-/*!
- * wxTextAttrEx is an extended version of wxTextAttr with more paragraph attributes.
- */
-
-class WXDLLIMPEXP_ADV wxTextAttrEx: public wxTextAttr
-{
-public:
- // ctors
- wxTextAttrEx(const wxTextAttrEx& attr);
- wxTextAttrEx() { Init(); }
-
- // Initialise this object.
- void Init();
-
- // Assignment from a wxTextAttrEx object
- void operator= (const wxTextAttrEx& attr);
-
- // Assignment from a wxTextAttr object.
- 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; }
-
- const wxString& GetCharacterStyleName() const { return m_characterStyleName; }
- const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; }
- int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; }
- int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; }
- int GetLineSpacing() const { return m_lineSpacing; }
- int GetBulletStyle() const { return m_bulletStyle; }
- int GetBulletNumber() const { return m_bulletNumber; }
- wxChar GetBulletSymbol() const { return m_bulletSymbol; }
-
- 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 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); }
-
- // Is this a character style?
- bool IsCharacterStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR))); }
- bool IsParagraphStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|
- wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|
- wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER))); }
-
- // returns false if we have any attributes set, true otherwise
- bool IsDefault() const
- {
- return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() &&
- !HasTabs() && !HasLeftIndent() && !HasRightIndent() &&
- !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() &&
- !HasCharacterStyleName() && !HasParagraphStyleName() && !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol();
- }
-private:
- // Paragraph styles
- int m_paragraphSpacingAfter;
- int m_paragraphSpacingBefore;
- int m_lineSpacing;
- int m_bulletStyle;
- int m_bulletNumber;
- wxChar m_bulletSymbol;
-
- // Character style
- wxString m_characterStyleName;
-
- // Paragraph style
- wxString m_paragraphStyleName;
-};
-
-/*!
- * wxRichTextAttr stores attributes without a wxFont object, so is a much more
- * efficient way to query styles.
- */
-
-class WXDLLIMPEXP_ADV wxRichTextAttr
-{
-public:
- // ctors
- wxRichTextAttr(const wxTextAttrEx& attr);
- wxRichTextAttr() { Init(); }
- wxRichTextAttr(const wxColour& colText,
- const wxColour& colBack = wxNullColour,
- wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT);
-
- // Initialise this object.
- void Init();
-
- // Assignment from a wxRichTextAttr object.
- void operator= (const wxRichTextAttr& attr);
-
- // Assignment from a wxTextAttrEx object.
- void operator= (const wxTextAttrEx& attr);
-
- // Making a wxTextAttrEx object.
- operator wxTextAttrEx () const ;
-
- // Copy to a wxTextAttr
- void CopyTo(wxTextAttrEx& attr) const;
-
- // Create font from font attributes.
- wxFont CreateFont() const;
-
- // Get attributes from font.
- bool GetFontAttributes(const wxFont& font);
-
- // setters
- void SetTextColour(const wxColour& colText) { m_colText = colText; m_flags |= wxTEXT_ATTR_TEXT_COLOUR; }
- void SetBackgroundColour(const wxColour& colBack) { m_colBack = colBack; m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; }
- void SetAlignment(wxTextAttrAlignment alignment) { m_textAlignment = alignment; m_flags |= wxTEXT_ATTR_ALIGNMENT; }
- void SetTabs(const wxArrayInt& tabs) { m_tabs = tabs; m_flags |= wxTEXT_ATTR_TABS; }
- void SetLeftIndent(int indent, int subIndent = 0) { m_leftIndent = indent; m_leftSubIndent = subIndent; m_flags |= wxTEXT_ATTR_LEFT_INDENT; }
- void SetRightIndent(int indent) { m_rightIndent = indent; m_flags |= wxTEXT_ATTR_RIGHT_INDENT; }
-
- void SetFontSize(int pointSize) { m_fontSize = pointSize; m_flags |= wxTEXT_ATTR_FONT_SIZE; }
- void SetFontStyle(int fontStyle) { m_fontStyle = fontStyle; m_flags |= wxTEXT_ATTR_FONT_ITALIC; }
- void SetFontWeight(int fontWeight) { m_fontWeight = fontWeight; m_flags |= wxTEXT_ATTR_FONT_WEIGHT; }
- void SetFontFaceName(const wxString& faceName) { m_fontFaceName = faceName; m_flags |= wxTEXT_ATTR_FONT_FACE; }
- void SetFontUnderlined(bool underlined) { m_fontUnderlined = underlined; m_flags |= wxTEXT_ATTR_FONT_UNDERLINE; }
-
- 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; }
-
- const wxColour& GetTextColour() const { return m_colText; }
- const wxColour& GetBackgroundColour() const { return m_colBack; }
- wxTextAttrAlignment GetAlignment() const { return m_textAlignment; }
- const wxArrayInt& GetTabs() const { return m_tabs; }
- long GetLeftIndent() const { return m_leftIndent; }
- long GetLeftSubIndent() const { return m_leftSubIndent; }
- long GetRightIndent() const { return m_rightIndent; }
- long GetFlags() const { return m_flags; }
-
- int GetFontSize() const { return m_fontSize; }
- int GetFontStyle() const { return m_fontStyle; }
- int GetFontWeight() const { return m_fontWeight; }
- bool GetFontUnderlined() const { return m_fontUnderlined; }
- const wxString& GetFontFaceName() const { return m_fontFaceName; }
-
- const wxString& GetCharacterStyleName() const { return m_characterStyleName; }
- const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; }
- int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; }
- int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; }
- int GetLineSpacing() const { return m_lineSpacing; }
- int GetBulletStyle() const { return m_bulletStyle; }
- int GetBulletNumber() const { return m_bulletNumber; }
- wxChar GetBulletSymbol() const { return m_bulletSymbol; }
-
- // accessors
- bool HasTextColour() const { return m_colText.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; }
- bool HasBackgroundColour() const { return m_colBack.Ok() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR) ; }
- bool HasAlignment() const { return (m_textAlignment != wxTEXT_ALIGNMENT_DEFAULT) || ((m_flags & wxTEXT_ATTR_ALIGNMENT) != 0) ; }
- bool HasTabs() const { return (m_flags & wxTEXT_ATTR_TABS) != 0 ; }
- bool HasLeftIndent() const { return (m_flags & wxTEXT_ATTR_LEFT_INDENT) != 0 ; }
- bool HasRightIndent() const { return (m_flags & wxTEXT_ATTR_RIGHT_INDENT) != 0 ; }
- bool HasWeight() const { return (m_flags & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
- bool HasSize() const { return (m_flags & wxTEXT_ATTR_FONT_SIZE) != 0; }
- bool HasItalic() const { return (m_flags & wxTEXT_ATTR_FONT_ITALIC) != 0; }
- bool HasUnderlined() const { return (m_flags & wxTEXT_ATTR_FONT_UNDERLINE) != 0; }
- bool HasFaceName() const { return (m_flags & wxTEXT_ATTR_FONT_FACE) != 0; }
- bool HasFont() const { return (m_flags & (wxTEXT_ATTR_FONT)) != 0; }
-
- 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 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; }
-
- bool HasFlag(long flag) const { return (m_flags & flag) != 0; }
-
- // Is this a character style?
- bool IsCharacterStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR))); }
- bool IsParagraphStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|
- wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|
- wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER))); }
-
- // returns false if we have any attributes set, true otherwise
- bool IsDefault() const
- {
- return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() &&
- !HasTabs() && !HasLeftIndent() && !HasRightIndent() &&
- !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() &&
- !HasCharacterStyleName() && !HasParagraphStyleName() && !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol();
- }
-
-private:
- long m_flags;
-
- // Paragraph styles
- wxArrayInt m_tabs; // array of int: tab stops in 1/10 mm
- int m_leftIndent; // left indent in 1/10 mm
- int m_leftSubIndent; // left indent for all but the first
- // line in a paragraph relative to the
- // first line, in 1/10 mm
- int m_rightIndent; // right indent in 1/10 mm
- wxTextAttrAlignment m_textAlignment;
-
- int m_paragraphSpacingAfter;
- int m_paragraphSpacingBefore;
- int m_lineSpacing;
- int m_bulletStyle;
- int m_bulletNumber;
- wxChar m_bulletSymbol;
-
- // Character styles
- wxColour m_colText,
- m_colBack;
- int m_fontSize;
- int m_fontStyle;
- int m_fontWeight;
- bool m_fontUnderlined;
- wxString m_fontFaceName;
-
- // Character style
- wxString m_characterStyleName;
-
- // Paragraph style
- wxString m_paragraphStyleName;
-};
-
-#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR)
-
-#define wxTEXT_ATTR_PARAGRAPH (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\
- wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\
- wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_SYMBOL)
-
-#define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
-