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;
 | 
					    bool Eq(const wxRichTextStyleDefinition& def) const;
 | 
				
			||||||
    void operator =(const wxRichTextStyleDefinition& def) { Copy(def); }
 | 
					    void operator =(const wxRichTextStyleDefinition& def) { Copy(def); }
 | 
				
			||||||
    bool operator ==(const wxRichTextStyleDefinition& def) const { return Eq(def); }
 | 
					    bool operator ==(const wxRichTextStyleDefinition& def) const { return Eq(def); }
 | 
				
			||||||
 | 
					    virtual wxRichTextStyleDefinition* Clone() const = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The name of the style.
 | 
					    /// The name of the style.
 | 
				
			||||||
    void SetName(const wxString& name) { m_name = name; }
 | 
					    void SetName(const wxString& name) { m_name = name; }
 | 
				
			||||||
@@ -98,6 +99,8 @@ public:
 | 
				
			|||||||
        wxRichTextStyleDefinition(name) {}
 | 
					        wxRichTextStyleDefinition(name) {}
 | 
				
			||||||
    virtual ~wxRichTextCharacterStyleDefinition() {}
 | 
					    virtual ~wxRichTextCharacterStyleDefinition() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextCharacterStyleDefinition(*this); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -125,6 +128,8 @@ public:
 | 
				
			|||||||
    void operator =(const wxRichTextParagraphStyleDefinition& def) { Copy(def); }
 | 
					    void operator =(const wxRichTextParagraphStyleDefinition& def) { Copy(def); }
 | 
				
			||||||
    bool operator ==(const wxRichTextParagraphStyleDefinition& def) const;
 | 
					    bool operator ==(const wxRichTextParagraphStyleDefinition& def) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextParagraphStyleDefinition(*this); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// The next style to use when adding a paragraph after this style.
 | 
					    /// The next style to use when adding a paragraph after this style.
 | 
				
			||||||
@@ -235,6 +240,7 @@ public:
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        m_styleSheet = NULL;
 | 
					        m_styleSheet = NULL;
 | 
				
			||||||
        m_richTextCtrl = NULL;
 | 
					        m_richTextCtrl = NULL;
 | 
				
			||||||
 | 
					        m_applyOnSelection = true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
 | 
					    bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
 | 
				
			||||||
@@ -263,8 +269,8 @@ public:
 | 
				
			|||||||
    /// Updates the list
 | 
					    /// Updates the list
 | 
				
			||||||
    void UpdateStyles();
 | 
					    void UpdateStyles();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// Do selection
 | 
					    /// Apply the style
 | 
				
			||||||
    void DoSelection(int i);
 | 
					    void ApplyStyle(int i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /// React to selection
 | 
					    /// React to selection
 | 
				
			||||||
    void OnSelect(wxCommandEvent& event);
 | 
					    void OnSelect(wxCommandEvent& event);
 | 
				
			||||||
@@ -287,6 +293,10 @@ public:
 | 
				
			|||||||
    /// Need to override this if being used in a combobox popup
 | 
					    /// Need to override this if being used in a combobox popup
 | 
				
			||||||
    virtual bool CanAutoSetSelection() { return true; }
 | 
					    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:
 | 
					protected:
 | 
				
			||||||
    /// Returns the HTML for this item
 | 
					    /// Returns the HTML for this item
 | 
				
			||||||
    virtual wxString OnGetItem(size_t n) const;
 | 
					    virtual wxString OnGetItem(size_t n) const;
 | 
				
			||||||
@@ -295,6 +305,7 @@ private:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    wxRichTextStyleSheet*   m_styleSheet;
 | 
					    wxRichTextStyleSheet*   m_styleSheet;
 | 
				
			||||||
    wxRichTextCtrl*         m_richTextCtrl;
 | 
					    wxRichTextCtrl*         m_richTextCtrl;
 | 
				
			||||||
 | 
					    bool                    m_applyOnSelection; // if true, applies style on selection
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if wxUSE_COMBOCTRL
 | 
					#if wxUSE_COMBOCTRL
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -380,8 +380,8 @@ void wxRichTextStyleListBox::OnLeftDown(wxMouseEvent& event)
 | 
				
			|||||||
    wxVListBox::OnLeftDown(event);
 | 
					    wxVListBox::OnLeftDown(event);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int item = HitTest(event.GetPosition());
 | 
					    int item = HitTest(event.GetPosition());
 | 
				
			||||||
    if (item != wxNOT_FOUND)
 | 
					    if (item != wxNOT_FOUND && GetApplyOnSelection())
 | 
				
			||||||
        DoSelection(item);
 | 
					        ApplyStyle(item);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Auto-select from style under caret in idle time
 | 
					/// Auto-select from style under caret in idle time
 | 
				
			||||||
@@ -429,7 +429,7 @@ void wxRichTextStyleListBox::OnIdle(wxIdleEvent& event)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// Do selection
 | 
					/// Do selection
 | 
				
			||||||
void wxRichTextStyleListBox::DoSelection(int item)
 | 
					void wxRichTextStyleListBox::ApplyStyle(int item)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if ( item != wxNOT_FOUND )
 | 
					    if ( item != wxNOT_FOUND )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@@ -508,11 +508,11 @@ void wxRichTextStyleComboPopup::OnMouseClick(wxMouseEvent& WXUNUSED(event))
 | 
				
			|||||||
        m_value = m_itemHere;
 | 
					        m_value = m_itemHere;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Ordering is important, so we don't dismiss this popup accidentally
 | 
					    // 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();
 | 
					    Dismiss();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (m_itemHere >= 0)
 | 
					    if (m_itemHere >= 0)
 | 
				
			||||||
        wxRichTextStyleListBox::DoSelection(m_itemHere);
 | 
					        wxRichTextStyleListBox::ApplyStyle(m_itemHere);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*!
 | 
					/*!
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user