Added option to set style from style listbox when single
clicking or not. Changed DoSelection name to ApplyStyle. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41708 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -62,6 +62,7 @@ public:
 | 
			
		||||
    bool Eq(const wxRichTextStyleDefinition& def) const;
 | 
			
		||||
    void operator =(const wxRichTextStyleDefinition& def) { Copy(def); }
 | 
			
		||||
    bool operator ==(const wxRichTextStyleDefinition& def) const { return Eq(def); }
 | 
			
		||||
    virtual wxRichTextStyleDefinition* Clone() const = 0;
 | 
			
		||||
 | 
			
		||||
    /// The name of the style.
 | 
			
		||||
    void SetName(const wxString& name) { m_name = name; }
 | 
			
		||||
@@ -98,6 +99,8 @@ public:
 | 
			
		||||
        wxRichTextStyleDefinition(name) {}
 | 
			
		||||
    virtual ~wxRichTextCharacterStyleDefinition() {}
 | 
			
		||||
 | 
			
		||||
    virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextCharacterStyleDefinition(*this); }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -125,6 +128,8 @@ public:
 | 
			
		||||
    void operator =(const wxRichTextParagraphStyleDefinition& def) { Copy(def); }
 | 
			
		||||
    bool operator ==(const wxRichTextParagraphStyleDefinition& def) const;
 | 
			
		||||
 | 
			
		||||
    virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextParagraphStyleDefinition(*this); }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
 | 
			
		||||
    /// The next style to use when adding a paragraph after this style.
 | 
			
		||||
@@ -235,6 +240,7 @@ public:
 | 
			
		||||
    {
 | 
			
		||||
        m_styleSheet = NULL;
 | 
			
		||||
        m_richTextCtrl = NULL;
 | 
			
		||||
        m_applyOnSelection = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
 | 
			
		||||
@@ -263,8 +269,8 @@ public:
 | 
			
		||||
    /// Updates the list
 | 
			
		||||
    void UpdateStyles();
 | 
			
		||||
 | 
			
		||||
    /// Do selection
 | 
			
		||||
    void DoSelection(int i);
 | 
			
		||||
    /// Apply the style
 | 
			
		||||
    void ApplyStyle(int i);
 | 
			
		||||
 | 
			
		||||
    /// React to selection
 | 
			
		||||
    void OnSelect(wxCommandEvent& event);
 | 
			
		||||
@@ -287,6 +293,10 @@ public:
 | 
			
		||||
    /// Need to override this if being used in a combobox popup
 | 
			
		||||
    virtual bool CanAutoSetSelection() { return true; }
 | 
			
		||||
 | 
			
		||||
    /// Set whether the style should be applied as soon as the item is selected (the default)
 | 
			
		||||
    void SetApplyOnSelection(bool applyOnSel) { m_applyOnSelection = applyOnSel; }
 | 
			
		||||
    bool GetApplyOnSelection() const { return m_applyOnSelection; }
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    /// Returns the HTML for this item
 | 
			
		||||
    virtual wxString OnGetItem(size_t n) const;
 | 
			
		||||
@@ -295,6 +305,7 @@ private:
 | 
			
		||||
 | 
			
		||||
    wxRichTextStyleSheet*   m_styleSheet;
 | 
			
		||||
    wxRichTextCtrl*         m_richTextCtrl;
 | 
			
		||||
    bool                    m_applyOnSelection; // if true, applies style on selection
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#if wxUSE_COMBOCTRL
 | 
			
		||||
 
 | 
			
		||||
@@ -380,8 +380,8 @@ void wxRichTextStyleListBox::OnLeftDown(wxMouseEvent& event)
 | 
			
		||||
    wxVListBox::OnLeftDown(event);
 | 
			
		||||
 | 
			
		||||
    int item = HitTest(event.GetPosition());
 | 
			
		||||
    if (item != wxNOT_FOUND)
 | 
			
		||||
        DoSelection(item);
 | 
			
		||||
    if (item != wxNOT_FOUND && GetApplyOnSelection())
 | 
			
		||||
        ApplyStyle(item);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Auto-select from style under caret in idle time
 | 
			
		||||
@@ -429,7 +429,7 @@ void wxRichTextStyleListBox::OnIdle(wxIdleEvent& event)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/// Do selection
 | 
			
		||||
void wxRichTextStyleListBox::DoSelection(int item)
 | 
			
		||||
void wxRichTextStyleListBox::ApplyStyle(int item)
 | 
			
		||||
{
 | 
			
		||||
    if ( item != wxNOT_FOUND )
 | 
			
		||||
    {
 | 
			
		||||
@@ -508,11 +508,11 @@ void wxRichTextStyleComboPopup::OnMouseClick(wxMouseEvent& WXUNUSED(event))
 | 
			
		||||
        m_value = m_itemHere;
 | 
			
		||||
 | 
			
		||||
    // Ordering is important, so we don't dismiss this popup accidentally
 | 
			
		||||
    // by setting the focus elsewhere e.g. in DoSelection
 | 
			
		||||
    // by setting the focus elsewhere e.g. in ApplyStyle
 | 
			
		||||
    Dismiss();
 | 
			
		||||
 | 
			
		||||
    if (m_itemHere >= 0)
 | 
			
		||||
        wxRichTextStyleListBox::DoSelection(m_itemHere);
 | 
			
		||||
        wxRichTextStyleListBox::ApplyStyle(m_itemHere);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*!
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user