Added URL support to attribute objects and to wxRichTextCtrl,
[wxWidgets.git] / docs / latex / wx / textattrex.tex
1 \section{\class{wxTextAttrEx}}\label{wxtextattrex}
2
3 wxTextAttrEx is an extended version of wxTextAttr with more paragraph attributes.
4 Currently it is only used with \helpref{wxRichTextCtrl}{wxrichtextctrl}.
5
6 It is intended that eventually, the members of wxTextAttrEx will
7 be folded into wxTextAttr, and wxTextAttr will be the official
8 cross-platform API for text controls that support attributes.
9 However, for now, wxTextAttrEx is provided as a means of enabling
10 extra functionality in wxRichTextCtrl, while retaining some compatibility
11 with the wxTextAttr API.
12
13 The most efficient method of accessing wxRichTextCtrl functionality
14 is a third attribute class, \helpref{wxRichTextAttr}{wxrichtextattr}, which
15 optimizes its storage to allow it to be used for implementing objects
16 in a buffer, as well as access to that buffer.
17
18 This section only documents the additional members; see \helpref{wxTextAttr}{wxtextattr} for
19 the remaining functions.
20
21 \wxheading{Derived from}
22
23 \helpref{wxTextAttr}{wxtextattr}
24
25 \wxheading{Include files}
26
27 <wx/richtext/richtextbuffer.h>
28
29 \wxheading{Constants}
30
31 The following values can be passed to SetAlignment to determine
32 paragraph alignment.
33
34 {\small
35 \begin{verbatim}
36 enum wxTextAttrAlignment
37 {
38 wxTEXT_ALIGNMENT_DEFAULT,
39 wxTEXT_ALIGNMENT_LEFT,
40 wxTEXT_ALIGNMENT_CENTRE,
41 wxTEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE,
42 wxTEXT_ALIGNMENT_RIGHT,
43 wxTEXT_ALIGNMENT_JUSTIFIED
44 };
45 \end{verbatim}
46 }
47
48 These values are passed in a bitlist to SetFlags to determine
49 what attributes will be considered when setting the attributes
50 for a text control.
51
52 {\small
53 \begin{verbatim}
54 // Standard wxTextAttr constants
55
56 #define wxTEXT_ATTR_TEXT_COLOUR 0x0001
57 #define wxTEXT_ATTR_BACKGROUND_COLOUR 0x0002
58 #define wxTEXT_ATTR_FONT_FACE 0x0004
59 #define wxTEXT_ATTR_FONT_SIZE 0x0008
60 #define wxTEXT_ATTR_FONT_WEIGHT 0x0010
61 #define wxTEXT_ATTR_FONT_ITALIC 0x0020
62 #define wxTEXT_ATTR_FONT_UNDERLINE 0x0040
63 #define wxTEXT_ATTR_FONT \
64 wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT \
65 | wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE
66 #define wxTEXT_ATTR_ALIGNMENT 0x0080
67 #define wxTEXT_ATTR_LEFT_INDENT 0x0100
68 #define wxTEXT_ATTR_RIGHT_INDENT 0x0200
69 #define wxTEXT_ATTR_TABS 0x0400
70
71 // Extra formatting flags not in wxTextAttr
72
73 #define wxTEXT_ATTR_PARA_SPACING_AFTER 0x00000800
74 #define wxTEXT_ATTR_PARA_SPACING_BEFORE 0x00001000
75 #define wxTEXT_ATTR_LINE_SPACING 0x00002000
76 #define wxTEXT_ATTR_CHARACTER_STYLE_NAME 0x00004000
77 #define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME 0x00008000
78 #define wxTEXT_ATTR_LIST_STYLE_NAME 0x00010000
79 #define wxTEXT_ATTR_BULLET_STYLE 0x00020000
80 #define wxTEXT_ATTR_BULLET_NUMBER 0x00040000
81 #define wxTEXT_ATTR_BULLET_TEXT 0x00080000
82 #define wxTEXT_ATTR_BULLET_NAME 0x00100000
83 #define wxTEXT_ATTR_URL 0x00200000
84 \end{verbatim}
85 }
86
87 The following styles can be passed to wxRichTextAttr::SetBulletStyle:
88
89 {\small
90 \begin{verbatim}
91 #define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000
92 #define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001
93 #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002
94 #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004
95 #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008
96 #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010
97 #define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020
98 #define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040
99 #define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080
100 #define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100
101 #define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200
102 #define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400
103 #define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800
104 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000
105 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000
106 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000
107 \end{verbatim}
108 }
109
110 The following constants can be passed to wxRichTextAttr::SetLineSpacing:
111
112 {\small
113 \begin{verbatim}
114 #define wxTEXT_ATTR_LINE_SPACING_NORMAL 10
115 #define wxTEXT_ATTR_LINE_SPACING_HALF 15
116 #define wxTEXT_ATTR_LINE_SPACING_TWICE 20
117 \end{verbatim}
118 }
119
120 \wxheading{See also}
121
122 \helpref{wxTextAttr}{wxtextattr}, \helpref{wxRichTextAttr}{wxrichtextattr}, \helpref{wxRichTextCtrl}{wxrichtextctrl}
123
124 \latexignore{\rtfignore{\wxheading{Members}}}
125
126
127 \membersection{wxTextAttrEx::wxTextAttrEx}\label{wxtextattrexwxtextattrex}
128
129 \func{}{wxTextAttrEx}{\void}
130
131
132 \func{}{wxTextAttrEx}{\param{const wxTextAttrEx\& }{attr}}
133
134 Constructors.
135
136 \membersection{wxTextAttrEx::GetBulletFont}\label{wxtextattrexgetbulletfont}
137
138 \constfunc{const wxString\&}{GetBulletFont}{\void}
139
140 Returns a string containing the name of the font associated with the bullet symbol.
141 Only valid for attributes with wxTEXT\_ATTR\_BULLET\_SYMBOL.
142
143 \membersection{wxTextAttrEx::GetBulletName}\label{wxtextattrexgetbulletname}
144
145 \constfunc{const wxString\&}{GetBulletName}{\void}
146
147 Returns the standard bullet name, applicable if the bullet style is wxTEXT\_ATTR\_BULLET\_STYLE\_STANDARD.
148 Currently the following standard bullet names are supported:
149
150 \begin{itemize}\itemsep=0pt
151 \item {\tt standard/circle}
152 \item {\tt standard/square}
153 \item {\tt standard/diamond}
154 \item {\tt standard/triangle}
155 \end{itemize}
156
157 If you wish your application to support further bullet graphics, you can derive a
158 class from wxRichTextRenderer or wxRichTextStdRenderer, override {\tt DrawStandardBullet} and {\tt EnumerateStandardBulletNames}, and
159 set an instance of the class using \helpref{wxRichTextBuffer::SetRenderer}{wxrichtextbuffersetrenderer}.
160
161 \membersection{wxTextAttrEx::GetBulletNumber}\label{wxtextattrexgetbulletnumber}
162
163 \constfunc{int}{GetBulletNumber}{\void}
164
165 Returns the bullet number.
166
167 \membersection{wxTextAttrEx::GetBulletStyle}\label{wxtextattrexgetbulletstyle}
168
169 \constfunc{int}{GetBulletStyle}{\void}
170
171 Returns the bullet style.
172 See \helpref{wxTextAttrEx::SetBulletStyle}{wxtextattrexsetbulletstyle} for a list of available styles.
173
174 \membersection{wxTextAttrEx::GetBulletText}\label{wxrichtextattrgetbullettext}
175
176 \constfunc{const wxString\&}{GetBulletText}{\void}
177
178 Returns the bullet text, which could be a symbol, or (for example) cached outline text.
179
180 \membersection{wxTextAttrEx::GetCharacterStyleName}\label{wxtextattrexgetcharacterstylename}
181
182 \constfunc{const wxString\&}{GetCharacterStyleName}{\void}
183
184 Returns the name of the character style.
185
186 \membersection{wxTextAttrEx::GetLineSpacing}\label{wxtextattrexgetlinespacing}
187
188 \constfunc{int}{GetLineSpacing}{\void}
189
190 Returns the line spacing value, one of wxTEXT\_ATTR\_LINE\_SPACING\_NORMAL,
191 wxTEXT\_ATTR\_LINE\_SPACING\_HALF, and wxTEXT\_ATTR\_LINE\_SPACING\_TWICE.
192
193 \membersection{wxTextAttrEx::GetListStyleName}\label{wxtextattrexgetliststylename}
194
195 \constfunc{const wxString\&}{GetListStyleName}{\void}
196
197 Returns the name of the list style.
198
199 \membersection{wxTextAttrEx::GetParagraphSpacingAfter}\label{wxtextattrexgetparagraphspacingafter}
200
201 \constfunc{int}{GetParagraphSpacingAfter}{\void}
202
203 Returns the space in tenths of a millimeter after the paragraph.
204
205 \membersection{wxTextAttrEx::GetParagraphSpacingBefore}\label{wxtextattrexgetparagraphspacingbefore}
206
207 \constfunc{int}{GetParagraphSpacingBefore}{\void}
208
209 Returns the space in tenths of a millimeter before the paragraph.
210
211 \membersection{wxTextAttrEx::GetParagraphStyleName}\label{wxtextattrexgetparagraphstylename}
212
213 \constfunc{const wxString\&}{GetParagraphStyleName}{\void}
214
215 Returns the name of the paragraph style.
216
217 \membersection{wxTextAttrEx::GetURL}\label{wxtextattrexgeturl}
218
219 \constfunc{const wxString\&}{GetURL}{\void}
220
221 Returns the URL for the content. Content with wxTEXT\_ATTR\_URL style
222 causes wxRichTextCtrl to show a hand cursor over it, and wxRichTextCtrl generates
223 a wxTextUrlEvent when the content is clicked.
224
225 \membersection{wxTextAttrEx::HasBulletName}\label{wxtextattrexhasbulletname}
226
227 \constfunc{bool}{HasBulletName}{\void}
228
229 Returns \true if the attribute object specifies a standard bullet name.
230
231 \membersection{wxTextAttrEx::HasBulletNumber}\label{wxtextattrexhasbulletnumber}
232
233 \constfunc{bool}{HasBulletNumber}{\void}
234
235 Returns \true if the attribute object specifies a bullet number.
236
237 \membersection{wxTextAttrEx::HasBulletStyle}\label{wxtextattrexhasbulletstyle}
238
239 \constfunc{bool}{HasBulletStyle}{\void}
240
241 Returns \true if the attribute object specifies a bullet style.
242
243 \membersection{wxTextAttrEx::HasBulletText}\label{wxtextattrexhasbullettext}
244
245 \constfunc{bool}{HasBulletText}{\void}
246
247 Returns \true if the attribute object specifies bullet text (usually containing a symbol).
248
249 \membersection{wxTextAttrEx::HasCharacterStyleName}\label{wxtextattrexhascharacterstylename}
250
251 \constfunc{bool}{HasCharacterStyleName}{\void}
252
253 Returns \true if the attribute object specifies a character style name.
254
255 \membersection{wxTextAttrEx::HasLineSpacing}\label{wxtextattrexhaslinespacing}
256
257 \constfunc{bool}{HasLineSpacing}{\void}
258
259 Returns \true if the attribute object specifies line spacing.
260
261 \membersection{wxTextAttrEx::HasListStyleName}\label{wxtextattrexhasliststylename}
262
263 \constfunc{bool}{HasListStyleName}{\void}
264
265 Returns \true if the attribute object specifies a list style name.
266
267 \membersection{wxTextAttrEx::HasParagraphSpacingAfter}\label{wxtextattrexhasparagraphspacingafter}
268
269 \constfunc{bool}{HasParagraphSpacingAfter}{\void}
270
271 Returns \true if the attribute object specifies spacing after a paragraph.
272
273 \membersection{wxTextAttrEx::HasParagraphSpacingBefore}\label{wxtextattrexhasparagraphspacingbefore}
274
275 \constfunc{bool}{HasParagraphSpacingBefore}{\void}
276
277 Returns \true if the attribute object specifies spacing before a paragraph.
278
279 \membersection{wxTextAttrEx::HasParagraphStyleName}\label{wxtextattrexhasparagraphstylename}
280
281 \constfunc{bool}{HasParagraphStyleName}{\void}
282
283 Returns \true if the attribute object specifies a paragraph style name.
284
285 \membersection{wxTextAttrEx::Init}\label{wxtextattrexinit}
286
287 \func{void}{Init}{\void}
288
289 Initialises this object.
290
291 \membersection{wxTextAttrEx::IsCharacterStyle}\label{wxtextattrexischaracterstyle}
292
293 \constfunc{bool}{IsCharacterStyle}{\void}
294
295 Returns \true if the object represents a character style, that is,
296 the flags specify a font or a text background or foreground colour.
297
298 \membersection{wxTextAttrEx::IsDefault}\label{wxtextattrexisdefault}
299
300 \constfunc{bool}{IsDefault}{\void}
301
302 Returns \false if we have any attributes set, \true otherwise.
303
304 \membersection{wxTextAttrEx::IsParagraphStyle}\label{wxtextattrexisparagraphstyle}
305
306 \constfunc{bool}{IsParagraphStyle}{\void}
307
308 Returns \true if the object represents a paragraph style, that is,
309 the flags specify alignment, indentation, tabs, paragraph spacing, or
310 bullet style.
311
312 \membersection{wxTextAttrEx::SetBulletFont}\label{wxtextattrexsetbulletfont}
313
314 \func{void}{SetBulletFont}{\param{const wxString\& }{font}}
315
316 Sets the name of the font associated with the bullet symbol.
317 Only valid for attributes with wxTEXT\_ATTR\_BULLET\_SYMBOL.
318
319 \membersection{wxTextAttrEx::SetBulletNumber}\label{wxtextattrexsetbulletnumber}
320
321 \func{void}{SetBulletNumber}{\param{int }{n}}
322
323 Sets the bullet number.
324
325 \membersection{wxTextAttrEx::SetBulletName}\label{wxtextattrexsetbulletname}
326
327 \func{void}{SetBulletName}{\param{const wxString\& }{name}}
328
329 Sets the standard bullet name, applicable if the bullet style is wxTEXT\_ATTR\_BULLET\_STYLE\_STANDARD.
330 See \helpref{wxTextAttrEx::GetBulletName}{wxtextattrexgetbulletname} for a list
331 of supported names, and how to expand the range of supported types.
332
333 \membersection{wxTextAttrEx::SetBulletStyle}\label{wxtextattrexsetbulletstyle}
334
335 \func{void}{SetBulletStyle}{\param{int }{style}}
336
337 Sets the bullet style. The following styles can be passed:
338
339 {\small
340 \begin{verbatim}
341 #define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000
342 #define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001
343 #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002
344 #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004
345 #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008
346 #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010
347 #define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020
348 #define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040
349 #define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080
350 #define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100
351 #define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200
352 #define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400
353 #define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800
354 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000
355 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000
356 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000
357 \end{verbatim}
358 }
359
360 \membersection{wxTextAttrEx::SetBulletText}\label{wxtextattrexsetbullettext}
361
362 \func{void}{SetBulletText}{\param{const wxString\& }{text}}
363
364 Sets the bullet text, which could be a symbol, or (for example) cached outline text.
365
366 \membersection{wxTextAttrEx::SetCharacterStyleName}\label{wxtextattrexsetcharacterstylename}
367
368 \func{void}{SetCharacterStyleName}{\param{const wxString\& }{name}}
369
370 Sets the character style name.
371
372 \membersection{wxTextAttrEx::SetLineSpacing}\label{wxtextattrexsetlinespacing}
373
374 \func{void}{SetLineSpacing}{\param{int }{spacing}}
375
376 Sets the line spacing. {\it spacing} is a multiple, where 10 means single-spacing,
377 15 means 1.5 spacing, and 20 means double spacing. The following constants are
378 defined for convenience:
379
380 {\small
381 \begin{verbatim}
382 #define wxTEXT_ATTR_LINE_SPACING_NORMAL 10
383 #define wxTEXT_ATTR_LINE_SPACING_HALF 15
384 #define wxTEXT_ATTR_LINE_SPACING_TWICE 20
385 \end{verbatim}
386 }
387
388 \membersection{wxTextAttrEx::SetListStyleName}\label{wxtextattrexsetliststylename}
389
390 \func{void}{SetListStyleName}{\param{const wxString\& }{name}}
391
392 Sets the list style name.
393
394 \membersection{wxTextAttrEx::SetParagraphSpacingAfter}\label{wxtextattrexsetparagraphspacingafter}
395
396 \func{void}{SetParagraphSpacingAfter}{\param{int }{spacing}}
397
398 Sets the spacing after a paragraph, in tenths of a millimetre.
399
400 \membersection{wxTextAttrEx::SetParagraphSpacingBefore}\label{wxtextattrexsetparagraphspacingbefore}
401
402 \func{void}{SetParagraphSpacingBefore}{\param{int }{spacing}}
403
404 Sets the spacing before a paragraph, in tenths of a millimetre.
405
406 \membersection{wxTextAttrEx::SetParagraphStyleName}\label{wxtextattrexsetparagraphstylename}
407
408 \func{void}{SetParagraphStyleName}{\param{const wxString\& }{name}}
409
410 Sets the name of the paragraph style.
411
412 \membersection{wxTextAttrEx::SetURL}\label{wxtextattrexseturl}
413
414 \func{void}{SetURL}{\param{const wxString\& }{url}}
415
416 Sets the URL for the content. Sets the wxTEXT\_ATTR\_URL style; content with this style
417 causes wxRichTextCtrl to show a hand cursor over it, and wxRichTextCtrl generates
418 a wxTextUrlEvent when the content is clicked.
419
420 \membersection{wxTextAttrEx::operator=}\label{wxtextattrexoperatorassign}
421
422 \func{void operator}{operator=}{\param{const wxTextAttr\& }{attr}}
423
424 Assignment from a wxTextAttr object.
425
426 \func{void operator}{operator=}{\param{const wxTextAttrEx\& }{attr}}
427
428 Assignment from a wxTextAttrEx object.
429