]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: textctrl.h | |
e54c96f1 | 3 | // Purpose: interface of wxTextAttr |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
0e8dff1b RD |
9 | /** |
10 | wxTextCtrl style flags | |
11 | */ | |
12 | #define wxTE_NO_VSCROLL 0x0002 | |
13 | ||
14 | #define wxTE_READONLY 0x0010 | |
15 | #define wxTE_MULTILINE 0x0020 | |
16 | #define wxTE_PROCESS_TAB 0x0040 | |
17 | ||
18 | // alignment flags | |
19 | #define wxTE_LEFT 0x0000 // 0x0000 | |
20 | #define wxTE_CENTER wxALIGN_CENTER_HORIZONTAL // 0x0100 | |
21 | #define wxTE_RIGHT wxALIGN_RIGHT // 0x0200 | |
22 | #define wxTE_CENTRE wxTE_CENTER | |
23 | ||
24 | // this style means to use RICHEDIT control and does something only under wxMSW | |
25 | // and Win32 and is silently ignored under all other platforms | |
26 | #define wxTE_RICH 0x0080 | |
27 | ||
28 | #define wxTE_PROCESS_ENTER 0x0400 | |
29 | #define wxTE_PASSWORD 0x0800 | |
30 | ||
31 | // automatically detect the URLs and generate the events when mouse is | |
32 | // moved/clicked over an URL | |
33 | // | |
34 | // this is for Win32 richedit and wxGTK2 multiline controls only so far | |
35 | #define wxTE_AUTO_URL 0x1000 | |
36 | ||
37 | // by default, the Windows text control doesn't show the selection when it | |
38 | // doesn't have focus - use this style to force it to always show it | |
39 | #define wxTE_NOHIDESEL 0x2000 | |
40 | ||
41 | // use wxHSCROLL to not wrap text at all, wxTE_CHARWRAP to wrap it at any | |
42 | // position and wxTE_WORDWRAP to wrap at words boundary | |
43 | // | |
44 | // if no wrapping style is given at all, the control wraps at word boundary | |
45 | #define wxTE_DONTWRAP wxHSCROLL | |
46 | #define wxTE_CHARWRAP 0x4000 // wrap at any position | |
47 | #define wxTE_WORDWRAP 0x0001 // wrap only at words boundaries | |
48 | #define wxTE_BESTWRAP 0x0000 // this is the default | |
49 | ||
50 | // force using RichEdit version 2.0 or 3.0 instead of 1.0 (default) for | |
51 | // wxTE_RICH controls - can be used together with or instead of wxTE_RICH | |
52 | #define wxTE_RICH2 0x8000 | |
53 | ||
54 | ||
55 | ||
56 | /** | |
57 | wxTextCoord is a line or row number | |
58 | */ | |
59 | typedef long wxTextCoord; | |
60 | ||
c6cf894a | 61 | |
c6cf894a | 62 | /** |
7d76fbd5 | 63 | One of the following values can be passed to wxTextAttr::SetAlignment to determine paragraph alignment. |
c6cf894a FM |
64 | */ |
65 | enum wxTextAttrAlignment | |
66 | { | |
67 | wxTEXT_ALIGNMENT_DEFAULT, | |
68 | wxTEXT_ALIGNMENT_LEFT, | |
69 | wxTEXT_ALIGNMENT_CENTRE, | |
70 | wxTEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE, | |
71 | wxTEXT_ALIGNMENT_RIGHT, | |
72 | ||
73 | /** wxTEXT_ALIGNMENT_JUSTIFIED is unimplemented. | |
74 | In future justification may be supported when printing or previewing, only. */ | |
75 | wxTEXT_ALIGNMENT_JUSTIFIED | |
76 | }; | |
77 | ||
78 | /** | |
79 | The following values are passed in a bitlist to wxTextAttr::SetFlags() to | |
80 | determine what attributes will be considered when setting the attributes for a text control. | |
81 | */ | |
82 | enum wxTextAttrFlags | |
83 | { | |
84 | wxTEXT_ATTR_TEXT_COLOUR = 0x00000001, | |
85 | wxTEXT_ATTR_BACKGROUND_COLOUR = 0x00000002, | |
7d76fbd5 | 86 | |
c6cf894a FM |
87 | wxTEXT_ATTR_FONT_FACE = 0x00000004, |
88 | wxTEXT_ATTR_FONT_SIZE = 0x00000008, | |
89 | wxTEXT_ATTR_FONT_WEIGHT = 0x00000010, | |
90 | wxTEXT_ATTR_FONT_ITALIC = 0x00000020, | |
91 | wxTEXT_ATTR_FONT_UNDERLINE = 0x00000040, | |
92 | wxTEXT_ATTR_FONT_ENCODING = 0x02000000, | |
9c4cb611 | 93 | wxTEXT_ATTR_FONT_FAMILY = 0x04000000, |
7d76fbd5 FM |
94 | |
95 | /** | |
96 | Defined as the combination of all @c wxTEXT_ATTR_FONT_* values above. | |
97 | */ | |
c6cf894a FM |
98 | wxTEXT_ATTR_FONT = \ |
99 | ( wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT | \ | |
9c4cb611 | 100 | wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE | wxTEXT_ATTR_FONT_ENCODING | wxTEXT_ATTR_FONT_FAMILY ), |
c6cf894a FM |
101 | |
102 | wxTEXT_ATTR_ALIGNMENT = 0x00000080, | |
103 | wxTEXT_ATTR_LEFT_INDENT = 0x00000100, | |
104 | wxTEXT_ATTR_RIGHT_INDENT = 0x00000200, | |
105 | wxTEXT_ATTR_TABS = 0x00000400, | |
c6cf894a FM |
106 | wxTEXT_ATTR_PARA_SPACING_AFTER = 0x00000800, |
107 | wxTEXT_ATTR_PARA_SPACING_BEFORE = 0x00001000, | |
108 | wxTEXT_ATTR_LINE_SPACING = 0x00002000, | |
109 | wxTEXT_ATTR_CHARACTER_STYLE_NAME = 0x00004000, | |
110 | wxTEXT_ATTR_PARAGRAPH_STYLE_NAME = 0x00008000, | |
111 | wxTEXT_ATTR_LIST_STYLE_NAME = 0x00010000, | |
7d76fbd5 | 112 | |
c6cf894a FM |
113 | wxTEXT_ATTR_BULLET_STYLE = 0x00020000, |
114 | wxTEXT_ATTR_BULLET_NUMBER = 0x00040000, | |
115 | wxTEXT_ATTR_BULLET_TEXT = 0x00080000, | |
116 | wxTEXT_ATTR_BULLET_NAME = 0x00100000, | |
7d76fbd5 FM |
117 | |
118 | /** | |
119 | Defined as the combination of all @c wxTEXT_ATTR_BULLET_* values above. | |
120 | */ | |
121 | wxTEXT_ATTR_BULLET = \ | |
122 | ( wxTEXT_ATTR_BULLET_STYLE | wxTEXT_ATTR_BULLET_NUMBER | wxTEXT_ATTR_BULLET_TEXT | \ | |
123 | wxTEXT_ATTR_BULLET_NAME ), | |
124 | ||
c6cf894a FM |
125 | wxTEXT_ATTR_URL = 0x00200000, |
126 | wxTEXT_ATTR_PAGE_BREAK = 0x00400000, | |
127 | wxTEXT_ATTR_EFFECTS = 0x00800000, | |
128 | wxTEXT_ATTR_OUTLINE_LEVEL = 0x01000000, | |
129 | ||
130 | /** | |
7d76fbd5 FM |
131 | Combines the styles @c wxTEXT_ATTR_FONT, @c wxTEXT_ATTR_EFFECTS, @c wxTEXT_ATTR_BACKGROUND_COLOUR, |
132 | @c wxTEXT_ATTR_TEXT_COLOUR, @c wxTEXT_ATTR_CHARACTER_STYLE_NAME, @c wxTEXT_ATTR_URL. | |
c6cf894a FM |
133 | */ |
134 | ||
135 | wxTEXT_ATTR_CHARACTER = \ | |
9c4cb611 | 136 | (wxTEXT_ATTR_FONT|wxTEXT_ATTR_EFFECTS| \ |
c6cf894a FM |
137 | wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL), |
138 | ||
7d76fbd5 FM |
139 | /** |
140 | Combines all the styles regarding text paragraphs. | |
141 | */ | |
c6cf894a FM |
142 | wxTEXT_ATTR_PARAGRAPH = \ |
143 | (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\ | |
144 | wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\ | |
7d76fbd5 | 145 | wxTEXT_ATTR_BULLET|wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL), |
c6cf894a | 146 | |
7d76fbd5 FM |
147 | /** |
148 | Combines all previous values. | |
149 | */ | |
c6cf894a FM |
150 | wxTEXT_ATTR_ALL = (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) |
151 | }; | |
152 | ||
153 | /** | |
7d76fbd5 | 154 | Styles for wxTextAttr::SetBulletStyle. They can be combined together as a bitlist. |
c6cf894a FM |
155 | */ |
156 | enum wxTextAttrBulletStyle | |
157 | { | |
158 | wxTEXT_ATTR_BULLET_STYLE_NONE = 0x00000000, | |
159 | wxTEXT_ATTR_BULLET_STYLE_ARABIC = 0x00000001, | |
160 | wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER = 0x00000002, | |
161 | wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER = 0x00000004, | |
162 | wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER = 0x00000008, | |
163 | wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER = 0x00000010, | |
164 | wxTEXT_ATTR_BULLET_STYLE_SYMBOL = 0x00000020, | |
165 | ||
166 | /** wxTEXT_ATTR_BULLET_STYLE_BITMAP is unimplemented. */ | |
167 | wxTEXT_ATTR_BULLET_STYLE_BITMAP = 0x00000040, | |
168 | wxTEXT_ATTR_BULLET_STYLE_PARENTHESES = 0x00000080, | |
169 | wxTEXT_ATTR_BULLET_STYLE_PERIOD = 0x00000100, | |
170 | wxTEXT_ATTR_BULLET_STYLE_STANDARD = 0x00000200, | |
171 | wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS = 0x00000400, | |
172 | wxTEXT_ATTR_BULLET_STYLE_OUTLINE = 0x00000800, | |
173 | ||
174 | wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT = 0x00000000, | |
175 | wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT = 0x00001000, | |
176 | wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE = 0x00002000 | |
177 | }; | |
178 | ||
179 | /** | |
7d76fbd5 | 180 | Styles for wxTextAttr::SetTextEffects(). They can be combined together as a bitlist. |
c6cf894a | 181 | |
75936ec6 JS |
182 | Of these, only wxTEXT_ATTR_EFFECT_CAPITALS, wxTEXT_ATTR_EFFECT_STRIKETHROUGH, |
183 | wxTEXT_ATTR_EFFECT_SUPERSCRIPT and wxTEXT_ATTR_EFFECT_SUBSCRIPT are implemented. | |
c6cf894a FM |
184 | */ |
185 | enum wxTextAttrEffects | |
186 | { | |
187 | wxTEXT_ATTR_EFFECT_NONE = 0x00000000, | |
188 | wxTEXT_ATTR_EFFECT_CAPITALS = 0x00000001, | |
189 | wxTEXT_ATTR_EFFECT_SMALL_CAPITALS = 0x00000002, | |
190 | wxTEXT_ATTR_EFFECT_STRIKETHROUGH = 0x00000004, | |
191 | wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH = 0x00000008, | |
192 | wxTEXT_ATTR_EFFECT_SHADOW = 0x00000010, | |
193 | wxTEXT_ATTR_EFFECT_EMBOSS = 0x00000020, | |
194 | wxTEXT_ATTR_EFFECT_OUTLINE = 0x00000040, | |
195 | wxTEXT_ATTR_EFFECT_ENGRAVE = 0x00000080, | |
196 | wxTEXT_ATTR_EFFECT_SUPERSCRIPT = 0x00000100, | |
197 | wxTEXT_ATTR_EFFECT_SUBSCRIPT = 0x00000200 | |
198 | }; | |
199 | ||
200 | /** | |
7d76fbd5 | 201 | Convenience line spacing values; see wxTextAttr::SetLineSpacing(). |
c6cf894a FM |
202 | */ |
203 | enum wxTextAttrLineSpacing | |
204 | { | |
205 | wxTEXT_ATTR_LINE_SPACING_NORMAL = 10, | |
206 | wxTEXT_ATTR_LINE_SPACING_HALF = 15, | |
207 | wxTEXT_ATTR_LINE_SPACING_TWICE = 20 | |
208 | }; | |
209 | ||
210 | ||
211 | /** | |
212 | Describes the possible return values of wxTextCtrl::HitTest(). | |
213 | ||
214 | The element names correspond to the relationship between the point asked | |
215 | for and the character returned, e.g. @c wxTE_HT_BEFORE means that the point | |
216 | is before (leftward or upward) it and so on. | |
217 | */ | |
218 | enum wxTextCtrlHitTestResult | |
219 | { | |
220 | /// Indicates that wxTextCtrl::HitTest() is not implemented on this | |
221 | /// platform. | |
222 | wxTE_HT_UNKNOWN = -2, | |
223 | ||
224 | /// The point is before the character returned. | |
225 | wxTE_HT_BEFORE, | |
226 | ||
227 | /// The point is directly on the character returned. | |
228 | wxTE_HT_ON_TEXT, | |
229 | ||
230 | /// The point is below the last line of the control. | |
231 | wxTE_HT_BELOW, | |
232 | ||
233 | /// The point is beyond the end of line containing the character returned. | |
234 | wxTE_HT_BEYOND | |
235 | }; | |
236 | ||
237 | ||
23324ae1 FM |
238 | /** |
239 | @class wxTextAttr | |
7c913512 | 240 | |
23324ae1 FM |
241 | wxTextAttr represents the character and paragraph attributes, or style, |
242 | for a range of text in a wxTextCtrl or wxRichTextCtrl. | |
7c913512 | 243 | |
23324ae1 | 244 | When setting up a wxTextAttr object, pass a bitlist mask to |
c6cf894a FM |
245 | wxTextAttr::SetFlags() to indicate which style elements should be changed. |
246 | As a convenience, when you call a setter such as SetFont, the relevant bit | |
756e6e49 | 247 | will be set. |
7c913512 | 248 | |
23324ae1 FM |
249 | @library{wxcore} |
250 | @category{richtext} | |
7c913512 | 251 | |
e54c96f1 | 252 | @see wxTextCtrl, wxRichTextCtrl |
23324ae1 | 253 | */ |
7c913512 | 254 | class wxTextAttr |
23324ae1 FM |
255 | { |
256 | public: | |
257 | //@{ | |
258 | /** | |
259 | Constructors. | |
260 | */ | |
261 | wxTextAttr(); | |
7c913512 FM |
262 | wxTextAttr(const wxColour& colText, |
263 | const wxColour& colBack = wxNullColour, | |
264 | const wxFont& font = wxNullFont, | |
265 | wxTextAttrAlignment alignment = wxTEXT_ALIGNMENT_DEFAULT); | |
266 | wxTextAttr(const wxTextAttr& attr); | |
23324ae1 FM |
267 | //@} |
268 | ||
269 | /** | |
4cc4bfaf FM |
270 | Applies the attributes in @a style to the original object, but not those |
271 | attributes from @a style that are the same as those in @a compareWith (if passed). | |
23324ae1 FM |
272 | */ |
273 | bool Apply(const wxTextAttr& style, | |
4cc4bfaf | 274 | const wxTextAttr* compareWith = NULL); |
23324ae1 | 275 | |
7d76fbd5 FM |
276 | /** |
277 | Copies all defined/valid properties from overlay to current object. | |
278 | */ | |
279 | void Merge(const wxTextAttr& overlay); | |
280 | ||
281 | /** | |
282 | Creates a new @c wxTextAttr which is a merge of @a base and @a overlay. | |
283 | ||
284 | Properties defined in @a overlay take precedence over those in @a base. | |
285 | Properties undefined/invalid in both are undefined in the result. | |
286 | */ | |
287 | static wxTextAttr Merge(const wxTextAttr& base, | |
288 | const wxTextAttr& overlay); | |
289 | ||
290 | ||
291 | /** | |
292 | @name GetXXX functions | |
293 | */ | |
294 | ||
295 | //@{ | |
296 | ||
23324ae1 FM |
297 | /** |
298 | Returns the alignment flags. | |
c6cf894a | 299 | See ::wxTextAttrAlignment for a list of available styles. |
23324ae1 | 300 | */ |
328f5751 | 301 | wxTextAttrAlignment GetAlignment() const; |
23324ae1 FM |
302 | |
303 | /** | |
304 | Returns the background colour. | |
305 | */ | |
c6cf894a | 306 | const wxColour& GetBackgroundColour() const; |
23324ae1 FM |
307 | |
308 | /** | |
c6cf894a | 309 | Returns a string containing the name of the font associated with the bullet symbol. |
23324ae1 FM |
310 | Only valid for attributes with wxTEXT_ATTR_BULLET_SYMBOL. |
311 | */ | |
c6cf894a | 312 | const wxString& GetBulletFont() const; |
23324ae1 FM |
313 | |
314 | /** | |
315 | Returns the standard bullet name, applicable if the bullet style is | |
316 | wxTEXT_ATTR_BULLET_STYLE_STANDARD. | |
c6cf894a | 317 | |
23324ae1 | 318 | Currently the following standard bullet names are supported: |
c6cf894a FM |
319 | - @c standard/circle |
320 | - @c standard/square | |
321 | - @c standard/diamond | |
322 | - @c standard/triangle | |
323 | ||
324 | @note | |
23324ae1 | 325 | For wxRichTextCtrl users only: if you wish your rich text controls to support |
c6cf894a FM |
326 | further bullet graphics, you can derive a class from wxRichTextRenderer or |
327 | wxRichTextStdRenderer, override @c DrawStandardBullet and @c EnumerateStandardBulletNames, | |
328 | and set an instance of the class using wxRichTextBuffer::SetRenderer. | |
23324ae1 | 329 | */ |
c6cf894a | 330 | const wxString& GetBulletName() const; |
23324ae1 FM |
331 | |
332 | /** | |
333 | Returns the bullet number. | |
334 | */ | |
328f5751 | 335 | int GetBulletNumber() const; |
23324ae1 FM |
336 | |
337 | /** | |
338 | Returns the bullet style. | |
c6cf894a | 339 | See ::wxTextAttrBulletStyle for a list of available styles. |
23324ae1 | 340 | */ |
328f5751 | 341 | int GetBulletStyle() const; |
23324ae1 FM |
342 | |
343 | /** | |
344 | Returns the bullet text, which could be a symbol, or (for example) cached | |
345 | outline text. | |
346 | */ | |
43c48e1e | 347 | const wxString& GetBulletText() const; |
23324ae1 FM |
348 | |
349 | /** | |
350 | Returns the name of the character style. | |
351 | */ | |
43c48e1e | 352 | const wxString& GetCharacterStyleName() const; |
23324ae1 FM |
353 | |
354 | /** | |
355 | Returns flags indicating which attributes are applicable. | |
356 | See SetFlags() for a list of available flags. | |
357 | */ | |
328f5751 | 358 | long GetFlags() const; |
23324ae1 FM |
359 | |
360 | /** | |
361 | Creates and returns a font specified by the font attributes in the wxTextAttr | |
c6cf894a FM |
362 | object. Note that wxTextAttr does not store a wxFont object, so this is only |
363 | a temporary font. | |
364 | ||
365 | For greater efficiency, access the font attributes directly. | |
23324ae1 | 366 | */ |
328f5751 | 367 | wxFont GetFont() const; |
23324ae1 FM |
368 | |
369 | /** | |
370 | Gets the font attributes from the given font, using only the attributes | |
756e6e49 | 371 | specified by @a flags. |
23324ae1 FM |
372 | */ |
373 | bool GetFontAttributes(const wxFont& font, | |
374 | int flags = wxTEXT_ATTR_FONT); | |
375 | ||
376 | /** | |
377 | Returns the font encoding. | |
378 | */ | |
328f5751 | 379 | wxFontEncoding GetFontEncoding() const; |
23324ae1 FM |
380 | |
381 | /** | |
382 | Returns the font face name. | |
383 | */ | |
43c48e1e | 384 | const wxString& GetFontFaceName() const; |
23324ae1 | 385 | |
9c4cb611 JS |
386 | /** |
387 | Returns the font family. | |
388 | */ | |
7d76fbd5 | 389 | wxFontFamily GetFontFamily() const; |
9c4cb611 | 390 | |
23324ae1 FM |
391 | /** |
392 | Returns the font size in points. | |
393 | */ | |
328f5751 | 394 | int GetFontSize() const; |
23324ae1 FM |
395 | |
396 | /** | |
397 | Returns the font style. | |
398 | */ | |
7d76fbd5 | 399 | wxFontStyle GetFontStyle() const; |
23324ae1 FM |
400 | |
401 | /** | |
402 | Returns @true if the font is underlined. | |
403 | */ | |
328f5751 | 404 | bool GetFontUnderlined() const; |
23324ae1 FM |
405 | |
406 | /** | |
407 | Returns the font weight. | |
408 | */ | |
7d76fbd5 | 409 | wxFontWeight GetFontWeight() const; |
23324ae1 FM |
410 | |
411 | /** | |
412 | Returns the left indent in tenths of a millimetre. | |
413 | */ | |
328f5751 | 414 | long GetLeftIndent() const; |
23324ae1 FM |
415 | |
416 | /** | |
417 | Returns the left sub-indent in tenths of a millimetre. | |
418 | */ | |
328f5751 | 419 | long GetLeftSubIndent() const; |
23324ae1 FM |
420 | |
421 | /** | |
c6cf894a | 422 | Returns the line spacing value, one of ::wxTextAttrLineSpacing values. |
23324ae1 | 423 | */ |
328f5751 | 424 | int GetLineSpacing() const; |
23324ae1 FM |
425 | |
426 | /** | |
427 | Returns the name of the list style. | |
428 | */ | |
43c48e1e | 429 | const wxString& GetListStyleName() const; |
23324ae1 FM |
430 | |
431 | /** | |
432 | Returns the outline level. | |
433 | */ | |
43c48e1e | 434 | int GetOutlineLevel() const; |
23324ae1 FM |
435 | |
436 | /** | |
437 | Returns the space in tenths of a millimeter after the paragraph. | |
438 | */ | |
328f5751 | 439 | int GetParagraphSpacingAfter() const; |
23324ae1 FM |
440 | |
441 | /** | |
442 | Returns the space in tenths of a millimeter before the paragraph. | |
443 | */ | |
328f5751 | 444 | int GetParagraphSpacingBefore() const; |
23324ae1 FM |
445 | |
446 | /** | |
447 | Returns the name of the paragraph style. | |
448 | */ | |
43c48e1e | 449 | const wxString& GetParagraphStyleName() const; |
23324ae1 FM |
450 | |
451 | /** | |
452 | Returns the right indent in tenths of a millimeter. | |
453 | */ | |
328f5751 | 454 | long GetRightIndent() const; |
23324ae1 FM |
455 | |
456 | /** | |
c6cf894a FM |
457 | Returns an array of tab stops, each expressed in tenths of a millimeter. |
458 | ||
459 | Each stop is measured from the left margin and therefore each value must | |
460 | be larger than the last. | |
23324ae1 | 461 | */ |
43c48e1e | 462 | const wxArrayInt& GetTabs() const; |
23324ae1 FM |
463 | |
464 | /** | |
465 | Returns the text foreground colour. | |
466 | */ | |
43c48e1e | 467 | const wxColour& GetTextColour() const; |
23324ae1 FM |
468 | |
469 | /** | |
c6cf894a FM |
470 | Returns the text effect bits of interest. |
471 | See SetFlags() for further information. | |
23324ae1 | 472 | */ |
328f5751 | 473 | int GetTextEffectFlags() const; |
23324ae1 FM |
474 | |
475 | /** | |
c6cf894a FM |
476 | Returns the text effects, a bit list of styles. |
477 | See SetTextEffects() for details. | |
23324ae1 | 478 | */ |
328f5751 | 479 | int GetTextEffects() const; |
23324ae1 FM |
480 | |
481 | /** | |
c6cf894a FM |
482 | Returns the URL for the content. |
483 | ||
484 | Content with @a wxTEXT_ATTR_URL style causes wxRichTextCtrl to show a | |
485 | hand cursor over it, and wxRichTextCtrl generates a wxTextUrlEvent | |
486 | when the content is clicked. | |
23324ae1 | 487 | */ |
43c48e1e | 488 | const wxString& GetURL() const; |
23324ae1 | 489 | |
7d76fbd5 FM |
490 | //@} |
491 | ||
492 | ||
493 | ||
494 | /** | |
495 | @name HasXXX and IsXXX functions | |
496 | */ | |
497 | ||
498 | //@{ | |
499 | ||
23324ae1 FM |
500 | /** |
501 | Returns @true if the attribute object specifies alignment. | |
502 | */ | |
328f5751 | 503 | bool HasAlignment() const; |
23324ae1 FM |
504 | |
505 | /** | |
506 | Returns @true if the attribute object specifies a background colour. | |
507 | */ | |
328f5751 | 508 | bool HasBackgroundColour() const; |
23324ae1 FM |
509 | |
510 | /** | |
511 | Returns @true if the attribute object specifies a standard bullet name. | |
512 | */ | |
328f5751 | 513 | bool HasBulletName() const; |
23324ae1 FM |
514 | |
515 | /** | |
516 | Returns @true if the attribute object specifies a bullet number. | |
517 | */ | |
328f5751 | 518 | bool HasBulletNumber() const; |
23324ae1 FM |
519 | |
520 | /** | |
521 | Returns @true if the attribute object specifies a bullet style. | |
522 | */ | |
328f5751 | 523 | bool HasBulletStyle() const; |
23324ae1 FM |
524 | |
525 | /** | |
526 | Returns @true if the attribute object specifies bullet text (usually | |
527 | specifying a symbol). | |
528 | */ | |
328f5751 | 529 | bool HasBulletText() const; |
23324ae1 FM |
530 | |
531 | /** | |
532 | Returns @true if the attribute object specifies a character style name. | |
533 | */ | |
328f5751 | 534 | bool HasCharacterStyleName() const; |
23324ae1 FM |
535 | |
536 | /** | |
4cc4bfaf | 537 | Returns @true if the @a flag is present in the attribute object's flag |
23324ae1 FM |
538 | bitlist. |
539 | */ | |
328f5751 | 540 | bool HasFlag(long flag) const; |
23324ae1 FM |
541 | |
542 | /** | |
543 | Returns @true if the attribute object specifies any font attributes. | |
544 | */ | |
328f5751 | 545 | bool HasFont() const; |
23324ae1 FM |
546 | |
547 | /** | |
548 | Returns @true if the attribute object specifies an encoding. | |
549 | */ | |
328f5751 | 550 | bool HasFontEncoding() const; |
23324ae1 FM |
551 | |
552 | /** | |
553 | Returns @true if the attribute object specifies a font face name. | |
554 | */ | |
328f5751 | 555 | bool HasFontFaceName() const; |
23324ae1 | 556 | |
9c4cb611 JS |
557 | /** |
558 | Returns @true if the attribute object specifies a font family. | |
559 | */ | |
560 | bool HasFontFamily() const; | |
561 | ||
23324ae1 FM |
562 | /** |
563 | Returns @true if the attribute object specifies italic style. | |
564 | */ | |
328f5751 | 565 | bool HasFontItalic() const; |
23324ae1 FM |
566 | |
567 | /** | |
568 | Returns @true if the attribute object specifies a font point size. | |
569 | */ | |
328f5751 | 570 | bool HasFontSize() const; |
23324ae1 FM |
571 | |
572 | /** | |
573 | Returns @true if the attribute object specifies either underlining or no | |
574 | underlining. | |
575 | */ | |
328f5751 | 576 | bool HasFontUnderlined() const; |
23324ae1 FM |
577 | |
578 | /** | |
579 | Returns @true if the attribute object specifies font weight (bold, light or | |
580 | normal). | |
581 | */ | |
328f5751 | 582 | bool HasFontWeight() const; |
23324ae1 FM |
583 | |
584 | /** | |
585 | Returns @true if the attribute object specifies a left indent. | |
586 | */ | |
328f5751 | 587 | bool HasLeftIndent() const; |
23324ae1 FM |
588 | |
589 | /** | |
590 | Returns @true if the attribute object specifies line spacing. | |
591 | */ | |
328f5751 | 592 | bool HasLineSpacing() const; |
23324ae1 FM |
593 | |
594 | /** | |
595 | Returns @true if the attribute object specifies a list style name. | |
596 | */ | |
328f5751 | 597 | bool HasListStyleName() const; |
23324ae1 FM |
598 | |
599 | /** | |
600 | Returns @true if the attribute object specifies an outline level. | |
601 | */ | |
328f5751 | 602 | bool HasOutlineLevel() const; |
23324ae1 FM |
603 | |
604 | /** | |
605 | Returns @true if the attribute object specifies a page break before this | |
606 | paragraph. | |
607 | */ | |
328f5751 | 608 | bool HasPageBreak() const; |
23324ae1 FM |
609 | |
610 | /** | |
611 | Returns @true if the attribute object specifies spacing after a paragraph. | |
612 | */ | |
328f5751 | 613 | bool HasParagraphSpacingAfter() const; |
23324ae1 FM |
614 | |
615 | /** | |
616 | Returns @true if the attribute object specifies spacing before a paragraph. | |
617 | */ | |
328f5751 | 618 | bool HasParagraphSpacingBefore() const; |
23324ae1 FM |
619 | |
620 | /** | |
621 | Returns @true if the attribute object specifies a paragraph style name. | |
622 | */ | |
328f5751 | 623 | bool HasParagraphStyleName() const; |
23324ae1 FM |
624 | |
625 | /** | |
626 | Returns @true if the attribute object specifies a right indent. | |
627 | */ | |
328f5751 | 628 | bool HasRightIndent() const; |
23324ae1 FM |
629 | |
630 | /** | |
631 | Returns @true if the attribute object specifies tab stops. | |
632 | */ | |
328f5751 | 633 | bool HasTabs() const; |
23324ae1 FM |
634 | |
635 | /** | |
636 | Returns @true if the attribute object specifies a text foreground colour. | |
637 | */ | |
328f5751 | 638 | bool HasTextColour() const; |
23324ae1 FM |
639 | |
640 | /** | |
641 | Returns @true if the attribute object specifies text effects. | |
642 | */ | |
328f5751 | 643 | bool HasTextEffects() const; |
23324ae1 FM |
644 | |
645 | /** | |
646 | Returns @true if the attribute object specifies a URL. | |
647 | */ | |
328f5751 | 648 | bool HasURL() const; |
23324ae1 FM |
649 | |
650 | /** | |
651 | Returns @true if the object represents a character style, that is, | |
652 | the flags specify a font or a text background or foreground colour. | |
653 | */ | |
328f5751 | 654 | bool IsCharacterStyle() const; |
23324ae1 FM |
655 | |
656 | /** | |
657 | Returns @false if we have any attributes set, @true otherwise. | |
658 | */ | |
328f5751 | 659 | bool IsDefault() const; |
23324ae1 FM |
660 | |
661 | /** | |
662 | Returns @true if the object represents a paragraph style, that is, | |
663 | the flags specify alignment, indentation, tabs, paragraph spacing, or | |
664 | bullet style. | |
665 | */ | |
328f5751 | 666 | bool IsParagraphStyle() const; |
23324ae1 | 667 | |
7d76fbd5 FM |
668 | //@} |
669 | ||
c6cf894a FM |
670 | |
671 | /** | |
7d76fbd5 FM |
672 | @name SetXXX functions |
673 | */ | |
c6cf894a | 674 | |
7d76fbd5 | 675 | //@{ |
23324ae1 FM |
676 | |
677 | /** | |
c6cf894a | 678 | Sets the paragraph alignment. See ::wxTextAttrAlignment enumeration values. |
3c4f71cc | 679 | |
c6cf894a FM |
680 | Of these, wxTEXT_ALIGNMENT_JUSTIFIED is unimplemented. |
681 | In future justification may be supported when printing or previewing, only. | |
23324ae1 FM |
682 | */ |
683 | void SetAlignment(wxTextAttrAlignment alignment); | |
684 | ||
685 | /** | |
686 | Sets the background colour. | |
687 | */ | |
688 | void SetBackgroundColour(const wxColour& colBack); | |
689 | ||
690 | /** | |
691 | Sets the name of the font associated with the bullet symbol. | |
692 | Only valid for attributes with wxTEXT_ATTR_BULLET_SYMBOL. | |
693 | */ | |
694 | void SetBulletFont(const wxString& font); | |
695 | ||
696 | /** | |
697 | Sets the standard bullet name, applicable if the bullet style is | |
698 | wxTEXT_ATTR_BULLET_STYLE_STANDARD. | |
c6cf894a FM |
699 | |
700 | See GetBulletName() for a list of supported names, and how | |
701 | to expand the range of supported types. | |
23324ae1 FM |
702 | */ |
703 | void SetBulletName(const wxString& name); | |
704 | ||
705 | /** | |
706 | Sets the bullet number. | |
707 | */ | |
708 | void SetBulletNumber(int n); | |
709 | ||
710 | /** | |
c6cf894a | 711 | Sets the bullet style. |
3c4f71cc | 712 | |
c6cf894a FM |
713 | The ::wxTextAttrBulletStyle enumeration values are all supported, |
714 | except for wxTEXT_ATTR_BULLET_STYLE_BITMAP. | |
23324ae1 FM |
715 | */ |
716 | void SetBulletStyle(int style); | |
717 | ||
718 | /** | |
c6cf894a FM |
719 | Sets the bullet text, which could be a symbol, or (for example) cached |
720 | outline text. | |
23324ae1 | 721 | */ |
43c48e1e | 722 | void SetBulletText(const wxString& text); |
23324ae1 FM |
723 | |
724 | /** | |
725 | Sets the character style name. | |
726 | */ | |
727 | void SetCharacterStyleName(const wxString& name); | |
728 | ||
729 | /** | |
c6cf894a FM |
730 | Sets the flags determining which styles are being specified. |
731 | The ::wxTextAttrFlags values can be passed in a bitlist. | |
23324ae1 FM |
732 | */ |
733 | void SetFlags(long flags); | |
734 | ||
735 | /** | |
c6cf894a FM |
736 | Sets the attributes for the given font. |
737 | Note that wxTextAttr does not store an actual wxFont object. | |
23324ae1 | 738 | */ |
43c48e1e | 739 | void SetFont(const wxFont& font, int flags = wxTEXT_ATTR_FONT); |
23324ae1 FM |
740 | |
741 | /** | |
742 | Sets the font encoding. | |
743 | */ | |
744 | void SetFontEncoding(wxFontEncoding encoding); | |
745 | ||
746 | /** | |
9c4cb611 | 747 | Sets the font face name. |
23324ae1 FM |
748 | */ |
749 | void SetFontFaceName(const wxString& faceName); | |
750 | ||
9c4cb611 JS |
751 | /** |
752 | Sets the font family. | |
753 | */ | |
7d76fbd5 | 754 | void SetFontFamily(wxFontFamily family); |
9c4cb611 | 755 | |
23324ae1 FM |
756 | /** |
757 | Sets the font size in points. | |
758 | */ | |
759 | void SetFontSize(int pointSize); | |
760 | ||
761 | /** | |
762 | Sets the font style (normal, italic or slanted). | |
763 | */ | |
7d76fbd5 | 764 | void SetFontStyle(wxFontStyle fontStyle); |
23324ae1 FM |
765 | |
766 | /** | |
767 | Sets the font underlining. | |
768 | */ | |
769 | void SetFontUnderlined(bool underlined); | |
770 | ||
771 | /** | |
772 | Sets the font weight. | |
773 | */ | |
7d76fbd5 | 774 | void SetFontWeight(wxFontWeight fontWeight); |
23324ae1 FM |
775 | |
776 | /** | |
777 | Sets the left indent and left subindent in tenths of a millimetre. | |
23324ae1 | 778 | The sub-indent is an offset from the left of the paragraph, and is used for all |
c6cf894a FM |
779 | but the first line in a paragraph. |
780 | ||
781 | A positive value will cause the first line to appear to the left | |
23324ae1 | 782 | of the subsequent lines, and a negative value will cause the first line to be |
c6cf894a FM |
783 | indented relative to the subsequent lines. |
784 | ||
785 | wxRichTextBuffer uses indentation to render a bulleted item. | |
786 | The left indent is the distance between the margin and the bullet. | |
787 | The content of the paragraph, including the first line, starts | |
788 | at leftMargin + leftSubIndent. | |
789 | So the distance between the left edge of the bullet and the | |
23324ae1 FM |
790 | left of the actual paragraph is leftSubIndent. |
791 | */ | |
792 | void SetLeftIndent(int indent, int subIndent = 0); | |
793 | ||
794 | /** | |
4cc4bfaf | 795 | Sets the line spacing. @a spacing is a multiple, where 10 means single-spacing, |
c6cf894a FM |
796 | 15 means 1.5 spacing, and 20 means double spacing. |
797 | The ::wxTextAttrLineSpacing values are defined for convenience. | |
23324ae1 FM |
798 | */ |
799 | void SetLineSpacing(int spacing); | |
800 | ||
801 | /** | |
802 | Sets the list style name. | |
803 | */ | |
804 | void SetListStyleName(const wxString& name); | |
805 | ||
806 | /** | |
c6cf894a FM |
807 | Specifies the outline level. Zero represents normal text. |
808 | At present, the outline level is not used, but may be used in future for | |
809 | determining list levels and for applications that need to store document | |
810 | structure information. | |
23324ae1 FM |
811 | */ |
812 | void SetOutlineLevel(int level); | |
813 | ||
814 | /** | |
815 | Specifies a page break before this paragraph. | |
816 | */ | |
4cc4bfaf | 817 | void SetPageBreak(bool pageBreak = true); |
23324ae1 FM |
818 | |
819 | /** | |
820 | Sets the spacing after a paragraph, in tenths of a millimetre. | |
821 | */ | |
822 | void SetParagraphSpacingAfter(int spacing); | |
823 | ||
824 | /** | |
825 | Sets the spacing before a paragraph, in tenths of a millimetre. | |
826 | */ | |
827 | void SetParagraphSpacingBefore(int spacing); | |
828 | ||
829 | /** | |
830 | Sets the name of the paragraph style. | |
831 | */ | |
832 | void SetParagraphStyleName(const wxString& name); | |
833 | ||
834 | /** | |
835 | Sets the right indent in tenths of a millimetre. | |
836 | */ | |
837 | void SetRightIndent(int indent); | |
838 | ||
839 | /** | |
840 | Sets the tab stops, expressed in tenths of a millimetre. | |
841 | Each stop is measured from the left margin and therefore each value must be | |
842 | larger than the last. | |
843 | */ | |
844 | void SetTabs(const wxArrayInt& tabs); | |
845 | ||
846 | /** | |
d13b34d3 | 847 | Sets the text foreground colour. |
23324ae1 FM |
848 | */ |
849 | void SetTextColour(const wxColour& colText); | |
850 | ||
851 | /** | |
c6cf894a FM |
852 | Sets the text effect bits of interest. |
853 | ||
854 | You should also pass wxTEXT_ATTR_EFFECTS to SetFlags(). | |
23324ae1 FM |
855 | See SetFlags() for further information. |
856 | */ | |
857 | void SetTextEffectFlags(int flags); | |
858 | ||
859 | /** | |
860 | Sets the text effects, a bit list of styles. | |
c6cf894a | 861 | The ::wxTextAttrEffects enumeration values can be used. |
3c4f71cc | 862 | |
75936ec6 JS |
863 | Of these, only wxTEXT_ATTR_EFFECT_CAPITALS, wxTEXT_ATTR_EFFECT_STRIKETHROUGH, |
864 | wxTEXT_ATTR_EFFECT_SUPERSCRIPT and wxTEXT_ATTR_EFFECT_SUBSCRIPT are implemented. | |
c6cf894a | 865 | |
23324ae1 | 866 | wxTEXT_ATTR_EFFECT_CAPITALS capitalises text when displayed (leaving the case |
c6cf894a FM |
867 | of the actual buffer text unchanged), and wxTEXT_ATTR_EFFECT_STRIKETHROUGH draws |
868 | a line through text. | |
869 | ||
23324ae1 | 870 | To set effects, you should also pass wxTEXT_ATTR_EFFECTS to SetFlags(), and call |
c6cf894a FM |
871 | SetTextEffectFlags() with the styles (taken from the above set) that you |
872 | are interested in setting. | |
23324ae1 FM |
873 | */ |
874 | void SetTextEffects(int effects); | |
875 | ||
876 | /** | |
877 | Sets the URL for the content. Sets the wxTEXT_ATTR_URL style; content with this | |
c6cf894a FM |
878 | style causes wxRichTextCtrl to show a hand cursor over it, and wxRichTextCtrl |
879 | generates a wxTextUrlEvent when the content is clicked. | |
23324ae1 | 880 | */ |
4cc4bfaf | 881 | void SetURL(const wxString& url); |
23324ae1 | 882 | |
7d76fbd5 FM |
883 | //@} |
884 | ||
885 | ||
23324ae1 FM |
886 | /** |
887 | Assignment from a wxTextAttr object. | |
888 | */ | |
0e8dff1b | 889 | void operator=(const wxTextAttr& attr); |
23324ae1 FM |
890 | }; |
891 | ||
e54c96f1 | 892 | |
23324ae1 FM |
893 | /** |
894 | @class wxTextCtrl | |
7c913512 | 895 | |
756e6e49 VZ |
896 | A text control allows text to be displayed and edited. |
897 | ||
2e7789a9 VZ |
898 | It may be single line or multi-line. Notice that a lot of methods of the |
899 | text controls are found in the base wxTextEntry class which is a common | |
900 | base class for wxTextCtrl and other controls using a single line text entry | |
901 | field (e.g. wxComboBox). | |
7c913512 | 902 | |
23324ae1 | 903 | @beginStyleTable |
8c6791e4 | 904 | @style{wxTE_PROCESS_ENTER} |
3a194bda | 905 | The control will generate the event @c wxEVT_COMMAND_TEXT_ENTER |
23324ae1 FM |
906 | (otherwise pressing Enter key is either processed internally by the |
907 | control or used for navigation between dialog controls). | |
8c6791e4 | 908 | @style{wxTE_PROCESS_TAB} |
3a194bda | 909 | The control will receive @c wxEVT_CHAR events for TAB pressed - |
23324ae1 FM |
910 | normally, TAB is used for passing to the next control in a dialog |
911 | instead. For the control created with this style, you can still use | |
912 | Ctrl-Enter to pass to the next control from the keyboard. | |
8c6791e4 | 913 | @style{wxTE_MULTILINE} |
d911dc04 VZ |
914 | The text control allows multiple lines. If this style is not |
915 | specified, line break characters should not be used in the controls | |
916 | value. | |
8c6791e4 | 917 | @style{wxTE_PASSWORD} |
23324ae1 | 918 | The text will be echoed as asterisks. |
8c6791e4 | 919 | @style{wxTE_READONLY} |
23324ae1 | 920 | The text will not be user-editable. |
8c6791e4 | 921 | @style{wxTE_RICH} |
23324ae1 FM |
922 | Use rich text control under Win32, this allows to have more than |
923 | 64KB of text in the control even under Win9x. This style is ignored | |
924 | under other platforms. | |
8c6791e4 | 925 | @style{wxTE_RICH2} |
23324ae1 FM |
926 | Use rich text control version 2.0 or 3.0 under Win32, this style is |
927 | ignored under other platforms | |
8c6791e4 | 928 | @style{wxTE_AUTO_URL} |
23324ae1 FM |
929 | Highlight the URLs and generate the wxTextUrlEvents when mouse |
930 | events occur over them. This style is only supported for wxTE_RICH | |
931 | Win32 and multi-line wxGTK2 text controls. | |
8c6791e4 | 932 | @style{wxTE_NOHIDESEL} |
23324ae1 FM |
933 | By default, the Windows text control doesn't show the selection |
934 | when it doesn't have focus - use this style to force it to always | |
935 | show it. It doesn't do anything under other platforms. | |
8c6791e4 | 936 | @style{wxHSCROLL} |
23324ae1 FM |
937 | A horizontal scrollbar will be created and used, so that text won't |
938 | be wrapped. No effect under wxGTK1. | |
8c6791e4 | 939 | @style{wxTE_NO_VSCROLL} |
23324ae1 FM |
940 | For multiline controls only: vertical scrollbar will never be |
941 | created. This limits the amount of text which can be entered into | |
942 | the control to what can be displayed in it under MSW but not under | |
943 | GTK2. Currently not implemented for the other platforms. | |
8c6791e4 | 944 | @style{wxTE_LEFT} |
23324ae1 | 945 | The text in the control will be left-justified (default). |
8c6791e4 | 946 | @style{wxTE_CENTRE} |
23324ae1 FM |
947 | The text in the control will be centered (currently wxMSW and |
948 | wxGTK2 only). | |
8c6791e4 | 949 | @style{wxTE_RIGHT} |
23324ae1 FM |
950 | The text in the control will be right-justified (currently wxMSW |
951 | and wxGTK2 only). | |
8c6791e4 | 952 | @style{wxTE_DONTWRAP} |
23324ae1 FM |
953 | Same as wxHSCROLL style: don't wrap at all, show horizontal |
954 | scrollbar instead. | |
8c6791e4 | 955 | @style{wxTE_CHARWRAP} |
23324ae1 FM |
956 | Wrap the lines too long to be shown entirely at any position |
957 | (wxUniv and wxGTK2 only). | |
8c6791e4 | 958 | @style{wxTE_WORDWRAP} |
23324ae1 FM |
959 | Wrap the lines too long to be shown entirely at word boundaries |
960 | (wxUniv and wxGTK2 only). | |
8c6791e4 | 961 | @style{wxTE_BESTWRAP} |
23324ae1 FM |
962 | Wrap the lines at word boundaries or at any other character if |
963 | there are words longer than the window width (this is the default). | |
8c6791e4 | 964 | @style{wxTE_CAPITALIZE} |
23324ae1 FM |
965 | On PocketPC and Smartphone, causes the first letter to be |
966 | capitalized. | |
967 | @endStyleTable | |
7c913512 | 968 | |
c6cf894a FM |
969 | Note that alignment styles (wxTE_LEFT, wxTE_CENTRE and wxTE_RIGHT) can be |
970 | changed dynamically after control creation on wxMSW and wxGTK. wxTE_READONLY, | |
971 | wxTE_PASSWORD and wrapping styles can be dynamically changed under wxGTK but | |
972 | not wxMSW. The other styles can be only set during control creation. | |
973 | ||
756e6e49 VZ |
974 | |
975 | @section textctrl_text_format wxTextCtrl Text Format | |
976 | ||
977 | The multiline text controls always store the text as a sequence of lines | |
978 | separated by @c '\\n' characters, i.e. in the Unix text format even on | |
979 | non-Unix platforms. This allows the user code to ignore the differences | |
980 | between the platforms but at a price: the indices in the control such as | |
981 | those returned by GetInsertionPoint() or GetSelection() can @b not be used | |
982 | as indices into the string returned by GetValue() as they're going to be | |
983 | slightly off for platforms using @c "\\r\\n" as separator (as Windows | |
984 | does). | |
985 | ||
986 | Instead, if you need to obtain a substring between the 2 indices obtained | |
987 | from the control with the help of the functions mentioned above, you should | |
988 | use GetRange(). And the indices themselves can only be passed to other | |
989 | methods, for example SetInsertionPoint() or SetSelection(). | |
990 | ||
991 | To summarize: never use the indices returned by (multiline) wxTextCtrl as | |
992 | indices into the string it contains, but only as arguments to be passed | |
993 | back to the other wxTextCtrl methods. This problem doesn't arise for | |
994 | single-line platforms however where the indices in the control do | |
995 | correspond to the positions in the value string. | |
996 | ||
997 | ||
998 | @section textctrl_styles wxTextCtrl Styles. | |
999 | ||
1000 | Multi-line text controls support styling, i.e. provide a possibility to set | |
1001 | colours and font for individual characters in it (note that under Windows | |
1002 | @c wxTE_RICH style is required for style support). To use the styles you | |
1003 | can either call SetDefaultStyle() before inserting the text or call | |
1004 | SetStyle() later to change the style of the text already in the control | |
1005 | (the first solution is much more efficient). | |
1006 | ||
1007 | In either case, if the style doesn't specify some of the attributes (for | |
1008 | example you only want to set the text colour but without changing the font | |
1009 | nor the text background), the values of the default style will be used for | |
1010 | them. If there is no default style, the attributes of the text control | |
1011 | itself are used. | |
1012 | ||
1013 | So the following code correctly describes what it does: the second call to | |
1014 | SetDefaultStyle() doesn't change the text foreground colour (which stays | |
1015 | red) while the last one doesn't change the background colour (which stays | |
1016 | grey): | |
1017 | ||
1018 | @code | |
1019 | text->SetDefaultStyle(wxTextAttr(*wxRED)); | |
1020 | text->AppendText("Red text\n"); | |
1021 | text->SetDefaultStyle(wxTextAttr(wxNullColour, *wxLIGHT_GREY)); | |
1022 | text->AppendText("Red on grey text\n"); | |
1023 | text->SetDefaultStyle(wxTextAttr(*wxBLUE); | |
1024 | text->AppendText("Blue on grey text\n"); | |
1025 | @endcode | |
1026 | ||
1027 | ||
1028 | @section textctrl_cpp_streams wxTextCtrl and C++ Streams | |
1029 | ||
1030 | This class multiply-inherits from @c std::streambuf (except for some really | |
1031 | old compilers using non-standard iostream library), allowing code such as | |
1032 | the following: | |
1033 | ||
1034 | @code | |
1035 | wxTextCtrl *control = new wxTextCtrl(...); | |
1036 | ||
1037 | ostream stream(control) | |
1038 | ||
1039 | stream << 123.456 << " some text\n"; | |
1040 | stream.flush(); | |
1041 | @endcode | |
1042 | ||
1043 | Note that even if your compiler doesn't support this (the symbol | |
1044 | @c wxHAS_TEXT_WINDOW_STREAM has value of 0 then) you can still use | |
1045 | wxTextCtrl itself in a stream-like manner: | |
1046 | ||
1047 | @code | |
1048 | wxTextCtrl *control = new wxTextCtrl(...); | |
1049 | ||
1050 | *control << 123.456 << " some text\n"; | |
1051 | @endcode | |
1052 | ||
1053 | However the possibility to create an ostream associated with wxTextCtrl may | |
1054 | be useful if you need to redirect the output of a function taking an | |
1055 | ostream as parameter to a text control. | |
1056 | ||
1057 | Another commonly requested need is to redirect @c std::cout to the text | |
1058 | control. This may be done in the following way: | |
1059 | ||
1060 | @code | |
1061 | #include <iostream> | |
1062 | ||
1063 | wxTextCtrl *control = new wxTextCtrl(...); | |
1064 | ||
1065 | std::streambuf *sbOld = std::cout.rdbuf(); | |
1066 | std::cout.rdbuf(control); | |
1067 | ||
1068 | // use cout as usual, the output appears in the text control | |
1069 | ... | |
1070 | ||
1071 | std::cout.rdbuf(sbOld); | |
1072 | @endcode | |
1073 | ||
1074 | But wxWidgets provides a convenient class to make it even simpler so | |
1075 | instead you may just do | |
1076 | ||
1077 | @code | |
1078 | #include <iostream> | |
1079 | ||
1080 | wxTextCtrl *control = new wxTextCtrl(...); | |
1081 | ||
1082 | wxStreamToTextRedirector redirect(control); | |
1083 | ||
1084 | // all output to cout goes into the text control until the exit from | |
1085 | // current scope | |
1086 | @endcode | |
1087 | ||
1088 | See wxStreamToTextRedirector for more details. | |
1089 | ||
1090 | ||
1091 | @section textctrl_event_handling Event Handling. | |
1092 | ||
1093 | The following commands are processed by default event handlers in | |
1094 | wxTextCtrl: @c wxID_CUT, @c wxID_COPY, @c wxID_PASTE, @c wxID_UNDO, @c | |
1095 | wxID_REDO. The associated UI update events are also processed | |
1096 | automatically, when the control has the focus. | |
1097 | ||
3051a44a | 1098 | @beginEventEmissionTable{wxCommandEvent} |
756e6e49 | 1099 | @event{EVT_TEXT(id, func)} |
3a194bda | 1100 | Respond to a @c wxEVT_COMMAND_TEXT_UPDATED event, generated when the text |
756e6e49 VZ |
1101 | changes. Notice that this event will be sent when the text controls |
1102 | contents changes -- whether this is due to user input or comes from the | |
c6cf894a FM |
1103 | program itself (for example, if wxTextCtrl::SetValue() is called); see |
1104 | wxTextCtrl::ChangeValue() for a function which does not send this event. | |
1105 | This event is however not sent during the control creation. | |
756e6e49 | 1106 | @event{EVT_TEXT_ENTER(id, func)} |
3a194bda | 1107 | Respond to a @c wxEVT_COMMAND_TEXT_ENTER event, generated when enter is |
756e6e49 VZ |
1108 | pressed in a text control which must have wxTE_PROCESS_ENTER style for |
1109 | this event to be generated. | |
e36df657 | 1110 | @event{EVT_TEXT_URL(id, func)} |
756e6e49 VZ |
1111 | A mouse event occurred over an URL in the text control (wxMSW and |
1112 | wxGTK2 only currently). | |
e36df657 | 1113 | @event{EVT_TEXT_MAXLEN(id, func)} |
756e6e49 | 1114 | This event is generated when the user tries to enter more text into the |
c6cf894a | 1115 | control than the limit set by wxTextCtrl::SetMaxLength(), see its description. |
756e6e49 VZ |
1116 | @endEventTable |
1117 | ||
23324ae1 FM |
1118 | @library{wxcore} |
1119 | @category{ctrl} | |
7e59b885 | 1120 | @appearance{textctrl.png} |
7c913512 | 1121 | |
e54c96f1 | 1122 | @see wxTextCtrl::Create, wxValidator |
23324ae1 | 1123 | */ |
2e7789a9 VZ |
1124 | class wxTextCtrl : public wxControl, |
1125 | public wxTextEntry | |
23324ae1 FM |
1126 | { |
1127 | public: | |
e36df657 | 1128 | /** |
c6cf894a | 1129 | Default ctor. |
e36df657 | 1130 | */ |
c6cf894a | 1131 | wxTextCtrl(); |
e36df657 | 1132 | |
23324ae1 FM |
1133 | /** |
1134 | Constructor, creating and showing a text control. | |
3c4f71cc | 1135 | |
7c913512 | 1136 | @param parent |
4cc4bfaf | 1137 | Parent window. Should not be @NULL. |
7c913512 | 1138 | @param id |
4cc4bfaf | 1139 | Control identifier. A value of -1 denotes a default value. |
7c913512 | 1140 | @param value |
4cc4bfaf | 1141 | Default text value. |
7c913512 | 1142 | @param pos |
4cc4bfaf | 1143 | Text control position. |
7c913512 | 1144 | @param size |
4cc4bfaf | 1145 | Text control size. |
7c913512 | 1146 | @param style |
4cc4bfaf | 1147 | Window style. See wxTextCtrl. |
7c913512 | 1148 | @param validator |
4cc4bfaf | 1149 | Window validator. |
7c913512 | 1150 | @param name |
4cc4bfaf | 1151 | Window name. |
3c4f71cc | 1152 | |
c6cf894a FM |
1153 | @remarks |
1154 | The horizontal scrollbar (wxHSCROLL style flag) will only be | |
756e6e49 VZ |
1155 | created for multi-line text controls. Without a horizontal |
1156 | scrollbar, text lines that don't fit in the control's size will be | |
c6cf894a FM |
1157 | wrapped (but no newline character is inserted). |
1158 | Single line controls don't have a horizontal scrollbar, the text is | |
1159 | automatically scrolled so that the insertion point is always visible. | |
3c4f71cc | 1160 | |
4cc4bfaf | 1161 | @see Create(), wxValidator |
23324ae1 | 1162 | */ |
7c913512 | 1163 | wxTextCtrl(wxWindow* parent, wxWindowID id, |
ccf39540 | 1164 | const wxString& value = wxEmptyString, |
7c913512 FM |
1165 | const wxPoint& pos = wxDefaultPosition, |
1166 | const wxSize& size = wxDefaultSize, | |
1167 | long style = 0, | |
1168 | const wxValidator& validator = wxDefaultValidator, | |
1169 | const wxString& name = wxTextCtrlNameStr); | |
23324ae1 FM |
1170 | |
1171 | /** | |
1172 | Destructor, destroying the text control. | |
1173 | */ | |
adaaa686 | 1174 | virtual ~wxTextCtrl(); |
23324ae1 | 1175 | |
23324ae1 | 1176 | /** |
756e6e49 VZ |
1177 | Creates the text control for two-step construction. |
1178 | ||
1179 | This method should be called if the default constructor was used for | |
1180 | the control creation. Its parameters have the same meaning as for the | |
1181 | non-default constructor. | |
23324ae1 FM |
1182 | */ |
1183 | bool Create(wxWindow* parent, wxWindowID id, | |
43c48e1e | 1184 | const wxString& value = wxEmptyString, |
23324ae1 | 1185 | const wxPoint& pos = wxDefaultPosition, |
43c48e1e | 1186 | const wxSize& size = wxDefaultSize, long style = 0, |
23324ae1 FM |
1187 | const wxValidator& validator = wxDefaultValidator, |
1188 | const wxString& name = wxTextCtrlNameStr); | |
1189 | ||
1190 | /** | |
1191 | Copies the selected text to the clipboard and removes the selection. | |
1192 | */ | |
4cc4bfaf | 1193 | virtual void Cut(); |
23324ae1 FM |
1194 | |
1195 | /** | |
756e6e49 VZ |
1196 | Resets the internal modified flag as if the current changes had been |
1197 | saved. | |
23324ae1 | 1198 | */ |
adaaa686 | 1199 | virtual void DiscardEdits(); |
23324ae1 FM |
1200 | |
1201 | /** | |
2e7789a9 | 1202 | This function inserts into the control the character which would have |
756e6e49 VZ |
1203 | been inserted if the given key event had occurred in the text control. |
1204 | ||
c6cf894a FM |
1205 | The @a event object should be the same as the one passed to @c EVT_KEY_DOWN |
1206 | handler previously by wxWidgets. Please note that this function doesn't | |
1207 | currently work correctly for all keys under any platform but MSW. | |
3c4f71cc | 1208 | |
756e6e49 | 1209 | @return |
c6cf894a | 1210 | @true if the event resulted in a change to the control, @false otherwise. |
23324ae1 | 1211 | */ |
adaaa686 | 1212 | virtual bool EmulateKeyPress(const wxKeyEvent& event); |
23324ae1 FM |
1213 | |
1214 | /** | |
1215 | Returns the style currently used for the new text. | |
3c4f71cc | 1216 | |
4cc4bfaf | 1217 | @see SetDefaultStyle() |
23324ae1 | 1218 | */ |
43c48e1e | 1219 | virtual const wxTextAttr& GetDefaultStyle() const; |
23324ae1 | 1220 | |
23324ae1 | 1221 | /** |
756e6e49 VZ |
1222 | Gets the length of the specified line, not including any trailing |
1223 | newline character(s). | |
3c4f71cc | 1224 | |
7c913512 | 1225 | @param lineNo |
4cc4bfaf | 1226 | Line number (starting from zero). |
3c4f71cc | 1227 | |
756e6e49 VZ |
1228 | @return |
1229 | The length of the line, or -1 if @a lineNo was invalid. | |
23324ae1 | 1230 | */ |
adaaa686 | 1231 | virtual int GetLineLength(long lineNo) const; |
23324ae1 FM |
1232 | |
1233 | /** | |
1234 | Returns the contents of a given line in the text control, not including | |
1235 | any trailing newline character(s). | |
3c4f71cc | 1236 | |
7c913512 | 1237 | @param lineNo |
4cc4bfaf | 1238 | The line number, starting from zero. |
3c4f71cc | 1239 | |
756e6e49 VZ |
1240 | @return |
1241 | The contents of the line. | |
23324ae1 | 1242 | */ |
adaaa686 | 1243 | virtual wxString GetLineText(long lineNo) const; |
23324ae1 FM |
1244 | |
1245 | /** | |
1246 | Returns the number of lines in the text control buffer. | |
3c4f71cc | 1247 | |
567e5e47 VZ |
1248 | The returned number is the number of logical lines, i.e. just the count |
1249 | of the number of newline characters in the control + 1, for wxGTK and | |
1250 | wxOSX/Cocoa ports while it is the number of physical lines, i.e. the | |
1251 | count of lines actually shown in the control, in wxMSW and wxOSX/Carbon. | |
1252 | Because of this discrepancy, it is not recommended to use this function. | |
1253 | ||
c6cf894a FM |
1254 | @remarks |
1255 | Note that even empty text controls have one line (where the | |
1256 | insertion point is), so GetNumberOfLines() never returns 0. | |
23324ae1 | 1257 | */ |
adaaa686 | 1258 | virtual int GetNumberOfLines() const; |
23324ae1 | 1259 | |
23324ae1 | 1260 | /** |
756e6e49 VZ |
1261 | Returns the style at this position in the text control. |
1262 | ||
1263 | Not all platforms support this function. | |
3c4f71cc | 1264 | |
756e6e49 VZ |
1265 | @return |
1266 | @true on success, @false if an error occurred (this may also mean | |
1267 | that the styles are not supported under this platform). | |
3c4f71cc | 1268 | |
4cc4bfaf | 1269 | @see SetStyle(), wxTextAttr |
23324ae1 | 1270 | */ |
adaaa686 | 1271 | virtual bool GetStyle(long position, wxTextAttr& style); |
23324ae1 | 1272 | |
621d922f | 1273 | //@{ |
23324ae1 | 1274 | /** |
756e6e49 VZ |
1275 | This function finds the character at the specified position expressed |
1276 | in pixels. | |
1277 | ||
621d922f VZ |
1278 | The two overloads of this method allow to find either the position of |
1279 | the character, as an index into the text control contents, or its row | |
1280 | and column. | |
1281 | ||
756e6e49 | 1282 | If the return code is not @c wxTE_HT_UNKNOWN the row and column of the |
621d922f VZ |
1283 | character closest to this position are returned, otherwise the output |
1284 | parameters are not modified. | |
1285 | ||
1286 | Please note that this function is currently only implemented in wxUniv, | |
1287 | wxMSW and wxGTK2 ports and always returns @c wxTE_HT_UNKNOWN in the | |
1288 | other ports. | |
3c4f71cc | 1289 | |
1058f652 MB |
1290 | @beginWxPerlOnly |
1291 | In wxPerl this function takes only the @a pt argument and | |
1292 | returns a 3-element list (result, col, row). | |
1293 | @endWxPerlOnly | |
1294 | ||
621d922f VZ |
1295 | @param pt |
1296 | The position of the point to check, in window device coordinates. | |
1297 | @param col | |
1298 | Receives the column of the character at the given position. May be | |
1299 | @NULL. | |
1300 | @param row | |
1301 | Receives the row of the character at the given position. May be | |
1302 | @NULL. | |
1303 | @param pos | |
1304 | Receives the position of the character at the given position. May | |
1305 | be @NULL. | |
1306 | ||
4cc4bfaf | 1307 | @see PositionToXY(), XYToPosition() |
23324ae1 | 1308 | */ |
621d922f | 1309 | wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const; |
23324ae1 | 1310 | wxTextCtrlHitTestResult HitTest(const wxPoint& pt, |
621d922f VZ |
1311 | wxTextCoord *col, |
1312 | wxTextCoord *row) const; | |
1313 | //@} | |
23324ae1 | 1314 | |
23324ae1 | 1315 | /** |
756e6e49 VZ |
1316 | Returns @true if the text has been modified by user. |
1317 | ||
1318 | Note that calling SetValue() doesn't make the control modified. | |
3c4f71cc | 1319 | |
4cc4bfaf | 1320 | @see MarkDirty() |
23324ae1 | 1321 | */ |
adaaa686 | 1322 | virtual bool IsModified() const; |
23324ae1 FM |
1323 | |
1324 | /** | |
c6cf894a | 1325 | Returns @true if this is a multi line edit control and @false otherwise. |
3c4f71cc | 1326 | |
4cc4bfaf | 1327 | @see IsSingleLine() |
23324ae1 | 1328 | */ |
328f5751 | 1329 | bool IsMultiLine() const; |
23324ae1 FM |
1330 | |
1331 | /** | |
c6cf894a | 1332 | Returns @true if this is a single line edit control and @false otherwise. |
3c4f71cc | 1333 | |
c6cf894a | 1334 | @see IsSingleLine(), IsMultiLine() |
23324ae1 | 1335 | */ |
328f5751 | 1336 | bool IsSingleLine() const; |
23324ae1 FM |
1337 | |
1338 | /** | |
1339 | Loads and displays the named file, if it exists. | |
3c4f71cc | 1340 | |
7c913512 | 1341 | @param filename |
4cc4bfaf | 1342 | The filename of the file to load. |
7c913512 | 1343 | @param fileType |
4cc4bfaf | 1344 | The type of file to load. This is currently ignored in wxTextCtrl. |
3c4f71cc | 1345 | |
756e6e49 VZ |
1346 | @return |
1347 | @true if successful, @false otherwise. | |
23324ae1 FM |
1348 | */ |
1349 | bool LoadFile(const wxString& filename, | |
1350 | int fileType = wxTEXT_TYPE_ANY); | |
1351 | ||
1352 | /** | |
1353 | Mark text as modified (dirty). | |
3c4f71cc | 1354 | |
4cc4bfaf | 1355 | @see IsModified() |
23324ae1 | 1356 | */ |
adaaa686 | 1357 | virtual void MarkDirty(); |
23324ae1 FM |
1358 | |
1359 | /** | |
756e6e49 VZ |
1360 | This event handler function implements default drag and drop behaviour, |
1361 | which is to load the first dropped file into the control. | |
3c4f71cc | 1362 | |
7c913512 | 1363 | @param event |
4cc4bfaf | 1364 | The drop files event. |
3c4f71cc | 1365 | |
23324ae1 | 1366 | @remarks This is not implemented on non-Windows platforms. |
3c4f71cc | 1367 | |
4cc4bfaf | 1368 | @see wxDropFilesEvent |
23324ae1 FM |
1369 | */ |
1370 | void OnDropFiles(wxDropFilesEvent& event); | |
1371 | ||
23324ae1 FM |
1372 | /** |
1373 | Converts given position to a zero-based column, line number pair. | |
3c4f71cc | 1374 | |
7c913512 | 1375 | @param pos |
4cc4bfaf | 1376 | Position. |
7c913512 | 1377 | @param x |
4cc4bfaf | 1378 | Receives zero based column number. |
7c913512 | 1379 | @param y |
4cc4bfaf | 1380 | Receives zero based line number. |
3c4f71cc | 1381 | |
756e6e49 VZ |
1382 | @return |
1383 | @true on success, @false on failure (most likely due to a too large | |
1384 | position parameter). | |
3c4f71cc | 1385 | |
1058f652 MB |
1386 | @beginWxPerlOnly |
1387 | In wxPerl this function takes only the @a pos argument and | |
1388 | returns a 2-element list (x, y). | |
1389 | @endWxPerlOnly | |
1390 | ||
4cc4bfaf | 1391 | @see XYToPosition() |
23324ae1 | 1392 | */ |
adaaa686 | 1393 | virtual bool PositionToXY(long pos, long* x, long* y) const; |
6ce83213 VZ |
1394 | |
1395 | /** | |
1396 | Converts given text position to client coordinates in pixels. | |
1397 | ||
1398 | This function allows to find where is the character at the given | |
1399 | position displayed in the text control. | |
1400 | ||
1401 | @onlyfor{wxmsw,wxgtk}. Additionally, wxGTK only implements this method | |
1402 | for multiline controls and ::wxDefaultPosition is always returned for | |
1403 | the single line ones. | |
1404 | ||
1405 | @param pos | |
1406 | Text position in 0 to GetLastPosition() range (inclusive). | |
1407 | @return | |
1408 | On success returns a wxPoint which contains client coordinates for | |
1409 | the given position in pixels, otherwise returns ::wxDefaultPosition. | |
1410 | ||
1411 | @since 2.9.3 | |
1412 | ||
1413 | @see XYToPosition(), PositionToXY() | |
1414 | */ | |
1415 | wxPoint PositionToCoords(long pos) const; | |
23324ae1 | 1416 | |
23324ae1 FM |
1417 | /** |
1418 | Saves the contents of the control in a text file. | |
3c4f71cc | 1419 | |
7c913512 | 1420 | @param filename |
4cc4bfaf | 1421 | The name of the file in which to save the text. |
7c913512 | 1422 | @param fileType |
4cc4bfaf | 1423 | The type of file to save. This is currently ignored in wxTextCtrl. |
3c4f71cc | 1424 | |
756e6e49 VZ |
1425 | @return |
1426 | @true if the operation was successful, @false otherwise. | |
23324ae1 | 1427 | */ |
43c48e1e | 1428 | bool SaveFile(const wxString& filename = wxEmptyString, |
23324ae1 FM |
1429 | int fileType = wxTEXT_TYPE_ANY); |
1430 | ||
1431 | /** | |
756e6e49 VZ |
1432 | Changes the default style to use for the new text which is going to be |
1433 | added to the control using WriteText() or AppendText(). | |
1434 | ||
23324ae1 | 1435 | If either of the font, foreground, or background colour is not set in |
756e6e49 VZ |
1436 | @a style, the values of the previous default style are used for them. |
1437 | If the previous default style didn't set them neither, the global font | |
c6cf894a FM |
1438 | or colours of the text control itself are used as fall back. |
1439 | ||
1440 | However if the @a style parameter is the default wxTextAttr, then the default | |
756e6e49 | 1441 | style is just reset (instead of being combined with the new style which |
23324ae1 | 1442 | wouldn't change it at all). |
3c4f71cc | 1443 | |
7c913512 | 1444 | @param style |
4cc4bfaf | 1445 | The style for the new text. |
3c4f71cc | 1446 | |
756e6e49 VZ |
1447 | @return |
1448 | @true on success, @false if an error occurred (this may also mean | |
1449 | that the styles are not supported under this platform). | |
3c4f71cc | 1450 | |
4cc4bfaf | 1451 | @see GetDefaultStyle() |
23324ae1 | 1452 | */ |
adaaa686 | 1453 | virtual bool SetDefaultStyle(const wxTextAttr& style); |
23324ae1 | 1454 | |
23324ae1 FM |
1455 | /** |
1456 | Marks the control as being modified by the user or not. | |
3c4f71cc | 1457 | |
4cc4bfaf | 1458 | @see MarkDirty(), DiscardEdits() |
23324ae1 FM |
1459 | */ |
1460 | void SetModified(bool modified); | |
1461 | ||
23324ae1 | 1462 | /** |
756e6e49 VZ |
1463 | Changes the style of the given range. |
1464 | ||
1465 | If any attribute within @a style is not set, the corresponding | |
1466 | attribute from GetDefaultStyle() is used. | |
3c4f71cc | 1467 | |
7c913512 | 1468 | @param start |
4cc4bfaf | 1469 | The start of the range to change. |
7c913512 | 1470 | @param end |
4cc4bfaf | 1471 | The end of the range to change. |
7c913512 | 1472 | @param style |
4cc4bfaf | 1473 | The new style for the range. |
3c4f71cc | 1474 | |
756e6e49 VZ |
1475 | @return |
1476 | @true on success, @false if an error occurred (this may also mean | |
1477 | that the styles are not supported under this platform). | |
3c4f71cc | 1478 | |
4cc4bfaf | 1479 | @see GetStyle(), wxTextAttr |
23324ae1 | 1480 | */ |
adaaa686 | 1481 | virtual bool SetStyle(long start, long end, const wxTextAttr& style); |
23324ae1 | 1482 | |
23324ae1 FM |
1483 | /** |
1484 | Makes the line containing the given position visible. | |
3c4f71cc | 1485 | |
7c913512 | 1486 | @param pos |
4cc4bfaf | 1487 | The position that should be visible. |
23324ae1 | 1488 | */ |
adaaa686 | 1489 | virtual void ShowPosition(long pos); |
23324ae1 | 1490 | |
23324ae1 FM |
1491 | /** |
1492 | Converts the given zero based column and line number to a position. | |
3c4f71cc | 1493 | |
7c913512 | 1494 | @param x |
4cc4bfaf | 1495 | The column number. |
7c913512 | 1496 | @param y |
4cc4bfaf | 1497 | The line number. |
3c4f71cc | 1498 | |
756e6e49 VZ |
1499 | @return |
1500 | The position value, or -1 if x or y was invalid. | |
23324ae1 | 1501 | */ |
adaaa686 | 1502 | virtual long XYToPosition(long x, long y) const; |
23324ae1 FM |
1503 | |
1504 | //@{ | |
1505 | /** | |
9e50ed28 | 1506 | Operator definitions for appending to a text control. |
756e6e49 VZ |
1507 | |
1508 | These operators can be used as with the standard C++ streams, for | |
1509 | example: | |
1510 | @code | |
1511 | wxTextCtrl *wnd = new wxTextCtrl(my_frame); | |
1512 | ||
1513 | (*wnd) << "Welcome to text control number " << 1 << ".\n"; | |
1514 | @endcode | |
9e50ed28 | 1515 | */ |
756e6e49 | 1516 | |
9e50ed28 VZ |
1517 | wxTextCtrl& operator<<(const wxString& s); |
1518 | wxTextCtrl& operator<<(int i); | |
1519 | wxTextCtrl& operator<<(long i); | |
1520 | wxTextCtrl& operator<<(float f); | |
1521 | wxTextCtrl& operator<<(double d); | |
1522 | wxTextCtrl& operator<<(char c); | |
1523 | wxTextCtrl& operator<<(wchar_t c); | |
23324ae1 FM |
1524 | //@} |
1525 | }; | |
1526 | ||
1527 | ||
e54c96f1 | 1528 | |
23324ae1 FM |
1529 | /** |
1530 | @class wxStreamToTextRedirector | |
7c913512 | 1531 | |
23324ae1 FM |
1532 | This class can be used to (temporarily) redirect all output sent to a C++ |
1533 | ostream object to a wxTextCtrl instead. | |
7c913512 | 1534 | |
c6cf894a FM |
1535 | @note |
1536 | Some compilers and/or build configurations don't support multiply | |
1537 | inheriting wxTextCtrl from @c std::streambuf in which case this class is | |
1538 | not compiled in. | |
1539 | You also must have @c wxUSE_STD_IOSTREAM option on (i.e. set to 1) in your | |
1540 | @c setup.h to be able to use it. Under Unix, specify @c --enable-std_iostreams | |
1541 | switch when running configure for this. | |
7c913512 | 1542 | |
23324ae1 | 1543 | Example of usage: |
7c913512 | 1544 | |
23324ae1 FM |
1545 | @code |
1546 | using namespace std; | |
d00029b2 BP |
1547 | wxTextCtrl* text = new wxTextCtrl(...); |
1548 | { | |
23324ae1 | 1549 | wxStreamToTextRedirector redirect(text); |
7c913512 | 1550 | |
23324ae1 | 1551 | // this goes to the text control |
d00029b2 BP |
1552 | cout << "Hello, text!" << endl; |
1553 | } | |
1554 | // this goes somewhere else, presumably to stdout | |
1555 | cout << "Hello, console!" << endl; | |
23324ae1 | 1556 | @endcode |
7c913512 | 1557 | |
23324ae1 FM |
1558 | @library{wxcore} |
1559 | @category{logging} | |
7c913512 | 1560 | |
e54c96f1 | 1561 | @see wxTextCtrl |
23324ae1 | 1562 | */ |
7c913512 | 1563 | class wxStreamToTextRedirector |
23324ae1 FM |
1564 | { |
1565 | public: | |
1566 | /** | |
756e6e49 VZ |
1567 | The constructor starts redirecting output sent to @a ostr or @a cout for |
1568 | the default parameter value to the text control @a text. | |
3c4f71cc | 1569 | |
7c913512 | 1570 | @param text |
4cc4bfaf | 1571 | The text control to append output too, must be non-@NULL |
7c913512 | 1572 | @param ostr |
4cc4bfaf | 1573 | The C++ stream to redirect, cout is used if it is @NULL |
23324ae1 | 1574 | */ |
11e3af6e | 1575 | wxStreamToTextRedirector(wxTextCtrl *text, ostream* ostr); |
23324ae1 FM |
1576 | |
1577 | /** | |
1578 | When a wxStreamToTextRedirector object is destroyed, the redirection is ended | |
1579 | and any output sent to the C++ ostream which had been specified at the time of | |
1580 | the object construction will go to its original destination. | |
1581 | */ | |
1582 | ~wxStreamToTextRedirector(); | |
1583 | }; | |
e54c96f1 | 1584 |