X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dadd4f5523e6ab9b489632f478958cd6dc8d03aa..8770af492aec443f8016c27ff46cbb01cd2e8357:/include/wx/richtext/richtextstyles.h?ds=sidebyside diff --git a/include/wx/richtext/richtextstyles.h b/include/wx/richtext/richtextstyles.h index a9c45d2009..e639144f7c 100644 --- a/include/wx/richtext/richtextstyles.h +++ b/include/wx/richtext/richtextstyles.h @@ -4,7 +4,7 @@ // Author: Julian Smart // Modified by: // Created: 2005-09-30 -// RCS-ID: +// RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -36,8 +36,8 @@ * Forward declarations */ -class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl; -class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer; +class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCtrl; +class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextBuffer; /*! * wxRichTextStyleDefinition class declaration @@ -85,18 +85,26 @@ public: void SetName(const wxString& name) { m_name = name; } const wxString& GetName() const { return m_name; } + /// Sets and gets the style description + void SetDescription(const wxString& descr) { m_description = descr; } + const wxString& GetDescription() const { return m_description; } + /// Sets and gets the name of the style that this style is based on void SetBaseStyle(const wxString& name) { m_baseStyle = name; } const wxString& GetBaseStyle() const { return m_baseStyle; } - /// Sets the style + /// Sets and gets the style void SetStyle(const wxRichTextAttr& style) { m_style = style; } const wxRichTextAttr& GetStyle() const { return m_style; } wxRichTextAttr& GetStyle() { return m_style; } + /// Gets the style combined with the base style + virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const; + protected: wxString m_name; wxString m_baseStyle; + wxString m_description; wxRichTextAttr m_style; }; @@ -198,9 +206,9 @@ public: virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextListStyleDefinition(*this); } /// Sets/gets the attributes for the given level - void SetLevelAttributes(int i, const wxTextAttrEx& attr); - wxTextAttrEx* GetLevelAttributes(int i); - const wxTextAttrEx* GetLevelAttributes(int i) const; + void SetLevelAttributes(int i, const wxRichTextAttr& attr); + wxRichTextAttr* GetLevelAttributes(int i); + const wxRichTextAttr* GetLevelAttributes(int i) const; /// Convenience function for setting the major attributes for a list level specification void SetAttributes(int i, int leftIndent, int leftSubIndent, int bulletStyle, const wxString& bulletSymbol = wxEmptyString); @@ -210,15 +218,15 @@ public: /// Combine the base and list style with a paragraph style, using the given indent (from which /// an appropriate level is found) - wxTextAttrEx CombineWithParagraphStyle(int indent, const wxTextAttrEx& paraStyle); + wxRichTextAttr CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet = NULL); /// Combine the base and list style, using the given indent (from which /// an appropriate level is found) - wxTextAttrEx GetCombinedStyle(int indent); + wxRichTextAttr GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet = NULL); /// Combine the base and list style, using the given level from which /// an appropriate level is found) - wxTextAttrEx GetCombinedStyleForLevel(int level); + wxRichTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL); /// Gets the number of available levels int GetLevelCount() const { return 10; } @@ -229,7 +237,41 @@ public: protected: /// The styles for each level (up to 10) - wxTextAttrEx m_levelStyles[10]; + wxRichTextAttr m_levelStyles[10]; +}; + +/*! + * wxRichTextBoxStyleDefinition class declaration, for box attributes in objects such as wxRichTextBox. + */ + +class WXDLLIMPEXP_RICHTEXT wxRichTextBoxStyleDefinition: public wxRichTextStyleDefinition +{ + DECLARE_DYNAMIC_CLASS(wxRichTextBoxStyleDefinition) +public: + + /// Copy constructor + wxRichTextBoxStyleDefinition(const wxRichTextBoxStyleDefinition& def): wxRichTextStyleDefinition(def) { Copy(def); } + + /// Default constructor + wxRichTextBoxStyleDefinition(const wxString& name = wxEmptyString): + wxRichTextStyleDefinition(name) {} + + // Destructor + virtual ~wxRichTextBoxStyleDefinition() {} + + /// Copies from def + void Copy(const wxRichTextBoxStyleDefinition& def); + + /// Assignment operator + void operator =(const wxRichTextBoxStyleDefinition& def) { Copy(def); } + + /// Equality operator + bool operator ==(const wxRichTextBoxStyleDefinition& def) const; + + /// Clones the object + virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextBoxStyleDefinition(*this); } + +protected: }; /*! @@ -245,6 +287,7 @@ public: wxRichTextStyleSheet(const wxRichTextStyleSheet& sheet) : wxObject() { + Init(); Copy(sheet); } wxRichTextStyleSheet() { Init(); } @@ -271,6 +314,12 @@ public: /// Add a definition to the list style list bool AddListStyle(wxRichTextListStyleDefinition* def); + /// Add a definition to the box style list + bool AddBoxStyle(wxRichTextBoxStyleDefinition* def); + + /// Add a definition to the appropriate style list + bool AddStyle(wxRichTextStyleDefinition* def); + /// Remove a character style bool RemoveCharacterStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_characterStyleDefinitions, def, deleteStyle); } @@ -280,6 +329,12 @@ public: /// Remove a list style bool RemoveListStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_listStyleDefinitions, def, deleteStyle); } + /// Remove a box style + bool RemoveBoxStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_boxStyleDefinitions, def, deleteStyle); } + + /// Remove a style + bool RemoveStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false); + /// Find a character definition by name wxRichTextCharacterStyleDefinition* FindCharacterStyle(const wxString& name, bool recurse = true) const { return (wxRichTextCharacterStyleDefinition*) FindStyle(m_characterStyleDefinitions, name, recurse); } @@ -289,6 +344,12 @@ public: /// Find a list definition by name wxRichTextListStyleDefinition* FindListStyle(const wxString& name, bool recurse = true) const { return (wxRichTextListStyleDefinition*) FindStyle(m_listStyleDefinitions, name, recurse); } + /// Find a box definition by name + wxRichTextBoxStyleDefinition* FindBoxStyle(const wxString& name, bool recurse = true) const { return (wxRichTextBoxStyleDefinition*) FindStyle(m_boxStyleDefinitions, name, recurse); } + + /// Find any definition by name + wxRichTextStyleDefinition* FindStyle(const wxString& name, bool recurse = true) const; + /// Return the number of character styles size_t GetCharacterStyleCount() const { return m_characterStyleDefinitions.GetCount(); } @@ -298,6 +359,9 @@ public: /// Return the number of list styles size_t GetListStyleCount() const { return m_listStyleDefinitions.GetCount(); } + /// Return the number of box styles + size_t GetBoxStyleCount() const { return m_boxStyleDefinitions.GetCount(); } + /// Return the nth character style wxRichTextCharacterStyleDefinition* GetCharacterStyle(size_t n) const { return (wxRichTextCharacterStyleDefinition*) m_characterStyleDefinitions.Item(n)->GetData(); } @@ -307,6 +371,9 @@ public: /// Return the nth list style wxRichTextListStyleDefinition* GetListStyle(size_t n) const { return (wxRichTextListStyleDefinition*) m_listStyleDefinitions.Item(n)->GetData(); } + /// Return the nth box style + wxRichTextBoxStyleDefinition* GetBoxStyle(size_t n) const { return (wxRichTextBoxStyleDefinition*) m_boxStyleDefinitions.Item(n)->GetData(); } + /// Delete all styles void DeleteStyles(); @@ -327,6 +394,14 @@ public: wxRichTextStyleSheet* GetPreviousSheet() const { return m_previousSheet; } void SetPreviousSheet(wxRichTextStyleSheet* sheet) { m_previousSheet = sheet; } + /// Sets and gets the name of the style sheet + void SetName(const wxString& name) { m_name = name; } + const wxString& GetName() const { return m_name; } + + /// Sets and gets the style description + void SetDescription(const wxString& descr) { m_description = descr; } + const wxString& GetDescription() const { return m_description; } + /// Implementation /// Add a definition to one of the style lists @@ -340,12 +415,16 @@ public: protected: - wxList m_characterStyleDefinitions; - wxList m_paragraphStyleDefinitions; - wxList m_listStyleDefinitions; + wxString m_description; + wxString m_name; + + wxList m_characterStyleDefinitions; + wxList m_paragraphStyleDefinitions; + wxList m_listStyleDefinitions; + wxList m_boxStyleDefinitions; - wxRichTextStyleSheet* m_previousSheet; - wxRichTextStyleSheet* m_nextSheet; + wxRichTextStyleSheet* m_previousSheet; + wxRichTextStyleSheet* m_nextSheet; }; #if wxUSE_HTML @@ -366,7 +445,8 @@ public: wxRICHTEXT_STYLE_ALL, wxRICHTEXT_STYLE_PARAGRAPH, wxRICHTEXT_STYLE_CHARACTER, - wxRICHTEXT_STYLE_LIST + wxRICHTEXT_STYLE_LIST, + wxRICHTEXT_STYLE_BOX }; wxRichTextStyleListBox() @@ -392,7 +472,7 @@ public: /// Creates a suitable HTML fragment for a definition wxString CreateHTML(wxRichTextStyleDefinition* def) const; - /// Associates the control with a style manager + /// Associates the control with a style sheet void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { m_styleSheet = styleSheet; } wxRichTextStyleSheet* GetStyleSheet() const { return m_styleSheet; } @@ -454,6 +534,7 @@ private: bool m_applyOnSelection; // if true, applies style on selection wxRichTextStyleType m_styleType; // style type to display bool m_autoSetSelection; + wxArrayString m_styleNames; }; /*! @@ -498,7 +579,7 @@ public: /// Updates the style list box void UpdateStyles(); - /// Associates the control with a style manager + /// Associates the control with a style sheet void SetStyleSheet(wxRichTextStyleSheet* styleSheet); wxRichTextStyleSheet* GetStyleSheet() const; @@ -550,12 +631,7 @@ public: m_value = -1; } - virtual bool Create( wxWindow* parent ) - { - return wxRichTextStyleListBox::Create(parent, wxID_ANY, - wxPoint(0,0), wxDefaultSize, - wxSIMPLE_BORDER); - } + virtual bool Create( wxWindow* parent ); virtual wxWindow *GetControl() { return this; } @@ -622,7 +698,7 @@ public: /// Updates the list void UpdateStyles() { m_stylePopup->UpdateStyles(); } - /// Associates the control with a style manager + /// Associates the control with a style sheet void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { m_stylePopup->SetStyleSheet(styleSheet); } wxRichTextStyleSheet* GetStyleSheet() const { return m_stylePopup->GetStyleSheet(); }