X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/38f833b10c071603eb8d7739ab31b1c07c4576f1..5b464d6bbd088e122bca53f2a4a4ce1f09378de4:/include/wx/richtext/richtextstyles.h diff --git a/include/wx/richtext/richtextstyles.h b/include/wx/richtext/richtextstyles.h index f16a3b6cf1..fb5557b6fd 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,19 +85,27 @@ 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 - void SetStyle(const wxRichTextAttr& style) { m_style = style; } - const wxRichTextAttr& GetStyle() const { return m_style; } - wxRichTextAttr& GetStyle() { return m_style; } + /// Sets and gets the style + void SetStyle(const wxTextAttr& style) { m_style = style; } + const wxTextAttr& GetStyle() const { return m_style; } + wxTextAttr& GetStyle() { return m_style; } + + /// Gets the style combined with the base style + virtual wxTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const; protected: wxString m_name; wxString m_baseStyle; - wxRichTextAttr m_style; + wxString m_description; + wxTextAttr 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 wxTextAttr& attr); + wxTextAttr* GetLevelAttributes(int i); + const wxTextAttr* 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); + wxTextAttr CombineWithParagraphStyle(int indent, const wxTextAttr& 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); + wxTextAttr 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); + wxTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL); /// Gets the number of available levels int GetLevelCount() const { return 10; } @@ -229,7 +237,7 @@ public: protected: /// The styles for each level (up to 10) - wxTextAttrEx m_levelStyles[10]; + wxTextAttr m_levelStyles[10]; }; /*! @@ -245,6 +253,7 @@ public: wxRichTextStyleSheet(const wxRichTextStyleSheet& sheet) : wxObject() { + Init(); Copy(sheet); } wxRichTextStyleSheet() { Init(); } @@ -271,6 +280,9 @@ public: /// Add a definition to the list style list bool AddListStyle(wxRichTextListStyleDefinition* 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 +292,9 @@ public: /// Remove a list style bool RemoveListStyle(wxRichTextStyleDefinition* def, bool deleteStyle = false) { return RemoveStyle(m_listStyleDefinitions, 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 +304,9 @@ public: /// Find a list definition by name wxRichTextListStyleDefinition* FindListStyle(const wxString& name, bool recurse = true) const { return (wxRichTextListStyleDefinition*) FindStyle(m_listStyleDefinitions, 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(); } @@ -327,6 +345,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 +366,15 @@ public: protected: - wxList m_characterStyleDefinitions; - wxList m_paragraphStyleDefinitions; - wxList m_listStyleDefinitions; + wxString m_description; + wxString m_name; - wxRichTextStyleSheet* m_previousSheet; - wxRichTextStyleSheet* m_nextSheet; + wxList m_characterStyleDefinitions; + wxList m_paragraphStyleDefinitions; + wxList m_listStyleDefinitions; + + wxRichTextStyleSheet* m_previousSheet; + wxRichTextStyleSheet* m_nextSheet; }; #if wxUSE_HTML @@ -383,6 +412,7 @@ public: m_richTextCtrl = NULL; m_applyOnSelection = false; m_styleType = wxRICHTEXT_STYLE_PARAGRAPH; + m_autoSetSelection = true; } bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, @@ -391,7 +421,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; } @@ -414,9 +444,6 @@ public: /// Apply the style void ApplyStyle(int i); - /// React to selection - void OnSelect(wxCommandEvent& event); - /// Left click void OnLeftDown(wxMouseEvent& event); @@ -431,7 +458,8 @@ public: /// Can we set the selection based on the editor caret position? /// Need to override this if being used in a combobox popup - virtual bool CanAutoSetSelection() { return true; } + virtual bool CanAutoSetSelection() { return m_autoSetSelection; } + virtual void SetAutoSetSelection(bool autoSet) { m_autoSetSelection = autoSet; } /// Set whether the style should be applied as soon as the item is selected (the default) void SetApplyOnSelection(bool applyOnSel) { m_applyOnSelection = applyOnSel; } @@ -454,6 +482,8 @@ private: wxRichTextCtrl* m_richTextCtrl; bool m_applyOnSelection; // if true, applies style on selection wxRichTextStyleType m_styleType; // style type to display + bool m_autoSetSelection; + wxArrayString m_styleNames; }; /*! @@ -462,6 +492,8 @@ private: * style types. */ +#define wxRICHTEXTSTYLELIST_HIDE_TYPE_SELECTOR 0x1000 + class WXDLLIMPEXP_RICHTEXT wxRichTextStyleListCtrl: public wxControl { DECLARE_CLASS(wxRichTextStyleListCtrl) @@ -493,7 +525,10 @@ public: bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0); - /// Associates the control with a style manager + /// Updates the style list box + void UpdateStyles(); + + /// Associates the control with a style sheet void SetStyleSheet(wxRichTextStyleSheet* styleSheet); wxRichTextStyleSheet* GetStyleSheet() const; @@ -501,9 +536,6 @@ public: void SetRichTextCtrl(wxRichTextCtrl* ctrl); wxRichTextCtrl* GetRichTextCtrl() const; - /// Updates the style list box - void UpdateStyles(); - /// Set/get the style type to display void SetStyleType(wxRichTextStyleListBox::wxRichTextStyleType styleType); wxRichTextStyleListBox::wxRichTextStyleType GetStyleType() const; @@ -548,12 +580,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; } @@ -620,7 +647,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(); }