X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe5aa22c174da89809b6c5d27e60300df0b879ac..deb325e3b21d956705214520b172ae8bf898a1ae:/include/wx/richtext/richtextstyles.h diff --git a/include/wx/richtext/richtextstyles.h b/include/wx/richtext/richtextstyles.h index 89672946ed..d903fccb86 100644 --- a/include/wx/richtext/richtextstyles.h +++ b/include/wx/richtext/richtextstyles.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: richtextstyles.h +// Name: wx/richtext/richtextstyles.h // Purpose: Style management for wxRichTextCtrl // Author: Julian Smart // Modified by: @@ -16,10 +16,12 @@ * Includes */ -#include "wx/richtext/richtextbuffer.h" +#include "wx/defs.h" #if wxUSE_RICHTEXT +#include "wx/richtext/richtextbuffer.h" + #if wxUSE_HTML #include "wx/htmllbox.h" #endif @@ -47,7 +49,11 @@ public: // Constructors - wxRichTextStyleDefinition(const wxRichTextStyleDefinition& def) { Copy(def); } + wxRichTextStyleDefinition(const wxRichTextStyleDefinition& def) + : wxObject() + { + Copy(def); + } wxRichTextStyleDefinition(const wxString& name = wxEmptyString) { Init(); m_name = name; } virtual ~wxRichTextStyleDefinition() {} @@ -56,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; } @@ -92,6 +99,8 @@ public: wxRichTextStyleDefinition(name) {} virtual ~wxRichTextCharacterStyleDefinition() {} + virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextCharacterStyleDefinition(*this); } + protected: }; @@ -119,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. @@ -135,7 +146,11 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet: public wxObject public: /// Constructors - wxRichTextStyleSheet(const wxRichTextStyleSheet& sheet) { Copy(sheet); } + wxRichTextStyleSheet(const wxRichTextStyleSheet& sheet) + : wxObject() + { + Copy(sheet); + } wxRichTextStyleSheet() { Init(); } virtual ~wxRichTextStyleSheet() { DeleteStyles(); } @@ -225,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, @@ -253,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); @@ -277,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; @@ -285,6 +305,7 @@ private: wxRichTextStyleSheet* m_styleSheet; wxRichTextCtrl* m_richTextCtrl; + bool m_applyOnSelection; // if true, applies style on selection }; #if wxUSE_COMBOCTRL