📄 richtextattr.tex
字号:
\section{\class{wxRichTextAttr}}\label{wxrichtextattr}wxRichTextAttr represents the character and paragraph attributes, or style,for a range of text in a \helpref{wxRichTextCtrl}{wxrichtextctrl}. This classis specific to wxRichTextCtrl, although you can also use thestandard \helpref{wxTextAttr}{wxtextattr} class with wxRichTextCtrl.When setting up a wxRichTextAttr object, pass a bitlist mask to \helpref{SetFlags}{wxrichtextattrsetflags} toindicate which style elements should be changed. As a convenience, when you call a setter suchas SetFont, the relevant bit will be set.wxRichTextAttr stores attributes without a wxFont object, so is a moreefficient way to query styles than using a \helpref{wxTextAttr}{wxtextattr} or \helpref{wxTextAttrEx}{wxtextattrex} object.\wxheading{Derived from}No base class\wxheading{Include files}<wx/richtext/richtextbuffer.h>\wxheading{Constants}The following values can be passed to wxRichTextAttr::SetAlignment to determineparagraph 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}}Of these, wxTEXT\_ALIGNMENT\_JUSTIFIED is unimplemented. In future justification may be supportedwhen printing or previewing, only.The following values are passed in a bitlist to wxRichTextAttr::SetFlags to determinewhat attributes will be considered when setting the attributesfor a text control.{\small\begin{verbatim}// Standard wxTextAttr constants#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 \ wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT \| wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE#define wxTEXT_ATTR_ALIGNMENT 0x00000080#define wxTEXT_ATTR_LEFT_INDENT 0x00000100#define wxTEXT_ATTR_RIGHT_INDENT 0x00000200#define wxTEXT_ATTR_TABS 0x00000400// 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 wxRichTextAttr::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 wxRichTextAttr::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{wxTextAttrEx}{wxtextattrex}, \helpref{wxRichTextCtrl}{wxrichtextctrl}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxRichTextAttr::wxRichTextAttr}\label{wxrichtextattrwxrichtextattr}\func{}{wxRichTextAttr}{\void}\func{}{wxRichTextAttr}{\param{const wxColour\& }{colText}, \param{const wxColour\& }{colBack = wxNullColour}, \param{wxTextAttrAlignment }{alignment = wxTEXT\_ALIGNMENT\_DEFAULT}}\func{}{wxRichTextAttr}{\param{const wxTextAttrEx\& }{attr}}Constructors.\membersection{wxRichTextAttr::Apply}\label{wxrichtextattrapply}\func{bool}{Combine}{\param{const wxRichTextAttrEx\& }{style}, \param{const wxRichTextAttrEx* }{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}\constfunc{wxFont}{CreateFont}{\void}Creates a font from the font attributes.\membersection{wxRichTextAttr::GetAlignment}\label{wxrichtextattrgetalignment}\constfunc{wxTextAttrAlignment}{GetAlignment}{\void}Returns the alignment flags.See \helpref{wxRichTextAttr::SetAlignment}{wxrichtextattrsetalignment} for a list of available styles.\membersection{wxRichTextAttr::GetBackgroundColour}\label{wxrichtextattrgetbackgroundcolour}\constfunc{const wxColour\&}{GetBackgroundColour}{\void}Returns the background colour.\membersection{wxRichTextAttr::GetBulletFont}\label{wxrichtextattrgetbulletfont}\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}\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 aclass from wxRichTextRenderer or wxRichTextStdRenderer, override {\tt DrawStandardBullet} and {\tt EnumerateStandardBulletNames}, andset an instance of the class using \helpref{wxRichTextBuffer::SetRenderer}{wxrichtextbuffersetrenderer}.\membersection{wxRichTextAttr::GetBulletNumber}\label{wxrichtextattrgetbulletnumber}\constfunc{int}{GetBulletNumber}{\void}Returns the bullet number.\membersection{wxRichTextAttr::GetBulletStyle}\label{wxrichtextattrgetbulletstyle}\constfunc{int}{GetBulletStyle}{\void}Returns the bullet style.See \helpref{wxRichTextAttr::SetBulletStyle}{wxrichtextattrsetbulletstyle} for a list of available styles.\membersection{wxRichTextAttr::GetBulletText}\label{wxrichtextattrgetbullettext}\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}\constfunc{const wxString\&}{GetCharacterStyleName}{\void}Returns the name of the character style.\membersection{wxRichTextAttr::GetFlags}\label{wxrichtextattrgetflags}\constfunc{long}{GetFlags}{\void}Returns flags indicating which attributes are applicable.See \helpref{wxRichTextAttr::SetFlags}{wxrichtextattrsetflags} for a list of available flags.\membersection{wxRichTextAttr::GetFontAttributes}\label{wxrichtextattrgetfontattributes}\func{bool}{GetFontAttributes}{\param{const wxFont\& }{font}}Sets the font attributes from the given font.\membersection{wxRichTextAttr::GetFontFaceName}\label{wxrichtextattrgetfontfacename}\constfunc{const wxString\&}{GetFontFaceName}{\void}Returns the font face name.\membersection{wxRichTextAttr::GetFontSize}\label{wxrichtextattrgetfontsize}\constfunc{int}{GetFontSize}{\void}Returns the font size in points.\membersection{wxRichTextAttr::GetFontStyle}\label{wxrichtextattrgetfontstyle}\constfunc{int}{GetFontStyle}{\void}Returns the font style.\membersection{wxRichTextAttr::GetFontUnderlined}\label{wxrichtextattrgetfontunderlined}\constfunc{bool}{GetFontUnderlined}{\void}Returns \true if the font is underlined.\membersection{wxRichTextAttr::GetFontWeight}\label{wxrichtextattrgetfontweight}\constfunc{int}{GetFontWeight}{\void}Returns the font weight.\membersection{wxRichTextAttr::GetLeftIndent}\label{wxrichtextattrgetleftindent}\constfunc{long}{GetLeftIndent}{\void}Returns the left indent in tenths of a millimetre.\membersection{wxRichTextAttr::GetLeftSubIndent}\label{wxrichtextattrgetleftsubindent}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -