X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3b2cb4316b4deca34ae451493449e97e4bdb3f3b..22a35096a0a9c3fe4d3d32b8d68a361126ef9677:/include/wx/richtext/richtextbuffer.h diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index aaefaa3ccd..0e90377f23 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -263,6 +263,7 @@ class WXDLLIMPEXP_RICHTEXT wxTextAttrEx: public wxTextAttr public: // ctors wxTextAttrEx(const wxTextAttrEx& attr); + wxTextAttrEx(const wxTextAttr& attr) { Init(); (*this) = attr; } wxTextAttrEx() { Init(); } // Initialise this object. @@ -275,14 +276,14 @@ public: void operator= (const wxTextAttr& attr); // setters - void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; } - void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; } - void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; } - void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; } - void SetLineSpacing(int spacing) { m_lineSpacing = spacing; } - void SetBulletStyle(int style) { m_bulletStyle = style; } - void SetBulletNumber(int n) { m_bulletNumber = n; } - void SetBulletSymbol(wxChar symbol) { m_bulletSymbol = symbol; } + void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_CHARACTER_STYLE_NAME); } + void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_PARAGRAPH_STYLE_NAME); } + void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_AFTER); } + void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_BEFORE); } + void SetLineSpacing(int spacing) { m_lineSpacing = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_LINE_SPACING); } + void SetBulletStyle(int style) { m_bulletStyle = style; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_STYLE); } + void SetBulletNumber(int n) { m_bulletNumber = n; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NUMBER); } + void SetBulletSymbol(wxChar symbol) { m_bulletSymbol = symbol; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_SYMBOL); } const wxString& GetCharacterStyleName() const { return m_characterStyleName; } const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; } @@ -293,11 +294,17 @@ public: int GetBulletNumber() const { return m_bulletNumber; } wxChar GetBulletSymbol() const { return m_bulletSymbol; } + bool HasWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; } + bool HasSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; } + bool HasItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC) != 0; } + bool HasUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } + bool HasFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE) != 0; } + bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER); } bool HasParagraphSpacingBefore() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE); } bool HasLineSpacing() const { return HasFlag(wxTEXT_ATTR_LINE_SPACING); } - bool HasCharacterStyleName() const { return HasFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME); } - bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME); } + bool HasCharacterStyleName() const { return HasFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME) || !m_characterStyleName.IsEmpty(); } + bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) || !m_paragraphStyleName.IsEmpty(); } bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE); } bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER); } bool HasBulletSymbol() const { return HasFlag(wxTEXT_ATTR_BULLET_SYMBOL); } @@ -316,6 +323,14 @@ public: !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() && !HasCharacterStyleName() && !HasParagraphStyleName() && !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol(); } + + // return the attribute having the valid font and colours: it uses the + // attributes set in attr and falls back first to attrDefault and then to + // the text control font/colours for those attributes which are not set + static wxTextAttrEx CombineEx(const wxTextAttrEx& attr, + const wxTextAttrEx& attrDef, + const wxTextCtrlBase *text); + private: // Paragraph styles int m_paragraphSpacingAfter; @@ -384,14 +399,14 @@ public: void SetFlags(long flags) { m_flags = flags; } - void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; } - void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; } - void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; } - void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; } - void SetLineSpacing(int spacing) { m_lineSpacing = spacing; } - void SetBulletStyle(int style) { m_bulletStyle = style; } - void SetBulletNumber(int n) { m_bulletNumber = n; } - void SetBulletSymbol(wxChar symbol) { m_bulletSymbol = symbol; } + void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; m_flags |= wxTEXT_ATTR_CHARACTER_STYLE_NAME; } + void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; m_flags |= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME; } + void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_AFTER; } + void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_BEFORE; } + void SetLineSpacing(int spacing) { m_lineSpacing = spacing; m_flags |= wxTEXT_ATTR_LINE_SPACING; } + void SetBulletStyle(int style) { m_bulletStyle = style; m_flags |= wxTEXT_ATTR_BULLET_STYLE; } + void SetBulletNumber(int n) { m_bulletNumber = n; m_flags |= wxTEXT_ATTR_BULLET_NUMBER; } + void SetBulletSymbol(wxChar symbol) { m_bulletSymbol = symbol; m_flags |= wxTEXT_ATTR_BULLET_NUMBER; } const wxColour& GetTextColour() const { return m_colText; } const wxColour& GetBackgroundColour() const { return m_colBack; } @@ -434,8 +449,8 @@ public: bool HasParagraphSpacingAfter() const { return (m_flags & wxTEXT_ATTR_PARA_SPACING_AFTER) != 0; } bool HasParagraphSpacingBefore() const { return (m_flags & wxTEXT_ATTR_PARA_SPACING_BEFORE) != 0; } bool HasLineSpacing() const { return (m_flags & wxTEXT_ATTR_LINE_SPACING) != 0; } - bool HasCharacterStyleName() const { return (m_flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) != 0; } - bool HasParagraphStyleName() const { return (m_flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) != 0; } + bool HasCharacterStyleName() const { return (m_flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) != 0 || !m_characterStyleName.IsEmpty(); } + bool HasParagraphStyleName() const { return (m_flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) != 0 || !m_paragraphStyleName.IsEmpty(); } bool HasBulletStyle() const { return (m_flags & wxTEXT_ATTR_BULLET_STYLE) != 0; } bool HasBulletNumber() const { return (m_flags & wxTEXT_ATTR_BULLET_NUMBER) != 0; } bool HasBulletSymbol() const { return (m_flags & wxTEXT_ATTR_BULLET_SYMBOL) != 0; } @@ -457,6 +472,12 @@ public: !HasCharacterStyleName() && !HasParagraphStyleName() && !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol(); } + // return the attribute having the valid font and colours: it uses the + // attributes set in attr and falls back first to attrDefault and then to + // the text control font/colours for those attributes which are not set + static wxRichTextAttr Combine(const wxRichTextAttr& attr, + const wxRichTextAttr& attrDef, + const wxTextCtrlBase *text); private: long m_flags; @@ -512,7 +533,7 @@ public: // Constructors wxRichTextObject(wxRichTextObject* parent = NULL); - ~wxRichTextObject(); + virtual ~wxRichTextObject(); // Overrideables @@ -665,7 +686,7 @@ public: // Constructors wxRichTextCompositeObject(wxRichTextObject* parent = NULL); - ~wxRichTextCompositeObject(); + virtual ~wxRichTextCompositeObject(); // Overrideables @@ -1089,7 +1110,7 @@ public: wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL); wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL); - ~wxRichTextParagraph(); + virtual ~wxRichTextParagraph(); wxRichTextParagraph(const wxRichTextParagraph& obj):wxRichTextBox() { Copy(obj); } // Overrideables @@ -1259,7 +1280,7 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock: public wxObject public: wxRichTextImageBlock(); wxRichTextImageBlock(const wxRichTextImageBlock& block); - ~wxRichTextImageBlock(); + virtual ~wxRichTextImageBlock(); void Init(); void Clear(); @@ -1406,7 +1427,7 @@ public: wxRichTextBuffer() { Init(); } wxRichTextBuffer(const wxRichTextBuffer& obj):wxRichTextParagraphLayoutBox() { Init(); Copy(obj); } - ~wxRichTextBuffer() ; + virtual ~wxRichTextBuffer() ; // Accessors @@ -1707,7 +1728,7 @@ public: // Ctor for multiple actions wxRichTextCommand(const wxString& name); - ~wxRichTextCommand(); + virtual ~wxRichTextCommand(); bool Do(); bool Undo(); @@ -1733,7 +1754,7 @@ public: wxRichTextAction(wxRichTextCommand* cmd, const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, wxRichTextCtrl* ctrl, bool ignoreFirstTime = false); - ~wxRichTextAction(); + virtual ~wxRichTextAction(); bool Do(); bool Undo();