From 44cc96a80c09c8572e1315be66d29f6d610cbf78 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 9 Oct 2007 11:20:36 +0000 Subject: [PATCH] Merged wxRichTextAttr and wxTextAttrEx into wxTextAttr, and added a font table to wxRichTextBuffer to reduce wxFont consumption and increase performance. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49108 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 20 +- docs/latex/wx/category.tex | 1 - docs/latex/wx/classes.tex | 2 - docs/latex/wx/richtextbuffer.tex | 28 +- docs/latex/wx/richtextctrl.tex | 69 +- docs/latex/wx/richtextformattingdialog.tex | 10 +- docs/latex/wx/richtextliststyledefinition.tex | 12 +- docs/latex/wx/richtextoverview.tex | 18 +- docs/latex/wx/richtextstyledefinition.tex | 8 +- docs/latex/wx/richtextxmlhandler.tex | 4 +- docs/latex/wx/symbolpickerdialog.tex | 2 +- docs/latex/wx/{richtextattr.tex => textattr.tex} | 349 ++-- docs/latex/wx/textattrex.tex | 555 ------ include/wx/richtext/richtextbuffer.h | 527 +----- include/wx/richtext/richtextbulletspage.h | 2 +- include/wx/richtext/richtextctrl.h | 42 +- include/wx/richtext/richtextfontpage.h | 2 +- include/wx/richtext/richtextformatdlg.h | 12 +- include/wx/richtext/richtexthtml.h | 14 +- include/wx/richtext/richtextindentspage.h | 2 +- include/wx/richtext/richtextliststylepage.h | 2 +- include/wx/richtext/richtextstylepage.h | 2 +- include/wx/richtext/richtextstyles.h | 26 +- include/wx/richtext/richtexttabspage.h | 2 +- include/wx/richtext/richtextxml.h | 4 +- include/wx/textctrl.h | 308 +++- samples/richtext/richtext.cpp | 18 +- src/common/textcmn.cpp | 543 +++++- src/gtk/textctrl.cpp | 12 +- src/gtk1/textctrl.cpp | 17 +- src/mac/carbon/textctrl.cpp | 8 +- src/msw/textctrl.cpp | 7 +- src/richtext/richtextbuffer.cpp | 2091 +++++----------------- src/richtext/richtextbulletspage.cpp | 10 +- src/richtext/richtextctrl.cpp | 117 +- src/richtext/richtextfontpage.cpp | 57 +- src/richtext/richtextformatdlg.cpp | 6 +- src/richtext/richtexthtml.cpp | 44 +- src/richtext/richtextindentspage.cpp | 14 +- src/richtext/richtextliststylepage.cpp | 14 +- src/richtext/richtextstyledlg.cpp | 8 +- src/richtext/richtextstylepage.cpp | 2 +- src/richtext/richtextstyles.cpp | 32 +- src/richtext/richtexttabspage.cpp | 6 +- src/richtext/richtextxml.cpp | 61 +- 45 files changed, 1733 insertions(+), 3357 deletions(-) rename docs/latex/wx/{richtextattr.tex => textattr.tex} (64%) delete mode 100644 docs/latex/wx/textattrex.tex diff --git a/docs/changes.txt b/docs/changes.txt index f172e17..bc46d45 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -187,16 +187,18 @@ All (GUI): - Show standard options in wxCmdLineParser usage message (Francesco Montorsi). - Added wxRect::operator+ (union) and * (intersection) (bdonner). - Added support for two auxiliary mouse buttons to wxMouseEvent (Chris Weiland). -- Added wxToolTip::SetAutoPop() and SetReshow() (Jan Knepper) -- Added wxTaskBarIcon::Destroy() -- Added XRC handler for wxSearchCtrl (Sander Berents) -- Read image resolution from TIFF, JPEG and BMP images (Maycon Aparecido Gasoto) -- Add support for reading alpha data from TIFF images -- Added wxSYS_DCLICK_TIME system metric constant (Arne Steinarson) -- Added wxApp::Get/SetAppDisplayName() (Brian A. Vanderburg II) -- Added wxWindow::GetPopupMenuSelectionFromUser() (Arne Steinarson) +- Added wxToolTip::SetAutoPop() and SetReshow() (Jan Knepper). +- Added wxTaskBarIcon::Destroy(). +- Added XRC handler for wxSearchCtrl (Sander Berents). +- Read image resolution from TIFF, JPEG and BMP images (Maycon Aparecido Gasoto). +- Add support for reading alpha data from TIFF images. +- Added wxSYS_DCLICK_TIME system metric constant (Arne Steinarson). +- Added wxApp::Get/SetAppDisplayName() (Brian A. Vanderburg II). +- Added wxWindow::GetPopupMenuSelectionFromUser() (Arne Steinarson). - Implemented wxTreeCtrl::GetPrevVisible() in the generic version and made the - behaviour of GetNextSibling() consistent between wxMSW and generic versions + behaviour of GetNextSibling() consistent between wxMSW and generic versions. +- Merged wxRichTextAttr and wxTextAttrEx into wxTextAttr, and added a font table + to wxRichTextBuffer to reduce wxFont consumption and increase performance. wxGTK: diff --git a/docs/latex/wx/category.tex b/docs/latex/wx/category.tex index a446c49..8df2132 100644 --- a/docs/latex/wx/category.tex +++ b/docs/latex/wx/category.tex @@ -620,7 +620,6 @@ and paragraph formatting. \begin{twocollist}\itemsep=0pt \twocolitem{\helpref{wxRichTextCtrl}{wxrichtextctrl}}{A rich text control.} \twocolitem{\helpref{wxRichTextBuffer}{wxrichtextbuffer}}{The content of a rich text control.} -\twocolitem{\helpref{wxRichTextAttr}{wxrichtextattr}}{Attributes specifying rich text styling.} \twocolitem{\helpref{wxRichTextCharacterStyleDefinition}{wxrichtextcharacterstyledefinition}}{Definition of character styling.} \twocolitem{\helpref{wxRichTextParagraphStyleDefinition}{wxrichtextparagraphstyledefinition}}{Definition of paragraph styling.} \twocolitem{\helpref{wxRichTextListStyleDefinition}{wxrichtextliststyledefinition}}{Definition of list styling.} diff --git a/docs/latex/wx/classes.tex b/docs/latex/wx/classes.tex index d9c3c39..0aa7adb 100644 --- a/docs/latex/wx/classes.tex +++ b/docs/latex/wx/classes.tex @@ -328,7 +328,6 @@ \input renderer.tex \input rendver.tex -\input richtextattr.tex \input richtextbuffer.tex \input richtextcharacterstyledefinition.tex \input richtextctrl.tex @@ -415,7 +414,6 @@ \input tempfile.tex \input tempfilestrm.tex \input textattr.tex -\input textattrex.tex \input text.tex \input txtdatob.tex \input txtdrptg.tex diff --git a/docs/latex/wx/richtextbuffer.tex b/docs/latex/wx/richtextbuffer.tex index 0363c9d..76b48fc 100644 --- a/docs/latex/wx/richtextbuffer.tex +++ b/docs/latex/wx/richtextbuffer.tex @@ -18,7 +18,7 @@ wxRichTextParagraphLayoutBox \wxheading{See also} -\helpref{wxTextAttr}{wxtextattr}, \helpref{wxTextAttrEx}{wxtextattrex}, \helpref{wxRichTextAttr}{wxrichtextattr}, \helpref{wxRichTextCtrl}{wxrichtextctrl} +\helpref{wxTextAttr}{wxtextattr}, \helpref{wxRichTextCtrl}{wxrichtextctrl} \latexignore{\rtfignore{\wxheading{Members}}} @@ -209,7 +209,7 @@ Begins a right indent, specified in tenths of a millimetre. \membersection{wxRichTextBuffer::BeginStyle}\label{wxrichtextbufferbeginstyle} -\func{bool}{BeginStyle}{\param{const wxTextAttrEx\& }{style}} +\func{bool}{BeginStyle}{\param{const wxTextAttr\& }{style}} Begins using a specified style. @@ -481,7 +481,7 @@ Finds a handler by filename or, if supplied, type. \membersection{wxRichTextBuffer::GetBasicStyle}\label{wxrichtextbuffergetbasicstyle} -\constfunc{const wxTextAttrEx\&}{GetBasicStyle}{\void} +\constfunc{const wxTextAttr\&}{GetBasicStyle}{\void} Gets the basic (overall) style. This is the style of the whole buffer before further styles are applied, unlike the default style, which @@ -503,7 +503,7 @@ initialized. \membersection{wxRichTextBuffer::GetDefaultStyle}\label{wxrichtextbuffergetdefaultstyle} -\constfunc{const wxTextAttrEx\&}{GetDefaultStyle}{\void} +\constfunc{const wxTextAttr\&}{GetDefaultStyle}{\void} Returns the current default style, affecting the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold). @@ -530,9 +530,7 @@ Returns the object to be used to render certain aspects of the content, such as \membersection{wxRichTextBuffer::GetStyle}\label{wxrichtextbuffergetstyle} -\func{bool}{GetStyle}{\param{long }{position}, \param{wxRichTextAttr\& }{style}} - -\func{bool}{GetStyle}{\param{long }{position}, \param{wxTextAttrEx\& }{style}} +\func{bool}{GetStyle}{\param{long }{position}, \param{wxTextAttr\& }{style}} Gets the attributes at the given position. @@ -542,7 +540,7 @@ or paragraph style alone, use \helpref{GetUncombinedStyle}{wxrichtextbuffergetun \membersection{wxRichTextBuffer::GetStyleForRange}\label{wxrichtextbuffergetstyleforrange} -\func{bool}{GetStyleForRange}{\param{const wxRichTextRange\&}{ range}, \param{wxTextAttrEx\& }{style}} +\func{bool}{GetStyleForRange}{\param{const wxRichTextRange\&}{ range}, \param{wxTextAttr\& }{style}} This function gets a style representing the common, combined attributes in the given range. Attributes which have different values within the specified range will not be included the style @@ -577,9 +575,7 @@ Get the size of the style stack, for example to check correct nesting. \membersection{wxRichTextBuffer::GetUncombinedStyle}\label{wxrichtextbuffergetuncombinedstyle} -\func{bool}{GetUncombinedStyle}{\param{long }{position}, \param{wxRichTextAttr\& }{style}} - -\func{bool}{GetUncombinedStyle}{\param{long }{position}, \param{wxTextAttrEx\& }{style}} +\func{bool}{GetUncombinedStyle}{\param{long }{position}, \param{wxTextAttr\& }{style}} Gets the attributes at the given position. @@ -749,9 +745,7 @@ Saves content to a file. \membersection{wxRichTextBuffer::SetBasicStyle}\label{wxrichtextbuffersetbasicstyle} -\func{void}{SetBasicStyle}{\param{const wxRichTextAttr\& }{style}} - -\func{void}{SetBasicStyle}{\param{const wxTextAttrEx\& }{style}} +\func{void}{SetBasicStyle}{\param{const wxTextAttr\& }{style}} Sets the basic (overall) style. This is the style of the whole buffer before further styles are applied, unlike the default style, which @@ -760,7 +754,7 @@ style to bold will cause subsequently inserted text to be bold). \membersection{wxRichTextBuffer::SetDefaultStyle}\label{wxrichtextbuffersetdefaultstyle} -\func{void}{SetDefaultStyle}{\param{const wxTextAttrEx\& }{style}} +\func{void}{SetDefaultStyle}{\param{const wxTextAttr\& }{style}} Sets the default style, affecting the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold). @@ -796,9 +790,7 @@ overriding one or more virtual functions, and setting an instance of the class u \membersection{wxRichTextBuffer::SetStyle}\label{wxrichtextbuffersetstyle} -\func{bool}{SetStyle}{\param{const wxRichTextRange\& }{range}, \param{const wxRichTextAttr\& }{style}, \param{int }{flags $=$ wxRICHTEXT\_SETSTYLE\_WITH\_UNDO}} - -\func{bool}{SetStyle}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttrEx\& }{style}, \param{int }{flags $=$ wxRICHTEXT\_SETSTYLE\_WITH\_UNDO}} +\func{bool}{SetStyle}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttr\& }{style}, \param{int }{flags $=$ wxRICHTEXT\_SETSTYLE\_WITH\_UNDO}} Sets the attributes for the given range. Pass flags to determine how the attributes are set. diff --git a/docs/latex/wx/richtextctrl.tex b/docs/latex/wx/richtextctrl.tex index 1c6b91a..7900385 100644 --- a/docs/latex/wx/richtextctrl.tex +++ b/docs/latex/wx/richtextctrl.tex @@ -65,7 +65,7 @@ Sets the insertion point to the end of the buffer and writes the text. Applies the given alignment to the selection (undoable). -For alignment values, see \helpref{wxTextAttrEx}{wxtextattrex}. +For alignment values, see \helpref{wxTextAttr}{wxtextattr}. \membersection{wxRichTextCtrl::ApplyBoldToSelection}\label{wxrichtextctrlapplyboldtoselection} @@ -113,7 +113,7 @@ Returns \true if undo commands are being batched. Begins using alignment -For alignment values, see \helpref{wxTextAttrEx}{wxtextattrex}. +For alignment values, see \helpref{wxTextAttr}{wxtextattr}. \membersection{wxRichTextCtrl::BeginBatchUndo}\label{wxrichtextctrlbeginbatchundo} @@ -249,7 +249,7 @@ Begins a right indent, specified in tenths of a millimetre. \membersection{wxRichTextCtrl::BeginStyle}\label{wxrichtextctrlbeginstyle} -\func{bool}{BeginStyle}{\param{const wxTextAttrEx\& }{style}} +\func{bool}{BeginStyle}{\param{const wxTextAttr\& }{style}} Begins applying a style. @@ -551,7 +551,7 @@ refresh the control. \membersection{wxRichTextCtrl::GetBasicStyle}\label{wxrichtextctrlgetbasicstyle} -\constfunc{const wxTextAttrEx\&}{GetBasicStyle}{\void} +\constfunc{const wxTextAttr\&}{GetBasicStyle}{\void} Gets the basic (overall) style. This is the style of the whole buffer before further styles are applied, unlike the default style, which @@ -584,13 +584,12 @@ Returns the caret height and position for the given character position Gets the command processor associated with the control's buffer. -\membersection{wxRichTextCtrl::GetDefaultStyleEx}\label{wxrichtextctrlgetdefaultstyleex} +\membersection{wxRichTextCtrl::GetDefaultStyle}\label{wxrichtextctrlgetdefaultstyle} -\constfunc{const wxTextAttrEx\&}{GetDefaultStyleEx}{\void} +\constfunc{const wxTextAttr\&}{GetDefaultStyle}{\void} Returns the current default style, which can be used to change how subsequently inserted -text is displayed. When wxTextAttrEx is merged with wxTextAttr, this function -will become GetDefaultStyle. +text is displayed. \membersection{wxRichTextCtrl::GetDelayedLayoutThreshold}\label{wxrichtextctrlgetdelayedlayoutthreshold} @@ -692,14 +691,9 @@ Returns the text within the current selection range, if any. \membersection{wxRichTextCtrl::GetStyle}\label{wxrichtextctrlgetstyle} -\func{bool}{GetStyle}{\param{long }{position}, \param{wxRichTextAttr\& }{style}} - -\func{bool}{GetStyle}{\param{long }{position}, \param{wxTextAttrEx\& }{style}} - \func{bool}{GetStyle}{\param{long }{position}, \param{wxTextAttr\& }{style}} -Gets the attributes at the given position. The wxRichTextAttr version is generally more efficient -because it does not use wxFont objects. +Gets the attributes at the given position. This function gets the combined style - that is, the style you see on the screen as a result of combining base style, paragraph style and character style attributes. To get the character @@ -707,9 +701,7 @@ or paragraph style alone, use \helpref{GetUncombinedStyle}{wxrichtextctrlgetunco \membersection{wxRichTextCtrl::GetStyleForRange}\label{wxrichtextctrlgetstyleforrange} -\func{bool}{GetStyleForRange}{\param{const wxRichTextRange\& }{range}, \param{wxRichTextAttr\& }{style}} - -\func{bool}{GetStyleForRange}{\param{const wxRichTextRange\& }{range}, \param{wxTextAttrEx\& }{style}} +\func{bool}{GetStyleForRange}{\param{const wxRichTextRange\& }{range}, \param{wxTextAttr\& }{style}} Gets the attributes common to the specified range. Attributes that differ in value within the range will not be included in {\it style}'s flags. @@ -723,14 +715,9 @@ character and paragraph styles to be applied. \membersection{wxRichTextCtrl::GetUncombinedStyle}\label{wxrichtextctrlgetuncombinedstyle} -\func{bool}{GetUncombinedStyle}{\param{long }{position}, \param{wxRichTextAttr\& }{style}} - -\func{bool}{GetUncombinedStyle}{\param{long }{position}, \param{wxTextAttrEx\& }{style}} - \func{bool}{GetUncombinedStyle}{\param{long }{position}, \param{wxTextAttr\& }{style}} -Gets the attributes at the given position. The wxRichTextAttr version is generally more efficient -because it does not use wxFont objects. +Gets the attributes at the given position. This function gets the {\it uncombined style} - that is, the attributes associated with the paragraph or character content, and not necessarily the combined attributes you see on the @@ -756,9 +743,7 @@ if this is the case. \membersection{wxRichTextCtrl::HasCharacterAttributes}\label{wxrichtextctrlhascharacterattributes} -\constfunc{bool}{HasCharacterAttributes}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttrEx\& }{style}} - -\constfunc{bool}{HasCharacterAttributes}{\param{const wxRichTextRange\& }{range}, \param{const wxRichTextAttr\& }{style}} +\constfunc{bool}{HasCharacterAttributes}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttr\& }{style}} Test if this whole range has character attributes of the specified kind. If any of the attributes are different within the range, the test fails. You @@ -767,9 +752,7 @@ flags indicating which attributes are of interest. \membersection{wxRichTextCtrl::HasParagraphAttributes}\label{wxrichtextctrlhasparagraphattributes} -\constfunc{bool}{HasParagraphAttributes}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttrEx\& }{style}} - -\constfunc{bool}{HasParagraphAttributes}{\param{const wxRichTextRange\& }{range}, \param{const wxRichTextAttr\& }{style}} +\constfunc{bool}{HasParagraphAttributes}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttr\& }{style}} Test if this whole range has paragraph attributes of the specified kind. If any of the attributes are different within the range, the test fails. You @@ -820,7 +803,7 @@ bool wxRichTextCtrl::IsSelectionBold() { if (HasSelection()) { - wxRichTextAttr attr; + wxTextAttr attr; wxRichTextRange range = GetInternalSelectionRange(); attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT); attr.SetFontWeight(wxBOLD); @@ -831,7 +814,7 @@ bool wxRichTextCtrl::IsSelectionBold() { // If no selection, then we need to combine current style with default style // to see what the effect would be if we started typing. - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT); long pos = GetAdjustedCaretPosition(GetCaretPosition()); @@ -1252,7 +1235,7 @@ Cancels any selection. \membersection{wxRichTextCtrl::SetAndShowDefaultStyle}\label{wxrichtextctrlsetandshowdefaultstyle} -\func{void}{SetAndShowDefaultStyle}{\param{const wxRichTextAttr\& }{attr}} +\func{void}{SetAndShowDefaultStyle}{\param{const wxTextAttr\& }{attr}} Sets {\it attr} as the default style and tells the control that the UI should reflect this attribute until the user moves the caret. @@ -1261,9 +1244,7 @@ See also \helpref{IsDefaultStyleShowing}{wxrichtextctrlisdefaultstyleshowing}. \membersection{wxRichTextCtrl::SetBasicStyle}\label{wxrichtextctrlsetbasicstyle} -\func{void}{SetBasicStyle}{\param{const wxRichTextAttr\& }{style}} - -\func{void}{SetBasicStyle}{\param{const wxTextAttrEx\& }{style}} +\func{void}{SetBasicStyle}{\param{const wxTextAttr\& }{style}} Sets the basic (overall) style. This is the style of the whole buffer before further styles are applied, unlike the default style, which @@ -1279,7 +1260,7 @@ A value of -1 means the caret is at the start of the buffer. \membersection{wxRichTextCtrl::SetDefaultStyle}\label{wxrichtextctrlsetdefaultstyle} -\func{bool}{SetDefaultStyle}{\param{const wxTextAttrEx\& }{style}} +\func{bool}{SetDefaultStyle}{\param{const wxTextAttr\& }{style}} Sets the current default style, which can be used to change how subsequently inserted text is displayed. @@ -1373,28 +1354,22 @@ So, for example, to set the selection for a character at position 5, use the ran \membersection{wxRichTextCtrl::SetStyle}\label{wxrichtextctrlsetstyle} -\func{bool}{SetStyle}{\param{const wxRichTextRange\& }{range}, \param{const wxRichTextAttr\& }{style}} - -\func{bool}{SetStyle}{\param{long }{start}, \param{long }{end}, \param{const wxTextAttrEx\& }{style}} +\func{bool}{SetStyle}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttr\& }{style}} \func{bool}{SetStyle}{\param{long }{start}, \param{long }{end}, \param{const wxTextAttr\& }{style}} -Sets the attributes for the given range. The wxRichTextAttr version is more efficient -because it does not use wxFont objects. +Sets the attributes for the given range. The end point of range is specified as the last character position of the span of text, plus one. So, for example, to set the style for a character at position 5, use the range (5,6). \membersection{wxRichTextCtrl::SetStyleEx}\label{wxrichtextctrlsetstyleex} -\func{bool}{SetStyleEx}{\param{const wxRichTextRange\& }{range}, \param{const wxRichTextAttr\& }{style}, \param{int }{flags $=$ wxRICHTEXT\_SETSTYLE\_WITH\_UNDO}} - -\func{bool}{SetStyleEx}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttrEx\& }{style}, \param{int }{flags $=$ wxRICHTEXT\_SETSTYLE\_WITH\_UNDO}} +\func{bool}{SetStyleEx}{\param{const wxRichTextRange\& }{range}, \param{const wxTextAttr\& }{style}, \param{int }{flags $=$ wxRICHTEXT\_SETSTYLE\_WITH\_UNDO}} -\func{bool}{SetStyleEx}{\param{long }{start}, \param{long }{end}, \param{const wxTextAttrEx\& }{style}, \param{int }{flags $=$ wxRICHTEXT\_SETSTYLE\_WITH\_UNDO}} +\func{bool}{SetStyleEx}{\param{long }{start}, \param{long }{end}, \param{const wxTextAttr\& }{style}, \param{int }{flags $=$ wxRICHTEXT\_SETSTYLE\_WITH\_UNDO}} -Sets the attributes for the given range, passing flags to determine how the attributes are set. The wxRichTextAttr version is more efficient -because it does not use wxFont objects. +Sets the attributes for the given range, passing flags to determine how the attributes are set. The end point of range is specified as the last character position of the span of text, plus one. So, for example, to set the style for a character at position 5, use the range (5,6). diff --git a/docs/latex/wx/richtextformattingdialog.tex b/docs/latex/wx/richtextformattingdialog.tex index 0968df0..3076779 100644 --- a/docs/latex/wx/richtextformattingdialog.tex +++ b/docs/latex/wx/richtextformattingdialog.tex @@ -102,9 +102,9 @@ Creation: see \helpref{the constructor}{wxrichtextformattingdialog} for details \membersection{wxRichTextFormattingDialog::GetAttributes}\label{wxrichtextformattingdialoggetattributes} -\constfunc{const wxTextAttrEx\&}{GetAttributes}{\void} +\constfunc{const wxTextAttr\&}{GetAttributes}{\void} -\func{wxTextAttrEx\&}{GetAttributes}{\void} +\func{wxTextAttr\&}{GetAttributes}{\void} Gets the attributes being edited. @@ -116,7 +116,7 @@ Helper for pages to get the top-level dialog. \membersection{wxRichTextFormattingDialog::GetDialogAttributes}\label{wxrichtextformattingdialoggetdialogattributes} -\func{wxTextAttrEx*}{GetDialogAttributes}{\param{wxWindow* }{win}} +\func{wxTextAttr*}{GetDialogAttributes}{\param{wxWindow* }{win}} Helper for pages to get the attributes. @@ -159,7 +159,7 @@ Gets the associated style sheet, if any. \membersection{wxRichTextFormattingDialog::SetAttributes}\label{wxrichtextformattingdialogsetattributes} -\func{void}{SetAttributes}{\param{const wxTextAttrEx\& }{attr}} +\func{void}{SetAttributes}{\param{const wxTextAttr\& }{attr}} Sets the attributes to be edited. @@ -178,7 +178,7 @@ Sets the image list associated with the dialog's property sheet. \membersection{wxRichTextFormattingDialog::SetStyle}\label{wxrichtextformattingdialogsetstyle} -\func{bool}{SetStyle}{\param{const wxTextAttrEx\& }{style}, \param{bool }{update = true}} +\func{bool}{SetStyle}{\param{const wxTextAttr\& }{style}, \param{bool }{update = true}} Sets the attributes and optionally updates the display, if {\it update} is \true. diff --git a/docs/latex/wx/richtextliststyledefinition.tex b/docs/latex/wx/richtextliststyledefinition.tex index fdd60a4..996028e 100644 --- a/docs/latex/wx/richtextliststyledefinition.tex +++ b/docs/latex/wx/richtextliststyledefinition.tex @@ -43,7 +43,7 @@ Destructor. \membersection{wxRichTextListStyleDefinition::CombineWithParagraphStyle}\label{wxrichtextliststyledefinitioncombinewithparagraphstyle} -\func{wxRichTextAttr}{CombineWithParagraphStyle}{\param{int }{indent}, \param{const wxRichTextAttr\&}{ paraStyle}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}} +\func{wxTextAttr}{CombineWithParagraphStyle}{\param{int }{indent}, \param{const wxTextAttr\&}{ paraStyle}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}} This function combines the given paragraph style with the list style's base attributes and level style matching the given indent, returning the combined attributes. If {\it styleSheet} is specified, the base style for this definition will also be included in the result. @@ -56,21 +56,21 @@ This function finds the level (from 0 to 9) whose indentation attribute mostly c \membersection{wxRichTextListStyleDefinition::GetCombinedStyle}\label{wxrichtextliststyledefinitiongetcombinedstyle} -\constfunc{wxRichTextAttr}{GetCombinedStyle}{\param{int }{indent}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}} +\constfunc{wxTextAttr}{GetCombinedStyle}{\param{int }{indent}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}} This function combines the list style's base attributes and the level style matching the given indent, returning the combined attributes. If {\it styleSheet} is specified, the base style for this definition will also be included in the result. \membersection{wxRichTextListStyleDefinition::GetCombinedStyleForLevel}\label{wxrichtextliststyledefinitioncombinewithparagraphstyleforlevel} -\constfunc{wxRichTextAttr}{GetCombinedStyleLevel}{\param{int }{level}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}} +\constfunc{wxTextAttr}{GetCombinedStyleLevel}{\param{int }{level}, \param{wxRichTextStyleSheet*}{ styleSheet = NULL}} This function combines the list style's base attributes and the style for the specified level, returning the combined attributes. If {\it styleSheet} is specified, the base style for this definition will also be included in the result. \membersection{wxRichTextListStyleDefinition::GetLevelAttributes}\label{wxrichtextliststyledefinitiongetlevelattributes} -\constfunc{const wxRichTextAttr*}{GetLevelAttributes}{\param{int }{level}} +\constfunc{const wxTextAttr*}{GetLevelAttributes}{\param{int }{level}} Returns the style for the given level. {\it level} is a number between 0 and 9. @@ -90,11 +90,11 @@ Returns \true if the given level has numbered list attributes. \membersection{wxRichTextListStyleDefinition::SetLevelAttributes}\label{wxrichtextliststyledefinitionsetlevelattributes} -\func{void}{SetLevelAttributes}{\param{int }{level}, \param{const wxRichTextAttr\&}{ attr}} +\func{void}{SetLevelAttributes}{\param{int }{level}, \param{const wxTextAttr\&}{ attr}} \func{void}{SetLevelAttributes}{\param{int }{level}, \param{int}{ leftIndent}, \param{int}{ leftSubIndent}, \param{int}{ bulletStyle}, \param{const wxString\&}{ bulletSymbol = wxEmptyString}} Sets the style for the given level. {\it level} is a number between 0 and 9. -The first and most flexible form uses a wxRichTextAttr object, while the second form is for convenient setting of the most commonly-used attributes. +The first and most flexible form uses a wxTextAttr object, while the second form is for convenient setting of the most commonly-used attributes. diff --git a/docs/latex/wx/richtextoverview.tex b/docs/latex/wx/richtextoverview.tex index 624e59f..8d88108 100644 --- a/docs/latex/wx/richtextoverview.tex +++ b/docs/latex/wx/richtextoverview.tex @@ -2,8 +2,7 @@ {\bf Major classes:} \helpref{wxRichTextCtrl}{wxrichtextctrl}, \helpref{wxRichTextBuffer}{wxrichtextbuffer}, \helpref{wxRichTextEvent}{wxrichtextevent} -{\bf Helper classes:} \helpref{wxRichTextAttr}{wxrichtextattr}, \helpref{wxTextAttrEx}{wxtextattrex}, -\helpref{wxRichTextRange}{wxrichtextrange} +{\bf Helper classes:} \helpref{wxTextAttr}{wxtextattr}, \helpref{wxRichTextRange}{wxrichtextrange} {\bf File handler classes:} \helpref{wxRichTextFileHandler}{wxrichtextfilehandler}, \helpref{wxRichTextHTMLHandler}{wxrichtexthtmlhandler}, \helpref{wxRichTextXMLHandler}{wxrichtextxmlhandler} @@ -186,7 +185,7 @@ The following code is taken from the sample, and adds text and styles to a rich tabs.Add(600); tabs.Add(800); tabs.Add(1000); - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_TABS); attr.SetTabs(tabs); r.SetDefaultStyle(attr); @@ -220,14 +219,7 @@ be processed by the control rather than being used for navigation between contro \subsubsection{wxRichTextCtrl and styles} -Styling attributes are represented by three classes: \helpref{wxTextAttr}{wxtextattr}, \helpref{wxTextAttrEx}{wxtextattrex} and \helpref{wxRichTextAttr}{wxrichtextattr}. -wxTextAttr is shared across all controls that are derived from wxTextCtrlBase and -can store basic character and paragraph attributes. wxTextAttrEx derives -from wxTextAttr and adds some further attributes that are only supported -by wxRichTextCtrl. Finally, wxRichTextAttr is a more efficient version -of wxTextAttrEx that doesn't use a wxFont object and can be used to -query styles more quickly. wxTextAttrEx and wxRichTextAttr are largely -interchangeable and have suitable conversion operators between them. +Styling attributes are represented by \helpref{wxTextAttr}{wxtextattr}. When setting a style, the flags of the attribute object determine which attributes are applied. When querying a style, the passed flags are ignored @@ -348,7 +340,7 @@ always has one such buffer. The content is represented by a hierarchy of objects, all derived from wxRichTextObject. An object might be an image, a fragment of text, a paragraph, -or a whole buffer. Objects store a wxTextAttrEx containing style information; +or a whole buffer. Objects store a wxTextAttr containing style information; a paragraph object can contain both paragraph and character information, but content objects such as text can only store character information. The final style displayed in the control or in a printout is a combination of base @@ -375,7 +367,7 @@ A paragraph of pure text with the same style contains just one further object, a wxRichTextPlainText object. When styling is applied to part of this object, the object is decomposed into separate objects, one object for each different character style. So each object within a paragraph always has -just one wxTextAttrEx object to denote its character style. Of course, this can +just one wxTextAttr object to denote its character style. Of course, this can lead to fragmentation after a lot of edit operations, potentially leading to several objects with the same style where just one would do. So a Defragment function is called when updating the control's display, to ensure that diff --git a/docs/latex/wx/richtextstyledefinition.tex b/docs/latex/wx/richtextstyledefinition.tex index 7399d13..6ab245f 100644 --- a/docs/latex/wx/richtextstyledefinition.tex +++ b/docs/latex/wx/richtextstyledefinition.tex @@ -50,15 +50,15 @@ Returns the style name. \membersection{wxRichTextStyleDefinition::GetStyle}\label{wxrichtextstyledefinitiongetstyle} -\func{wxRichTextAttr\&}{GetStyle}{\void} +\func{wxTextAttr\&}{GetStyle}{\void} -\constfunc{const wxRichTextAttr\&}{GetStyle}{\void} +\constfunc{const wxTextAttr\&}{GetStyle}{\void} Returns the attributes associated with this style. \membersection{wxRichTextStyleDefinition::GetStyleMergedWithBase}\label{wxrichtextstyledefinitiongetstylemergedwithbase} -\constfunc{wxRichTextAttr}{GetStyleMergedWithBase}{\param{wxRichTextStyleSheet*}{ sheet}} +\constfunc{wxTextAttr}{GetStyleMergedWithBase}{\param{wxRichTextStyleSheet*}{ sheet}} Returns the style attributes combined with the attributes of the specified base style, if any. This function works recursively. @@ -82,7 +82,7 @@ Sets the name of the style. \membersection{wxRichTextStyleDefinition::SetStyle}\label{wxrichtextstyledefinitionsetstyle} -\func{void}{SetStyle}{\param{const wxRichTextAttr\& }{style}} +\func{void}{SetStyle}{\param{const wxTextAttr\& }{style}} Sets the attributes for this style. diff --git a/docs/latex/wx/richtextxmlhandler.tex b/docs/latex/wx/richtextxmlhandler.tex index d49251f..bf05d0d 100644 --- a/docs/latex/wx/richtextxmlhandler.tex +++ b/docs/latex/wx/richtextxmlhandler.tex @@ -54,7 +54,7 @@ Returns \true. \membersection{wxRichTextXMLHandler::CreateStyle}\label{wxrichtextxmlhandlercreatestyle} -\func{wxString}{CreateStyle}{\param{const wxTextAttrEx\& }{attr}, \param{bool }{isPara = false}} +\func{wxString}{CreateStyle}{\param{const wxTextAttr\& }{attr}, \param{bool }{isPara = false}} Creates XML code for a given character or paragraph style. @@ -96,7 +96,7 @@ Helper function: gets a named parameter from the XML node. \membersection{wxRichTextXMLHandler::GetStyle}\label{wxrichtextxmlhandlergetstyle} -\func{bool}{GetStyle}{\param{wxTextAttrEx\& }{attr}, \param{wxXmlNode* }{node}, \param{bool }{isPara = false}} +\func{bool}{GetStyle}{\param{wxTextAttr\& }{attr}, \param{wxXmlNode* }{node}, \param{bool }{isPara = false}} Helper function: gets style parameters from the given XML node. diff --git a/docs/latex/wx/symbolpickerdialog.tex b/docs/latex/wx/symbolpickerdialog.tex index 517a998..6918963 100644 --- a/docs/latex/wx/symbolpickerdialog.tex +++ b/docs/latex/wx/symbolpickerdialog.tex @@ -26,7 +26,7 @@ rich text control in either the current font or specified font. \begin{verbatim} wxRichTextCtrl* ctrl = (wxRichTextCtrl*) FindWindow(ID_RICHTEXT_CTRL); - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT); ctrl->GetStyle(ctrl->GetInsertionPoint(), attr); diff --git a/docs/latex/wx/richtextattr.tex b/docs/latex/wx/textattr.tex similarity index 64% rename from docs/latex/wx/richtextattr.tex rename to docs/latex/wx/textattr.tex index 9bec6fc..1fba2be 100644 --- a/docs/latex/wx/richtextattr.tex +++ b/docs/latex/wx/textattr.tex @@ -1,32 +1,27 @@ -\section{\class{wxRichTextAttr}}\label{wxrichtextattr} +\section{\class{wxTextAttr}}\label{wxtextattr} -wxRichTextAttr represents the character and paragraph attributes, or style, -for a range of text in a \helpref{wxRichTextCtrl}{wxrichtextctrl}. This class -is specific to wxRichTextCtrl, although you can also use the -standard \helpref{wxTextAttr}{wxtextattr} class with wxRichTextCtrl. +wxTextAttr represents the character and paragraph attributes, or style, +for a range of text in a \helpref{wxTextCtrl}{wxtextctrl} or \helpref{wxRichTextCtrl}{wxrichtextctrl}. -When setting up a wxRichTextAttr object, pass a bitlist mask to \helpref{SetFlags}{wxrichtextattrsetflags} to +When setting up a wxTextAttr object, pass a bitlist mask to \helpref{SetFlags}{wxtextattrsetflags} to indicate which style elements should be changed. As a convenience, when you call a setter such as SetFont, the relevant bit will be set. -wxRichTextAttr stores attributes without a wxFont object, so is a more -efficient way to query styles than using a \helpref{wxTextAttr}{wxtextattr} or \helpref{wxTextAttrEx}{wxtextattrex} object. - \wxheading{Derived from} No base class \wxheading{Include files} - + \wxheading{Library} -\helpref{wxRichtext}{librarieslist} +\helpref{wxCore}{librarieslist} \wxheading{Constants} -The following values can be passed to wxRichTextAttr::SetAlignment to determine +The following values can be passed to wxTextAttr::SetAlignment to determine paragraph alignment. {\small @@ -46,7 +41,7 @@ enum wxTextAttrAlignment Of these, wxTEXT\_ALIGNMENT\_JUSTIFIED is unimplemented. In future justification may be supported when printing or previewing, only. -The following values are passed in a bitlist to wxRichTextAttr::SetFlags to determine +The following values are passed in a bitlist to wxTextAttr::SetFlags to determine what attributes will be considered when setting the attributes for a text control. @@ -61,9 +56,10 @@ for a text control. #define wxTEXT_ATTR_FONT_WEIGHT 0x00000010 #define wxTEXT_ATTR_FONT_ITALIC 0x00000020 #define wxTEXT_ATTR_FONT_UNDERLINE 0x00000040 +#define wxTEXT_ATTR_FONT_ENCODING 0x02000000 #define wxTEXT_ATTR_FONT \ wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT \ -| wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE +| wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING #define wxTEXT_ATTR_ALIGNMENT 0x00000080 #define wxTEXT_ATTR_LEFT_INDENT 0x00000100 #define wxTEXT_ATTR_RIGHT_INDENT 0x00000200 @@ -88,7 +84,7 @@ for a text control. \end{verbatim} } -The following styles can be passed to wxRichTextAttr::SetBulletStyle: +The following styles can be passed to wxTextAttr::SetBulletStyle: {\small \begin{verbatim} @@ -113,7 +109,7 @@ The following styles can be passed to wxRichTextAttr::SetBulletStyle: Of these, wxTEXT\_ATTR\_BULLET\_STYLE\_BITMAP is unimplemented. -The following constants can be passed to wxRichTextAttr::SetLineSpacing: +The following constants can be passed to wxTextAttr::SetLineSpacing: {\small \begin{verbatim} @@ -123,7 +119,7 @@ The following constants can be passed to wxRichTextAttr::SetLineSpacing: \end{verbatim} } -The following styles can be passed to wxTextAttrEx::SetTextEffects: +The following styles can be passed to wxTextAttr::SetTextEffects: {\small \begin{verbatim} @@ -145,64 +141,53 @@ Of these, only wxTEXT\_ATTR\_EFFECT\_CAPITALS and wxTEXT\_ATTR\_EFFECT\_STRIKETH \wxheading{See also} -\helpref{wxTextAttr}{wxtextattr}, \helpref{wxTextAttrEx}{wxtextattrex}, \helpref{wxRichTextCtrl}{wxrichtextctrl} +\helpref{wxTextCtrl}{wxtextctrl}, \helpref{wxRichTextCtrl}{wxrichtextctrl} \latexignore{\rtfignore{\wxheading{Members}}} -\membersection{wxRichTextAttr::wxRichTextAttr}\label{wxrichtextattrwxrichtextattr} +\membersection{wxTextAttr::wxTextAttr}\label{wxtextattrwxtextattr} -\func{}{wxRichTextAttr}{\void} +\func{}{wxTextAttr}{\void} -\func{}{wxRichTextAttr}{\param{const wxColour\& }{colText}, \param{const wxColour\& }{colBack = wxNullColour}, \param{wxTextAttrAlignment }{alignment = wxTEXT\_ALIGNMENT\_DEFAULT}} +\func{}{wxTextAttr}{\param{const wxColour\& }{colText}, \param{const wxColour\& }{colBack = wxNullColour}, \param{const wxFont\& }{font = wxNullFont}, \param{wxTextAttrAlignment }{alignment = wxTEXT\_ALIGNMENT\_DEFAULT}} -\func{}{wxRichTextAttr}{\param{const wxTextAttrEx\& }{attr}} +\func{}{wxTextAttr}{\param{const wxTextAttr\& }{attr}} Constructors. -\membersection{wxRichTextAttr::Apply}\label{wxrichtextattrapply} +\membersection{wxTextAttr::Apply}\label{wxtextattrapply} -\func{bool}{Combine}{\param{const wxRichTextAttrEx\& }{style}, \param{const wxRichTextAttrEx* }{compareWith = NULL}} +\func{bool}{Apply}{\param{const wxTextAttr\& }{style}, \param{const wxTextAttr* }{compareWith = NULL}} Applies the attributes in {\it style} to the original object, but not those attributes from {\it style} that are the same as those in {\it compareWith} (if passed). -See also \helpref{wxRichTextAttr::Combine}{wxrichtextattrcombine} for a function that does almost the same but returns a new object instead of modifying the original object. - -\membersection{wxRichTextAttr::Combine}\label{wxrichtextattrcombine} - -\constfunc{wxRichTextAttr}{Combine}{\param{const wxRichTextAttrEx\& }{style}, \param{const wxRichTextAttrEx* }{compareWith = NULL}} - -Combines 'this' with {\it style}, but not applying attributes from {\it style} that are the same as those in {\it compareWith} (if passed). -A wxRichTextAttr object is returned and the original object is not changed. - -See also \helpref{wxRichTextAttr::Apply}{wxrichtextattrapply} for a function that does almost the same but modifies the original object instead of returning a new one. - -\membersection{wxRichTextAttr::CreateFont}\label{wxrichtextattrcreatefont} +\membersection{wxTextAttr::CreateFont}\label{wxtextattrcreatefont} \constfunc{wxFont}{CreateFont}{\void} Creates a font from the font attributes. -\membersection{wxRichTextAttr::GetAlignment}\label{wxrichtextattrgetalignment} +\membersection{wxTextAttr::GetAlignment}\label{wxtextattrgetalignment} \constfunc{wxTextAttrAlignment}{GetAlignment}{\void} Returns the alignment flags. -See \helpref{wxRichTextAttr::SetAlignment}{wxrichtextattrsetalignment} for a list of available styles. +See \helpref{wxTextAttr::SetAlignment}{wxtextattrsetalignment} for a list of available styles. -\membersection{wxRichTextAttr::GetBackgroundColour}\label{wxrichtextattrgetbackgroundcolour} +\membersection{wxTextAttr::GetBackgroundColour}\label{wxtextattrgetbackgroundcolour} \constfunc{const wxColour\&}{GetBackgroundColour}{\void} Returns the background colour. -\membersection{wxRichTextAttr::GetBulletFont}\label{wxrichtextattrgetbulletfont} +\membersection{wxTextAttr::GetBulletFont}\label{wxtextattrgetbulletfont} \constfunc{const wxString\&}{GetBulletFont}{\void} Returns a string containing the name of the font associated with the bullet symbol. Only valid for attributes with wxTEXT\_ATTR\_BULLET\_SYMBOL. -\membersection{wxRichTextAttr::GetBulletName}\label{wxrichtextattrgetbulletname} +\membersection{wxTextAttr::GetBulletName}\label{wxtextattrgetbulletname} \constfunc{const wxString\&}{GetBulletName}{\void} @@ -216,160 +201,174 @@ Currently the following standard bullet names are supported: \item {\tt standard/triangle} \end{itemize} -If you wish your application to support further bullet graphics, you can derive a +For wxRichTextCtrl users only: if you wish your rich text controls to support further bullet graphics, you can derive a class from wxRichTextRenderer or wxRichTextStdRenderer, override {\tt DrawStandardBullet} and {\tt EnumerateStandardBulletNames}, and set an instance of the class using \helpref{wxRichTextBuffer::SetRenderer}{wxrichtextbuffersetrenderer}. -\membersection{wxRichTextAttr::GetBulletNumber}\label{wxrichtextattrgetbulletnumber} +\membersection{wxTextAttr::GetBulletNumber}\label{wxtextattrgetbulletnumber} \constfunc{int}{GetBulletNumber}{\void} Returns the bullet number. -\membersection{wxRichTextAttr::GetBulletStyle}\label{wxrichtextattrgetbulletstyle} +\membersection{wxTextAttr::GetBulletStyle}\label{wxtextattrgetbulletstyle} \constfunc{int}{GetBulletStyle}{\void} Returns the bullet style. -See \helpref{wxRichTextAttr::SetBulletStyle}{wxrichtextattrsetbulletstyle} for a list of available styles. +See \helpref{wxTextAttr::SetBulletStyle}{wxtextattrsetbulletstyle} for a list of available styles. -\membersection{wxRichTextAttr::GetBulletText}\label{wxrichtextattrgetbullettext} +\membersection{wxTextAttr::GetBulletText}\label{wxtextattrgetbullettext} \constfunc{const wxString\&}{GetBulletText}{\void} Returns the bullet text, which could be a symbol, or (for example) cached outline text. -\membersection{wxRichTextAttr::GetCharacterStyleName}\label{wxrichtextattrgetcharacterstylename} +\membersection{wxTextAttr::GetCharacterStyleName}\label{wxtextattrgetcharacterstylename} \constfunc{const wxString\&}{GetCharacterStyleName}{\void} Returns the name of the character style. -\membersection{wxRichTextAttr::GetFlags}\label{wxrichtextattrgetflags} +\membersection{wxTextAttr::GetFlags}\label{wxtextattrgetflags} \constfunc{long}{GetFlags}{\void} Returns flags indicating which attributes are applicable. -See \helpref{wxRichTextAttr::SetFlags}{wxrichtextattrsetflags} for a list of available flags. +See \helpref{wxTextAttr::SetFlags}{wxtextattrsetflags} for a list of available flags. + +\membersection{wxTextAttr::GetFont}\label{wxtextattrgetfont} -\membersection{wxRichTextAttr::GetFontAttributes}\label{wxrichtextattrgetfontattributes} +\constfunc{wxFont}{GetFont}{\void} -\func{bool}{GetFontAttributes}{\param{const wxFont\& }{font}} +Creates and returns a font specified by the font attributes in the wxTextAttr object. Note that +wxTextAttr does not store a wxFont object, so this is only a temporary font. For greater +efficiency, access the font attributes directly. -Sets the font attributes from the given font. +\membersection{wxTextAttr::GetFontAttributes}\label{wxtextattrgetfontattributes} -\membersection{wxRichTextAttr::GetFontFaceName}\label{wxrichtextattrgetfontfacename} +\func{bool}{GetFontAttributes}{\param{const wxFont\& }{font}, \param{int}{ flags = wxTEXT\_ATTR\_FONT}} + +Gets the font attributes from the given font, using only the attributes specified by {\it flags}. + +\membersection{wxTextAttr::GetFontEncoding}\label{wxtextattrgetfontencoding} + +\constfunc{wxFontEncoding}{GetFontEncoding}{\void} + +Returns the font encoding. + +\membersection{wxTextAttr::GetFontFaceName}\label{wxtextattrgetfontfacename} \constfunc{const wxString\&}{GetFontFaceName}{\void} Returns the font face name. -\membersection{wxRichTextAttr::GetFontSize}\label{wxrichtextattrgetfontsize} +\membersection{wxTextAttr::GetFontSize}\label{wxtextattrgetfontsize} \constfunc{int}{GetFontSize}{\void} Returns the font size in points. -\membersection{wxRichTextAttr::GetFontStyle}\label{wxrichtextattrgetfontstyle} +\membersection{wxTextAttr::GetFontStyle}\label{wxtextattrgetfontstyle} \constfunc{int}{GetFontStyle}{\void} Returns the font style. -\membersection{wxRichTextAttr::GetFontUnderlined}\label{wxrichtextattrgetfontunderlined} +\membersection{wxTextAttr::GetFontUnderlined}\label{wxtextattrgetfontunderlined} \constfunc{bool}{GetFontUnderlined}{\void} Returns \true if the font is underlined. -\membersection{wxRichTextAttr::GetFontWeight}\label{wxrichtextattrgetfontweight} +\membersection{wxTextAttr::GetFontWeight}\label{wxtextattrgetfontweight} \constfunc{int}{GetFontWeight}{\void} Returns the font weight. -\membersection{wxRichTextAttr::GetLeftIndent}\label{wxrichtextattrgetleftindent} +\membersection{wxTextAttr::GetLeftIndent}\label{wxtextattrgetleftindent} \constfunc{long}{GetLeftIndent}{\void} Returns the left indent in tenths of a millimetre. -\membersection{wxRichTextAttr::GetLeftSubIndent}\label{wxrichtextattrgetleftsubindent} +\membersection{wxTextAttr::GetLeftSubIndent}\label{wxtextattrgetleftsubindent} \constfunc{long}{GetLeftSubIndent}{\void} Returns the left sub-indent in tenths of a millimetre. -\membersection{wxRichTextAttr::GetLineSpacing}\label{wxrichtextattrgetlinespacing} +\membersection{wxTextAttr::GetLineSpacing}\label{wxtextattrgetlinespacing} \constfunc{int}{GetLineSpacing}{\void} Returns the line spacing value, one of wxTEXT\_ATTR\_LINE\_SPACING\_NORMAL, wxTEXT\_ATTR\_LINE\_SPACING\_HALF, and wxTEXT\_ATTR\_LINE\_SPACING\_TWICE. -\membersection{wxRichTextAttr::GetListStyleName}\label{wxrichtextattrgetliststylename} +\membersection{wxTextAttr::GetListStyleName}\label{wxtextattrgetliststylename} \constfunc{const wxString\&}{GetListStyleName}{\void} Returns the name of the list style. -\membersection{wxRichTextAttr::GetOutlineLevel}\label{wxrichtextattrgetoutlinelevel} +\membersection{wxTextAttr::GetOutlineLevel}\label{wxtextattrgetoutlinelevel} \constfunc{bool}{GetOutlineLevel}{\void} Returns the outline level. -\membersection{wxRichTextAttr::GetParagraphSpacingAfter}\label{wxrichtextattrgetparagraphspacingafter} +\membersection{wxTextAttr::GetParagraphSpacingAfter}\label{wxtextattrgetparagraphspacingafter} \constfunc{int}{GetParagraphSpacingAfter}{\void} Returns the space in tenths of a millimeter after the paragraph. -\membersection{wxRichTextAttr::GetParagraphSpacingBefore}\label{wxrichtextattrgetparagraphspacingbefore} +\membersection{wxTextAttr::GetParagraphSpacingBefore}\label{wxtextattrgetparagraphspacingbefore} \constfunc{int}{GetParagraphSpacingBefore}{\void} Returns the space in tenths of a millimeter before the paragraph. -\membersection{wxRichTextAttr::GetParagraphStyleName}\label{wxrichtextattrgetparagraphstylename} +\membersection{wxTextAttr::GetParagraphStyleName}\label{wxtextattrgetparagraphstylename} \constfunc{const wxString\&}{GetParagraphStyleName}{\void} Returns the name of the paragraph style. -\membersection{wxRichTextAttr::GetRightIndent}\label{wxrichtextattrgetrightindent} +\membersection{wxTextAttr::GetRightIndent}\label{wxtextattrgetrightindent} \constfunc{long}{GetRightIndent}{\void} Returns the right indent in tenths of a millimeter. -\membersection{wxRichTextAttr::GetTabs}\label{wxrichtextattrgettabs} +\membersection{wxTextAttr::GetTabs}\label{wxtextattrgettabs} \constfunc{const wxArrayInt\&}{GetTabs}{\void} Returns an array of tab stops, each expressed in tenths of a millimeter. Each stop is measured from the left margin and therefore each value must be larger than the last. -\membersection{wxRichTextAttr::GetTextColour}\label{wxrichtextattrgettextcolour} +\membersection{wxTextAttr::GetTextColour}\label{wxtextattrgettextcolour} \constfunc{const wxColour\&}{GetTextColour}{\void} Returns the text foreground colour. -\membersection{wxRichTextAttr::GetTextEffectFlags}\label{wxrichtextattrgettexteffectflags} +\membersection{wxTextAttr::GetTextEffectFlags}\label{wxtextattrgettexteffectflags} \constfunc{int}{GetTextEffectFlags}{\void} -Returns the text effect bits of interest. See \helpref{wxRichTextAttr::SetFlags}{wxrichtextattrsetflags} for further information. +Returns the text effect bits of interest. See \helpref{wxTextAttr::SetFlags}{wxtextattrsetflags} for further information. -\membersection{wxRichTextAttr::GetTextEffects}\label{wxrichtextattrgettexteffects} +\membersection{wxTextAttr::GetTextEffects}\label{wxtextattrgettexteffects} \constfunc{int}{GetTextEffects}{\void} -Returns the text effects, a bit list of styles. See \helpref{wxRichTextAttr::SetTextEffects}{wxrichtextattrsettexteffects} for +Returns the text effects, a bit list of styles. See \helpref{wxTextAttr::SetTextEffects}{wxtextattrsettexteffects} for details. -\membersection{wxRichTextAttr::GetURL}\label{wxrichtextattrgeturl} +\membersection{wxTextAttr::GetURL}\label{wxtextattrgeturl} \constfunc{const wxString\&}{GetURL}{\void} @@ -377,182 +376,188 @@ Returns the URL for the content. Content with wxTEXT\_ATTR\_URL style causes wxRichTextCtrl to show a hand cursor over it, and wxRichTextCtrl generates a wxTextUrlEvent when the content is clicked. -\membersection{wxRichTextAttr::HasAlignment}\label{wxrichtextattrhasalignment} +\membersection{wxTextAttr::HasAlignment}\label{wxtextattrhasalignment} \constfunc{bool}{HasAlignment}{\void} Returns \true if the attribute object specifies alignment. -\membersection{wxRichTextAttr::HasBackgroundColour}\label{wxrichtextattrhasbackgroundcolour} +\membersection{wxTextAttr::HasBackgroundColour}\label{wxtextattrhasbackgroundcolour} \constfunc{bool}{HasBackgroundColour}{\void} Returns \true if the attribute object specifies a background colour. -\membersection{wxRichTextAttr::HasBulletName}\label{wxrichtextattrhasbulletname} +\membersection{wxTextAttr::HasBulletName}\label{wxtextattrhasbulletname} \constfunc{bool}{HasBulletName}{\void} Returns \true if the attribute object specifies a standard bullet name. -\membersection{wxRichTextAttr::HasBulletNumber}\label{wxrichtextattrhasbulletnumber} +\membersection{wxTextAttr::HasBulletNumber}\label{wxtextattrhasbulletnumber} \constfunc{bool}{HasBulletNumber}{\void} Returns \true if the attribute object specifies a bullet number. -\membersection{wxRichTextAttr::HasBulletStyle}\label{wxrichtextattrhasbulletstyle} +\membersection{wxTextAttr::HasBulletStyle}\label{wxtextattrhasbulletstyle} \constfunc{bool}{HasBulletStyle}{\void} Returns \true if the attribute object specifies a bullet style. -\membersection{wxRichTextAttr::HasBulletText}\label{wxrichtextattrhasbullettext} +\membersection{wxTextAttr::HasBulletText}\label{wxtextattrhasbullettext} \constfunc{bool}{HasBulletText}{\void} Returns \true if the attribute object specifies bullet text (usually specifying a symbol). -\membersection{wxRichTextAttr::HasCharacterStyleName}\label{wxrichtextattrhascharacterstylename} +\membersection{wxTextAttr::HasCharacterStyleName}\label{wxtextattrhascharacterstylename} \constfunc{bool}{HasCharacterStyleName}{\void} Returns \true if the attribute object specifies a character style name. -\membersection{wxRichTextAttr::HasFontFaceName}\label{wxrichtextattrhasfontfacename} +\membersection{wxTextAttr::HasFontEncoding}\label{wxtextattrhasfontencoding} + +\constfunc{bool}{HasFontEncoding}{\void} + +Returns \true if the attribute object specifies an encoding. + +\membersection{wxTextAttr::HasFontFaceName}\label{wxtextattrhasfontfacename} \constfunc{bool}{HasFontFaceName}{\void} Returns \true if the attribute object specifies a font face name. -\membersection{wxRichTextAttr::HasFlag}\label{wxrichtextattrhasflag} +\membersection{wxTextAttr::HasFlag}\label{wxtextattrhasflag} \constfunc{bool}{HasFlag}{\param{long }{flag}} Returns \true if the {\it flag} is present in the attribute object's flag bitlist. -\membersection{wxRichTextAttr::HasFont}\label{wxrichtextattrhasfont} +\membersection{wxTextAttr::HasFont}\label{wxtextattrhasfont} \constfunc{bool}{HasFont}{\void} Returns \true if the attribute object specifies any font attributes. -\membersection{wxRichTextAttr::HasFontItalic}\label{wxrichtextattrhasfontitalic} +\membersection{wxTextAttr::HasFontItalic}\label{wxtextattrhasfontitalic} \constfunc{bool}{HasFontItalic}{\void} Returns \true if the attribute object specifies italic style. -\membersection{wxRichTextAttr::HasLeftIndent}\label{wxrichtextattrhasleftindent} +\membersection{wxTextAttr::HasFontUnderlined}\label{wxtextattrhasfontunderlined} + +\constfunc{bool}{HasFontUnderlined}{\void} + +Returns \true if the attribute object specifies either underlining or no underlining. + +\membersection{wxTextAttr::HasURL}\label{wxtextattrhasurl} + +\constfunc{bool}{HasURL}{\void} + +Returns \true if the attribute object specifies a URL. + +\membersection{wxTextAttr::HasFontWeight}\label{wxtextattrhasfontweight} + +\constfunc{bool}{HasFontWeight}{\void} + +Returns \true if the attribute object specifies font weight (bold, light or normal). + +\membersection{wxTextAttr::HasLeftIndent}\label{wxtextattrhasleftindent} \constfunc{bool}{HasLeftIndent}{\void} Returns \true if the attribute object specifies a left indent. -\membersection{wxRichTextAttr::HasLineSpacing}\label{wxrichtextattrhaslinespacing} +\membersection{wxTextAttr::HasLineSpacing}\label{wxtextattrhaslinespacing} \constfunc{bool}{HasLineSpacing}{\void} Returns \true if the attribute object specifies line spacing. -\membersection{wxRichTextAttr::HasListStyleName}\label{wxrichtextattrhasliststylename} +\membersection{wxTextAttr::HasListStyleName}\label{wxtextattrhasliststylename} \constfunc{bool}{HasListStyleName}{\void} Returns \true if the attribute object specifies a list style name. -\membersection{wxRichTextAttr::HasOutlineLevel}\label{wxrichtextattrhasoutlinelevel} +\membersection{wxTextAttr::HasOutlineLevel}\label{wxtextattrhasoutlinelevel} \constfunc{bool}{HasOutlineLevel}{\void} Returns \true if the attribute object specifies an outline level. -\membersection{wxRichTextAttr::HasPageBreak}\label{wxrichtextattrhaspagebreak} +\membersection{wxTextAttr::HasPageBreak}\label{wxtextattrhaspagebreak} \constfunc{bool}{HasPageBreak}{\void} Returns \true if the attribute object specifies a page break before this paragraph. -\membersection{wxRichTextAttr::HasParagraphSpacingAfter}\label{wxrichtextattrhasparagraphspacingafter} +\membersection{wxTextAttr::HasParagraphSpacingAfter}\label{wxtextattrhasparagraphspacingafter} \constfunc{bool}{HasParagraphSpacingAfter}{\void} Returns \true if the attribute object specifies spacing after a paragraph. -\membersection{wxRichTextAttr::HasParagraphSpacingBefore}\label{wxrichtextattrhasparagraphspacingbefore} +\membersection{wxTextAttr::HasParagraphSpacingBefore}\label{wxtextattrhasparagraphspacingbefore} \constfunc{bool}{HasParagraphSpacingBefore}{\void} Returns \true if the attribute object specifies spacing before a paragraph. -\membersection{wxRichTextAttr::HasParagraphStyleName}\label{wxrichtextattrhasparagraphstylename} +\membersection{wxTextAttr::HasParagraphStyleName}\label{wxtextattrhasparagraphstylename} \constfunc{bool}{HasParagraphStyleName}{\void} Returns \true if the attribute object specifies a paragraph style name. -\membersection{wxRichTextAttr::HasRightIndent}\label{wxrichtextattrhasrightindent} +\membersection{wxTextAttr::HasRightIndent}\label{wxtextattrhasrightindent} \constfunc{bool}{HasRightIndent}{\void} Returns \true if the attribute object specifies a right indent. -\membersection{wxRichTextAttr::HasFontSize}\label{wxrichtextattrhasfontsize} +\membersection{wxTextAttr::HasFontSize}\label{wxtextattrhasfontsize} \constfunc{bool}{HasFontSize}{\void} Returns \true if the attribute object specifies a font point size. -\membersection{wxRichTextAttr::HasTabs}\label{wxrichtextattrhastabs} +\membersection{wxTextAttr::HasTabs}\label{wxtextattrhastabs} \constfunc{bool}{HasTabs}{\void} Returns \true if the attribute object specifies tab stops. -\membersection{wxRichTextAttr::HasTextColour}\label{wxrichtextattrhastextcolour} +\membersection{wxTextAttr::HasTextColour}\label{wxtextattrhastextcolour} \constfunc{bool}{HasTextColour}{\void} Returns \true if the attribute object specifies a text foreground colour. -\membersection{wxRichTextAttr::HasTextEffects}\label{wxrichtextattrhastexteffects} +\membersection{wxTextAttr::HasTextEffects}\label{wxtextattrhastexteffects} \constfunc{bool}{HasTextEffects}{\void} Returns \true if the attribute object specifies text effects. -\membersection{wxRichTextAttr::HasFontUnderlined}\label{wxrichtextattrhasfontunderlined} - -\constfunc{bool}{HasFontUnderlined}{\void} - -Returns \true if the attribute object specifies either underlining or no underlining. - -\membersection{wxRichTextAttr::HasURL}\label{wxrichtextattrhasurl} - -\constfunc{bool}{HasURL}{\void} - -Returns \true if the attribute object specifies a URL. - -\membersection{wxRichTextAttr::HasFontWeight}\label{wxrichtextattrhasfontweight} - -\constfunc{bool}{HasFontWeight}{\void} - -Returns \true if the attribute object specifies font weight (bold, light or normal). - -\membersection{wxRichTextAttr::IsCharacterStyle}\label{wxrichtextattrischaracterstyle} +\membersection{wxTextAttr::IsCharacterStyle}\label{wxtextattrischaracterstyle} \constfunc{bool}{IsCharacterStyle}{\void} Returns \true if the object represents a character style, that is, the flags specify a font or a text background or foreground colour. -\membersection{wxRichTextAttr::IsDefault}\label{wxrichtextattrisdefault} +\membersection{wxTextAttr::IsDefault}\label{wxtextattrisdefault} \constfunc{bool}{IsDefault}{\void} Returns \false if we have any attributes set, \true otherwise. -\membersection{wxRichTextAttr::IsParagraphStyle}\label{wxrichtextattrisparagraphstyle} +\membersection{wxTextAttr::IsParagraphStyle}\label{wxtextattrisparagraphstyle} \constfunc{bool}{IsParagraphStyle}{\void} @@ -560,7 +565,21 @@ Returns \true if the object represents a paragraph style, that is, the flags specify alignment, indentation, tabs, paragraph spacing, or bullet style. -\membersection{wxRichTextAttr::SetAlignment}\label{wxrichtextattrsetalignment} +\membersection{wxTextAttr::Merge}\label{wxtextattrmerge} + +\func{void}{Merge}{\param{const wxTextAttr\&}{ overlay}} + +Copies all defined/valid properties from \arg{overlay} to current object. + +\func{static wxTextAttr}{Merge}{\param{const wxTextAttr\&}{ base}, \param{const wxTextAttr\&}{ overlay}} + +Creates a new {\tt wxTextAttr} which is a merge of \arg{base} and +\arg{overlay}. Properties defined in \arg{overlay} take precedence over those +in \arg{base}. Properties undefined/invalid in both are undefined in the +result. + + +\membersection{wxTextAttr::SetAlignment}\label{wxtextattrsetalignment} \func{void}{SetAlignment}{\param{wxTextAttrAlignment }{alignment}} @@ -583,34 +602,34 @@ enum wxTextAttrAlignment Of these, wxTEXT\_ALIGNMENT\_JUSTIFIED is unimplemented. In future justification may be supported when printing or previewing, only. -\membersection{wxRichTextAttr::SetBackgroundColour}\label{wxrichtextattrsetbackgroundcolour} +\membersection{wxTextAttr::SetBackgroundColour}\label{wxtextattrsetbackgroundcolour} \func{void}{SetBackgroundColour}{\param{const wxColour\& }{colBack}} Sets the background colour. -\membersection{wxRichTextAttr::SetBulletFont}\label{wxrichtextattrsetbulletfont} +\membersection{wxTextAttr::SetBulletFont}\label{wxtextattrsetbulletfont} \func{void}{SetBulletFont}{\param{const wxString\& }{font}} Sets the name of the font associated with the bullet symbol. Only valid for attributes with wxTEXT\_ATTR\_BULLET\_SYMBOL. -\membersection{wxRichTextAttr::SetBulletName}\label{wxrichtextattrsetbulletname} +\membersection{wxTextAttr::SetBulletName}\label{wxtextattrsetbulletname} \func{void}{SetBulletName}{\param{const wxString\& }{name}} Sets the standard bullet name, applicable if the bullet style is wxTEXT\_ATTR\_BULLET\_STYLE\_STANDARD. -See \helpref{wxRichTextAttr::GetBulletName}{wxrichtextattrgetbulletname} for a list +See \helpref{wxTextAttr::GetBulletName}{wxtextattrgetbulletname} for a list of supported names, and how to expand the range of supported types. -\membersection{wxRichTextAttr::SetBulletNumber}\label{wxrichtextattrsetbulletnumber} +\membersection{wxTextAttr::SetBulletNumber}\label{wxtextattrsetbulletnumber} \func{void}{SetBulletNumber}{\param{int }{n}} Sets the bullet number. -\membersection{wxRichTextAttr::SetBulletStyle}\label{wxrichtextattrsetbulletstyle} +\membersection{wxTextAttr::SetBulletStyle}\label{wxtextattrsetbulletstyle} \func{void}{SetBulletStyle}{\param{int }{style}} @@ -639,19 +658,19 @@ Sets the bullet style. The following styles can be passed: Currently wxTEXT\_ATTR\_BULLET\_STYLE\_BITMAP is not supported. -\membersection{wxRichTextAttr::SetBulletText}\label{wxrichtextattrsetbullettext} +\membersection{wxTextAttr::SetBulletText}\label{wxtextattrsetbullettext} \func{void}{SetBulletText}{\param{const wxString& }{text}} Sets the bullet text, which could be a symbol, or (for example) cached outline text. -\membersection{wxRichTextAttr::SetCharacterStyleName}\label{wxrichtextattrsetcharacterstylename} +\membersection{wxTextAttr::SetCharacterStyleName}\label{wxtextattrsetcharacterstylename} \func{void}{SetCharacterStyleName}{\param{const wxString\& }{name}} Sets the character style name. -\membersection{wxRichTextAttr::SetFlags}\label{wxrichtextattrsetflags} +\membersection{wxTextAttr::SetFlags}\label{wxtextattrsetflags} \func{void}{SetFlags}{\param{long }{flags}} @@ -696,37 +715,49 @@ flags can be passed in a bitlist: \end{verbatim} } -\membersection{wxRichTextAttr::SetFontFaceName}\label{wxrichtextattrsetfontfacename} +\membersection{wxTextAttr::SetFont}\label{wxtextattrsetfont} + +\func{void}{SetFont}{\param{const wxFont\&}{ font}} + +Sets the attributes for the given font. Note that wxTextAttr does not store an actual wxFont object. + +\membersection{wxTextAttr::SetFontEncoding}\label{wxtextattrsetfontencoding} + +\func{void}{SetFontEncoding}{\param{wxFontEncoding }{encoding}} + +Sets the font encoding. + +\membersection{wxTextAttr::SetFontFaceName}\label{wxtextattrsetfontfacename} \func{void}{SetFontFaceName}{\param{const wxString\& }{faceName}} Sets the paragraph alignment. -\membersection{wxRichTextAttr::SetFontSize}\label{wxrichtextattrsetfontsize} +\membersection{wxTextAttr::SetFontSize}\label{wxtextattrsetfontsize} \func{void}{SetFontSize}{\param{int }{pointSize}} Sets the font size in points. -\membersection{wxRichTextAttr::SetFontStyle}\label{wxrichtextattrsetfontstyle} +\membersection{wxTextAttr::SetFontStyle}\label{wxtextattrsetfontstyle} \func{void}{SetFontStyle}{\param{int }{fontStyle}} Sets the font style (normal, italic or slanted). -\membersection{wxRichTextAttr::SetFontUnderlined}\label{wxrichtextattrsetfontunderlined} +\membersection{wxTextAttr::SetFontUnderlined}\label{wxtextattrsetfontunderlined} \func{void}{SetFontUnderlined}{\param{bool }{underlined}} Sets the font underlining. -\membersection{wxRichTextAttr::SetFontWeight}\label{wxrichtextattrsetfontweight} +\membersection{wxTextAttr::SetFontWeight}\label{wxtextattrsetfontweight} \func{void}{SetFontWeight}{\param{int }{fontWeight}} Sets the font weight. -\membersection{wxRichTextAttr::SetLeftIndent}\label{wxrichtextattrsetleftindent} +\membersection{wxTextAttr::SetLeftIndent}\label{wxtextattrsetleftindent} \func{void}{SetLeftIndent}{\param{int }{indent}, \param{int }{subIndent = 0}} @@ -742,7 +773,7 @@ the margin and the bullet. The content of the paragraph, including the first lin at leftMargin + leftSubIndent. So the distance between the left edge of the bullet and the left of the actual paragraph is leftSubIndent. -\membersection{wxRichTextAttr::SetLineSpacing}\label{wxrichtextattrsetlinespacing} +\membersection{wxTextAttr::SetLineSpacing}\label{wxtextattrsetlinespacing} \func{void}{SetLineSpacing}{\param{int }{spacing}} @@ -758,13 +789,13 @@ defined for convenience: \end{verbatim} } -\membersection{wxRichTextAttr::SetListStyleName}\label{wxrichtextattrsetliststylename} +\membersection{wxTextAttr::SetListStyleName}\label{wxtextattrsetliststylename} \func{void}{SetListStyleName}{\param{const wxString\& }{name}} Sets the list style name. -\membersection{wxRichTextAttr::SetOutlineLevel}\label{wxrichtextattrsetoutlinelevel} +\membersection{wxTextAttr::SetOutlineLevel}\label{wxtextattrsetoutlinelevel} \func{void}{SetOutlineLevel}{\param{int}{ level}} @@ -772,57 +803,57 @@ Specifies the outline level. Zero represents normal text. At present, the outlin not used, but may be used in future for determining list levels and for applications that need to store document structure information. -\membersection{wxRichTextAttr::SetPageBreak}\label{wxrichtextattrsetpagebreak} +\membersection{wxTextAttr::SetPageBreak}\label{wxtextattrsetpagebreak} \func{void}{SetPageBreak}{\param{bool}{ pageBreak = true}} Specifies a page break before this paragraph. -\membersection{wxRichTextAttr::SetParagraphSpacingAfter}\label{wxrichtextattrsetparagraphspacingafter} +\membersection{wxTextAttr::SetParagraphSpacingAfter}\label{wxtextattrsetparagraphspacingafter} \func{void}{SetParagraphSpacingAfter}{\param{int }{spacing}} Sets the spacing after a paragraph, in tenths of a millimetre. -\membersection{wxRichTextAttr::SetParagraphSpacingBefore}\label{wxrichtextattrsetparagraphspacingbefore} +\membersection{wxTextAttr::SetParagraphSpacingBefore}\label{wxtextattrsetparagraphspacingbefore} \func{void}{SetParagraphSpacingBefore}{\param{int }{spacing}} Sets the spacing before a paragraph, in tenths of a millimetre. -\membersection{wxRichTextAttr::SetParagraphStyleName}\label{wxrichtextattrsetparagraphstylename} +\membersection{wxTextAttr::SetParagraphStyleName}\label{wxtextattrsetparagraphstylename} \func{void}{SetParagraphStyleName}{\param{const wxString\& }{name}} Sets the name of the paragraph style. -\membersection{wxRichTextAttr::SetRightIndent}\label{wxrichtextattrsetrightindent} +\membersection{wxTextAttr::SetRightIndent}\label{wxtextattrsetrightindent} \func{void}{SetRightIndent}{\param{int }{indent}} Sets the right indent in tenths of a millimetre. -\membersection{wxRichTextAttr::SetTabs}\label{wxrichtextattrsettabs} +\membersection{wxTextAttr::SetTabs}\label{wxtextattrsettabs} \func{void}{SetTabs}{\param{const wxArrayInt\& }{tabs}} Sets the tab stops, expressed in tenths of a millimetre. Each stop is measured from the left margin and therefore each value must be larger than the last. -\membersection{wxRichTextAttr::SetTextColour}\label{wxrichtextattrsettextcolour} +\membersection{wxTextAttr::SetTextColour}\label{wxtextattrsettextcolour} \func{void}{SetTextColour}{\param{const wxColour\& }{colText}} Sets the text foreground colout. -\membersection{wxRichTextAttr::SetTextEffectFlags}\label{wxrichtextattrsettexteffectflags} +\membersection{wxTextAttr::SetTextEffectFlags}\label{wxtextattrsettexteffectflags} \func{void}{SetTextEffectFlags}{\param{int }{flags}} -Sets the text effect bits of interest. You should also pass wxTEXT\_ATTR\_EFFECTS to \helpref{wxRichTextAttr::SetFlags}{wxrichtextattrsetflags}. -See \helpref{wxRichTextAttr::SetFlags}{wxrichtextattrsetflags} for further information. +Sets the text effect bits of interest. You should also pass wxTEXT\_ATTR\_EFFECTS to \helpref{wxTextAttr::SetFlags}{wxtextattrsetflags}. +See \helpref{wxTextAttr::SetFlags}{wxtextattrsetflags} for further information. -\membersection{wxRichTextAttr::SetTextEffects}\label{wxrichtextattrsettexteffects} +\membersection{wxTextAttr::SetTextEffects}\label{wxtextattrsettexteffects} \func{void}{SetTextEffects}{\param{int }{effects}} @@ -850,11 +881,11 @@ Of these, only wxTEXT\_ATTR\_EFFECT\_CAPITALS and wxTEXT\_ATTR\_EFFECT\_STRIKETH wxTEXT\_ATTR\_EFFECT\_CAPITALS capitalises text when displayed (leaving the case of the actual buffer text unchanged), and wxTEXT\_ATTR\_EFFECT\_STRIKETHROUGH draws a line through text. -To set effects, you should also pass wxTEXT\_ATTR\_EFFECTS to \helpref{wxRichTextAttr::SetFlags}{wxrichtextattrsetflags}, and call\rtfsp -\helpref{wxRichTextAttr::SetTextEffectFlags}{wxrichtextattrsettexteffectflags} with the styles (taken from the +To set effects, you should also pass wxTEXT\_ATTR\_EFFECTS to \helpref{wxTextAttr::SetFlags}{wxtextattrsetflags}, and call\rtfsp +\helpref{wxTextAttr::SetTextEffectFlags}{wxtextattrsettexteffectflags} with the styles (taken from the above set) that you are interested in setting. -\membersection{wxRichTextAttr::SetURL}\label{wxrichtextattrseturl} +\membersection{wxTextAttr::SetURL}\label{wxtextattrseturl} \func{void}{SetURL}{\param{const wxString\& }{url}} @@ -862,19 +893,9 @@ Sets the URL for the content. Sets the wxTEXT\_ATTR\_URL style; content with thi causes wxRichTextCtrl to show a hand cursor over it, and wxRichTextCtrl generates a wxTextUrlEvent when the content is clicked. -\membersection{wxRichTextAttr::operator=}\label{wxrichtextattroperatorassign} - -\func{void operator}{operator=}{\param{const wxTextAttrEx\& }{attr}} - -Assignment from a \helpref{wxTextAttrEx}{wxtextattr} object. - -\func{void operator}{operator=}{\param{const wxRichTextAttr\& }{attr}} - -Assignment from a \helpref{wxRichTextAttr}{wxrichtextattr} object. - -\membersection{wxRichTextAttr::wxTextAttrEx}\label{wxrichtextattrwxtextattrex} +\membersection{wxTextAttr::operator=}\label{wxtextattroperatorassign} -\constfunc{operator}{wxTextAttrEx}{\void} +\func{void operator}{operator=}{\param{const wxTextAttr\& }{attr}} -Makes a \helpref{wxTextAttrEx}{wxtextattrex} object from this object. +Assignment from a \helpref{wxTextAttr}{wxtextattr} object. diff --git a/docs/latex/wx/textattrex.tex b/docs/latex/wx/textattrex.tex deleted file mode 100644 index 43b7054..0000000 --- a/docs/latex/wx/textattrex.tex +++ /dev/null @@ -1,555 +0,0 @@ -\section{\class{wxTextAttrEx}}\label{wxtextattrex} - -wxTextAttrEx is an extended version of wxTextAttr with more paragraph attributes. -Currently it is only used with \helpref{wxRichTextCtrl}{wxrichtextctrl}. - -It is intended that eventually, the members of wxTextAttrEx will -be folded into wxTextAttr, and wxTextAttr will be the official -cross-platform API for text controls that support attributes. -However, for now, wxTextAttrEx is provided as a means of enabling -extra functionality in wxRichTextCtrl, while retaining some compatibility -with the wxTextAttr API. - -The most efficient method of accessing wxRichTextCtrl functionality -is a third attribute class, \helpref{wxRichTextAttr}{wxrichtextattr}, which -optimizes its storage to allow it to be used for implementing objects -in a buffer, as well as access to that buffer. - -This section only documents the additional members; see \helpref{wxTextAttr}{wxtextattr} for -the remaining functions. - -\wxheading{Derived from} - -\helpref{wxTextAttr}{wxtextattr} - -\wxheading{Include files} - - - -\wxheading{Library} - -\helpref{wxRichtext}{librarieslist} - -\wxheading{Constants} - -The following values can be passed to SetAlignment to determine -paragraph alignment. - -{\small -\begin{verbatim} -enum wxTextAttrAlignment -{ - wxTEXT_ALIGNMENT_DEFAULT, - wxTEXT_ALIGNMENT_LEFT, - wxTEXT_ALIGNMENT_CENTRE, - wxTEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE, - wxTEXT_ALIGNMENT_RIGHT, - wxTEXT_ALIGNMENT_JUSTIFIED -}; -\end{verbatim} -} - -These values are passed in a bitlist to SetFlags to determine -what attributes will be considered when setting the attributes -for a text control. - -{\small -\begin{verbatim} -// Standard wxTextAttr constants - -#define wxTEXT_ATTR_TEXT_COLOUR 0x0001 -#define wxTEXT_ATTR_BACKGROUND_COLOUR 0x0002 -#define wxTEXT_ATTR_FONT_FACE 0x0004 -#define wxTEXT_ATTR_FONT_SIZE 0x0008 -#define wxTEXT_ATTR_FONT_WEIGHT 0x0010 -#define wxTEXT_ATTR_FONT_ITALIC 0x0020 -#define wxTEXT_ATTR_FONT_UNDERLINE 0x0040 -#define wxTEXT_ATTR_FONT \ - wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT \ -| wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE -#define wxTEXT_ATTR_ALIGNMENT 0x0080 -#define wxTEXT_ATTR_LEFT_INDENT 0x0100 -#define wxTEXT_ATTR_RIGHT_INDENT 0x0200 -#define wxTEXT_ATTR_TABS 0x0400 - -// Extra formatting flags not in wxTextAttr - -#define wxTEXT_ATTR_PARA_SPACING_AFTER 0x00000800 -#define wxTEXT_ATTR_PARA_SPACING_BEFORE 0x00001000 -#define wxTEXT_ATTR_LINE_SPACING 0x00002000 -#define wxTEXT_ATTR_CHARACTER_STYLE_NAME 0x00004000 -#define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME 0x00008000 -#define wxTEXT_ATTR_LIST_STYLE_NAME 0x00010000 -#define wxTEXT_ATTR_BULLET_STYLE 0x00020000 -#define wxTEXT_ATTR_BULLET_NUMBER 0x00040000 -#define wxTEXT_ATTR_BULLET_TEXT 0x00080000 -#define wxTEXT_ATTR_BULLET_NAME 0x00100000 -#define wxTEXT_ATTR_URL 0x00200000 -#define wxTEXT_ATTR_PAGE_BREAK 0x00400000 -#define wxTEXT_ATTR_EFFECTS 0x00800000 -#define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000 -\end{verbatim} -} - -The following styles can be passed to wxTextAttrEx::SetBulletStyle: - -{\small -\begin{verbatim} -#define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000 -#define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001 -#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002 -#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004 -#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008 -#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010 -#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020 -#define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040 -#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080 -#define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100 -#define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200 -#define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400 -#define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000 -\end{verbatim} -} - -Of these, wxTEXT\_ATTR\_BULLET\_STYLE\_BITMAP is unimplemented. - -The following constants can be passed to wxTextAttrEx::SetLineSpacing: - -{\small -\begin{verbatim} -#define wxTEXT_ATTR_LINE_SPACING_NORMAL 10 -#define wxTEXT_ATTR_LINE_SPACING_HALF 15 -#define wxTEXT_ATTR_LINE_SPACING_TWICE 20 -\end{verbatim} -} - -The following styles can be passed to wxTextAttrEx::SetTextEffects: - -{\small -\begin{verbatim} -#define wxTEXT_ATTR_EFFECT_NONE 0x00000000 -#define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001 -#define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002 -#define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004 -#define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008 -#define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010 -#define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020 -#define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040 -#define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080 -#define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100 -#define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200 -\end{verbatim} -} - -Of these, only wxTEXT\_ATTR\_EFFECT\_CAPITALS and wxTEXT\_ATTR\_EFFECT\_STRIKETHROUGH are implemented. - -\wxheading{See also} - -\helpref{wxTextAttr}{wxtextattr}, \helpref{wxRichTextAttr}{wxrichtextattr}, \helpref{wxRichTextCtrl}{wxrichtextctrl} - -\latexignore{\rtfignore{\wxheading{Members}}} - - -\membersection{wxTextAttrEx::wxTextAttrEx}\label{wxtextattrexwxtextattrex} - -\func{}{wxTextAttrEx}{\void} - - -\func{}{wxTextAttrEx}{\param{const wxTextAttrEx\& }{attr}} - -Constructors. - -\membersection{wxTextAttrEx::GetBulletFont}\label{wxtextattrexgetbulletfont} - -\constfunc{const wxString\&}{GetBulletFont}{\void} - -Returns a string containing the name of the font associated with the bullet symbol. -Only valid for attributes with wxTEXT\_ATTR\_BULLET\_SYMBOL. - -\membersection{wxTextAttrEx::GetBulletName}\label{wxtextattrexgetbulletname} - -\constfunc{const wxString\&}{GetBulletName}{\void} - -Returns the standard bullet name, applicable if the bullet style is wxTEXT\_ATTR\_BULLET\_STYLE\_STANDARD. -Currently the following standard bullet names are supported: - -\begin{itemize}\itemsep=0pt -\item {\tt standard/circle} -\item {\tt standard/square} -\item {\tt standard/diamond} -\item {\tt standard/triangle} -\end{itemize} - -If you wish your application to support further bullet graphics, you can derive a -class from wxRichTextRenderer or wxRichTextStdRenderer, override {\tt DrawStandardBullet} and {\tt EnumerateStandardBulletNames}, and -set an instance of the class using \helpref{wxRichTextBuffer::SetRenderer}{wxrichtextbuffersetrenderer}. - -\membersection{wxTextAttrEx::GetBulletNumber}\label{wxtextattrexgetbulletnumber} - -\constfunc{int}{GetBulletNumber}{\void} - -Returns the bullet number. - -\membersection{wxTextAttrEx::GetBulletStyle}\label{wxtextattrexgetbulletstyle} - -\constfunc{int}{GetBulletStyle}{\void} - -Returns the bullet style. -See \helpref{wxTextAttrEx::SetBulletStyle}{wxtextattrexsetbulletstyle} for a list of available styles. - -\membersection{wxTextAttrEx::GetBulletText}\label{wxtextattrexgetbullettext} - -\constfunc{const wxString\&}{GetBulletText}{\void} - -Returns the bullet text, which could be a symbol, or (for example) cached outline text. - -\membersection{wxTextAttrEx::GetCharacterStyleName}\label{wxtextattrexgetcharacterstylename} - -\constfunc{const wxString\&}{GetCharacterStyleName}{\void} - -Returns the name of the character style. - -\membersection{wxTextAttrEx::GetLineSpacing}\label{wxtextattrexgetlinespacing} - -\constfunc{int}{GetLineSpacing}{\void} - -Returns the line spacing value, one of wxTEXT\_ATTR\_LINE\_SPACING\_NORMAL, -wxTEXT\_ATTR\_LINE\_SPACING\_HALF, and wxTEXT\_ATTR\_LINE\_SPACING\_TWICE. - -\membersection{wxTextAttrEx::GetListStyleName}\label{wxtextattrexgetliststylename} - -\constfunc{const wxString\&}{GetListStyleName}{\void} - -Returns the name of the list style. - -\membersection{wxTextAttrEx::GetOutlineLevel}\label{wxtextattrexgetoutlinelevel} - -\constfunc{bool}{GetOutlineLevel}{\void} - -Returns the outline level. - -\membersection{wxTextAttrEx::GetParagraphSpacingAfter}\label{wxtextattrexgetparagraphspacingafter} - -\constfunc{int}{GetParagraphSpacingAfter}{\void} - -Returns the space in tenths of a millimeter after the paragraph. - -\membersection{wxTextAttrEx::GetParagraphSpacingBefore}\label{wxtextattrexgetparagraphspacingbefore} - -\constfunc{int}{GetParagraphSpacingBefore}{\void} - -Returns the space in tenths of a millimeter before the paragraph. - -\membersection{wxTextAttrEx::GetParagraphStyleName}\label{wxtextattrexgetparagraphstylename} - -\constfunc{const wxString\&}{GetParagraphStyleName}{\void} - -Returns the name of the paragraph style. - -\membersection{wxTextAttrEx::GetTextEffectFlags}\label{wxtextattrexgettexteffectflags} - -\constfunc{int}{GetTextEffectFlags}{\void} - -Returns the text effect bits of interest. See \helpref{wxTextAttr::SetFlags}{wxtextattrsetflags} for further information. - -\membersection{wxTextAttrEx::GetTextEffects}\label{wxtextattrexgettexteffects} - -\constfunc{int}{GetTextEffects}{\void} - -Returns the text effects, a bit list of styles. See \helpref{wxTextAttrEx::SetTextEffects}{wxtextattrexsettexteffects} for -details. - -\membersection{wxTextAttrEx::GetURL}\label{wxtextattrexgeturl} - -\constfunc{const wxString\&}{GetURL}{\void} - -Returns the URL for the content. Content with wxTEXT\_ATTR\_URL style -causes wxRichTextCtrl to show a hand cursor over it, and wxRichTextCtrl generates -a wxTextUrlEvent when the content is clicked. - -\membersection{wxTextAttrEx::HasBulletName}\label{wxtextattrexhasbulletname} - -\constfunc{bool}{HasBulletName}{\void} - -Returns \true if the attribute object specifies a standard bullet name. - -\membersection{wxTextAttrEx::HasBulletNumber}\label{wxtextattrexhasbulletnumber} - -\constfunc{bool}{HasBulletNumber}{\void} - -Returns \true if the attribute object specifies a bullet number. - -\membersection{wxTextAttrEx::HasBulletStyle}\label{wxtextattrexhasbulletstyle} - -\constfunc{bool}{HasBulletStyle}{\void} - -Returns \true if the attribute object specifies a bullet style. - -\membersection{wxTextAttrEx::HasBulletText}\label{wxtextattrexhasbullettext} - -\constfunc{bool}{HasBulletText}{\void} - -Returns \true if the attribute object specifies bullet text (usually containing a symbol). - -\membersection{wxTextAttrEx::HasCharacterStyleName}\label{wxtextattrexhascharacterstylename} - -\constfunc{bool}{HasCharacterStyleName}{\void} - -Returns \true if the attribute object specifies a character style name. - -\membersection{wxTextAttrEx::HasLineSpacing}\label{wxtextattrexhaslinespacing} - -\constfunc{bool}{HasLineSpacing}{\void} - -Returns \true if the attribute object specifies line spacing. - -\membersection{wxTextAttrEx::HasListStyleName}\label{wxtextattrexhasliststylename} - -\constfunc{bool}{HasListStyleName}{\void} - -Returns \true if the attribute object specifies a list style name. - -\membersection{wxTextAttrEx::HasOutlineLevel}\label{wxtextattrexhasoutlinelevel} - -\constfunc{bool}{HasOutlineLevel}{\void} - -Returns \true if the attribute object specifies an outline level. - -\membersection{wxTextAttrEx::HasPageBreak}\label{wxtextattrexhaspagebreak} - -\constfunc{bool}{HasPageBreak}{\void} - -Returns \true if the attribute object specifies a page break before this paragraph. - -\membersection{wxTextAttrEx::HasParagraphSpacingAfter}\label{wxtextattrexhasparagraphspacingafter} - -\constfunc{bool}{HasParagraphSpacingAfter}{\void} - -Returns \true if the attribute object specifies spacing after a paragraph. - -\membersection{wxTextAttrEx::HasParagraphSpacingBefore}\label{wxtextattrexhasparagraphspacingbefore} - -\constfunc{bool}{HasParagraphSpacingBefore}{\void} - -Returns \true if the attribute object specifies spacing before a paragraph. - -\membersection{wxTextAttrEx::HasParagraphStyleName}\label{wxtextattrexhasparagraphstylename} - -\constfunc{bool}{HasParagraphStyleName}{\void} - -Returns \true if the attribute object specifies a paragraph style name. - -\membersection{wxTextAttrEx::HasTextEffects}\label{wxtextattrexhastexteffects} - -\constfunc{bool}{HasTextEffects}{\void} - -Returns \true if the attribute object specifies text effects. - -\membersection{wxTextAttrEx::HasURL}\label{wxtextattrexhasurl} - -\constfunc{bool}{HasURL}{\void} - -Returns \true if the attribute object specifies a URL. - -\membersection{wxTextAttrEx::Init}\label{wxtextattrexinit} - -\func{void}{Init}{\void} - -Initialises this object. - -\membersection{wxTextAttrEx::IsCharacterStyle}\label{wxtextattrexischaracterstyle} - -\constfunc{bool}{IsCharacterStyle}{\void} - -Returns \true if the object represents a character style, that is, -the flags specify a font or a text background or foreground colour. - -\membersection{wxTextAttrEx::IsDefault}\label{wxtextattrexisdefault} - -\constfunc{bool}{IsDefault}{\void} - -Returns \false if we have any attributes set, \true otherwise. - -\membersection{wxTextAttrEx::IsParagraphStyle}\label{wxtextattrexisparagraphstyle} - -\constfunc{bool}{IsParagraphStyle}{\void} - -Returns \true if the object represents a paragraph style, that is, -the flags specify alignment, indentation, tabs, paragraph spacing, or -bullet style. - -\membersection{wxTextAttrEx::SetBulletFont}\label{wxtextattrexsetbulletfont} - -\func{void}{SetBulletFont}{\param{const wxString\& }{font}} - -Sets the name of the font associated with the bullet symbol. -Only valid for attributes with wxTEXT\_ATTR\_BULLET\_SYMBOL. - -\membersection{wxTextAttrEx::SetBulletNumber}\label{wxtextattrexsetbulletnumber} - -\func{void}{SetBulletNumber}{\param{int }{n}} - -Sets the bullet number. - -\membersection{wxTextAttrEx::SetBulletName}\label{wxtextattrexsetbulletname} - -\func{void}{SetBulletName}{\param{const wxString\& }{name}} - -Sets the standard bullet name, applicable if the bullet style is wxTEXT\_ATTR\_BULLET\_STYLE\_STANDARD. -See \helpref{wxTextAttrEx::GetBulletName}{wxtextattrexgetbulletname} for a list -of supported names, and how to expand the range of supported types. - -\membersection{wxTextAttrEx::SetBulletStyle}\label{wxtextattrexsetbulletstyle} - -\func{void}{SetBulletStyle}{\param{int }{style}} - -Sets the bullet style. The following styles can be passed: - -{\small -\begin{verbatim} -#define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000 -#define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001 -#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002 -#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004 -#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008 -#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010 -#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020 -#define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040 -#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080 -#define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100 -#define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200 -#define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400 -#define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000 -\end{verbatim} -} - -Currently wxTEXT\_ATTR\_BULLET\_STYLE\_BITMAP is not supported. - -\membersection{wxTextAttrEx::SetBulletText}\label{wxtextattrexsetbullettext} - -\func{void}{SetBulletText}{\param{const wxString\& }{text}} - -Sets the bullet text, which could be a symbol, or (for example) cached outline text. - -\membersection{wxTextAttrEx::SetCharacterStyleName}\label{wxtextattrexsetcharacterstylename} - -\func{void}{SetCharacterStyleName}{\param{const wxString\& }{name}} - -Sets the character style name. - -\membersection{wxTextAttrEx::SetLineSpacing}\label{wxtextattrexsetlinespacing} - -\func{void}{SetLineSpacing}{\param{int }{spacing}} - -Sets the line spacing. {\it spacing} is a multiple, where 10 means single-spacing, -15 means 1.5 spacing, and 20 means double spacing. The following constants are -defined for convenience: - -{\small -\begin{verbatim} -#define wxTEXT_ATTR_LINE_SPACING_NORMAL 10 -#define wxTEXT_ATTR_LINE_SPACING_HALF 15 -#define wxTEXT_ATTR_LINE_SPACING_TWICE 20 -\end{verbatim} -} - -\membersection{wxTextAttrEx::SetListStyleName}\label{wxtextattrexsetliststylename} - -\func{void}{SetListStyleName}{\param{const wxString\& }{name}} - -Sets the list style name. - -\membersection{wxTextAttrEx::SetOutlineLevel}\label{wxtextattrexsetoutlinelevel} - -\func{void}{SetOutlineLevel}{\param{int}{ level}} - -Specifies the outline level. Zero represents normal text. At present, the outline level is -not used, but may be used in future for determining list levels and for applications -that need to store document structure information. - -\membersection{wxTextAttrEx::SetPageBreak}\label{wxtextattrexsetpagebreak} - -\func{void}{SetPageBreak}{\param{bool}{ pageBreak = true}} - -Specifies a page break before this paragraph. - -\membersection{wxTextAttrEx::SetParagraphSpacingAfter}\label{wxtextattrexsetparagraphspacingafter} - -\func{void}{SetParagraphSpacingAfter}{\param{int }{spacing}} - -Sets the spacing after a paragraph, in tenths of a millimetre. - -\membersection{wxTextAttrEx::SetParagraphSpacingBefore}\label{wxtextattrexsetparagraphspacingbefore} - -\func{void}{SetParagraphSpacingBefore}{\param{int }{spacing}} - -Sets the spacing before a paragraph, in tenths of a millimetre. - -\membersection{wxTextAttrEx::SetParagraphStyleName}\label{wxtextattrexsetparagraphstylename} - -\func{void}{SetParagraphStyleName}{\param{const wxString\& }{name}} - -Sets the name of the paragraph style. - -\membersection{wxTextAttrEx::SetTextEffectFlags}\label{wxtextattrexsettexteffectflags} - -\func{void}{SetTextEffectFlags}{\param{int }{flags}} - -Sets the text effect bits of interest. You should also pass wxTEXT\_ATTR\_EFFECTS to \helpref{wxTextAttr::SetFlags}{wxtextattrsetflags}. - -\membersection{wxTextAttrEx::SetTextEffects}\label{wxtextattrexsettexteffects} - -\func{void}{SetTextEffects}{\param{int }{effects}} - -Sets the text effects, a bit list of styles. - -The following styles can be passed: - -{\small -\begin{verbatim} -#define wxTEXT_ATTR_EFFECT_NONE 0x00000000 -#define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001 -#define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002 -#define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004 -#define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008 -#define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010 -#define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020 -#define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040 -#define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080 -#define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100 -#define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200 -\end{verbatim} -} - -Of these, only wxTEXT\_ATTR\_EFFECT\_CAPITALS and wxTEXT\_ATTR\_EFFECT\_STRIKETHROUGH are implemented. -wxTEXT\_ATTR\_EFFECT\_CAPITALS capitalises text when displayed (leaving the case of the actual buffer -text unchanged), and wxTEXT\_ATTR\_EFFECT\_STRIKETHROUGH draws a line through text. - -To set effects, you should also pass wxTEXT\_ATTR\_EFFECTS to \helpref{wxTextAttr::SetFlags}{wxtextattrsetflags}, and call\rtfsp -\helpref{wxTextAttrEx::SetTextEffectFlags}{wxtextattrexsettexteffectflags} with the styles (taken from the -above set) that you are interested in setting. - -\membersection{wxTextAttrEx::SetURL}\label{wxtextattrexseturl} - -\func{void}{SetURL}{\param{const wxString\& }{url}} - -Sets the URL for the content. Sets the wxTEXT\_ATTR\_URL style; content with this style -causes wxRichTextCtrl to show a hand cursor over it, and wxRichTextCtrl generates -a wxTextUrlEvent when the content is clicked. - -\membersection{wxTextAttrEx::operator=}\label{wxtextattrexoperatorassign} - -\func{void operator}{operator=}{\param{const wxTextAttr\& }{attr}} - -Assignment from a wxTextAttr object. - -\func{void operator}{operator=}{\param{const wxTextAttrEx\& }{attr}} - -Assignment from a wxTextAttrEx object. - diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index b8d2912..b956071 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -70,6 +70,10 @@ #include "wx/dataobj.h" #endif +// Compatibility +#define wxRichTextAttr wxTextAttr +#define wxTextAttrEx wxTextAttr + /*! * Special characters */ @@ -99,7 +103,6 @@ class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextLine; class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraph; class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFileHandler; class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleSheet; -class WXDLLIMPEXP_FWD_RICHTEXT wxTextAttrEx; class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextListStyleDefinition; class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextEvent; class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextRenderer; @@ -194,86 +197,36 @@ class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextBuffer; #define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE 0x01 /*! - * Extra formatting flags not in wxTextAttr - */ - -#define wxTEXT_ATTR_PARA_SPACING_AFTER 0x00000800 -#define wxTEXT_ATTR_PARA_SPACING_BEFORE 0x00001000 -#define wxTEXT_ATTR_LINE_SPACING 0x00002000 -#define wxTEXT_ATTR_CHARACTER_STYLE_NAME 0x00004000 -#define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME 0x00008000 -#define wxTEXT_ATTR_LIST_STYLE_NAME 0x00010000 -#define wxTEXT_ATTR_BULLET_STYLE 0x00020000 -#define wxTEXT_ATTR_BULLET_NUMBER 0x00040000 -#define wxTEXT_ATTR_BULLET_TEXT 0x00080000 -#define wxTEXT_ATTR_BULLET_NAME 0x00100000 -#define wxTEXT_ATTR_URL 0x00200000 -#define wxTEXT_ATTR_PAGE_BREAK 0x00400000 -#define wxTEXT_ATTR_EFFECTS 0x00800000 -#define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000 - -/*! - * Styles for wxTextAttrEx::SetBulletStyle + * wxRichTextFontTable + * Manages quick access to a pool of fonts for rendering rich text */ -#define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000 -#define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001 -#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002 -#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004 -#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008 -#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010 -#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020 -#define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040 -#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080 -#define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100 -#define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200 -#define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400 -#define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800 - -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000 -#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000 - -/*! - * Styles for wxTextAttrEx::SetTextEffects - */ - -#define wxTEXT_ATTR_EFFECT_NONE 0x00000000 -#define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001 -#define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002 -#define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004 -#define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008 -#define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010 -#define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020 -#define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040 -#define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080 -#define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100 -#define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200 +class WXDLLIMPEXP_RICHTEXT wxRichTextFontTable: public wxObject +{ +public: + wxRichTextFontTable(); -/*! - * Line spacing values - */ + wxRichTextFontTable(const wxRichTextFontTable& table); + virtual ~wxRichTextFontTable(); -#define wxTEXT_ATTR_LINE_SPACING_NORMAL 10 -#define wxTEXT_ATTR_LINE_SPACING_HALF 15 -#define wxTEXT_ATTR_LINE_SPACING_TWICE 20 + bool IsOk() const { return m_refData != NULL; } -/*! - * Character and paragraph combined styles - */ + wxFont FindFont(const wxTextAttr& fontSpec); + void Clear(); -#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT|wxTEXT_ATTR_EFFECTS|wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL) + void operator= (const wxRichTextFontTable& table); + bool operator == (const wxRichTextFontTable& table) const; + bool operator != (const wxRichTextFontTable& table) const { return !(*this == table); } -#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_TEXT|wxTEXT_ATTR_BULLET_NAME|\ - wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL) +protected: -#define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) + DECLARE_DYNAMIC_CLASS(wxRichTextFontTable) +}; /*! * wxRichTextRange class declaration * This stores beginning and end positions for a range of data. + * TODO: consider renaming wxTextRange and using for all text controls. */ class WXDLLIMPEXP_RICHTEXT wxRichTextRange @@ -336,331 +289,6 @@ protected: #define wxRICHTEXT_NONE wxRichTextRange(-1, -1) /*! - * wxTextAttrEx is an extended version of wxTextAttr with more paragraph attributes. - */ - -class WXDLLIMPEXP_RICHTEXT wxTextAttrEx: public wxTextAttr -{ -public: - // ctors - wxTextAttrEx(const wxTextAttrEx& attr); - wxTextAttrEx(const wxTextAttr& attr) { Init(); (*this) = attr; } - wxTextAttrEx() { Init(); } - - // Initialise this object - void Init(); - - // Copy - void Copy(const wxTextAttrEx& attr); - - // Assignment from a wxTextAttrEx object - void operator= (const wxTextAttrEx& attr); - - // Assignment from a wxTextAttr object - void operator= (const wxTextAttr& attr); - - // Equality test - bool operator== (const wxTextAttrEx& attr) const; - - // setters - 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 SetListStyleName(const wxString& name) { m_listStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_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 SetBulletText(const wxString& text) { m_bulletText = text; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_TEXT); } - void SetBulletName(const wxString& name) { m_bulletName = name; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NAME); } - void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; } - void SetURL(const wxString& url) { m_urlTarget = url; SetFlags(GetFlags() | wxTEXT_ATTR_URL); } - void SetPageBreak(bool pageBreak = true) { SetFlags(pageBreak ? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK)); } - void SetTextEffects(int effects) { m_textEffects = effects; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS); } - void SetTextEffectFlags(int effects) { m_textEffectFlags = effects; } - void SetOutlineLevel(int level) { m_outlineLevel = level; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL); } - - const wxString& GetCharacterStyleName() const { return m_characterStyleName; } - const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; } - const wxString& GetListStyleName() const { return m_listStyleName; } - 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; } - const wxString& GetBulletText() const { return m_bulletText; } - const wxString& GetBulletName() const { return m_bulletName; } - const wxString& GetBulletFont() const { return m_bulletFont; } - const wxString& GetURL() const { return m_urlTarget; } - int GetTextEffects() const { return m_textEffects; } - int GetTextEffectFlags() const { return m_textEffectFlags; } - int GetOutlineLevel() const { return m_outlineLevel; } - - bool HasFontWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; } - bool HasFontSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; } - bool HasFontItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC) != 0; } - bool HasFontUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } - bool HasFontFaceName() 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) && !m_characterStyleName.IsEmpty(); } - bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && !m_paragraphStyleName.IsEmpty(); } - bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME) || !m_listStyleName.IsEmpty(); } - bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE); } - bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER); } - bool HasBulletText() const { return HasFlag(wxTEXT_ATTR_BULLET_TEXT); } - bool HasBulletName() const { return HasFlag(wxTEXT_ATTR_BULLET_NAME); } - bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL); } - bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK); } - bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS); } - bool HasTextEffect(int effect) const { return HasFlag(wxTEXT_ATTR_EFFECTS) && ((GetTextEffectFlags() & effect) != 0); } - bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); } - - // Is this a character style? - bool IsCharacterStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_CHARACTER)); } - bool IsParagraphStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_PARAGRAPH)); } - - // returns false if we have any attributes set, true otherwise - bool IsDefault() const - { - return (GetFlags() == 0); - } - - // 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; - int m_paragraphSpacingBefore; - int m_lineSpacing; - int m_bulletStyle; - int m_bulletNumber; - int m_textEffects; - int m_textEffectFlags; - int m_outlineLevel; - wxString m_bulletText; - wxString m_bulletFont; - wxString m_bulletName; - wxString m_urlTarget; - - // Character style - wxString m_characterStyleName; - - // Paragraph style - wxString m_paragraphStyleName; - - // List style - wxString m_listStyleName; -}; - -/*! - * wxRichTextAttr stores attributes without a wxFont object, so is a much more - * efficient way to query styles. - */ - -class WXDLLIMPEXP_RICHTEXT wxRichTextAttr -{ -public: - // ctors - wxRichTextAttr(const wxTextAttrEx& attr); - wxRichTextAttr(const wxRichTextAttr& attr); - wxRichTextAttr() { Init(); } - wxRichTextAttr(const wxColour& colText, - const wxColour& colBack = wxNullColour, - wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT); - - // Initialise this object. - void Init(); - - // Copy - void Copy(const wxRichTextAttr& attr); - - // Assignment from a wxRichTextAttr object. - void operator= (const wxRichTextAttr& attr); - - // Assignment from a wxTextAttrEx object. - void operator= (const wxTextAttrEx& attr); - - // Equality test - bool operator== (const wxRichTextAttr& attr) const; - - // Making a wxTextAttrEx object. - operator wxTextAttrEx () 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; m_flags |= wxTEXT_ATTR_CHARACTER_STYLE_NAME; } - void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; m_flags |= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME; } - void SetListStyleName(const wxString& name) { m_listStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_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 SetBulletText(const wxString& text) { m_bulletText = text; m_flags |= wxTEXT_ATTR_BULLET_TEXT; } - void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; } - void SetBulletName(const wxString& name) { m_bulletName = name; m_flags |= wxTEXT_ATTR_BULLET_NAME; } - void SetURL(const wxString& url) { m_urlTarget = url; m_flags |= wxTEXT_ATTR_URL; } - void SetPageBreak(bool pageBreak = true) { SetFlags(pageBreak ? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK)); } - void SetTextEffects(int effects) { m_textEffects = effects; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS); } - void SetTextEffectFlags(int effects) { m_textEffectFlags = effects; } - void SetOutlineLevel(int level) { m_outlineLevel = level; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL); } - - 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; } - const wxString& GetListStyleName() const { return m_listStyleName; } - 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; } - const wxString& GetBulletText() const { return m_bulletText; } - const wxString& GetBulletFont() const { return m_bulletFont; } - const wxString& GetBulletName() const { return m_bulletName; } - const wxString& GetURL() const { return m_urlTarget; } - int GetTextEffects() const { return m_textEffects; } - int GetTextEffectFlags() const { return m_textEffectFlags; } - int GetOutlineLevel() const { return m_outlineLevel; } - - // 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 HasFontWeight() const { return (m_flags & wxTEXT_ATTR_FONT_WEIGHT) != 0; } - bool HasFontSize() const { return (m_flags & wxTEXT_ATTR_FONT_SIZE) != 0; } - bool HasFontItalic() const { return (m_flags & wxTEXT_ATTR_FONT_ITALIC) != 0; } - bool HasFontUnderlined() const { return (m_flags & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } - bool HasFontFaceName() 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 && !m_characterStyleName.IsEmpty(); } - bool HasParagraphStyleName() const { return (m_flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) != 0 && !m_paragraphStyleName.IsEmpty(); } - bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME) || !m_listStyleName.IsEmpty(); } - bool HasBulletStyle() const { return (m_flags & wxTEXT_ATTR_BULLET_STYLE) != 0; } - bool HasBulletNumber() const { return (m_flags & wxTEXT_ATTR_BULLET_NUMBER) != 0; } - bool HasBulletText() const { return (m_flags & wxTEXT_ATTR_BULLET_TEXT) != 0; } - bool HasBulletName() const { return (m_flags & wxTEXT_ATTR_BULLET_NAME) != 0; } - bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL); } - bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK); } - bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS); } - bool HasTextEffect(int effect) const { return HasFlag(wxTEXT_ATTR_EFFECTS) && ((GetTextEffectFlags() & effect) != 0); } - bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); } - - bool HasFlag(long flag) const { return (m_flags & flag) != 0; } - - // Is this a character style? - bool IsCharacterStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_CHARACTER)); } - bool IsParagraphStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_PARAGRAPH)); } - - // returns false if we have any attributes set, true otherwise - bool IsDefault() const - { - return GetFlags() == 0; - } - - // Merges the given attributes. Does not affect 'this'. If compareWith - // is non-NULL, then it will be used to mask out those attributes that are the same in style - // and compareWith, for situations where we don't want to explicitly set inherited attributes. - bool Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith = NULL); - - // Merges the given attributes and returns the result. Does not affect 'this'. If compareWith - // is non-NULL, then it will be used to mask out those attributes that are the same in style - // and compareWith, for situations where we don't want to explicitly set inherited attributes. - wxRichTextAttr Combine(const wxRichTextAttr& style, const wxRichTextAttr* compareWith = NULL) const; - -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; - int m_textEffects; - int m_textEffectFlags; - int m_outlineLevel; - wxString m_bulletText; - wxString m_bulletFont; - wxString m_bulletName; - wxString m_urlTarget; - - // 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; - - // List style - wxString m_listStyleName; -}; - -/*! * wxRichTextObject class declaration * This is the base for drawable objects. */ @@ -766,9 +394,9 @@ public: virtual int GetBottomMargin() const { return m_bottomMargin; } /// Set attributes object - void SetAttributes(const wxTextAttrEx& attr) { m_attributes = attr; } - const wxTextAttrEx& GetAttributes() const { return m_attributes; } - wxTextAttrEx& GetAttributes() { return m_attributes; } + void SetAttributes(const wxTextAttr& attr) { m_attributes = attr; } + const wxTextAttr& GetAttributes() const { return m_attributes; } + wxTextAttr& GetAttributes() { return m_attributes; } /// Set/get stored descent void SetDescent(int descent) { m_descent = descent; } @@ -812,7 +440,7 @@ protected: int m_bottomMargin; /// Attributes - wxTextAttrEx m_attributes; + wxTextAttr m_attributes; }; WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_RICHTEXT ); @@ -1000,13 +628,13 @@ public: virtual void Reset(); /// Convenience function to add a paragraph of text - virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttrEx* paraStyle = NULL); + virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttr* paraStyle = NULL); /// Convenience function to add an image - virtual wxRichTextRange AddImage(const wxImage& image, wxTextAttrEx* paraStyle = NULL); + virtual wxRichTextRange AddImage(const wxImage& image, wxTextAttr* paraStyle = NULL); /// Adds multiple paragraphs, based on newlines. - virtual wxRichTextRange AddParagraphs(const wxString& text, wxTextAttrEx* paraStyle = NULL); + virtual wxRichTextRange AddParagraphs(const wxString& text, wxTextAttr* paraStyle = NULL); /// Get the line at the given position. If caretPosition is true, the position is /// a caret position, which is normally a smaller number. @@ -1060,28 +688,25 @@ public: virtual bool PositionToXY(long pos, long* x, long* y) const; /// Set text attributes: character and/or paragraph styles. - virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); - virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttrEx& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); + virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); /// Get the conbined text attributes for this position. - virtual bool GetStyle(long position, wxTextAttrEx& style); - virtual bool GetStyle(long position, wxRichTextAttr& style); + virtual bool GetStyle(long position, wxTextAttr& style); /// Get the content (uncombined) attributes for this position. - virtual bool GetUncombinedStyle(long position, wxTextAttrEx& style); - virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style); + virtual bool GetUncombinedStyle(long position, wxTextAttr& style); /// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and /// context attributes. - virtual bool DoGetStyle(long position, wxTextAttrEx& style, bool combineStyles = true); + virtual bool DoGetStyle(long position, wxTextAttr& style, bool combineStyles = true); /// Get the combined style for a range - if any attribute is different within the range, /// that attribute is not present within the flags - virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttrEx& style); + virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style); /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of /// content. - bool CollectStyle(wxTextAttrEx& currentStyle, const wxTextAttrEx& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes); + bool CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes); /// Set list style virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); @@ -1105,21 +730,19 @@ public: virtual bool DoNumberList(const wxRichTextRange& range, const wxRichTextRange& promotionRange, int promoteBy, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); /// Fills in the attributes for numbering a paragraph after previousParagraph. - virtual bool FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const; + virtual bool FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxTextAttr& attr) const; /// Test if this whole range has character attributes of the specified kind. If any /// of the attributes are different within the range, the test fails. You /// can use this to implement, for example, bold button updating. style must have /// flags indicating which attributes are of interest. - virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const; - virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const; + virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttr& style) const; /// Test if this whole range has paragraph attributes of the specified kind. If any /// of the attributes are different within the range, the test fails. You /// can use this to implement, for example, centering button updating. style must have /// flags indicating which attributes are of interest. - virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const; - virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const; + virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttr& style) const; /// Clone virtual wxRichTextObject* Clone() const { return new wxRichTextParagraphLayoutBox(*this); } @@ -1149,17 +772,16 @@ public: /// Set default style for new content. Setting it to a default attribute /// makes new content take on the 'basic' style. - virtual bool SetDefaultStyle(const wxTextAttrEx& style); + virtual bool SetDefaultStyle(const wxTextAttr& style); /// Get default style - virtual const wxTextAttrEx& GetDefaultStyle() const { return m_defaultAttributes; } + virtual const wxTextAttr& GetDefaultStyle() const { return m_defaultAttributes; } /// Set basic (overall) style - virtual void SetBasicStyle(const wxTextAttrEx& style) { m_attributes = style; } - virtual void SetBasicStyle(const wxRichTextAttr& style) { m_attributes = style; } + virtual void SetBasicStyle(const wxTextAttr& style) { m_attributes = style; } /// Get basic (overall) style - virtual const wxTextAttrEx& GetBasicStyle() const { return m_attributes; } + virtual const wxTextAttr& GetBasicStyle() const { return m_attributes; } /// Invalidate the buffer. With no argument, invalidates whole buffer. void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL); @@ -1169,7 +791,7 @@ public: protected: wxRichTextCtrl* m_ctrl; - wxTextAttrEx m_defaultAttributes; + wxTextAttr m_defaultAttributes; /// The invalidated range that will need full layout wxRichTextRange m_invalidRange; @@ -1271,8 +893,8 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph: public wxRichTextBox public: // Constructors - wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL); - wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* paraStyle = NULL, wxTextAttrEx* charStyle = NULL); + wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttr* style = NULL); + wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttr* paraStyle = NULL, wxTextAttr* charStyle = NULL); virtual ~wxRichTextParagraph(); wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { Copy(obj); } @@ -1317,7 +939,7 @@ public: // Implementation /// Apply paragraph styles such as centering to the wrapped lines - virtual void ApplyParagraphStyle(const wxTextAttrEx& attr, const wxRect& rect); + virtual void ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect); /// Insert text at the given position virtual bool InsertText(long pos, const wxString& text); @@ -1354,10 +976,10 @@ public: /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically /// retrieve the actual style. - wxTextAttrEx GetCombinedAttributes(const wxTextAttrEx& contentStyle) const; + wxTextAttr GetCombinedAttributes(const wxTextAttr& contentStyle) const; /// Get combined attributes of the base style and paragraph style. - wxTextAttrEx GetCombinedAttributes() const; + wxTextAttr GetCombinedAttributes() const; /// Get the first position from pos that has a line break character. long GetFirstLineBreakPosition(long pos); @@ -1390,7 +1012,7 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText: public wxRichTextObject public: // Constructors - wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL); + wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxTextAttr* style = NULL); wxRichTextPlainText(const wxRichTextPlainText& obj): wxRichTextObject() { Copy(obj); } // Overrideables @@ -1450,7 +1072,7 @@ public: /// Clone virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); } private: - bool DrawTabbedString(wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected); + bool DrawTabbedString(wxDC& dc, const wxTextAttr& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected); protected: wxString m_text; @@ -1551,8 +1173,8 @@ public: // Constructors wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextObject(parent) { } - wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxTextAttrEx* charStyle = NULL); - wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxTextAttrEx* charStyle = NULL); + wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxTextAttr* charStyle = NULL); + wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxTextAttr* charStyle = NULL); wxRichTextImage(const wxRichTextImage& obj): wxRichTextObject() { Copy(obj); } // Overrideables @@ -1639,6 +1261,11 @@ public: /// Pop style sheet from top of stack wxRichTextStyleSheet* PopStyleSheet(); + /// Set/get table storing fonts + wxRichTextFontTable& GetFontTable() { return m_fontTable; } + const wxRichTextFontTable& GetFontTable() const { return m_fontTable; } + void SetFontTable(const wxRichTextFontTable& table) { m_fontTable = table; } + // Operations /// Initialisation @@ -1666,7 +1293,7 @@ public: int GetHandlerFlags() const { return m_handlerFlags; } /// Convenience function to add a paragraph of text - virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttrEx* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); } + virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttr* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); } /// Begin collapsing undo/redo commands. Note that this may not work properly /// if combining commands that delete or insert content, changing ranges for @@ -1707,7 +1334,7 @@ public: virtual bool CanPasteFromClipboard() const; /// Begin using a style - virtual bool BeginStyle(const wxTextAttrEx& style); + virtual bool BeginStyle(const wxTextAttr& style); /// End the style virtual bool EndStyle(); @@ -1874,7 +1501,7 @@ public: /// Get the style that is appropriate for a new paragraph at this position. /// If the previous paragraph has a paragraph style name, look up the next-paragraph /// style. - wxRichTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const; + wxTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const; /// Dumps contents of buffer for debugging purposes virtual void Dump(); @@ -1938,6 +1565,9 @@ protected: /// Command processor wxCommandProcessor* m_commandProcessor; + /// Table storing fonts + wxRichTextFontTable m_fontTable; + /// Has been modified? bool m_modified; @@ -2265,13 +1895,13 @@ public: virtual ~wxRichTextRenderer() {} /// Draw a standard bullet, as specified by the value of GetBulletName - virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect) = 0; + virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect) = 0; /// Draw a bullet that can be described by text, such as numbered or symbol bullets - virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect, const wxString& text) = 0; + virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text) = 0; /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName - virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect) = 0; + virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect) = 0; /// Enumerate the standard bullet names currently supported virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0; @@ -2287,13 +1917,13 @@ public: wxRichTextStdRenderer() {} /// Draw a standard bullet, as specified by the value of GetBulletName - virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect); + virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect); /// Draw a bullet that can be described by text, such as numbered or symbol bullets - virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect, const wxString& text); + virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text); /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName - virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect); + virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect); /// Enumerate the standard bullet names currently supported virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames); @@ -2310,22 +1940,18 @@ inline bool wxRichTextHasStyle(int flags, int style) } /// Compare two attribute objects -WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2); -WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxRichTextAttr& attr2); +WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2); +WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2); /// Compare two attribute objects, but take into account the flags /// specifying attributes of interest. -WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2, int flags); -WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxRichTextAttr& attr2, int flags); +WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttr& attr1, const wxTextAttr& attr2, int flags); /// Apply one style to another -WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxTextAttrEx& style); -WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxTextAttrEx& style); -WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL); -WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL); +WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttr& destStyle, const wxTextAttr& style, wxTextAttr* compareWith = NULL); // Remove attributes -WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style); +WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style); /// Combine two bitlists WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB); @@ -2334,14 +1960,11 @@ WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int WXDLLIMPEXP_RICHTEXT bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags); /// Split into paragraph and character styles -WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxTextAttrEx& style, wxTextAttrEx& parStyle, wxTextAttrEx& charStyle); +WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle); /// Compare tabs WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2); -/// Set the font without changing the font attributes -WXDLLIMPEXP_RICHTEXT void wxSetFontPreservingStyles(wxTextAttr& attr, const wxFont& font); - /// Convert a decimal to Roman numerals WXDLLIMPEXP_RICHTEXT wxString wxRichTextDecimalToRoman(long n); diff --git a/include/wx/richtext/richtextbulletspage.h b/include/wx/richtext/richtextbulletspage.h index 9972b66..624ed02 100644 --- a/include/wx/richtext/richtextbulletspage.h +++ b/include/wx/richtext/richtextbulletspage.h @@ -73,7 +73,7 @@ public: virtual bool TransferDataToWindow(); /// Gets the attributes associated with the main formatting dialog - wxTextAttrEx* GetAttributes(); + wxTextAttr* GetAttributes(); /// Update for symbol-related controls void OnSymbolUpdate( wxUpdateUIEvent& event ); diff --git a/include/wx/richtext/richtextctrl.h b/include/wx/richtext/richtextctrl.h index f3b1d88..8d0b6b9 100644 --- a/include/wx/richtext/richtextctrl.h +++ b/include/wx/richtext/richtextctrl.h @@ -179,33 +179,23 @@ public: // methods allow to apply the given text style to the given selection or to // set/get the style which will be used for all appended text virtual bool SetStyle(long start, long end, const wxTextAttr& style); - virtual bool SetStyle(long start, long end, const wxTextAttrEx& style); - virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style); + virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style); virtual bool GetStyle(long position, wxTextAttr& style); - virtual bool GetStyle(long position, wxTextAttrEx& style); - virtual bool GetStyle(long position, wxRichTextAttr& style); // get the common set of styles for the range - virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style); - virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttrEx& style); - + virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style); // extended style setting operation with flags including: // wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY, wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY // see richtextbuffer.h for more details. - virtual bool SetStyleEx(long start, long end, const wxTextAttrEx& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); - virtual bool SetStyleEx(const wxRichTextRange& range, const wxTextAttrEx& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); - virtual bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); + virtual bool SetStyleEx(const wxRichTextRange& range, const wxTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); /// Get the content (uncombined) attributes for this position. virtual bool GetUncombinedStyle(long position, wxTextAttr& style); - virtual bool GetUncombinedStyle(long position, wxTextAttrEx& style); - virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style); - virtual bool SetDefaultStyle(const wxTextAttrEx& style); virtual bool SetDefaultStyle(const wxTextAttr& style); - // TODO: change to GetDefaultStyle if we merge wxTextAttr and wxTextAttrEx - virtual const wxTextAttrEx& GetDefaultStyleEx() const; + virtual const wxTextAttr& GetDefaultStyleEx() const { return GetDefaultStyle(); } + virtual const wxTextAttr& GetDefaultStyle() const; /// Set list style @@ -307,14 +297,12 @@ public: virtual bool LineBreak(); /// Set basic (overall) style - virtual void SetBasicStyle(const wxTextAttrEx& style) { GetBuffer().SetBasicStyle(style); } - virtual void SetBasicStyle(const wxRichTextAttr& style) { GetBuffer().SetBasicStyle(style); } + virtual void SetBasicStyle(const wxTextAttr& style) { GetBuffer().SetBasicStyle(style); } /// Get basic (overall) style - virtual const wxTextAttrEx& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); } + virtual const wxTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); } - /// Begin using a style - virtual bool BeginStyle(const wxTextAttrEx& style) { return GetBuffer().BeginStyle(style); } + virtual bool BeginStyle(const wxTextAttr& style) { return GetBuffer().BeginStyle(style); } /// End the style virtual bool EndStyle() { return GetBuffer().EndStyle(); } @@ -535,11 +523,7 @@ public: /// of the attributes are different within the range, the test fails. You /// can use this to implement, for example, bold button updating. style must have /// flags indicating which attributes are of interest. - virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const - { - return GetBuffer().HasCharacterAttributes(range.ToInternal(), style); - } - virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const + virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttr& style) const { return GetBuffer().HasCharacterAttributes(range.ToInternal(), style); } @@ -548,11 +532,7 @@ public: /// of the attributes are different within the range, the test fails. You /// can use this to implement, for example, centering button updating. style must have /// flags indicating which attributes are of interest. - virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const - { - return GetBuffer().HasParagraphAttributes(range.ToInternal(), style); - } - virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const + virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttr& style) const { return GetBuffer().HasParagraphAttributes(range.ToInternal(), style); } @@ -767,7 +747,7 @@ public: /// Convenience function that tells the control to start reflecting the default /// style, since the user is changing it. - void SetAndShowDefaultStyle(const wxRichTextAttr& attr) + void SetAndShowDefaultStyle(const wxTextAttr& attr) { SetDefaultStyle(attr); SetCaretPositionForDefaultStyle(GetCaretPosition()); diff --git a/include/wx/richtext/richtextfontpage.h b/include/wx/richtext/richtextfontpage.h index 839e9ce..74a4652 100644 --- a/include/wx/richtext/richtextfontpage.h +++ b/include/wx/richtext/richtextfontpage.h @@ -75,7 +75,7 @@ public: void OnColourClicked( wxCommandEvent& event ); /// Gets the attributes associated with the main formatting dialog - wxTextAttrEx* GetAttributes(); + wxTextAttr* GetAttributes(); ////@begin wxRichTextFontPage event handler declarations diff --git a/include/wx/richtext/richtextformatdlg.h b/include/wx/richtext/richtextformatdlg.h index 3e27263..b3a81ac 100644 --- a/include/wx/richtext/richtextformatdlg.h +++ b/include/wx/richtext/richtextformatdlg.h @@ -138,7 +138,7 @@ public: virtual bool GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range); /// Set the attributes and optionally update the display - virtual bool SetStyle(const wxTextAttrEx& style, bool update = true); + virtual bool SetStyle(const wxTextAttr& style, bool update = true); /// Set the style definition and optionally update the display virtual bool SetStyleDefinition(const wxRichTextStyleDefinition& styleDef, wxRichTextStyleSheet* sheet, bool update = true); @@ -156,9 +156,9 @@ public: virtual bool ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE); /// Gets and sets the attributes - const wxTextAttrEx& GetAttributes() const { return m_attributes; } - wxTextAttrEx& GetAttributes() { return m_attributes; } - void SetAttributes(const wxTextAttrEx& attr) { m_attributes = attr; } + const wxTextAttr& GetAttributes() const { return m_attributes; } + wxTextAttr& GetAttributes() { return m_attributes; } + void SetAttributes(const wxTextAttr& attr) { m_attributes = attr; } /// Transfers the data and from to the window virtual bool TransferDataToWindow(); @@ -183,7 +183,7 @@ public: static wxRichTextFormattingDialog* GetDialog(wxWindow* win); /// Helper for pages to get the attributes - static wxTextAttrEx* GetDialogAttributes(wxWindow* win); + static wxTextAttr* GetDialogAttributes(wxWindow* win); /// Helper for pages to get the style static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win); @@ -200,7 +200,7 @@ public: protected: wxImageList* m_imageList; - wxTextAttrEx m_attributes; + wxTextAttr m_attributes; wxRichTextStyleDefinition* m_styleDefinition; wxRichTextStyleSheet* m_styleSheet; wxArrayInt m_pageIds; // mapping of book control indexes to page ids diff --git a/include/wx/richtext/richtexthtml.h b/include/wx/richtext/richtexthtml.h index f71ed68..dee3f70 100644 --- a/include/wx/richtext/richtexthtml.h +++ b/include/wx/richtext/richtexthtml.h @@ -77,15 +77,15 @@ protected: virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); /// Output character formatting - void BeginCharacterFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, const wxTextAttrEx& paraStyle, wxTextOutputStream& stream ); - void EndCharacterFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, const wxTextAttrEx& paraStyle, wxTextOutputStream& stream ); + void BeginCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& paraStyle, wxTextOutputStream& stream ); + void EndCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& paraStyle, wxTextOutputStream& stream ); /// Output paragraph formatting - void BeginParagraphFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, wxTextOutputStream& stream); - void EndParagraphFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, wxTextOutputStream& stream); + void BeginParagraphFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, wxTextOutputStream& stream); + void EndParagraphFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, wxTextOutputStream& stream); /// Output font tag - void OutputFont(const wxTextAttrEx& style, wxTextOutputStream& stream); + void OutputFont(const wxTextAttr& style, wxTextOutputStream& stream); /// Closes lists to level (-1 means close all) void CloseLists(int level, wxTextOutputStream& str); @@ -103,13 +103,13 @@ protected: const wxChar* GetMimeType(int imageType); /// Gets the html equivalent of the specified value - wxString GetAlignment(const wxTextAttrEx& thisStyle); + wxString GetAlignment(const wxTextAttr& thisStyle); /// Generates   array for indentations wxString SymbolicIndent(long indent); /// Finds the html equivalent of the specified bullet - int TypeOfList(const wxTextAttrEx& thisStyle, wxString& tag); + int TypeOfList(const wxTextAttr& thisStyle, wxString& tag); #endif // Data members diff --git a/include/wx/richtext/richtextindentspage.h b/include/wx/richtext/richtextindentspage.h index a801703..a92caed 100644 --- a/include/wx/richtext/richtextindentspage.h +++ b/include/wx/richtext/richtextindentspage.h @@ -71,7 +71,7 @@ public: void UpdatePreview(); /// Gets the attributes associated with the main formatting dialog - wxTextAttrEx* GetAttributes(); + wxTextAttr* GetAttributes(); ////@begin wxRichTextIndentsSpacingPage event handler declarations diff --git a/include/wx/richtext/richtextliststylepage.h b/include/wx/richtext/richtextliststylepage.h index 3ac2d70..bbb8602 100644 --- a/include/wx/richtext/richtextliststylepage.h +++ b/include/wx/richtext/richtextliststylepage.h @@ -65,7 +65,7 @@ public: virtual bool TransferDataToWindow(); /// Get attributes for selected level - wxRichTextAttr* GetAttributesForSelection(); + wxTextAttr* GetAttributesForSelection(); /// Update for symbol-related controls void OnSymbolUpdate( wxUpdateUIEvent& event ); diff --git a/include/wx/richtext/richtextstylepage.h b/include/wx/richtext/richtextstylepage.h index 50fa525..8cbd5f3 100644 --- a/include/wx/richtext/richtextstylepage.h +++ b/include/wx/richtext/richtextstylepage.h @@ -52,7 +52,7 @@ public: virtual bool TransferDataToWindow(); /// Gets the attributes associated with the main formatting dialog - wxTextAttrEx* GetAttributes(); + wxTextAttr* GetAttributes(); ////@begin wxRichTextStylePage event handler declarations diff --git a/include/wx/richtext/richtextstyles.h b/include/wx/richtext/richtextstyles.h index d87b5bc..fb5557b 100644 --- a/include/wx/richtext/richtextstyles.h +++ b/include/wx/richtext/richtextstyles.h @@ -94,18 +94,18 @@ public: const wxString& GetBaseStyle() const { return m_baseStyle; } /// 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; } + 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 wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const; + virtual wxTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const; protected: wxString m_name; wxString m_baseStyle; wxString m_description; - wxRichTextAttr m_style; + wxTextAttr m_style; }; /*! @@ -206,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 wxRichTextAttr& attr); - wxRichTextAttr* GetLevelAttributes(int i); - const wxRichTextAttr* 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); @@ -218,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) - wxRichTextAttr CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet = NULL); + 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) - wxRichTextAttr GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet = NULL); + wxTextAttr GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet = NULL); /// Combine the base and list style, using the given level from which /// an appropriate level is found) - wxRichTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL); + wxTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL); /// Gets the number of available levels int GetLevelCount() const { return 10; } @@ -237,7 +237,7 @@ public: protected: /// The styles for each level (up to 10) - wxRichTextAttr m_levelStyles[10]; + wxTextAttr m_levelStyles[10]; }; /*! @@ -253,7 +253,7 @@ public: wxRichTextStyleSheet(const wxRichTextStyleSheet& sheet) : wxObject() { - Init(); + Init(); Copy(sheet); } wxRichTextStyleSheet() { Init(); } diff --git a/include/wx/richtext/richtexttabspage.h b/include/wx/richtext/richtexttabspage.h index 8624108..e903a69 100644 --- a/include/wx/richtext/richtexttabspage.h +++ b/include/wx/richtext/richtexttabspage.h @@ -69,7 +69,7 @@ public: virtual void SortTabs(); /// Gets the attributes associated with the main formatting dialog - wxTextAttrEx* GetAttributes(); + wxTextAttr* GetAttributes(); ////@begin wxRichTextTabsPage event handler declarations diff --git a/include/wx/richtext/richtextxml.h b/include/wx/richtext/richtextxml.h index 5399ab5..493511f 100644 --- a/include/wx/richtext/richtextxml.h +++ b/include/wx/richtext/richtextxml.h @@ -45,10 +45,10 @@ public: bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node); /// Create style parameters - wxString CreateStyle(const wxTextAttrEx& attr, bool isPara = false); + wxString CreateStyle(const wxTextAttr& attr, bool isPara = false); /// Get style parameters - bool GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool isPara = false); + bool GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara = false); #endif /// Can we save using this handler? diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index 7c8be51..75ad314 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -160,20 +160,95 @@ enum wxTextAttrAlignment // Flags to indicate which attributes are being applied -#define wxTEXT_ATTR_TEXT_COLOUR 0x0001 -#define wxTEXT_ATTR_BACKGROUND_COLOUR 0x0002 -#define wxTEXT_ATTR_FONT_FACE 0x0004 -#define wxTEXT_ATTR_FONT_SIZE 0x0008 -#define wxTEXT_ATTR_FONT_WEIGHT 0x0010 -#define wxTEXT_ATTR_FONT_ITALIC 0x0020 -#define wxTEXT_ATTR_FONT_UNDERLINE 0x0040 +#define wxTEXT_ATTR_TEXT_COLOUR 0x00000001 +#define wxTEXT_ATTR_BACKGROUND_COLOUR 0x00000002 +#define wxTEXT_ATTR_FONT_FACE 0x00000004 +#define wxTEXT_ATTR_FONT_SIZE 0x00000008 +#define wxTEXT_ATTR_FONT_WEIGHT 0x00000010 +#define wxTEXT_ATTR_FONT_ITALIC 0x00000020 +#define wxTEXT_ATTR_FONT_UNDERLINE 0x00000040 +#define wxTEXT_ATTR_FONT_ENCODING 0x02000000 #define wxTEXT_ATTR_FONT \ ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \ - wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE ) -#define wxTEXT_ATTR_ALIGNMENT 0x0080 -#define wxTEXT_ATTR_LEFT_INDENT 0x0100 -#define wxTEXT_ATTR_RIGHT_INDENT 0x0200 -#define wxTEXT_ATTR_TABS 0x0400 + wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING ) +#define wxTEXT_ATTR_ALIGNMENT 0x00000080 +#define wxTEXT_ATTR_LEFT_INDENT 0x00000100 +#define wxTEXT_ATTR_RIGHT_INDENT 0x00000200 +#define wxTEXT_ATTR_TABS 0x00000400 + +#define wxTEXT_ATTR_PARA_SPACING_AFTER 0x00000800 +#define wxTEXT_ATTR_PARA_SPACING_BEFORE 0x00001000 +#define wxTEXT_ATTR_LINE_SPACING 0x00002000 +#define wxTEXT_ATTR_CHARACTER_STYLE_NAME 0x00004000 +#define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME 0x00008000 +#define wxTEXT_ATTR_LIST_STYLE_NAME 0x00010000 +#define wxTEXT_ATTR_BULLET_STYLE 0x00020000 +#define wxTEXT_ATTR_BULLET_NUMBER 0x00040000 +#define wxTEXT_ATTR_BULLET_TEXT 0x00080000 +#define wxTEXT_ATTR_BULLET_NAME 0x00100000 +#define wxTEXT_ATTR_URL 0x00200000 +#define wxTEXT_ATTR_PAGE_BREAK 0x00400000 +#define wxTEXT_ATTR_EFFECTS 0x00800000 +#define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000 + +/*! + * Character and paragraph combined styles + */ + +#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT|wxTEXT_ATTR_FONT_ENCODING|wxTEXT_ATTR_EFFECTS|wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL) + +#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_TEXT|wxTEXT_ATTR_BULLET_NAME|\ + wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL) + +#define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) + +/*! + * Styles for wxTextAttr::SetBulletStyle + */ + +#define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000 +#define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001 +#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002 +#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004 +#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008 +#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010 +#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020 +#define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040 +#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080 +#define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100 +#define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200 +#define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400 +#define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800 + +#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000 +#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000 +#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000 + +/*! + * Styles for wxTextAttr::SetTextEffects + */ + +#define wxTEXT_ATTR_EFFECT_NONE 0x00000000 +#define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001 +#define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002 +#define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004 +#define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008 +#define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010 +#define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020 +#define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040 +#define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080 +#define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100 +#define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200 + +/*! + * Line spacing values + */ + +#define wxTEXT_ATTR_LINE_SPACING_NORMAL 10 +#define wxTEXT_ATTR_LINE_SPACING_HALF 15 +#define wxTEXT_ATTR_LINE_SPACING_TWICE 20 // ---------------------------------------------------------------------------- // wxTextAttr: a structure containing the visual attributes of a text @@ -184,56 +259,72 @@ class WXDLLEXPORT wxTextAttr public: // ctors wxTextAttr() { Init(); } + wxTextAttr(const wxTextAttr& attr) { Init(); Copy(attr); } wxTextAttr(const wxColour& colText, const wxColour& colBack = wxNullColour, const wxFont& font = wxNullFont, wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT); - // operations + // Initialise this object. void Init(); - // merges the attributes of the base and the overlay objects and returns - // the result; the parameter attributes take precedence - // - // WARNING: the order of arguments is the opposite of Combine() - static wxTextAttr Merge(const wxTextAttr& base, const wxTextAttr& overlay) - { - return Combine(overlay, base, NULL); - } + // Copy + void Copy(const wxTextAttr& attr); - // merges the attributes of this object and overlay - void Merge(const wxTextAttr& overlay) - { - *this = Merge(*this, overlay); - } + // Assignment + void operator= (const wxTextAttr& attr); + // Equality test + bool operator== (const wxTextAttr& attr) const; - // operators - void operator= (const wxTextAttr& attr); + // Partial equality test taking flags into account + bool EqPartial(const wxTextAttr& attr, int flags) const; + + // Create font from font attributes. + wxFont CreateFont() const; + + // Get attributes from font. + bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_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 SetFont(const wxFont& font, long flags = wxTEXT_ATTR_FONT) { m_font = font; m_flags |= flags; } 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 SetFontEncoding(wxFontEncoding encoding) { m_fontEncoding = encoding; m_flags |= wxTEXT_ATTR_FONT_ENCODING; } + + // Set font + void SetFont(const wxFont& font, int flags = wxTEXT_ATTR_FONT) { GetFontAttributes(font, flags); } + void SetFlags(long flags) { m_flags = flags; } - // 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 HasFont() const { return m_font.Ok() && HasFlag(wxTEXT_ATTR_FONT) ; } - 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 HasFlag(long flag) const { return (m_flags & flag) != 0; } + 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 SetListStyleName(const wxString& name) { m_listStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_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 SetBulletText(const wxString& text) { m_bulletText = text; m_flags |= wxTEXT_ATTR_BULLET_TEXT; } + void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; } + void SetBulletName(const wxString& name) { m_bulletName = name; m_flags |= wxTEXT_ATTR_BULLET_NAME; } + void SetURL(const wxString& url) { m_urlTarget = url; m_flags |= wxTEXT_ATTR_URL; } + void SetPageBreak(bool pageBreak = true) { SetFlags(pageBreak ? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK)); } + void SetTextEffects(int effects) { m_textEffects = effects; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS); } + void SetTextEffectFlags(int effects) { m_textEffectFlags = effects; } + void SetOutlineLevel(int level) { m_outlineLevel = level; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL); } const wxColour& GetTextColour() const { return m_colText; } const wxColour& GetBackgroundColour() const { return m_colBack; } - const wxFont& GetFont() const { return m_font; } wxTextAttrAlignment GetAlignment() const { return m_textAlignment; } const wxArrayInt& GetTabs() const { return m_tabs; } long GetLeftIndent() const { return m_leftIndent; } @@ -241,11 +332,92 @@ public: 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; } + wxFontEncoding GetFontEncoding() const { return m_fontEncoding; } + + wxFont GetFont() const { return CreateFont(); } + + const wxString& GetCharacterStyleName() const { return m_characterStyleName; } + const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; } + const wxString& GetListStyleName() const { return m_listStyleName; } + 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; } + const wxString& GetBulletText() const { return m_bulletText; } + const wxString& GetBulletFont() const { return m_bulletFont; } + const wxString& GetBulletName() const { return m_bulletName; } + const wxString& GetURL() const { return m_urlTarget; } + int GetTextEffects() const { return m_textEffects; } + int GetTextEffectFlags() const { return m_textEffectFlags; } + int GetOutlineLevel() const { return m_outlineLevel; } + + // 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) || HasFlag(wxTEXT_ATTR_ALIGNMENT) ; } + bool HasTabs() const { return HasFlag(wxTEXT_ATTR_TABS) ; } + bool HasLeftIndent() const { return HasFlag(wxTEXT_ATTR_LEFT_INDENT); } + bool HasRightIndent() const { return HasFlag(wxTEXT_ATTR_RIGHT_INDENT); } + bool HasFontWeight() const { return HasFlag(wxTEXT_ATTR_FONT_WEIGHT); } + bool HasFontSize() const { return HasFlag(wxTEXT_ATTR_FONT_SIZE); } + bool HasFontItalic() const { return HasFlag(wxTEXT_ATTR_FONT_ITALIC); } + bool HasFontUnderlined() const { return HasFlag(wxTEXT_ATTR_FONT_UNDERLINE); } + bool HasFontFaceName() const { return HasFlag(wxTEXT_ATTR_FONT_FACE); } + bool HasFontEncoding() const { return HasFlag(wxTEXT_ATTR_FONT_ENCODING); } + bool HasFont() const { return HasFlag(wxTEXT_ATTR_FONT); } + + 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) && !m_characterStyleName.IsEmpty(); } + bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && !m_paragraphStyleName.IsEmpty(); } + bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME) || !m_listStyleName.IsEmpty(); } + bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE); } + bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER); } + bool HasBulletText() const { return HasFlag(wxTEXT_ATTR_BULLET_TEXT); } + bool HasBulletName() const { return HasFlag(wxTEXT_ATTR_BULLET_NAME); } + bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL); } + bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK); } + bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS); } + bool HasTextEffect(int effect) const { return HasFlag(wxTEXT_ATTR_EFFECTS) && ((GetTextEffectFlags() & effect) != 0); } + bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); } + + bool HasFlag(long flag) const { return (m_flags & flag) != 0; } + + // Is this a character style? + bool IsCharacterStyle() const { return HasFlag(wxTEXT_ATTR_CHARACTER); } + bool IsParagraphStyle() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH); } + // returns false if we have any attributes set, true otherwise bool IsDefault() const { - return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() && - !HasTabs() && !HasLeftIndent() && !HasRightIndent() ; + return GetFlags() == 0; + } + + // Merges the given attributes. Does not affect 'this'. If compareWith + // is non-NULL, then it will be used to mask out those attributes that are the same in style + // and compareWith, for situations where we don't want to explicitly set inherited attributes. + bool Apply(const wxTextAttr& style, const wxTextAttr* compareWith = NULL); + + // merges the attributes of the base and the overlay objects and returns + // the result; the parameter attributes take precedence + // + // WARNING: the order of arguments is the opposite of Combine() + static wxTextAttr Merge(const wxTextAttr& base, const wxTextAttr& overlay) + { + return Combine(overlay, base, NULL); + } + + // merges the attributes of this object and overlay + void Merge(const wxTextAttr& overlay) + { + *this = Merge(*this, overlay); } // return the attribute having the valid font and colours: it uses the @@ -255,18 +427,64 @@ public: const wxTextAttr& attrDef, const wxTextCtrlBase *text); + // Compare tabs + static bool TabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2); + + // Remove attributes + static bool RemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style); + + // Combine two bitlists, specifying the bits of interest with separate flags. + static bool CombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB); + + // Compare two bitlists + static bool BitlistsEqPartial(int valueA, int valueB, int flags); + + // Split into paragraph and character styles + static bool SplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle); + private: long m_flags; - wxColour m_colText, - m_colBack; - wxFont m_font; - wxTextAttrAlignment m_textAlignment; + + // 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; + int m_textEffects; + int m_textEffectFlags; + int m_outlineLevel; + wxString m_bulletText; + wxString m_bulletFont; + wxString m_bulletName; + wxString m_urlTarget; + wxFontEncoding m_fontEncoding; + + // 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; + + // List style + wxString m_listStyleName; }; // ---------------------------------------------------------------------------- diff --git a/samples/richtext/richtext.cpp b/samples/richtext/richtext.cpp index ec71a3d..23e50e2 100644 --- a/samples/richtext/richtext.cpp +++ b/samples/richtext/richtext.cpp @@ -840,7 +840,7 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, tabs.Add(600); tabs.Add(800); tabs.Add(1000); - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_TABS); attr.SetTabs(tabs); r.SetDefaultStyle(attr); @@ -1184,7 +1184,7 @@ void MyFrame::OnUpdateFormat(wxUpdateUIEvent& event) void MyFrame::OnIndentMore(wxCommandEvent& WXUNUSED(event)) { - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_LEFT_INDENT); if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr)) @@ -1202,7 +1202,7 @@ void MyFrame::OnIndentMore(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnIndentLess(wxCommandEvent& WXUNUSED(event)) { - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_LEFT_INDENT); if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr)) @@ -1222,7 +1222,7 @@ void MyFrame::OnIndentLess(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnLineSpacingHalf(wxCommandEvent& WXUNUSED(event)) { - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_LINE_SPACING); if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr)) @@ -1240,7 +1240,7 @@ void MyFrame::OnLineSpacingHalf(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnLineSpacingDouble(wxCommandEvent& WXUNUSED(event)) { - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_LINE_SPACING); if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr)) @@ -1258,7 +1258,7 @@ void MyFrame::OnLineSpacingDouble(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnLineSpacingSingle(wxCommandEvent& WXUNUSED(event)) { - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_LINE_SPACING); if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr)) @@ -1276,7 +1276,7 @@ void MyFrame::OnLineSpacingSingle(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnParagraphSpacingMore(wxCommandEvent& WXUNUSED(event)) { - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_PARA_SPACING_AFTER); if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr)) @@ -1294,7 +1294,7 @@ void MyFrame::OnParagraphSpacingMore(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnParagraphSpacingLess(wxCommandEvent& WXUNUSED(event)) { - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_PARA_SPACING_AFTER); if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr)) @@ -1422,7 +1422,7 @@ void MyFrame::OnManageStyles(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnInsertSymbol(wxCommandEvent& WXUNUSED(event)) { - wxTextAttrEx attr; + wxRichTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT); m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr); diff --git a/src/common/textcmn.cpp b/src/common/textcmn.cpp index 8fa4ad2..82d6585 100644 --- a/src/common/textcmn.cpp +++ b/src/common/textcmn.cpp @@ -56,27 +56,26 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_TEXT_MAXLEN) IMPLEMENT_ABSTRACT_CLASS(wxTextCtrlBase, wxControl) -// ---------------------------------------------------------------------------- -// style functions - not implemented here -// ---------------------------------------------------------------------------- +// ============================================================================ +// wxTextAttr implementation +// ============================================================================ wxTextAttr::wxTextAttr(const wxColour& colText, const wxColour& colBack, const wxFont& font, - wxTextAttrAlignment alignment) - : m_colText(colText), m_colBack(colBack), m_font(font), m_textAlignment(alignment) + wxTextAttrAlignment alignment): m_textAlignment(alignment), m_colText(colText), m_colBack(colBack) { - m_flags = 0; - m_leftIndent = 0; - m_leftSubIndent = 0; - m_rightIndent = 0; + Init(); + if (m_colText.Ok()) m_flags |= wxTEXT_ATTR_TEXT_COLOUR; if (m_colBack.Ok()) m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; - if (m_font.Ok()) m_flags |= wxTEXT_ATTR_FONT; if (alignment != wxTEXT_ALIGNMENT_DEFAULT) m_flags |= wxTEXT_ATTR_ALIGNMENT; + + GetFontAttributes(font); } +// Initialisation void wxTextAttr::Init() { m_textAlignment = wxTEXT_ALIGNMENT_DEFAULT; @@ -84,6 +83,456 @@ void wxTextAttr::Init() m_leftIndent = 0; m_leftSubIndent = 0; m_rightIndent = 0; + + m_fontSize = 12; + m_fontStyle = wxNORMAL; + m_fontWeight = wxNORMAL; + m_fontUnderlined = false; + m_fontEncoding = wxFONTENCODING_DEFAULT; + + m_paragraphSpacingAfter = 0; + m_paragraphSpacingBefore = 0; + m_lineSpacing = 0; + m_bulletStyle = wxTEXT_ATTR_BULLET_STYLE_NONE; + m_textEffects = wxTEXT_ATTR_EFFECT_NONE; + m_textEffectFlags = wxTEXT_ATTR_EFFECT_NONE; + m_outlineLevel = 0; + m_bulletNumber = 0; +} + +// Copy +void wxTextAttr::Copy(const wxTextAttr& attr) +{ + m_colText = attr.m_colText; + m_colBack = attr.m_colBack; + m_textAlignment = attr.m_textAlignment; + m_leftIndent = attr.m_leftIndent; + m_leftSubIndent = attr.m_leftSubIndent; + m_rightIndent = attr.m_rightIndent; + m_tabs = attr.m_tabs; + m_flags = attr.m_flags; + + m_fontSize = attr.m_fontSize; + m_fontStyle = attr.m_fontStyle; + m_fontWeight = attr.m_fontWeight; + m_fontUnderlined = attr.m_fontUnderlined; + m_fontFaceName = attr.m_fontFaceName; + m_fontEncoding = attr.m_fontEncoding; + m_textEffects = attr.m_textEffects; + m_textEffectFlags = attr.m_textEffectFlags; + + m_paragraphSpacingAfter = attr.m_paragraphSpacingAfter; + m_paragraphSpacingBefore = attr.m_paragraphSpacingBefore; + m_lineSpacing = attr.m_lineSpacing; + m_characterStyleName = attr.m_characterStyleName; + m_paragraphStyleName = attr.m_paragraphStyleName; + m_listStyleName = attr.m_listStyleName; + m_bulletStyle = attr.m_bulletStyle; + m_bulletNumber = attr.m_bulletNumber; + m_bulletText = attr.m_bulletText; + m_bulletFont = attr.m_bulletFont; + m_bulletName = attr.m_bulletName; + m_outlineLevel = attr.m_outlineLevel; + + m_urlTarget = attr.m_urlTarget; +} + +// operators +void wxTextAttr::operator= (const wxTextAttr& attr) +{ + Copy(attr); +} + +// Equality test +bool wxTextAttr::operator== (const wxTextAttr& attr) const +{ + return GetFlags() == attr.GetFlags() && + + GetTextColour() == attr.GetTextColour() && + GetBackgroundColour() == attr.GetBackgroundColour() && + + GetAlignment() == attr.GetAlignment() && + GetLeftIndent() == attr.GetLeftIndent() && + GetLeftSubIndent() == attr.GetLeftSubIndent() && + GetRightIndent() == attr.GetRightIndent() && + TabsEq(GetTabs(), attr.GetTabs()) && + + GetParagraphSpacingAfter() == attr.GetParagraphSpacingAfter() && + GetParagraphSpacingBefore() == attr.GetParagraphSpacingBefore() && + GetLineSpacing() == attr.GetLineSpacing() && + GetCharacterStyleName() == attr.GetCharacterStyleName() && + GetParagraphStyleName() == attr.GetParagraphStyleName() && + GetListStyleName() == attr.GetListStyleName() && + + GetBulletStyle() == attr.GetBulletStyle() && + GetBulletText() == attr.GetBulletText() && + GetBulletNumber() == attr.GetBulletNumber() && + GetBulletFont() == attr.GetBulletFont() && + GetBulletName() == attr.GetBulletName() && + + GetTextEffects() == attr.GetTextEffects() && + GetTextEffectFlags() == attr.GetTextEffectFlags() && + + GetOutlineLevel() == attr.GetOutlineLevel() && + + GetFontSize() == attr.GetFontSize() && + GetFontStyle() == attr.GetFontStyle() && + GetFontWeight() == attr.GetFontWeight() && + GetFontUnderlined() == attr.GetFontUnderlined() && + GetFontFaceName() == attr.GetFontFaceName() && + GetFontEncoding() == attr.GetFontEncoding() && + + GetURL() == attr.GetURL(); +} + +// Partial equality test taking flags into account +bool wxTextAttr::EqPartial(const wxTextAttr& attr, int flags) const +{ + if ((flags & wxTEXT_ATTR_TEXT_COLOUR) && GetTextColour() != attr.GetTextColour()) + return false; + + if ((flags & wxTEXT_ATTR_BACKGROUND_COLOUR) && GetBackgroundColour() != attr.GetBackgroundColour()) + return false; + + if ((flags & wxTEXT_ATTR_FONT_FACE) && + GetFontFaceName() != attr.GetFontFaceName()) + return false; + + if ((flags & wxTEXT_ATTR_FONT_SIZE) && + GetFontSize() != attr.GetFontSize()) + return false; + + if ((flags & wxTEXT_ATTR_FONT_WEIGHT) && + GetFontWeight() != attr.GetFontWeight()) + return false; + + if ((flags & wxTEXT_ATTR_FONT_ITALIC) && + GetFontStyle() != attr.GetFontStyle()) + return false; + + if ((flags & wxTEXT_ATTR_FONT_UNDERLINE) && + GetFontUnderlined() != attr.GetFontUnderlined()) + return false; + + if ((flags & wxTEXT_ATTR_FONT_ENCODING) && + GetFontEncoding() != attr.GetFontEncoding()) + return false; + + if ((flags & wxTEXT_ATTR_URL) && GetURL() != attr.GetURL()) + return false; + + if ((flags & wxTEXT_ATTR_ALIGNMENT) && GetAlignment() != attr.GetAlignment()) + return false; + + if ((flags & wxTEXT_ATTR_LEFT_INDENT) && + ((GetLeftIndent() != attr.GetLeftIndent()) || (GetLeftSubIndent() != attr.GetLeftSubIndent()))) + return false; + + if ((flags & wxTEXT_ATTR_RIGHT_INDENT) && + (GetRightIndent() != attr.GetRightIndent())) + return false; + + if ((flags & wxTEXT_ATTR_PARA_SPACING_AFTER) && + (GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter())) + return false; + + if ((flags & wxTEXT_ATTR_PARA_SPACING_BEFORE) && + (GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore())) + return false; + + if ((flags & wxTEXT_ATTR_LINE_SPACING) && + (GetLineSpacing() != attr.GetLineSpacing())) + return false; + + if ((flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) && + (GetCharacterStyleName() != attr.GetCharacterStyleName())) + return false; + + if ((flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && + (GetParagraphStyleName() != attr.GetParagraphStyleName())) + return false; + + if ((flags & wxTEXT_ATTR_LIST_STYLE_NAME) && + (GetListStyleName() != attr.GetListStyleName())) + return false; + + if ((flags & wxTEXT_ATTR_BULLET_STYLE) && + (GetBulletStyle() != attr.GetBulletStyle())) + return false; + + if ((flags & wxTEXT_ATTR_BULLET_NUMBER) && + (GetBulletNumber() != attr.GetBulletNumber())) + return false; + + if ((flags & wxTEXT_ATTR_BULLET_TEXT) && + (GetBulletText() != attr.GetBulletText()) && + (GetBulletFont() != attr.GetBulletFont())) + return false; + + if ((flags & wxTEXT_ATTR_BULLET_NAME) && + (GetBulletName() != attr.GetBulletName())) + return false; + + if ((flags & wxTEXT_ATTR_TABS) && + !TabsEq(GetTabs(), attr.GetTabs())) + return false; + + if ((flags & wxTEXT_ATTR_PAGE_BREAK) && + (HasPageBreak() != attr.HasPageBreak())) + return false; + + if (flags & wxTEXT_ATTR_EFFECTS) + { + if (HasTextEffects() != attr.HasTextEffects()) + return false; + if (!BitlistsEqPartial(GetTextEffects(), attr.GetTextEffects(), attr.GetTextEffectFlags())) + return false; + } + + if ((flags & wxTEXT_ATTR_OUTLINE_LEVEL) && + (GetOutlineLevel() != attr.GetOutlineLevel())) + return false; + + return true; +} + +// Create font from font attributes. +wxFont wxTextAttr::CreateFont() const +{ + int fontSize = 10; + if (HasFontSize()) + fontSize = GetFontSize(); + + int fontStyle = wxNORMAL; + if (HasFontItalic()) + fontStyle = GetFontStyle(); + + int fontWeight = wxNORMAL; + if (HasFontWeight()) + fontWeight = GetFontWeight(); + + bool underlined = false; + if (HasFontUnderlined()) + underlined = GetFontUnderlined(); + + wxString fontFaceName; + if (HasFontFaceName()) + fontFaceName = GetFontFaceName(); + + wxFontEncoding encoding = wxFONTENCODING_DEFAULT; + if (HasFontEncoding()) + encoding = GetFontEncoding(); + + wxFont font(fontSize, wxDEFAULT, fontStyle, fontWeight, underlined, fontFaceName, encoding); +#ifdef __WXMAC__ + font.SetNoAntiAliasing(true); +#endif + return font; +} + +// Get attributes from font. +bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags) +{ + if (!font.Ok()) + return false; + + if (flags & wxTEXT_ATTR_FONT_SIZE) + m_fontSize = font.GetPointSize(); + + if (flags & wxTEXT_ATTR_FONT_ITALIC) + m_fontStyle = font.GetStyle(); + + if (flags & wxTEXT_ATTR_FONT_WEIGHT) + m_fontWeight = font.GetWeight(); + + if (flags & wxTEXT_ATTR_FONT_UNDERLINE) + m_fontUnderlined = font.GetUnderlined(); + + if (flags & wxTEXT_ATTR_FONT_FACE) + m_fontFaceName = font.GetFaceName(); + + if (flags & wxTEXT_ATTR_FONT_ENCODING) + m_fontEncoding = font.GetEncoding(); + + return true; +} + +bool wxTextAttr::Apply(const wxTextAttr& style, const wxTextAttr* compareWith) +{ + wxTextAttr& destStyle = (*this); + + if (style.HasFontWeight()) + { + if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight())) + destStyle.SetFontWeight(style.GetFontWeight()); + } + + if (style.HasFontSize()) + { + if (!(compareWith && compareWith->HasFontSize() && compareWith->GetFontSize() == style.GetFontSize())) + destStyle.SetFontSize(style.GetFontSize()); + } + + if (style.HasFontItalic()) + { + if (!(compareWith && compareWith->HasFontItalic() && compareWith->GetFontStyle() == style.GetFontStyle())) + destStyle.SetFontStyle(style.GetFontStyle()); + } + + if (style.HasFontUnderlined()) + { + if (!(compareWith && compareWith->HasFontUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined())) + destStyle.SetFontUnderlined(style.GetFontUnderlined()); + } + + if (style.HasFontFaceName()) + { + if (!(compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName())) + destStyle.SetFontFaceName(style.GetFontFaceName()); + } + + if (style.HasFontEncoding()) + { + if (!(compareWith && compareWith->HasFontEncoding() && compareWith->GetFontEncoding() == style.GetFontEncoding())) + destStyle.SetFontEncoding(style.GetFontEncoding()); + } + + if (style.GetTextColour().Ok() && style.HasTextColour()) + { + if (!(compareWith && compareWith->HasTextColour() && compareWith->GetTextColour() == style.GetTextColour())) + destStyle.SetTextColour(style.GetTextColour()); + } + + if (style.GetBackgroundColour().Ok() && style.HasBackgroundColour()) + { + if (!(compareWith && compareWith->HasBackgroundColour() && compareWith->GetBackgroundColour() == style.GetBackgroundColour())) + destStyle.SetBackgroundColour(style.GetBackgroundColour()); + } + + if (style.HasAlignment()) + { + if (!(compareWith && compareWith->HasAlignment() && compareWith->GetAlignment() == style.GetAlignment())) + destStyle.SetAlignment(style.GetAlignment()); + } + + if (style.HasTabs()) + { + if (!(compareWith && compareWith->HasTabs() && TabsEq(compareWith->GetTabs(), style.GetTabs()))) + destStyle.SetTabs(style.GetTabs()); + } + + if (style.HasLeftIndent()) + { + if (!(compareWith && compareWith->HasLeftIndent() && compareWith->GetLeftIndent() == style.GetLeftIndent() + && compareWith->GetLeftSubIndent() == style.GetLeftSubIndent())) + destStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent()); + } + + if (style.HasRightIndent()) + { + if (!(compareWith && compareWith->HasRightIndent() && compareWith->GetRightIndent() == style.GetRightIndent())) + destStyle.SetRightIndent(style.GetRightIndent()); + } + + if (style.HasParagraphSpacingAfter()) + { + if (!(compareWith && compareWith->HasParagraphSpacingAfter() && compareWith->GetParagraphSpacingAfter() == style.GetParagraphSpacingAfter())) + destStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter()); + } + + if (style.HasParagraphSpacingBefore()) + { + if (!(compareWith && compareWith->HasParagraphSpacingBefore() && compareWith->GetParagraphSpacingBefore() == style.GetParagraphSpacingBefore())) + destStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore()); + } + + if (style.HasLineSpacing()) + { + if (!(compareWith && compareWith->HasLineSpacing() && compareWith->GetLineSpacing() == style.GetLineSpacing())) + destStyle.SetLineSpacing(style.GetLineSpacing()); + } + + if (style.HasCharacterStyleName()) + { + if (!(compareWith && compareWith->HasCharacterStyleName() && compareWith->GetCharacterStyleName() == style.GetCharacterStyleName())) + destStyle.SetCharacterStyleName(style.GetCharacterStyleName()); + } + + if (style.HasParagraphStyleName()) + { + if (!(compareWith && compareWith->HasParagraphStyleName() && compareWith->GetParagraphStyleName() == style.GetParagraphStyleName())) + destStyle.SetParagraphStyleName(style.GetParagraphStyleName()); + } + + if (style.HasListStyleName()) + { + if (!(compareWith && compareWith->HasListStyleName() && compareWith->GetListStyleName() == style.GetListStyleName())) + destStyle.SetListStyleName(style.GetListStyleName()); + } + + if (style.HasBulletStyle()) + { + if (!(compareWith && compareWith->HasBulletStyle() && compareWith->GetBulletStyle() == style.GetBulletStyle())) + destStyle.SetBulletStyle(style.GetBulletStyle()); + } + + if (style.HasBulletText()) + { + if (!(compareWith && compareWith->HasBulletText() && compareWith->GetBulletText() == style.GetBulletText())) + { + destStyle.SetBulletText(style.GetBulletText()); + destStyle.SetBulletFont(style.GetBulletFont()); + } + } + + if (style.HasBulletNumber()) + { + if (!(compareWith && compareWith->HasBulletNumber() && compareWith->GetBulletNumber() == style.GetBulletNumber())) + destStyle.SetBulletNumber(style.GetBulletNumber()); + } + + if (style.HasBulletName()) + { + if (!(compareWith && compareWith->HasBulletName() && compareWith->GetBulletName() == style.GetBulletName())) + destStyle.SetBulletName(style.GetBulletName()); + } + + if (style.HasURL()) + { + if (!(compareWith && compareWith->HasURL() && compareWith->GetURL() == style.GetURL())) + destStyle.SetURL(style.GetURL()); + } + + if (style.HasPageBreak()) + { + if (!(compareWith && compareWith->HasPageBreak())) + destStyle.SetPageBreak(); + } + + if (style.HasTextEffects()) + { + if (!(compareWith && compareWith->HasTextEffects() && compareWith->GetTextEffects() == style.GetTextEffects())) + { + int destBits = destStyle.GetTextEffects(); + int destFlags = destStyle.GetTextEffectFlags(); + + int srcBits = style.GetTextEffects(); + int srcFlags = style.GetTextEffectFlags(); + + CombineBitlists(destBits, srcBits, destFlags, srcFlags); + + destStyle.SetTextEffects(destBits); + destStyle.SetTextEffectFlags(destFlags); + } + } + + if (style.HasOutlineLevel()) + { + if (!(compareWith && compareWith->HasOutlineLevel() && compareWith->GetOutlineLevel() == style.GetOutlineLevel())) + destStyle.SetOutlineLevel(style.GetOutlineLevel()); + } + + return true; } /* static */ @@ -143,19 +592,73 @@ wxTextAttr wxTextAttr::Combine(const wxTextAttr& attr, return newAttr; } -void wxTextAttr::operator= (const wxTextAttr& attr) +/// Compare tabs +bool wxTextAttr::TabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2) { - m_font = attr.m_font; - m_colText = attr.m_colText; - m_colBack = attr.m_colBack; - m_textAlignment = attr.m_textAlignment; - m_leftIndent = attr.m_leftIndent; - m_leftSubIndent = attr.m_leftSubIndent; - m_rightIndent = attr.m_rightIndent; - m_tabs = attr.m_tabs; - m_flags = attr.m_flags; + if (tabs1.GetCount() != tabs2.GetCount()) + return false; + + size_t i; + for (i = 0; i < tabs1.GetCount(); i++) + { + if (tabs1[i] != tabs2[i]) + return false; + } + return true; +} + +// Remove attributes +bool wxTextAttr::RemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style) +{ + int flags = style.GetFlags(); + int destFlags = destStyle.GetFlags(); + + destStyle.SetFlags(destFlags & ~flags); + + return true; +} + +/// Combine two bitlists, specifying the bits of interest with separate flags. +bool wxTextAttr::CombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB) +{ + // We want to apply B's bits to A, taking into account each's flags which indicate which bits + // are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags + // indicate it. + + // First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero + // bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant. + int valueA2 = ~(~valueB & flagsB) & valueA; + + // Now combine the 1 bits. + int valueA3 = (valueB & flagsB) | valueA2; + + valueA = valueA3; + flagsA = (flagsA | flagsB); + + return true; +} + +/// Compare two bitlists +bool wxTextAttr::BitlistsEqPartial(int valueA, int valueB, int flags) +{ + int relevantBitsA = valueA & flags; + int relevantBitsB = valueB & flags; + return (relevantBitsA != relevantBitsB); } +/// Split into paragraph and character styles +bool wxTextAttr::SplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle) +{ + wxTextAttr defaultCharStyle1(style); + wxTextAttr defaultParaStyle1(style); + defaultCharStyle1.SetFlags(defaultCharStyle1.GetFlags()&wxTEXT_ATTR_CHARACTER); + defaultParaStyle1.SetFlags(defaultParaStyle1.GetFlags()&wxTEXT_ATTR_PARAGRAPH); + + charStyle.Apply(defaultCharStyle1); + parStyle.Apply(defaultParaStyle1); + + return true; +} // apply styling to text range bool wxTextCtrlBase::SetStyle(long WXUNUSED(start), long WXUNUSED(end), diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 37c1c1a..e7a7724 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -84,7 +84,9 @@ static void wxGtkTextApplyTagsFromAttr(GtkWidget *text, { wxGtkTextRemoveTagsWithPrefix(text_buffer, "WXFONT", start, end); - PangoFontDescription *font_description = attr.GetFont().GetNativeFontInfo()->description; + wxFont font(attr.GetFont()); + + PangoFontDescription *font_description = font.GetNativeFontInfo()->description; wxGtkString font_string(pango_font_description_to_string(font_description)); g_snprintf(buf, sizeof(buf), "WXFONT %s", font_string.c_str()); tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ), @@ -95,7 +97,7 @@ static void wxGtkTextApplyTagsFromAttr(GtkWidget *text, NULL ); gtk_text_buffer_apply_tag (text_buffer, tag, start, end); - if (attr.GetFont().GetUnderlined()) + if (font.GetUnderlined()) { g_snprintf(buf, sizeof(buf), "WXFONTUNDERLINE"); tag = gtk_text_tag_table_lookup( gtk_text_buffer_get_tag_table( text_buffer ), @@ -943,7 +945,7 @@ wxFontEncoding wxTextCtrl::GetTextEncoding() const // first check the default text style (we intentionally don't check the // style for the current position as it doesn't make sense for SetValue()) const wxTextAttr& style = GetDefaultStyle(); - wxFontEncoding enc = style.HasFont() ? style.GetFont().GetEncoding() + wxFontEncoding enc = style.HasFontEncoding() ? style.GetFontEncoding() : wxFONTENCODING_SYSTEM; // fall back to the controls font if no style @@ -1028,9 +1030,9 @@ void wxTextCtrl::WriteText( const wxString &text ) // check if we have a specific style for the current position wxFontEncoding enc = wxFONTENCODING_SYSTEM; wxTextAttr style; - if ( GetStyle(GetInsertionPoint(), style) && style.HasFont() ) + if ( GetStyle(GetInsertionPoint(), style) && style.HasFontEncoding() ) { - enc = style.GetFont().GetEncoding(); + enc = style.GetFontEncoding(); } if ( enc == wxFONTENCODING_SYSTEM ) diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp index b789f65..9dfc2f1 100644 --- a/src/gtk1/textctrl.cpp +++ b/src/gtk1/textctrl.cpp @@ -55,8 +55,21 @@ static void wxGtkTextInsert(GtkWidget *text, const char *txt, size_t len) { - GdkFont *font = attr.HasFont() ? attr.GetFont().GetInternalFont() - : NULL; + wxFont tmpFont; + GdkFont *font; + if (attr.HasFont()) + { + tmpFont = attr.GetFont(); + + // FIXME: if this crashes because tmpFont goes out of scope and the GdkFont is + // deleted, then we need to call gdk_font_ref on font. + // This is because attr.GetFont() now returns a temporary font since wxTextAttr + // no longer stores a wxFont object, for efficiency. + + font = tmpFont.GetInternalFont(); + } + else + font = NULL; GdkColor *colFg = attr.HasTextColour() ? attr.GetTextColour().GetColor() : NULL; diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index fd154aa..dd9601d 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -448,7 +448,7 @@ void wxTextCtrl::CreatePeer( } #endif - // the horizontal single line scrolling bug that made us keep + // the horizontal single line scrolling bug that made us keep #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 if ( !m_peer ) m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ; @@ -1374,7 +1374,7 @@ bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer, wxMacConvertNewlines10To13( &st ) ; wxMacCFStringHolder cf(st , m_font.GetEncoding()) ; CFStringRef cfr = cf ; - + m_valueTag = kControlEditTextCFStringTag ; CreateControl( wxPeer, &bounds, cfr ); @@ -1384,7 +1384,7 @@ bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer, InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(), GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this, &m_focusHandlerRef); - + return true; } @@ -1829,7 +1829,7 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo if ( style.HasFont() ) { - const wxFont &font = style.GetFont() ; + wxFont font(style.GetFont()) ; #if 0 // old version Str255 fontName = "\pMonaco" ; diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index d57e3ec..16a0ef0 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -2410,9 +2410,12 @@ bool wxTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) // the real height in twips and not the negative number which // wxFillLogFont() returns (this is correct in general and works with // the Windows font mapper, but not here) + + wxFont font(style.GetFont()); + LOGFONT lf; - wxFillLogFont(&lf, &style.GetFont()); - cf.yHeight = 20*style.GetFont().GetPointSize(); // 1 pt = 20 twips + wxFillLogFont(&lf, &font); + cf.yHeight = 20*font.GetPointSize(); // 1 pt = 20 twips cf.bCharSet = lf.lfCharSet; cf.bPitchAndFamily = lf.lfPitchAndFamily; wxStrncpy( cf.szFaceName, lf.lfFaceName, WXSIZEOF(cf.szFaceName) ); diff --git a/src/richtext/richtextbuffer.cpp b/src/richtext/richtextbuffer.cpp index 84c330f..dc5a764 100644 --- a/src/richtext/richtextbuffer.cpp +++ b/src/richtext/richtextbuffer.cpp @@ -34,6 +34,7 @@ #include "wx/mstream.h" #include "wx/sstream.h" #include "wx/textfile.h" +#include "wx/hashmap.h" #include "wx/richtext/richtextctrl.h" #include "wx/richtext/richtextstyles.h" @@ -902,18 +903,18 @@ wxSize wxRichTextParagraphLayoutBox::GetLineSizeAtPosition(long pos, bool caretP /// Convenience function to add a paragraph of text -wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text, wxTextAttrEx* paraStyle) +wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text, wxTextAttr* paraStyle) { // Don't use the base style, just the default style, and the base style will // be combined at display time. // Divide into paragraph and character styles. - wxTextAttrEx defaultCharStyle; - wxTextAttrEx defaultParaStyle; + wxTextAttr defaultCharStyle; + wxTextAttr defaultParaStyle; wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle); - wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle; - wxTextAttrEx* cStyle = & defaultCharStyle; + wxTextAttr* pStyle = paraStyle ? paraStyle : (wxTextAttr*) & defaultParaStyle; + wxTextAttr* cStyle = & defaultCharStyle; wxRichTextParagraph* para = new wxRichTextParagraph(text, this, pStyle, cStyle); @@ -926,18 +927,18 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text, } /// Adds multiple paragraphs, based on newlines. -wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text, wxTextAttrEx* paraStyle) +wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text, wxTextAttr* paraStyle) { // Don't use the base style, just the default style, and the base style will // be combined at display time. // Divide into paragraph and character styles. - wxTextAttrEx defaultCharStyle; - wxTextAttrEx defaultParaStyle; + wxTextAttr defaultCharStyle; + wxTextAttr defaultParaStyle; wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle); - wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle; - wxTextAttrEx* cStyle = & defaultCharStyle; + wxTextAttr* pStyle = paraStyle ? paraStyle : (wxTextAttr*) & defaultParaStyle; + wxTextAttr* cStyle = & defaultCharStyle; wxRichTextParagraph* firstPara = NULL; wxRichTextParagraph* lastPara = NULL; @@ -989,18 +990,18 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text } /// Convenience function to add an image -wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxTextAttrEx* paraStyle) +wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxTextAttr* paraStyle) { // Don't use the base style, just the default style, and the base style will // be combined at display time. // Divide into paragraph and character styles. - wxTextAttrEx defaultCharStyle; - wxTextAttrEx defaultParaStyle; + wxTextAttr defaultCharStyle; + wxTextAttr defaultParaStyle; wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle); - wxTextAttrEx* pStyle = paraStyle ? paraStyle : (wxTextAttrEx*) & defaultParaStyle; - wxTextAttrEx* cStyle = & defaultCharStyle; + wxTextAttr* pStyle = paraStyle ? paraStyle : (wxTextAttr*) & defaultParaStyle; + wxTextAttr* cStyle = & defaultCharStyle; wxRichTextParagraph* para = new wxRichTextParagraph(this, pStyle); AppendChild(para); @@ -1046,7 +1047,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag wxASSERT (firstPara != NULL); // Apply the new paragraph attributes to the existing paragraph - wxTextAttrEx attr(para->GetAttributes()); + wxTextAttr attr(para->GetAttributes()); wxRichTextApplyStyle(attr, firstPara->GetAttributes()); para->SetAttributes(attr); @@ -1545,7 +1546,7 @@ wxRichTextObject* wxRichTextParagraphLayoutBox::GetLeafObjectAtPosition(long pos } /// Set character or paragraph text attributes: apply character styles only to immediate text nodes -bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style, int flags) +bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const wxTextAttr& style, int flags) { bool characterStyle = false; bool paragraphStyle = false; @@ -1563,7 +1564,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const bool removeStyle = ((flags & wxRICHTEXT_SETSTYLE_REMOVE) != 0); // Apply paragraph style first, if any - wxRichTextAttr wholeStyle(style); + wxTextAttr wholeStyle(style); if (!removeStyle && wholeStyle.HasParagraphStyleName() && GetStyleSheet()) { @@ -1573,7 +1574,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const } // Limit the attributes to be set to the content to only character attributes. - wxRichTextAttr characterAttributes(wholeStyle); + wxTextAttr characterAttributes(wholeStyle); characterAttributes.SetFlags(characterAttributes.GetFlags() & (wxTEXT_ATTR_CHARACTER)); if (!removeStyle && characterAttributes.HasCharacterStyleName() && GetStyleSheet()) @@ -1643,7 +1644,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const { // Only apply attributes that will make a difference to the combined // style as seen on the display - wxRichTextAttr combinedAttr(para->GetCombinedAttributes()); + wxTextAttr combinedAttr(para->GetCombinedAttributes()); wxRichTextApplyStyle(newPara->GetAttributes(), wholeStyle, & combinedAttr); } else @@ -1723,7 +1724,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const { // Only apply attributes that will make a difference to the combined // style as seen on the display - wxRichTextAttr combinedAttr(newPara->GetCombinedAttributes(child->GetAttributes())); + wxTextAttr combinedAttr(newPara->GetCombinedAttributes(child->GetAttributes())); wxRichTextApplyStyle(child->GetAttributes(), characterAttributes, & combinedAttr); } else @@ -1749,53 +1750,20 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const return true; } -/// Set text attributes -bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const wxTextAttrEx& style, int flags) -{ - wxRichTextAttr richStyle = style; - return SetStyle(range, richStyle, flags); -} - /// Get the text attributes for this position. -bool wxRichTextParagraphLayoutBox::GetStyle(long position, wxTextAttrEx& style) +bool wxRichTextParagraphLayoutBox::GetStyle(long position, wxTextAttr& style) { return DoGetStyle(position, style, true); } -/// Get the text attributes for this position. -bool wxRichTextParagraphLayoutBox::GetStyle(long position, wxRichTextAttr& style) -{ - wxTextAttrEx textAttrEx(style); - if (GetStyle(position, textAttrEx)) - { - style = textAttrEx; - return true; - } - else - return false; -} - -/// Get the content (uncombined) attributes for this position. -bool wxRichTextParagraphLayoutBox::GetUncombinedStyle(long position, wxTextAttrEx& style) +bool wxRichTextParagraphLayoutBox::GetUncombinedStyle(long position, wxTextAttr& style) { return DoGetStyle(position, style, false); } -bool wxRichTextParagraphLayoutBox::GetUncombinedStyle(long position, wxRichTextAttr& style) -{ - wxTextAttrEx textAttrEx(style); - if (GetUncombinedStyle(position, textAttrEx)) - { - style = textAttrEx; - return true; - } - else - return false; -} - /// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and /// context attributes. -bool wxRichTextParagraphLayoutBox::DoGetStyle(long position, wxTextAttrEx& style, bool combineStyles) +bool wxRichTextParagraphLayoutBox::DoGetStyle(long position, wxTextAttr& style, bool combineStyles) { wxRichTextObject* obj wxDUMMY_INITIALIZE(NULL); @@ -1844,15 +1812,15 @@ static bool wxHasStyle(long flags, long style) /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of /// content. -bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, const wxTextAttrEx& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes) +bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes) { if (style.HasFont()) { if (style.HasFontSize() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_SIZE)) { - if (currentStyle.GetFont().Ok() && currentStyle.HasFontSize()) + if (currentStyle.HasFontSize()) { - if (currentStyle.GetFont().GetPointSize() != style.GetFont().GetPointSize()) + if (currentStyle.GetFontSize() != style.GetFontSize()) { // Clash of style - mark as such multipleStyleAttributes |= wxTEXT_ATTR_FONT_SIZE; @@ -1861,21 +1829,15 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons } else { - if (!currentStyle.GetFont().Ok()) - wxSetFontPreservingStyles(currentStyle, *wxNORMAL_FONT); - wxFont font(currentStyle.GetFont()); - font.SetPointSize(style.GetFont().GetPointSize()); - - wxSetFontPreservingStyles(currentStyle, font); - currentStyle.SetFlags(currentStyle.GetFlags() | wxTEXT_ATTR_FONT_SIZE); + currentStyle.SetFontSize(style.GetFontSize()); } } if (style.HasFontItalic() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_ITALIC)) { - if (currentStyle.GetFont().Ok() && currentStyle.HasFontItalic()) + if (currentStyle.HasFontItalic()) { - if (currentStyle.GetFont().GetStyle() != style.GetFont().GetStyle()) + if (currentStyle.GetFontStyle() != style.GetFontStyle()) { // Clash of style - mark as such multipleStyleAttributes |= wxTEXT_ATTR_FONT_ITALIC; @@ -1884,20 +1846,15 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons } else { - if (!currentStyle.GetFont().Ok()) - wxSetFontPreservingStyles(currentStyle, *wxNORMAL_FONT); - wxFont font(currentStyle.GetFont()); - font.SetStyle(style.GetFont().GetStyle()); - wxSetFontPreservingStyles(currentStyle, font); - currentStyle.SetFlags(currentStyle.GetFlags() | wxTEXT_ATTR_FONT_ITALIC); + currentStyle.SetFontStyle(style.GetFontStyle()); } } if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT)) { - if (currentStyle.GetFont().Ok() && currentStyle.HasFontWeight()) + if (currentStyle.HasFontWeight()) { - if (currentStyle.GetFont().GetWeight() != style.GetFont().GetWeight()) + if (currentStyle.GetFontWeight() != style.GetFontWeight()) { // Clash of style - mark as such multipleStyleAttributes |= wxTEXT_ATTR_FONT_WEIGHT; @@ -1906,21 +1863,16 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons } else { - if (!currentStyle.GetFont().Ok()) - wxSetFontPreservingStyles(currentStyle, *wxNORMAL_FONT); - wxFont font(currentStyle.GetFont()); - font.SetWeight(style.GetFont().GetWeight()); - wxSetFontPreservingStyles(currentStyle, font); - currentStyle.SetFlags(currentStyle.GetFlags() | wxTEXT_ATTR_FONT_WEIGHT); + currentStyle.SetFontWeight(style.GetFontWeight()); } } if (style.HasFontFaceName() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_FACE)) { - if (currentStyle.GetFont().Ok() && currentStyle.HasFontFaceName()) + if (currentStyle.HasFontFaceName()) { - wxString faceName1(currentStyle.GetFont().GetFaceName()); - wxString faceName2(style.GetFont().GetFaceName()); + wxString faceName1(currentStyle.GetFontFaceName()); + wxString faceName2(style.GetFontFaceName()); if (faceName1 != faceName2) { @@ -1931,20 +1883,15 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons } else { - if (!currentStyle.GetFont().Ok()) - wxSetFontPreservingStyles(currentStyle, *wxNORMAL_FONT); - wxFont font(currentStyle.GetFont()); - font.SetFaceName(style.GetFont().GetFaceName()); - wxSetFontPreservingStyles(currentStyle, font); - currentStyle.SetFlags(currentStyle.GetFlags() | wxTEXT_ATTR_FONT_FACE); + currentStyle.SetFontFaceName(style.GetFontFaceName()); } } if (style.HasFontUnderlined() && !wxHasStyle(multipleStyleAttributes, wxTEXT_ATTR_FONT_UNDERLINE)) { - if (currentStyle.GetFont().Ok() && currentStyle.HasFontUnderlined()) + if (currentStyle.HasFontUnderlined()) { - if (currentStyle.GetFont().GetUnderlined() != style.GetFont().GetUnderlined()) + if (currentStyle.GetFontUnderlined() != style.GetFontUnderlined()) { // Clash of style - mark as such multipleStyleAttributes |= wxTEXT_ATTR_FONT_UNDERLINE; @@ -1953,12 +1900,7 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons } else { - if (!currentStyle.GetFont().Ok()) - wxSetFontPreservingStyles(currentStyle, *wxNORMAL_FONT); - wxFont font(currentStyle.GetFont()); - font.SetUnderlined(style.GetFont().GetUnderlined()); - wxSetFontPreservingStyles(currentStyle, font); - currentStyle.SetFlags(currentStyle.GetFlags() | wxTEXT_ATTR_FONT_UNDERLINE); + currentStyle.SetFontUnderlined(style.GetFontUnderlined()); } } } @@ -2274,9 +2216,9 @@ bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttrEx& currentStyle, cons /// that attribute is not present within the flags. /// *** Note that this is not recursive, and so assumes that content inside a paragraph is not itself /// nested. -bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range, wxTextAttrEx& style) +bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style) { - style = wxTextAttrEx(); + style = wxTextAttr(); // The attributes that aren't valid because of multiple styles within the range long multipleStyleAttributes = 0; @@ -2290,7 +2232,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range { if (para->GetChildren().GetCount() == 0) { - wxTextAttrEx paraStyle = para->GetCombinedAttributes(); + wxTextAttr paraStyle = para->GetCombinedAttributes(); CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes); } @@ -2300,7 +2242,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range paraRange.LimitTo(range); // First collect paragraph attributes only - wxTextAttrEx paraStyle = para->GetCombinedAttributes(); + wxTextAttr paraStyle = para->GetCombinedAttributes(); paraStyle.SetFlags(paraStyle.GetFlags() & wxTEXT_ATTR_PARAGRAPH); CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes); @@ -2311,7 +2253,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range wxRichTextObject* child = childNode->GetData(); if (!(child->GetRange().GetStart() > range.GetEnd() || child->GetRange().GetEnd() < range.GetStart())) { - wxTextAttrEx childStyle = para->GetCombinedAttributes(child->GetAttributes()); + wxTextAttr childStyle = para->GetCombinedAttributes(child->GetAttributes()); // Now collect character attributes only childStyle.SetFlags(childStyle.GetFlags() & wxTEXT_ATTR_CHARACTER); @@ -2329,7 +2271,7 @@ bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range } /// Set default style -bool wxRichTextParagraphLayoutBox::SetDefaultStyle(const wxTextAttrEx& style) +bool wxRichTextParagraphLayoutBox::SetDefaultStyle(const wxTextAttr& style) { m_defaultAttributes = style; return true; @@ -2339,7 +2281,7 @@ bool wxRichTextParagraphLayoutBox::SetDefaultStyle(const wxTextAttrEx& style) /// of the attributes are different within the range, the test fails. You /// can use this to implement, for example, bold button updating. style must have /// flags indicating which attributes are of interest. -bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const +bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttr& style) const { int foundCount = 0; int matchingCount = 0; @@ -2366,7 +2308,7 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& if (!child->GetRange().IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText))) { foundCount ++; - wxTextAttrEx textAttr = para->GetCombinedAttributes(child->GetAttributes()); + wxTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes()); if (wxTextAttrEqPartial(textAttr, style, style.GetFlags())) matchingCount ++; @@ -2383,17 +2325,11 @@ bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& return foundCount == matchingCount; } -bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const -{ - wxRichTextAttr richStyle = style; - return HasCharacterAttributes(range, richStyle); -} - /// Test if this whole range has paragraph attributes of the specified kind. If any /// of the attributes are different within the range, the test fails. You /// can use this to implement, for example, centering button updating. style must have /// flags indicating which attributes are of interest. -bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const +bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttr& style) const { int foundCount = 0; int matchingCount = 0; @@ -2412,7 +2348,7 @@ bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& if (!para->GetRange().IsOutside(range)) { - wxTextAttrEx textAttr = GetAttributes(); + wxTextAttr textAttr = GetAttributes(); // Apply the paragraph style wxRichTextApplyStyle(textAttr, para->GetAttributes()); @@ -2427,12 +2363,6 @@ bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& return foundCount == matchingCount; } -bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const -{ - wxRichTextAttr richStyle = style; - return HasParagraphAttributes(range, richStyle); -} - void wxRichTextParagraphLayoutBox::Clear() { DeleteChildren(); @@ -2643,7 +2573,7 @@ bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wx // Renumbering will need to be done when we promote/demote a paragraph. // Apply the overall list style, and item style for this level - wxTextAttrEx listStyle(def->GetCombinedStyleForLevel(thisLevel, styleSheet)); + wxTextAttr listStyle(def->GetCombinedStyleForLevel(thisLevel, styleSheet)); wxRichTextApplyStyle(newPara->GetAttributes(), listStyle); // Now we need to do numbering @@ -2818,7 +2748,7 @@ bool wxRichTextParagraphLayoutBox::DoNumberList(const wxRichTextRange& range, co } // Apply the overall list style, and item style for this level - wxTextAttrEx listStyle(defToUse->GetCombinedStyleForLevel(thisLevel, styleSheet)); + wxTextAttr listStyle(defToUse->GetCombinedStyleForLevel(thisLevel, styleSheet)); wxRichTextApplyStyle(newPara->GetAttributes(), listStyle); // OK, we've (re)applied the style, now let's get the numbering right. @@ -2929,7 +2859,7 @@ bool wxRichTextParagraphLayoutBox::PromoteList(int promoteBy, const wxRichTextRa /// Fills in the attributes for numbering a paragraph after previousParagraph. It also finds the /// position of the paragraph that it had to start looking from. -bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const +bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxTextAttr& attr) const { if (!previousParagraph->GetAttributes().HasFlag(wxTEXT_ATTR_BULLET_STYLE) || previousParagraph->GetAttributes().GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE) return false; @@ -2991,14 +2921,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextParagraph, wxRichTextBox) wxArrayInt wxRichTextParagraph::sm_defaultTabs; -wxRichTextParagraph::wxRichTextParagraph(wxRichTextObject* parent, wxTextAttrEx* style): +wxRichTextParagraph::wxRichTextParagraph(wxRichTextObject* parent, wxTextAttr* style): wxRichTextBox(parent) { if (style) SetAttributes(*style); } -wxRichTextParagraph::wxRichTextParagraph(const wxString& text, wxRichTextObject* parent, wxTextAttrEx* paraStyle, wxTextAttrEx* charStyle): +wxRichTextParagraph::wxRichTextParagraph(const wxString& text, wxRichTextObject* parent, wxTextAttr* paraStyle, wxTextAttr* charStyle): wxRichTextBox(parent) { if (paraStyle) @@ -3015,7 +2945,7 @@ wxRichTextParagraph::~wxRichTextParagraph() /// Draw the item bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& WXUNUSED(rect), int WXUNUSED(descent), int style) { - wxTextAttrEx attr = GetCombinedAttributes(); + wxTextAttr attr = GetCombinedAttributes(); // Draw the bullet, if any if (attr.GetBulletStyle() != wxTEXT_ATTR_BULLET_STYLE_NONE) @@ -3025,7 +2955,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR int spaceBeforePara = ConvertTenthsMMToPixels(dc, attr.GetParagraphSpacingBefore()); int leftIndent = ConvertTenthsMMToPixels(dc, attr.GetLeftIndent()); - wxTextAttrEx bulletAttr(GetCombinedAttributes()); + wxTextAttr bulletAttr(GetCombinedAttributes()); // Combine with the font of the first piece of content, if one is specified if (GetChildren().GetCount() > 0) @@ -3050,8 +2980,8 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR else { wxFont font; - if (bulletAttr.GetFont().Ok()) - font = bulletAttr.GetFont(); + if (bulletAttr.HasFont() && GetBuffer()) + font = GetBuffer()->GetFontTable().FindFont(bulletAttr); else font = (*wxNORMAL_FONT); @@ -3137,7 +3067,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR /// Lay the item out bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) { - wxTextAttrEx attr = GetCombinedAttributes(); + wxTextAttr attr = GetCombinedAttributes(); // ClearLines(); @@ -3151,9 +3081,10 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) int lineSpacing = 0; // Let's assume line spacing of 10 is normal, 15 is 1.5, 20 is 2, etc. - if (attr.GetLineSpacing() != 10 && attr.GetFont().Ok()) + if (attr.GetLineSpacing() != 10 && GetBuffer()) { - dc.SetFont(attr.GetFont()); + wxFont font(GetBuffer()->GetFontTable().FindFont(attr)); + dc.SetFont(font); lineSpacing = (ConvertTenthsMMToPixels(dc, dc.GetCharHeight()) * attr.GetLineSpacing())/10; } @@ -3330,10 +3261,10 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) line->SetPosition(currentPosition); - if (lineHeight == 0) + if (lineHeight == 0 && GetBuffer()) { - if (attr.GetFont().Ok()) - dc.SetFont(attr.GetFont()); + wxFont font(GetBuffer()->GetFontTable().FindFont(attr)); + dc.SetFont(font); lineHeight = dc.GetCharHeight(); } if (maxDescent == 0) @@ -3363,7 +3294,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style) } /// Apply paragraph styles, such as centering, to wrapped lines -void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttrEx& attr, const wxRect& rect) +void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect) { if (!attr.HasAlignment()) return; @@ -4036,9 +3967,9 @@ bool wxRichTextParagraph::ClearUnusedLines(int lineCount) /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically /// retrieve the actual style. -wxTextAttrEx wxRichTextParagraph::GetCombinedAttributes(const wxTextAttrEx& contentStyle) const +wxTextAttr wxRichTextParagraph::GetCombinedAttributes(const wxTextAttr& contentStyle) const { - wxTextAttrEx attr; + wxTextAttr attr; wxRichTextBuffer* buf = wxDynamicCast(GetParent(), wxRichTextBuffer); if (buf) { @@ -4053,9 +3984,9 @@ wxTextAttrEx wxRichTextParagraph::GetCombinedAttributes(const wxTextAttrEx& cont } /// Get combined attributes of the base style and paragraph style. -wxTextAttrEx wxRichTextParagraph::GetCombinedAttributes() const +wxTextAttr wxRichTextParagraph::GetCombinedAttributes() const { - wxTextAttrEx attr; + wxTextAttr attr; wxRichTextBuffer* buf = wxDynamicCast(GetParent(), wxRichTextBuffer); if (buf) { @@ -4155,7 +4086,7 @@ wxRichTextRange wxRichTextLine::GetAbsoluteRange() const IMPLEMENT_DYNAMIC_CLASS(wxRichTextPlainText, wxRichTextObject) -wxRichTextPlainText::wxRichTextPlainText(const wxString& text, wxRichTextObject* parent, wxTextAttrEx* style): +wxRichTextPlainText::wxRichTextPlainText(const wxString& text, wxRichTextObject* parent, wxTextAttr* style): wxRichTextObject(parent) { if (style) @@ -4175,7 +4106,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph); wxASSERT (para != NULL); - wxTextAttrEx textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes()); + wxTextAttr textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes()); int offset = GetRange().GetStart(); @@ -4197,8 +4128,8 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR // Test for the optimized situations where all is selected, or none // is selected. - if (textAttr.GetFont().Ok()) - dc.SetFont(textAttr.GetFont()); + wxFont font(GetBuffer()->GetFontTable().FindFont(textAttr)); + dc.SetFont(font); // (a) All selected. if (selectionRange.GetStart() <= range.GetStart() && selectionRange.GetEnd() >= range.GetEnd()) @@ -4297,7 +4228,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR return true; } -bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect,wxString& str, wxCoord& x, wxCoord& y, bool selected) +bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxTextAttr& attr, const wxRect& rect,wxString& str, wxCoord& x, wxCoord& y, bool selected) { bool hasTabs = (str.Find(wxT('\t')) != wxNOT_FOUND); @@ -4442,14 +4373,14 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph); wxASSERT (para != NULL); - wxTextAttrEx textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes()); + wxTextAttr textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes()); // Always assume unformatted text, since at this level we have no knowledge // of line breaks - and we don't need it, since we'll calculate size within // formatted text by doing it in chunks according to the line ranges - if (textAttr.GetFont().Ok()) - dc.SetFont(textAttr.GetFont()); + wxFont font(GetBuffer()->GetFontTable().FindFont(textAttr)); + dc.SetFont(font); int startPos = range.GetStart() - GetRange().GetStart(); long len = range.GetLength(); @@ -4721,10 +4652,10 @@ bool wxRichTextBuffer::InsertParagraphsWithUndo(long pos, const wxRichTextParagr { wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false); - wxTextAttrEx attr(GetDefaultStyle()); + wxTextAttr attr(GetDefaultStyle()); - wxTextAttrEx* p = NULL; - wxTextAttrEx paraAttr; + wxTextAttr* p = NULL; + wxTextAttr paraAttr; if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE) { paraAttr = GetStyleForNewParagraph(pos); @@ -4762,8 +4693,8 @@ bool wxRichTextBuffer::InsertTextWithUndo(long pos, const wxString& text, wxRich { wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false); - wxTextAttrEx* p = NULL; - wxTextAttrEx paraAttr; + wxTextAttr* p = NULL; + wxTextAttr paraAttr; if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE) { // Get appropriate paragraph style @@ -4800,8 +4731,8 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int { wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false); - wxTextAttrEx* p = NULL; - wxTextAttrEx paraAttr; + wxTextAttr* p = NULL; + wxTextAttr paraAttr; if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE) { paraAttr = GetStyleForNewParagraph(pos, false, true /* look for next paragraph style */); @@ -4809,7 +4740,7 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int p = & paraAttr; } - wxTextAttrEx attr(GetDefaultStyle()); + wxTextAttr attr(GetDefaultStyle()); wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr); action->GetNewParagraphs().AppendChild(newPara); @@ -4833,8 +4764,8 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock& { wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Image"), wxRICHTEXT_INSERT, this, ctrl, false); - wxTextAttrEx* p = NULL; - wxTextAttrEx paraAttr; + wxTextAttr* p = NULL; + wxTextAttr paraAttr; if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE) { paraAttr = GetStyleForNewParagraph(pos); @@ -4842,7 +4773,7 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock& p = & paraAttr; } - wxTextAttrEx attr(GetDefaultStyle()); + wxTextAttr attr(GetDefaultStyle()); wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr); if (p) @@ -4868,12 +4799,12 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock& /// Get the style that is appropriate for a new paragraph at this position. /// If the previous paragraph has a paragraph style name, look up the next-paragraph /// style. -wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPosition, bool lookUpNewParaStyle) const +wxTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPosition, bool lookUpNewParaStyle) const { wxRichTextParagraph* para = GetParagraphAtPosition(pos, caretPosition); if (para) { - wxRichTextAttr attr; + wxTextAttr attr; bool foundAttributes = false; // Look for a matching paragraph style @@ -4915,15 +4846,15 @@ wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPos // Now see if we need to number the paragraph. if (attr.HasBulletStyle()) { - wxRichTextAttr numberingAttr; + wxTextAttr numberingAttr; if (FindNextParagraphNumber(para, numberingAttr)) - wxRichTextApplyStyle(attr, (const wxRichTextAttr&) numberingAttr); + wxRichTextApplyStyle(attr, (const wxTextAttr&) numberingAttr); } return attr; } else - return wxRichTextAttr(); + return wxTextAttr(); } /// Submit command to delete this range @@ -5033,12 +4964,12 @@ bool wxRichTextBuffer::EndSuppressUndo() } /// Begin using a style -bool wxRichTextBuffer::BeginStyle(const wxTextAttrEx& style) +bool wxRichTextBuffer::BeginStyle(const wxTextAttr& style) { - wxTextAttrEx newStyle(GetDefaultStyle()); + wxTextAttr newStyle(GetDefaultStyle()); // Save the old default style - m_attributeStack.Append((wxObject*) new wxTextAttrEx(GetDefaultStyle())); + m_attributeStack.Append((wxObject*) new wxTextAttr(GetDefaultStyle())); wxRichTextApplyStyle(newStyle, style); newStyle.SetFlags(style.GetFlags()|newStyle.GetFlags()); @@ -5060,7 +4991,7 @@ bool wxRichTextBuffer::EndStyle() } wxList::compatibility_iterator node = m_attributeStack.GetLast(); - wxTextAttrEx* attr = (wxTextAttrEx*)node->GetData(); + wxTextAttr* attr = (wxTextAttr*)node->GetData(); m_attributeStack.Erase(node); SetDefaultStyle(*attr); @@ -5081,18 +5012,15 @@ bool wxRichTextBuffer::EndAllStyles() void wxRichTextBuffer::ClearStyleStack() { for (wxList::compatibility_iterator node = m_attributeStack.GetFirst(); node; node = node->GetNext()) - delete (wxTextAttrEx*) node->GetData(); + delete (wxTextAttr*) node->GetData(); m_attributeStack.Clear(); } /// Begin using bold bool wxRichTextBuffer::BeginBold() { - wxFont font(GetBasicStyle().GetFont()); - font.SetWeight(wxBOLD); - - wxTextAttrEx attr; - attr.SetFont(font,wxTEXT_ATTR_FONT_WEIGHT); + wxTextAttr attr; + attr.SetFontWeight(wxBOLD); return BeginStyle(attr); } @@ -5100,11 +5028,8 @@ bool wxRichTextBuffer::BeginBold() /// Begin using italic bool wxRichTextBuffer::BeginItalic() { - wxFont font(GetBasicStyle().GetFont()); - font.SetStyle(wxITALIC); - - wxTextAttrEx attr; - attr.SetFont(font, wxTEXT_ATTR_FONT_ITALIC); + wxTextAttr attr; + attr.SetFontStyle(wxITALIC); return BeginStyle(attr); } @@ -5112,11 +5037,8 @@ bool wxRichTextBuffer::BeginItalic() /// Begin using underline bool wxRichTextBuffer::BeginUnderline() { - wxFont font(GetBasicStyle().GetFont()); - font.SetUnderlined(true); - - wxTextAttrEx attr; - attr.SetFont(font, wxTEXT_ATTR_FONT_UNDERLINE); + wxTextAttr attr; + attr.SetFontUnderlined(true); return BeginStyle(attr); } @@ -5124,11 +5046,8 @@ bool wxRichTextBuffer::BeginUnderline() /// Begin using point size bool wxRichTextBuffer::BeginFontSize(int pointSize) { - wxFont font(GetBasicStyle().GetFont()); - font.SetPointSize(pointSize); - - wxTextAttrEx attr; - attr.SetFont(font, wxTEXT_ATTR_FONT_SIZE); + wxTextAttr attr; + attr.SetFontSize(pointSize); return BeginStyle(attr); } @@ -5136,8 +5055,7 @@ bool wxRichTextBuffer::BeginFontSize(int pointSize) /// Begin using this font bool wxRichTextBuffer::BeginFont(const wxFont& font) { - wxTextAttrEx attr; - attr.SetFlags(wxTEXT_ATTR_FONT); + wxTextAttr attr; attr.SetFont(font); return BeginStyle(attr); @@ -5146,7 +5064,7 @@ bool wxRichTextBuffer::BeginFont(const wxFont& font) /// Begin using this colour bool wxRichTextBuffer::BeginTextColour(const wxColour& colour) { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_TEXT_COLOUR); attr.SetTextColour(colour); @@ -5156,7 +5074,7 @@ bool wxRichTextBuffer::BeginTextColour(const wxColour& colour) /// Begin using alignment bool wxRichTextBuffer::BeginAlignment(wxTextAttrAlignment alignment) { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_ALIGNMENT); attr.SetAlignment(alignment); @@ -5166,7 +5084,7 @@ bool wxRichTextBuffer::BeginAlignment(wxTextAttrAlignment alignment) /// Begin left indent bool wxRichTextBuffer::BeginLeftIndent(int leftIndent, int leftSubIndent) { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_LEFT_INDENT); attr.SetLeftIndent(leftIndent, leftSubIndent); @@ -5176,7 +5094,7 @@ bool wxRichTextBuffer::BeginLeftIndent(int leftIndent, int leftSubIndent) /// Begin right indent bool wxRichTextBuffer::BeginRightIndent(int rightIndent) { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_RIGHT_INDENT); attr.SetRightIndent(rightIndent); @@ -5192,7 +5110,7 @@ bool wxRichTextBuffer::BeginParagraphSpacing(int before, int after) if (after != 0) flags |= wxTEXT_ATTR_PARA_SPACING_AFTER; - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(flags); attr.SetParagraphSpacingBefore(before); attr.SetParagraphSpacingAfter(after); @@ -5203,7 +5121,7 @@ bool wxRichTextBuffer::BeginParagraphSpacing(int before, int after) /// Begin line spacing bool wxRichTextBuffer::BeginLineSpacing(int lineSpacing) { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_LINE_SPACING); attr.SetLineSpacing(lineSpacing); @@ -5213,7 +5131,7 @@ bool wxRichTextBuffer::BeginLineSpacing(int lineSpacing) /// Begin numbered bullet bool wxRichTextBuffer::BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle) { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT); attr.SetBulletStyle(bulletStyle); attr.SetBulletNumber(bulletNumber); @@ -5225,7 +5143,7 @@ bool wxRichTextBuffer::BeginNumberedBullet(int bulletNumber, int leftIndent, int /// Begin symbol bullet bool wxRichTextBuffer::BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle) { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT); attr.SetBulletStyle(bulletStyle); attr.SetLeftIndent(leftIndent, leftSubIndent); @@ -5237,7 +5155,7 @@ bool wxRichTextBuffer::BeginSymbolBullet(const wxString& symbol, int leftIndent, /// Begin standard bullet bool wxRichTextBuffer::BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle) { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT); attr.SetBulletStyle(bulletStyle); attr.SetLeftIndent(leftIndent, leftSubIndent); @@ -5254,7 +5172,7 @@ bool wxRichTextBuffer::BeginCharacterStyle(const wxString& characterStyle) wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterStyle); if (def) { - wxTextAttrEx attr = def->GetStyleMergedWithBase(GetStyleSheet()); + wxTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet()); return BeginStyle(attr); } } @@ -5269,7 +5187,7 @@ bool wxRichTextBuffer::BeginParagraphStyle(const wxString& paragraphStyle) wxRichTextParagraphStyleDefinition* def = GetStyleSheet()->FindParagraphStyle(paragraphStyle); if (def) { - wxTextAttrEx attr = def->GetStyleMergedWithBase(GetStyleSheet()); + wxTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet()); return BeginStyle(attr); } } @@ -5284,7 +5202,7 @@ bool wxRichTextBuffer::BeginListStyle(const wxString& listStyle, int level, int wxRichTextListStyleDefinition* def = GetStyleSheet()->FindListStyle(listStyle); if (def) { - wxTextAttrEx attr(def->GetCombinedStyleForLevel(level)); + wxTextAttr attr(def->GetCombinedStyleForLevel(level)); attr.SetBulletNumber(number); @@ -5297,7 +5215,7 @@ bool wxRichTextBuffer::BeginListStyle(const wxString& listStyle, int level, int /// Begin URL bool wxRichTextBuffer::BeginURL(const wxString& url, const wxString& characterStyle) { - wxTextAttrEx attr; + wxTextAttr attr; if (!characterStyle.IsEmpty() && GetStyleSheet()) { @@ -5467,7 +5385,7 @@ bool wxRichTextBuffer::LoadFile(const wxString& filename, int type) wxRichTextFileHandler* handler = FindHandlerFilenameOrType(filename, type); if (handler) { - SetDefaultStyle(wxTextAttrEx()); + SetDefaultStyle(wxTextAttr()); handler->SetFlags(GetHandlerFlags()); bool success = handler->LoadFile(this, filename); Invalidate(wxRICHTEXT_ALL); @@ -5496,7 +5414,7 @@ bool wxRichTextBuffer::LoadFile(wxInputStream& stream, int type) wxRichTextFileHandler* handler = FindHandler(type); if (handler) { - SetDefaultStyle(wxTextAttrEx()); + SetDefaultStyle(wxTextAttr()); handler->SetFlags(GetHandlerFlags()); bool success = handler->LoadFile(this, stream); Invalidate(wxRICHTEXT_ALL); @@ -5750,7 +5668,7 @@ void wxRichTextBuffer::SetRenderer(wxRichTextRenderer* renderer) sm_renderer = renderer; } -bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& bulletAttr, const wxRect& rect) +bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& bulletAttr, const wxRect& rect) { if (bulletAttr.GetTextColour().Ok()) { @@ -5764,8 +5682,10 @@ bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, w } wxFont font; - if (bulletAttr.GetFont().Ok()) - font = bulletAttr.GetFont(); + if (bulletAttr.HasFont()) + { + font = paragraph->GetBuffer()->GetFontTable().FindFont(bulletAttr); + } else font = (*wxNORMAL_FONT); @@ -5823,19 +5743,23 @@ bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, w return true; } -bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect, const wxString& text) +bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text) { if (!text.empty()) { wxFont font; - if ((attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL) && !attr.GetBulletFont().IsEmpty() && attr.GetFont().Ok()) - { - font = (*wxTheFontList->FindOrCreateFont(attr.GetFont().GetPointSize(), attr.GetFont().GetFamily(), - attr.GetFont().GetStyle(), attr.GetFont().GetWeight(), attr.GetFont().GetUnderlined(), - attr.GetBulletFont())); - } - else if (attr.GetFont().Ok()) - font = attr.GetFont(); + if ((attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL) && !attr.GetBulletFont().IsEmpty() && attr.HasFont()) + { + wxTextAttr fontAttr; + fontAttr.SetFontSize(attr.GetFontSize()); + fontAttr.SetFontStyle(attr.GetFontStyle()); + fontAttr.SetFontWeight(attr.GetFontWeight()); + fontAttr.SetFontUnderlined(attr.GetFontUnderlined()); + fontAttr.SetFontFaceName(attr.GetBulletFont()); + font = paragraph->GetBuffer()->GetFontTable().FindFont(fontAttr); + } + else if (attr.HasFont()) + font = paragraph->GetBuffer()->GetFontTable().FindFont(attr); else font = (*wxNORMAL_FONT); @@ -5871,7 +5795,7 @@ bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& return false; } -bool wxRichTextStdRenderer::DrawBitmapBullet(wxRichTextParagraph* WXUNUSED(paragraph), wxDC& WXUNUSED(dc), const wxTextAttrEx& WXUNUSED(attr), const wxRect& WXUNUSED(rect)) +bool wxRichTextStdRenderer::DrawBitmapBullet(wxRichTextParagraph* WXUNUSED(paragraph), wxDC& WXUNUSED(dc), const wxTextAttr& WXUNUSED(attr), const wxRect& WXUNUSED(rect)) { // Currently unimplemented. The intention is to store bitmaps by name in a media store associated // with the buffer. The store will allow retrieval from memory, disk or other means. @@ -6385,7 +6309,7 @@ bool wxRichTextRange::LimitTo(const wxRichTextRange& range) IMPLEMENT_DYNAMIC_CLASS(wxRichTextImage, wxRichTextObject) -wxRichTextImage::wxRichTextImage(const wxImage& image, wxRichTextObject* parent, wxTextAttrEx* charStyle): +wxRichTextImage::wxRichTextImage(const wxImage& image, wxRichTextObject* parent, wxTextAttr* charStyle): wxRichTextObject(parent) { m_image = image; @@ -6393,7 +6317,7 @@ wxRichTextImage::wxRichTextImage(const wxImage& image, wxRichTextObject* parent, SetAttributes(*charStyle); } -wxRichTextImage::wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent, wxTextAttrEx* charStyle): +wxRichTextImage::wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent, wxTextAttr* charStyle): wxRichTextObject(parent) { m_imageBlock = imageBlock; @@ -6495,1529 +6419,232 @@ void wxRichTextImage::Copy(const wxRichTextImage& obj) */ /// Compare two attribute objects -bool wxTextAttrEq(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2) +bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2) { return (attr1 == attr2); } -bool wxTextAttrEq(const wxTextAttrEx& attr1, const wxRichTextAttr& attr2) -{ - return ( - attr1.GetTextColour() == attr2.GetTextColour() && - attr1.GetBackgroundColour() == attr2.GetBackgroundColour() && - attr1.GetFont().GetPointSize() == attr2.GetFontSize() && - attr1.GetFont().GetStyle() == attr2.GetFontStyle() && - attr1.GetFont().GetWeight() == attr2.GetFontWeight() && - attr1.GetFont().GetFaceName() == attr2.GetFontFaceName() && - attr1.GetFont().GetUnderlined() == attr2.GetFontUnderlined() && - attr1.GetTextEffects() == attr2.GetTextEffects() && - attr1.GetTextEffectFlags() == attr2.GetTextEffectFlags() && - attr1.GetAlignment() == attr2.GetAlignment() && - attr1.GetLeftIndent() == attr2.GetLeftIndent() && - attr1.GetRightIndent() == attr2.GetRightIndent() && - attr1.GetLeftSubIndent() == attr2.GetLeftSubIndent() && - wxRichTextTabsEq(attr1.GetTabs(), attr2.GetTabs()) && - attr1.GetLineSpacing() == attr2.GetLineSpacing() && - attr1.GetParagraphSpacingAfter() == attr2.GetParagraphSpacingAfter() && - attr1.GetParagraphSpacingBefore() == attr2.GetParagraphSpacingBefore() && - attr1.GetBulletStyle() == attr2.GetBulletStyle() && - attr1.GetBulletNumber() == attr2.GetBulletNumber() && - attr1.GetBulletText() == attr2.GetBulletText() && - attr1.GetBulletName() == attr2.GetBulletName() && - attr1.GetBulletFont() == attr2.GetBulletFont() && - attr1.GetOutlineLevel() == attr2.GetOutlineLevel() && - attr1.GetCharacterStyleName() == attr2.GetCharacterStyleName() && - attr1.GetParagraphStyleName() == attr2.GetParagraphStyleName() && - attr1.GetListStyleName() == attr2.GetListStyleName() && - attr1.HasPageBreak() == attr2.HasPageBreak()); -} - -/// Compare two attribute objects, but take into account the flags -/// specifying attributes of interest. -bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2, int flags) -{ - if ((flags & wxTEXT_ATTR_TEXT_COLOUR) && attr1.GetTextColour() != attr2.GetTextColour()) - return false; - - if ((flags & wxTEXT_ATTR_BACKGROUND_COLOUR) && attr1.GetBackgroundColour() != attr2.GetBackgroundColour()) - return false; - - if ((flags & wxTEXT_ATTR_FONT_FACE) && attr1.GetFont().Ok() && attr2.GetFont().Ok() && - attr1.GetFont().GetFaceName() != attr2.GetFont().GetFaceName()) - return false; - - if ((flags & wxTEXT_ATTR_FONT_SIZE) && attr1.GetFont().Ok() && attr2.GetFont().Ok() && - attr1.GetFont().GetPointSize() != attr2.GetFont().GetPointSize()) - return false; - - if ((flags & wxTEXT_ATTR_FONT_WEIGHT) && attr1.GetFont().Ok() && attr2.GetFont().Ok() && - attr1.GetFont().GetWeight() != attr2.GetFont().GetWeight()) - return false; - - if ((flags & wxTEXT_ATTR_FONT_ITALIC) && attr1.GetFont().Ok() && attr2.GetFont().Ok() && - attr1.GetFont().GetStyle() != attr2.GetFont().GetStyle()) - return false; - - if ((flags & wxTEXT_ATTR_FONT_UNDERLINE) && attr1.GetFont().Ok() && attr2.GetFont().Ok() && - attr1.GetFont().GetUnderlined() != attr2.GetFont().GetUnderlined()) - return false; - - if ((flags & wxTEXT_ATTR_URL) && attr1.GetURL() != attr2.GetURL()) - return false; - - if ((flags & wxTEXT_ATTR_ALIGNMENT) && attr1.GetAlignment() != attr2.GetAlignment()) - return false; - - if ((flags & wxTEXT_ATTR_LEFT_INDENT) && - ((attr1.GetLeftIndent() != attr2.GetLeftIndent()) || (attr1.GetLeftSubIndent() != attr2.GetLeftSubIndent()))) - return false; - - if ((flags & wxTEXT_ATTR_RIGHT_INDENT) && - (attr1.GetRightIndent() != attr2.GetRightIndent())) - return false; +// Partial equality test taking flags into account +bool wxTextAttrEqPartial(const wxTextAttr& attr1, const wxTextAttr& attr2, int flags) +{ + return attr1.EqPartial(attr2, flags); +} - if ((flags & wxTEXT_ATTR_PARA_SPACING_AFTER) && - (attr1.GetParagraphSpacingAfter() != attr2.GetParagraphSpacingAfter())) +/// Compare tabs +bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2) +{ + if (tabs1.GetCount() != tabs2.GetCount()) return false; - if ((flags & wxTEXT_ATTR_PARA_SPACING_BEFORE) && - (attr1.GetParagraphSpacingBefore() != attr2.GetParagraphSpacingBefore())) - return false; + size_t i; + for (i = 0; i < tabs1.GetCount(); i++) + { + if (tabs1[i] != tabs2[i]) + return false; + } + return true; +} - if ((flags & wxTEXT_ATTR_LINE_SPACING) && - (attr1.GetLineSpacing() != attr2.GetLineSpacing())) - return false; +bool wxRichTextApplyStyle(wxTextAttr& destStyle, const wxTextAttr& style, wxTextAttr* compareWith) +{ + return destStyle.Apply(style, compareWith); +} - if ((flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) && - (attr1.GetCharacterStyleName() != attr2.GetCharacterStyleName())) - return false; +// Remove attributes +bool wxRichTextRemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style) +{ + return wxTextAttr::RemoveStyle(destStyle, style); +} - if ((flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && - (attr1.GetParagraphStyleName() != attr2.GetParagraphStyleName())) - return false; +/// Combine two bitlists, specifying the bits of interest with separate flags. +bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB) +{ + return wxTextAttr::CombineBitlists(valueA, valueB, flagsA, flagsB); +} - if ((flags & wxTEXT_ATTR_LIST_STYLE_NAME) && - (attr1.GetListStyleName() != attr2.GetListStyleName())) - return false; +/// Compare two bitlists +bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags) +{ + return wxTextAttr::BitlistsEqPartial(valueA, valueB, flags); +} - if ((flags & wxTEXT_ATTR_BULLET_STYLE) && - (attr1.GetBulletStyle() != attr2.GetBulletStyle())) - return false; +/// Split into paragraph and character styles +bool wxRichTextSplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle) +{ + return wxTextAttr::SplitParaCharStyles(style, parStyle, charStyle); +} - if ((flags & wxTEXT_ATTR_BULLET_NUMBER) && - (attr1.GetBulletNumber() != attr2.GetBulletNumber())) - return false; +/// Convert a decimal to Roman numerals +wxString wxRichTextDecimalToRoman(long n) +{ + static wxArrayInt decimalNumbers; + static wxArrayString romanNumbers; - if ((flags & wxTEXT_ATTR_BULLET_TEXT) && - (attr1.GetBulletText() != attr2.GetBulletText()) && - (attr1.GetBulletFont() != attr2.GetBulletFont())) - return false; + // Clean up arrays + if (n == -1) + { + decimalNumbers.Clear(); + romanNumbers.Clear(); + return wxEmptyString; + } - if ((flags & wxTEXT_ATTR_BULLET_NAME) && - (attr1.GetBulletName() != attr2.GetBulletName())) - return false; + if (decimalNumbers.GetCount() == 0) + { + #define wxRichTextAddDecRom(n, r) decimalNumbers.Add(n); romanNumbers.Add(r); - if ((flags & wxTEXT_ATTR_TABS) && - !wxRichTextTabsEq(attr1.GetTabs(), attr2.GetTabs())) - return false; + wxRichTextAddDecRom(1000, wxT("M")); + wxRichTextAddDecRom(900, wxT("CM")); + wxRichTextAddDecRom(500, wxT("D")); + wxRichTextAddDecRom(400, wxT("CD")); + wxRichTextAddDecRom(100, wxT("C")); + wxRichTextAddDecRom(90, wxT("XC")); + wxRichTextAddDecRom(50, wxT("L")); + wxRichTextAddDecRom(40, wxT("XL")); + wxRichTextAddDecRom(10, wxT("X")); + wxRichTextAddDecRom(9, wxT("IX")); + wxRichTextAddDecRom(5, wxT("V")); + wxRichTextAddDecRom(4, wxT("IV")); + wxRichTextAddDecRom(1, wxT("I")); + } - if ((flags & wxTEXT_ATTR_PAGE_BREAK) && - (attr1.HasPageBreak() != attr2.HasPageBreak())) - return false; + int i = 0; + wxString roman; - if (flags & wxTEXT_ATTR_EFFECTS) + while (n > 0 && i < 13) { - if (attr1.HasTextEffects() != attr2.HasTextEffects()) - return false; - if (!wxRichTextBitlistsEqPartial(attr1.GetTextEffects(), attr2.GetTextEffects(), attr2.GetTextEffectFlags())) - return false; + if (n >= decimalNumbers[i]) + { + n -= decimalNumbers[i]; + roman += romanNumbers[i]; + } + else + { + i ++; + } } + if (roman.IsEmpty()) + roman = wxT("0"); + return roman; +} - if ((flags & wxTEXT_ATTR_OUTLINE_LEVEL) && - (attr1.GetOutlineLevel() != attr2.GetOutlineLevel())) - return false; +/*! + * wxRichTextFileHandler + * Base class for file handlers + */ - return true; -} +IMPLEMENT_CLASS(wxRichTextFileHandler, wxObject) -bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxRichTextAttr& attr2, int flags) +#if wxUSE_FFILE && wxUSE_STREAMS +bool wxRichTextFileHandler::LoadFile(wxRichTextBuffer *buffer, const wxString& filename) { - if ((flags & wxTEXT_ATTR_TEXT_COLOUR) && attr1.GetTextColour() != attr2.GetTextColour()) - return false; + wxFFileInputStream stream(filename); + if (stream.Ok()) + return LoadFile(buffer, stream); - if ((flags & wxTEXT_ATTR_BACKGROUND_COLOUR) && attr1.GetBackgroundColour() != attr2.GetBackgroundColour()) - return false; + return false; +} - if ((flags & (wxTEXT_ATTR_FONT)) && !attr1.GetFont().Ok()) - return false; +bool wxRichTextFileHandler::SaveFile(wxRichTextBuffer *buffer, const wxString& filename) +{ + wxFFileOutputStream stream(filename); + if (stream.Ok()) + return SaveFile(buffer, stream); - if ((flags & wxTEXT_ATTR_FONT_FACE) && attr1.GetFont().Ok() && - attr1.GetFont().GetFaceName() != attr2.GetFontFaceName()) - return false; + return false; +} +#endif // wxUSE_FFILE && wxUSE_STREAMS - if ((flags & wxTEXT_ATTR_FONT_SIZE) && attr1.GetFont().Ok() && - attr1.GetFont().GetPointSize() != attr2.GetFontSize()) - return false; +/// Can we handle this filename (if using files)? By default, checks the extension. +bool wxRichTextFileHandler::CanHandle(const wxString& filename) const +{ + wxString path, file, ext; + wxSplitPath(filename, & path, & file, & ext); - if ((flags & wxTEXT_ATTR_FONT_WEIGHT) && attr1.GetFont().Ok() && - attr1.GetFont().GetWeight() != attr2.GetFontWeight()) - return false; + return (ext.Lower() == GetExtension()); +} - if ((flags & wxTEXT_ATTR_FONT_ITALIC) && attr1.GetFont().Ok() && - attr1.GetFont().GetStyle() != attr2.GetFontStyle()) - return false; +/*! + * wxRichTextTextHandler + * Plain text handler + */ - if ((flags & wxTEXT_ATTR_FONT_UNDERLINE) && attr1.GetFont().Ok() && - attr1.GetFont().GetUnderlined() != attr2.GetFontUnderlined()) - return false; +IMPLEMENT_CLASS(wxRichTextPlainTextHandler, wxRichTextFileHandler) - if ((flags & wxTEXT_ATTR_URL) && attr1.GetURL() != attr2.GetURL()) +#if wxUSE_STREAMS +bool wxRichTextPlainTextHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) +{ + if (!stream.IsOk()) return false; - if ((flags & wxTEXT_ATTR_ALIGNMENT) && attr1.GetAlignment() != attr2.GetAlignment()) - return false; + wxString str; + int lastCh = 0; - if ((flags & wxTEXT_ATTR_LEFT_INDENT) && - ((attr1.GetLeftIndent() != attr2.GetLeftIndent()) || (attr1.GetLeftSubIndent() != attr2.GetLeftSubIndent()))) - return false; + while (!stream.Eof()) + { + int ch = stream.GetC(); - if ((flags & wxTEXT_ATTR_RIGHT_INDENT) && - (attr1.GetRightIndent() != attr2.GetRightIndent())) - return false; + if (!stream.Eof()) + { + if (ch == 10 && lastCh != 13) + str += wxT('\n'); - if ((flags & wxTEXT_ATTR_PARA_SPACING_AFTER) && - (attr1.GetParagraphSpacingAfter() != attr2.GetParagraphSpacingAfter())) - return false; + if (ch > 0 && ch != 10) + str += wxChar(ch); - if ((flags & wxTEXT_ATTR_PARA_SPACING_BEFORE) && - (attr1.GetParagraphSpacingBefore() != attr2.GetParagraphSpacingBefore())) - return false; + lastCh = ch; + } + } - if ((flags & wxTEXT_ATTR_LINE_SPACING) && - (attr1.GetLineSpacing() != attr2.GetLineSpacing())) - return false; + buffer->ResetAndClearCommands(); + buffer->Clear(); + buffer->AddParagraphs(str); + buffer->UpdateRanges(); - if ((flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) && - (attr1.GetCharacterStyleName() != attr2.GetCharacterStyleName())) - return false; + return true; +} - if ((flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) && - (attr1.GetParagraphStyleName() != attr2.GetParagraphStyleName())) +bool wxRichTextPlainTextHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) +{ + if (!stream.IsOk()) return false; - if ((flags & wxTEXT_ATTR_LIST_STYLE_NAME) && - (attr1.GetListStyleName() != attr2.GetListStyleName())) - return false; + wxString text = buffer->GetText(); - if ((flags & wxTEXT_ATTR_BULLET_STYLE) && - (attr1.GetBulletStyle() != attr2.GetBulletStyle())) - return false; + wxString newLine = wxRichTextLineBreakChar; + text.Replace(newLine, wxT("\n")); - if ((flags & wxTEXT_ATTR_BULLET_NUMBER) && - (attr1.GetBulletNumber() != attr2.GetBulletNumber())) - return false; + wxCharBuffer buf = text.ToAscii(); - if ((flags & wxTEXT_ATTR_BULLET_TEXT) && - (attr1.GetBulletText() != attr2.GetBulletText()) && - (attr1.GetBulletFont() != attr2.GetBulletFont())) - return false; + stream.Write((const char*) buf, text.length()); + return true; +} +#endif // wxUSE_STREAMS - if ((flags & wxTEXT_ATTR_BULLET_NAME) && - (attr1.GetBulletName() != attr2.GetBulletName())) - return false; +/* + * Stores information about an image, in binary in-memory form + */ - if ((flags & wxTEXT_ATTR_TABS) && - !wxRichTextTabsEq(attr1.GetTabs(), attr2.GetTabs())) - return false; +wxRichTextImageBlock::wxRichTextImageBlock() +{ + Init(); +} - if ((flags & wxTEXT_ATTR_PAGE_BREAK) && - (attr1.HasPageBreak() != attr2.HasPageBreak())) - return false; +wxRichTextImageBlock::wxRichTextImageBlock(const wxRichTextImageBlock& block):wxObject() +{ + Init(); + Copy(block); +} - if (flags & wxTEXT_ATTR_EFFECTS) +wxRichTextImageBlock::~wxRichTextImageBlock() +{ + if (m_data) { - if (attr1.HasTextEffects() != attr2.HasTextEffects()) - return false; - if (!wxRichTextBitlistsEqPartial(attr1.GetTextEffects(), attr2.GetTextEffects(), attr2.GetTextEffectFlags())) - return false; + delete[] m_data; + m_data = NULL; } - - if ((flags & wxTEXT_ATTR_OUTLINE_LEVEL) && - (attr1.GetOutlineLevel() != attr2.GetOutlineLevel())) - return false; - - return true; } -/// Compare tabs -bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2) -{ - if (tabs1.GetCount() != tabs2.GetCount()) - return false; - - size_t i; - for (i = 0; i < tabs1.GetCount(); i++) - { - if (tabs1[i] != tabs2[i]) - return false; - } - return true; -} - -/// Apply one style to another -bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxTextAttrEx& style) -{ - // Whole font - if (style.GetFont().Ok() && ((style.GetFlags() & (wxTEXT_ATTR_FONT)) == (wxTEXT_ATTR_FONT))) - destStyle.SetFont(style.GetFont()); - else if (style.GetFont().Ok()) - { - wxFont font = destStyle.GetFont(); - - if (style.GetFlags() & wxTEXT_ATTR_FONT_FACE) - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_FACE); - font.SetFaceName(style.GetFont().GetFaceName()); - } - - if (style.GetFlags() & wxTEXT_ATTR_FONT_SIZE) - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_SIZE); - font.SetPointSize(style.GetFont().GetPointSize()); - } - - if (style.GetFlags() & wxTEXT_ATTR_FONT_ITALIC) - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_ITALIC); - font.SetStyle(style.GetFont().GetStyle()); - } - - if (style.GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_WEIGHT); - font.SetWeight(style.GetFont().GetWeight()); - } - - if (style.GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_UNDERLINE); - font.SetUnderlined(style.GetFont().GetUnderlined()); - } - - if (font != destStyle.GetFont()) - { - int oldFlags = destStyle.GetFlags(); - - destStyle.SetFont(font); - - destStyle.SetFlags(oldFlags); - } - } - - if ( style.GetTextColour().Ok() && style.HasTextColour()) - destStyle.SetTextColour(style.GetTextColour()); - - if ( style.GetBackgroundColour().Ok() && style.HasBackgroundColour()) - destStyle.SetBackgroundColour(style.GetBackgroundColour()); - - if (style.HasAlignment()) - destStyle.SetAlignment(style.GetAlignment()); - - if (style.HasTabs()) - destStyle.SetTabs(style.GetTabs()); - - if (style.HasLeftIndent()) - destStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent()); - - if (style.HasRightIndent()) - destStyle.SetRightIndent(style.GetRightIndent()); - - if (style.HasParagraphSpacingAfter()) - destStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter()); - - if (style.HasParagraphSpacingBefore()) - destStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore()); - - if (style.HasLineSpacing()) - destStyle.SetLineSpacing(style.GetLineSpacing()); - - if (style.HasCharacterStyleName()) - destStyle.SetCharacterStyleName(style.GetCharacterStyleName()); - - if (style.HasParagraphStyleName()) - destStyle.SetParagraphStyleName(style.GetParagraphStyleName()); - - if (style.HasListStyleName()) - destStyle.SetListStyleName(style.GetListStyleName()); - - if (style.HasBulletStyle()) - destStyle.SetBulletStyle(style.GetBulletStyle()); - - if (style.HasBulletText()) - { - destStyle.SetBulletText(style.GetBulletText()); - destStyle.SetBulletFont(style.GetBulletFont()); - } - - if (style.HasBulletName()) - destStyle.SetBulletName(style.GetBulletName()); - - if (style.HasBulletNumber()) - destStyle.SetBulletNumber(style.GetBulletNumber()); - - if (style.HasURL()) - destStyle.SetURL(style.GetURL()); - - if (style.HasPageBreak()) - destStyle.SetPageBreak(); - - if (style.HasTextEffects()) - { - int destBits = destStyle.GetTextEffects(); - int destFlags = destStyle.GetTextEffectFlags(); - - int srcBits = style.GetTextEffects(); - int srcFlags = style.GetTextEffectFlags(); - - wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags); - - destStyle.SetTextEffects(destBits); - destStyle.SetTextEffectFlags(destFlags); - } - - if (style.HasOutlineLevel()) - destStyle.SetOutlineLevel(style.GetOutlineLevel()); - - return true; -} - -bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxTextAttrEx& style) -{ - wxTextAttrEx destStyle2 = destStyle; - wxRichTextApplyStyle(destStyle2, style); - destStyle = destStyle2; - return true; -} - -bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith) -{ - destStyle = destStyle.Combine(style, compareWith); - return true; -} - -bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith) -{ - // Whole font. Avoiding setting individual attributes if possible, since - // it recreates the font each time. - if (((style.GetFlags() & (wxTEXT_ATTR_FONT)) == (wxTEXT_ATTR_FONT)) && !compareWith) - { - destStyle.SetFont(wxFont(style.GetFontSize(), destStyle.GetFont().Ok() ? destStyle.GetFont().GetFamily() : wxDEFAULT, - style.GetFontStyle(), style.GetFontWeight(), style.GetFontUnderlined(), style.GetFontFaceName())); - } - else if (style.GetFlags() & (wxTEXT_ATTR_FONT)) - { - wxFont font = destStyle.GetFont(); - - if (style.GetFlags() & wxTEXT_ATTR_FONT_FACE) - { - if (compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName()) - { - // The same as currently displayed, so don't set - } - else - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_FACE); - font.SetFaceName(style.GetFontFaceName()); - } - } - - if (style.GetFlags() & wxTEXT_ATTR_FONT_SIZE) - { - if (compareWith && compareWith->HasFontSize() && compareWith->GetFontSize() == style.GetFontSize()) - { - // The same as currently displayed, so don't set - } - else - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_SIZE); - font.SetPointSize(style.GetFontSize()); - } - } - - if (style.GetFlags() & wxTEXT_ATTR_FONT_ITALIC) - { - if (compareWith && compareWith->HasFontItalic() && compareWith->GetFontStyle() == style.GetFontStyle()) - { - // The same as currently displayed, so don't set - } - else - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_ITALIC); - font.SetStyle(style.GetFontStyle()); - } - } - - if (style.GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) - { - if (compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight()) - { - // The same as currently displayed, so don't set - } - else - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_WEIGHT); - font.SetWeight(style.GetFontWeight()); - } - } - - if (style.GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) - { - if (compareWith && compareWith->HasFontUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined()) - { - // The same as currently displayed, so don't set - } - else - { - destStyle.SetFlags(destStyle.GetFlags() | wxTEXT_ATTR_FONT_UNDERLINE); - font.SetUnderlined(style.GetFontUnderlined()); - } - } - - if (font != destStyle.GetFont()) - { - int oldFlags = destStyle.GetFlags(); - - destStyle.SetFont(font); - - destStyle.SetFlags(oldFlags); - } - } - - if (style.GetTextColour().Ok() && style.HasTextColour()) - { - if (!(compareWith && compareWith->HasTextColour() && compareWith->GetTextColour() == style.GetTextColour())) - destStyle.SetTextColour(style.GetTextColour()); - } - - if (style.GetBackgroundColour().Ok() && style.HasBackgroundColour()) - { - if (!(compareWith && compareWith->HasBackgroundColour() && compareWith->GetBackgroundColour() == style.GetBackgroundColour())) - destStyle.SetBackgroundColour(style.GetBackgroundColour()); - } - - if (style.HasAlignment()) - { - if (!(compareWith && compareWith->HasAlignment() && compareWith->GetAlignment() == style.GetAlignment())) - destStyle.SetAlignment(style.GetAlignment()); - } - - if (style.HasTabs()) - { - if (!(compareWith && compareWith->HasTabs() && wxRichTextTabsEq(compareWith->GetTabs(), style.GetTabs()))) - destStyle.SetTabs(style.GetTabs()); - } - - if (style.HasLeftIndent()) - { - if (!(compareWith && compareWith->HasLeftIndent() && compareWith->GetLeftIndent() == style.GetLeftIndent() - && compareWith->GetLeftSubIndent() == style.GetLeftSubIndent())) - destStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent()); - } - - if (style.HasRightIndent()) - { - if (!(compareWith && compareWith->HasRightIndent() && compareWith->GetRightIndent() == style.GetRightIndent())) - destStyle.SetRightIndent(style.GetRightIndent()); - } - - if (style.HasParagraphSpacingAfter()) - { - if (!(compareWith && compareWith->HasParagraphSpacingAfter() && compareWith->GetParagraphSpacingAfter() == style.GetParagraphSpacingAfter())) - destStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter()); - } - - if (style.HasParagraphSpacingBefore()) - { - if (!(compareWith && compareWith->HasParagraphSpacingBefore() && compareWith->GetParagraphSpacingBefore() == style.GetParagraphSpacingBefore())) - destStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore()); - } - - if (style.HasLineSpacing()) - { - if (!(compareWith && compareWith->HasLineSpacing() && compareWith->GetLineSpacing() == style.GetLineSpacing())) - destStyle.SetLineSpacing(style.GetLineSpacing()); - } - - if (style.HasCharacterStyleName()) - { - if (!(compareWith && compareWith->HasCharacterStyleName() && compareWith->GetCharacterStyleName() == style.GetCharacterStyleName())) - destStyle.SetCharacterStyleName(style.GetCharacterStyleName()); - } - - if (style.HasParagraphStyleName()) - { - if (!(compareWith && compareWith->HasParagraphStyleName() && compareWith->GetParagraphStyleName() == style.GetParagraphStyleName())) - destStyle.SetParagraphStyleName(style.GetParagraphStyleName()); - } - - if (style.HasListStyleName()) - { - if (!(compareWith && compareWith->HasListStyleName() && compareWith->GetListStyleName() == style.GetListStyleName())) - destStyle.SetListStyleName(style.GetListStyleName()); - } - - if (style.HasBulletStyle()) - { - if (!(compareWith && compareWith->HasBulletStyle() && compareWith->GetBulletStyle() == style.GetBulletStyle())) - destStyle.SetBulletStyle(style.GetBulletStyle()); - } - - if (style.HasBulletText()) - { - if (!(compareWith && compareWith->HasBulletText() && compareWith->GetBulletText() == style.GetBulletText())) - { - destStyle.SetBulletText(style.GetBulletText()); - destStyle.SetBulletFont(style.GetBulletFont()); - } - } - - if (style.HasBulletNumber()) - { - if (!(compareWith && compareWith->HasBulletNumber() && compareWith->GetBulletNumber() == style.GetBulletNumber())) - destStyle.SetBulletNumber(style.GetBulletNumber()); - } - - if (style.HasBulletName()) - { - if (!(compareWith && compareWith->HasBulletName() && compareWith->GetBulletName() == style.GetBulletName())) - destStyle.SetBulletName(style.GetBulletName()); - } - - if (style.HasURL()) - { - if (!(compareWith && compareWith->HasURL() && compareWith->GetURL() == style.GetURL())) - destStyle.SetURL(style.GetURL()); - } - - if (style.HasPageBreak()) - { - if (!(compareWith && compareWith->HasPageBreak())) - destStyle.SetPageBreak(); - } - - if (style.HasTextEffects()) - { - if (!(compareWith && compareWith->HasTextEffects() && compareWith->GetTextEffects() == style.GetTextEffects())) - { - int destBits = destStyle.GetTextEffects(); - int destFlags = destStyle.GetTextEffectFlags(); - - int srcBits = style.GetTextEffects(); - int srcFlags = style.GetTextEffectFlags(); - - wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags); - - destStyle.SetTextEffects(destBits); - destStyle.SetTextEffectFlags(destFlags); - } - } - - if (style.HasOutlineLevel()) - { - if (!(compareWith && compareWith->HasOutlineLevel() && compareWith->GetOutlineLevel() == style.GetOutlineLevel())) - destStyle.SetOutlineLevel(style.GetOutlineLevel()); - } - - return true; -} - -// Remove attributes -bool wxRichTextRemoveStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style) -{ - int flags = style.GetFlags(); - int destFlags = destStyle.GetFlags(); - - destStyle.SetFlags(destFlags & ~flags); - - return true; -} - -/// Combine two bitlists, specifying the bits of interest with separate flags. -bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB) -{ - // We want to apply B's bits to A, taking into account each's flags which indicate which bits - // are to be taken into account. A zero in B's bits should reset that bit in A but only if B's flags - // indicate it. - - // First, reset the 0 bits from B. We make a mask so we're only dealing with B's zero - // bits at this point, ignoring any 1 bits in B or 0 bits in B that are not relevant. - int valueA2 = ~(~valueB & flagsB) & valueA; - - // Now combine the 1 bits. - int valueA3 = (valueB & flagsB) | valueA2; - - valueA = valueA3; - flagsA = (flagsA | flagsB); - - return true; -} - -/// Compare two bitlists -bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags) -{ - int relevantBitsA = valueA & flags; - int relevantBitsB = valueB & flags; - return (relevantBitsA != relevantBitsB); -} - -/// Split into paragraph and character styles -bool wxRichTextSplitParaCharStyles(const wxTextAttrEx& style, wxTextAttrEx& parStyle, wxTextAttrEx& charStyle) -{ - wxTextAttrEx defaultCharStyle1(style); - wxTextAttrEx defaultParaStyle1(style); - defaultCharStyle1.SetFlags(defaultCharStyle1.GetFlags()&wxTEXT_ATTR_CHARACTER); - defaultParaStyle1.SetFlags(defaultParaStyle1.GetFlags()&wxTEXT_ATTR_PARAGRAPH); - - wxRichTextApplyStyle(charStyle, defaultCharStyle1); - wxRichTextApplyStyle(parStyle, defaultParaStyle1); - - return true; -} - -void wxSetFontPreservingStyles(wxTextAttr& attr, const wxFont& font) -{ - long flags = attr.GetFlags(); - attr.SetFont(font); - attr.SetFlags(flags); -} - -/// Convert a decimal to Roman numerals -wxString wxRichTextDecimalToRoman(long n) -{ - static wxArrayInt decimalNumbers; - static wxArrayString romanNumbers; - - // Clean up arrays - if (n == -1) - { - decimalNumbers.Clear(); - romanNumbers.Clear(); - return wxEmptyString; - } - - if (decimalNumbers.GetCount() == 0) - { - #define wxRichTextAddDecRom(n, r) decimalNumbers.Add(n); romanNumbers.Add(r); - - wxRichTextAddDecRom(1000, wxT("M")); - wxRichTextAddDecRom(900, wxT("CM")); - wxRichTextAddDecRom(500, wxT("D")); - wxRichTextAddDecRom(400, wxT("CD")); - wxRichTextAddDecRom(100, wxT("C")); - wxRichTextAddDecRom(90, wxT("XC")); - wxRichTextAddDecRom(50, wxT("L")); - wxRichTextAddDecRom(40, wxT("XL")); - wxRichTextAddDecRom(10, wxT("X")); - wxRichTextAddDecRom(9, wxT("IX")); - wxRichTextAddDecRom(5, wxT("V")); - wxRichTextAddDecRom(4, wxT("IV")); - wxRichTextAddDecRom(1, wxT("I")); - } - - int i = 0; - wxString roman; - - while (n > 0 && i < 13) - { - if (n >= decimalNumbers[i]) - { - n -= decimalNumbers[i]; - roman += romanNumbers[i]; - } - else - { - i ++; - } - } - if (roman.IsEmpty()) - roman = wxT("0"); - return roman; -} - -/*! - * wxRichTextAttr stores attributes without a wxFont object, so is a much more - * efficient way to query styles. - */ - -// ctors -wxRichTextAttr::wxRichTextAttr(const wxColour& colText, - const wxColour& colBack, - wxTextAttrAlignment alignment): m_textAlignment(alignment), m_colText(colText), m_colBack(colBack) -{ - Init(); - - if (m_colText.Ok()) m_flags |= wxTEXT_ATTR_TEXT_COLOUR; - if (m_colBack.Ok()) m_flags |= wxTEXT_ATTR_BACKGROUND_COLOUR; - if (alignment != wxTEXT_ALIGNMENT_DEFAULT) - m_flags |= wxTEXT_ATTR_ALIGNMENT; -} - -wxRichTextAttr::wxRichTextAttr(const wxTextAttrEx& attr) -{ - Init(); - - (*this) = attr; -} - -wxRichTextAttr::wxRichTextAttr(const wxRichTextAttr& attr) -{ - Copy(attr); -} - -// operations -void wxRichTextAttr::Init() -{ - m_textAlignment = wxTEXT_ALIGNMENT_DEFAULT; - m_flags = 0; - m_leftIndent = 0; - m_leftSubIndent = 0; - m_rightIndent = 0; - - m_fontSize = 12; - m_fontStyle = wxNORMAL; - m_fontWeight = wxNORMAL; - m_fontUnderlined = false; - - m_paragraphSpacingAfter = 0; - m_paragraphSpacingBefore = 0; - m_lineSpacing = 0; - m_bulletStyle = wxTEXT_ATTR_BULLET_STYLE_NONE; - m_textEffects = wxTEXT_ATTR_EFFECT_NONE; - m_textEffectFlags = wxTEXT_ATTR_EFFECT_NONE; - m_outlineLevel = 0; - m_bulletNumber = 0; -} - -// Copy -void wxRichTextAttr::Copy(const wxRichTextAttr& attr) -{ - m_colText = attr.m_colText; - m_colBack = attr.m_colBack; - m_textAlignment = attr.m_textAlignment; - m_leftIndent = attr.m_leftIndent; - m_leftSubIndent = attr.m_leftSubIndent; - m_rightIndent = attr.m_rightIndent; - m_tabs = attr.m_tabs; - m_flags = attr.m_flags; - - m_fontSize = attr.m_fontSize; - m_fontStyle = attr.m_fontStyle; - m_fontWeight = attr.m_fontWeight; - m_fontUnderlined = attr.m_fontUnderlined; - m_fontFaceName = attr.m_fontFaceName; - m_textEffects = attr.m_textEffects; - m_textEffectFlags = attr.m_textEffectFlags; - - m_paragraphSpacingAfter = attr.m_paragraphSpacingAfter; - m_paragraphSpacingBefore = attr.m_paragraphSpacingBefore; - m_lineSpacing = attr.m_lineSpacing; - m_characterStyleName = attr.m_characterStyleName; - m_paragraphStyleName = attr.m_paragraphStyleName; - m_listStyleName = attr.m_listStyleName; - m_bulletStyle = attr.m_bulletStyle; - m_bulletNumber = attr.m_bulletNumber; - m_bulletText = attr.m_bulletText; - m_bulletFont = attr.m_bulletFont; - m_bulletName = attr.m_bulletName; - m_outlineLevel = attr.m_outlineLevel; - - m_urlTarget = attr.m_urlTarget; -} - -// operators -void wxRichTextAttr::operator= (const wxRichTextAttr& attr) -{ - Copy(attr); -} - -// operators -void wxRichTextAttr::operator= (const wxTextAttrEx& attr) -{ - m_flags = attr.GetFlags(); - - m_colText = attr.GetTextColour(); - m_colBack = attr.GetBackgroundColour(); - m_textAlignment = attr.GetAlignment(); - m_leftIndent = attr.GetLeftIndent(); - m_leftSubIndent = attr.GetLeftSubIndent(); - m_rightIndent = attr.GetRightIndent(); - m_tabs = attr.GetTabs(); - m_textEffects = attr.GetTextEffects(); - m_textEffectFlags = attr.GetTextEffectFlags(); - - m_paragraphSpacingAfter = attr.GetParagraphSpacingAfter(); - m_paragraphSpacingBefore = attr.GetParagraphSpacingBefore(); - m_lineSpacing = attr.GetLineSpacing(); - m_characterStyleName = attr.GetCharacterStyleName(); - m_paragraphStyleName = attr.GetParagraphStyleName(); - m_listStyleName = attr.GetListStyleName(); - m_bulletStyle = attr.GetBulletStyle(); - m_bulletNumber = attr.GetBulletNumber(); - m_bulletText = attr.GetBulletText(); - m_bulletName = attr.GetBulletName(); - m_bulletFont = attr.GetBulletFont(); - m_outlineLevel = attr.GetOutlineLevel(); - - m_urlTarget = attr.GetURL(); - - if (attr.GetFont().Ok()) - GetFontAttributes(attr.GetFont()); -} - -// Making a wxTextAttrEx object. -wxRichTextAttr::operator wxTextAttrEx () const -{ - wxTextAttrEx attr; - attr.SetTextColour(GetTextColour()); - attr.SetBackgroundColour(GetBackgroundColour()); - attr.SetAlignment(GetAlignment()); - attr.SetTabs(GetTabs()); - attr.SetLeftIndent(GetLeftIndent(), GetLeftSubIndent()); - attr.SetRightIndent(GetRightIndent()); - attr.SetFont(CreateFont()); - - attr.SetParagraphSpacingAfter(m_paragraphSpacingAfter); - attr.SetParagraphSpacingBefore(m_paragraphSpacingBefore); - attr.SetLineSpacing(m_lineSpacing); - attr.SetBulletStyle(m_bulletStyle); - attr.SetBulletNumber(m_bulletNumber); - attr.SetBulletText(m_bulletText); - attr.SetBulletName(m_bulletName); - attr.SetBulletFont(m_bulletFont); - attr.SetCharacterStyleName(m_characterStyleName); - attr.SetParagraphStyleName(m_paragraphStyleName); - attr.SetListStyleName(m_listStyleName); - attr.SetTextEffects(m_textEffects); - attr.SetTextEffectFlags(m_textEffectFlags); - attr.SetOutlineLevel(m_outlineLevel); - - attr.SetURL(m_urlTarget); - - attr.SetFlags(GetFlags()); // Important: set after SetFont and others, since they set flags - return attr; -} - -// Equality test -bool wxRichTextAttr::operator== (const wxRichTextAttr& attr) const -{ - return GetFlags() == attr.GetFlags() && - - GetTextColour() == attr.GetTextColour() && - GetBackgroundColour() == attr.GetBackgroundColour() && - - GetAlignment() == attr.GetAlignment() && - GetLeftIndent() == attr.GetLeftIndent() && - GetLeftSubIndent() == attr.GetLeftSubIndent() && - GetRightIndent() == attr.GetRightIndent() && - wxRichTextTabsEq(GetTabs(), attr.GetTabs()) && - - GetParagraphSpacingAfter() == attr.GetParagraphSpacingAfter() && - GetParagraphSpacingBefore() == attr.GetParagraphSpacingBefore() && - GetLineSpacing() == attr.GetLineSpacing() && - GetCharacterStyleName() == attr.GetCharacterStyleName() && - GetParagraphStyleName() == attr.GetParagraphStyleName() && - GetListStyleName() == attr.GetListStyleName() && - - GetBulletStyle() == attr.GetBulletStyle() && - GetBulletText() == attr.GetBulletText() && - GetBulletNumber() == attr.GetBulletNumber() && - GetBulletFont() == attr.GetBulletFont() && - GetBulletName() == attr.GetBulletName() && - - GetTextEffects() == attr.GetTextEffects() && - GetTextEffectFlags() == attr.GetTextEffectFlags() && - - GetOutlineLevel() == attr.GetOutlineLevel() && - - GetFontSize() == attr.GetFontSize() && - GetFontStyle() == attr.GetFontStyle() && - GetFontWeight() == attr.GetFontWeight() && - GetFontUnderlined() == attr.GetFontUnderlined() && - GetFontFaceName() == attr.GetFontFaceName() && - - GetURL() == attr.GetURL(); -} - -// Create font from font attributes. -wxFont wxRichTextAttr::CreateFont() const -{ - wxFont font(m_fontSize, wxDEFAULT, m_fontStyle, m_fontWeight, m_fontUnderlined, m_fontFaceName); -#ifdef __WXMAC__ - font.SetNoAntiAliasing(true); -#endif - return font; -} - -// Get attributes from font. -bool wxRichTextAttr::GetFontAttributes(const wxFont& font) -{ - if (!font.Ok()) - return false; - - m_fontSize = font.GetPointSize(); - m_fontStyle = font.GetStyle(); - m_fontWeight = font.GetWeight(); - m_fontUnderlined = font.GetUnderlined(); - m_fontFaceName = font.GetFaceName(); - - return true; -} - -wxRichTextAttr wxRichTextAttr::Combine(const wxRichTextAttr& style, const wxRichTextAttr* compareWith) const -{ - wxRichTextAttr destStyle = (*this); - destStyle.Apply(style, compareWith); - - return destStyle; -} - -bool wxRichTextAttr::Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith) -{ - wxRichTextAttr& destStyle = (*this); - - if (style.HasFontWeight()) - { - if (!(compareWith && compareWith->HasFontWeight() && compareWith->GetFontWeight() == style.GetFontWeight())) - destStyle.SetFontWeight(style.GetFontWeight()); - } - - if (style.HasFontSize()) - { - if (!(compareWith && compareWith->HasFontSize() && compareWith->GetFontSize() == style.GetFontSize())) - destStyle.SetFontSize(style.GetFontSize()); - } - - if (style.HasFontItalic()) - { - if (!(compareWith && compareWith->HasFontItalic() && compareWith->GetFontStyle() == style.GetFontStyle())) - destStyle.SetFontStyle(style.GetFontStyle()); - } - - if (style.HasFontUnderlined()) - { - if (!(compareWith && compareWith->HasFontUnderlined() && compareWith->GetFontUnderlined() == style.GetFontUnderlined())) - destStyle.SetFontUnderlined(style.GetFontUnderlined()); - } - - if (style.HasFontFaceName()) - { - if (!(compareWith && compareWith->HasFontFaceName() && compareWith->GetFontFaceName() == style.GetFontFaceName())) - destStyle.SetFontFaceName(style.GetFontFaceName()); - } - - if (style.GetTextColour().Ok() && style.HasTextColour()) - { - if (!(compareWith && compareWith->HasTextColour() && compareWith->GetTextColour() == style.GetTextColour())) - destStyle.SetTextColour(style.GetTextColour()); - } - - if (style.GetBackgroundColour().Ok() && style.HasBackgroundColour()) - { - if (!(compareWith && compareWith->HasBackgroundColour() && compareWith->GetBackgroundColour() == style.GetBackgroundColour())) - destStyle.SetBackgroundColour(style.GetBackgroundColour()); - } - - if (style.HasAlignment()) - { - if (!(compareWith && compareWith->HasAlignment() && compareWith->GetAlignment() == style.GetAlignment())) - destStyle.SetAlignment(style.GetAlignment()); - } - - if (style.HasTabs()) - { - if (!(compareWith && compareWith->HasTabs() && wxRichTextTabsEq(compareWith->GetTabs(), style.GetTabs()))) - destStyle.SetTabs(style.GetTabs()); - } - - if (style.HasLeftIndent()) - { - if (!(compareWith && compareWith->HasLeftIndent() && compareWith->GetLeftIndent() == style.GetLeftIndent() - && compareWith->GetLeftSubIndent() == style.GetLeftSubIndent())) - destStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent()); - } - - if (style.HasRightIndent()) - { - if (!(compareWith && compareWith->HasRightIndent() && compareWith->GetRightIndent() == style.GetRightIndent())) - destStyle.SetRightIndent(style.GetRightIndent()); - } - - if (style.HasParagraphSpacingAfter()) - { - if (!(compareWith && compareWith->HasParagraphSpacingAfter() && compareWith->GetParagraphSpacingAfter() == style.GetParagraphSpacingAfter())) - destStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter()); - } - - if (style.HasParagraphSpacingBefore()) - { - if (!(compareWith && compareWith->HasParagraphSpacingBefore() && compareWith->GetParagraphSpacingBefore() == style.GetParagraphSpacingBefore())) - destStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore()); - } - - if (style.HasLineSpacing()) - { - if (!(compareWith && compareWith->HasLineSpacing() && compareWith->GetLineSpacing() == style.GetLineSpacing())) - destStyle.SetLineSpacing(style.GetLineSpacing()); - } - - if (style.HasCharacterStyleName()) - { - if (!(compareWith && compareWith->HasCharacterStyleName() && compareWith->GetCharacterStyleName() == style.GetCharacterStyleName())) - destStyle.SetCharacterStyleName(style.GetCharacterStyleName()); - } - - if (style.HasParagraphStyleName()) - { - if (!(compareWith && compareWith->HasParagraphStyleName() && compareWith->GetParagraphStyleName() == style.GetParagraphStyleName())) - destStyle.SetParagraphStyleName(style.GetParagraphStyleName()); - } - - if (style.HasListStyleName()) - { - if (!(compareWith && compareWith->HasListStyleName() && compareWith->GetListStyleName() == style.GetListStyleName())) - destStyle.SetListStyleName(style.GetListStyleName()); - } - - if (style.HasBulletStyle()) - { - if (!(compareWith && compareWith->HasBulletStyle() && compareWith->GetBulletStyle() == style.GetBulletStyle())) - destStyle.SetBulletStyle(style.GetBulletStyle()); - } - - if (style.HasBulletText()) - { - if (!(compareWith && compareWith->HasBulletText() && compareWith->GetBulletText() == style.GetBulletText())) - { - destStyle.SetBulletText(style.GetBulletText()); - destStyle.SetBulletFont(style.GetBulletFont()); - } - } - - if (style.HasBulletNumber()) - { - if (!(compareWith && compareWith->HasBulletNumber() && compareWith->GetBulletNumber() == style.GetBulletNumber())) - destStyle.SetBulletNumber(style.GetBulletNumber()); - } - - if (style.HasBulletName()) - { - if (!(compareWith && compareWith->HasBulletName() && compareWith->GetBulletName() == style.GetBulletName())) - destStyle.SetBulletName(style.GetBulletName()); - } - - if (style.HasURL()) - { - if (!(compareWith && compareWith->HasURL() && compareWith->GetURL() == style.GetURL())) - destStyle.SetURL(style.GetURL()); - } - - if (style.HasPageBreak()) - { - if (!(compareWith && compareWith->HasPageBreak())) - destStyle.SetPageBreak(); - } - - if (style.HasTextEffects()) - { - if (!(compareWith && compareWith->HasTextEffects() && compareWith->GetTextEffects() == style.GetTextEffects())) - { - int destBits = destStyle.GetTextEffects(); - int destFlags = destStyle.GetTextEffectFlags(); - - int srcBits = style.GetTextEffects(); - int srcFlags = style.GetTextEffectFlags(); - - wxRichTextCombineBitlists(destBits, srcBits, destFlags, srcFlags); - - destStyle.SetTextEffects(destBits); - destStyle.SetTextEffectFlags(destFlags); - } - } - - if (style.HasOutlineLevel()) - { - if (!(compareWith && compareWith->HasOutlineLevel() && compareWith->GetOutlineLevel() == style.GetOutlineLevel())) - destStyle.SetOutlineLevel(style.GetOutlineLevel()); - } - - return true; -} - -/*! - * wxTextAttrEx is an extended version of wxTextAttr with more paragraph attributes. - */ - -wxTextAttrEx::wxTextAttrEx(const wxTextAttrEx& attr): wxTextAttr() -{ - Copy(attr); -} - -// Initialise this object. -void wxTextAttrEx::Init() -{ - m_paragraphSpacingAfter = 0; - m_paragraphSpacingBefore = 0; - m_lineSpacing = 0; - m_bulletStyle = wxTEXT_ATTR_BULLET_STYLE_NONE; - m_textEffects = wxTEXT_ATTR_EFFECT_NONE; - m_textEffectFlags = wxTEXT_ATTR_EFFECT_NONE; - m_bulletNumber = 0; - m_outlineLevel = 0; -} - -// Copy -void wxTextAttrEx::Copy(const wxTextAttrEx& attr) -{ - wxTextAttr::operator= (attr); - - m_paragraphSpacingAfter = attr.m_paragraphSpacingAfter; - m_paragraphSpacingBefore = attr.m_paragraphSpacingBefore; - m_lineSpacing = attr.m_lineSpacing; - m_characterStyleName = attr.m_characterStyleName; - m_paragraphStyleName = attr.m_paragraphStyleName; - m_listStyleName = attr.m_listStyleName; - m_bulletStyle = attr.m_bulletStyle; - m_bulletNumber = attr.m_bulletNumber; - m_bulletText = attr.m_bulletText; - m_bulletFont = attr.m_bulletFont; - m_bulletName = attr.m_bulletName; - m_urlTarget = attr.m_urlTarget; - m_textEffects = attr.m_textEffects; - m_textEffectFlags = attr.m_textEffectFlags; - m_outlineLevel = attr.m_outlineLevel; -} - -// Assignment from a wxTextAttrEx object -void wxTextAttrEx::operator= (const wxTextAttrEx& attr) -{ - Copy(attr); -} - -// Assignment from a wxTextAttr object. -void wxTextAttrEx::operator= (const wxTextAttr& attr) -{ - wxTextAttr::operator= (attr); -} - -// Equality test -bool wxTextAttrEx::operator== (const wxTextAttrEx& attr) const -{ - return ( - GetFlags() == attr.GetFlags() && - GetTextColour() == attr.GetTextColour() && - GetBackgroundColour() == attr.GetBackgroundColour() && - GetFont() == attr.GetFont() && - GetTextEffects() == attr.GetTextEffects() && - GetTextEffectFlags() == attr.GetTextEffectFlags() && - GetAlignment() == attr.GetAlignment() && - GetLeftIndent() == attr.GetLeftIndent() && - GetRightIndent() == attr.GetRightIndent() && - GetLeftSubIndent() == attr.GetLeftSubIndent() && - wxRichTextTabsEq(GetTabs(), attr.GetTabs()) && - GetLineSpacing() == attr.GetLineSpacing() && - GetParagraphSpacingAfter() == attr.GetParagraphSpacingAfter() && - GetParagraphSpacingBefore() == attr.GetParagraphSpacingBefore() && - GetBulletStyle() == attr.GetBulletStyle() && - GetBulletNumber() == attr.GetBulletNumber() && - GetBulletText() == attr.GetBulletText() && - GetBulletName() == attr.GetBulletName() && - GetBulletFont() == attr.GetBulletFont() && - GetCharacterStyleName() == attr.GetCharacterStyleName() && - GetParagraphStyleName() == attr.GetParagraphStyleName() && - GetListStyleName() == attr.GetListStyleName() && - GetOutlineLevel() == attr.GetOutlineLevel() && - GetURL() == attr.GetURL()); -} - -wxTextAttrEx wxTextAttrEx::CombineEx(const wxTextAttrEx& attr, - const wxTextAttrEx& attrDef, - const wxTextCtrlBase *text) -{ - wxTextAttrEx newAttr; - - // If attr specifies the complete font, just use that font, overriding all - // default font attributes. - if ((attr.GetFlags() & wxTEXT_ATTR_FONT) == wxTEXT_ATTR_FONT) - newAttr.SetFont(attr.GetFont()); - else - { - // First find the basic, default font - long flags = 0; - - wxFont font; - if (attrDef.HasFont()) - { - flags = (attrDef.GetFlags() & wxTEXT_ATTR_FONT); - font = attrDef.GetFont(); - } - else - { - if (text) - font = text->GetFont(); - - // We leave flags at 0 because no font attributes have been specified yet - } - if (!font.Ok()) - font = *wxNORMAL_FONT; - - // Otherwise, if there are font attributes in attr, apply them - if (attr.GetFlags() & wxTEXT_ATTR_FONT) - { - if (attr.HasFontSize()) - { - flags |= wxTEXT_ATTR_FONT_SIZE; - font.SetPointSize(attr.GetFont().GetPointSize()); - } - if (attr.HasFontItalic()) - { - flags |= wxTEXT_ATTR_FONT_ITALIC;; - font.SetStyle(attr.GetFont().GetStyle()); - } - if (attr.HasFontWeight()) - { - flags |= wxTEXT_ATTR_FONT_WEIGHT; - font.SetWeight(attr.GetFont().GetWeight()); - } - if (attr.HasFontFaceName()) - { - flags |= wxTEXT_ATTR_FONT_FACE; - font.SetFaceName(attr.GetFont().GetFaceName()); - } - if (attr.HasFontUnderlined()) - { - flags |= wxTEXT_ATTR_FONT_UNDERLINE; - font.SetUnderlined(attr.GetFont().GetUnderlined()); - } - newAttr.SetFont(font); - newAttr.SetFlags(newAttr.GetFlags()|flags); - } - } - - // TODO: should really check we are specifying these in the flags, - // before setting them, as per above; or we will set them willy-nilly. - // However, we should also check whether this is the intention - // as per wxTextAttr::Combine, i.e. always to have valid colours - // in the style. - wxColour colFg = attr.GetTextColour(); - if ( !colFg.Ok() ) - { - colFg = attrDef.GetTextColour(); - - if ( text && !colFg.Ok() ) - colFg = text->GetForegroundColour(); - } - - wxColour colBg = attr.GetBackgroundColour(); - if ( !colBg.Ok() ) - { - colBg = attrDef.GetBackgroundColour(); - - if ( text && !colBg.Ok() ) - colBg = text->GetBackgroundColour(); - } - - newAttr.SetTextColour(colFg); - newAttr.SetBackgroundColour(colBg); - - if (attr.HasAlignment()) - newAttr.SetAlignment(attr.GetAlignment()); - else if (attrDef.HasAlignment()) - newAttr.SetAlignment(attrDef.GetAlignment()); - - if (attr.HasTabs()) - newAttr.SetTabs(attr.GetTabs()); - else if (attrDef.HasTabs()) - newAttr.SetTabs(attrDef.GetTabs()); - - if (attr.HasLeftIndent()) - newAttr.SetLeftIndent(attr.GetLeftIndent(), attr.GetLeftSubIndent()); - else if (attrDef.HasLeftIndent()) - newAttr.SetLeftIndent(attrDef.GetLeftIndent(), attr.GetLeftSubIndent()); - - if (attr.HasRightIndent()) - newAttr.SetRightIndent(attr.GetRightIndent()); - else if (attrDef.HasRightIndent()) - newAttr.SetRightIndent(attrDef.GetRightIndent()); - - // NEW ATTRIBUTES - - if (attr.HasParagraphSpacingAfter()) - newAttr.SetParagraphSpacingAfter(attr.GetParagraphSpacingAfter()); - - if (attr.HasParagraphSpacingBefore()) - newAttr.SetParagraphSpacingBefore(attr.GetParagraphSpacingBefore()); - - if (attr.HasLineSpacing()) - newAttr.SetLineSpacing(attr.GetLineSpacing()); - - if (attr.HasCharacterStyleName()) - newAttr.SetCharacterStyleName(attr.GetCharacterStyleName()); - - if (attr.HasParagraphStyleName()) - newAttr.SetParagraphStyleName(attr.GetParagraphStyleName()); - - if (attr.HasListStyleName()) - newAttr.SetListStyleName(attr.GetListStyleName()); - - if (attr.HasBulletStyle()) - newAttr.SetBulletStyle(attr.GetBulletStyle()); - - if (attr.HasBulletNumber()) - newAttr.SetBulletNumber(attr.GetBulletNumber()); - - if (attr.HasBulletName()) - newAttr.SetBulletName(attr.GetBulletName()); - - if (attr.HasBulletText()) - { - newAttr.SetBulletText(attr.GetBulletText()); - newAttr.SetBulletFont(attr.GetBulletFont()); - } - - if (attr.HasURL()) - newAttr.SetURL(attr.GetURL()); - - if (attr.HasTextEffects()) - { - newAttr.SetTextEffects(attr.GetTextEffects()); - newAttr.SetTextEffectFlags(attr.GetTextEffectFlags()); - } - - if (attr.HasOutlineLevel()) - newAttr.SetOutlineLevel(attr.GetOutlineLevel()); - - return newAttr; -} - - -/*! - * wxRichTextFileHandler - * Base class for file handlers - */ - -IMPLEMENT_CLASS(wxRichTextFileHandler, wxObject) - -#if wxUSE_FFILE && wxUSE_STREAMS -bool wxRichTextFileHandler::LoadFile(wxRichTextBuffer *buffer, const wxString& filename) -{ - wxFFileInputStream stream(filename); - if (stream.Ok()) - return LoadFile(buffer, stream); - - return false; -} - -bool wxRichTextFileHandler::SaveFile(wxRichTextBuffer *buffer, const wxString& filename) -{ - wxFFileOutputStream stream(filename); - if (stream.Ok()) - return SaveFile(buffer, stream); - - return false; -} -#endif // wxUSE_FFILE && wxUSE_STREAMS - -/// Can we handle this filename (if using files)? By default, checks the extension. -bool wxRichTextFileHandler::CanHandle(const wxString& filename) const -{ - wxString path, file, ext; - wxSplitPath(filename, & path, & file, & ext); - - return (ext.Lower() == GetExtension()); -} - -/*! - * wxRichTextTextHandler - * Plain text handler - */ - -IMPLEMENT_CLASS(wxRichTextPlainTextHandler, wxRichTextFileHandler) - -#if wxUSE_STREAMS -bool wxRichTextPlainTextHandler::DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) -{ - if (!stream.IsOk()) - return false; - - wxString str; - int lastCh = 0; - - while (!stream.Eof()) - { - int ch = stream.GetC(); - - if (!stream.Eof()) - { - if (ch == 10 && lastCh != 13) - str += wxT('\n'); - - if (ch > 0 && ch != 10) - str += wxChar(ch); - - lastCh = ch; - } - } - - buffer->ResetAndClearCommands(); - buffer->Clear(); - buffer->AddParagraphs(str); - buffer->UpdateRanges(); - - return true; -} - -bool wxRichTextPlainTextHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) -{ - if (!stream.IsOk()) - return false; - - wxString text = buffer->GetText(); - - wxString newLine = wxRichTextLineBreakChar; - text.Replace(newLine, wxT("\n")); - - wxCharBuffer buf = text.ToAscii(); - - stream.Write((const char*) buf, text.length()); - return true; -} -#endif // wxUSE_STREAMS - -/* - * Stores information about an image, in binary in-memory form - */ - -wxRichTextImageBlock::wxRichTextImageBlock() -{ - Init(); -} - -wxRichTextImageBlock::wxRichTextImageBlock(const wxRichTextImageBlock& block):wxObject() -{ - Init(); - Copy(block); -} - -wxRichTextImageBlock::~wxRichTextImageBlock() -{ - if (m_data) - { - delete[] m_data; - m_data = NULL; - } -} - -void wxRichTextImageBlock::Init() +void wxRichTextImageBlock::Init() { m_data = NULL; m_dataSize = 0; @@ -8402,5 +7029,85 @@ bool wxRichTextBufferDataObject::SetData(size_t WXUNUSED(len), const void *buf) #endif // wxUSE_DATAOBJ + +/* + * wxRichTextFontTable + * Manages quick access to a pool of fonts for rendering rich text + */ + +WX_DECLARE_EXPORTED_STRING_HASH_MAP(wxFont, wxRichTextFontTableHashMap); + +class wxRichTextFontTableData: public wxObjectRefData +{ +public: + wxRichTextFontTableData() {} + + wxFont FindFont(const wxTextAttr& fontSpec); + + wxRichTextFontTableHashMap m_hashMap; +}; + +wxFont wxRichTextFontTableData::FindFont(const wxTextAttr& fontSpec) +{ + wxString facename(fontSpec.GetFontFaceName()); + wxString spec(wxString::Format(wxT("%d-%d-%d-%d-%s-%d"), fontSpec.GetFontSize(), fontSpec.GetFontStyle(), fontSpec.GetFontWeight(), (int) fontSpec.GetFontUnderlined(), facename.c_str(), (int) fontSpec.GetFontEncoding())); + wxRichTextFontTableHashMap::iterator entry = m_hashMap.find(spec); + + if ( entry == m_hashMap.end() ) + { + wxFont font(fontSpec.GetFontSize(), wxDEFAULT, fontSpec.GetFontStyle(), fontSpec.GetFontWeight(), fontSpec.GetFontUnderlined(), facename.c_str()); + m_hashMap[spec] = font; + return font; + } + else + { + return entry->second; + } +} + +IMPLEMENT_DYNAMIC_CLASS(wxRichTextFontTable, wxObject) + +wxRichTextFontTable::wxRichTextFontTable() +{ + m_refData = new wxRichTextFontTableData; + m_refData->IncRef(); +} + +wxRichTextFontTable::wxRichTextFontTable(const wxRichTextFontTable& table) +{ + (*this) = table; +} + +wxRichTextFontTable::~wxRichTextFontTable() +{ + UnRef(); +} + +bool wxRichTextFontTable::operator == (const wxRichTextFontTable& table) const +{ + return (m_refData == table.m_refData); +} + +void wxRichTextFontTable::operator= (const wxRichTextFontTable& table) +{ + Ref(table); +} + +wxFont wxRichTextFontTable::FindFont(const wxTextAttr& fontSpec) +{ + wxRichTextFontTableData* data = (wxRichTextFontTableData*) m_refData; + if (data) + return data->FindFont(fontSpec); + else + return wxFont(); +} + +void wxRichTextFontTable::Clear() +{ + wxRichTextFontTableData* data = (wxRichTextFontTableData*) m_refData; + if (data) + data->m_hashMap.clear(); +} + #endif // wxUSE_RICHTEXT diff --git a/src/richtext/richtextbulletspage.cpp b/src/richtext/richtextbulletspage.cpp index a74225c..8a7a066 100644 --- a/src/richtext/richtextbulletspage.cpp +++ b/src/richtext/richtextbulletspage.cpp @@ -311,7 +311,7 @@ bool wxRichTextBulletsPage::TransferDataFromWindow() { wxPanel::TransferDataFromWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (m_hasBulletStyle) { @@ -384,7 +384,7 @@ bool wxRichTextBulletsPage::TransferDataToWindow() wxPanel::TransferDataToWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (attr->HasBulletStyle()) { @@ -487,7 +487,7 @@ et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id m iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); TransferDataFromWindow(); - wxTextAttrEx attr(*GetAttributes()); + wxTextAttr attr(*GetAttributes()); attr.SetFlags(attr.GetFlags() & (wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME| wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER| @@ -497,7 +497,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); font.SetPointSize(9); m_previewCtrl->SetFont(font); - wxTextAttrEx normalParaAttr; + wxTextAttr normalParaAttr; normalParaAttr.SetFont(font); normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY"))); @@ -521,7 +521,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); m_previewCtrl->Thaw(); } -wxTextAttrEx* wxRichTextBulletsPage::GetAttributes() +wxTextAttr* wxRichTextBulletsPage::GetAttributes() { return wxRichTextFormattingDialog::GetDialogAttributes(this); } diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index c2df7e6..f324707 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -149,7 +149,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va SetEditable(false); // The base attributes must all have default values - wxTextAttrEx attributes; + wxTextAttr attributes; attributes.SetFont(GetFont()); attributes.SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); attributes.SetAlignment(wxTEXT_ALIGNMENT_LEFT); @@ -163,7 +163,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va // The default attributes will be merged with base attributes, so // can be empty to begin with - wxTextAttrEx defaultAttributes; + wxTextAttr defaultAttributes; SetDefaultStyle(defaultAttributes); SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW)); @@ -402,7 +402,7 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event) if (!GetEventHandler()->ProcessEvent(cmdEvent)) { - wxTextAttrEx attr; + wxTextAttr attr; if (GetStyle(position, attr)) { if (attr.HasFlag(wxTEXT_ATTR_URL)) @@ -450,7 +450,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) { if (hit != wxRICHTEXT_HITTEST_NONE && !(hit & wxRICHTEXT_HITTEST_OUTSIDE)) { - wxTextAttrEx attr; + wxTextAttr attr; if (GetStyle(position, attr)) { if (attr.HasFlag(wxTEXT_ATTR_URL)) @@ -2554,17 +2554,12 @@ void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event) return; } -bool wxRichTextCtrl::SetStyle(long start, long end, const wxTextAttrEx& style) -{ - return GetBuffer().SetStyle(wxRichTextRange(start, end-1), style); -} - bool wxRichTextCtrl::SetStyle(long start, long end, const wxTextAttr& style) { - return GetBuffer().SetStyle(wxRichTextRange(start, end-1), wxTextAttrEx(style)); + return GetBuffer().SetStyle(wxRichTextRange(start, end-1), wxTextAttr(style)); } -bool wxRichTextCtrl::SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style) +bool wxRichTextCtrl::SetStyle(const wxRichTextRange& range, const wxTextAttr& style) { return GetBuffer().SetStyle(range.ToInternal(), style); } @@ -2572,34 +2567,15 @@ bool wxRichTextCtrl::SetStyle(const wxRichTextRange& range, const wxRichTextAttr // extended style setting operation with flags including: // wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY. // see richtextbuffer.h for more details. -bool wxRichTextCtrl::SetStyleEx(long start, long end, const wxTextAttrEx& style, int flags) -{ - return GetBuffer().SetStyle(wxRichTextRange(start, end-1), style, flags); -} -bool wxRichTextCtrl::SetStyleEx(const wxRichTextRange& range, const wxTextAttrEx& style, int flags) +bool wxRichTextCtrl::SetStyleEx(const wxRichTextRange& range, const wxTextAttr& style, int flags) { return GetBuffer().SetStyle(range.ToInternal(), style, flags); } -bool wxRichTextCtrl::SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags) -{ - return GetBuffer().SetStyle(range.ToInternal(), style, flags); -} - -bool wxRichTextCtrl::SetDefaultStyle(const wxTextAttrEx& style) -{ - return GetBuffer().SetDefaultStyle(style); -} - bool wxRichTextCtrl::SetDefaultStyle(const wxTextAttr& style) { - return GetBuffer().SetDefaultStyle(wxTextAttrEx(style)); -} - -const wxTextAttrEx& wxRichTextCtrl::GetDefaultStyleEx() const -{ - return GetBuffer().GetDefaultStyle(); + return GetBuffer().SetDefaultStyle(wxTextAttr(style)); } const wxTextAttr& wxRichTextCtrl::GetDefaultStyle() const @@ -2609,65 +2585,18 @@ const wxTextAttr& wxRichTextCtrl::GetDefaultStyle() const bool wxRichTextCtrl::GetStyle(long position, wxTextAttr& style) { - wxTextAttrEx attr(style); - if (GetBuffer().GetStyle(position, attr)) - { - style = attr; - return true; - } - else - return false; -} - -bool wxRichTextCtrl::GetStyle(long position, wxTextAttrEx& style) -{ - return GetBuffer().GetStyle(position, style); -} - -bool wxRichTextCtrl::GetStyle(long position, wxRichTextAttr& style) -{ return GetBuffer().GetStyle(position, style); } // get the common set of styles for the range -bool wxRichTextCtrl::GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style) -{ - wxTextAttrEx styleEx; - if (GetBuffer().GetStyleForRange(range.ToInternal(), styleEx)) - { - style = styleEx; - return true; - } - else - return false; -} - -bool wxRichTextCtrl::GetStyleForRange(const wxRichTextRange& range, wxTextAttrEx& style) +bool wxRichTextCtrl::GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style) { return GetBuffer().GetStyleForRange(range.ToInternal(), style); } /// Get the content (uncombined) attributes for this position. - bool wxRichTextCtrl::GetUncombinedStyle(long position, wxTextAttr& style) { - wxTextAttrEx attr(style); - if (GetBuffer().GetUncombinedStyle(position, attr)) - { - style = attr; - return true; - } - else - return false; -} - -bool wxRichTextCtrl::GetUncombinedStyle(long position, wxTextAttrEx& style) -{ - return GetBuffer().GetUncombinedStyle(position, style); -} - -bool wxRichTextCtrl::GetUncombinedStyle(long position, wxRichTextAttr& style) -{ return GetBuffer().GetUncombinedStyle(position, style); } @@ -2676,7 +2605,7 @@ bool wxRichTextCtrl::SetFont(const wxFont& font) { wxControl::SetFont(font); - wxTextAttrEx attr = GetBuffer().GetAttributes(); + wxTextAttr attr = GetBuffer().GetAttributes(); attr.SetFont(font); GetBuffer().SetBasicStyle(attr); @@ -2831,7 +2760,7 @@ bool wxRichTextCtrl::IsSelectionBold() { if (HasSelection()) { - wxRichTextAttr attr; + wxTextAttr attr; wxRichTextRange range = GetSelectionRange(); attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT); attr.SetFontWeight(wxBOLD); @@ -2842,7 +2771,7 @@ bool wxRichTextCtrl::IsSelectionBold() { // If no selection, then we need to combine current style with default style // to see what the effect would be if we started typing. - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT); long pos = GetAdjustedCaretPosition(GetCaretPosition()); @@ -2862,7 +2791,7 @@ bool wxRichTextCtrl::IsSelectionItalics() if (HasSelection()) { wxRichTextRange range = GetSelectionRange(); - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC); attr.SetFontStyle(wxITALIC); @@ -2872,7 +2801,7 @@ bool wxRichTextCtrl::IsSelectionItalics() { // If no selection, then we need to combine current style with default style // to see what the effect would be if we started typing. - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC); long pos = GetAdjustedCaretPosition(GetCaretPosition()); @@ -2892,7 +2821,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined() if (HasSelection()) { wxRichTextRange range = GetSelectionRange(); - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE); attr.SetFontUnderlined(true); @@ -2902,7 +2831,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined() { // If no selection, then we need to combine current style with default style // to see what the effect would be if we started typing. - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE); long pos = GetAdjustedCaretPosition(GetCaretPosition()); @@ -2919,7 +2848,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined() /// Apply bold to the selection bool wxRichTextCtrl::ApplyBoldToSelection() { - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT); attr.SetFontWeight(IsSelectionBold() ? wxNORMAL : wxBOLD); @@ -2933,7 +2862,7 @@ bool wxRichTextCtrl::ApplyBoldToSelection() /// Apply italic to the selection bool wxRichTextCtrl::ApplyItalicToSelection() { - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC); attr.SetFontStyle(IsSelectionItalics() ? wxNORMAL : wxITALIC); @@ -2947,7 +2876,7 @@ bool wxRichTextCtrl::ApplyItalicToSelection() /// Apply underline to the selection bool wxRichTextCtrl::ApplyUnderlineToSelection() { - wxRichTextAttr attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE); attr.SetFontUnderlined(!IsSelectionUnderlined()); @@ -2967,7 +2896,7 @@ bool wxRichTextCtrl::IsSelectionAligned(wxTextAttrAlignment alignment) else range = wxRichTextRange(GetCaretPosition()+1, GetCaretPosition()+2); - wxRichTextAttr attr; + wxTextAttr attr; attr.SetAlignment(alignment); return HasParagraphAttributes(range, attr); @@ -2976,7 +2905,7 @@ bool wxRichTextCtrl::IsSelectionAligned(wxTextAttrAlignment alignment) /// Apply alignment to the selection bool wxRichTextCtrl::ApplyAlignmentToSelection(wxTextAttrAlignment alignment) { - wxRichTextAttr attr; + wxTextAttr attr; attr.SetAlignment(alignment); if (HasSelection()) return SetStyle(GetSelectionRange(), attr); @@ -2994,7 +2923,7 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def) { // Flags are defined within each definition, so only certain // attributes are applied. - wxRichTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle()); + wxTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle()); int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE; @@ -3058,7 +2987,7 @@ bool wxRichTextCtrl::ApplyStyleSheet(wxRichTextStyleSheet* styleSheet) /// Sets the default style to the style under the cursor bool wxRichTextCtrl::SetDefaultStyleToCursorStyle() { - wxTextAttrEx attr; + wxTextAttr attr; attr.SetFlags(wxTEXT_ATTR_CHARACTER); // If at the start of a paragraph, use the next position. diff --git a/src/richtext/richtextfontpage.cpp b/src/richtext/richtextfontpage.cpp index 1324dab..b47f370 100644 --- a/src/richtext/richtextfontpage.cpp +++ b/src/richtext/richtextfontpage.cpp @@ -267,17 +267,14 @@ bool wxRichTextFontPage::TransferDataFromWindow() { wxPanel::TransferDataFromWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (m_faceListBox->GetSelection() != wxNOT_FOUND) { wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection()); if (!faceName.IsEmpty()) { - wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT); - font.SetFaceName(faceName); - wxSetFontPreservingStyles(*attr, font); - attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_FACE); + attr->SetFontFaceName(faceName); } } else @@ -289,10 +286,7 @@ bool wxRichTextFontPage::TransferDataFromWindow() int sz = wxAtoi(strSize); if (sz > 0) { - wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT); - font.SetPointSize(sz); - wxSetFontPreservingStyles(*attr, font); - attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_SIZE); + attr->SetFontSize(sz); } } else @@ -306,10 +300,7 @@ bool wxRichTextFontPage::TransferDataFromWindow() else style = wxNORMAL; - wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT); - font.SetStyle(style); - wxSetFontPreservingStyles(*attr, font); - attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_ITALIC); + attr->SetFontStyle(style); } else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC)); @@ -322,10 +313,7 @@ bool wxRichTextFontPage::TransferDataFromWindow() else weight = wxNORMAL; - wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT); - font.SetWeight(weight); - wxSetFontPreservingStyles(*attr, font); - attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_WEIGHT); + attr->SetFontWeight(weight); } else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT)); @@ -338,10 +326,7 @@ bool wxRichTextFontPage::TransferDataFromWindow() else underlined = false; - wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT); - font.SetUnderlined(underlined); - wxSetFontPreservingStyles(*attr, font); - attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_UNDERLINE); + attr->SetFontUnderlined(underlined); } else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE)); @@ -352,7 +337,7 @@ bool wxRichTextFontPage::TransferDataFromWindow() } else attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR)); - + if (m_strikethroughCtrl->Get3StateValue() != wxCHK_UNDETERMINED) { attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_STRIKETHROUGH); @@ -366,7 +351,7 @@ bool wxRichTextFontPage::TransferDataFromWindow() if (m_capitalsCtrl->Get3StateValue() != wxCHK_UNDETERMINED) { attr->SetTextEffectFlags(attr->GetTextEffectFlags() | wxTEXT_ATTR_EFFECT_CAPITALS); - + if (m_capitalsCtrl->Get3StateValue() == wxCHK_CHECKED) attr->SetTextEffects(attr->GetTextEffects() | wxTEXT_ATTR_EFFECT_CAPITALS); else @@ -381,11 +366,11 @@ bool wxRichTextFontPage::TransferDataToWindow() wxPanel::TransferDataToWindow(); m_dontUpdate = true; - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); - if (attr->HasFont() && attr->HasFontFaceName()) + if (attr->HasFontFaceName()) { - m_faceTextCtrl->SetValue(attr->GetFont().GetFaceName()); + m_faceTextCtrl->SetValue(attr->GetFontFaceName()); m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName()); } else @@ -394,9 +379,9 @@ bool wxRichTextFontPage::TransferDataToWindow() m_faceListBox->SetFaceNameSelection(wxEmptyString); } - if (attr->HasFont() && attr->HasFontSize()) + if (attr->HasFontSize()) { - wxString strSize = wxString::Format(wxT("%d"), attr->GetFont().GetPointSize()); + wxString strSize = wxString::Format(wxT("%d"), attr->GetFontSize()); m_sizeTextCtrl->SetValue(strSize); if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND) m_sizeListBox->SetStringSelection(strSize); @@ -407,9 +392,9 @@ bool wxRichTextFontPage::TransferDataToWindow() m_sizeListBox->SetSelection(wxNOT_FOUND); } - if (attr->HasFont() && attr->HasFontWeight()) + if (attr->HasFontWeight()) { - if (attr->GetFont().GetWeight() == wxBOLD) + if (attr->GetFontWeight() == wxBOLD) m_weightCtrl->SetSelection(1); else m_weightCtrl->SetSelection(0); @@ -419,9 +404,9 @@ bool wxRichTextFontPage::TransferDataToWindow() m_weightCtrl->SetSelection(wxNOT_FOUND); } - if (attr->HasFont() && attr->HasFontItalic()) + if (attr->HasFontItalic()) { - if (attr->GetFont().GetStyle() == wxITALIC) + if (attr->GetFontStyle() == wxITALIC) m_styleCtrl->SetSelection(1); else m_styleCtrl->SetSelection(0); @@ -431,9 +416,9 @@ bool wxRichTextFontPage::TransferDataToWindow() m_styleCtrl->SetSelection(wxNOT_FOUND); } - if (attr->HasFont() && attr->HasFontUnderlined()) + if (attr->HasFontUnderlined()) { - if (attr->GetFont().GetUnderlined()) + if (attr->GetFontUnderlined()) m_underliningCtrl->SetSelection(1); else m_underliningCtrl->SetSelection(0); @@ -484,7 +469,7 @@ bool wxRichTextFontPage::TransferDataToWindow() return true; } -wxTextAttrEx* wxRichTextFontPage::GetAttributes() +wxTextAttr* wxRichTextFontPage::GetAttributes() { return wxRichTextFormattingDialog::GetDialogAttributes(this); } @@ -543,7 +528,7 @@ void wxRichTextFontPage::UpdatePreview() font.SetUnderlined(underlined); } - + int textEffects = 0; if (m_strikethroughCtrl->Get3StateValue() == wxCHK_CHECKED) diff --git a/src/richtext/richtextformatdlg.cpp b/src/richtext/richtextformatdlg.cpp index e93767e..d4c6081 100644 --- a/src/richtext/richtextformatdlg.cpp +++ b/src/richtext/richtextformatdlg.cpp @@ -130,7 +130,7 @@ bool wxRichTextFormattingDialog::ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTe } /// Set the attributes and optionally update the display -bool wxRichTextFormattingDialog::SetStyle(const wxTextAttrEx& style, bool update) +bool wxRichTextFormattingDialog::SetStyle(const wxTextAttr& style, bool update) { m_attributes = style; if (update) @@ -347,7 +347,7 @@ bool wxRichTextFormattingDialogFactory::SetSheetStyle(wxRichTextFormattingDialog dialog->SetSheetInnerBorder(0); dialog->SetSheetOuterBorder(0); #else - wxUnusedVar(dialog); + wxUnusedVar(dialog); #endif // wxRICHTEXT_USE_TOOLBOOK return true; @@ -440,7 +440,7 @@ wxRichTextFormattingDialog* wxRichTextFormattingDialog::GetDialog(wxWindow* win) // Helper for pages to get the attributes -wxTextAttrEx* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win) +wxTextAttr* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win) { wxRichTextFormattingDialog* dialog = GetDialog(win); if (dialog) diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp index df1eb2d..2ec1513 100644 --- a/src/richtext/richtexthtml.cpp +++ b/src/richtext/richtexthtml.cpp @@ -79,8 +79,8 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& wxTextOutputStream str(stream); - wxTextAttrEx currentParaStyle = buffer->GetAttributes(); - wxTextAttrEx currentCharStyle = buffer->GetAttributes(); + wxTextAttr currentParaStyle = buffer->GetAttributes(); + wxTextAttr currentCharStyle = buffer->GetAttributes(); if ((GetFlags() & wxRICHTEXT_HANDLER_NO_HEADER_FOOTER) == 0) str << wxT("\n"); @@ -103,7 +103,7 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& if (para) { - wxTextAttrEx paraStyle(para->GetCombinedAttributes()); + wxTextAttr paraStyle(para->GetCombinedAttributes()); BeginParagraphFormatting(currentParaStyle, paraStyle, str); @@ -114,7 +114,7 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& wxRichTextPlainText* textObj = wxDynamicCast(obj, wxRichTextPlainText); if (textObj && !textObj->IsEmpty()) { - wxTextAttrEx charStyle(para->GetCombinedAttributes(obj->GetAttributes())); + wxTextAttr charStyle(para->GetCombinedAttributes(obj->GetAttributes())); BeginCharacterFormatting(currentCharStyle, charStyle, paraStyle, str); wxString text = textObj->GetText(); @@ -160,18 +160,18 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& return true; } -void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, const wxTextAttrEx& WXUNUSED(paraStyle), wxTextOutputStream& str) +void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& str) { wxString style; // Is there any change in the font properties of the item? - if (thisStyle.GetFont().GetFaceName() != currentStyle.GetFont().GetFaceName()) + if (thisStyle.GetFontFaceName() != currentStyle.GetFontFaceName()) { - wxString faceName(thisStyle.GetFont().GetFaceName()); + wxString faceName(thisStyle.GetFontFaceName()); style += wxString::Format(wxT(" face=\"%s\""), faceName.c_str()); } - if (thisStyle.GetFont().GetPointSize() != currentStyle.GetFont().GetPointSize()) - style += wxString::Format(wxT(" size=\"%ld\""), PtToSize(thisStyle.GetFont().GetPointSize())); + if (thisStyle.GetFontSize() != currentStyle.GetFontSize()) + style += wxString::Format(wxT(" size=\"%ld\""), PtToSize(thisStyle.GetFontSize())); if (thisStyle.GetTextColour() != currentStyle.GetTextColour() ) { wxString color(thisStyle.GetTextColour().GetAsString(wxC2S_HTML_SYNTAX)); @@ -184,27 +184,27 @@ void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxTextAttrEx& current m_font = true; } - if (thisStyle.GetFont().GetWeight() == wxBOLD) + if (thisStyle.GetFontWeight() == wxBOLD) str << wxT(""); - if (thisStyle.GetFont().GetStyle() == wxITALIC) + if (thisStyle.GetFontStyle() == wxITALIC) str << wxT(""); - if (thisStyle.GetFont().GetUnderlined()) + if (thisStyle.GetFontUnderlined()) str << wxT(""); if (thisStyle.HasURL()) str << wxT(""); } -void wxRichTextHTMLHandler::EndCharacterFormatting(const wxTextAttrEx& WXUNUSED(currentStyle), const wxTextAttrEx& thisStyle, const wxTextAttrEx& WXUNUSED(paraStyle), wxTextOutputStream& stream) +void wxRichTextHTMLHandler::EndCharacterFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, const wxTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& stream) { if (thisStyle.HasURL()) stream << wxT(""); - if (thisStyle.GetFont().GetUnderlined()) + if (thisStyle.GetFontUnderlined()) stream << wxT(""); - if (thisStyle.GetFont().GetStyle() == wxITALIC) + if (thisStyle.GetFontStyle() == wxITALIC) stream << wxT(""); - if (thisStyle.GetFont().GetWeight() == wxBOLD) + if (thisStyle.GetFontWeight() == wxBOLD) stream << wxT(""); if (m_font) @@ -215,7 +215,7 @@ void wxRichTextHTMLHandler::EndCharacterFormatting(const wxTextAttrEx& WXUNUSED( } /// Begin paragraph formatting -void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxTextAttrEx& WXUNUSED(currentStyle), const wxTextAttrEx& thisStyle, wxTextOutputStream& str) +void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, wxTextOutputStream& str) { if (thisStyle.HasPageBreak()) { @@ -286,7 +286,7 @@ void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxTextAttrEx& WXUNUSE } /// End paragraph formatting -void wxRichTextHTMLHandler::EndParagraphFormatting(const wxTextAttrEx& WXUNUSED(currentStyle), const wxTextAttrEx& thisStyle, wxTextOutputStream& stream) +void wxRichTextHTMLHandler::EndParagraphFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, wxTextOutputStream& stream) { if (m_inTable) { @@ -322,18 +322,18 @@ void wxRichTextHTMLHandler::CloseLists(int level, wxTextOutputStream& str) } /// Output font tag -void wxRichTextHTMLHandler::OutputFont(const wxTextAttrEx& style, wxTextOutputStream& stream) +void wxRichTextHTMLHandler::OutputFont(const wxTextAttr& style, wxTextOutputStream& stream) { if (style.HasFont()) { - stream << wxString::Format(wxT(""); } } -int wxRichTextHTMLHandler::TypeOfList( const wxTextAttrEx& thisStyle, wxString& tag ) +int wxRichTextHTMLHandler::TypeOfList( const wxTextAttr& thisStyle, wxString& tag ) { // We can use number attribute of li tag but not all the browsers support it. // also wxHtmlWindow doesn't support type attribute. @@ -361,7 +361,7 @@ int wxRichTextHTMLHandler::TypeOfList( const wxTextAttrEx& thisStyle, wxString& return 0; } -wxString wxRichTextHTMLHandler::GetAlignment( const wxTextAttrEx& thisStyle ) +wxString wxRichTextHTMLHandler::GetAlignment( const wxTextAttr& thisStyle ) { switch( thisStyle.GetAlignment() ) { diff --git a/src/richtext/richtextindentspage.cpp b/src/richtext/richtextindentspage.cpp index 5edb752..360a7fa6 100644 --- a/src/richtext/richtextindentspage.cpp +++ b/src/richtext/richtextindentspage.cpp @@ -334,7 +334,7 @@ void wxRichTextIndentsSpacingPage::CreateControls() ////@end wxRichTextIndentsSpacingPage content construction } -wxTextAttrEx* wxRichTextIndentsSpacingPage::GetAttributes() +wxTextAttr* wxRichTextIndentsSpacingPage::GetAttributes() { return wxRichTextFormattingDialog::GetDialogAttributes(this); } @@ -352,7 +352,7 @@ et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id m iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); TransferDataFromWindow(); - wxTextAttrEx attr(*GetAttributes()); + wxTextAttr attr(*GetAttributes()); attr.SetFlags(attr.GetFlags() & (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER| wxTEXT_ATTR_LINE_SPACING| @@ -362,7 +362,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); font.SetPointSize(9); m_previewCtrl->SetFont(font); - wxTextAttrEx normalParaAttr; + wxTextAttr normalParaAttr; normalParaAttr.SetFont(font); normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY"))); @@ -389,7 +389,7 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow() { wxPanel::TransferDataFromWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (m_alignmentLeft->GetValue()) attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT); @@ -450,7 +450,7 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow() attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING)); else attr->SetLineSpacing(lineSpacing); - + int outlineLevel = m_outlineLevelCtrl->GetSelection(); if (outlineLevel != wxNOT_FOUND) attr->SetOutlineLevel(outlineLevel); @@ -464,7 +464,7 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow() wxPanel::TransferDataToWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (attr->HasAlignment()) { @@ -548,7 +548,7 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow() if (outlineLevel < 0) outlineLevel = 0; if (outlineLevel > 9) - outlineLevel = 9; + outlineLevel = 9; m_outlineLevelCtrl->SetSelection(outlineLevel); } diff --git a/src/richtext/richtextliststylepage.cpp b/src/richtext/richtextliststylepage.cpp index 28f8691..75bcfa7 100644 --- a/src/richtext/richtextliststylepage.cpp +++ b/src/richtext/richtextliststylepage.cpp @@ -530,7 +530,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); wxRichTextStyleSheet* styleSheet = wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet(); - wxTextAttrEx attr(styleSheet ? def->GetStyle() : def->GetStyleMergedWithBase(styleSheet)); + wxTextAttr attr(styleSheet ? def->GetStyle() : def->GetStyleMergedWithBase(styleSheet)); attr.SetFlags(attr.GetFlags() & (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER| @@ -541,7 +541,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); font.SetPointSize(9); m_previewCtrl->SetFont(font); - wxTextAttrEx normalParaAttr; + wxTextAttr normalParaAttr; normalParaAttr.SetFont(font); normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY"))); @@ -558,7 +558,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); int i; for (i = 0; i < 10; i++) { - wxTextAttrEx levelAttr = * def->GetLevelAttributes(i); + wxTextAttr levelAttr = * def->GetLevelAttributes(i); levelAttr.SetBulletNumber(1); m_previewCtrl->BeginStyle(levelAttr); m_previewCtrl->WriteText(wxString::Format(wxT("\nList level %d. "), i+1) + s_para2); @@ -583,7 +583,7 @@ bool wxRichTextListStylePage::TransferDataFromWindow() m_currentLevel = m_levelCtrl->GetValue(); - wxRichTextAttr* attr = GetAttributesForSelection(); + wxTextAttr* attr = GetAttributesForSelection(); if (m_alignmentLeft->GetValue()) attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT); @@ -721,7 +721,7 @@ void wxRichTextListStylePage::DoTransferDataToWindow() wxPanel::TransferDataToWindow(); - wxRichTextAttr* attr = GetAttributesForSelection(); + wxTextAttr* attr = GetAttributesForSelection(); if (attr->HasAlignment()) { @@ -877,7 +877,7 @@ void wxRichTextListStylePage::DoTransferDataToWindow() } /// Get attributes for selected level -wxRichTextAttr* wxRichTextListStylePage::GetAttributesForSelection() +wxTextAttr* wxRichTextListStylePage::GetAttributesForSelection() { wxRichTextListStyleDefinition* def = wxDynamicCast(wxRichTextFormattingDialog::GetDialogStyleDefinition(this), wxRichTextListStyleDefinition); @@ -1282,7 +1282,7 @@ void wxRichTextListStylePage::OnStandardBulletUpdate( wxUpdateUIEvent& event ) void wxRichTextListStylePage::OnChooseFontClick( wxCommandEvent& WXUNUSED(event) ) { - wxRichTextAttr* attr = GetAttributesForSelection(); + wxTextAttr* attr = GetAttributesForSelection(); int pages = wxRICHTEXT_FORMAT_FONT; wxRichTextFormattingDialog formatDlg; diff --git a/src/richtext/richtextstyledlg.cpp b/src/richtext/richtextstyledlg.cpp index e31fbc1..784d18e 100644 --- a/src/richtext/richtextstyledlg.cpp +++ b/src/richtext/richtextstyledlg.cpp @@ -426,13 +426,13 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition); - wxTextAttrEx attr(def->GetStyleMergedWithBase(GetStyleSheet())); + wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet())); wxFont font(m_previewCtrl->GetFont()); font.SetPointSize(9); m_previewCtrl->SetFont(font); - wxTextAttrEx normalParaAttr; + wxTextAttr normalParaAttr; normalParaAttr.SetFont(font); normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY"))); @@ -451,7 +451,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n"); int i; for (i = 0; i < 10; i++) { - wxTextAttrEx levelAttr = * listDef->GetLevelAttributes(i); + wxTextAttr levelAttr = * listDef->GetLevelAttributes(i); levelAttr.SetBulletNumber(1); m_previewCtrl->BeginStyle(levelAttr); m_previewCtrl->WriteText(wxString::Format(wxT("\nList level %d. "), i+1) + s_para2List); @@ -870,4 +870,4 @@ void wxRichTextStyleOrganiserDialog::OnListSelection(wxCommandEvent& event) #endif // wxUSE_RICHTEXT - + diff --git a/src/richtext/richtextstylepage.cpp b/src/richtext/richtextstylepage.cpp index 2b90f57..19fbea0 100644 --- a/src/richtext/richtextstylepage.cpp +++ b/src/richtext/richtextstylepage.cpp @@ -245,7 +245,7 @@ bool wxRichTextStylePage::TransferDataToWindow() return true; } -wxTextAttrEx* wxRichTextStylePage::GetAttributes() +wxTextAttr* wxRichTextStylePage::GetAttributes() { return wxRichTextFormattingDialog::GetDialogAttributes(this); } diff --git a/src/richtext/richtextstyles.cpp b/src/richtext/richtextstyles.cpp index 5fa16bb..ca97d59 100644 --- a/src/richtext/richtextstyles.cpp +++ b/src/richtext/richtextstyles.cpp @@ -54,14 +54,14 @@ bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const } /// Gets the style combined with the base style -wxRichTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const +wxTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const { if (!m_baseStyle.IsEmpty()) { wxRichTextStyleDefinition* baseStyle = sheet->FindStyle(m_baseStyle); if (baseStyle) { - wxRichTextAttr baseAttr = baseStyle->GetStyleMergedWithBase(sheet); + wxTextAttr baseAttr = baseStyle->GetStyleMergedWithBase(sheet); baseAttr.Apply(m_style, NULL); return baseAttr; } @@ -111,14 +111,14 @@ bool wxRichTextListStyleDefinition::operator ==(const wxRichTextListStyleDefinit } /// Sets/gets the attributes for the given level -void wxRichTextListStyleDefinition::SetLevelAttributes(int i, const wxRichTextAttr& attr) +void wxRichTextListStyleDefinition::SetLevelAttributes(int i, const wxTextAttr& attr) { wxASSERT( (i >= 0 && i < 10) ); if (i >= 0 && i < 10) m_levelStyles[i] = attr; } -const wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const +const wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const { wxASSERT( (i >= 0 && i < 10) ); if (i >= 0 && i < 10) @@ -127,7 +127,7 @@ const wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) c return NULL; } -wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) +wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) { wxASSERT( (i >= 0 && i < 10) ); if (i >= 0 && i < 10) @@ -142,7 +142,7 @@ void wxRichTextListStyleDefinition::SetAttributes(int i, int leftIndent, int lef wxASSERT( (i >= 0 && i < 10) ); if (i >= 0 && i < 10) { - wxRichTextAttr attr; + wxTextAttr attr; attr.SetBulletStyle(bulletStyle); attr.SetLeftIndent(leftIndent, leftSubIndent); @@ -178,11 +178,11 @@ int wxRichTextListStyleDefinition::FindLevelForIndent(int indent) const /// Combine the list style with a paragraph style, using the given indent (from which /// an appropriate level is found) -wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet) +wxTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet) { int listLevel = FindLevelForIndent(indent); - wxRichTextAttr attr(*GetLevelAttributes(listLevel)); + wxTextAttr attr(*GetLevelAttributes(listLevel)); int oldLeftIndent = attr.GetLeftIndent(); int oldLeftSubIndent = attr.GetLeftSubIndent(); @@ -203,7 +203,7 @@ wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int inde /// Combine the base and list style, using the given indent (from which /// an appropriate level is found) -wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet) +wxTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet) { int listLevel = FindLevelForIndent(indent); return GetCombinedStyleForLevel(listLevel, styleSheet); @@ -211,9 +211,9 @@ wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRic /// Combine the base and list style, using the given indent (from which /// an appropriate level is found) -wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel, wxRichTextStyleSheet* styleSheet) +wxTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel, wxRichTextStyleSheet* styleSheet) { - wxRichTextAttr attr(*GetLevelAttributes(listLevel)); + wxTextAttr attr(*GetLevelAttributes(listLevel)); int oldLeftIndent = attr.GetLeftIndent(); int oldLeftSubIndent = attr.GetLeftSubIndent(); @@ -590,7 +590,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons bool isCentred = false; - wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet())); + wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet())); if (attr.HasAlignment() && attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE) isCentred = true; @@ -722,7 +722,7 @@ wxString wxRichTextStyleListBox::GetStyleToShowInIdleTime(wxRichTextCtrl* ctrl, // Take into account current default style just chosen by user if (ctrl->IsDefaultStyleShowing()) { - wxTextAttrEx attr; + wxTextAttr attr; ctrl->GetStyle(adjustedCaretPos, attr); wxRichTextApplyStyle(attr, ctrl->GetDefaultStyleEx()); @@ -1000,9 +1000,9 @@ END_EVENT_TABLE() bool wxRichTextStyleComboPopup::Create( wxWindow* parent ) { - int borderStyle = GetDefaultBorder(); - if (borderStyle == wxBORDER_SUNKEN) - borderStyle = wxBORDER_SIMPLE; + int borderStyle = GetDefaultBorder(); + if (borderStyle == wxBORDER_SUNKEN) + borderStyle = wxBORDER_SIMPLE; return wxRichTextStyleListBox::Create(parent, wxID_ANY, wxPoint(0,0), wxDefaultSize, diff --git a/src/richtext/richtexttabspage.cpp b/src/richtext/richtexttabspage.cpp index 6957462..25343ab 100644 --- a/src/richtext/richtexttabspage.cpp +++ b/src/richtext/richtexttabspage.cpp @@ -159,7 +159,7 @@ bool wxRichTextTabsPage::TransferDataFromWindow() { wxPanel::TransferDataFromWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); if (m_tabsPresent) { @@ -178,7 +178,7 @@ bool wxRichTextTabsPage::TransferDataToWindow() { wxPanel::TransferDataToWindow(); - wxTextAttrEx* attr = GetAttributes(); + wxTextAttr* attr = GetAttributes(); m_tabListCtrl->Clear(); m_tabEditCtrl->SetValue(wxEmptyString); @@ -226,7 +226,7 @@ void wxRichTextTabsPage::SortTabs() } } -wxTextAttrEx* wxRichTextTabsPage::GetAttributes() +wxTextAttr* wxRichTextTabsPage::GetAttributes() { return wxRichTextFormattingDialog::GetDialogAttributes(this); } diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index a102475..a9833b3 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -270,7 +270,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx { if (child->GetName() == wxT("style")) { - wxTextAttrEx attr; + wxTextAttr attr; GetStyle(attr, child, false); def->SetStyle(attr); } @@ -292,7 +292,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx { if (child->GetName() == wxT("style")) { - wxTextAttrEx attr; + wxTextAttr attr; GetStyle(attr, child, false); def->SetStyle(attr); } @@ -314,7 +314,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx { if (child->GetName() == wxT("style")) { - wxTextAttrEx attr; + wxTextAttr attr; GetStyle(attr, child, false); wxString styleLevel = child->GetAttribute(wxT("level"), wxEmptyString); @@ -834,7 +834,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon int i; for (i = 0; i < 10; i ++) { - wxRichTextAttr* levelAttr = listDef->GetLevelAttributes(i); + wxTextAttr* levelAttr = listDef->GetLevelAttributes(i); if (levelAttr) { wxString style = CreateStyle(def->GetStyle(), false); @@ -882,7 +882,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon } /// Create style parameters -wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara) +wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttr& attr, bool isPara) { wxString str; if (attr.HasTextColour() && attr.GetTextColour().Ok()) @@ -894,26 +894,23 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara str << wxT(" bgcolor=\"#") << ColourToHexString(attr.GetBackgroundColour()) << wxT("\""); } - if (attr.GetFont().Ok()) - { - if (attr.HasFontSize()) - str << wxT(" fontsize=\"") << attr.GetFont().GetPointSize() << wxT("\""); + if (attr.HasFontSize()) + str << wxT(" fontsize=\"") << attr.GetFontSize() << wxT("\""); - //if (attr.HasFontFamily()) - // str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\""); + //if (attr.HasFontFamily()) + // str << wxT(" fontfamily=\"") << attr.GetFont().GetFamily() << wxT("\""); - if (attr.HasFontItalic()) - str << wxT(" fontstyle=\"") << attr.GetFont().GetStyle() << wxT("\""); + if (attr.HasFontItalic()) + str << wxT(" fontstyle=\"") << attr.GetFontStyle() << wxT("\""); - if (attr.HasFontWeight()) - str << wxT(" fontweight=\"") << attr.GetFont().GetWeight() << wxT("\""); + if (attr.HasFontWeight()) + str << wxT(" fontweight=\"") << attr.GetFontWeight() << wxT("\""); - if (attr.HasFontUnderlined()) - str << wxT(" fontunderlined=\"") << (int) attr.GetFont().GetUnderlined() << wxT("\""); + if (attr.HasFontUnderlined()) + str << wxT(" fontunderlined=\"") << (int) attr.GetFontUnderlined() << wxT("\""); - if (attr.HasFontFaceName()) - str << wxT(" fontface=\"") << attr.GetFont().GetFaceName() << wxT("\""); - } + if (attr.HasFontFaceName()) + str << wxT(" fontface=\"") << attr.GetFontFaceName() << wxT("\""); if (attr.HasTextEffects()) { @@ -1009,20 +1006,20 @@ wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttrEx& attr, bool isPara } /// Get style parameters -bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool isPara) +bool wxRichTextXMLHandler::GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara) { wxString fontFacename; int fontSize = 12; - int fontFamily = wxDEFAULT; + // int fontFamily = wxDEFAULT; int fontWeight = wxNORMAL; int fontStyle = wxNORMAL; bool fontUnderlined = false; - int fontFlags = 0; + // int fontFlags = 0; fontFacename = node->GetAttribute(wxT("fontface"), wxEmptyString); if (!fontFacename.IsEmpty()) - fontFlags |= wxTEXT_ATTR_FONT_FACE; + attr.SetFontFaceName(fontFacename); wxString value; //value = node->GetAttribute(wxT("fontfamily"), wxEmptyString); @@ -1033,38 +1030,30 @@ bool wxRichTextXMLHandler::GetStyle(wxTextAttrEx& attr, wxXmlNode* node, bool is if (!value.empty()) { fontStyle = wxAtoi(value); - fontFlags |= wxTEXT_ATTR_FONT_ITALIC; + attr.SetFontStyle(fontStyle); } value = node->GetAttribute(wxT("fontsize"), wxEmptyString); if (!value.empty()) { fontSize = wxAtoi(value); - fontFlags |= wxTEXT_ATTR_FONT_SIZE; + attr.SetFontSize(fontSize); } value = node->GetAttribute(wxT("fontweight"), wxEmptyString); if (!value.empty()) { fontWeight = wxAtoi(value); - fontFlags |= wxTEXT_ATTR_FONT_WEIGHT; + attr.SetFontWeight(fontWeight); } value = node->GetAttribute(wxT("fontunderlined"), wxEmptyString); if (!value.empty()) { fontUnderlined = wxAtoi(value) != 0; - fontFlags |= wxTEXT_ATTR_FONT_UNDERLINE; + attr.SetFontUnderlined(fontUnderlined); } - attr.SetFlags(fontFlags); - - if (attr.HasFlag(wxTEXT_ATTR_FONT)) - attr.SetFont(* wxTheFontList->FindOrCreateFont(fontSize, fontFamily, fontStyle, fontWeight, fontUnderlined, fontFacename)); - - // Restore correct font flags - attr.SetFlags(fontFlags); - value = node->GetAttribute(wxT("textcolor"), wxEmptyString); if (!value.empty()) { -- 2.7.4