]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/richtext/richtextbuffer.h | |
3 | // Purpose: Buffer for wxRichTextCtrl | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2005-09-30 | |
7 | // Copyright: (c) Julian Smart | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #ifndef _WX_RICHTEXTBUFFER_H_ | |
12 | #define _WX_RICHTEXTBUFFER_H_ | |
13 | ||
14 | /* | |
15 | ||
16 | Data structures | |
17 | =============== | |
18 | ||
19 | Data is represented by a hierarchy of objects, all derived from | |
20 | wxRichTextObject. | |
21 | ||
22 | The top of the hierarchy is the buffer, a kind of wxRichTextParagraphLayoutBox. | |
23 | These boxes will allow flexible placement of text boxes on a page, but | |
24 | for now there is a single box representing the document, and this box is | |
25 | a wxRichTextParagraphLayoutBox which contains further wxRichTextParagraph | |
26 | objects, each of which can include text and images. | |
27 | ||
28 | Each object maintains a range (start and end position) measured | |
29 | from the start of the main parent box. | |
30 | A paragraph object knows its range, and a text fragment knows its range | |
31 | too. So, a character or image in a page has a position relative to the | |
32 | start of the document, and a character in an embedded text box has | |
33 | a position relative to that text box. For now, we will not be dealing with | |
34 | embedded objects but it's something to bear in mind for later. | |
35 | ||
36 | Note that internally, a range (5,5) represents a range of one character. | |
37 | In the public wx[Rich]TextCtrl API, this would be passed to e.g. SetSelection | |
38 | as (5,6). A paragraph with one character might have an internal range of (0, 1) | |
39 | since the end of the paragraph takes up one position. | |
40 | ||
41 | Layout | |
42 | ====== | |
43 | ||
44 | When Layout is called on an object, it is given a size which the object | |
45 | must limit itself to, or one or more flexible directions (vertical | |
46 | or horizontal). So for example a centered paragraph is given the page | |
47 | width to play with (minus any margins), but can extend indefinitely | |
48 | in the vertical direction. The implementation of Layout can then | |
49 | cache the calculated size and position within the parent. | |
50 | ||
51 | */ | |
52 | ||
53 | /*! | |
54 | * Includes | |
55 | */ | |
56 | ||
57 | #include "wx/defs.h" | |
58 | ||
59 | #if wxUSE_RICHTEXT | |
60 | ||
61 | #include "wx/list.h" | |
62 | #include "wx/textctrl.h" | |
63 | #include "wx/bitmap.h" | |
64 | #include "wx/image.h" | |
65 | #include "wx/cmdproc.h" | |
66 | #include "wx/txtstrm.h" | |
67 | #include "wx/variant.h" | |
68 | #include "wx/position.h" | |
69 | ||
70 | #if wxUSE_DATAOBJ | |
71 | #include "wx/dataobj.h" | |
72 | #endif | |
73 | ||
74 | // Compatibility | |
75 | //#define wxRichTextAttr wxTextAttr | |
76 | #define wxTextAttrEx wxTextAttr | |
77 | ||
78 | // Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a | |
79 | // caret reliably without using wxClientDC in case there | |
80 | // are platform-specific problems with the generic caret. | |
81 | #if defined(__WXGTK__) || defined(__WXMAC__) | |
82 | #define wxRICHTEXT_USE_OWN_CARET 1 | |
83 | #else | |
84 | #define wxRICHTEXT_USE_OWN_CARET 0 | |
85 | #endif | |
86 | ||
87 | // Switch off for binary compatibility, on for faster drawing | |
88 | // Note: this seems to be buggy (overzealous use of extents) so | |
89 | // don't use for now | |
90 | #define wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING 0 | |
91 | ||
92 | // The following two symbols determine whether an output implementation | |
93 | // is present. To switch the relevant one on, set wxRICHTEXT_USE_XMLDOCUMENT_OUTPUT in | |
94 | // richtextxml.cpp. By default, the faster direct output implementation is used. | |
95 | ||
96 | // Include the wxXmlDocument implementation for output | |
97 | #define wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT 1 | |
98 | ||
99 | // Include the faster, direct implementation for output | |
100 | #define wxRICHTEXT_HAVE_DIRECT_OUTPUT 1 | |
101 | ||
102 | /** | |
103 | The line break character that can be embedded in content. | |
104 | */ | |
105 | ||
106 | extern WXDLLIMPEXP_RICHTEXT const wxChar wxRichTextLineBreakChar; | |
107 | ||
108 | /** | |
109 | File types in wxRichText context. | |
110 | */ | |
111 | enum wxRichTextFileType | |
112 | { | |
113 | wxRICHTEXT_TYPE_ANY = 0, | |
114 | wxRICHTEXT_TYPE_TEXT, | |
115 | wxRICHTEXT_TYPE_XML, | |
116 | wxRICHTEXT_TYPE_HTML, | |
117 | wxRICHTEXT_TYPE_RTF, | |
118 | wxRICHTEXT_TYPE_PDF | |
119 | }; | |
120 | ||
121 | /* | |
122 | * Forward declarations | |
123 | */ | |
124 | ||
125 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCtrl; | |
126 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObject; | |
127 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextImage; | |
128 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextPlainText; | |
129 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCacheObject; | |
130 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObjectList; | |
131 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextLine; | |
132 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraph; | |
133 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFileHandler; | |
134 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextDrawingHandler; | |
135 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextField; | |
136 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFieldType; | |
137 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleSheet; | |
138 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextListStyleDefinition; | |
139 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextEvent; | |
140 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextRenderer; | |
141 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextBuffer; | |
142 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextXMLHandler; | |
143 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraphLayoutBox; | |
144 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextImageBlock; | |
145 | class WXDLLIMPEXP_FWD_XML wxXmlNode; | |
146 | class wxRichTextFloatCollector; | |
147 | class WXDLLIMPEXP_FWD_BASE wxDataInputStream; | |
148 | class WXDLLIMPEXP_FWD_BASE wxDataOutputStream; | |
149 | ||
150 | /** | |
151 | Flags determining the available space, passed to Layout. | |
152 | */ | |
153 | ||
154 | #define wxRICHTEXT_FIXED_WIDTH 0x01 | |
155 | #define wxRICHTEXT_FIXED_HEIGHT 0x02 | |
156 | #define wxRICHTEXT_VARIABLE_WIDTH 0x04 | |
157 | #define wxRICHTEXT_VARIABLE_HEIGHT 0x08 | |
158 | ||
159 | // Only lay out the part of the buffer that lies within | |
160 | // the rect passed to Layout. | |
161 | #define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10 | |
162 | ||
163 | /** | |
164 | Flags to pass to Draw | |
165 | */ | |
166 | ||
167 | // Ignore paragraph cache optimization, e.g. for printing purposes | |
168 | // where one line may be drawn higher (on the next page) compared | |
169 | // with the previous line | |
170 | #define wxRICHTEXT_DRAW_IGNORE_CACHE 0x01 | |
171 | #define wxRICHTEXT_DRAW_SELECTED 0x02 | |
172 | #define wxRICHTEXT_DRAW_PRINT 0x04 | |
173 | #define wxRICHTEXT_DRAW_GUIDELINES 0x08 | |
174 | ||
175 | /** | |
176 | Flags returned from hit-testing, or passed to hit-test function. | |
177 | */ | |
178 | enum wxRichTextHitTestFlags | |
179 | { | |
180 | // The point was not on this object | |
181 | wxRICHTEXT_HITTEST_NONE = 0x01, | |
182 | ||
183 | // The point was before the position returned from HitTest | |
184 | wxRICHTEXT_HITTEST_BEFORE = 0x02, | |
185 | ||
186 | // The point was after the position returned from HitTest | |
187 | wxRICHTEXT_HITTEST_AFTER = 0x04, | |
188 | ||
189 | // The point was on the position returned from HitTest | |
190 | wxRICHTEXT_HITTEST_ON = 0x08, | |
191 | ||
192 | // The point was on space outside content | |
193 | wxRICHTEXT_HITTEST_OUTSIDE = 0x10, | |
194 | ||
195 | // Only do hit-testing at the current level (don't traverse into top-level objects) | |
196 | wxRICHTEXT_HITTEST_NO_NESTED_OBJECTS = 0x20, | |
197 | ||
198 | // Ignore floating objects | |
199 | wxRICHTEXT_HITTEST_NO_FLOATING_OBJECTS = 0x40, | |
200 | ||
201 | // Don't recurse into objects marked as atomic | |
202 | wxRICHTEXT_HITTEST_HONOUR_ATOMIC = 0x80 | |
203 | }; | |
204 | ||
205 | /** | |
206 | Flags for GetRangeSize. | |
207 | */ | |
208 | ||
209 | #define wxRICHTEXT_FORMATTED 0x01 | |
210 | #define wxRICHTEXT_UNFORMATTED 0x02 | |
211 | #define wxRICHTEXT_CACHE_SIZE 0x04 | |
212 | #define wxRICHTEXT_HEIGHT_ONLY 0x08 | |
213 | ||
214 | /** | |
215 | Flags for SetStyle/SetListStyle. | |
216 | */ | |
217 | ||
218 | #define wxRICHTEXT_SETSTYLE_NONE 0x00 | |
219 | ||
220 | // Specifies that this operation should be undoable | |
221 | #define wxRICHTEXT_SETSTYLE_WITH_UNDO 0x01 | |
222 | ||
223 | // Specifies that the style should not be applied if the | |
224 | // combined style at this point is already the style in question. | |
225 | #define wxRICHTEXT_SETSTYLE_OPTIMIZE 0x02 | |
226 | ||
227 | // Specifies that the style should only be applied to paragraphs, | |
228 | // and not the content. This allows content styling to be | |
229 | // preserved independently from that of e.g. a named paragraph style. | |
230 | #define wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY 0x04 | |
231 | ||
232 | // Specifies that the style should only be applied to characters, | |
233 | // and not the paragraph. This allows content styling to be | |
234 | // preserved independently from that of e.g. a named paragraph style. | |
235 | #define wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY 0x08 | |
236 | ||
237 | // For SetListStyle only: specifies starting from the given number, otherwise | |
238 | // deduces number from existing attributes | |
239 | #define wxRICHTEXT_SETSTYLE_RENUMBER 0x10 | |
240 | ||
241 | // For SetListStyle only: specifies the list level for all paragraphs, otherwise | |
242 | // the current indentation will be used | |
243 | #define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL 0x20 | |
244 | ||
245 | // Resets the existing style before applying the new style | |
246 | #define wxRICHTEXT_SETSTYLE_RESET 0x40 | |
247 | ||
248 | // Removes the given style instead of applying it | |
249 | #define wxRICHTEXT_SETSTYLE_REMOVE 0x80 | |
250 | ||
251 | /** | |
252 | Flags for SetProperties. | |
253 | */ | |
254 | ||
255 | #define wxRICHTEXT_SETPROPERTIES_NONE 0x00 | |
256 | ||
257 | // Specifies that this operation should be undoable | |
258 | #define wxRICHTEXT_SETPROPERTIES_WITH_UNDO 0x01 | |
259 | ||
260 | // Specifies that the properties should only be applied to paragraphs, | |
261 | // and not the content. | |
262 | #define wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY 0x02 | |
263 | ||
264 | // Specifies that the properties should only be applied to characters, | |
265 | // and not the paragraph. | |
266 | #define wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY 0x04 | |
267 | ||
268 | // Resets the existing properties before applying the new properties. | |
269 | #define wxRICHTEXT_SETPROPERTIES_RESET 0x08 | |
270 | ||
271 | // Removes the given properties instead of applying them. | |
272 | #define wxRICHTEXT_SETPROPERTIES_REMOVE 0x10 | |
273 | ||
274 | /** | |
275 | Flags for object insertion. | |
276 | */ | |
277 | ||
278 | #define wxRICHTEXT_INSERT_NONE 0x00 | |
279 | #define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE 0x01 | |
280 | #define wxRICHTEXT_INSERT_INTERACTIVE 0x02 | |
281 | ||
282 | // A special flag telling the buffer to keep the first paragraph style | |
283 | // as-is, when deleting a paragraph marker. In future we might pass a | |
284 | // flag to InsertFragment and DeleteRange to indicate the appropriate mode. | |
285 | #define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x20000000 | |
286 | ||
287 | /** | |
288 | Default superscript/subscript font multiplication factor. | |
289 | */ | |
290 | ||
291 | #define wxSCRIPT_MUL_FACTOR 1.5 | |
292 | ||
293 | /** | |
294 | The type for wxTextAttrDimension flags. | |
295 | */ | |
296 | typedef unsigned short wxTextAttrDimensionFlags; | |
297 | ||
298 | /** | |
299 | Miscellaneous text box flags | |
300 | */ | |
301 | enum wxTextBoxAttrFlags | |
302 | { | |
303 | wxTEXT_BOX_ATTR_FLOAT = 0x00000001, | |
304 | wxTEXT_BOX_ATTR_CLEAR = 0x00000002, | |
305 | wxTEXT_BOX_ATTR_COLLAPSE_BORDERS = 0x00000004, | |
306 | wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT = 0x00000008, | |
307 | wxTEXT_BOX_ATTR_BOX_STYLE_NAME = 0x00000010 | |
308 | }; | |
309 | ||
310 | /** | |
311 | Whether a value is present, used in dimension flags. | |
312 | */ | |
313 | enum wxTextAttrValueFlags | |
314 | { | |
315 | wxTEXT_ATTR_VALUE_VALID = 0x1000, | |
316 | wxTEXT_ATTR_VALUE_VALID_MASK = 0x1000 | |
317 | }; | |
318 | ||
319 | /** | |
320 | Units, included in the dimension value. | |
321 | */ | |
322 | enum wxTextAttrUnits | |
323 | { | |
324 | wxTEXT_ATTR_UNITS_TENTHS_MM = 0x0001, | |
325 | wxTEXT_ATTR_UNITS_PIXELS = 0x0002, | |
326 | wxTEXT_ATTR_UNITS_PERCENTAGE = 0x0004, | |
327 | wxTEXT_ATTR_UNITS_POINTS = 0x0008, | |
328 | ||
329 | wxTEXT_ATTR_UNITS_MASK = 0x000F | |
330 | }; | |
331 | ||
332 | /** | |
333 | Position alternatives, included in the dimension flags. | |
334 | */ | |
335 | enum wxTextBoxAttrPosition | |
336 | { | |
337 | wxTEXT_BOX_ATTR_POSITION_STATIC = 0x0000, // Default is static, i.e. as per normal layout | |
338 | wxTEXT_BOX_ATTR_POSITION_RELATIVE = 0x0010, // Relative to the relevant edge | |
339 | wxTEXT_BOX_ATTR_POSITION_ABSOLUTE = 0x0020, // Relative to the parent | |
340 | wxTEXT_BOX_ATTR_POSITION_FIXED = 0x0040, // Relative to the top-level window | |
341 | ||
342 | wxTEXT_BOX_ATTR_POSITION_MASK = 0x00F0 | |
343 | }; | |
344 | ||
345 | /** | |
346 | @class wxTextAttrDimension | |
347 | ||
348 | A class representing a rich text dimension, including units and position. | |
349 | ||
350 | @library{wxrichtext} | |
351 | @category{richtext} | |
352 | ||
353 | @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimensions | |
354 | */ | |
355 | ||
356 | class WXDLLIMPEXP_RICHTEXT wxTextAttrDimension | |
357 | { | |
358 | public: | |
359 | /** | |
360 | Default constructor. | |
361 | */ | |
362 | wxTextAttrDimension() { Reset(); } | |
363 | /** | |
364 | Constructor taking value and units flag. | |
365 | */ | |
366 | wxTextAttrDimension(int value, wxTextAttrUnits units = wxTEXT_ATTR_UNITS_TENTHS_MM) { m_value = value; m_flags = units|wxTEXT_ATTR_VALUE_VALID; } | |
367 | ||
368 | /** | |
369 | Resets the dimension value and flags. | |
370 | */ | |
371 | void Reset() { m_value = 0; m_flags = 0; } | |
372 | ||
373 | /** | |
374 | Partial equality test. If @a weakTest is @true, attributes of this object do not | |
375 | have to be present if those attributes of @a dim are present. If @a weakTest is | |
376 | @false, the function will fail if an attribute is present in @a dim but not | |
377 | in this object. | |
378 | */ | |
379 | bool EqPartial(const wxTextAttrDimension& dim, bool weakTest = true) const; | |
380 | ||
381 | /** Apply the dimension, but not those identical to @a compareWith if present. | |
382 | */ | |
383 | bool Apply(const wxTextAttrDimension& dim, const wxTextAttrDimension* compareWith = NULL); | |
384 | ||
385 | /** Collects the attributes that are common to a range of content, building up a note of | |
386 | which attributes are absent in some objects and which clash in some objects. | |
387 | */ | |
388 | void CollectCommonAttributes(const wxTextAttrDimension& attr, wxTextAttrDimension& clashingAttr, wxTextAttrDimension& absentAttr); | |
389 | ||
390 | /** | |
391 | Equality operator. | |
392 | */ | |
393 | bool operator==(const wxTextAttrDimension& dim) const { return m_value == dim.m_value && m_flags == dim.m_flags; } | |
394 | ||
395 | /** | |
396 | Returns the integer value of the dimension. | |
397 | */ | |
398 | int GetValue() const { return m_value; } | |
399 | ||
400 | /** | |
401 | Returns the floating-pointing value of the dimension in mm. | |
402 | ||
403 | */ | |
404 | float GetValueMM() const { return float(m_value) / 10.0; } | |
405 | ||
406 | /** | |
407 | Sets the value of the dimension in mm. | |
408 | */ | |
409 | void SetValueMM(float value) { m_value = (int) ((value * 10.0) + 0.5); m_flags |= wxTEXT_ATTR_VALUE_VALID; } | |
410 | ||
411 | /** | |
412 | Sets the integer value of the dimension. | |
413 | */ | |
414 | void SetValue(int value) { m_value = value; m_flags |= wxTEXT_ATTR_VALUE_VALID; } | |
415 | ||
416 | /** | |
417 | Sets the integer value of the dimension, passing dimension flags. | |
418 | */ | |
419 | void SetValue(int value, wxTextAttrDimensionFlags flags) { SetValue(value); m_flags = flags; } | |
420 | ||
421 | /** | |
422 | Sets the integer value and units. | |
423 | */ | |
424 | void SetValue(int value, wxTextAttrUnits units) { m_value = value; m_flags = units | wxTEXT_ATTR_VALUE_VALID; } | |
425 | ||
426 | /** | |
427 | Sets the dimension. | |
428 | */ | |
429 | void SetValue(const wxTextAttrDimension& dim) { (*this) = dim; } | |
430 | ||
431 | /** | |
432 | Gets the units of the dimension. | |
433 | */ | |
434 | wxTextAttrUnits GetUnits() const { return (wxTextAttrUnits) (m_flags & wxTEXT_ATTR_UNITS_MASK); } | |
435 | ||
436 | /** | |
437 | Sets the units of the dimension. | |
438 | */ | |
439 | void SetUnits(wxTextAttrUnits units) { m_flags &= ~wxTEXT_ATTR_UNITS_MASK; m_flags |= units; } | |
440 | ||
441 | /** | |
442 | Gets the position flags. | |
443 | */ | |
444 | wxTextBoxAttrPosition GetPosition() const { return (wxTextBoxAttrPosition) (m_flags & wxTEXT_BOX_ATTR_POSITION_MASK); } | |
445 | ||
446 | /** | |
447 | Sets the position flags. | |
448 | */ | |
449 | void SetPosition(wxTextBoxAttrPosition pos) { m_flags &= ~wxTEXT_BOX_ATTR_POSITION_MASK; m_flags |= pos; } | |
450 | ||
451 | /** | |
452 | Returns @true if the dimension is valid. | |
453 | */ | |
454 | bool IsValid() const { return (m_flags & wxTEXT_ATTR_VALUE_VALID) != 0; } | |
455 | ||
456 | /** | |
457 | Sets the valid flag. | |
458 | */ | |
459 | void SetValid(bool b) { m_flags &= ~wxTEXT_ATTR_VALUE_VALID_MASK; m_flags |= (b ? wxTEXT_ATTR_VALUE_VALID : 0); } | |
460 | ||
461 | /** | |
462 | Gets the dimension flags. | |
463 | */ | |
464 | wxTextAttrDimensionFlags GetFlags() const { return m_flags; } | |
465 | ||
466 | /** | |
467 | Sets the dimension flags. | |
468 | */ | |
469 | void SetFlags(wxTextAttrDimensionFlags flags) { m_flags = flags; } | |
470 | ||
471 | int m_value; | |
472 | wxTextAttrDimensionFlags m_flags; | |
473 | }; | |
474 | ||
475 | /** | |
476 | @class wxTextAttrDimensions | |
477 | A class for left, right, top and bottom dimensions. | |
478 | ||
479 | @library{wxrichtext} | |
480 | @category{richtext} | |
481 | ||
482 | @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension | |
483 | */ | |
484 | ||
485 | class WXDLLIMPEXP_RICHTEXT wxTextAttrDimensions | |
486 | { | |
487 | public: | |
488 | /** | |
489 | Default constructor. | |
490 | */ | |
491 | wxTextAttrDimensions() {} | |
492 | ||
493 | /** | |
494 | Resets the value and flags for all dimensions. | |
495 | */ | |
496 | void Reset() { m_left.Reset(); m_top.Reset(); m_right.Reset(); m_bottom.Reset(); } | |
497 | ||
498 | /** | |
499 | Equality operator. | |
500 | */ | |
501 | bool operator==(const wxTextAttrDimensions& dims) const { return m_left == dims.m_left && m_top == dims.m_top && m_right == dims.m_right && m_bottom == dims.m_bottom; } | |
502 | ||
503 | /** | |
504 | Partial equality test. If @a weakTest is @true, attributes of this object do not | |
505 | have to be present if those attributes of @a dim sare present. If @a weakTest is | |
506 | @false, the function will fail if an attribute is present in @a dims but not | |
507 | in this object. | |
508 | ||
509 | */ | |
510 | bool EqPartial(const wxTextAttrDimensions& dims, bool weakTest = true) const; | |
511 | ||
512 | /** | |
513 | Apply to 'this', but not if the same as @a compareWith. | |
514 | ||
515 | */ | |
516 | bool Apply(const wxTextAttrDimensions& dims, const wxTextAttrDimensions* compareWith = NULL); | |
517 | ||
518 | /** | |
519 | Collects the attributes that are common to a range of content, building up a note of | |
520 | which attributes are absent in some objects and which clash in some objects. | |
521 | ||
522 | */ | |
523 | void CollectCommonAttributes(const wxTextAttrDimensions& attr, wxTextAttrDimensions& clashingAttr, wxTextAttrDimensions& absentAttr); | |
524 | ||
525 | /** | |
526 | Remove specified attributes from this object. | |
527 | */ | |
528 | bool RemoveStyle(const wxTextAttrDimensions& attr); | |
529 | ||
530 | /** | |
531 | Gets the left dimension. | |
532 | */ | |
533 | const wxTextAttrDimension& GetLeft() const { return m_left; } | |
534 | wxTextAttrDimension& GetLeft() { return m_left; } | |
535 | ||
536 | /** | |
537 | Gets the right dimension. | |
538 | ||
539 | */ | |
540 | const wxTextAttrDimension& GetRight() const { return m_right; } | |
541 | wxTextAttrDimension& GetRight() { return m_right; } | |
542 | ||
543 | /** | |
544 | Gets the top dimension. | |
545 | ||
546 | */ | |
547 | const wxTextAttrDimension& GetTop() const { return m_top; } | |
548 | wxTextAttrDimension& GetTop() { return m_top; } | |
549 | ||
550 | /** | |
551 | Gets the bottom dimension. | |
552 | ||
553 | */ | |
554 | const wxTextAttrDimension& GetBottom() const { return m_bottom; } | |
555 | wxTextAttrDimension& GetBottom() { return m_bottom; } | |
556 | ||
557 | /** | |
558 | Are all dimensions valid? | |
559 | ||
560 | */ | |
561 | bool IsValid() const { return m_left.IsValid() && m_top.IsValid() && m_right.IsValid() && m_bottom.IsValid(); } | |
562 | ||
563 | wxTextAttrDimension m_left; | |
564 | wxTextAttrDimension m_top; | |
565 | wxTextAttrDimension m_right; | |
566 | wxTextAttrDimension m_bottom; | |
567 | }; | |
568 | ||
569 | /** | |
570 | @class wxTextAttrSize | |
571 | A class for representing width and height. | |
572 | ||
573 | @library{wxrichtext} | |
574 | @category{richtext} | |
575 | ||
576 | @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension | |
577 | */ | |
578 | ||
579 | class WXDLLIMPEXP_RICHTEXT wxTextAttrSize | |
580 | { | |
581 | public: | |
582 | /** | |
583 | Default constructor. | |
584 | */ | |
585 | wxTextAttrSize() {} | |
586 | ||
587 | /** | |
588 | Resets the width and height dimensions. | |
589 | */ | |
590 | void Reset() { m_width.Reset(); m_height.Reset(); } | |
591 | ||
592 | /** | |
593 | Equality operator. | |
594 | */ | |
595 | bool operator==(const wxTextAttrSize& size) const { return m_width == size.m_width && m_height == size.m_height ; } | |
596 | ||
597 | /** | |
598 | Partial equality test. If @a weakTest is @true, attributes of this object do not | |
599 | have to be present if those attributes of @a size are present. If @a weakTest is | |
600 | @false, the function will fail if an attribute is present in @a size but not | |
601 | in this object. | |
602 | */ | |
603 | bool EqPartial(const wxTextAttrSize& size, bool weakTest = true) const; | |
604 | ||
605 | /** | |
606 | Apply to this object, but not if the same as @a compareWith. | |
607 | */ | |
608 | bool Apply(const wxTextAttrSize& dims, const wxTextAttrSize* compareWith = NULL); | |
609 | ||
610 | /** | |
611 | Collects the attributes that are common to a range of content, building up a note of | |
612 | which attributes are absent in some objects and which clash in some objects. | |
613 | */ | |
614 | void CollectCommonAttributes(const wxTextAttrSize& attr, wxTextAttrSize& clashingAttr, wxTextAttrSize& absentAttr); | |
615 | ||
616 | /** | |
617 | Removes the specified attributes from this object. | |
618 | */ | |
619 | bool RemoveStyle(const wxTextAttrSize& attr); | |
620 | ||
621 | /** | |
622 | Returns the width. | |
623 | */ | |
624 | wxTextAttrDimension& GetWidth() { return m_width; } | |
625 | const wxTextAttrDimension& GetWidth() const { return m_width; } | |
626 | ||
627 | /** | |
628 | Sets the width. | |
629 | */ | |
630 | void SetWidth(int value, wxTextAttrDimensionFlags flags) { m_width.SetValue(value, flags); } | |
631 | ||
632 | /** | |
633 | Sets the width. | |
634 | */ | |
635 | void SetWidth(int value, wxTextAttrUnits units) { m_width.SetValue(value, units); } | |
636 | ||
637 | /** | |
638 | Sets the width. | |
639 | */ | |
640 | void SetWidth(const wxTextAttrDimension& dim) { m_width.SetValue(dim); } | |
641 | ||
642 | /** | |
643 | Gets the height. | |
644 | */ | |
645 | wxTextAttrDimension& GetHeight() { return m_height; } | |
646 | const wxTextAttrDimension& GetHeight() const { return m_height; } | |
647 | ||
648 | /** | |
649 | Sets the height. | |
650 | */ | |
651 | void SetHeight(int value, wxTextAttrDimensionFlags flags) { m_height.SetValue(value, flags); } | |
652 | ||
653 | /** | |
654 | Sets the height. | |
655 | */ | |
656 | void SetHeight(int value, wxTextAttrUnits units) { m_height.SetValue(value, units); } | |
657 | ||
658 | /** | |
659 | Sets the height. | |
660 | */ | |
661 | void SetHeight(const wxTextAttrDimension& dim) { m_height.SetValue(dim); } | |
662 | ||
663 | /** | |
664 | Is the size valid? | |
665 | */ | |
666 | bool IsValid() const { return m_width.IsValid() && m_height.IsValid(); } | |
667 | ||
668 | wxTextAttrDimension m_width; | |
669 | wxTextAttrDimension m_height; | |
670 | }; | |
671 | ||
672 | /** | |
673 | @class wxTextAttrDimensionConverter | |
674 | A class to make it easier to convert dimensions. | |
675 | ||
676 | @library{wxrichtext} | |
677 | @category{richtext} | |
678 | ||
679 | @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension | |
680 | */ | |
681 | ||
682 | class WXDLLIMPEXP_RICHTEXT wxTextAttrDimensionConverter | |
683 | { | |
684 | public: | |
685 | /** | |
686 | Constructor. | |
687 | */ | |
688 | wxTextAttrDimensionConverter(wxDC& dc, double scale = 1.0, const wxSize& parentSize = wxDefaultSize); | |
689 | /** | |
690 | Constructor. | |
691 | */ | |
692 | wxTextAttrDimensionConverter(int ppi, double scale = 1.0, const wxSize& parentSize = wxDefaultSize); | |
693 | ||
694 | /** | |
695 | Gets the pixel size for the given dimension. | |
696 | */ | |
697 | int GetPixels(const wxTextAttrDimension& dim, int direction = wxHORIZONTAL) const; | |
698 | /** | |
699 | Gets the mm size for the given dimension. | |
700 | */ | |
701 | int GetTenthsMM(const wxTextAttrDimension& dim) const; | |
702 | ||
703 | /** | |
704 | Converts tenths of a mm to pixels. | |
705 | */ | |
706 | int ConvertTenthsMMToPixels(int units) const; | |
707 | /** | |
708 | Converts pixels to tenths of a mm. | |
709 | */ | |
710 | int ConvertPixelsToTenthsMM(int pixels) const; | |
711 | ||
712 | int m_ppi; | |
713 | double m_scale; | |
714 | wxSize m_parentSize; | |
715 | }; | |
716 | ||
717 | /** | |
718 | Border styles, used with wxTextAttrBorder. | |
719 | */ | |
720 | enum wxTextAttrBorderStyle | |
721 | { | |
722 | wxTEXT_BOX_ATTR_BORDER_NONE = 0, | |
723 | wxTEXT_BOX_ATTR_BORDER_SOLID = 1, | |
724 | wxTEXT_BOX_ATTR_BORDER_DOTTED = 2, | |
725 | wxTEXT_BOX_ATTR_BORDER_DASHED = 3, | |
726 | wxTEXT_BOX_ATTR_BORDER_DOUBLE = 4, | |
727 | wxTEXT_BOX_ATTR_BORDER_GROOVE = 5, | |
728 | wxTEXT_BOX_ATTR_BORDER_RIDGE = 6, | |
729 | wxTEXT_BOX_ATTR_BORDER_INSET = 7, | |
730 | wxTEXT_BOX_ATTR_BORDER_OUTSET = 8 | |
731 | }; | |
732 | ||
733 | /** | |
734 | Border style presence flags, used with wxTextAttrBorder. | |
735 | */ | |
736 | enum wxTextAttrBorderFlags | |
737 | { | |
738 | wxTEXT_BOX_ATTR_BORDER_STYLE = 0x0001, | |
739 | wxTEXT_BOX_ATTR_BORDER_COLOUR = 0x0002 | |
740 | }; | |
741 | ||
742 | /** | |
743 | Border width symbols for qualitative widths, used with wxTextAttrBorder. | |
744 | */ | |
745 | enum wxTextAttrBorderWidth | |
746 | { | |
747 | wxTEXT_BOX_ATTR_BORDER_THIN = -1, | |
748 | wxTEXT_BOX_ATTR_BORDER_MEDIUM = -2, | |
749 | wxTEXT_BOX_ATTR_BORDER_THICK = -3 | |
750 | }; | |
751 | ||
752 | /** | |
753 | Float styles. | |
754 | */ | |
755 | enum wxTextBoxAttrFloatStyle | |
756 | { | |
757 | wxTEXT_BOX_ATTR_FLOAT_NONE = 0, | |
758 | wxTEXT_BOX_ATTR_FLOAT_LEFT = 1, | |
759 | wxTEXT_BOX_ATTR_FLOAT_RIGHT = 2 | |
760 | }; | |
761 | ||
762 | /** | |
763 | Clear styles. | |
764 | */ | |
765 | enum wxTextBoxAttrClearStyle | |
766 | { | |
767 | wxTEXT_BOX_ATTR_CLEAR_NONE = 0, | |
768 | wxTEXT_BOX_ATTR_CLEAR_LEFT = 1, | |
769 | wxTEXT_BOX_ATTR_CLEAR_RIGHT = 2, | |
770 | wxTEXT_BOX_ATTR_CLEAR_BOTH = 3 | |
771 | }; | |
772 | ||
773 | /** | |
774 | Collapse mode styles. TODO: can they be switched on per side? | |
775 | */ | |
776 | enum wxTextBoxAttrCollapseMode | |
777 | { | |
778 | wxTEXT_BOX_ATTR_COLLAPSE_NONE = 0, | |
779 | wxTEXT_BOX_ATTR_COLLAPSE_FULL = 1 | |
780 | }; | |
781 | ||
782 | /** | |
783 | Vertical alignment values. | |
784 | */ | |
785 | enum wxTextBoxAttrVerticalAlignment | |
786 | { | |
787 | wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE = 0, | |
788 | wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP = 1, | |
789 | wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE = 2, | |
790 | wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM = 3 | |
791 | }; | |
792 | ||
793 | /** | |
794 | @class wxTextAttrBorder | |
795 | A class representing a rich text object border. | |
796 | ||
797 | @library{wxrichtext} | |
798 | @category{richtext} | |
799 | ||
800 | @see wxRichTextAttr, wxRichTextCtrl, wxRichTextAttrBorders | |
801 | */ | |
802 | ||
803 | class WXDLLIMPEXP_RICHTEXT wxTextAttrBorder | |
804 | { | |
805 | public: | |
806 | /** | |
807 | Default constructor. | |
808 | */ | |
809 | wxTextAttrBorder() { Reset(); } | |
810 | ||
811 | /** | |
812 | Equality operator. | |
813 | */ | |
814 | bool operator==(const wxTextAttrBorder& border) const | |
815 | { | |
816 | return m_flags == border.m_flags && m_borderStyle == border.m_borderStyle && | |
817 | m_borderColour == border.m_borderColour && m_borderWidth == border.m_borderWidth; | |
818 | } | |
819 | ||
820 | /** | |
821 | Resets the border style, colour, width and flags. | |
822 | */ | |
823 | void Reset() { m_borderStyle = 0; m_borderColour = 0; m_flags = 0; m_borderWidth.Reset(); } | |
824 | ||
825 | /** | |
826 | Partial equality test. If @a weakTest is @true, attributes of this object do not | |
827 | have to be present if those attributes of @a border are present. If @a weakTest is | |
828 | @false, the function will fail if an attribute is present in @a border but not | |
829 | in this object. | |
830 | */ | |
831 | bool EqPartial(const wxTextAttrBorder& border, bool weakTest = true) const; | |
832 | ||
833 | /** | |
834 | Applies the border to this object, but not if the same as @a compareWith. | |
835 | ||
836 | */ | |
837 | bool Apply(const wxTextAttrBorder& border, const wxTextAttrBorder* compareWith = NULL); | |
838 | ||
839 | /** | |
840 | Removes the specified attributes from this object. | |
841 | */ | |
842 | bool RemoveStyle(const wxTextAttrBorder& attr); | |
843 | ||
844 | /** | |
845 | Collects the attributes that are common to a range of content, building up a note of | |
846 | which attributes are absent in some objects and which clash in some objects. | |
847 | */ | |
848 | void CollectCommonAttributes(const wxTextAttrBorder& attr, wxTextAttrBorder& clashingAttr, wxTextAttrBorder& absentAttr); | |
849 | ||
850 | /** | |
851 | Sets the border style. | |
852 | */ | |
853 | void SetStyle(int style) { m_borderStyle = style; m_flags |= wxTEXT_BOX_ATTR_BORDER_STYLE; } | |
854 | ||
855 | /** | |
856 | Gets the border style. | |
857 | ||
858 | */ | |
859 | int GetStyle() const { return m_borderStyle; } | |
860 | ||
861 | /** | |
862 | Sets the border colour. | |
863 | */ | |
864 | void SetColour(unsigned long colour) { m_borderColour = colour; m_flags |= wxTEXT_BOX_ATTR_BORDER_COLOUR; } | |
865 | ||
866 | /** | |
867 | Sets the border colour. | |
868 | */ | |
869 | void SetColour(const wxColour& colour) { m_borderColour = colour.GetRGB(); m_flags |= wxTEXT_BOX_ATTR_BORDER_COLOUR; } | |
870 | ||
871 | /** | |
872 | Gets the colour as a long. | |
873 | */ | |
874 | unsigned long GetColourLong() const { return m_borderColour; } | |
875 | ||
876 | /** | |
877 | Gets the colour. | |
878 | */ | |
879 | wxColour GetColour() const { return wxColour(m_borderColour); } | |
880 | ||
881 | /** | |
882 | Gets the border width. | |
883 | */ | |
884 | wxTextAttrDimension& GetWidth() { return m_borderWidth; } | |
885 | const wxTextAttrDimension& GetWidth() const { return m_borderWidth; } | |
886 | ||
887 | /** | |
888 | Sets the border width. | |
889 | */ | |
890 | void SetWidth(const wxTextAttrDimension& width) { m_borderWidth = width; } | |
891 | /** | |
892 | Sets the border width. | |
893 | */ | |
894 | void SetWidth(int value, wxTextAttrUnits units = wxTEXT_ATTR_UNITS_TENTHS_MM) { SetWidth(wxTextAttrDimension(value, units)); } | |
895 | ||
896 | /** | |
897 | True if the border has a valid style. | |
898 | */ | |
899 | bool HasStyle() const { return (m_flags & wxTEXT_BOX_ATTR_BORDER_STYLE) != 0; } | |
900 | ||
901 | /** | |
902 | True if the border has a valid colour. | |
903 | */ | |
904 | bool HasColour() const { return (m_flags & wxTEXT_BOX_ATTR_BORDER_COLOUR) != 0; } | |
905 | ||
906 | /** | |
907 | True if the border has a valid width. | |
908 | */ | |
909 | bool HasWidth() const { return m_borderWidth.IsValid(); } | |
910 | ||
911 | /** | |
912 | True if the border is valid. | |
913 | */ | |
914 | bool IsValid() const { return HasWidth(); } | |
915 | ||
916 | /** | |
917 | Set the valid flag for this border. | |
918 | */ | |
919 | void MakeValid() { m_borderWidth.SetValid(true); } | |
920 | ||
921 | /** | |
922 | Returns the border flags. | |
923 | */ | |
924 | int GetFlags() const { return m_flags; } | |
925 | ||
926 | /** | |
927 | Sets the border flags. | |
928 | */ | |
929 | void SetFlags(int flags) { m_flags = flags; } | |
930 | ||
931 | /** | |
932 | Adds a border flag. | |
933 | */ | |
934 | void AddFlag(int flag) { m_flags |= flag; } | |
935 | ||
936 | /** | |
937 | Removes a border flag. | |
938 | */ | |
939 | void RemoveFlag(int flag) { m_flags &= ~flag; } | |
940 | ||
941 | int m_borderStyle; | |
942 | unsigned long m_borderColour; | |
943 | wxTextAttrDimension m_borderWidth; | |
944 | int m_flags; | |
945 | }; | |
946 | ||
947 | /** | |
948 | @class wxTextAttrBorders | |
949 | A class representing a rich text object's borders. | |
950 | ||
951 | @library{wxrichtext} | |
952 | @category{richtext} | |
953 | ||
954 | @see wxRichTextAttr, wxRichTextCtrl, wxRichTextAttrBorder | |
955 | */ | |
956 | ||
957 | class WXDLLIMPEXP_RICHTEXT wxTextAttrBorders | |
958 | { | |
959 | public: | |
960 | /** | |
961 | Default constructor. | |
962 | */ | |
963 | wxTextAttrBorders() { } | |
964 | ||
965 | /** | |
966 | Equality operator. | |
967 | */ | |
968 | bool operator==(const wxTextAttrBorders& borders) const | |
969 | { | |
970 | return m_left == borders.m_left && m_right == borders.m_right && | |
971 | m_top == borders.m_top && m_bottom == borders.m_bottom; | |
972 | } | |
973 | ||
974 | /** | |
975 | Sets the style of all borders. | |
976 | */ | |
977 | void SetStyle(int style); | |
978 | ||
979 | /** | |
980 | Sets colour of all borders. | |
981 | */ | |
982 | void SetColour(unsigned long colour); | |
983 | ||
984 | /** | |
985 | Sets the colour for all borders. | |
986 | */ | |
987 | void SetColour(const wxColour& colour); | |
988 | ||
989 | /** | |
990 | Sets the width of all borders. | |
991 | */ | |
992 | void SetWidth(const wxTextAttrDimension& width); | |
993 | ||
994 | /** | |
995 | Sets the width of all borders. | |
996 | */ | |
997 | void SetWidth(int value, wxTextAttrUnits units = wxTEXT_ATTR_UNITS_TENTHS_MM) { SetWidth(wxTextAttrDimension(value, units)); } | |
998 | ||
999 | /** | |
1000 | Resets all borders. | |
1001 | */ | |
1002 | void Reset() { m_left.Reset(); m_right.Reset(); m_top.Reset(); m_bottom.Reset(); } | |
1003 | ||
1004 | /** | |
1005 | Partial equality test. If @a weakTest is @true, attributes of this object do not | |
1006 | have to be present if those attributes of @a borders are present. If @a weakTest is | |
1007 | @false, the function will fail if an attribute is present in @a borders but not | |
1008 | in this object. | |
1009 | */ | |
1010 | bool EqPartial(const wxTextAttrBorders& borders, bool weakTest = true) const; | |
1011 | ||
1012 | /** | |
1013 | Applies border to this object, but not if the same as @a compareWith. | |
1014 | */ | |
1015 | bool Apply(const wxTextAttrBorders& borders, const wxTextAttrBorders* compareWith = NULL); | |
1016 | ||
1017 | /** | |
1018 | Removes the specified attributes from this object. | |
1019 | */ | |
1020 | bool RemoveStyle(const wxTextAttrBorders& attr); | |
1021 | ||
1022 | /** | |
1023 | Collects the attributes that are common to a range of content, building up a note of | |
1024 | which attributes are absent in some objects and which clash in some objects. | |
1025 | */ | |
1026 | void CollectCommonAttributes(const wxTextAttrBorders& attr, wxTextAttrBorders& clashingAttr, wxTextAttrBorders& absentAttr); | |
1027 | ||
1028 | /** | |
1029 | Returns @true if all borders are valid. | |
1030 | */ | |
1031 | bool IsValid() const { return m_left.IsValid() || m_right.IsValid() || m_top.IsValid() || m_bottom.IsValid(); } | |
1032 | ||
1033 | /** | |
1034 | Returns the left border. | |
1035 | */ | |
1036 | const wxTextAttrBorder& GetLeft() const { return m_left; } | |
1037 | wxTextAttrBorder& GetLeft() { return m_left; } | |
1038 | ||
1039 | /** | |
1040 | Returns the right border. | |
1041 | */ | |
1042 | const wxTextAttrBorder& GetRight() const { return m_right; } | |
1043 | wxTextAttrBorder& GetRight() { return m_right; } | |
1044 | ||
1045 | /** | |
1046 | Returns the top border. | |
1047 | */ | |
1048 | const wxTextAttrBorder& GetTop() const { return m_top; } | |
1049 | wxTextAttrBorder& GetTop() { return m_top; } | |
1050 | ||
1051 | /** | |
1052 | Returns the bottom border. | |
1053 | */ | |
1054 | const wxTextAttrBorder& GetBottom() const { return m_bottom; } | |
1055 | wxTextAttrBorder& GetBottom() { return m_bottom; } | |
1056 | ||
1057 | wxTextAttrBorder m_left, m_right, m_top, m_bottom; | |
1058 | ||
1059 | }; | |
1060 | ||
1061 | /** | |
1062 | @class wxTextBoxAttr | |
1063 | A class representing the box attributes of a rich text object. | |
1064 | ||
1065 | @library{wxrichtext} | |
1066 | @category{richtext} | |
1067 | ||
1068 | @see wxRichTextAttr, wxRichTextCtrl | |
1069 | */ | |
1070 | ||
1071 | class WXDLLIMPEXP_RICHTEXT wxTextBoxAttr | |
1072 | { | |
1073 | public: | |
1074 | /** | |
1075 | Default constructor. | |
1076 | */ | |
1077 | wxTextBoxAttr() { Init(); } | |
1078 | ||
1079 | /** | |
1080 | Copy constructor. | |
1081 | */ | |
1082 | wxTextBoxAttr(const wxTextBoxAttr& attr) { Init(); (*this) = attr; } | |
1083 | ||
1084 | /** | |
1085 | Initialises this object. | |
1086 | */ | |
1087 | void Init() { Reset(); } | |
1088 | ||
1089 | /** | |
1090 | Resets this object. | |
1091 | */ | |
1092 | void Reset(); | |
1093 | ||
1094 | // Copy. Unnecessary since we let it do a binary copy | |
1095 | //void Copy(const wxTextBoxAttr& attr); | |
1096 | ||
1097 | // Assignment | |
1098 | //void operator= (const wxTextBoxAttr& attr); | |
1099 | ||
1100 | /** | |
1101 | Equality test. | |
1102 | */ | |
1103 | bool operator== (const wxTextBoxAttr& attr) const; | |
1104 | ||
1105 | /** | |
1106 | Partial equality test, ignoring unset attributes. If @a weakTest is @true, attributes of this object do not | |
1107 | have to be present if those attributes of @a attr are present. If @a weakTest is | |
1108 | @false, the function will fail if an attribute is present in @a attr but not | |
1109 | in this object. | |
1110 | ||
1111 | */ | |
1112 | bool EqPartial(const wxTextBoxAttr& attr, bool weakTest = true) const; | |
1113 | ||
1114 | /** | |
1115 | Merges the given attributes. If @a compareWith is non-NULL, then it will be used | |
1116 | to mask out those attributes that are the same in style and @a compareWith, for | |
1117 | situations where we don't want to explicitly set inherited attributes. | |
1118 | */ | |
1119 | bool Apply(const wxTextBoxAttr& style, const wxTextBoxAttr* compareWith = NULL); | |
1120 | ||
1121 | /** | |
1122 | Collects the attributes that are common to a range of content, building up a note of | |
1123 | which attributes are absent in some objects and which clash in some objects. | |
1124 | */ | |
1125 | void CollectCommonAttributes(const wxTextBoxAttr& attr, wxTextBoxAttr& clashingAttr, wxTextBoxAttr& absentAttr); | |
1126 | ||
1127 | /** | |
1128 | Removes the specified attributes from this object. | |
1129 | */ | |
1130 | bool RemoveStyle(const wxTextBoxAttr& attr); | |
1131 | ||
1132 | /** | |
1133 | Sets the flags. | |
1134 | */ | |
1135 | void SetFlags(int flags) { m_flags = flags; } | |
1136 | ||
1137 | /** | |
1138 | Returns the flags. | |
1139 | */ | |
1140 | int GetFlags() const { return m_flags; } | |
1141 | ||
1142 | /** | |
1143 | Is this flag present? | |
1144 | */ | |
1145 | bool HasFlag(wxTextBoxAttrFlags flag) const { return (m_flags & flag) != 0; } | |
1146 | ||
1147 | /** | |
1148 | Removes this flag. | |
1149 | */ | |
1150 | void RemoveFlag(wxTextBoxAttrFlags flag) { m_flags &= ~flag; } | |
1151 | ||
1152 | /** | |
1153 | Adds this flag. | |
1154 | */ | |
1155 | void AddFlag(wxTextBoxAttrFlags flag) { m_flags |= flag; } | |
1156 | ||
1157 | /** | |
1158 | Returns @true if no attributes are set. | |
1159 | */ | |
1160 | bool IsDefault() const; | |
1161 | ||
1162 | /** | |
1163 | Returns the float mode. | |
1164 | */ | |
1165 | wxTextBoxAttrFloatStyle GetFloatMode() const { return m_floatMode; } | |
1166 | ||
1167 | /** | |
1168 | Sets the float mode. | |
1169 | */ | |
1170 | void SetFloatMode(wxTextBoxAttrFloatStyle mode) { m_floatMode = mode; m_flags |= wxTEXT_BOX_ATTR_FLOAT; } | |
1171 | ||
1172 | /** | |
1173 | Returns @true if float mode is active. | |
1174 | */ | |
1175 | bool HasFloatMode() const { return HasFlag(wxTEXT_BOX_ATTR_FLOAT); } | |
1176 | ||
1177 | /** | |
1178 | Returns @true if this object is floating. | |
1179 | */ | |
1180 | bool IsFloating() const { return HasFloatMode() && GetFloatMode() != wxTEXT_BOX_ATTR_FLOAT_NONE; } | |
1181 | ||
1182 | /** | |
1183 | Returns the clear mode - whether to wrap text after object. Currently unimplemented. | |
1184 | */ | |
1185 | wxTextBoxAttrClearStyle GetClearMode() const { return m_clearMode; } | |
1186 | ||
1187 | /** | |
1188 | Set the clear mode. Currently unimplemented. | |
1189 | */ | |
1190 | void SetClearMode(wxTextBoxAttrClearStyle mode) { m_clearMode = mode; m_flags |= wxTEXT_BOX_ATTR_CLEAR; } | |
1191 | ||
1192 | /** | |
1193 | Returns @true if we have a clear flag. | |
1194 | */ | |
1195 | bool HasClearMode() const { return HasFlag(wxTEXT_BOX_ATTR_CLEAR); } | |
1196 | ||
1197 | /** | |
1198 | Returns the collapse mode - whether to collapse borders. Currently unimplemented. | |
1199 | */ | |
1200 | wxTextBoxAttrCollapseMode GetCollapseBorders() const { return m_collapseMode; } | |
1201 | ||
1202 | /** | |
1203 | Sets the collapse mode - whether to collapse borders. Currently unimplemented. | |
1204 | */ | |
1205 | void SetCollapseBorders(wxTextBoxAttrCollapseMode collapse) { m_collapseMode = collapse; m_flags |= wxTEXT_BOX_ATTR_COLLAPSE_BORDERS; } | |
1206 | ||
1207 | /** | |
1208 | Returns @true if the collapse borders flag is present. | |
1209 | */ | |
1210 | bool HasCollapseBorders() const { return HasFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS); } | |
1211 | ||
1212 | /** | |
1213 | Returns the vertical alignment. | |
1214 | */ | |
1215 | wxTextBoxAttrVerticalAlignment GetVerticalAlignment() const { return m_verticalAlignment; } | |
1216 | ||
1217 | /** | |
1218 | Sets the vertical alignment. | |
1219 | */ | |
1220 | void SetVerticalAlignment(wxTextBoxAttrVerticalAlignment verticalAlignment) { m_verticalAlignment = verticalAlignment; m_flags |= wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT; } | |
1221 | ||
1222 | /** | |
1223 | Returns @true if a vertical alignment flag is present. | |
1224 | */ | |
1225 | bool HasVerticalAlignment() const { return HasFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT); } | |
1226 | ||
1227 | /** | |
1228 | Returns the margin values. | |
1229 | */ | |
1230 | wxTextAttrDimensions& GetMargins() { return m_margins; } | |
1231 | const wxTextAttrDimensions& GetMargins() const { return m_margins; } | |
1232 | ||
1233 | /** | |
1234 | Returns the left margin. | |
1235 | */ | |
1236 | wxTextAttrDimension& GetLeftMargin() { return m_margins.m_left; } | |
1237 | const wxTextAttrDimension& GetLeftMargin() const { return m_margins.m_left; } | |
1238 | ||
1239 | /** | |
1240 | Returns the right margin. | |
1241 | */ | |
1242 | wxTextAttrDimension& GetRightMargin() { return m_margins.m_right; } | |
1243 | const wxTextAttrDimension& GetRightMargin() const { return m_margins.m_right; } | |
1244 | ||
1245 | /** | |
1246 | Returns the top margin. | |
1247 | */ | |
1248 | wxTextAttrDimension& GetTopMargin() { return m_margins.m_top; } | |
1249 | const wxTextAttrDimension& GetTopMargin() const { return m_margins.m_top; } | |
1250 | ||
1251 | /** | |
1252 | Returns the bottom margin. | |
1253 | */ | |
1254 | wxTextAttrDimension& GetBottomMargin() { return m_margins.m_bottom; } | |
1255 | const wxTextAttrDimension& GetBottomMargin() const { return m_margins.m_bottom; } | |
1256 | ||
1257 | /** | |
1258 | Returns the position. | |
1259 | */ | |
1260 | wxTextAttrDimensions& GetPosition() { return m_position; } | |
1261 | const wxTextAttrDimensions& GetPosition() const { return m_position; } | |
1262 | ||
1263 | /** | |
1264 | Returns the left position. | |
1265 | */ | |
1266 | wxTextAttrDimension& GetLeft() { return m_position.m_left; } | |
1267 | const wxTextAttrDimension& GetLeft() const { return m_position.m_left; } | |
1268 | ||
1269 | /** | |
1270 | Returns the right position. | |
1271 | */ | |
1272 | wxTextAttrDimension& GetRight() { return m_position.m_right; } | |
1273 | const wxTextAttrDimension& GetRight() const { return m_position.m_right; } | |
1274 | ||
1275 | /** | |
1276 | Returns the top position. | |
1277 | */ | |
1278 | wxTextAttrDimension& GetTop() { return m_position.m_top; } | |
1279 | const wxTextAttrDimension& GetTop() const { return m_position.m_top; } | |
1280 | ||
1281 | /** | |
1282 | Returns the bottom position. | |
1283 | */ | |
1284 | wxTextAttrDimension& GetBottom() { return m_position.m_bottom; } | |
1285 | const wxTextAttrDimension& GetBottom() const { return m_position.m_bottom; } | |
1286 | ||
1287 | /** | |
1288 | Returns the padding values. | |
1289 | */ | |
1290 | wxTextAttrDimensions& GetPadding() { return m_padding; } | |
1291 | const wxTextAttrDimensions& GetPadding() const { return m_padding; } | |
1292 | ||
1293 | /** | |
1294 | Returns the left padding value. | |
1295 | */ | |
1296 | wxTextAttrDimension& GetLeftPadding() { return m_padding.m_left; } | |
1297 | const wxTextAttrDimension& GetLeftPadding() const { return m_padding.m_left; } | |
1298 | ||
1299 | /** | |
1300 | Returns the right padding value. | |
1301 | */ | |
1302 | wxTextAttrDimension& GetRightPadding() { return m_padding.m_right; } | |
1303 | const wxTextAttrDimension& GetRightPadding() const { return m_padding.m_right; } | |
1304 | ||
1305 | /** | |
1306 | Returns the top padding value. | |
1307 | */ | |
1308 | wxTextAttrDimension& GetTopPadding() { return m_padding.m_top; } | |
1309 | const wxTextAttrDimension& GetTopPadding() const { return m_padding.m_top; } | |
1310 | ||
1311 | /** | |
1312 | Returns the bottom padding value. | |
1313 | */ | |
1314 | wxTextAttrDimension& GetBottomPadding() { return m_padding.m_bottom; } | |
1315 | const wxTextAttrDimension& GetBottomPadding() const { return m_padding.m_bottom; } | |
1316 | ||
1317 | /** | |
1318 | Returns the borders. | |
1319 | */ | |
1320 | wxTextAttrBorders& GetBorder() { return m_border; } | |
1321 | const wxTextAttrBorders& GetBorder() const { return m_border; } | |
1322 | ||
1323 | /** | |
1324 | Returns the left border. | |
1325 | */ | |
1326 | wxTextAttrBorder& GetLeftBorder() { return m_border.m_left; } | |
1327 | const wxTextAttrBorder& GetLeftBorder() const { return m_border.m_left; } | |
1328 | ||
1329 | /** | |
1330 | Returns the top border. | |
1331 | */ | |
1332 | wxTextAttrBorder& GetTopBorder() { return m_border.m_top; } | |
1333 | const wxTextAttrBorder& GetTopBorder() const { return m_border.m_top; } | |
1334 | ||
1335 | /** | |
1336 | Returns the right border. | |
1337 | */ | |
1338 | wxTextAttrBorder& GetRightBorder() { return m_border.m_right; } | |
1339 | const wxTextAttrBorder& GetRightBorder() const { return m_border.m_right; } | |
1340 | ||
1341 | /** | |
1342 | Returns the bottom border. | |
1343 | */ | |
1344 | wxTextAttrBorder& GetBottomBorder() { return m_border.m_bottom; } | |
1345 | const wxTextAttrBorder& GetBottomBorder() const { return m_border.m_bottom; } | |
1346 | ||
1347 | /** | |
1348 | Returns the outline. | |
1349 | */ | |
1350 | wxTextAttrBorders& GetOutline() { return m_outline; } | |
1351 | const wxTextAttrBorders& GetOutline() const { return m_outline; } | |
1352 | ||
1353 | /** | |
1354 | Returns the left outline. | |
1355 | */ | |
1356 | wxTextAttrBorder& GetLeftOutline() { return m_outline.m_left; } | |
1357 | const wxTextAttrBorder& GetLeftOutline() const { return m_outline.m_left; } | |
1358 | ||
1359 | /** | |
1360 | Returns the top outline. | |
1361 | */ | |
1362 | wxTextAttrBorder& GetTopOutline() { return m_outline.m_top; } | |
1363 | const wxTextAttrBorder& GetTopOutline() const { return m_outline.m_top; } | |
1364 | ||
1365 | /** | |
1366 | Returns the right outline. | |
1367 | */ | |
1368 | wxTextAttrBorder& GetRightOutline() { return m_outline.m_right; } | |
1369 | const wxTextAttrBorder& GetRightOutline() const { return m_outline.m_right; } | |
1370 | ||
1371 | /** | |
1372 | Returns the bottom outline. | |
1373 | */ | |
1374 | wxTextAttrBorder& GetBottomOutline() { return m_outline.m_bottom; } | |
1375 | const wxTextAttrBorder& GetBottomOutline() const { return m_outline.m_bottom; } | |
1376 | ||
1377 | /** | |
1378 | Returns the object size. | |
1379 | */ | |
1380 | wxTextAttrSize& GetSize() { return m_size; } | |
1381 | const wxTextAttrSize& GetSize() const { return m_size; } | |
1382 | ||
1383 | /** | |
1384 | Returns the object minimum size. | |
1385 | */ | |
1386 | ||
1387 | wxTextAttrSize& GetMinSize() { return m_minSize; } | |
1388 | const wxTextAttrSize& GetMinSize() const { return m_minSize; } | |
1389 | ||
1390 | /** | |
1391 | Returns the object maximum size. | |
1392 | */ | |
1393 | ||
1394 | wxTextAttrSize& GetMaxSize() { return m_maxSize; } | |
1395 | const wxTextAttrSize& GetMaxSize() const { return m_maxSize; } | |
1396 | ||
1397 | /** | |
1398 | Sets the object size. | |
1399 | */ | |
1400 | void SetSize(const wxTextAttrSize& sz) { m_size = sz; } | |
1401 | ||
1402 | /** | |
1403 | Sets the object minimum size. | |
1404 | */ | |
1405 | void SetMinSize(const wxTextAttrSize& sz) { m_minSize = sz; } | |
1406 | ||
1407 | /** | |
1408 | Sets the object maximum size. | |
1409 | */ | |
1410 | void SetMaxSize(const wxTextAttrSize& sz) { m_maxSize = sz; } | |
1411 | ||
1412 | /** | |
1413 | Returns the object width. | |
1414 | */ | |
1415 | wxTextAttrDimension& GetWidth() { return m_size.m_width; } | |
1416 | const wxTextAttrDimension& GetWidth() const { return m_size.m_width; } | |
1417 | ||
1418 | /** | |
1419 | Returns the object height. | |
1420 | */ | |
1421 | wxTextAttrDimension& GetHeight() { return m_size.m_height; } | |
1422 | const wxTextAttrDimension& GetHeight() const { return m_size.m_height; } | |
1423 | ||
1424 | /** | |
1425 | Returns the box style name. | |
1426 | */ | |
1427 | const wxString& GetBoxStyleName() const { return m_boxStyleName; } | |
1428 | ||
1429 | /** | |
1430 | Sets the box style name. | |
1431 | */ | |
1432 | void SetBoxStyleName(const wxString& name) { m_boxStyleName = name; AddFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME); } | |
1433 | ||
1434 | /** | |
1435 | Returns @true if the box style name is present. | |
1436 | */ | |
1437 | bool HasBoxStyleName() const { return HasFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME); } | |
1438 | ||
1439 | public: | |
1440 | ||
1441 | int m_flags; | |
1442 | ||
1443 | wxTextAttrDimensions m_margins; | |
1444 | wxTextAttrDimensions m_padding; | |
1445 | wxTextAttrDimensions m_position; | |
1446 | ||
1447 | wxTextAttrSize m_size; | |
1448 | wxTextAttrSize m_minSize; | |
1449 | wxTextAttrSize m_maxSize; | |
1450 | ||
1451 | wxTextAttrBorders m_border; | |
1452 | wxTextAttrBorders m_outline; | |
1453 | ||
1454 | wxTextBoxAttrFloatStyle m_floatMode; | |
1455 | wxTextBoxAttrClearStyle m_clearMode; | |
1456 | wxTextBoxAttrCollapseMode m_collapseMode; | |
1457 | wxTextBoxAttrVerticalAlignment m_verticalAlignment; | |
1458 | wxString m_boxStyleName; | |
1459 | }; | |
1460 | ||
1461 | /** | |
1462 | @class wxRichTextAttr | |
1463 | A class representing enhanced attributes for rich text objects. | |
1464 | This adds a wxTextBoxAttr member to the basic wxTextAttr class. | |
1465 | ||
1466 | @library{wxrichtext} | |
1467 | @category{richtext} | |
1468 | ||
1469 | @see wxRichTextAttr, wxTextBoxAttr, wxRichTextCtrl | |
1470 | */ | |
1471 | ||
1472 | class WXDLLIMPEXP_RICHTEXT wxRichTextAttr: public wxTextAttr | |
1473 | { | |
1474 | public: | |
1475 | /** | |
1476 | Constructor taking a wxTextAttr. | |
1477 | */ | |
1478 | wxRichTextAttr(const wxTextAttr& attr) { wxTextAttr::Copy(attr); } | |
1479 | ||
1480 | /** | |
1481 | Copy constructor. | |
1482 | */ | |
1483 | wxRichTextAttr(const wxRichTextAttr& attr): wxTextAttr() { Copy(attr); } | |
1484 | ||
1485 | /** | |
1486 | Default constructor. | |
1487 | */ | |
1488 | wxRichTextAttr() {} | |
1489 | ||
1490 | /** | |
1491 | Copy function. | |
1492 | */ | |
1493 | void Copy(const wxRichTextAttr& attr); | |
1494 | ||
1495 | /** | |
1496 | Assignment operator. | |
1497 | */ | |
1498 | void operator=(const wxRichTextAttr& attr) { Copy(attr); } | |
1499 | ||
1500 | /** | |
1501 | Assignment operator. | |
1502 | */ | |
1503 | void operator=(const wxTextAttr& attr) { wxTextAttr::Copy(attr); } | |
1504 | ||
1505 | /** | |
1506 | Equality test. | |
1507 | */ | |
1508 | bool operator==(const wxRichTextAttr& attr) const; | |
1509 | ||
1510 | /** | |
1511 | Partial equality test. If @a weakTest is @true, attributes of this object do not | |
1512 | have to be present if those attributes of @a attr are present. If @a weakTest is | |
1513 | @false, the function will fail if an attribute is present in @a attr but not | |
1514 | in this object. | |
1515 | */ | |
1516 | bool EqPartial(const wxRichTextAttr& attr, bool weakTest = true) const; | |
1517 | ||
1518 | /** | |
1519 | Merges the given attributes. If @a compareWith | |
1520 | is non-NULL, then it will be used to mask out those attributes that are the same in style | |
1521 | and @a compareWith, for situations where we don't want to explicitly set inherited attributes. | |
1522 | */ | |
1523 | bool Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith = NULL); | |
1524 | ||
1525 | /** | |
1526 | Collects the attributes that are common to a range of content, building up a note of | |
1527 | which attributes are absent in some objects and which clash in some objects. | |
1528 | */ | |
1529 | void CollectCommonAttributes(const wxRichTextAttr& attr, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr); | |
1530 | ||
1531 | /** | |
1532 | Removes the specified attributes from this object. | |
1533 | */ | |
1534 | bool RemoveStyle(const wxRichTextAttr& attr); | |
1535 | ||
1536 | /** | |
1537 | Returns the text box attributes. | |
1538 | */ | |
1539 | wxTextBoxAttr& GetTextBoxAttr() { return m_textBoxAttr; } | |
1540 | const wxTextBoxAttr& GetTextBoxAttr() const { return m_textBoxAttr; } | |
1541 | ||
1542 | /** | |
1543 | Set the text box attributes. | |
1544 | */ | |
1545 | void SetTextBoxAttr(const wxTextBoxAttr& attr) { m_textBoxAttr = attr; } | |
1546 | ||
1547 | /** | |
1548 | Returns @true if no attributes are set. | |
1549 | */ | |
1550 | bool IsDefault() const { return (GetFlags() == 0) && m_textBoxAttr.IsDefault(); } | |
1551 | ||
1552 | wxTextBoxAttr m_textBoxAttr; | |
1553 | }; | |
1554 | ||
1555 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRichTextAttr, wxRichTextAttrArray, WXDLLIMPEXP_RICHTEXT); | |
1556 | ||
1557 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxVariant, wxRichTextVariantArray, WXDLLIMPEXP_RICHTEXT); | |
1558 | ||
1559 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRect, wxRichTextRectArray, WXDLLIMPEXP_RICHTEXT); | |
1560 | ||
1561 | /** | |
1562 | @class wxRichTextProperties | |
1563 | A simple property class using wxVariants. This is used to give each rich text object the | |
1564 | ability to store custom properties that can be used by the application. | |
1565 | ||
1566 | @library{wxrichtext} | |
1567 | @category{richtext} | |
1568 | ||
1569 | @see wxRichTextBuffer, wxRichTextObject, wxRichTextCtrl | |
1570 | */ | |
1571 | ||
1572 | class WXDLLIMPEXP_RICHTEXT wxRichTextProperties: public wxObject | |
1573 | { | |
1574 | DECLARE_DYNAMIC_CLASS(wxRichTextProperties) | |
1575 | public: | |
1576 | ||
1577 | /** | |
1578 | Default constructor. | |
1579 | */ | |
1580 | wxRichTextProperties() {} | |
1581 | ||
1582 | /** | |
1583 | Copy constructor. | |
1584 | */ | |
1585 | wxRichTextProperties(const wxRichTextProperties& props): wxObject() { Copy(props); } | |
1586 | ||
1587 | /** | |
1588 | Assignment operator. | |
1589 | */ | |
1590 | void operator=(const wxRichTextProperties& props) { Copy(props); } | |
1591 | ||
1592 | /** | |
1593 | Equality operator. | |
1594 | */ | |
1595 | bool operator==(const wxRichTextProperties& props) const; | |
1596 | ||
1597 | /** | |
1598 | Copies from @a props. | |
1599 | */ | |
1600 | void Copy(const wxRichTextProperties& props) { m_properties = props.m_properties; } | |
1601 | ||
1602 | /** | |
1603 | Returns the variant at the given index. | |
1604 | */ | |
1605 | const wxVariant& operator[](size_t idx) const { return m_properties[idx]; } | |
1606 | ||
1607 | /** | |
1608 | Returns the variant at the given index. | |
1609 | */ | |
1610 | wxVariant& operator[](size_t idx) { return m_properties[idx]; } | |
1611 | ||
1612 | /** | |
1613 | Clears the properties. | |
1614 | */ | |
1615 | void Clear() { m_properties.Clear(); } | |
1616 | ||
1617 | /** | |
1618 | Returns the array of variants implementing the properties. | |
1619 | */ | |
1620 | const wxRichTextVariantArray& GetProperties() const { return m_properties; } | |
1621 | ||
1622 | /** | |
1623 | Returns the array of variants implementing the properties. | |
1624 | */ | |
1625 | wxRichTextVariantArray& GetProperties() { return m_properties; } | |
1626 | ||
1627 | /** | |
1628 | Sets the array of variants. | |
1629 | */ | |
1630 | void SetProperties(const wxRichTextVariantArray& props) { m_properties = props; } | |
1631 | ||
1632 | /** | |
1633 | Returns all the property names. | |
1634 | */ | |
1635 | wxArrayString GetPropertyNames() const; | |
1636 | ||
1637 | /** | |
1638 | Returns a count of the properties. | |
1639 | */ | |
1640 | size_t GetCount() const { return m_properties.GetCount(); } | |
1641 | ||
1642 | /** | |
1643 | Returns @true if the given property is found. | |
1644 | */ | |
1645 | bool HasProperty(const wxString& name) const { return Find(name) != -1; } | |
1646 | ||
1647 | /** | |
1648 | Finds the given property. | |
1649 | */ | |
1650 | int Find(const wxString& name) const; | |
1651 | ||
1652 | /** | |
1653 | Removes the given property. | |
1654 | */ | |
1655 | bool Remove(const wxString& name); | |
1656 | ||
1657 | /** | |
1658 | Gets the property variant by name. | |
1659 | */ | |
1660 | const wxVariant& GetProperty(const wxString& name) const; | |
1661 | ||
1662 | /** | |
1663 | Finds or creates a property with the given name, returning a pointer to the variant. | |
1664 | */ | |
1665 | wxVariant* FindOrCreateProperty(const wxString& name); | |
1666 | ||
1667 | /** | |
1668 | Gets the value of the named property as a string. | |
1669 | */ | |
1670 | wxString GetPropertyString(const wxString& name) const; | |
1671 | ||
1672 | /** | |
1673 | Gets the value of the named property as a long integer. | |
1674 | */ | |
1675 | long GetPropertyLong(const wxString& name) const; | |
1676 | ||
1677 | /** | |
1678 | Gets the value of the named property as a boolean. | |
1679 | */ | |
1680 | bool GetPropertyBool(const wxString& name) const; | |
1681 | ||
1682 | /** | |
1683 | Gets the value of the named property as a double. | |
1684 | */ | |
1685 | double GetPropertyDouble(const wxString& name) const; | |
1686 | ||
1687 | /** | |
1688 | Sets the property by passing a variant which contains a name and value. | |
1689 | */ | |
1690 | void SetProperty(const wxVariant& variant); | |
1691 | ||
1692 | /** | |
1693 | Sets a property by name and variant. | |
1694 | */ | |
1695 | void SetProperty(const wxString& name, const wxVariant& variant); | |
1696 | ||
1697 | /** | |
1698 | Sets a property by name and string value. | |
1699 | */ | |
1700 | void SetProperty(const wxString& name, const wxString& value); | |
1701 | ||
1702 | /** | |
1703 | Sets property by name and long integer value. | |
1704 | */ | |
1705 | void SetProperty(const wxString& name, long value); | |
1706 | ||
1707 | /** | |
1708 | Sets property by name and double value. | |
1709 | */ | |
1710 | void SetProperty(const wxString& name, double value); | |
1711 | ||
1712 | /** | |
1713 | Sets property by name and boolean value. | |
1714 | */ | |
1715 | void SetProperty(const wxString& name, bool value); | |
1716 | ||
1717 | /** | |
1718 | Removes the given properties from these properties. | |
1719 | */ | |
1720 | void RemoveProperties(const wxRichTextProperties& properties); | |
1721 | ||
1722 | /** | |
1723 | Merges the given properties with these properties. | |
1724 | */ | |
1725 | void MergeProperties(const wxRichTextProperties& properties); | |
1726 | ||
1727 | protected: | |
1728 | wxRichTextVariantArray m_properties; | |
1729 | }; | |
1730 | ||
1731 | ||
1732 | /** | |
1733 | @class wxRichTextFontTable | |
1734 | Manages quick access to a pool of fonts for rendering rich text. | |
1735 | ||
1736 | @library{wxrichtext} | |
1737 | @category{richtext} | |
1738 | ||
1739 | @see wxRichTextBuffer, wxRichTextCtrl | |
1740 | */ | |
1741 | ||
1742 | class WXDLLIMPEXP_RICHTEXT wxRichTextFontTable: public wxObject | |
1743 | { | |
1744 | public: | |
1745 | /** | |
1746 | Default constructor. | |
1747 | */ | |
1748 | wxRichTextFontTable(); | |
1749 | ||
1750 | /** | |
1751 | Copy constructor. | |
1752 | */ | |
1753 | wxRichTextFontTable(const wxRichTextFontTable& table); | |
1754 | virtual ~wxRichTextFontTable(); | |
1755 | ||
1756 | /** | |
1757 | Returns @true if the font table is valid. | |
1758 | */ | |
1759 | bool IsOk() const { return m_refData != NULL; } | |
1760 | ||
1761 | /** | |
1762 | Finds a font for the given attribute object. | |
1763 | */ | |
1764 | wxFont FindFont(const wxRichTextAttr& fontSpec); | |
1765 | ||
1766 | /** | |
1767 | Clears the font table. | |
1768 | */ | |
1769 | void Clear(); | |
1770 | ||
1771 | /** | |
1772 | Assignment operator. | |
1773 | */ | |
1774 | void operator= (const wxRichTextFontTable& table); | |
1775 | ||
1776 | /** | |
1777 | Equality operator. | |
1778 | */ | |
1779 | bool operator == (const wxRichTextFontTable& table) const; | |
1780 | ||
1781 | /** | |
1782 | Inequality operator. | |
1783 | */ | |
1784 | bool operator != (const wxRichTextFontTable& table) const { return !(*this == table); } | |
1785 | ||
1786 | /** | |
1787 | Set the font scale factor. | |
1788 | */ | |
1789 | void SetFontScale(double fontScale); | |
1790 | ||
1791 | protected: | |
1792 | ||
1793 | double m_fontScale; | |
1794 | ||
1795 | DECLARE_DYNAMIC_CLASS(wxRichTextFontTable) | |
1796 | }; | |
1797 | ||
1798 | /** | |
1799 | @class wxRichTextRange | |
1800 | ||
1801 | This stores beginning and end positions for a range of data. | |
1802 | ||
1803 | @library{wxrichtext} | |
1804 | @category{richtext} | |
1805 | ||
1806 | @see wxRichTextBuffer, wxRichTextCtrl | |
1807 | */ | |
1808 | ||
1809 | class WXDLLIMPEXP_RICHTEXT wxRichTextRange | |
1810 | { | |
1811 | public: | |
1812 | // Constructors | |
1813 | ||
1814 | /** | |
1815 | Default constructor. | |
1816 | */ | |
1817 | wxRichTextRange() { m_start = 0; m_end = 0; } | |
1818 | ||
1819 | /** | |
1820 | Constructor taking start and end positions. | |
1821 | */ | |
1822 | wxRichTextRange(long start, long end) { m_start = start; m_end = end; } | |
1823 | ||
1824 | /** | |
1825 | Copy constructor. | |
1826 | */ | |
1827 | wxRichTextRange(const wxRichTextRange& range) { m_start = range.m_start; m_end = range.m_end; } | |
1828 | ~wxRichTextRange() {} | |
1829 | ||
1830 | /** | |
1831 | Assigns @a range to this range. | |
1832 | */ | |
1833 | void operator =(const wxRichTextRange& range) { m_start = range.m_start; m_end = range.m_end; } | |
1834 | ||
1835 | /** | |
1836 | Equality operator. Returns @true if @a range is the same as this range. | |
1837 | */ | |
1838 | bool operator ==(const wxRichTextRange& range) const { return (m_start == range.m_start && m_end == range.m_end); } | |
1839 | ||
1840 | /** | |
1841 | Inequality operator. | |
1842 | */ | |
1843 | bool operator !=(const wxRichTextRange& range) const { return (m_start != range.m_start || m_end != range.m_end); } | |
1844 | ||
1845 | /** | |
1846 | Subtracts a range from this range. | |
1847 | */ | |
1848 | wxRichTextRange operator -(const wxRichTextRange& range) const { return wxRichTextRange(m_start - range.m_start, m_end - range.m_end); } | |
1849 | ||
1850 | /** | |
1851 | Adds a range to this range. | |
1852 | */ | |
1853 | wxRichTextRange operator +(const wxRichTextRange& range) const { return wxRichTextRange(m_start + range.m_start, m_end + range.m_end); } | |
1854 | ||
1855 | /** | |
1856 | Sets the range start and end positions. | |
1857 | */ | |
1858 | void SetRange(long start, long end) { m_start = start; m_end = end; } | |
1859 | ||
1860 | /** | |
1861 | Sets the start position. | |
1862 | */ | |
1863 | void SetStart(long start) { m_start = start; } | |
1864 | ||
1865 | /** | |
1866 | Returns the start position. | |
1867 | */ | |
1868 | long GetStart() const { return m_start; } | |
1869 | ||
1870 | /** | |
1871 | Sets the end position. | |
1872 | */ | |
1873 | void SetEnd(long end) { m_end = end; } | |
1874 | ||
1875 | /** | |
1876 | Gets the end position. | |
1877 | */ | |
1878 | long GetEnd() const { return m_end; } | |
1879 | ||
1880 | /** | |
1881 | Returns true if this range is completely outside @a range. | |
1882 | */ | |
1883 | bool IsOutside(const wxRichTextRange& range) const { return range.m_start > m_end || range.m_end < m_start; } | |
1884 | ||
1885 | /** | |
1886 | Returns true if this range is completely within @a range. | |
1887 | */ | |
1888 | bool IsWithin(const wxRichTextRange& range) const { return m_start >= range.m_start && m_end <= range.m_end; } | |
1889 | ||
1890 | /** | |
1891 | Returns true if @a pos was within the range. Does not match if the range is empty. | |
1892 | */ | |
1893 | bool Contains(long pos) const { return pos >= m_start && pos <= m_end ; } | |
1894 | ||
1895 | /** | |
1896 | Limit this range to be within @a range. | |
1897 | */ | |
1898 | bool LimitTo(const wxRichTextRange& range) ; | |
1899 | ||
1900 | /** | |
1901 | Gets the length of the range. | |
1902 | */ | |
1903 | long GetLength() const { return m_end - m_start + 1; } | |
1904 | ||
1905 | /** | |
1906 | Swaps the start and end. | |
1907 | */ | |
1908 | void Swap() { long tmp = m_start; m_start = m_end; m_end = tmp; } | |
1909 | ||
1910 | /** | |
1911 | Converts the API-standard range, whose end is one past the last character in | |
1912 | the range, to the internal form, which uses the first and last character | |
1913 | positions of the range. In other words, one is subtracted from the end position. | |
1914 | (n, n) is the range of a single character. | |
1915 | */ | |
1916 | wxRichTextRange ToInternal() const { return wxRichTextRange(m_start, m_end-1); } | |
1917 | ||
1918 | /** | |
1919 | Converts the internal range, which uses the first and last character positions | |
1920 | of the range, to the API-standard range, whose end is one past the last | |
1921 | character in the range. In other words, one is added to the end position. | |
1922 | (n, n+1) is the range of a single character. | |
1923 | */ | |
1924 | wxRichTextRange FromInternal() const { return wxRichTextRange(m_start, m_end+1); } | |
1925 | ||
1926 | protected: | |
1927 | long m_start; | |
1928 | long m_end; | |
1929 | }; | |
1930 | ||
1931 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRichTextRange, wxRichTextRangeArray, WXDLLIMPEXP_RICHTEXT); | |
1932 | ||
1933 | #define wxRICHTEXT_ALL wxRichTextRange(-2, -2) | |
1934 | #define wxRICHTEXT_NONE wxRichTextRange(-1, -1) | |
1935 | ||
1936 | #define wxRICHTEXT_NO_SELECTION wxRichTextRange(-2, -2) | |
1937 | ||
1938 | /** | |
1939 | @class wxRichTextSelection | |
1940 | ||
1941 | Stores selection information. The selection does not have to be contiguous, though currently non-contiguous | |
1942 | selections are only supported for a range of table cells (a geometric block of cells can consist | |
1943 | of a set of non-contiguous positions). | |
1944 | ||
1945 | The selection consists of an array of ranges, and the container that is the context for the selection. It | |
1946 | follows that a single selection object can only represent ranges with the same parent container. | |
1947 | ||
1948 | @library{wxrichtext} | |
1949 | @category{richtext} | |
1950 | ||
1951 | @see wxRichTextBuffer, wxRichTextCtrl | |
1952 | */ | |
1953 | ||
1954 | class WXDLLIMPEXP_RICHTEXT wxRichTextSelection | |
1955 | { | |
1956 | public: | |
1957 | /** | |
1958 | Copy constructor. | |
1959 | */ | |
1960 | wxRichTextSelection(const wxRichTextSelection& sel) { Copy(sel); } | |
1961 | ||
1962 | /** | |
1963 | Creates a selection from a range and a container. | |
1964 | */ | |
1965 | wxRichTextSelection(const wxRichTextRange& range, wxRichTextParagraphLayoutBox* container) { m_ranges.Add(range); m_container = container; } | |
1966 | ||
1967 | /** | |
1968 | Default constructor. | |
1969 | */ | |
1970 | wxRichTextSelection() { Reset(); } | |
1971 | ||
1972 | /** | |
1973 | Resets the selection. | |
1974 | */ | |
1975 | void Reset() { m_ranges.Clear(); m_container = NULL; } | |
1976 | ||
1977 | /** | |
1978 | Sets the selection. | |
1979 | */ | |
1980 | ||
1981 | void Set(const wxRichTextRange& range, wxRichTextParagraphLayoutBox* container) | |
1982 | { m_ranges.Clear(); m_ranges.Add(range); m_container = container; } | |
1983 | ||
1984 | /** | |
1985 | Adds a range to the selection. | |
1986 | */ | |
1987 | void Add(const wxRichTextRange& range) | |
1988 | { m_ranges.Add(range); } | |
1989 | ||
1990 | /** | |
1991 | Sets the selections from an array of ranges and a container object. | |
1992 | */ | |
1993 | void Set(const wxRichTextRangeArray& ranges, wxRichTextParagraphLayoutBox* container) | |
1994 | { m_ranges = ranges; m_container = container; } | |
1995 | ||
1996 | /** | |
1997 | Copies from @a sel. | |
1998 | */ | |
1999 | void Copy(const wxRichTextSelection& sel) | |
2000 | { m_ranges = sel.m_ranges; m_container = sel.m_container; } | |
2001 | ||
2002 | /** | |
2003 | Assignment operator. | |
2004 | */ | |
2005 | void operator=(const wxRichTextSelection& sel) { Copy(sel); } | |
2006 | ||
2007 | /** | |
2008 | Equality operator. | |
2009 | */ | |
2010 | bool operator==(const wxRichTextSelection& sel) const; | |
2011 | ||
2012 | /** | |
2013 | Index operator. | |
2014 | */ | |
2015 | wxRichTextRange operator[](size_t i) const { return GetRange(i); } | |
2016 | ||
2017 | /** | |
2018 | Returns the selection ranges. | |
2019 | */ | |
2020 | wxRichTextRangeArray& GetRanges() { return m_ranges; } | |
2021 | ||
2022 | /** | |
2023 | Returns the selection ranges. | |
2024 | */ | |
2025 | const wxRichTextRangeArray& GetRanges() const { return m_ranges; } | |
2026 | ||
2027 | /** | |
2028 | Sets the selection ranges. | |
2029 | */ | |
2030 | void SetRanges(const wxRichTextRangeArray& ranges) { m_ranges = ranges; } | |
2031 | ||
2032 | /** | |
2033 | Returns the number of ranges in the selection. | |
2034 | */ | |
2035 | size_t GetCount() const { return m_ranges.GetCount(); } | |
2036 | ||
2037 | /** | |
2038 | Returns the range at the given index. | |
2039 | ||
2040 | */ | |
2041 | wxRichTextRange GetRange(size_t i) const { return m_ranges[i]; } | |
2042 | ||
2043 | /** | |
2044 | Returns the first range if there is one, otherwise wxRICHTEXT_NO_SELECTION. | |
2045 | */ | |
2046 | wxRichTextRange GetRange() const { return (m_ranges.GetCount() > 0) ? (m_ranges[0]) : wxRICHTEXT_NO_SELECTION; } | |
2047 | ||
2048 | /** | |
2049 | Sets a single range. | |
2050 | */ | |
2051 | void SetRange(const wxRichTextRange& range) { m_ranges.Clear(); m_ranges.Add(range); } | |
2052 | ||
2053 | /** | |
2054 | Returns the container for which the selection is valid. | |
2055 | */ | |
2056 | wxRichTextParagraphLayoutBox* GetContainer() const { return m_container; } | |
2057 | ||
2058 | /** | |
2059 | Sets the container for which the selection is valid. | |
2060 | */ | |
2061 | void SetContainer(wxRichTextParagraphLayoutBox* container) { m_container = container; } | |
2062 | ||
2063 | /** | |
2064 | Returns @true if the selection is valid. | |
2065 | */ | |
2066 | bool IsValid() const { return m_ranges.GetCount() > 0 && GetContainer(); } | |
2067 | ||
2068 | /** | |
2069 | Returns the selection appropriate to the specified object, if any; returns an empty array if none | |
2070 | at the level of the object's container. | |
2071 | */ | |
2072 | wxRichTextRangeArray GetSelectionForObject(wxRichTextObject* obj) const; | |
2073 | ||
2074 | /** | |
2075 | Returns @true if the given position is within the selection. | |
2076 | */ | |
2077 | bool WithinSelection(long pos, wxRichTextObject* obj) const; | |
2078 | ||
2079 | /** | |
2080 | Returns @true if the given position is within the selection. | |
2081 | ||
2082 | */ | |
2083 | bool WithinSelection(long pos) const { return WithinSelection(pos, m_ranges); } | |
2084 | ||
2085 | /** | |
2086 | Returns @true if the given position is within the selection range. | |
2087 | */ | |
2088 | static bool WithinSelection(long pos, const wxRichTextRangeArray& ranges); | |
2089 | ||
2090 | /** | |
2091 | Returns @true if the given range is within the selection range. | |
2092 | */ | |
2093 | static bool WithinSelection(const wxRichTextRange& range, const wxRichTextRangeArray& ranges); | |
2094 | ||
2095 | wxRichTextRangeArray m_ranges; | |
2096 | wxRichTextParagraphLayoutBox* m_container; | |
2097 | }; | |
2098 | ||
2099 | /** | |
2100 | @class wxRichTextDrawingContext | |
2101 | ||
2102 | A class for passing information to drawing and measuring functions. | |
2103 | ||
2104 | @library{wxrichtext} | |
2105 | @category{richtext} | |
2106 | ||
2107 | @see wxRichTextBuffer, wxRichTextCtrl | |
2108 | */ | |
2109 | ||
2110 | class WXDLLIMPEXP_RICHTEXT wxRichTextDrawingContext: public wxObject | |
2111 | { | |
2112 | DECLARE_CLASS(wxRichTextDrawingContext) | |
2113 | public: | |
2114 | ||
2115 | /** | |
2116 | Pass the buffer to the context so the context can retrieve information | |
2117 | such as virtual attributes. | |
2118 | */ | |
2119 | wxRichTextDrawingContext(wxRichTextBuffer* buffer); | |
2120 | ||
2121 | void Init() { m_buffer = NULL; m_enableVirtualAttributes = true; } | |
2122 | ||
2123 | /** | |
2124 | Does this object have virtual attributes? | |
2125 | Virtual attributes can be provided for visual cues without | |
2126 | affecting the actual styling. | |
2127 | */ | |
2128 | bool HasVirtualAttributes(wxRichTextObject* obj) const; | |
2129 | ||
2130 | /** | |
2131 | Returns the virtual attributes for this object. | |
2132 | Virtual attributes can be provided for visual cues without | |
2133 | affecting the actual styling. | |
2134 | */ | |
2135 | wxRichTextAttr GetVirtualAttributes(wxRichTextObject* obj) const; | |
2136 | ||
2137 | /** | |
2138 | Applies any virtual attributes relevant to this object. | |
2139 | */ | |
2140 | bool ApplyVirtualAttributes(wxRichTextAttr& attr, wxRichTextObject* obj) const; | |
2141 | ||
2142 | /** | |
2143 | Gets the count for mixed virtual attributes for individual positions within the object. | |
2144 | For example, individual characters within a text object may require special highlighting. | |
2145 | */ | |
2146 | int GetVirtualSubobjectAttributesCount(wxRichTextObject* obj) const; | |
2147 | ||
2148 | /** | |
2149 | Gets the mixed virtual attributes for individual positions within the object. | |
2150 | For example, individual characters within a text object may require special highlighting. | |
2151 | The function is passed the count returned by GetVirtualSubobjectAttributesCount. | |
2152 | */ | |
2153 | int GetVirtualSubobjectAttributes(wxRichTextObject* obj, wxArrayInt& positions, wxRichTextAttrArray& attributes) const; | |
2154 | ||
2155 | /** | |
2156 | Do we have virtual text for this object? Virtual text allows an application | |
2157 | to replace characters in an object for editing and display purposes, for example | |
2158 | for highlighting special characters. | |
2159 | */ | |
2160 | bool HasVirtualText(const wxRichTextPlainText* obj) const; | |
2161 | ||
2162 | /** | |
2163 | Gets the virtual text for this object. | |
2164 | */ | |
2165 | bool GetVirtualText(const wxRichTextPlainText* obj, wxString& text) const; | |
2166 | ||
2167 | /** | |
2168 | Enables virtual attribute processing. | |
2169 | */ | |
2170 | ||
2171 | void EnableVirtualAttributes(bool b) { m_enableVirtualAttributes = b; } | |
2172 | ||
2173 | /** | |
2174 | Returns @true if virtual attribute processing is enabled. | |
2175 | */ | |
2176 | ||
2177 | bool GetVirtualAttributesEnabled() const { return m_enableVirtualAttributes; } | |
2178 | ||
2179 | wxRichTextBuffer* m_buffer; | |
2180 | bool m_enableVirtualAttributes; | |
2181 | }; | |
2182 | ||
2183 | /** | |
2184 | @class wxRichTextObject | |
2185 | ||
2186 | This is the base for drawable rich text objects. | |
2187 | ||
2188 | @library{wxrichtext} | |
2189 | @category{richtext} | |
2190 | ||
2191 | @see wxRichTextBuffer, wxRichTextCtrl | |
2192 | */ | |
2193 | ||
2194 | class WXDLLIMPEXP_RICHTEXT wxRichTextObject: public wxObject | |
2195 | { | |
2196 | DECLARE_CLASS(wxRichTextObject) | |
2197 | public: | |
2198 | /** | |
2199 | Constructor, taking an optional parent pointer. | |
2200 | */ | |
2201 | wxRichTextObject(wxRichTextObject* parent = NULL); | |
2202 | ||
2203 | virtual ~wxRichTextObject(); | |
2204 | ||
2205 | // Overridables | |
2206 | ||
2207 | /** | |
2208 | Draw the item, within the given range. Some objects may ignore the range (for | |
2209 | example paragraphs) while others must obey it (lines, to implement wrapping) | |
2210 | */ | |
2211 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style) = 0; | |
2212 | ||
2213 | /** | |
2214 | Lay the item out at the specified position with the given size constraint. | |
2215 | Layout must set the cached size. @rect is the available space for the object, | |
2216 | and @a parentRect is the container that is used to determine a relative size | |
2217 | or position (for example if a text box must be 50% of the parent text box). | |
2218 | */ | |
2219 | virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style) = 0; | |
2220 | ||
2221 | /** | |
2222 | Hit-testing: returns a flag indicating hit test details, plus | |
2223 | information about position. @a contextObj is returned to specify what object | |
2224 | position is relevant to, since otherwise there's an ambiguity. | |
2225 | @ obj might not be a child of @a contextObj, since we may be referring to the container itself | |
2226 | if we have no hit on a child - for example if we click outside an object. | |
2227 | ||
2228 | The function puts the position in @a textPosition if one is found. | |
2229 | @a pt is in logical units (a zero y position is at the beginning of the buffer). | |
2230 | ||
2231 | Pass wxRICHTEXT_HITTEST_NO_NESTED_OBJECTS if you only want to consider objects | |
2232 | directly under the object you are calling HitTest on. Otherwise, it will recurse | |
2233 | and potentially find a nested object. | |
2234 | ||
2235 | @return One of the ::wxRichTextHitTestFlags values. | |
2236 | */ | |
2237 | ||
2238 | virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); | |
2239 | ||
2240 | /** | |
2241 | Finds the absolute position and row height for the given character position. | |
2242 | */ | |
2243 | virtual bool FindPosition(wxDC& WXUNUSED(dc), wxRichTextDrawingContext& WXUNUSED(context), long WXUNUSED(index), wxPoint& WXUNUSED(pt), int* WXUNUSED(height), bool WXUNUSED(forceLineStart)) { return false; } | |
2244 | ||
2245 | /** | |
2246 | Returns the best size, i.e. the ideal starting size for this object irrespective | |
2247 | of available space. For a short text string, it will be the size that exactly encloses | |
2248 | the text. For a longer string, it might use the parent width for example. | |
2249 | */ | |
2250 | virtual wxSize GetBestSize() const { return m_size; } | |
2251 | ||
2252 | /** | |
2253 | Returns the object size for the given range. Returns @false if the range | |
2254 | is invalid for this object. | |
2255 | */ | |
2256 | ||
2257 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const = 0; | |
2258 | ||
2259 | /** | |
2260 | Do a split from @a pos, returning an object containing the second part, and setting | |
2261 | the first part in 'this'. | |
2262 | */ | |
2263 | virtual wxRichTextObject* DoSplit(long WXUNUSED(pos)) { return NULL; } | |
2264 | ||
2265 | /** | |
2266 | Calculates the range of the object. By default, guess that the object is 1 unit long. | |
2267 | */ | |
2268 | virtual void CalculateRange(long start, long& end) { end = start ; m_range.SetRange(start, end); } | |
2269 | ||
2270 | /** | |
2271 | Deletes the given range. | |
2272 | */ | |
2273 | virtual bool DeleteRange(const wxRichTextRange& WXUNUSED(range)) { return false; } | |
2274 | ||
2275 | /** | |
2276 | Returns @true if the object is empty. | |
2277 | */ | |
2278 | virtual bool IsEmpty() const { return false; } | |
2279 | ||
2280 | /** | |
2281 | Returns @true if this class of object is floatable. | |
2282 | */ | |
2283 | virtual bool IsFloatable() const { return false; } | |
2284 | ||
2285 | /** | |
2286 | Returns @true if this object is currently floating. | |
2287 | */ | |
2288 | virtual bool IsFloating() const { return GetAttributes().GetTextBoxAttr().IsFloating(); } | |
2289 | ||
2290 | /** | |
2291 | Returns the floating direction. | |
2292 | */ | |
2293 | virtual int GetFloatDirection() const { return GetAttributes().GetTextBoxAttr().GetFloatMode(); } | |
2294 | ||
2295 | /** | |
2296 | Returns any text in this object for the given range. | |
2297 | */ | |
2298 | virtual wxString GetTextForRange(const wxRichTextRange& WXUNUSED(range)) const { return wxEmptyString; } | |
2299 | ||
2300 | /** | |
2301 | Returns @true if this object can merge itself with the given one. | |
2302 | */ | |
2303 | virtual bool CanMerge(wxRichTextObject* WXUNUSED(object), wxRichTextDrawingContext& WXUNUSED(context)) const { return false; } | |
2304 | ||
2305 | /** | |
2306 | Returns @true if this object merged itself with the given one. | |
2307 | The calling code will then delete the given object. | |
2308 | */ | |
2309 | virtual bool Merge(wxRichTextObject* WXUNUSED(object), wxRichTextDrawingContext& WXUNUSED(context)) { return false; } | |
2310 | ||
2311 | /** | |
2312 | JACS | |
2313 | Returns @true if this object can potentially be split, by virtue of having | |
2314 | different virtual attributes for individual sub-objects. | |
2315 | */ | |
2316 | virtual bool CanSplit(wxRichTextDrawingContext& WXUNUSED(context)) const { return false; } | |
2317 | ||
2318 | /** | |
2319 | Returns the final object in the split objects if this object was split due to differences between sub-object virtual attributes. | |
2320 | Returns itself if it was not split. | |
2321 | */ | |
2322 | virtual wxRichTextObject* Split(wxRichTextDrawingContext& WXUNUSED(context)) { return this; } | |
2323 | ||
2324 | /** | |
2325 | Dump object data to the given output stream for debugging. | |
2326 | */ | |
2327 | virtual void Dump(wxTextOutputStream& stream); | |
2328 | ||
2329 | /** | |
2330 | Returns @true if we can edit the object's properties via a GUI. | |
2331 | */ | |
2332 | virtual bool CanEditProperties() const { return false; } | |
2333 | ||
2334 | /** | |
2335 | Edits the object's properties via a GUI. | |
2336 | */ | |
2337 | virtual bool EditProperties(wxWindow* WXUNUSED(parent), wxRichTextBuffer* WXUNUSED(buffer)) { return false; } | |
2338 | ||
2339 | /** | |
2340 | Returns the label to be used for the properties context menu item. | |
2341 | */ | |
2342 | virtual wxString GetPropertiesMenuLabel() const { return wxEmptyString; } | |
2343 | ||
2344 | /** | |
2345 | Returns @true if objects of this class can accept the focus, i.e. a call to SetFocusObject | |
2346 | is possible. For example, containers supporting text, such as a text box object, can accept the focus, | |
2347 | but a table can't (set the focus to individual cells instead). | |
2348 | */ | |
2349 | virtual bool AcceptsFocus() const { return false; } | |
2350 | ||
2351 | #if wxUSE_XML | |
2352 | /** | |
2353 | Imports this object from XML. | |
2354 | */ | |
2355 | virtual bool ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse); | |
2356 | #endif | |
2357 | ||
2358 | #if wxRICHTEXT_HAVE_DIRECT_OUTPUT | |
2359 | /** | |
2360 | Exports this object directly to the given stream, bypassing the creation of a wxXmlNode hierarchy. | |
2361 | This method is considerably faster than creating a tree first. However, both versions of ExportXML must be | |
2362 | implemented so that if the tree method is made efficient in the future, we can deprecate the | |
2363 | more verbose direct output method. Compiled only if wxRICHTEXT_HAVE_DIRECT_OUTPUT is defined (on by default). | |
2364 | */ | |
2365 | virtual bool ExportXML(wxOutputStream& stream, int indent, wxRichTextXMLHandler* handler); | |
2366 | #endif | |
2367 | ||
2368 | #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT | |
2369 | /** | |
2370 | Exports this object to the given parent node, usually creating at least one child node. | |
2371 | This method is less efficient than the direct-to-stream method but is retained to allow for | |
2372 | switching to this method if we make it more efficient. Compiled only if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT is defined | |
2373 | (on by default). | |
2374 | */ | |
2375 | virtual bool ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler); | |
2376 | #endif | |
2377 | ||
2378 | /** | |
2379 | Returns @true if this object takes note of paragraph attributes (text and image objects don't). | |
2380 | */ | |
2381 | virtual bool UsesParagraphAttributes() const { return true; } | |
2382 | ||
2383 | /** | |
2384 | Returns the XML node name of this object. This must be overridden for wxXmlNode-base XML export to work. | |
2385 | */ | |
2386 | virtual wxString GetXMLNodeName() const { return wxT("unknown"); } | |
2387 | ||
2388 | /** | |
2389 | Invalidates the object at the given range. With no argument, invalidates the whole object. | |
2390 | */ | |
2391 | virtual void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL); | |
2392 | ||
2393 | /** | |
2394 | Returns @true if this object can handle the selections of its children, fOr example a table. | |
2395 | Required for composite selection handling to work. | |
2396 | */ | |
2397 | virtual bool HandlesChildSelections() const { return false; } | |
2398 | ||
2399 | /** | |
2400 | Returns a selection object specifying the selections between start and end character positions. | |
2401 | For example, a table would deduce what cells (of range length 1) are selected when dragging across the table. | |
2402 | */ | |
2403 | virtual wxRichTextSelection GetSelection(long WXUNUSED(start), long WXUNUSED(end)) const { return wxRichTextSelection(); } | |
2404 | ||
2405 | // Accessors | |
2406 | ||
2407 | /** | |
2408 | Gets the cached object size as calculated by Layout. | |
2409 | */ | |
2410 | virtual wxSize GetCachedSize() const { return m_size; } | |
2411 | ||
2412 | /** | |
2413 | Sets the cached object size as calculated by Layout. | |
2414 | */ | |
2415 | virtual void SetCachedSize(const wxSize& sz) { m_size = sz; } | |
2416 | ||
2417 | /** | |
2418 | Gets the maximum object size as calculated by Layout. This allows | |
2419 | us to fit an object to its contents or allocate extra space if required. | |
2420 | */ | |
2421 | virtual wxSize GetMaxSize() const { return m_maxSize; } | |
2422 | ||
2423 | /** | |
2424 | Sets the maximum object size as calculated by Layout. This allows | |
2425 | us to fit an object to its contents or allocate extra space if required. | |
2426 | */ | |
2427 | virtual void SetMaxSize(const wxSize& sz) { m_maxSize = sz; } | |
2428 | ||
2429 | /** | |
2430 | Gets the minimum object size as calculated by Layout. This allows | |
2431 | us to constrain an object to its absolute minimum size if necessary. | |
2432 | */ | |
2433 | virtual wxSize GetMinSize() const { return m_minSize; } | |
2434 | ||
2435 | /** | |
2436 | Sets the minimum object size as calculated by Layout. This allows | |
2437 | us to constrain an object to its absolute minimum size if necessary. | |
2438 | */ | |
2439 | virtual void SetMinSize(const wxSize& sz) { m_minSize = sz; } | |
2440 | ||
2441 | /** | |
2442 | Gets the 'natural' size for an object. For an image, it would be the | |
2443 | image size. | |
2444 | */ | |
2445 | virtual wxTextAttrSize GetNaturalSize() const { return wxTextAttrSize(); } | |
2446 | ||
2447 | /** | |
2448 | Returns the object position in pixels. | |
2449 | */ | |
2450 | virtual wxPoint GetPosition() const { return m_pos; } | |
2451 | ||
2452 | /** | |
2453 | Sets the object position in pixels. | |
2454 | */ | |
2455 | virtual void SetPosition(const wxPoint& pos) { m_pos = pos; } | |
2456 | ||
2457 | /** | |
2458 | Returns the absolute object position, by traversing up the child/parent hierarchy. | |
2459 | TODO: may not be needed, if all object positions are in fact relative to the | |
2460 | top of the coordinate space. | |
2461 | */ | |
2462 | virtual wxPoint GetAbsolutePosition() const; | |
2463 | ||
2464 | /** | |
2465 | Returns the rectangle enclosing the object. | |
2466 | */ | |
2467 | virtual wxRect GetRect() const { return wxRect(GetPosition(), GetCachedSize()); } | |
2468 | ||
2469 | /** | |
2470 | Sets the object's range within its container. | |
2471 | */ | |
2472 | void SetRange(const wxRichTextRange& range) { m_range = range; } | |
2473 | ||
2474 | /** | |
2475 | Returns the object's range. | |
2476 | */ | |
2477 | const wxRichTextRange& GetRange() const { return m_range; } | |
2478 | ||
2479 | /** | |
2480 | Returns the object's range. | |
2481 | */ | |
2482 | wxRichTextRange& GetRange() { return m_range; } | |
2483 | ||
2484 | /** | |
2485 | Set the object's own range, for a top-level object with its own position space. | |
2486 | */ | |
2487 | void SetOwnRange(const wxRichTextRange& range) { m_ownRange = range; } | |
2488 | ||
2489 | /** | |
2490 | Returns the object's own range (valid if top-level). | |
2491 | */ | |
2492 | const wxRichTextRange& GetOwnRange() const { return m_ownRange; } | |
2493 | ||
2494 | /** | |
2495 | Returns the object's own range (valid if top-level). | |
2496 | */ | |
2497 | wxRichTextRange& GetOwnRange() { return m_ownRange; } | |
2498 | ||
2499 | /** | |
2500 | Returns the object's own range only if a top-level object. | |
2501 | */ | |
2502 | wxRichTextRange GetOwnRangeIfTopLevel() const { return IsTopLevel() ? m_ownRange : m_range; } | |
2503 | ||
2504 | /** | |
2505 | Returns @true if this object is composite. | |
2506 | */ | |
2507 | virtual bool IsComposite() const { return false; } | |
2508 | ||
2509 | /** | |
2510 | Returns @true if no user editing can be done inside the object. This returns @true for simple objects, | |
2511 | @false for most composite objects, but @true for fields, which if composite, should not be user-edited. | |
2512 | */ | |
2513 | virtual bool IsAtomic() const { return true; } | |
2514 | ||
2515 | /** | |
2516 | Returns a pointer to the parent object. | |
2517 | */ | |
2518 | virtual wxRichTextObject* GetParent() const { return m_parent; } | |
2519 | ||
2520 | /** | |
2521 | Sets the pointer to the parent object. | |
2522 | */ | |
2523 | virtual void SetParent(wxRichTextObject* parent) { m_parent = parent; } | |
2524 | ||
2525 | /** | |
2526 | Returns the top-level container of this object. | |
2527 | May return itself if it's a container; use GetParentContainer to return | |
2528 | a different container. | |
2529 | */ | |
2530 | virtual wxRichTextParagraphLayoutBox* GetContainer() const; | |
2531 | ||
2532 | /** | |
2533 | Returns the top-level container of this object. | |
2534 | Returns a different container than itself, unless there's no parent, in which case it will return NULL. | |
2535 | */ | |
2536 | virtual wxRichTextParagraphLayoutBox* GetParentContainer() const { return GetParent() ? GetParent()->GetContainer() : GetContainer(); } | |
2537 | ||
2538 | /** | |
2539 | Set the margin around the object, in pixels. | |
2540 | */ | |
2541 | virtual void SetMargins(int margin); | |
2542 | ||
2543 | /** | |
2544 | Set the margin around the object, in pixels. | |
2545 | */ | |
2546 | virtual void SetMargins(int leftMargin, int rightMargin, int topMargin, int bottomMargin); | |
2547 | ||
2548 | /** | |
2549 | Returns the left margin of the object, in pixels. | |
2550 | */ | |
2551 | virtual int GetLeftMargin() const; | |
2552 | ||
2553 | /** | |
2554 | Returns the right margin of the object, in pixels. | |
2555 | */ | |
2556 | virtual int GetRightMargin() const; | |
2557 | ||
2558 | /** | |
2559 | Returns the top margin of the object, in pixels. | |
2560 | */ | |
2561 | virtual int GetTopMargin() const; | |
2562 | ||
2563 | /** | |
2564 | Returns the bottom margin of the object, in pixels. | |
2565 | */ | |
2566 | virtual int GetBottomMargin() const; | |
2567 | ||
2568 | /** | |
2569 | Calculates the available content space in the given rectangle, given the | |
2570 | margins, border and padding specified in the object's attributes. | |
2571 | */ | |
2572 | virtual wxRect GetAvailableContentArea(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& outerRect) const; | |
2573 | ||
2574 | /** | |
2575 | Lays out the object first with a given amount of space, and then if no width was specified in attr, | |
2576 | lays out the object again using the minimum size. @a availableParentSpace is the maximum space | |
2577 | for the object, whereas @a availableContainerSpace is the container with which relative positions and | |
2578 | sizes should be computed. For example, a text box whose space has already been constrained | |
2579 | in a previous layout pass to @a availableParentSpace, but should have a width of 50% of @a availableContainerSpace. | |
2580 | (If these two rects were the same, a 2nd pass could see the object getting too small.) | |
2581 | */ | |
2582 | virtual bool LayoutToBestSize(wxDC& dc, wxRichTextDrawingContext& context, wxRichTextBuffer* buffer, | |
2583 | const wxRichTextAttr& parentAttr, const wxRichTextAttr& attr, | |
2584 | const wxRect& availableParentSpace, const wxRect& availableContainerSpace, int style); | |
2585 | ||
2586 | /** | |
2587 | Sets the object's attributes. | |
2588 | */ | |
2589 | void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; } | |
2590 | ||
2591 | /** | |
2592 | Returns the object's attributes. | |
2593 | */ | |
2594 | const wxRichTextAttr& GetAttributes() const { return m_attributes; } | |
2595 | ||
2596 | /** | |
2597 | Returns the object's attributes. | |
2598 | */ | |
2599 | wxRichTextAttr& GetAttributes() { return m_attributes; } | |
2600 | ||
2601 | /** | |
2602 | Returns the object's properties. | |
2603 | */ | |
2604 | wxRichTextProperties& GetProperties() { return m_properties; } | |
2605 | ||
2606 | /** | |
2607 | Returns the object's properties. | |
2608 | */ | |
2609 | const wxRichTextProperties& GetProperties() const { return m_properties; } | |
2610 | ||
2611 | /** | |
2612 | Sets the object's properties. | |
2613 | */ | |
2614 | void SetProperties(const wxRichTextProperties& props) { m_properties = props; } | |
2615 | ||
2616 | /** | |
2617 | Sets the stored descent value. | |
2618 | */ | |
2619 | void SetDescent(int descent) { m_descent = descent; } | |
2620 | ||
2621 | /** | |
2622 | Returns the stored descent value. | |
2623 | */ | |
2624 | int GetDescent() const { return m_descent; } | |
2625 | ||
2626 | /** | |
2627 | Returns the containing buffer. | |
2628 | */ | |
2629 | wxRichTextBuffer* GetBuffer() const; | |
2630 | ||
2631 | /** | |
2632 | Sets the identifying name for this object as a property using the "name" key. | |
2633 | */ | |
2634 | void SetName(const wxString& name) { m_properties.SetProperty(wxT("name"), name); } | |
2635 | ||
2636 | /** | |
2637 | Returns the identifying name for this object from the properties, using the "name" key. | |
2638 | */ | |
2639 | wxString GetName() const { return m_properties.GetPropertyString(wxT("name")); } | |
2640 | ||
2641 | /** | |
2642 | Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box. | |
2643 | */ | |
2644 | virtual bool IsTopLevel() const { return false; } | |
2645 | ||
2646 | /** | |
2647 | Returns @true if the object will be shown, @false otherwise. | |
2648 | */ | |
2649 | bool IsShown() const { return m_show; } | |
2650 | ||
2651 | // Operations | |
2652 | ||
2653 | /** | |
2654 | Call to show or hide this object. This function does not cause the content to be | |
2655 | laid out or redrawn. | |
2656 | */ | |
2657 | virtual void Show(bool show) { m_show = show; } | |
2658 | ||
2659 | /** | |
2660 | Clones the object. | |
2661 | */ | |
2662 | virtual wxRichTextObject* Clone() const { return NULL; } | |
2663 | ||
2664 | /** | |
2665 | Copies the object. | |
2666 | */ | |
2667 | void Copy(const wxRichTextObject& obj); | |
2668 | ||
2669 | /** | |
2670 | Reference-counting allows us to use the same object in multiple | |
2671 | lists (not yet used). | |
2672 | */ | |
2673 | ||
2674 | void Reference() { m_refCount ++; } | |
2675 | ||
2676 | /** | |
2677 | Reference-counting allows us to use the same object in multiple | |
2678 | lists (not yet used). | |
2679 | */ | |
2680 | void Dereference(); | |
2681 | ||
2682 | /** | |
2683 | Moves the object recursively, by adding the offset from old to new. | |
2684 | */ | |
2685 | virtual void Move(const wxPoint& pt); | |
2686 | ||
2687 | /** | |
2688 | Converts units in tenths of a millimetre to device units. | |
2689 | */ | |
2690 | int ConvertTenthsMMToPixels(wxDC& dc, int units) const; | |
2691 | ||
2692 | /** | |
2693 | Converts units in tenths of a millimetre to device units. | |
2694 | */ | |
2695 | static int ConvertTenthsMMToPixels(int ppi, int units, double scale = 1.0); | |
2696 | ||
2697 | /** | |
2698 | Convert units in pixels to tenths of a millimetre. | |
2699 | */ | |
2700 | int ConvertPixelsToTenthsMM(wxDC& dc, int pixels) const; | |
2701 | ||
2702 | /** | |
2703 | Convert units in pixels to tenths of a millimetre. | |
2704 | */ | |
2705 | static int ConvertPixelsToTenthsMM(int ppi, int pixels, double scale = 1.0); | |
2706 | ||
2707 | /** | |
2708 | Draws the borders and background for the given rectangle and attributes. | |
2709 | @a boxRect is taken to be the outer margin box, not the box around the content. | |
2710 | */ | |
2711 | static bool DrawBoxAttributes(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, const wxRect& boxRect, int flags = 0, wxRichTextObject* obj = NULL); | |
2712 | ||
2713 | /** | |
2714 | Draws a border. | |
2715 | */ | |
2716 | static bool DrawBorder(wxDC& dc, wxRichTextBuffer* buffer, const wxTextAttrBorders& attr, const wxRect& rect, int flags = 0); | |
2717 | ||
2718 | /** | |
2719 | Returns the various rectangles of the box model in pixels. You can either specify @a contentRect (inner) | |
2720 | or @a marginRect (outer), and the other must be the default rectangle (no width or height). | |
2721 | Note that the outline doesn't affect the position of the rectangle, it's drawn in whatever space | |
2722 | is available. | |
2723 | */ | |
2724 | static bool GetBoxRects(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, wxRect& marginRect, wxRect& borderRect, wxRect& contentRect, wxRect& paddingRect, wxRect& outlineRect); | |
2725 | ||
2726 | /** | |
2727 | Returns the total margin for the object in pixels, taking into account margin, padding and border size. | |
2728 | */ | |
2729 | static bool GetTotalMargin(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& attr, int& leftMargin, int& rightMargin, | |
2730 | int& topMargin, int& bottomMargin); | |
2731 | ||
2732 | /** | |
2733 | Returns the rectangle which the child has available to it given restrictions specified in the | |
2734 | child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc. | |
2735 | availableContainerSpace might be a parent that the cell has to compute its width relative to. | |
2736 | E.g. a cell that's 50% of its parent. | |
2737 | */ | |
2738 | static wxRect AdjustAvailableSpace(wxDC& dc, wxRichTextBuffer* buffer, const wxRichTextAttr& parentAttr, const wxRichTextAttr& childAttr, | |
2739 | const wxRect& availableParentSpace, const wxRect& availableContainerSpace); | |
2740 | ||
2741 | protected: | |
2742 | wxSize m_size; | |
2743 | wxSize m_maxSize; | |
2744 | wxSize m_minSize; | |
2745 | wxPoint m_pos; | |
2746 | int m_descent; // Descent for this object (if any) | |
2747 | int m_refCount; | |
2748 | bool m_show; | |
2749 | wxRichTextObject* m_parent; | |
2750 | ||
2751 | // The range of this object (start position to end position) | |
2752 | wxRichTextRange m_range; | |
2753 | ||
2754 | // The internal range of this object, if it's a top-level object with its own range space | |
2755 | wxRichTextRange m_ownRange; | |
2756 | ||
2757 | // Attributes | |
2758 | wxRichTextAttr m_attributes; | |
2759 | ||
2760 | // Properties | |
2761 | wxRichTextProperties m_properties; | |
2762 | }; | |
2763 | ||
2764 | WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_RICHTEXT ); | |
2765 | ||
2766 | /** | |
2767 | @class wxRichTextCompositeObject | |
2768 | ||
2769 | Objects of this class can contain other objects. | |
2770 | ||
2771 | @library{wxrichtext} | |
2772 | @category{richtext} | |
2773 | ||
2774 | @see wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl | |
2775 | */ | |
2776 | ||
2777 | class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject: public wxRichTextObject | |
2778 | { | |
2779 | DECLARE_CLASS(wxRichTextCompositeObject) | |
2780 | public: | |
2781 | // Constructors | |
2782 | ||
2783 | wxRichTextCompositeObject(wxRichTextObject* parent = NULL); | |
2784 | virtual ~wxRichTextCompositeObject(); | |
2785 | ||
2786 | // Overridables | |
2787 | ||
2788 | virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); | |
2789 | ||
2790 | virtual bool FindPosition(wxDC& dc, wxRichTextDrawingContext& context, long index, wxPoint& pt, int* height, bool forceLineStart); | |
2791 | ||
2792 | virtual void CalculateRange(long start, long& end); | |
2793 | ||
2794 | virtual bool DeleteRange(const wxRichTextRange& range); | |
2795 | ||
2796 | virtual wxString GetTextForRange(const wxRichTextRange& range) const; | |
2797 | ||
2798 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const; | |
2799 | ||
2800 | virtual void Dump(wxTextOutputStream& stream); | |
2801 | ||
2802 | virtual void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL); | |
2803 | ||
2804 | // Accessors | |
2805 | ||
2806 | /** | |
2807 | Returns the children. | |
2808 | */ | |
2809 | wxRichTextObjectList& GetChildren() { return m_children; } | |
2810 | /** | |
2811 | Returns the children. | |
2812 | */ | |
2813 | const wxRichTextObjectList& GetChildren() const { return m_children; } | |
2814 | ||
2815 | /** | |
2816 | Returns the number of children. | |
2817 | */ | |
2818 | size_t GetChildCount() const ; | |
2819 | ||
2820 | /** | |
2821 | Returns the nth child. | |
2822 | */ | |
2823 | wxRichTextObject* GetChild(size_t n) const ; | |
2824 | ||
2825 | /** | |
2826 | Returns @true if this object is composite. | |
2827 | */ | |
2828 | virtual bool IsComposite() const { return true; } | |
2829 | ||
2830 | /** | |
2831 | Returns @true if no user editing can be done inside the object. This returns @true for simple objects, | |
2832 | @false for most composite objects, but @true for fields, which if composite, should not be user-edited. | |
2833 | */ | |
2834 | virtual bool IsAtomic() const { return false; } | |
2835 | ||
2836 | /** | |
2837 | Returns true if the buffer is empty. | |
2838 | */ | |
2839 | virtual bool IsEmpty() const { return GetChildCount() == 0; } | |
2840 | ||
2841 | /** | |
2842 | Returns the child object at the given character position. | |
2843 | */ | |
2844 | virtual wxRichTextObject* GetChildAtPosition(long pos) const; | |
2845 | ||
2846 | // Operations | |
2847 | ||
2848 | void Copy(const wxRichTextCompositeObject& obj); | |
2849 | ||
2850 | void operator= (const wxRichTextCompositeObject& obj) { Copy(obj); } | |
2851 | ||
2852 | /** | |
2853 | Appends a child, returning the position. | |
2854 | */ | |
2855 | size_t AppendChild(wxRichTextObject* child) ; | |
2856 | ||
2857 | /** | |
2858 | Inserts the child in front of the given object, or at the beginning. | |
2859 | */ | |
2860 | bool InsertChild(wxRichTextObject* child, wxRichTextObject* inFrontOf) ; | |
2861 | ||
2862 | /** | |
2863 | Removes and optionally deletes the specified child. | |
2864 | */ | |
2865 | bool RemoveChild(wxRichTextObject* child, bool deleteChild = false) ; | |
2866 | ||
2867 | /** | |
2868 | Deletes all the children. | |
2869 | */ | |
2870 | bool DeleteChildren() ; | |
2871 | ||
2872 | /** | |
2873 | Recursively merges all pieces that can be merged. | |
2874 | */ | |
2875 | bool Defragment(wxRichTextDrawingContext& context, const wxRichTextRange& range = wxRICHTEXT_ALL); | |
2876 | ||
2877 | /** | |
2878 | Moves the object recursively, by adding the offset from old to new. | |
2879 | */ | |
2880 | virtual void Move(const wxPoint& pt); | |
2881 | ||
2882 | protected: | |
2883 | wxRichTextObjectList m_children; | |
2884 | }; | |
2885 | ||
2886 | /** | |
2887 | @class wxRichTextParagraphBox | |
2888 | ||
2889 | This class knows how to lay out paragraphs. | |
2890 | ||
2891 | @library{wxrichtext} | |
2892 | @category{richtext} | |
2893 | ||
2894 | @see wxRichTextCompositeObject, wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl | |
2895 | */ | |
2896 | ||
2897 | class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphLayoutBox: public wxRichTextCompositeObject | |
2898 | { | |
2899 | DECLARE_DYNAMIC_CLASS(wxRichTextParagraphLayoutBox) | |
2900 | public: | |
2901 | // Constructors | |
2902 | ||
2903 | wxRichTextParagraphLayoutBox(wxRichTextObject* parent = NULL); | |
2904 | wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox& obj): wxRichTextCompositeObject() { Init(); Copy(obj); } | |
2905 | ~wxRichTextParagraphLayoutBox(); | |
2906 | ||
2907 | // Overridables | |
2908 | ||
2909 | virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); | |
2910 | ||
2911 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
2912 | ||
2913 | virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); | |
2914 | ||
2915 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const; | |
2916 | ||
2917 | virtual bool DeleteRange(const wxRichTextRange& range); | |
2918 | ||
2919 | virtual wxString GetTextForRange(const wxRichTextRange& range) const; | |
2920 | ||
2921 | #if wxUSE_XML | |
2922 | virtual bool ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse); | |
2923 | #endif | |
2924 | ||
2925 | #if wxRICHTEXT_HAVE_DIRECT_OUTPUT | |
2926 | virtual bool ExportXML(wxOutputStream& stream, int indent, wxRichTextXMLHandler* handler); | |
2927 | #endif | |
2928 | ||
2929 | #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT | |
2930 | virtual bool ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler); | |
2931 | #endif | |
2932 | ||
2933 | virtual wxString GetXMLNodeName() const { return wxT("paragraphlayout"); } | |
2934 | ||
2935 | virtual bool AcceptsFocus() const { return true; } | |
2936 | ||
2937 | // Accessors | |
2938 | ||
2939 | /** | |
2940 | Associates a control with the buffer, for operations that for example require refreshing the window. | |
2941 | */ | |
2942 | void SetRichTextCtrl(wxRichTextCtrl* ctrl) { m_ctrl = ctrl; } | |
2943 | ||
2944 | /** | |
2945 | Returns the associated control. | |
2946 | */ | |
2947 | wxRichTextCtrl* GetRichTextCtrl() const { return m_ctrl; } | |
2948 | ||
2949 | /** | |
2950 | Sets a flag indicating whether the last paragraph is partial or complete. | |
2951 | */ | |
2952 | void SetPartialParagraph(bool partialPara) { m_partialParagraph = partialPara; } | |
2953 | ||
2954 | /** | |
2955 | Returns a flag indicating whether the last paragraph is partial or complete. | |
2956 | */ | |
2957 | bool GetPartialParagraph() const { return m_partialParagraph; } | |
2958 | ||
2959 | /** | |
2960 | Returns the style sheet associated with the overall buffer. | |
2961 | */ | |
2962 | virtual wxRichTextStyleSheet* GetStyleSheet() const; | |
2963 | ||
2964 | virtual bool IsTopLevel() const { return true; } | |
2965 | ||
2966 | // Operations | |
2967 | ||
2968 | /** | |
2969 | Submits a command to insert paragraphs. | |
2970 | */ | |
2971 | bool InsertParagraphsWithUndo(wxRichTextBuffer* buffer, long pos, const wxRichTextParagraphLayoutBox& paragraphs, wxRichTextCtrl* ctrl, int flags = 0); | |
2972 | ||
2973 | /** | |
2974 | Submits a command to insert the given text. | |
2975 | */ | |
2976 | bool InsertTextWithUndo(wxRichTextBuffer* buffer, long pos, const wxString& text, wxRichTextCtrl* ctrl, int flags = 0); | |
2977 | ||
2978 | /** | |
2979 | Submits a command to insert the given text. | |
2980 | */ | |
2981 | bool InsertNewlineWithUndo(wxRichTextBuffer* buffer, long pos, wxRichTextCtrl* ctrl, int flags = 0); | |
2982 | ||
2983 | /** | |
2984 | Submits a command to insert the given image. | |
2985 | */ | |
2986 | bool InsertImageWithUndo(wxRichTextBuffer* buffer, long pos, const wxRichTextImageBlock& imageBlock, | |
2987 | wxRichTextCtrl* ctrl, int flags, const wxRichTextAttr& textAttr); | |
2988 | ||
2989 | /** | |
2990 | Submits a command to insert the given field. Field data can be included in properties. | |
2991 | ||
2992 | @see wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard | |
2993 | */ | |
2994 | wxRichTextField* InsertFieldWithUndo(wxRichTextBuffer* buffer, long pos, const wxString& fieldType, | |
2995 | const wxRichTextProperties& properties, | |
2996 | wxRichTextCtrl* ctrl, int flags, | |
2997 | const wxRichTextAttr& textAttr); | |
2998 | ||
2999 | /** | |
3000 | Returns the style that is appropriate for a new paragraph at this position. | |
3001 | If the previous paragraph has a paragraph style name, looks up the next-paragraph | |
3002 | style. | |
3003 | */ | |
3004 | wxRichTextAttr GetStyleForNewParagraph(wxRichTextBuffer* buffer, long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const; | |
3005 | ||
3006 | /** | |
3007 | Inserts an object. | |
3008 | */ | |
3009 | wxRichTextObject* InsertObjectWithUndo(wxRichTextBuffer* buffer, long pos, wxRichTextObject *object, wxRichTextCtrl* ctrl, int flags = 0); | |
3010 | ||
3011 | /** | |
3012 | Submits a command to delete this range. | |
3013 | */ | |
3014 | bool DeleteRangeWithUndo(const wxRichTextRange& range, wxRichTextCtrl* ctrl, wxRichTextBuffer* buffer); | |
3015 | ||
3016 | /** | |
3017 | Draws the floating objects in this buffer. | |
3018 | */ | |
3019 | void DrawFloats(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
3020 | ||
3021 | /** | |
3022 | Moves an anchored object to another paragraph. | |
3023 | */ | |
3024 | void MoveAnchoredObjectToParagraph(wxRichTextParagraph* from, wxRichTextParagraph* to, wxRichTextObject* obj); | |
3025 | ||
3026 | /** | |
3027 | Initializes the object. | |
3028 | */ | |
3029 | void Init(); | |
3030 | ||
3031 | /** | |
3032 | Clears all the children. | |
3033 | */ | |
3034 | virtual void Clear(); | |
3035 | ||
3036 | /** | |
3037 | Clears and initializes with one blank paragraph. | |
3038 | */ | |
3039 | virtual void Reset(); | |
3040 | ||
3041 | /** | |
3042 | Convenience function to add a paragraph of text. | |
3043 | */ | |
3044 | virtual wxRichTextRange AddParagraph(const wxString& text, wxRichTextAttr* paraStyle = NULL); | |
3045 | ||
3046 | /** | |
3047 | Convenience function to add an image. | |
3048 | */ | |
3049 | virtual wxRichTextRange AddImage(const wxImage& image, wxRichTextAttr* paraStyle = NULL); | |
3050 | ||
3051 | /** | |
3052 | Adds multiple paragraphs, based on newlines. | |
3053 | */ | |
3054 | virtual wxRichTextRange AddParagraphs(const wxString& text, wxRichTextAttr* paraStyle = NULL); | |
3055 | ||
3056 | /** | |
3057 | Returns the line at the given position. If @a caretPosition is true, the position is | |
3058 | a caret position, which is normally a smaller number. | |
3059 | */ | |
3060 | virtual wxRichTextLine* GetLineAtPosition(long pos, bool caretPosition = false) const; | |
3061 | ||
3062 | /** | |
3063 | Returns the line at the given y pixel position, or the last line. | |
3064 | */ | |
3065 | virtual wxRichTextLine* GetLineAtYPosition(int y) const; | |
3066 | ||
3067 | /** | |
3068 | Returns the paragraph at the given character or caret position. | |
3069 | */ | |
3070 | virtual wxRichTextParagraph* GetParagraphAtPosition(long pos, bool caretPosition = false) const; | |
3071 | ||
3072 | /** | |
3073 | Returns the line size at the given position. | |
3074 | */ | |
3075 | virtual wxSize GetLineSizeAtPosition(long pos, bool caretPosition = false) const; | |
3076 | ||
3077 | /** | |
3078 | Given a position, returns the number of the visible line (potentially many to a paragraph), | |
3079 | starting from zero at the start of the buffer. We also have to pass a bool (@a startOfLine) | |
3080 | that indicates whether the caret is being shown at the end of the previous line or at the start | |
3081 | of the next, since the caret can be shown at two visible positions for the same underlying | |
3082 | position. | |
3083 | */ | |
3084 | virtual long GetVisibleLineNumber(long pos, bool caretPosition = false, bool startOfLine = false) const; | |
3085 | ||
3086 | /** | |
3087 | Given a line number, returns the corresponding wxRichTextLine object. | |
3088 | */ | |
3089 | virtual wxRichTextLine* GetLineForVisibleLineNumber(long lineNumber) const; | |
3090 | ||
3091 | /** | |
3092 | Returns the leaf object in a paragraph at this position. | |
3093 | */ | |
3094 | virtual wxRichTextObject* GetLeafObjectAtPosition(long position) const; | |
3095 | ||
3096 | /** | |
3097 | Returns the paragraph by number. | |
3098 | */ | |
3099 | virtual wxRichTextParagraph* GetParagraphAtLine(long paragraphNumber) const; | |
3100 | ||
3101 | /** | |
3102 | Returns the paragraph for a given line. | |
3103 | */ | |
3104 | virtual wxRichTextParagraph* GetParagraphForLine(wxRichTextLine* line) const; | |
3105 | ||
3106 | /** | |
3107 | Returns the length of the paragraph. | |
3108 | */ | |
3109 | virtual int GetParagraphLength(long paragraphNumber) const; | |
3110 | ||
3111 | /** | |
3112 | Returns the number of paragraphs. | |
3113 | */ | |
3114 | virtual int GetParagraphCount() const { return static_cast<int>(GetChildCount()); } | |
3115 | ||
3116 | /** | |
3117 | Returns the number of visible lines. | |
3118 | */ | |
3119 | virtual int GetLineCount() const; | |
3120 | ||
3121 | /** | |
3122 | Returns the text of the paragraph. | |
3123 | */ | |
3124 | virtual wxString GetParagraphText(long paragraphNumber) const; | |
3125 | ||
3126 | /** | |
3127 | Converts zero-based line column and paragraph number to a position. | |
3128 | */ | |
3129 | virtual long XYToPosition(long x, long y) const; | |
3130 | ||
3131 | /** | |
3132 | Converts a zero-based position to line column and paragraph number. | |
3133 | */ | |
3134 | virtual bool PositionToXY(long pos, long* x, long* y) const; | |
3135 | ||
3136 | /** | |
3137 | Sets the attributes for the given range. Pass flags to determine how the | |
3138 | attributes are set. | |
3139 | ||
3140 | The end point of range is specified as the last character position of the span | |
3141 | of text. So, for example, to set the style for a character at position 5, | |
3142 | use the range (5,5). | |
3143 | This differs from the wxRichTextCtrl API, where you would specify (5,6). | |
3144 | ||
3145 | @a flags may contain a bit list of the following values: | |
3146 | - wxRICHTEXT_SETSTYLE_NONE: no style flag. | |
3147 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be | |
3148 | undoable. | |
3149 | - wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied | |
3150 | if the combined style at this point is already the style in question. | |
3151 | - wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be | |
3152 | applied to paragraphs, and not the content. | |
3153 | This allows content styling to be preserved independently from that | |
3154 | of e.g. a named paragraph style. | |
3155 | - wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be | |
3156 | applied to characters, and not the paragraph. | |
3157 | This allows content styling to be preserved independently from that | |
3158 | of e.g. a named paragraph style. | |
3159 | - wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying | |
3160 | the new style. | |
3161 | - wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. | |
3162 | Only the style flags are used in this operation. | |
3163 | */ | |
3164 | virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); | |
3165 | ||
3166 | /** | |
3167 | Sets the attributes for the given object only, for example the box attributes for a text box. | |
3168 | */ | |
3169 | virtual void SetStyle(wxRichTextObject *obj, const wxRichTextAttr& textAttr, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); | |
3170 | ||
3171 | /** | |
3172 | Returns the combined text attributes for this position. | |
3173 | ||
3174 | This function gets the @e uncombined style - that is, the attributes associated | |
3175 | with the paragraph or character content, and not necessarily the combined | |
3176 | attributes you see on the screen. To get the combined attributes, use GetStyle(). | |
3177 | If you specify (any) paragraph attribute in @e style's flags, this function | |
3178 | will fetch the paragraph attributes. | |
3179 | Otherwise, it will return the character attributes. | |
3180 | */ | |
3181 | virtual bool GetStyle(long position, wxRichTextAttr& style); | |
3182 | ||
3183 | /** | |
3184 | Returns the content (uncombined) attributes for this position. | |
3185 | */ | |
3186 | virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style); | |
3187 | ||
3188 | /** | |
3189 | Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and | |
3190 | context attributes. | |
3191 | */ | |
3192 | virtual bool DoGetStyle(long position, wxRichTextAttr& style, bool combineStyles = true); | |
3193 | ||
3194 | /** | |
3195 | This function gets a style representing the common, combined attributes in the | |
3196 | given range. | |
3197 | Attributes which have different values within the specified range will not be | |
3198 | included the style flags. | |
3199 | ||
3200 | The function is used to get the attributes to display in the formatting dialog: | |
3201 | the user can edit the attributes common to the selection, and optionally specify the | |
3202 | values of further attributes to be applied uniformly. | |
3203 | ||
3204 | To apply the edited attributes, you can use SetStyle() specifying | |
3205 | the wxRICHTEXT_SETSTYLE_OPTIMIZE flag, which will only apply attributes that | |
3206 | are different from the @e combined attributes within the range. | |
3207 | So, the user edits the effective, displayed attributes for the range, | |
3208 | but his choice won't be applied unnecessarily to content. As an example, | |
3209 | say the style for a paragraph specifies bold, but the paragraph text doesn't | |
3210 | specify a weight. | |
3211 | The combined style is bold, and this is what the user will see on-screen and | |
3212 | in the formatting dialog. The user now specifies red text, in addition to bold. | |
3213 | When applying with SetStyle(), the content font weight attributes won't be | |
3214 | changed to bold because this is already specified by the paragraph. | |
3215 | However the text colour attributes @e will be changed to show red. | |
3216 | */ | |
3217 | virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style); | |
3218 | ||
3219 | /** | |
3220 | Combines @a style with @a currentStyle for the purpose of summarising the attributes of a range of | |
3221 | content. | |
3222 | */ | |
3223 | bool CollectStyle(wxRichTextAttr& currentStyle, const wxRichTextAttr& style, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr); | |
3224 | ||
3225 | //@{ | |
3226 | /** | |
3227 | Sets the list attributes for the given range, passing flags to determine how | |
3228 | the attributes are set. | |
3229 | Either the style definition or the name of the style definition (in the current | |
3230 | sheet) can be passed. | |
3231 | ||
3232 | @a flags is a bit list of the following: | |
3233 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable. | |
3234 | - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from | |
3235 | @a startFrom, otherwise existing attributes are used. | |
3236 | - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used | |
3237 | as the level for all paragraphs, otherwise the current indentation will be used. | |
3238 | ||
3239 | @see NumberList(), PromoteList(), ClearListStyle(). | |
3240 | */ | |
3241 | virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
3242 | virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
3243 | //@} | |
3244 | ||
3245 | /** | |
3246 | Clears the list style from the given range, clearing list-related attributes | |
3247 | and applying any named paragraph style associated with each paragraph. | |
3248 | ||
3249 | @a flags is a bit list of the following: | |
3250 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable. | |
3251 | ||
3252 | @see SetListStyle(), PromoteList(), NumberList() | |
3253 | */ | |
3254 | virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); | |
3255 | ||
3256 | //@{ | |
3257 | /** | |
3258 | Numbers the paragraphs in the given range. | |
3259 | ||
3260 | Pass flags to determine how the attributes are set. | |
3261 | Either the style definition or the name of the style definition (in the current | |
3262 | sheet) can be passed. | |
3263 | ||
3264 | @a flags is a bit list of the following: | |
3265 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable. | |
3266 | - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from | |
3267 | @a startFrom, otherwise existing attributes are used. | |
3268 | - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used | |
3269 | as the level for all paragraphs, otherwise the current indentation will be used. | |
3270 | ||
3271 | @a def can be NULL to indicate that the existing list style should be used. | |
3272 | ||
3273 | @see SetListStyle(), PromoteList(), ClearListStyle() | |
3274 | */ | |
3275 | virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
3276 | virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
3277 | //@} | |
3278 | ||
3279 | //@{ | |
3280 | /** | |
3281 | Promotes the list items within the given range. | |
3282 | A positive @a promoteBy produces a smaller indent, and a negative number | |
3283 | produces a larger indent. Pass flags to determine how the attributes are set. | |
3284 | Either the style definition or the name of the style definition (in the current | |
3285 | sheet) can be passed. | |
3286 | ||
3287 | @a flags is a bit list of the following: | |
3288 | - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable. | |
3289 | - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from | |
3290 | @a startFrom, otherwise existing attributes are used. | |
3291 | - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used | |
3292 | as the level for all paragraphs, otherwise the current indentation will be used. | |
3293 | ||
3294 | @see SetListStyle(), SetListStyle(), ClearListStyle() | |
3295 | */ | |
3296 | virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); | |
3297 | virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); | |
3298 | //@} | |
3299 | ||
3300 | /** | |
3301 | Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously | |
3302 | @a def can be NULL/empty to indicate that the existing list style should be used. | |
3303 | */ | |
3304 | 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); | |
3305 | ||
3306 | /** | |
3307 | Fills in the attributes for numbering a paragraph after previousParagraph. | |
3308 | */ | |
3309 | virtual bool FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const; | |
3310 | ||
3311 | /** | |
3312 | Sets the properties for the given range, passing flags to determine how the | |
3313 | attributes are set. You can merge properties or replace them. | |
3314 | ||
3315 | The end point of range is specified as the last character position of the span | |
3316 | of text, plus one. So, for example, to set the properties for a character at | |
3317 | position 5, use the range (5,6). | |
3318 | ||
3319 | @a flags may contain a bit list of the following values: | |
3320 | - wxRICHTEXT_SETPROPERTIES_NONE: no flag. | |
3321 | - wxRICHTEXT_SETPROPERTIES_WITH_UNDO: specifies that this operation should be | |
3322 | undoable. | |
3323 | - wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY: specifies that the properties should only be | |
3324 | applied to paragraphs, and not the content. | |
3325 | - wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY: specifies that the properties should only be | |
3326 | applied to characters, and not the paragraph. | |
3327 | - wxRICHTEXT_SETPROPERTIES_RESET: resets (clears) the existing properties before applying | |
3328 | the new properties. | |
3329 | - wxRICHTEXT_SETPROPERTIES_REMOVE: removes the specified properties. | |
3330 | */ | |
3331 | virtual bool SetProperties(const wxRichTextRange& range, const wxRichTextProperties& properties, int flags = wxRICHTEXT_SETPROPERTIES_WITH_UNDO); | |
3332 | ||
3333 | /** | |
3334 | Sets with undo the properties for the given object. | |
3335 | */ | |
3336 | virtual bool SetObjectPropertiesWithUndo(wxRichTextObject& obj, const wxRichTextProperties& properties, wxRichTextObject* objToSet = NULL); | |
3337 | ||
3338 | /** | |
3339 | Test if this whole range has character attributes of the specified kind. If any | |
3340 | of the attributes are different within the range, the test fails. You | |
3341 | can use this to implement, for example, bold button updating. style must have | |
3342 | flags indicating which attributes are of interest. | |
3343 | */ | |
3344 | virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const; | |
3345 | ||
3346 | /** | |
3347 | Test if this whole range has paragraph attributes of the specified kind. If any | |
3348 | of the attributes are different within the range, the test fails. You | |
3349 | can use this to implement, for example, centering button updating. style must have | |
3350 | flags indicating which attributes are of interest. | |
3351 | */ | |
3352 | virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const; | |
3353 | ||
3354 | virtual wxRichTextObject* Clone() const { return new wxRichTextParagraphLayoutBox(*this); } | |
3355 | ||
3356 | /** | |
3357 | Prepares the content just before insertion (or after buffer reset). | |
3358 | Currently is only called if undo mode is on. | |
3359 | */ | |
3360 | virtual void PrepareContent(wxRichTextParagraphLayoutBox& container); | |
3361 | ||
3362 | /** | |
3363 | Insert fragment into this box at the given position. If partialParagraph is true, | |
3364 | it is assumed that the last (or only) paragraph is just a piece of data with no paragraph | |
3365 | marker. | |
3366 | */ | |
3367 | virtual bool InsertFragment(long position, wxRichTextParagraphLayoutBox& fragment); | |
3368 | ||
3369 | /** | |
3370 | Make a copy of the fragment corresponding to the given range, putting it in @a fragment. | |
3371 | */ | |
3372 | virtual bool CopyFragment(const wxRichTextRange& range, wxRichTextParagraphLayoutBox& fragment); | |
3373 | ||
3374 | /** | |
3375 | Apply the style sheet to the buffer, for example if the styles have changed. | |
3376 | */ | |
3377 | virtual bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet); | |
3378 | ||
3379 | void Copy(const wxRichTextParagraphLayoutBox& obj); | |
3380 | ||
3381 | void operator= (const wxRichTextParagraphLayoutBox& obj) { Copy(obj); } | |
3382 | ||
3383 | /** | |
3384 | Calculate ranges. | |
3385 | */ | |
3386 | virtual void UpdateRanges(); | |
3387 | ||
3388 | /** | |
3389 | Get all the text. | |
3390 | */ | |
3391 | virtual wxString GetText() const; | |
3392 | ||
3393 | /** | |
3394 | Sets the default style, affecting the style currently being applied | |
3395 | (for example, setting the default style to bold will cause subsequently | |
3396 | inserted text to be bold). | |
3397 | ||
3398 | This is not cumulative - setting the default style will replace the previous | |
3399 | default style. | |
3400 | ||
3401 | Setting it to a default attribute object makes new content take on the 'basic' style. | |
3402 | */ | |
3403 | virtual bool SetDefaultStyle(const wxRichTextAttr& style); | |
3404 | ||
3405 | /** | |
3406 | Returns the current default style, affecting the style currently being applied | |
3407 | (for example, setting the default style to bold will cause subsequently | |
3408 | inserted text to be bold). | |
3409 | */ | |
3410 | virtual const wxRichTextAttr& GetDefaultStyle() const { return m_defaultAttributes; } | |
3411 | ||
3412 | /** | |
3413 | Sets the basic (overall) style. This is the style of the whole | |
3414 | buffer before further styles are applied, unlike the default style, which | |
3415 | only affects the style currently being applied (for example, setting the default | |
3416 | style to bold will cause subsequently inserted text to be bold). | |
3417 | */ | |
3418 | virtual void SetBasicStyle(const wxRichTextAttr& style) { m_attributes = style; } | |
3419 | ||
3420 | /** | |
3421 | Returns the basic (overall) style. | |
3422 | ||
3423 | This is the style of the whole buffer before further styles are applied, | |
3424 | unlike the default style, which only affects the style currently being | |
3425 | applied (for example, setting the default style to bold will cause | |
3426 | subsequently inserted text to be bold). | |
3427 | */ | |
3428 | virtual const wxRichTextAttr& GetBasicStyle() const { return m_attributes; } | |
3429 | ||
3430 | /** | |
3431 | Invalidates the buffer. With no argument, invalidates whole buffer. | |
3432 | */ | |
3433 | virtual void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL); | |
3434 | ||
3435 | /** | |
3436 | Do the (in)validation for this object only. | |
3437 | */ | |
3438 | virtual void DoInvalidate(const wxRichTextRange& invalidRange); | |
3439 | ||
3440 | /** | |
3441 | Do the (in)validation both up and down the hierarchy. | |
3442 | */ | |
3443 | virtual void InvalidateHierarchy(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL); | |
3444 | ||
3445 | /** | |
3446 | Gather information about floating objects. If untilObj is non-NULL, | |
3447 | will stop getting information if the current object is this, since we | |
3448 | will collect the rest later. | |
3449 | */ | |
3450 | virtual bool UpdateFloatingObjects(const wxRect& availableRect, wxRichTextObject* untilObj = NULL); | |
3451 | ||
3452 | /** | |
3453 | Get invalid range, rounding to entire paragraphs if argument is true. | |
3454 | */ | |
3455 | wxRichTextRange GetInvalidRange(bool wholeParagraphs = false) const; | |
3456 | ||
3457 | /** | |
3458 | Returns @true if this object needs layout. | |
3459 | */ | |
3460 | bool IsDirty() const { return m_invalidRange != wxRICHTEXT_NONE; } | |
3461 | ||
3462 | /** | |
3463 | Returns the wxRichTextFloatCollector of this object. | |
3464 | */ | |
3465 | wxRichTextFloatCollector* GetFloatCollector() { return m_floatCollector; } | |
3466 | ||
3467 | /** | |
3468 | Returns the number of floating objects at this level. | |
3469 | */ | |
3470 | int GetFloatingObjectCount() const; | |
3471 | ||
3472 | /** | |
3473 | Returns a list of floating objects. | |
3474 | */ | |
3475 | bool GetFloatingObjects(wxRichTextObjectList& objects) const; | |
3476 | ||
3477 | protected: | |
3478 | wxRichTextCtrl* m_ctrl; | |
3479 | wxRichTextAttr m_defaultAttributes; | |
3480 | ||
3481 | // The invalidated range that will need full layout | |
3482 | wxRichTextRange m_invalidRange; | |
3483 | ||
3484 | // Is the last paragraph partial or complete? | |
3485 | bool m_partialParagraph; | |
3486 | ||
3487 | // The floating layout state | |
3488 | wxRichTextFloatCollector* m_floatCollector; | |
3489 | }; | |
3490 | ||
3491 | /** | |
3492 | @class wxRichTextBox | |
3493 | ||
3494 | This class implements a floating or inline text box, containing paragraphs. | |
3495 | ||
3496 | @library{wxrichtext} | |
3497 | @category{richtext} | |
3498 | ||
3499 | @see wxRichTextParagraphLayoutBox, wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl | |
3500 | */ | |
3501 | ||
3502 | class WXDLLIMPEXP_RICHTEXT wxRichTextBox: public wxRichTextParagraphLayoutBox | |
3503 | { | |
3504 | DECLARE_DYNAMIC_CLASS(wxRichTextBox) | |
3505 | public: | |
3506 | // Constructors | |
3507 | ||
3508 | /** | |
3509 | Default constructor; optionally pass the parent object. | |
3510 | */ | |
3511 | ||
3512 | wxRichTextBox(wxRichTextObject* parent = NULL); | |
3513 | ||
3514 | /** | |
3515 | Copy constructor. | |
3516 | */ | |
3517 | ||
3518 | wxRichTextBox(const wxRichTextBox& obj): wxRichTextParagraphLayoutBox() { Copy(obj); } | |
3519 | ||
3520 | // Overridables | |
3521 | ||
3522 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
3523 | ||
3524 | virtual wxString GetXMLNodeName() const { return wxT("textbox"); } | |
3525 | ||
3526 | virtual bool CanEditProperties() const { return true; } | |
3527 | ||
3528 | virtual bool EditProperties(wxWindow* parent, wxRichTextBuffer* buffer); | |
3529 | ||
3530 | virtual wxString GetPropertiesMenuLabel() const { return wxGetTranslation("&Box"); } | |
3531 | ||
3532 | // Accessors | |
3533 | ||
3534 | // Operations | |
3535 | ||
3536 | virtual wxRichTextObject* Clone() const { return new wxRichTextBox(*this); } | |
3537 | ||
3538 | void Copy(const wxRichTextBox& obj); | |
3539 | ||
3540 | protected: | |
3541 | }; | |
3542 | ||
3543 | /** | |
3544 | @class wxRichTextField | |
3545 | ||
3546 | This class implements the general concept of a field, an object that represents | |
3547 | additional functionality such as a footnote, a bookmark, a page number, a table | |
3548 | of contents, and so on. Extra information (such as a bookmark name) can be stored | |
3549 | in the object properties. | |
3550 | ||
3551 | Drawing, layout, and property editing is delegated to classes derived | |
3552 | from wxRichTextFieldType, such as instances of wxRichTextFieldTypeStandard; this makes | |
3553 | the use of fields an efficient method of introducing extra functionality, since | |
3554 | most of the information required to draw a field (such as a bitmap) is kept centrally | |
3555 | in a single field type definition. | |
3556 | ||
3557 | The FieldType property, accessed by SetFieldType/GetFieldType, is used to retrieve | |
3558 | the field type definition. So be careful not to overwrite this property. | |
3559 | ||
3560 | wxRichTextField is derived from wxRichTextParagraphLayoutBox, which means that it | |
3561 | can contain its own read-only content, refreshed when the application calls the UpdateField | |
3562 | function. Whether a field is treated as a composite or a single graphic is determined | |
3563 | by the field type definition. If using wxRichTextFieldTypeStandard, passing the display | |
3564 | type wxRICHTEXT_FIELD_STYLE_COMPOSITE to the field type definition causes the field | |
3565 | to behave like a composite; the other display styles display a simple graphic. | |
3566 | When implementing a composite field, you will still need to derive from wxRichTextFieldTypeStandard | |
3567 | or wxRichTextFieldType, if only to implement UpdateField to refresh the field content | |
3568 | appropriately. wxRichTextFieldTypeStandard is only one possible implementation, but | |
3569 | covers common needs especially for simple, static fields using text or a bitmap. | |
3570 | ||
3571 | Register field types on application initialisation with the static function | |
3572 | wxRichTextBuffer::AddFieldType. They will be deleted automatically on | |
3573 | application exit. | |
3574 | ||
3575 | An application can write a field to a control with wxRichTextCtrl::WriteField, | |
3576 | taking a field type, the properties for the field, and optional attributes. | |
3577 | ||
3578 | @library{wxrichtext} | |
3579 | @category{richtext} | |
3580 | ||
3581 | @see wxRichTextFieldTypeStandard, wxRichTextFieldType, wxRichTextParagraphLayoutBox, wxRichTextProperties, wxRichTextCtrl | |
3582 | */ | |
3583 | ||
3584 | class WXDLLIMPEXP_RICHTEXT wxRichTextField: public wxRichTextParagraphLayoutBox | |
3585 | { | |
3586 | DECLARE_DYNAMIC_CLASS(wxRichTextField) | |
3587 | public: | |
3588 | // Constructors | |
3589 | ||
3590 | /** | |
3591 | Default constructor; optionally pass the parent object. | |
3592 | */ | |
3593 | ||
3594 | wxRichTextField(const wxString& fieldType = wxEmptyString, wxRichTextObject* parent = NULL); | |
3595 | ||
3596 | /** | |
3597 | Copy constructor. | |
3598 | */ | |
3599 | ||
3600 | wxRichTextField(const wxRichTextField& obj): wxRichTextParagraphLayoutBox() { Copy(obj); } | |
3601 | ||
3602 | // Overridables | |
3603 | ||
3604 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
3605 | ||
3606 | virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); | |
3607 | ||
3608 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const; | |
3609 | ||
3610 | virtual wxString GetXMLNodeName() const { return wxT("field"); } | |
3611 | ||
3612 | virtual bool CanEditProperties() const; | |
3613 | ||
3614 | virtual bool EditProperties(wxWindow* parent, wxRichTextBuffer* buffer); | |
3615 | ||
3616 | virtual wxString GetPropertiesMenuLabel() const; | |
3617 | ||
3618 | virtual bool AcceptsFocus() const { return false; } | |
3619 | ||
3620 | virtual void CalculateRange(long start, long& end); | |
3621 | ||
3622 | /** | |
3623 | If a field has children, we don't want the user to be able to edit it. | |
3624 | */ | |
3625 | virtual bool IsAtomic() const { return true; } | |
3626 | ||
3627 | virtual bool IsEmpty() const { return false; } | |
3628 | ||
3629 | virtual bool IsTopLevel() const; | |
3630 | ||
3631 | // Accessors | |
3632 | ||
3633 | void SetFieldType(const wxString& fieldType) { GetProperties().SetProperty(wxT("FieldType"), fieldType); } | |
3634 | wxString GetFieldType() const { return GetProperties().GetPropertyString(wxT("FieldType")); } | |
3635 | ||
3636 | // Operations | |
3637 | ||
3638 | /** | |
3639 | Update the field; delegated to the associated field type. This would typically expand the field to its value, | |
3640 | if this is a dynamically changing and/or composite field. | |
3641 | */ | |
3642 | virtual bool UpdateField(wxRichTextBuffer* buffer); | |
3643 | ||
3644 | virtual wxRichTextObject* Clone() const { return new wxRichTextField(*this); } | |
3645 | ||
3646 | void Copy(const wxRichTextField& obj); | |
3647 | ||
3648 | protected: | |
3649 | }; | |
3650 | ||
3651 | /** | |
3652 | @class wxRichTextFieldType | |
3653 | ||
3654 | The base class for custom field types. Each type definition handles one | |
3655 | field type. Override functions to provide drawing, layout, updating and | |
3656 | property editing functionality for a field. | |
3657 | ||
3658 | Register field types on application initialisation with the static function | |
3659 | wxRichTextBuffer::AddFieldType. They will be deleted automatically on | |
3660 | application exit. | |
3661 | ||
3662 | @library{wxrichtext} | |
3663 | @category{richtext} | |
3664 | ||
3665 | @see wxRichTextFieldTypeStandard, wxRichTextField, wxRichTextCtrl | |
3666 | */ | |
3667 | ||
3668 | class WXDLLIMPEXP_RICHTEXT wxRichTextFieldType: public wxObject | |
3669 | { | |
3670 | DECLARE_CLASS(wxRichTextFieldType) | |
3671 | public: | |
3672 | /** | |
3673 | Creates a field type definition. | |
3674 | */ | |
3675 | wxRichTextFieldType(const wxString& name = wxEmptyString) | |
3676 | : m_name(name) | |
3677 | { } | |
3678 | ||
3679 | /** | |
3680 | Copy constructor. | |
3681 | */ | |
3682 | wxRichTextFieldType(const wxRichTextFieldType& fieldType) | |
3683 | : wxObject(fieldType) | |
3684 | { Copy(fieldType); } | |
3685 | ||
3686 | void Copy(const wxRichTextFieldType& fieldType) { m_name = fieldType.m_name; } | |
3687 | ||
3688 | /** | |
3689 | Draw the item, within the given range. Some objects may ignore the range (for | |
3690 | example paragraphs) while others must obey it (lines, to implement wrapping) | |
3691 | */ | |
3692 | virtual bool Draw(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style) = 0; | |
3693 | ||
3694 | /** | |
3695 | Lay the item out at the specified position with the given size constraint. | |
3696 | Layout must set the cached size. @rect is the available space for the object, | |
3697 | and @a parentRect is the container that is used to determine a relative size | |
3698 | or position (for example if a text box must be 50% of the parent text box). | |
3699 | */ | |
3700 | virtual bool Layout(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style) = 0; | |
3701 | ||
3702 | /** | |
3703 | Returns the object size for the given range. Returns @false if the range | |
3704 | is invalid for this object. | |
3705 | */ | |
3706 | virtual bool GetRangeSize(wxRichTextField* obj, const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const = 0; | |
3707 | ||
3708 | /** | |
3709 | Returns @true if we can edit the object's properties via a GUI. | |
3710 | */ | |
3711 | virtual bool CanEditProperties(wxRichTextField* WXUNUSED(obj)) const { return false; } | |
3712 | ||
3713 | /** | |
3714 | Edits the object's properties via a GUI. | |
3715 | */ | |
3716 | virtual bool EditProperties(wxRichTextField* WXUNUSED(obj), wxWindow* WXUNUSED(parent), wxRichTextBuffer* WXUNUSED(buffer)) { return false; } | |
3717 | ||
3718 | /** | |
3719 | Returns the label to be used for the properties context menu item. | |
3720 | */ | |
3721 | virtual wxString GetPropertiesMenuLabel(wxRichTextField* WXUNUSED(obj)) const { return wxEmptyString; } | |
3722 | ||
3723 | /** | |
3724 | Update the field. This would typically expand the field to its value, | |
3725 | if this is a dynamically changing and/or composite field. | |
3726 | */ | |
3727 | virtual bool UpdateField(wxRichTextBuffer* WXUNUSED(buffer), wxRichTextField* WXUNUSED(obj)) { return false; } | |
3728 | ||
3729 | /** | |
3730 | Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box. | |
3731 | */ | |
3732 | virtual bool IsTopLevel(wxRichTextField* WXUNUSED(obj)) const { return true; } | |
3733 | ||
3734 | /** | |
3735 | Sets the field type name. There should be a unique name per field type object. | |
3736 | */ | |
3737 | void SetName(const wxString& name) { m_name = name; } | |
3738 | ||
3739 | /** | |
3740 | Returns the field type name. There should be a unique name per field type object. | |
3741 | */ | |
3742 | wxString GetName() const { return m_name; } | |
3743 | ||
3744 | protected: | |
3745 | ||
3746 | wxString m_name; | |
3747 | }; | |
3748 | ||
3749 | WX_DECLARE_STRING_HASH_MAP(wxRichTextFieldType*, wxRichTextFieldTypeHashMap); | |
3750 | ||
3751 | /** | |
3752 | @class wxRichTextFieldTypeStandard | |
3753 | ||
3754 | A field type that can handle fields with text or bitmap labels, with a small range | |
3755 | of styles for implementing rectangular fields and fields that can be used for start | |
3756 | and end tags. | |
3757 | ||
3758 | The border, text and background colours can be customised; the default is | |
3759 | white text on a black background. | |
3760 | ||
3761 | The following display styles can be used. | |
3762 | ||
3763 | @beginStyleTable | |
3764 | @style{wxRICHTEXT_FIELD_STYLE_COMPOSITE} | |
3765 | Creates a composite field; you will probably need to derive a new class to implement UpdateField. | |
3766 | @style{wxRICHTEXT_FIELD_STYLE_RECTANGLE} | |
3767 | Shows a rounded rectangle background. | |
3768 | @style{wxRICHTEXT_FIELD_STYLE_NO_BORDER} | |
3769 | Suppresses the background and border; mostly used with a bitmap label. | |
3770 | @style{wxRICHTEXT_FIELD_STYLE_START_TAG} | |
3771 | Shows a start tag background, with the pointy end facing right. | |
3772 | @style{wxRICHTEXT_FIELD_STYLE_END_TAG} | |
3773 | Shows an end tag background, with the pointy end facing left. | |
3774 | @endStyleTable | |
3775 | ||
3776 | @library{wxrichtext} | |
3777 | @category{richtext} | |
3778 | ||
3779 | @see wxRichTextFieldType, wxRichTextField, wxRichTextBuffer, wxRichTextCtrl | |
3780 | */ | |
3781 | ||
3782 | class WXDLLIMPEXP_RICHTEXT wxRichTextFieldTypeStandard: public wxRichTextFieldType | |
3783 | { | |
3784 | DECLARE_CLASS(wxRichTextFieldTypeStandard) | |
3785 | public: | |
3786 | ||
3787 | // Display style types | |
3788 | enum { wxRICHTEXT_FIELD_STYLE_COMPOSITE = 0x01, | |
3789 | wxRICHTEXT_FIELD_STYLE_RECTANGLE = 0x02, | |
3790 | wxRICHTEXT_FIELD_STYLE_NO_BORDER = 0x04, | |
3791 | wxRICHTEXT_FIELD_STYLE_START_TAG = 0x08, | |
3792 | wxRICHTEXT_FIELD_STYLE_END_TAG = 0x10 | |
3793 | }; | |
3794 | ||
3795 | /** | |
3796 | Constructor, creating a field type definition with a text label. | |
3797 | ||
3798 | @param parent | |
3799 | The name of the type definition. This must be unique, and is the type | |
3800 | name used when adding a field to a control. | |
3801 | @param label | |
3802 | The text label to be shown on the field. | |
3803 | @param displayStyle | |
3804 | The display style: one of wxRICHTEXT_FIELD_STYLE_RECTANGLE, | |
3805 | wxRICHTEXT_FIELD_STYLE_NO_BORDER, wxRICHTEXT_FIELD_STYLE_START_TAG, | |
3806 | wxRICHTEXT_FIELD_STYLE_END_TAG. | |
3807 | ||
3808 | */ | |
3809 | wxRichTextFieldTypeStandard(const wxString& name, const wxString& label, int displayStyle = wxRICHTEXT_FIELD_STYLE_RECTANGLE); | |
3810 | ||
3811 | /** | |
3812 | Constructor, creating a field type definition with a bitmap label. | |
3813 | ||
3814 | @param parent | |
3815 | The name of the type definition. This must be unique, and is the type | |
3816 | name used when adding a field to a control. | |
3817 | @param label | |
3818 | The bitmap label to be shown on the field. | |
3819 | @param displayStyle | |
3820 | The display style: one of wxRICHTEXT_FIELD_STYLE_RECTANGLE, | |
3821 | wxRICHTEXT_FIELD_STYLE_NO_BORDER, wxRICHTEXT_FIELD_STYLE_START_TAG, | |
3822 | wxRICHTEXT_FIELD_STYLE_END_TAG. | |
3823 | ||
3824 | */ | |
3825 | wxRichTextFieldTypeStandard(const wxString& name, const wxBitmap& bitmap, int displayStyle = wxRICHTEXT_FIELD_STYLE_NO_BORDER); | |
3826 | ||
3827 | /** | |
3828 | The default constructor. | |
3829 | ||
3830 | */ | |
3831 | wxRichTextFieldTypeStandard() { Init(); } | |
3832 | ||
3833 | /** | |
3834 | The copy constructor. | |
3835 | ||
3836 | */ | |
3837 | wxRichTextFieldTypeStandard(const wxRichTextFieldTypeStandard& field) | |
3838 | : wxRichTextFieldType(field) | |
3839 | { Copy(field); } | |
3840 | ||
3841 | /** | |
3842 | Initialises the object. | |
3843 | */ | |
3844 | void Init(); | |
3845 | ||
3846 | /** | |
3847 | Copies the object. | |
3848 | */ | |
3849 | void Copy(const wxRichTextFieldTypeStandard& field); | |
3850 | ||
3851 | /** | |
3852 | The assignment operator. | |
3853 | */ | |
3854 | void operator=(const wxRichTextFieldTypeStandard& field) { Copy(field); } | |
3855 | ||
3856 | /** | |
3857 | Draw the item, within the given range. Some objects may ignore the range (for | |
3858 | example paragraphs) while others must obey it (lines, to implement wrapping) | |
3859 | */ | |
3860 | virtual bool Draw(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
3861 | ||
3862 | /** | |
3863 | Lay the item out at the specified position with the given size constraint. | |
3864 | Layout must set the cached size. @rect is the available space for the object, | |
3865 | and @a parentRect is the container that is used to determine a relative size | |
3866 | or position (for example if a text box must be 50% of the parent text box). | |
3867 | */ | |
3868 | virtual bool Layout(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); | |
3869 | ||
3870 | /** | |
3871 | Returns the object size for the given range. Returns @false if the range | |
3872 | is invalid for this object. | |
3873 | */ | |
3874 | virtual bool GetRangeSize(wxRichTextField* obj, const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const; | |
3875 | ||
3876 | /** | |
3877 | Get the size of the field, given the label, font size, and so on. | |
3878 | */ | |
3879 | wxSize GetSize(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, int style) const; | |
3880 | ||
3881 | /** | |
3882 | Returns @true if the display type is wxRICHTEXT_FIELD_STYLE_COMPOSITE, @false otherwise. | |
3883 | */ | |
3884 | virtual bool IsTopLevel(wxRichTextField* WXUNUSED(obj)) const { return (GetDisplayStyle() & wxRICHTEXT_FIELD_STYLE_COMPOSITE) != 0; } | |
3885 | ||
3886 | /** | |
3887 | Sets the text label for fields of this type. | |
3888 | */ | |
3889 | void SetLabel(const wxString& label) { m_label = label; } | |
3890 | ||
3891 | /** | |
3892 | Returns the text label for fields of this type. | |
3893 | */ | |
3894 | const wxString& GetLabel() const { return m_label; } | |
3895 | ||
3896 | /** | |
3897 | Sets the bitmap label for fields of this type. | |
3898 | */ | |
3899 | void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; } | |
3900 | ||
3901 | /** | |
3902 | Gets the bitmap label for fields of this type. | |
3903 | */ | |
3904 | const wxBitmap& GetBitmap() const { return m_bitmap; } | |
3905 | ||
3906 | /** | |
3907 | Gets the display style for fields of this type. | |
3908 | */ | |
3909 | int GetDisplayStyle() const { return m_displayStyle; } | |
3910 | ||
3911 | /** | |
3912 | Sets the display style for fields of this type. | |
3913 | */ | |
3914 | void SetDisplayStyle(int displayStyle) { m_displayStyle = displayStyle; } | |
3915 | ||
3916 | /** | |
3917 | Gets the font used for drawing the text label. | |
3918 | */ | |
3919 | const wxFont& GetFont() const { return m_font; } | |
3920 | ||
3921 | /** | |
3922 | Sets the font used for drawing the text label. | |
3923 | */ | |
3924 | void SetFont(const wxFont& font) { m_font = font; } | |
3925 | ||
3926 | /** | |
3927 | Gets the colour used for drawing the text label. | |
3928 | */ | |
3929 | const wxColour& GetTextColour() const { return m_textColour; } | |
3930 | ||
3931 | /** | |
3932 | Sets the colour used for drawing the text label. | |
3933 | */ | |
3934 | void SetTextColour(const wxColour& colour) { m_textColour = colour; } | |
3935 | ||
3936 | /** | |
3937 | Gets the colour used for drawing the field border. | |
3938 | */ | |
3939 | const wxColour& GetBorderColour() const { return m_borderColour; } | |
3940 | ||
3941 | /** | |
3942 | Sets the colour used for drawing the field border. | |
3943 | */ | |
3944 | void SetBorderColour(const wxColour& colour) { m_borderColour = colour; } | |
3945 | ||
3946 | /** | |
3947 | Gets the colour used for drawing the field background. | |
3948 | */ | |
3949 | const wxColour& GetBackgroundColour() const { return m_backgroundColour; } | |
3950 | ||
3951 | /** | |
3952 | Sets the colour used for drawing the field background. | |
3953 | */ | |
3954 | void SetBackgroundColour(const wxColour& colour) { m_backgroundColour = colour; } | |
3955 | ||
3956 | /** | |
3957 | Sets the vertical padding (the distance between the border and the text). | |
3958 | */ | |
3959 | void SetVerticalPadding(int padding) { m_verticalPadding = padding; } | |
3960 | ||
3961 | /** | |
3962 | Gets the vertical padding (the distance between the border and the text). | |
3963 | */ | |
3964 | int GetVerticalPadding() const { return m_verticalPadding; } | |
3965 | ||
3966 | /** | |
3967 | Sets the horizontal padding (the distance between the border and the text). | |
3968 | */ | |
3969 | void SetHorizontalPadding(int padding) { m_horizontalPadding = padding; } | |
3970 | ||
3971 | /** | |
3972 | Sets the horizontal padding (the distance between the border and the text). | |
3973 | */ | |
3974 | int GetHorizontalPadding() const { return m_horizontalPadding; } | |
3975 | ||
3976 | /** | |
3977 | Sets the horizontal margin surrounding the field object. | |
3978 | */ | |
3979 | void SetHorizontalMargin(int margin) { m_horizontalMargin = margin; } | |
3980 | ||
3981 | /** | |
3982 | Gets the horizontal margin surrounding the field object. | |
3983 | */ | |
3984 | int GetHorizontalMargin() const { return m_horizontalMargin; } | |
3985 | ||
3986 | /** | |
3987 | Sets the vertical margin surrounding the field object. | |
3988 | */ | |
3989 | void SetVerticalMargin(int margin) { m_verticalMargin = margin; } | |
3990 | ||
3991 | /** | |
3992 | Gets the vertical margin surrounding the field object. | |
3993 | */ | |
3994 | int GetVerticalMargin() const { return m_verticalMargin; } | |
3995 | ||
3996 | protected: | |
3997 | ||
3998 | wxString m_label; | |
3999 | int m_displayStyle; | |
4000 | wxFont m_font; | |
4001 | wxColour m_textColour; | |
4002 | wxColour m_borderColour; | |
4003 | wxColour m_backgroundColour; | |
4004 | int m_verticalPadding; | |
4005 | int m_horizontalPadding; | |
4006 | int m_horizontalMargin; | |
4007 | int m_verticalMargin; | |
4008 | wxBitmap m_bitmap; | |
4009 | }; | |
4010 | ||
4011 | /** | |
4012 | @class wxRichTextLine | |
4013 | ||
4014 | This object represents a line in a paragraph, and stores | |
4015 | offsets from the start of the paragraph representing the | |
4016 | start and end positions of the line. | |
4017 | ||
4018 | @library{wxrichtext} | |
4019 | @category{richtext} | |
4020 | ||
4021 | @see wxRichTextBuffer, wxRichTextCtrl | |
4022 | */ | |
4023 | ||
4024 | class WXDLLIMPEXP_RICHTEXT wxRichTextLine | |
4025 | { | |
4026 | public: | |
4027 | // Constructors | |
4028 | ||
4029 | wxRichTextLine(wxRichTextParagraph* parent); | |
4030 | wxRichTextLine(const wxRichTextLine& obj) { Init( NULL); Copy(obj); } | |
4031 | virtual ~wxRichTextLine() {} | |
4032 | ||
4033 | // Overridables | |
4034 | ||
4035 | // Accessors | |
4036 | ||
4037 | /** | |
4038 | Sets the range associated with this line. | |
4039 | */ | |
4040 | void SetRange(const wxRichTextRange& range) { m_range = range; } | |
4041 | /** | |
4042 | Sets the range associated with this line. | |
4043 | */ | |
4044 | void SetRange(long from, long to) { m_range = wxRichTextRange(from, to); } | |
4045 | ||
4046 | /** | |
4047 | Returns the parent paragraph. | |
4048 | */ | |
4049 | wxRichTextParagraph* GetParent() { return m_parent; } | |
4050 | ||
4051 | /** | |
4052 | Returns the range. | |
4053 | */ | |
4054 | const wxRichTextRange& GetRange() const { return m_range; } | |
4055 | /** | |
4056 | Returns the range. | |
4057 | */ | |
4058 | wxRichTextRange& GetRange() { return m_range; } | |
4059 | ||
4060 | /** | |
4061 | Returns the absolute range. | |
4062 | */ | |
4063 | wxRichTextRange GetAbsoluteRange() const; | |
4064 | ||
4065 | /** | |
4066 | Returns the line size as calculated by Layout. | |
4067 | */ | |
4068 | virtual wxSize GetSize() const { return m_size; } | |
4069 | ||
4070 | /** | |
4071 | Sets the line size as calculated by Layout. | |
4072 | */ | |
4073 | virtual void SetSize(const wxSize& sz) { m_size = sz; } | |
4074 | ||
4075 | /** | |
4076 | Returns the object position relative to the parent. | |
4077 | */ | |
4078 | virtual wxPoint GetPosition() const { return m_pos; } | |
4079 | ||
4080 | /** | |
4081 | Sets the object position relative to the parent. | |
4082 | */ | |
4083 | virtual void SetPosition(const wxPoint& pos) { m_pos = pos; } | |
4084 | ||
4085 | /** | |
4086 | Returns the absolute object position. | |
4087 | */ | |
4088 | virtual wxPoint GetAbsolutePosition() const; | |
4089 | ||
4090 | /** | |
4091 | Returns the rectangle enclosing the line. | |
4092 | */ | |
4093 | virtual wxRect GetRect() const { return wxRect(GetAbsolutePosition(), GetSize()); } | |
4094 | ||
4095 | /** | |
4096 | Sets the stored descent. | |
4097 | */ | |
4098 | void SetDescent(int descent) { m_descent = descent; } | |
4099 | ||
4100 | /** | |
4101 | Returns the stored descent. | |
4102 | */ | |
4103 | int GetDescent() const { return m_descent; } | |
4104 | ||
4105 | #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING | |
4106 | wxArrayInt& GetObjectSizes() { return m_objectSizes; } | |
4107 | const wxArrayInt& GetObjectSizes() const { return m_objectSizes; } | |
4108 | #endif | |
4109 | ||
4110 | // Operations | |
4111 | ||
4112 | /** | |
4113 | Initialises the object. | |
4114 | */ | |
4115 | void Init(wxRichTextParagraph* parent); | |
4116 | ||
4117 | /** | |
4118 | Copies from @a obj. | |
4119 | */ | |
4120 | void Copy(const wxRichTextLine& obj); | |
4121 | ||
4122 | virtual wxRichTextLine* Clone() const { return new wxRichTextLine(*this); } | |
4123 | ||
4124 | protected: | |
4125 | ||
4126 | // The range of the line (start position to end position) | |
4127 | // This is relative to the parent paragraph. | |
4128 | wxRichTextRange m_range; | |
4129 | ||
4130 | // Size and position measured relative to top of paragraph | |
4131 | wxPoint m_pos; | |
4132 | wxSize m_size; | |
4133 | ||
4134 | // Maximum descent for this line (location of text baseline) | |
4135 | int m_descent; | |
4136 | ||
4137 | // The parent object | |
4138 | wxRichTextParagraph* m_parent; | |
4139 | ||
4140 | #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING | |
4141 | wxArrayInt m_objectSizes; | |
4142 | #endif | |
4143 | }; | |
4144 | ||
4145 | WX_DECLARE_LIST_WITH_DECL( wxRichTextLine, wxRichTextLineList , class WXDLLIMPEXP_RICHTEXT ); | |
4146 | ||
4147 | /** | |
4148 | @class wxRichTextParagraph | |
4149 | ||
4150 | This object represents a single paragraph containing various objects such as text content, images, and further paragraph layout objects. | |
4151 | ||
4152 | @library{wxrichtext} | |
4153 | @category{richtext} | |
4154 | ||
4155 | @see wxRichTextBuffer, wxRichTextCtrl | |
4156 | */ | |
4157 | ||
4158 | class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph: public wxRichTextCompositeObject | |
4159 | { | |
4160 | DECLARE_DYNAMIC_CLASS(wxRichTextParagraph) | |
4161 | public: | |
4162 | // Constructors | |
4163 | ||
4164 | /** | |
4165 | Constructor taking a parent and style. | |
4166 | */ | |
4167 | wxRichTextParagraph(wxRichTextObject* parent = NULL, wxRichTextAttr* style = NULL); | |
4168 | /** | |
4169 | Constructor taking a text string, a parent and paragraph and character attributes. | |
4170 | */ | |
4171 | wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxRichTextAttr* paraStyle = NULL, wxRichTextAttr* charStyle = NULL); | |
4172 | virtual ~wxRichTextParagraph(); | |
4173 | wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextCompositeObject() { Copy(obj); } | |
4174 | ||
4175 | // Overridables | |
4176 | ||
4177 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
4178 | ||
4179 | virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); | |
4180 | ||
4181 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const; | |
4182 | ||
4183 | virtual bool FindPosition(wxDC& dc, wxRichTextDrawingContext& context, long index, wxPoint& pt, int* height, bool forceLineStart); | |
4184 | ||
4185 | virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); | |
4186 | ||
4187 | virtual void CalculateRange(long start, long& end); | |
4188 | ||
4189 | virtual wxString GetXMLNodeName() const { return wxT("paragraph"); } | |
4190 | ||
4191 | // Accessors | |
4192 | ||
4193 | /** | |
4194 | Returns the cached lines. | |
4195 | */ | |
4196 | wxRichTextLineList& GetLines() { return m_cachedLines; } | |
4197 | ||
4198 | // Operations | |
4199 | ||
4200 | /** | |
4201 | Copies the object. | |
4202 | */ | |
4203 | void Copy(const wxRichTextParagraph& obj); | |
4204 | ||
4205 | virtual wxRichTextObject* Clone() const { return new wxRichTextParagraph(*this); } | |
4206 | ||
4207 | /** | |
4208 | Clears the cached lines. | |
4209 | */ | |
4210 | void ClearLines(); | |
4211 | ||
4212 | // Implementation | |
4213 | ||
4214 | /** | |
4215 | Applies paragraph styles such as centering to the wrapped lines. | |
4216 | */ | |
4217 | virtual void ApplyParagraphStyle(wxRichTextLine* line, const wxRichTextAttr& attr, const wxRect& rect, wxDC& dc); | |
4218 | ||
4219 | /** | |
4220 | Inserts text at the given position. | |
4221 | */ | |
4222 | virtual bool InsertText(long pos, const wxString& text); | |
4223 | ||
4224 | /** | |
4225 | Splits an object at this position if necessary, and returns | |
4226 | the previous object, or NULL if inserting at the beginning. | |
4227 | */ | |
4228 | virtual wxRichTextObject* SplitAt(long pos, wxRichTextObject** previousObject = NULL); | |
4229 | ||
4230 | /** | |
4231 | Moves content to a list from this point. | |
4232 | */ | |
4233 | virtual void MoveToList(wxRichTextObject* obj, wxList& list); | |
4234 | ||
4235 | /** | |
4236 | Adds content back from a list. | |
4237 | */ | |
4238 | virtual void MoveFromList(wxList& list); | |
4239 | ||
4240 | /** | |
4241 | Returns the plain text searching from the start or end of the range. | |
4242 | The resulting string may be shorter than the range given. | |
4243 | */ | |
4244 | bool GetContiguousPlainText(wxString& text, const wxRichTextRange& range, bool fromStart = true); | |
4245 | ||
4246 | /** | |
4247 | Finds a suitable wrap position. @a wrapPosition is the last position in the line to the left | |
4248 | of the split. | |
4249 | */ | |
4250 | bool FindWrapPosition(const wxRichTextRange& range, wxDC& dc, wxRichTextDrawingContext& context, int availableSpace, long& wrapPosition, wxArrayInt* partialExtents); | |
4251 | ||
4252 | /** | |
4253 | Finds the object at the given position. | |
4254 | */ | |
4255 | wxRichTextObject* FindObjectAtPosition(long position); | |
4256 | ||
4257 | /** | |
4258 | Returns the bullet text for this paragraph. | |
4259 | */ | |
4260 | wxString GetBulletText(); | |
4261 | ||
4262 | /** | |
4263 | Allocates or reuses a line object. | |
4264 | */ | |
4265 | wxRichTextLine* AllocateLine(int pos); | |
4266 | ||
4267 | /** | |
4268 | Clears remaining unused line objects, if any. | |
4269 | */ | |
4270 | bool ClearUnusedLines(int lineCount); | |
4271 | ||
4272 | /** | |
4273 | Returns combined attributes of the base style, paragraph style and character style. We use this to dynamically | |
4274 | retrieve the actual style. | |
4275 | */ | |
4276 | wxRichTextAttr GetCombinedAttributes(const wxRichTextAttr& contentStyle, bool includingBoxAttr = false) const; | |
4277 | ||
4278 | /** | |
4279 | Returns the combined attributes of the base style and paragraph style. | |
4280 | */ | |
4281 | wxRichTextAttr GetCombinedAttributes(bool includingBoxAttr = false) const; | |
4282 | ||
4283 | /** | |
4284 | Returns the first position from pos that has a line break character. | |
4285 | */ | |
4286 | long GetFirstLineBreakPosition(long pos); | |
4287 | ||
4288 | /** | |
4289 | Creates a default tabstop array. | |
4290 | */ | |
4291 | static void InitDefaultTabs(); | |
4292 | ||
4293 | /** | |
4294 | Clears the default tabstop array. | |
4295 | */ | |
4296 | static void ClearDefaultTabs(); | |
4297 | ||
4298 | /** | |
4299 | Returns the default tabstop array. | |
4300 | */ | |
4301 | static const wxArrayInt& GetDefaultTabs() { return sm_defaultTabs; } | |
4302 | ||
4303 | /** | |
4304 | Lays out the floating objects. | |
4305 | */ | |
4306 | void LayoutFloat(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style, wxRichTextFloatCollector* floatCollector); | |
4307 | ||
4308 | protected: | |
4309 | ||
4310 | // The lines that make up the wrapped paragraph | |
4311 | wxRichTextLineList m_cachedLines; | |
4312 | ||
4313 | // Default tabstops | |
4314 | static wxArrayInt sm_defaultTabs; | |
4315 | ||
4316 | friend class wxRichTextFloatCollector; | |
4317 | }; | |
4318 | ||
4319 | /** | |
4320 | @class wxRichTextPlainText | |
4321 | ||
4322 | This object represents a single piece of text. | |
4323 | ||
4324 | @library{wxrichtext} | |
4325 | @category{richtext} | |
4326 | ||
4327 | @see wxRichTextBuffer, wxRichTextCtrl | |
4328 | */ | |
4329 | ||
4330 | class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText: public wxRichTextObject | |
4331 | { | |
4332 | DECLARE_DYNAMIC_CLASS(wxRichTextPlainText) | |
4333 | public: | |
4334 | // Constructors | |
4335 | ||
4336 | /** | |
4337 | Constructor. | |
4338 | */ | |
4339 | wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxRichTextAttr* style = NULL); | |
4340 | ||
4341 | /** | |
4342 | Copy constructor. | |
4343 | */ | |
4344 | wxRichTextPlainText(const wxRichTextPlainText& obj): wxRichTextObject() { Copy(obj); } | |
4345 | ||
4346 | // Overridables | |
4347 | ||
4348 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
4349 | ||
4350 | virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); | |
4351 | ||
4352 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const; | |
4353 | ||
4354 | virtual wxString GetTextForRange(const wxRichTextRange& range) const; | |
4355 | ||
4356 | virtual wxRichTextObject* DoSplit(long pos); | |
4357 | ||
4358 | virtual void CalculateRange(long start, long& end); | |
4359 | ||
4360 | virtual bool DeleteRange(const wxRichTextRange& range); | |
4361 | ||
4362 | virtual bool IsEmpty() const { return m_text.empty(); } | |
4363 | ||
4364 | virtual bool CanMerge(wxRichTextObject* object, wxRichTextDrawingContext& context) const; | |
4365 | ||
4366 | virtual bool Merge(wxRichTextObject* object, wxRichTextDrawingContext& context); | |
4367 | ||
4368 | virtual void Dump(wxTextOutputStream& stream); | |
4369 | ||
4370 | virtual bool CanSplit(wxRichTextDrawingContext& context) const; | |
4371 | ||
4372 | virtual wxRichTextObject* Split(wxRichTextDrawingContext& context); | |
4373 | ||
4374 | /** | |
4375 | Get the first position from pos that has a line break character. | |
4376 | */ | |
4377 | long GetFirstLineBreakPosition(long pos); | |
4378 | ||
4379 | /// Does this object take note of paragraph attributes? Text and image objects don't. | |
4380 | virtual bool UsesParagraphAttributes() const { return false; } | |
4381 | ||
4382 | #if wxUSE_XML | |
4383 | virtual bool ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse); | |
4384 | #endif | |
4385 | ||
4386 | #if wxRICHTEXT_HAVE_DIRECT_OUTPUT | |
4387 | virtual bool ExportXML(wxOutputStream& stream, int indent, wxRichTextXMLHandler* handler); | |
4388 | #endif | |
4389 | ||
4390 | #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT | |
4391 | virtual bool ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler); | |
4392 | #endif | |
4393 | ||
4394 | virtual wxString GetXMLNodeName() const { return wxT("text"); } | |
4395 | ||
4396 | // Accessors | |
4397 | ||
4398 | /** | |
4399 | Returns the text. | |
4400 | */ | |
4401 | const wxString& GetText() const { return m_text; } | |
4402 | ||
4403 | /** | |
4404 | Sets the text. | |
4405 | */ | |
4406 | void SetText(const wxString& text) { m_text = text; } | |
4407 | ||
4408 | // Operations | |
4409 | ||
4410 | // Copies the text object, | |
4411 | void Copy(const wxRichTextPlainText& obj); | |
4412 | ||
4413 | // Clones the text object. | |
4414 | virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); } | |
4415 | ||
4416 | private: | |
4417 | bool DrawTabbedString(wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected); | |
4418 | ||
4419 | protected: | |
4420 | wxString m_text; | |
4421 | }; | |
4422 | ||
4423 | /** | |
4424 | @class wxRichTextImageBlock | |
4425 | ||
4426 | This class stores information about an image, in binary in-memory form. | |
4427 | ||
4428 | @library{wxrichtext} | |
4429 | @category{richtext} | |
4430 | ||
4431 | @see wxRichTextBuffer, wxRichTextCtrl | |
4432 | */ | |
4433 | ||
4434 | class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock: public wxObject | |
4435 | { | |
4436 | public: | |
4437 | /** | |
4438 | Constructor. | |
4439 | */ | |
4440 | wxRichTextImageBlock(); | |
4441 | ||
4442 | /** | |
4443 | Copy constructor. | |
4444 | */ | |
4445 | wxRichTextImageBlock(const wxRichTextImageBlock& block); | |
4446 | virtual ~wxRichTextImageBlock(); | |
4447 | ||
4448 | /** | |
4449 | Initialises the block. | |
4450 | */ | |
4451 | void Init(); | |
4452 | ||
4453 | /** | |
4454 | Clears the block. | |
4455 | */ | |
4456 | ||
4457 | void Clear(); | |
4458 | ||
4459 | /** | |
4460 | Load the original image into a memory block. | |
4461 | If the image is not a JPEG, we must convert it into a JPEG | |
4462 | to conserve space. | |
4463 | If it's not a JPEG we can make use of @a image, already scaled, so we don't have to | |
4464 | load the image a second time. | |
4465 | */ | |
4466 | virtual bool MakeImageBlock(const wxString& filename, wxBitmapType imageType, | |
4467 | wxImage& image, bool convertToJPEG = true); | |
4468 | ||
4469 | /** | |
4470 | Make an image block from the wxImage in the given | |
4471 | format. | |
4472 | */ | |
4473 | virtual bool MakeImageBlock(wxImage& image, wxBitmapType imageType, int quality = 80); | |
4474 | ||
4475 | /** | |
4476 | Uses a const wxImage for efficiency, but can't set quality (only relevant for JPEG) | |
4477 | */ | |
4478 | virtual bool MakeImageBlockDefaultQuality(const wxImage& image, wxBitmapType imageType); | |
4479 | ||
4480 | /** | |
4481 | Makes the image block. | |
4482 | */ | |
4483 | virtual bool DoMakeImageBlock(const wxImage& image, wxBitmapType imageType); | |
4484 | ||
4485 | /** | |
4486 | Writes the block to a file. | |
4487 | */ | |
4488 | bool Write(const wxString& filename); | |
4489 | ||
4490 | /** | |
4491 | Writes the data in hex to a stream. | |
4492 | */ | |
4493 | bool WriteHex(wxOutputStream& stream); | |
4494 | ||
4495 | /** | |
4496 | Reads the data in hex from a stream. | |
4497 | */ | |
4498 | bool ReadHex(wxInputStream& stream, int length, wxBitmapType imageType); | |
4499 | ||
4500 | /** | |
4501 | Copy from @a block. | |
4502 | */ | |
4503 | void Copy(const wxRichTextImageBlock& block); | |
4504 | ||
4505 | // Load a wxImage from the block | |
4506 | /** | |
4507 | */ | |
4508 | bool Load(wxImage& image); | |
4509 | ||
4510 | // Operators | |
4511 | ||
4512 | /** | |
4513 | Assignment operation. | |
4514 | */ | |
4515 | void operator=(const wxRichTextImageBlock& block); | |
4516 | ||
4517 | // Accessors | |
4518 | ||
4519 | /** | |
4520 | Returns the raw data. | |
4521 | */ | |
4522 | unsigned char* GetData() const { return m_data; } | |
4523 | ||
4524 | /** | |
4525 | Returns the data size in bytes. | |
4526 | */ | |
4527 | size_t GetDataSize() const { return m_dataSize; } | |
4528 | ||
4529 | /** | |
4530 | Returns the image type. | |
4531 | */ | |
4532 | wxBitmapType GetImageType() const { return m_imageType; } | |
4533 | ||
4534 | /** | |
4535 | */ | |
4536 | void SetData(unsigned char* image) { m_data = image; } | |
4537 | ||
4538 | /** | |
4539 | Sets the data size. | |
4540 | */ | |
4541 | void SetDataSize(size_t size) { m_dataSize = size; } | |
4542 | ||
4543 | /** | |
4544 | Sets the image type. | |
4545 | */ | |
4546 | void SetImageType(wxBitmapType imageType) { m_imageType = imageType; } | |
4547 | ||
4548 | /** | |
4549 | Returns @true if the data is non-NULL. | |
4550 | */ | |
4551 | bool IsOk() const { return GetData() != NULL; } | |
4552 | bool Ok() const { return IsOk(); } | |
4553 | ||
4554 | /** | |
4555 | Gets the extension for the block's type. | |
4556 | */ | |
4557 | wxString GetExtension() const; | |
4558 | ||
4559 | /// Implementation | |
4560 | ||
4561 | /** | |
4562 | Allocates and reads from a stream as a block of memory. | |
4563 | */ | |
4564 | static unsigned char* ReadBlock(wxInputStream& stream, size_t size); | |
4565 | ||
4566 | /** | |
4567 | Allocates and reads from a file as a block of memory. | |
4568 | */ | |
4569 | static unsigned char* ReadBlock(const wxString& filename, size_t size); | |
4570 | ||
4571 | /** | |
4572 | Writes a memory block to stream. | |
4573 | */ | |
4574 | static bool WriteBlock(wxOutputStream& stream, unsigned char* block, size_t size); | |
4575 | ||
4576 | /** | |
4577 | Writes a memory block to a file. | |
4578 | */ | |
4579 | static bool WriteBlock(const wxString& filename, unsigned char* block, size_t size); | |
4580 | ||
4581 | protected: | |
4582 | // Size in bytes of the image stored. | |
4583 | // This is in the raw, original form such as a JPEG file. | |
4584 | unsigned char* m_data; | |
4585 | size_t m_dataSize; | |
4586 | wxBitmapType m_imageType; | |
4587 | }; | |
4588 | ||
4589 | /** | |
4590 | @class wxRichTextImage | |
4591 | ||
4592 | This class implements a graphic object. | |
4593 | ||
4594 | @library{wxrichtext} | |
4595 | @category{richtext} | |
4596 | ||
4597 | @see wxRichTextBuffer, wxRichTextCtrl, wxRichTextImageBlock | |
4598 | */ | |
4599 | ||
4600 | class WXDLLIMPEXP_RICHTEXT wxRichTextImage: public wxRichTextObject | |
4601 | { | |
4602 | DECLARE_DYNAMIC_CLASS(wxRichTextImage) | |
4603 | public: | |
4604 | // Constructors | |
4605 | ||
4606 | /** | |
4607 | Default constructor. | |
4608 | */ | |
4609 | wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextObject(parent) { Init(); } | |
4610 | ||
4611 | /** | |
4612 | Creates a wxRichTextImage from a wxImage. | |
4613 | */ | |
4614 | wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxRichTextAttr* charStyle = NULL); | |
4615 | ||
4616 | /** | |
4617 | Creates a wxRichTextImage from an image block. | |
4618 | */ | |
4619 | wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxRichTextAttr* charStyle = NULL); | |
4620 | ||
4621 | /** | |
4622 | Copy constructor. | |
4623 | */ | |
4624 | wxRichTextImage(const wxRichTextImage& obj): wxRichTextObject(obj) { Copy(obj); } | |
4625 | ||
4626 | /** | |
4627 | Destructor. | |
4628 | */ | |
4629 | ~wxRichTextImage(); | |
4630 | ||
4631 | /** | |
4632 | Initialisation. | |
4633 | */ | |
4634 | void Init(); | |
4635 | ||
4636 | // Overridables | |
4637 | ||
4638 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
4639 | ||
4640 | virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); | |
4641 | ||
4642 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const; | |
4643 | ||
4644 | /** | |
4645 | Returns the 'natural' size for this object - the image size. | |
4646 | */ | |
4647 | virtual wxTextAttrSize GetNaturalSize() const; | |
4648 | ||
4649 | virtual bool IsEmpty() const { return false; /* !m_imageBlock.IsOk(); */ } | |
4650 | ||
4651 | virtual bool CanEditProperties() const { return true; } | |
4652 | ||
4653 | virtual bool EditProperties(wxWindow* parent, wxRichTextBuffer* buffer); | |
4654 | ||
4655 | virtual wxString GetPropertiesMenuLabel() const { return wxGetTranslation("&Picture"); } | |
4656 | ||
4657 | virtual bool UsesParagraphAttributes() const { return false; } | |
4658 | ||
4659 | #if wxUSE_XML | |
4660 | virtual bool ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse); | |
4661 | #endif | |
4662 | ||
4663 | #if wxRICHTEXT_HAVE_DIRECT_OUTPUT | |
4664 | virtual bool ExportXML(wxOutputStream& stream, int indent, wxRichTextXMLHandler* handler); | |
4665 | #endif | |
4666 | ||
4667 | #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT | |
4668 | virtual bool ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler); | |
4669 | #endif | |
4670 | ||
4671 | // Images can be floatable (optionally). | |
4672 | virtual bool IsFloatable() const { return true; } | |
4673 | ||
4674 | virtual wxString GetXMLNodeName() const { return wxT("image"); } | |
4675 | ||
4676 | // Accessors | |
4677 | ||
4678 | /** | |
4679 | Returns the image cache (a scaled bitmap). | |
4680 | */ | |
4681 | const wxBitmap& GetImageCache() const { return m_imageCache; } | |
4682 | ||
4683 | /** | |
4684 | Sets the image cache. | |
4685 | */ | |
4686 | void SetImageCache(const wxBitmap& bitmap) { m_imageCache = bitmap; m_originalImageSize = wxSize(bitmap.GetWidth(), bitmap.GetHeight()); } | |
4687 | ||
4688 | /** | |
4689 | Resets the image cache. | |
4690 | */ | |
4691 | void ResetImageCache() { m_imageCache = wxNullBitmap; m_originalImageSize = wxSize(-1, -1); } | |
4692 | ||
4693 | /** | |
4694 | Returns the image block containing the raw data. | |
4695 | */ | |
4696 | wxRichTextImageBlock& GetImageBlock() { return m_imageBlock; } | |
4697 | ||
4698 | // Operations | |
4699 | ||
4700 | /** | |
4701 | Copies the image object. | |
4702 | */ | |
4703 | void Copy(const wxRichTextImage& obj); | |
4704 | ||
4705 | /** | |
4706 | Clones the image object. | |
4707 | */ | |
4708 | virtual wxRichTextObject* Clone() const { return new wxRichTextImage(*this); } | |
4709 | ||
4710 | /** | |
4711 | Creates a cached image at the required size. | |
4712 | */ | |
4713 | virtual bool LoadImageCache(wxDC& dc, bool resetCache = false, const wxSize& parentSize = wxDefaultSize); | |
4714 | ||
4715 | /** | |
4716 | Gets the original image size. | |
4717 | */ | |
4718 | wxSize GetOriginalImageSize() const { return m_originalImageSize; } | |
4719 | ||
4720 | /** | |
4721 | Sets the original image size. | |
4722 | */ | |
4723 | void SetOriginalImageSize(const wxSize& sz) { m_originalImageSize = sz; } | |
4724 | ||
4725 | protected: | |
4726 | wxRichTextImageBlock m_imageBlock; | |
4727 | wxBitmap m_imageCache; | |
4728 | wxSize m_originalImageSize; | |
4729 | }; | |
4730 | ||
4731 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCommand; | |
4732 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction; | |
4733 | ||
4734 | /** | |
4735 | @class wxRichTextBuffer | |
4736 | ||
4737 | This is a kind of paragraph layout box, used to represent the whole buffer. | |
4738 | ||
4739 | @library{wxrichtext} | |
4740 | @category{richtext} | |
4741 | ||
4742 | @see wxRichTextParagraphLayoutBox, wxRichTextCtrl | |
4743 | */ | |
4744 | ||
4745 | class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer: public wxRichTextParagraphLayoutBox | |
4746 | { | |
4747 | DECLARE_DYNAMIC_CLASS(wxRichTextBuffer) | |
4748 | public: | |
4749 | // Constructors | |
4750 | ||
4751 | /** | |
4752 | Default constructor. | |
4753 | */ | |
4754 | wxRichTextBuffer() { Init(); } | |
4755 | ||
4756 | /** | |
4757 | Copy constructor. | |
4758 | */ | |
4759 | wxRichTextBuffer(const wxRichTextBuffer& obj): wxRichTextParagraphLayoutBox() { Init(); Copy(obj); } | |
4760 | ||
4761 | virtual ~wxRichTextBuffer() ; | |
4762 | ||
4763 | // Accessors | |
4764 | ||
4765 | /** | |
4766 | Returns the command processor. | |
4767 | A text buffer always creates its own command processor when it is initialized. | |
4768 | */ | |
4769 | wxCommandProcessor* GetCommandProcessor() const { return m_commandProcessor; } | |
4770 | ||
4771 | /** | |
4772 | Sets style sheet, if any. This will allow the application to use named character and paragraph | |
4773 | styles found in the style sheet. | |
4774 | ||
4775 | Neither the buffer nor the control owns the style sheet so must be deleted by the application. | |
4776 | */ | |
4777 | void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { m_styleSheet = styleSheet; } | |
4778 | ||
4779 | /** | |
4780 | Returns the style sheet. | |
4781 | */ | |
4782 | virtual wxRichTextStyleSheet* GetStyleSheet() const { return m_styleSheet; } | |
4783 | ||
4784 | /** | |
4785 | Sets the style sheet and sends a notification of the change. | |
4786 | */ | |
4787 | bool SetStyleSheetAndNotify(wxRichTextStyleSheet* sheet); | |
4788 | ||
4789 | /** | |
4790 | Pushes the style sheet to the top of the style sheet stack. | |
4791 | */ | |
4792 | bool PushStyleSheet(wxRichTextStyleSheet* styleSheet); | |
4793 | ||
4794 | /** | |
4795 | Pops the style sheet from the top of the style sheet stack. | |
4796 | */ | |
4797 | wxRichTextStyleSheet* PopStyleSheet(); | |
4798 | ||
4799 | /** | |
4800 | Returns the table storing fonts, for quick access and font reuse. | |
4801 | */ | |
4802 | wxRichTextFontTable& GetFontTable() { return m_fontTable; } | |
4803 | ||
4804 | /** | |
4805 | Returns the table storing fonts, for quick access and font reuse. | |
4806 | */ | |
4807 | const wxRichTextFontTable& GetFontTable() const { return m_fontTable; } | |
4808 | ||
4809 | /** | |
4810 | Sets table storing fonts, for quick access and font reuse. | |
4811 | */ | |
4812 | void SetFontTable(const wxRichTextFontTable& table) { m_fontTable = table; } | |
4813 | ||
4814 | /** | |
4815 | Sets the scale factor for displaying fonts, for example for more comfortable | |
4816 | editing. | |
4817 | */ | |
4818 | void SetFontScale(double fontScale); | |
4819 | ||
4820 | /** | |
4821 | Returns the scale factor for displaying fonts, for example for more comfortable | |
4822 | editing. | |
4823 | */ | |
4824 | double GetFontScale() const { return m_fontScale; } | |
4825 | ||
4826 | /** | |
4827 | Sets the scale factor for displaying certain dimensions such as indentation and | |
4828 | inter-paragraph spacing. This can be useful when editing in a small control | |
4829 | where you still want legible text, but a minimum of wasted white space. | |
4830 | */ | |
4831 | void SetDimensionScale(double dimScale); | |
4832 | ||
4833 | /** | |
4834 | Returns the scale factor for displaying certain dimensions such as indentation | |
4835 | and inter-paragraph spacing. | |
4836 | */ | |
4837 | double GetDimensionScale() const { return m_dimensionScale; } | |
4838 | ||
4839 | // Operations | |
4840 | ||
4841 | /** | |
4842 | Initialisation. | |
4843 | */ | |
4844 | void Init(); | |
4845 | ||
4846 | /** | |
4847 | Clears the buffer, adds an empty paragraph, and clears the command processor. | |
4848 | */ | |
4849 | virtual void ResetAndClearCommands(); | |
4850 | ||
4851 | #if wxUSE_FFILE && wxUSE_STREAMS | |
4852 | //@{ | |
4853 | /** | |
4854 | Loads content from a file. | |
4855 | Not all handlers will implement file loading. | |
4856 | */ | |
4857 | virtual bool LoadFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); | |
4858 | //@} | |
4859 | ||
4860 | //@{ | |
4861 | /** | |
4862 | Saves content to a file. | |
4863 | Not all handlers will implement file saving. | |
4864 | */ | |
4865 | virtual bool SaveFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); | |
4866 | //@} | |
4867 | #endif // wxUSE_FFILE | |
4868 | ||
4869 | #if wxUSE_STREAMS | |
4870 | //@{ | |
4871 | /** | |
4872 | Loads content from a stream. | |
4873 | Not all handlers will implement loading from a stream. | |
4874 | */ | |
4875 | virtual bool LoadFile(wxInputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); | |
4876 | //@} | |
4877 | ||
4878 | //@{ | |
4879 | /** | |
4880 | Saves content to a stream. | |
4881 | Not all handlers will implement saving to a stream. | |
4882 | */ | |
4883 | virtual bool SaveFile(wxOutputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); | |
4884 | //@} | |
4885 | #endif // wxUSE_STREAMS | |
4886 | ||
4887 | /** | |
4888 | Sets the handler flags, controlling loading and saving. | |
4889 | */ | |
4890 | void SetHandlerFlags(int flags) { m_handlerFlags = flags; } | |
4891 | ||
4892 | /** | |
4893 | Gets the handler flags, controlling loading and saving. | |
4894 | */ | |
4895 | int GetHandlerFlags() const { return m_handlerFlags; } | |
4896 | ||
4897 | /** | |
4898 | Convenience function to add a paragraph of text. | |
4899 | */ | |
4900 | virtual wxRichTextRange AddParagraph(const wxString& text, wxRichTextAttr* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); } | |
4901 | ||
4902 | /** | |
4903 | Begin collapsing undo/redo commands. Note that this may not work properly | |
4904 | if combining commands that delete or insert content, changing ranges for | |
4905 | subsequent actions. | |
4906 | ||
4907 | @a cmdName should be the name of the combined command that will appear | |
4908 | next to Undo and Redo in the edit menu. | |
4909 | */ | |
4910 | virtual bool BeginBatchUndo(const wxString& cmdName); | |
4911 | ||
4912 | /** | |
4913 | End collapsing undo/redo commands. | |
4914 | */ | |
4915 | virtual bool EndBatchUndo(); | |
4916 | ||
4917 | /** | |
4918 | Returns @true if we are collapsing commands. | |
4919 | */ | |
4920 | virtual bool BatchingUndo() const { return m_batchedCommandDepth > 0; } | |
4921 | ||
4922 | /** | |
4923 | Submit the action immediately, or delay according to whether collapsing is on. | |
4924 | */ | |
4925 | virtual bool SubmitAction(wxRichTextAction* action); | |
4926 | ||
4927 | /** | |
4928 | Returns the collapsed command. | |
4929 | */ | |
4930 | virtual wxRichTextCommand* GetBatchedCommand() const { return m_batchedCommand; } | |
4931 | ||
4932 | /** | |
4933 | Begin suppressing undo/redo commands. The way undo is suppressed may be implemented | |
4934 | differently by each command. If not dealt with by a command implementation, then | |
4935 | it will be implemented automatically by not storing the command in the undo history | |
4936 | when the action is submitted to the command processor. | |
4937 | */ | |
4938 | virtual bool BeginSuppressUndo(); | |
4939 | ||
4940 | /** | |
4941 | End suppressing undo/redo commands. | |
4942 | */ | |
4943 | virtual bool EndSuppressUndo(); | |
4944 | ||
4945 | /** | |
4946 | Are we suppressing undo?? | |
4947 | */ | |
4948 | virtual bool SuppressingUndo() const { return m_suppressUndo > 0; } | |
4949 | ||
4950 | /** | |
4951 | Copy the range to the clipboard. | |
4952 | */ | |
4953 | virtual bool CopyToClipboard(const wxRichTextRange& range); | |
4954 | ||
4955 | /** | |
4956 | Paste the clipboard content to the buffer. | |
4957 | */ | |
4958 | virtual bool PasteFromClipboard(long position); | |
4959 | ||
4960 | /** | |
4961 | Returns @true if we can paste from the clipboard. | |
4962 | */ | |
4963 | virtual bool CanPasteFromClipboard() const; | |
4964 | ||
4965 | /** | |
4966 | Begin using a style. | |
4967 | */ | |
4968 | virtual bool BeginStyle(const wxRichTextAttr& style); | |
4969 | ||
4970 | /** | |
4971 | End the style. | |
4972 | */ | |
4973 | virtual bool EndStyle(); | |
4974 | ||
4975 | /** | |
4976 | End all styles. | |
4977 | */ | |
4978 | virtual bool EndAllStyles(); | |
4979 | ||
4980 | /** | |
4981 | Clears the style stack. | |
4982 | */ | |
4983 | virtual void ClearStyleStack(); | |
4984 | ||
4985 | /** | |
4986 | Returns the size of the style stack, for example to check correct nesting. | |
4987 | */ | |
4988 | virtual size_t GetStyleStackSize() const { return m_attributeStack.GetCount(); } | |
4989 | ||
4990 | /** | |
4991 | Begins using bold. | |
4992 | */ | |
4993 | bool BeginBold(); | |
4994 | ||
4995 | /** | |
4996 | Ends using bold. | |
4997 | */ | |
4998 | bool EndBold() { return EndStyle(); } | |
4999 | ||
5000 | /** | |
5001 | Begins using italic. | |
5002 | */ | |
5003 | bool BeginItalic(); | |
5004 | ||
5005 | /** | |
5006 | Ends using italic. | |
5007 | */ | |
5008 | bool EndItalic() { return EndStyle(); } | |
5009 | ||
5010 | /** | |
5011 | Begins using underline. | |
5012 | */ | |
5013 | bool BeginUnderline(); | |
5014 | ||
5015 | /** | |
5016 | Ends using underline. | |
5017 | */ | |
5018 | bool EndUnderline() { return EndStyle(); } | |
5019 | ||
5020 | /** | |
5021 | Begins using point size. | |
5022 | */ | |
5023 | bool BeginFontSize(int pointSize); | |
5024 | ||
5025 | /** | |
5026 | Ends using point size. | |
5027 | */ | |
5028 | bool EndFontSize() { return EndStyle(); } | |
5029 | ||
5030 | /** | |
5031 | Begins using this font. | |
5032 | */ | |
5033 | bool BeginFont(const wxFont& font); | |
5034 | ||
5035 | /** | |
5036 | Ends using a font. | |
5037 | */ | |
5038 | bool EndFont() { return EndStyle(); } | |
5039 | ||
5040 | /** | |
5041 | Begins using this colour. | |
5042 | */ | |
5043 | bool BeginTextColour(const wxColour& colour); | |
5044 | ||
5045 | /** | |
5046 | Ends using a colour. | |
5047 | */ | |
5048 | bool EndTextColour() { return EndStyle(); } | |
5049 | ||
5050 | /** | |
5051 | Begins using alignment. | |
5052 | */ | |
5053 | bool BeginAlignment(wxTextAttrAlignment alignment); | |
5054 | ||
5055 | /** | |
5056 | Ends alignment. | |
5057 | */ | |
5058 | bool EndAlignment() { return EndStyle(); } | |
5059 | ||
5060 | /** | |
5061 | Begins using @a leftIndent for the left indent, and optionally @a leftSubIndent for | |
5062 | the sub-indent. Both are expressed in tenths of a millimetre. | |
5063 | ||
5064 | The sub-indent is an offset from the left of the paragraph, and is used for all | |
5065 | but the first line in a paragraph. A positive value will cause the first line to appear | |
5066 | to the left of the subsequent lines, and a negative value will cause the first line to be | |
5067 | indented relative to the subsequent lines. | |
5068 | */ | |
5069 | bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0); | |
5070 | ||
5071 | /** | |
5072 | Ends left indent. | |
5073 | */ | |
5074 | bool EndLeftIndent() { return EndStyle(); } | |
5075 | ||
5076 | /** | |
5077 | Begins a right indent, specified in tenths of a millimetre. | |
5078 | */ | |
5079 | bool BeginRightIndent(int rightIndent); | |
5080 | ||
5081 | /** | |
5082 | Ends right indent. | |
5083 | */ | |
5084 | bool EndRightIndent() { return EndStyle(); } | |
5085 | ||
5086 | /** | |
5087 | Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing | |
5088 | in tenths of a millimetre. | |
5089 | */ | |
5090 | bool BeginParagraphSpacing(int before, int after); | |
5091 | ||
5092 | /** | |
5093 | Ends paragraph spacing. | |
5094 | */ | |
5095 | bool EndParagraphSpacing() { return EndStyle(); } | |
5096 | ||
5097 | /** | |
5098 | Begins line spacing using the specified value. @e spacing is a multiple, where | |
5099 | 10 means single-spacing, 15 means 1.5 spacing, and 20 means double spacing. | |
5100 | ||
5101 | The ::wxTextAttrLineSpacing enumeration values are defined for convenience. | |
5102 | */ | |
5103 | bool BeginLineSpacing(int lineSpacing); | |
5104 | ||
5105 | /** | |
5106 | Ends line spacing. | |
5107 | */ | |
5108 | bool EndLineSpacing() { return EndStyle(); } | |
5109 | ||
5110 | /** | |
5111 | Begins numbered bullet. | |
5112 | ||
5113 | This call will be needed for each item in the list, and the | |
5114 | application should take care of incrementing the numbering. | |
5115 | ||
5116 | @a bulletNumber is a number, usually starting with 1. | |
5117 | @a leftIndent and @a leftSubIndent are values in tenths of a millimetre. | |
5118 | @a bulletStyle is a bitlist of the following values: | |
5119 | ||
5120 | wxRichTextBuffer uses indentation to render a bulleted item. | |
5121 | The left indent is the distance between the margin and the bullet. | |
5122 | The content of the paragraph, including the first line, starts | |
5123 | at leftMargin + leftSubIndent. | |
5124 | So the distance between the left edge of the bullet and the | |
5125 | left of the actual paragraph is leftSubIndent. | |
5126 | */ | |
5127 | bool BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD); | |
5128 | ||
5129 | /** | |
5130 | Ends numbered bullet. | |
5131 | */ | |
5132 | bool EndNumberedBullet() { return EndStyle(); } | |
5133 | ||
5134 | /** | |
5135 | Begins applying a symbol bullet, using a character from the current font. | |
5136 | ||
5137 | See BeginNumberedBullet() for an explanation of how indentation is used | |
5138 | to render the bulleted paragraph. | |
5139 | */ | |
5140 | bool BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL); | |
5141 | ||
5142 | /** | |
5143 | Ends symbol bullet. | |
5144 | */ | |
5145 | bool EndSymbolBullet() { return EndStyle(); } | |
5146 | ||
5147 | /** | |
5148 | Begins applying a standard bullet, using one of the standard bullet names | |
5149 | (currently @c standard/circle or @c standard/square. | |
5150 | ||
5151 | See BeginNumberedBullet() for an explanation of how indentation is used to | |
5152 | render the bulleted paragraph. | |
5153 | */ | |
5154 | bool BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD); | |
5155 | ||
5156 | /** | |
5157 | Ends standard bullet. | |
5158 | */ | |
5159 | bool EndStandardBullet() { return EndStyle(); } | |
5160 | ||
5161 | /** | |
5162 | Begins named character style. | |
5163 | */ | |
5164 | bool BeginCharacterStyle(const wxString& characterStyle); | |
5165 | ||
5166 | /** | |
5167 | Ends named character style. | |
5168 | */ | |
5169 | bool EndCharacterStyle() { return EndStyle(); } | |
5170 | ||
5171 | /** | |
5172 | Begins named paragraph style. | |
5173 | */ | |
5174 | bool BeginParagraphStyle(const wxString& paragraphStyle); | |
5175 | ||
5176 | /** | |
5177 | Ends named character style. | |
5178 | */ | |
5179 | bool EndParagraphStyle() { return EndStyle(); } | |
5180 | ||
5181 | /** | |
5182 | Begins named list style. | |
5183 | ||
5184 | Optionally, you can also pass a level and a number. | |
5185 | */ | |
5186 | bool BeginListStyle(const wxString& listStyle, int level = 1, int number = 1); | |
5187 | ||
5188 | /** | |
5189 | Ends named character style. | |
5190 | */ | |
5191 | bool EndListStyle() { return EndStyle(); } | |
5192 | ||
5193 | /** | |
5194 | Begins applying wxTEXT_ATTR_URL to the content. | |
5195 | ||
5196 | Pass a URL and optionally, a character style to apply, since it is common | |
5197 | to mark a URL with a familiar style such as blue text with underlining. | |
5198 | */ | |
5199 | bool BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString); | |
5200 | ||
5201 | /** | |
5202 | Ends URL. | |
5203 | */ | |
5204 | bool EndURL() { return EndStyle(); } | |
5205 | ||
5206 | // Event handling | |
5207 | ||
5208 | /** | |
5209 | Adds an event handler. | |
5210 | ||
5211 | A buffer associated with a control has the control as the only event handler, | |
5212 | but the application is free to add more if further notification is required. | |
5213 | All handlers are notified of an event originating from the buffer, such as | |
5214 | the replacement of a style sheet during loading. | |
5215 | ||
5216 | The buffer never deletes any of the event handlers, unless RemoveEventHandler() | |
5217 | is called with @true as the second argument. | |
5218 | */ | |
5219 | bool AddEventHandler(wxEvtHandler* handler); | |
5220 | ||
5221 | /** | |
5222 | Removes an event handler from the buffer's list of handlers, deleting the | |
5223 | object if @a deleteHandler is @true. | |
5224 | */ | |
5225 | bool RemoveEventHandler(wxEvtHandler* handler, bool deleteHandler = false); | |
5226 | ||
5227 | /** | |
5228 | Clear event handlers. | |
5229 | */ | |
5230 | void ClearEventHandlers(); | |
5231 | ||
5232 | /** | |
5233 | Send event to event handlers. If sendToAll is true, will send to all event handlers, | |
5234 | otherwise will stop at the first successful one. | |
5235 | */ | |
5236 | bool SendEvent(wxEvent& event, bool sendToAll = true); | |
5237 | ||
5238 | // Implementation | |
5239 | ||
5240 | virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); | |
5241 | ||
5242 | /** | |
5243 | Copies the buffer. | |
5244 | */ | |
5245 | void Copy(const wxRichTextBuffer& obj); | |
5246 | ||
5247 | /** | |
5248 | Assignment operator. | |
5249 | */ | |
5250 | void operator= (const wxRichTextBuffer& obj) { Copy(obj); } | |
5251 | ||
5252 | /** | |
5253 | Clones the buffer. | |
5254 | */ | |
5255 | virtual wxRichTextObject* Clone() const { return new wxRichTextBuffer(*this); } | |
5256 | ||
5257 | /** | |
5258 | Submits a command to insert paragraphs. | |
5259 | */ | |
5260 | bool InsertParagraphsWithUndo(long pos, const wxRichTextParagraphLayoutBox& paragraphs, wxRichTextCtrl* ctrl, int flags = 0); | |
5261 | ||
5262 | /** | |
5263 | Submits a command to insert the given text. | |
5264 | */ | |
5265 | bool InsertTextWithUndo(long pos, const wxString& text, wxRichTextCtrl* ctrl, int flags = 0); | |
5266 | ||
5267 | /** | |
5268 | Submits a command to insert a newline. | |
5269 | */ | |
5270 | bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int flags = 0); | |
5271 | ||
5272 | /** | |
5273 | Submits a command to insert the given image. | |
5274 | */ | |
5275 | bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags = 0, | |
5276 | const wxRichTextAttr& textAttr = wxRichTextAttr()); | |
5277 | ||
5278 | /** | |
5279 | Submits a command to insert an object. | |
5280 | */ | |
5281 | wxRichTextObject* InsertObjectWithUndo(long pos, wxRichTextObject *object, wxRichTextCtrl* ctrl, int flags); | |
5282 | ||
5283 | /** | |
5284 | Submits a command to delete this range. | |
5285 | */ | |
5286 | bool DeleteRangeWithUndo(const wxRichTextRange& range, wxRichTextCtrl* ctrl); | |
5287 | ||
5288 | /** | |
5289 | Mark modified. | |
5290 | */ | |
5291 | void Modify(bool modify = true) { m_modified = modify; } | |
5292 | ||
5293 | /** | |
5294 | Returns @true if the buffer was modified. | |
5295 | */ | |
5296 | bool IsModified() const { return m_modified; } | |
5297 | ||
5298 | //@{ | |
5299 | /** | |
5300 | Dumps contents of buffer for debugging purposes. | |
5301 | */ | |
5302 | virtual void Dump(); | |
5303 | virtual void Dump(wxTextOutputStream& stream) { wxRichTextParagraphLayoutBox::Dump(stream); } | |
5304 | //@} | |
5305 | ||
5306 | /** | |
5307 | Returns the file handlers. | |
5308 | */ | |
5309 | static wxList& GetHandlers() { return sm_handlers; } | |
5310 | ||
5311 | /** | |
5312 | Adds a file handler to the end. | |
5313 | */ | |
5314 | static void AddHandler(wxRichTextFileHandler *handler); | |
5315 | ||
5316 | /** | |
5317 | Inserts a file handler at the front. | |
5318 | */ | |
5319 | static void InsertHandler(wxRichTextFileHandler *handler); | |
5320 | ||
5321 | /** | |
5322 | Removes a file handler. | |
5323 | */ | |
5324 | static bool RemoveHandler(const wxString& name); | |
5325 | ||
5326 | /** | |
5327 | Finds a file handler by name. | |
5328 | */ | |
5329 | static wxRichTextFileHandler *FindHandler(const wxString& name); | |
5330 | ||
5331 | /** | |
5332 | Finds a file handler by extension and type. | |
5333 | */ | |
5334 | static wxRichTextFileHandler *FindHandler(const wxString& extension, wxRichTextFileType imageType); | |
5335 | ||
5336 | /** | |
5337 | Finds a handler by filename or, if supplied, type. | |
5338 | */ | |
5339 | static wxRichTextFileHandler *FindHandlerFilenameOrType(const wxString& filename, | |
5340 | wxRichTextFileType imageType); | |
5341 | ||
5342 | /** | |
5343 | Finds a handler by type. | |
5344 | */ | |
5345 | static wxRichTextFileHandler *FindHandler(wxRichTextFileType imageType); | |
5346 | ||
5347 | /** | |
5348 | Gets a wildcard incorporating all visible handlers. If @a types is present, | |
5349 | it will be filled with the file type corresponding to each filter. This can be | |
5350 | used to determine the type to pass to LoadFile given a selected filter. | |
5351 | */ | |
5352 | static wxString GetExtWildcard(bool combine = false, bool save = false, wxArrayInt* types = NULL); | |
5353 | ||
5354 | /** | |
5355 | Clean up file handlers. | |
5356 | */ | |
5357 | static void CleanUpHandlers(); | |
5358 | ||
5359 | /** | |
5360 | Initialise the standard file handlers. | |
5361 | Currently, only the plain text loading/saving handler is initialised by default. | |
5362 | */ | |
5363 | static void InitStandardHandlers(); | |
5364 | ||
5365 | /** | |
5366 | Returns the drawing handlers. | |
5367 | */ | |
5368 | static wxList& GetDrawingHandlers() { return sm_drawingHandlers; } | |
5369 | ||
5370 | /** | |
5371 | Adds a drawing handler to the end. | |
5372 | */ | |
5373 | static void AddDrawingHandler(wxRichTextDrawingHandler *handler); | |
5374 | ||
5375 | /** | |
5376 | Inserts a drawing handler at the front. | |
5377 | */ | |
5378 | static void InsertDrawingHandler(wxRichTextDrawingHandler *handler); | |
5379 | ||
5380 | /** | |
5381 | Removes a drawing handler. | |
5382 | */ | |
5383 | static bool RemoveDrawingHandler(const wxString& name); | |
5384 | ||
5385 | /** | |
5386 | Finds a drawing handler by name. | |
5387 | */ | |
5388 | static wxRichTextDrawingHandler *FindDrawingHandler(const wxString& name); | |
5389 | ||
5390 | /** | |
5391 | Clean up drawing handlers. | |
5392 | */ | |
5393 | static void CleanUpDrawingHandlers(); | |
5394 | ||
5395 | /** | |
5396 | Returns the field types. | |
5397 | */ | |
5398 | static wxRichTextFieldTypeHashMap& GetFieldTypes() { return sm_fieldTypes; } | |
5399 | ||
5400 | /** | |
5401 | Adds a field type. | |
5402 | ||
5403 | @see RemoveFieldType(), FindFieldType(), wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard | |
5404 | ||
5405 | */ | |
5406 | static void AddFieldType(wxRichTextFieldType *fieldType); | |
5407 | ||
5408 | /** | |
5409 | Removes a field type by name. | |
5410 | ||
5411 | @see AddFieldType(), FindFieldType(), wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard | |
5412 | */ | |
5413 | static bool RemoveFieldType(const wxString& name); | |
5414 | ||
5415 | /** | |
5416 | Finds a field type by name. | |
5417 | ||
5418 | @see RemoveFieldType(), AddFieldType(), wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard | |
5419 | */ | |
5420 | static wxRichTextFieldType *FindFieldType(const wxString& name); | |
5421 | ||
5422 | /** | |
5423 | Cleans up field types. | |
5424 | */ | |
5425 | static void CleanUpFieldTypes(); | |
5426 | ||
5427 | /** | |
5428 | Returns the renderer object. | |
5429 | */ | |
5430 | static wxRichTextRenderer* GetRenderer() { return sm_renderer; } | |
5431 | ||
5432 | /** | |
5433 | Sets @a renderer as the object to be used to render certain aspects of the | |
5434 | content, such as bullets. | |
5435 | ||
5436 | You can override default rendering by deriving a new class from | |
5437 | wxRichTextRenderer or wxRichTextStdRenderer, overriding one or more | |
5438 | virtual functions, and setting an instance of the class using this function. | |
5439 | */ | |
5440 | static void SetRenderer(wxRichTextRenderer* renderer); | |
5441 | ||
5442 | /** | |
5443 | Returns the minimum margin between bullet and paragraph in 10ths of a mm. | |
5444 | */ | |
5445 | static int GetBulletRightMargin() { return sm_bulletRightMargin; } | |
5446 | ||
5447 | /** | |
5448 | Sets the minimum margin between bullet and paragraph in 10ths of a mm. | |
5449 | */ | |
5450 | static void SetBulletRightMargin(int margin) { sm_bulletRightMargin = margin; } | |
5451 | ||
5452 | /** | |
5453 | Returns the factor to multiply by character height to get a reasonable bullet size. | |
5454 | */ | |
5455 | static float GetBulletProportion() { return sm_bulletProportion; } | |
5456 | ||
5457 | /** | |
5458 | Sets the factor to multiply by character height to get a reasonable bullet size. | |
5459 | */ | |
5460 | static void SetBulletProportion(float prop) { sm_bulletProportion = prop; } | |
5461 | ||
5462 | /** | |
5463 | Returns the scale factor for calculating dimensions. | |
5464 | */ | |
5465 | double GetScale() const { return m_scale; } | |
5466 | ||
5467 | /** | |
5468 | Sets the scale factor for calculating dimensions. | |
5469 | */ | |
5470 | void SetScale(double scale) { m_scale = scale; } | |
5471 | ||
5472 | /** | |
5473 | Sets the floating layout mode. Pass @false to speed up editing by not performing | |
5474 | floating layout. This setting affects all buffers. | |
5475 | ||
5476 | */ | |
5477 | static void SetFloatingLayoutMode(bool mode) { sm_floatingLayoutMode = mode; } | |
5478 | ||
5479 | /** | |
5480 | Returns the floating layout mode. The default is @true, where objects | |
5481 | are laid out according to their floating status. | |
5482 | */ | |
5483 | static bool GetFloatingLayoutMode() { return sm_floatingLayoutMode; } | |
5484 | ||
5485 | protected: | |
5486 | ||
5487 | /// Command processor | |
5488 | wxCommandProcessor* m_commandProcessor; | |
5489 | ||
5490 | /// Table storing fonts | |
5491 | wxRichTextFontTable m_fontTable; | |
5492 | ||
5493 | /// Has been modified? | |
5494 | bool m_modified; | |
5495 | ||
5496 | /// Collapsed command stack | |
5497 | int m_batchedCommandDepth; | |
5498 | ||
5499 | /// Name for collapsed command | |
5500 | wxString m_batchedCommandsName; | |
5501 | ||
5502 | /// Current collapsed command accumulating actions | |
5503 | wxRichTextCommand* m_batchedCommand; | |
5504 | ||
5505 | /// Whether to suppress undo | |
5506 | int m_suppressUndo; | |
5507 | ||
5508 | /// Style sheet, if any | |
5509 | wxRichTextStyleSheet* m_styleSheet; | |
5510 | ||
5511 | /// List of event handlers that will be notified of events | |
5512 | wxList m_eventHandlers; | |
5513 | ||
5514 | /// Stack of attributes for convenience functions | |
5515 | wxList m_attributeStack; | |
5516 | ||
5517 | /// Flags to be passed to handlers | |
5518 | int m_handlerFlags; | |
5519 | ||
5520 | /// File handlers | |
5521 | static wxList sm_handlers; | |
5522 | ||
5523 | /// Drawing handlers | |
5524 | static wxList sm_drawingHandlers; | |
5525 | ||
5526 | /// Field types | |
5527 | static wxRichTextFieldTypeHashMap sm_fieldTypes; | |
5528 | ||
5529 | /// Renderer | |
5530 | static wxRichTextRenderer* sm_renderer; | |
5531 | ||
5532 | /// Minimum margin between bullet and paragraph in 10ths of a mm | |
5533 | static int sm_bulletRightMargin; | |
5534 | ||
5535 | /// Factor to multiply by character height to get a reasonable bullet size | |
5536 | static float sm_bulletProportion; | |
5537 | ||
5538 | /// Floating layout mode, @true by default | |
5539 | static bool sm_floatingLayoutMode; | |
5540 | ||
5541 | /// Scaling factor in use: needed to calculate correct dimensions when printing | |
5542 | double m_scale; | |
5543 | ||
5544 | /// Font scale for adjusting the text size when editing | |
5545 | double m_fontScale; | |
5546 | ||
5547 | /// Dimension scale for reducing redundant whitespace when editing | |
5548 | double m_dimensionScale; | |
5549 | }; | |
5550 | ||
5551 | /** | |
5552 | @class wxRichTextCell | |
5553 | ||
5554 | wxRichTextCell is the cell in a table. | |
5555 | */ | |
5556 | ||
5557 | class WXDLLIMPEXP_RICHTEXT wxRichTextCell: public wxRichTextBox | |
5558 | { | |
5559 | DECLARE_DYNAMIC_CLASS(wxRichTextCell) | |
5560 | public: | |
5561 | // Constructors | |
5562 | ||
5563 | /** | |
5564 | Default constructor; optionally pass the parent object. | |
5565 | */ | |
5566 | ||
5567 | wxRichTextCell(wxRichTextObject* parent = NULL); | |
5568 | ||
5569 | /** | |
5570 | Copy constructor. | |
5571 | */ | |
5572 | ||
5573 | wxRichTextCell(const wxRichTextCell& obj): wxRichTextBox() { Copy(obj); } | |
5574 | ||
5575 | // Overridables | |
5576 | ||
5577 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
5578 | ||
5579 | virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); | |
5580 | ||
5581 | virtual wxString GetXMLNodeName() const { return wxT("cell"); } | |
5582 | ||
5583 | virtual bool CanEditProperties() const { return true; } | |
5584 | ||
5585 | virtual bool EditProperties(wxWindow* parent, wxRichTextBuffer* buffer); | |
5586 | ||
5587 | virtual wxString GetPropertiesMenuLabel() const { return wxGetTranslation("&Cell"); } | |
5588 | ||
5589 | // Accessors | |
5590 | ||
5591 | int GetColspan() const; | |
5592 | ||
5593 | void SetColspan(long span) { GetProperties().SetProperty(wxT("colspan"), span); } | |
5594 | ||
5595 | int GetRowspan() const; | |
5596 | ||
5597 | void SetRowspan(long span) { GetProperties().SetProperty(wxT("rowspan"), span); } | |
5598 | ||
5599 | // Operations | |
5600 | ||
5601 | virtual wxRichTextObject* Clone() const { return new wxRichTextCell(*this); } | |
5602 | ||
5603 | void Copy(const wxRichTextCell& obj); | |
5604 | ||
5605 | protected: | |
5606 | }; | |
5607 | ||
5608 | /** | |
5609 | @class wxRichTextTable | |
5610 | ||
5611 | wxRichTextTable represents a table with arbitrary columns and rows. | |
5612 | */ | |
5613 | ||
5614 | WX_DEFINE_ARRAY_PTR(wxRichTextObject*, wxRichTextObjectPtrArray); | |
5615 | WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRichTextObjectPtrArray, wxRichTextObjectPtrArrayArray, WXDLLIMPEXP_RICHTEXT); | |
5616 | ||
5617 | class WXDLLIMPEXP_RICHTEXT wxRichTextTable: public wxRichTextBox | |
5618 | { | |
5619 | DECLARE_DYNAMIC_CLASS(wxRichTextTable) | |
5620 | public: | |
5621 | ||
5622 | // Constructors | |
5623 | ||
5624 | /** | |
5625 | Default constructor; optionally pass the parent object. | |
5626 | */ | |
5627 | ||
5628 | wxRichTextTable(wxRichTextObject* parent = NULL); | |
5629 | ||
5630 | /** | |
5631 | Copy constructor. | |
5632 | */ | |
5633 | ||
5634 | wxRichTextTable(const wxRichTextTable& obj): wxRichTextBox() { Copy(obj); } | |
5635 | ||
5636 | // Overridables | |
5637 | ||
5638 | virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style); | |
5639 | ||
5640 | virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0); | |
5641 | ||
5642 | virtual wxString GetXMLNodeName() const { return wxT("table"); } | |
5643 | ||
5644 | virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style); | |
5645 | ||
5646 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const; | |
5647 | ||
5648 | virtual bool DeleteRange(const wxRichTextRange& range); | |
5649 | ||
5650 | virtual wxString GetTextForRange(const wxRichTextRange& range) const; | |
5651 | ||
5652 | #if wxUSE_XML | |
5653 | virtual bool ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse); | |
5654 | #endif | |
5655 | ||
5656 | #if wxRICHTEXT_HAVE_DIRECT_OUTPUT | |
5657 | virtual bool ExportXML(wxOutputStream& stream, int indent, wxRichTextXMLHandler* handler); | |
5658 | #endif | |
5659 | ||
5660 | #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT | |
5661 | virtual bool ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler); | |
5662 | #endif | |
5663 | ||
5664 | virtual bool FindPosition(wxDC& dc, wxRichTextDrawingContext& context, long index, wxPoint& pt, int* height, bool forceLineStart); | |
5665 | ||
5666 | virtual void CalculateRange(long start, long& end); | |
5667 | ||
5668 | // Can this object handle the selections of its children? FOr example, a table. | |
5669 | virtual bool HandlesChildSelections() const { return true; } | |
5670 | ||
5671 | /// Returns a selection object specifying the selections between start and end character positions. | |
5672 | /// For example, a table would deduce what cells (of range length 1) are selected when dragging across the table. | |
5673 | virtual wxRichTextSelection GetSelection(long start, long end) const; | |
5674 | ||
5675 | virtual bool CanEditProperties() const { return true; } | |
5676 | ||
5677 | virtual bool EditProperties(wxWindow* parent, wxRichTextBuffer* buffer); | |
5678 | ||
5679 | virtual wxString GetPropertiesMenuLabel() const { return wxGetTranslation("&Table"); } | |
5680 | ||
5681 | // Returns true if objects of this class can accept the focus, i.e. a call to SetFocusObject | |
5682 | // is possible. For example, containers supporting text, such as a text box object, can accept the focus, | |
5683 | // but a table can't (set the focus to individual cells instead). | |
5684 | virtual bool AcceptsFocus() const { return false; } | |
5685 | ||
5686 | // Accessors | |
5687 | ||
5688 | /** | |
5689 | Returns the cells array. | |
5690 | */ | |
5691 | const wxRichTextObjectPtrArrayArray& GetCells() const { return m_cells; } | |
5692 | ||
5693 | /** | |
5694 | Returns the cells array. | |
5695 | */ | |
5696 | wxRichTextObjectPtrArrayArray& GetCells() { return m_cells; } | |
5697 | ||
5698 | /** | |
5699 | Returns the row count. | |
5700 | */ | |
5701 | int GetRowCount() const { return m_rowCount; } | |
5702 | ||
5703 | /** | |
5704 | Sets the row count. | |
5705 | */ | |
5706 | void SetRowCount(int count) { m_rowCount = count; } | |
5707 | ||
5708 | /** | |
5709 | Returns the column count. | |
5710 | */ | |
5711 | int GetColumnCount() const { return m_colCount; } | |
5712 | ||
5713 | /** | |
5714 | Sets the column count. | |
5715 | */ | |
5716 | void SetColumnCount(int count) { m_colCount = count; } | |
5717 | ||
5718 | /** | |
5719 | Returns the cell at the given row/column position. | |
5720 | */ | |
5721 | virtual wxRichTextCell* GetCell(int row, int col) const; | |
5722 | ||
5723 | /** | |
5724 | Returns the cell at the given character position (in the range of the table). | |
5725 | */ | |
5726 | virtual wxRichTextCell* GetCell(long pos) const; | |
5727 | ||
5728 | /** | |
5729 | Returns the row/column for a given character position. | |
5730 | */ | |
5731 | virtual bool GetCellRowColumnPosition(long pos, int& row, int& col) const; | |
5732 | ||
5733 | /** | |
5734 | Returns the coordinates of the cell with keyboard focus, or (-1,-1) if none. | |
5735 | */ | |
5736 | virtual wxPosition GetFocusedCell() const; | |
5737 | ||
5738 | // Operations | |
5739 | ||
5740 | /** | |
5741 | Clears the table. | |
5742 | */ | |
5743 | ||
5744 | virtual void ClearTable(); | |
5745 | ||
5746 | /** | |
5747 | Creates a table of the given dimensions. | |
5748 | */ | |
5749 | ||
5750 | virtual bool CreateTable(int rows, int cols); | |
5751 | ||
5752 | /** | |
5753 | Sets the attributes for the cells specified by the selection. | |
5754 | */ | |
5755 | ||
5756 | virtual bool SetCellStyle(const wxRichTextSelection& selection, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); | |
5757 | ||
5758 | /** | |
5759 | Deletes rows from the given row position. | |
5760 | */ | |
5761 | ||
5762 | virtual bool DeleteRows(int startRow, int noRows = 1); | |
5763 | ||
5764 | /** | |
5765 | Deletes columns from the given column position. | |
5766 | */ | |
5767 | ||
5768 | virtual bool DeleteColumns(int startCol, int noCols = 1); | |
5769 | ||
5770 | /** | |
5771 | Adds rows from the given row position. | |
5772 | */ | |
5773 | ||
5774 | virtual bool AddRows(int startRow, int noRows = 1, const wxRichTextAttr& attr = wxRichTextAttr()); | |
5775 | ||
5776 | /** | |
5777 | Adds columns from the given column position. | |
5778 | */ | |
5779 | ||
5780 | virtual bool AddColumns(int startCol, int noCols = 1, const wxRichTextAttr& attr = wxRichTextAttr()); | |
5781 | ||
5782 | // Makes a clone of this object. | |
5783 | virtual wxRichTextObject* Clone() const { return new wxRichTextTable(*this); } | |
5784 | ||
5785 | // Copies this object. | |
5786 | void Copy(const wxRichTextTable& obj); | |
5787 | ||
5788 | protected: | |
5789 | ||
5790 | int m_rowCount; | |
5791 | int m_colCount; | |
5792 | ||
5793 | // An array of rows, each of which is a wxRichTextObjectPtrArray containing | |
5794 | // the cell objects. The cell objects are also children of this object. | |
5795 | // Problem: if boxes are immediate children of a box, this will cause problems | |
5796 | // with wxRichTextParagraphLayoutBox functions (and functions elsewhere) that | |
5797 | // expect to find just paragraphs. May have to adjust the way we handle the | |
5798 | // hierarchy to accept non-paragraph objects in a paragraph layout box. | |
5799 | // We'll be overriding much wxRichTextParagraphLayoutBox functionality so this | |
5800 | // may not be such a problem. Perhaps the table should derive from a different | |
5801 | // class? | |
5802 | wxRichTextObjectPtrArrayArray m_cells; | |
5803 | }; | |
5804 | ||
5805 | /** @class wxRichTextTableBlock | |
5806 | ||
5807 | Stores the coordinates for a block of cells. | |
5808 | */ | |
5809 | ||
5810 | class WXDLLIMPEXP_RICHTEXT wxRichTextTableBlock | |
5811 | { | |
5812 | public: | |
5813 | wxRichTextTableBlock() { Init(); } | |
5814 | wxRichTextTableBlock(int colStart, int colEnd, int rowStart, int rowEnd) | |
5815 | { Init(); m_colStart = colStart; m_colEnd = colEnd; m_rowStart = rowStart; m_rowEnd = rowEnd; } | |
5816 | wxRichTextTableBlock(const wxRichTextTableBlock& block) { Copy(block); } | |
5817 | ||
5818 | void Init() { m_colStart = 0; m_colEnd = 0; m_rowStart = 0; m_rowEnd = 0; } | |
5819 | ||
5820 | void Copy(const wxRichTextTableBlock& block) | |
5821 | { | |
5822 | m_colStart = block.m_colStart; m_colEnd = block.m_colEnd; m_rowStart = block.m_rowStart; m_rowEnd = block.m_rowEnd; | |
5823 | } | |
5824 | void operator=(const wxRichTextTableBlock& block) { Copy(block); } | |
5825 | bool operator==(const wxRichTextTableBlock& block) | |
5826 | { return m_colStart == block.m_colStart && m_colEnd == block.m_colEnd && m_rowStart == block.m_rowStart && m_rowEnd == block.m_rowEnd; } | |
5827 | ||
5828 | /// Computes the block given a table (perhaps about to be edited) and a rich text control | |
5829 | /// that may have a selection. If no selection, the whole table is used. If just the whole content | |
5830 | /// of one cell is selected, this cell only is used. If the cell contents is not selected and | |
5831 | /// requireCellSelection is @false, the focused cell will count as a selected cell. | |
5832 | bool ComputeBlockForSelection(wxRichTextTable* table, wxRichTextCtrl* ctrl, bool requireCellSelection = true); | |
5833 | ||
5834 | /// Does this block represent the whole table? | |
5835 | bool IsWholeTable(wxRichTextTable* table) const; | |
5836 | ||
5837 | /// Returns the cell focused in the table, if any | |
5838 | static wxRichTextCell* GetFocusedCell(wxRichTextCtrl* ctrl); | |
5839 | ||
5840 | int& ColStart() { return m_colStart; } | |
5841 | int ColStart() const { return m_colStart; } | |
5842 | ||
5843 | int& ColEnd() { return m_colEnd; } | |
5844 | int ColEnd() const { return m_colEnd; } | |
5845 | ||
5846 | int& RowStart() { return m_rowStart; } | |
5847 | int RowStart() const { return m_rowStart; } | |
5848 | ||
5849 | int& RowEnd() { return m_rowEnd; } | |
5850 | int RowEnd() const { return m_rowEnd; } | |
5851 | ||
5852 | int m_colStart, m_colEnd, m_rowStart, m_rowEnd; | |
5853 | }; | |
5854 | ||
5855 | /** | |
5856 | The command identifiers for Do/Undo. | |
5857 | */ | |
5858 | ||
5859 | enum wxRichTextCommandId | |
5860 | { | |
5861 | wxRICHTEXT_INSERT, | |
5862 | wxRICHTEXT_DELETE, | |
5863 | wxRICHTEXT_CHANGE_ATTRIBUTES, | |
5864 | wxRICHTEXT_CHANGE_STYLE, | |
5865 | wxRICHTEXT_CHANGE_PROPERTIES, | |
5866 | wxRICHTEXT_CHANGE_OBJECT | |
5867 | }; | |
5868 | ||
5869 | /** | |
5870 | @class wxRichTextObjectAddress | |
5871 | ||
5872 | A class for specifying an object anywhere in an object hierarchy, | |
5873 | without using a pointer, necessary since wxRTC commands may delete | |
5874 | and recreate sub-objects so physical object addresses change. An array | |
5875 | of positions (one per hierarchy level) is used. | |
5876 | ||
5877 | @library{wxrichtext} | |
5878 | @category{richtext} | |
5879 | ||
5880 | @see wxRichTextCommand | |
5881 | */ | |
5882 | ||
5883 | class WXDLLIMPEXP_RICHTEXT wxRichTextObjectAddress | |
5884 | { | |
5885 | public: | |
5886 | /** | |
5887 | Creates the address given a container and an object. | |
5888 | */ | |
5889 | wxRichTextObjectAddress(wxRichTextParagraphLayoutBox* topLevelContainer, wxRichTextObject* obj) { Create(topLevelContainer, obj); } | |
5890 | /** | |
5891 | */ | |
5892 | wxRichTextObjectAddress() { Init(); } | |
5893 | /** | |
5894 | */ | |
5895 | wxRichTextObjectAddress(const wxRichTextObjectAddress& address) { Copy(address); } | |
5896 | ||
5897 | void Init() {} | |
5898 | ||
5899 | /** | |
5900 | Copies the address. | |
5901 | */ | |
5902 | void Copy(const wxRichTextObjectAddress& address) { m_address = address.m_address; } | |
5903 | ||
5904 | /** | |
5905 | Assignment operator. | |
5906 | */ | |
5907 | void operator=(const wxRichTextObjectAddress& address) { Copy(address); } | |
5908 | ||
5909 | /** | |
5910 | Returns the object specified by the address, given a top level container. | |
5911 | */ | |
5912 | wxRichTextObject* GetObject(wxRichTextParagraphLayoutBox* topLevelContainer) const; | |
5913 | ||
5914 | /** | |
5915 | Creates the address given a container and an object. | |
5916 | */ | |
5917 | bool Create(wxRichTextParagraphLayoutBox* topLevelContainer, wxRichTextObject* obj); | |
5918 | ||
5919 | /** | |
5920 | Returns the array of integers representing the object address. | |
5921 | */ | |
5922 | wxArrayInt& GetAddress() { return m_address; } | |
5923 | ||
5924 | /** | |
5925 | Returns the array of integers representing the object address. | |
5926 | */ | |
5927 | const wxArrayInt& GetAddress() const { return m_address; } | |
5928 | ||
5929 | /** | |
5930 | Sets the address from an array of integers. | |
5931 | */ | |
5932 | void SetAddress(const wxArrayInt& address) { m_address = address; } | |
5933 | ||
5934 | protected: | |
5935 | ||
5936 | wxArrayInt m_address; | |
5937 | }; | |
5938 | ||
5939 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction; | |
5940 | ||
5941 | /** | |
5942 | @class wxRichTextCommand | |
5943 | ||
5944 | Implements a command on the undo/redo stack. A wxRichTextCommand object contains one or more wxRichTextAction | |
5945 | objects, allowing aggregation of a number of operations into one command. | |
5946 | ||
5947 | @library{wxrichtext} | |
5948 | @category{richtext} | |
5949 | ||
5950 | @see wxRichTextAction | |
5951 | */ | |
5952 | ||
5953 | class WXDLLIMPEXP_RICHTEXT wxRichTextCommand: public wxCommand | |
5954 | { | |
5955 | public: | |
5956 | /** | |
5957 | Constructor for one action. | |
5958 | */ | |
5959 | wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, | |
5960 | wxRichTextParagraphLayoutBox* container, wxRichTextCtrl* ctrl, bool ignoreFirstTime = false); | |
5961 | ||
5962 | /** | |
5963 | Constructor for multiple actions. | |
5964 | */ | |
5965 | wxRichTextCommand(const wxString& name); | |
5966 | ||
5967 | virtual ~wxRichTextCommand(); | |
5968 | ||
5969 | /** | |
5970 | Performs the command. | |
5971 | */ | |
5972 | bool Do(); | |
5973 | ||
5974 | /** | |
5975 | Undoes the command. | |
5976 | */ | |
5977 | bool Undo(); | |
5978 | ||
5979 | /** | |
5980 | Adds an action to the action list. | |
5981 | */ | |
5982 | void AddAction(wxRichTextAction* action); | |
5983 | ||
5984 | /** | |
5985 | Clears the action list. | |
5986 | */ | |
5987 | void ClearActions(); | |
5988 | ||
5989 | /** | |
5990 | Returns the action list. | |
5991 | */ | |
5992 | wxList& GetActions() { return m_actions; } | |
5993 | ||
5994 | protected: | |
5995 | ||
5996 | wxList m_actions; | |
5997 | }; | |
5998 | ||
5999 | /** | |
6000 | @class wxRichTextAction | |
6001 | ||
6002 | Implements a part of a command. | |
6003 | ||
6004 | @library{wxrichtext} | |
6005 | @category{richtext} | |
6006 | ||
6007 | @see wxRichTextCommand | |
6008 | */ | |
6009 | ||
6010 | class WXDLLIMPEXP_RICHTEXT wxRichTextAction: public wxObject | |
6011 | { | |
6012 | public: | |
6013 | /** | |
6014 | Constructor. @a buffer is the top-level buffer, while @a container is the object within | |
6015 | which the action is taking place. In the simplest case, they are the same. | |
6016 | */ | |
6017 | wxRichTextAction(wxRichTextCommand* cmd, const wxString& name, wxRichTextCommandId id, | |
6018 | wxRichTextBuffer* buffer, wxRichTextParagraphLayoutBox* container, | |
6019 | wxRichTextCtrl* ctrl, bool ignoreFirstTime = false); | |
6020 | ||
6021 | virtual ~wxRichTextAction(); | |
6022 | ||
6023 | /** | |
6024 | Performs the action. | |
6025 | */ | |
6026 | bool Do(); | |
6027 | ||
6028 | /** | |
6029 | Undoes the action. | |
6030 | */ | |
6031 | bool Undo(); | |
6032 | ||
6033 | /** | |
6034 | Updates the control appearance, optimizing if possible given information from the call to Layout. | |
6035 | */ | |
6036 | void UpdateAppearance(long caretPosition, bool sendUpdateEvent = false, | |
6037 | wxArrayInt* optimizationLineCharPositions = NULL, wxArrayInt* optimizationLineYPositions = NULL, bool isDoCmd = true); | |
6038 | ||
6039 | /** | |
6040 | Replaces the buffer paragraphs with the given fragment. | |
6041 | */ | |
6042 | void ApplyParagraphs(const wxRichTextParagraphLayoutBox& fragment); | |
6043 | ||
6044 | /** | |
6045 | Returns the new fragments. | |
6046 | */ | |
6047 | wxRichTextParagraphLayoutBox& GetNewParagraphs() { return m_newParagraphs; } | |
6048 | ||
6049 | /** | |
6050 | Returns the old fragments. | |
6051 | */ | |
6052 | wxRichTextParagraphLayoutBox& GetOldParagraphs() { return m_oldParagraphs; } | |
6053 | ||
6054 | /** | |
6055 | Returns the attributes, for single-object commands. | |
6056 | */ | |
6057 | wxRichTextAttr& GetAttributes() { return m_attributes; } | |
6058 | ||
6059 | /** | |
6060 | Returns the object to replace the one at the position defined by the container address | |
6061 | and the action's range start position. | |
6062 | */ | |
6063 | wxRichTextObject* GetObject() const { return m_object; } | |
6064 | ||
6065 | /** | |
6066 | Stores the object to replace the one at the position defined by the container address | |
6067 | without making an address for it (cf SetObject() and MakeObject()). | |
6068 | */ | |
6069 | void StoreObject(wxRichTextObject* obj) { m_object = obj; } | |
6070 | ||
6071 | /** | |
6072 | Sets the object to replace the one at the position defined by the container address | |
6073 | and the action's range start position. | |
6074 | */ | |
6075 | void SetObject(wxRichTextObject* obj) { m_object = obj; m_objectAddress.Create(m_buffer, m_object); } | |
6076 | ||
6077 | /** | |
6078 | Makes an address from the given object. | |
6079 | */ | |
6080 | void MakeObject(wxRichTextObject* obj) { m_objectAddress.Create(m_buffer, obj); } | |
6081 | ||
6082 | /** | |
6083 | Sets the existing and new objects, for use with wxRICHTEXT_CHANGE_OBJECT. | |
6084 | */ | |
6085 | void SetOldAndNewObjects(wxRichTextObject* oldObj, wxRichTextObject* newObj) { SetObject(oldObj); StoreObject(newObj); } | |
6086 | ||
6087 | /** | |
6088 | Calculate arrays for refresh optimization. | |
6089 | */ | |
6090 | void CalculateRefreshOptimizations(wxArrayInt& optimizationLineCharPositions, wxArrayInt& optimizationLineYPositions); | |
6091 | ||
6092 | /** | |
6093 | Sets the position used for e.g. insertion. | |
6094 | */ | |
6095 | void SetPosition(long pos) { m_position = pos; } | |
6096 | ||
6097 | /** | |
6098 | Returns the position used for e.g. insertion. | |
6099 | */ | |
6100 | long GetPosition() const { return m_position; } | |
6101 | ||
6102 | /** | |
6103 | Sets the range for e.g. deletion. | |
6104 | */ | |
6105 | void SetRange(const wxRichTextRange& range) { m_range = range; } | |
6106 | ||
6107 | /** | |
6108 | Returns the range for e.g. deletion. | |
6109 | */ | |
6110 | const wxRichTextRange& GetRange() const { return m_range; } | |
6111 | ||
6112 | /** | |
6113 | Returns the address (nested position) of the container within the buffer being manipulated. | |
6114 | */ | |
6115 | wxRichTextObjectAddress& GetContainerAddress() { return m_containerAddress; } | |
6116 | ||
6117 | /** | |
6118 | Returns the address (nested position) of the container within the buffer being manipulated. | |
6119 | */ | |
6120 | const wxRichTextObjectAddress& GetContainerAddress() const { return m_containerAddress; } | |
6121 | ||
6122 | /** | |
6123 | Sets the address (nested position) of the container within the buffer being manipulated. | |
6124 | */ | |
6125 | void SetContainerAddress(const wxRichTextObjectAddress& address) { m_containerAddress = address; } | |
6126 | ||
6127 | /** | |
6128 | Sets the address (nested position) of the container within the buffer being manipulated. | |
6129 | */ | |
6130 | void SetContainerAddress(wxRichTextParagraphLayoutBox* container, wxRichTextObject* obj) { m_containerAddress.Create(container, obj); } | |
6131 | ||
6132 | /** | |
6133 | Returns the container that this action refers to, using the container address and top-level buffer. | |
6134 | */ | |
6135 | wxRichTextParagraphLayoutBox* GetContainer() const; | |
6136 | ||
6137 | /** | |
6138 | Returns the action name. | |
6139 | */ | |
6140 | const wxString& GetName() const { return m_name; } | |
6141 | ||
6142 | /** | |
6143 | Instructs the first Do() command should be skipped as it's already been applied. | |
6144 | */ | |
6145 | void SetIgnoreFirstTime(bool b) { m_ignoreThis = b; } | |
6146 | ||
6147 | /** | |
6148 | Returns true if the first Do() command should be skipped as it's already been applied. | |
6149 | */ | |
6150 | bool GetIgnoreFirstTime() const { return m_ignoreThis; } | |
6151 | ||
6152 | protected: | |
6153 | // Action name | |
6154 | wxString m_name; | |
6155 | ||
6156 | // Buffer | |
6157 | wxRichTextBuffer* m_buffer; | |
6158 | ||
6159 | // The address (nested position) of the container being manipulated. | |
6160 | // This is necessary because objects are deleted, and we can't | |
6161 | // therefore store actual pointers. | |
6162 | wxRichTextObjectAddress m_containerAddress; | |
6163 | ||
6164 | // Control | |
6165 | wxRichTextCtrl* m_ctrl; | |
6166 | ||
6167 | // Stores the new paragraphs | |
6168 | wxRichTextParagraphLayoutBox m_newParagraphs; | |
6169 | ||
6170 | // Stores the old paragraphs | |
6171 | wxRichTextParagraphLayoutBox m_oldParagraphs; | |
6172 | ||
6173 | // Stores an object to replace the one at the position | |
6174 | // defined by the container address and the action's range start position. | |
6175 | wxRichTextObject* m_object; | |
6176 | ||
6177 | // Stores the attributes | |
6178 | wxRichTextAttr m_attributes; | |
6179 | ||
6180 | // The address of the object being manipulated (used for changing an individual object or its attributes) | |
6181 | wxRichTextObjectAddress m_objectAddress; | |
6182 | ||
6183 | // Stores the old attributes | |
6184 | // wxRichTextAttr m_oldAttributes; | |
6185 | ||
6186 | // The affected range | |
6187 | wxRichTextRange m_range; | |
6188 | ||
6189 | // The insertion point for this command | |
6190 | long m_position; | |
6191 | ||
6192 | // Ignore 1st 'Do' operation because we already did it | |
6193 | bool m_ignoreThis; | |
6194 | ||
6195 | // The command identifier | |
6196 | wxRichTextCommandId m_cmdId; | |
6197 | }; | |
6198 | ||
6199 | /*! | |
6200 | * Handler flags | |
6201 | */ | |
6202 | ||
6203 | // Include style sheet when loading and saving | |
6204 | #define wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET 0x0001 | |
6205 | ||
6206 | // Save images to memory file system in HTML handler | |
6207 | #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY 0x0010 | |
6208 | ||
6209 | // Save images to files in HTML handler | |
6210 | #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES 0x0020 | |
6211 | ||
6212 | // Save images as inline base64 data in HTML handler | |
6213 | #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040 | |
6214 | ||
6215 | // Don't write header and footer (or BODY), so we can include the fragment | |
6216 | // in a larger document | |
6217 | #define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080 | |
6218 | ||
6219 | // Convert the more common face names to names that will work on the current platform | |
6220 | // in a larger document | |
6221 | #define wxRICHTEXT_HANDLER_CONVERT_FACENAMES 0x0100 | |
6222 | ||
6223 | /** | |
6224 | @class wxRichTextFileHandler | |
6225 | ||
6226 | The base class for file handlers. | |
6227 | ||
6228 | @library{wxrichtext} | |
6229 | @category{richtext} | |
6230 | ||
6231 | @see wxRichTextBuffer, wxRichTextCtrl | |
6232 | */ | |
6233 | ||
6234 | class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler: public wxObject | |
6235 | { | |
6236 | DECLARE_CLASS(wxRichTextFileHandler) | |
6237 | public: | |
6238 | /** | |
6239 | Creates a file handler object. | |
6240 | */ | |
6241 | wxRichTextFileHandler(const wxString& name = wxEmptyString, const wxString& ext = wxEmptyString, int type = 0) | |
6242 | : m_name(name), m_extension(ext), m_type(type), m_flags(0), m_visible(true) | |
6243 | { } | |
6244 | ||
6245 | #if wxUSE_STREAMS | |
6246 | /** | |
6247 | Loads the buffer from a stream. | |
6248 | Not all handlers will implement file loading. | |
6249 | */ | |
6250 | bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) | |
6251 | { return DoLoadFile(buffer, stream); } | |
6252 | ||
6253 | /** | |
6254 | Saves the buffer to a stream. | |
6255 | Not all handlers will implement file saving. | |
6256 | */ | |
6257 | bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) | |
6258 | { return DoSaveFile(buffer, stream); } | |
6259 | #endif | |
6260 | ||
6261 | #if wxUSE_FFILE && wxUSE_STREAMS | |
6262 | /** | |
6263 | Loads the buffer from a file. | |
6264 | */ | |
6265 | virtual bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename); | |
6266 | ||
6267 | /** | |
6268 | Saves the buffer to a file. | |
6269 | */ | |
6270 | virtual bool SaveFile(wxRichTextBuffer *buffer, const wxString& filename); | |
6271 | #endif // wxUSE_STREAMS && wxUSE_STREAMS | |
6272 | ||
6273 | /** | |
6274 | Returns @true if we handle this filename (if using files). By default, checks the extension. | |
6275 | */ | |
6276 | virtual bool CanHandle(const wxString& filename) const; | |
6277 | ||
6278 | /** | |
6279 | Returns @true if we can save using this handler. | |
6280 | */ | |
6281 | virtual bool CanSave() const { return false; } | |
6282 | ||
6283 | /** | |
6284 | Returns @true if we can load using this handler. | |
6285 | */ | |
6286 | virtual bool CanLoad() const { return false; } | |
6287 | ||
6288 | /** | |
6289 | Returns @true if this handler should be visible to the user. | |
6290 | */ | |
6291 | virtual bool IsVisible() const { return m_visible; } | |
6292 | ||
6293 | /** | |
6294 | Sets whether the handler should be visible to the user (via the application's | |
6295 | load and save dialogs). | |
6296 | */ | |
6297 | virtual void SetVisible(bool visible) { m_visible = visible; } | |
6298 | ||
6299 | /** | |
6300 | Sets the name of the handler. | |
6301 | */ | |
6302 | void SetName(const wxString& name) { m_name = name; } | |
6303 | ||
6304 | /** | |
6305 | Returns the name of the handler. | |
6306 | */ | |
6307 | wxString GetName() const { return m_name; } | |
6308 | ||
6309 | /** | |
6310 | Sets the default extension to recognise. | |
6311 | */ | |
6312 | void SetExtension(const wxString& ext) { m_extension = ext; } | |
6313 | ||
6314 | /** | |
6315 | Returns the default extension to recognise. | |
6316 | */ | |
6317 | wxString GetExtension() const { return m_extension; } | |
6318 | ||
6319 | /** | |
6320 | Sets the handler type. | |
6321 | */ | |
6322 | void SetType(int type) { m_type = type; } | |
6323 | ||
6324 | /** | |
6325 | Returns the handler type. | |
6326 | */ | |
6327 | int GetType() const { return m_type; } | |
6328 | ||
6329 | /** | |
6330 | Sets flags that change the behaviour of loading or saving. | |
6331 | See the documentation for each handler class to see what flags are relevant | |
6332 | for each handler. | |
6333 | ||
6334 | You call this function directly if you are using a file handler explicitly | |
6335 | (without going through the text control or buffer LoadFile/SaveFile API). | |
6336 | Or, you can call the control or buffer's SetHandlerFlags function to set | |
6337 | the flags that will be used for subsequent load and save operations. | |
6338 | */ | |
6339 | void SetFlags(int flags) { m_flags = flags; } | |
6340 | ||
6341 | /** | |
6342 | Returns flags controlling how loading and saving is done. | |
6343 | */ | |
6344 | int GetFlags() const { return m_flags; } | |
6345 | ||
6346 | /** | |
6347 | Sets the encoding to use when saving a file. If empty, a suitable encoding is chosen. | |
6348 | */ | |
6349 | void SetEncoding(const wxString& encoding) { m_encoding = encoding; } | |
6350 | ||
6351 | /** | |
6352 | Returns the encoding to use when saving a file. If empty, a suitable encoding is chosen. | |
6353 | */ | |
6354 | const wxString& GetEncoding() const { return m_encoding; } | |
6355 | ||
6356 | protected: | |
6357 | ||
6358 | #if wxUSE_STREAMS | |
6359 | /** | |
6360 | Override to load content from @a stream into @a buffer. | |
6361 | */ | |
6362 | virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) = 0; | |
6363 | ||
6364 | /** | |
6365 | Override to save content to @a stream from @a buffer. | |
6366 | */ | |
6367 | virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) = 0; | |
6368 | #endif | |
6369 | ||
6370 | wxString m_name; | |
6371 | wxString m_encoding; | |
6372 | wxString m_extension; | |
6373 | int m_type; | |
6374 | int m_flags; | |
6375 | bool m_visible; | |
6376 | }; | |
6377 | ||
6378 | /** | |
6379 | @class wxRichTextPlainTextHandler | |
6380 | ||
6381 | Implements saving a buffer to plain text. | |
6382 | ||
6383 | @library{wxrichtext} | |
6384 | @category{richtext} | |
6385 | ||
6386 | @see wxRichTextFileHandler, wxRichTextBuffer, wxRichTextCtrl | |
6387 | */ | |
6388 | ||
6389 | class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler: public wxRichTextFileHandler | |
6390 | { | |
6391 | DECLARE_CLASS(wxRichTextPlainTextHandler) | |
6392 | public: | |
6393 | wxRichTextPlainTextHandler(const wxString& name = wxT("Text"), | |
6394 | const wxString& ext = wxT("txt"), | |
6395 | wxRichTextFileType type = wxRICHTEXT_TYPE_TEXT) | |
6396 | : wxRichTextFileHandler(name, ext, type) | |
6397 | { } | |
6398 | ||
6399 | // Can we save using this handler? | |
6400 | virtual bool CanSave() const { return true; } | |
6401 | ||
6402 | // Can we load using this handler? | |
6403 | virtual bool CanLoad() const { return true; } | |
6404 | ||
6405 | protected: | |
6406 | ||
6407 | #if wxUSE_STREAMS | |
6408 | virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); | |
6409 | virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); | |
6410 | #endif | |
6411 | ||
6412 | }; | |
6413 | ||
6414 | /** | |
6415 | @class wxRichTextDrawingHandler | |
6416 | ||
6417 | The base class for custom drawing handlers. | |
6418 | Currently, drawing handlers can provide virtual attributes. | |
6419 | ||
6420 | @library{wxrichtext} | |
6421 | @category{richtext} | |
6422 | ||
6423 | @see wxRichTextBuffer, wxRichTextCtrl | |
6424 | */ | |
6425 | ||
6426 | class WXDLLIMPEXP_RICHTEXT wxRichTextDrawingHandler: public wxObject | |
6427 | { | |
6428 | DECLARE_CLASS(wxRichTextDrawingHandler) | |
6429 | public: | |
6430 | /** | |
6431 | Creates a drawing handler object. | |
6432 | */ | |
6433 | wxRichTextDrawingHandler(const wxString& name = wxEmptyString) | |
6434 | : m_name(name) | |
6435 | { } | |
6436 | ||
6437 | /** | |
6438 | Returns @true if this object has virtual attributes that we can provide. | |
6439 | */ | |
6440 | virtual bool HasVirtualAttributes(wxRichTextObject* obj) const = 0; | |
6441 | ||
6442 | /** | |
6443 | Provides virtual attributes that we can provide. | |
6444 | */ | |
6445 | virtual bool GetVirtualAttributes(wxRichTextAttr& attr, wxRichTextObject* obj) const = 0; | |
6446 | ||
6447 | /** | |
6448 | Gets the count for mixed virtual attributes for individual positions within the object. | |
6449 | For example, individual characters within a text object may require special highlighting. | |
6450 | */ | |
6451 | virtual int GetVirtualSubobjectAttributesCount(wxRichTextObject* obj) const = 0; | |
6452 | ||
6453 | /** | |
6454 | Gets the mixed virtual attributes for individual positions within the object. | |
6455 | For example, individual characters within a text object may require special highlighting. | |
6456 | Returns the number of virtual attributes found. | |
6457 | */ | |
6458 | virtual int GetVirtualSubobjectAttributes(wxRichTextObject* obj, wxArrayInt& positions, wxRichTextAttrArray& attributes) const = 0; | |
6459 | ||
6460 | /** | |
6461 | Do we have virtual text for this object? Virtual text allows an application | |
6462 | to replace characters in an object for editing and display purposes, for example | |
6463 | for highlighting special characters. | |
6464 | */ | |
6465 | virtual bool HasVirtualText(const wxRichTextPlainText* obj) const = 0; | |
6466 | ||
6467 | /** | |
6468 | Gets the virtual text for this object. | |
6469 | */ | |
6470 | virtual bool GetVirtualText(const wxRichTextPlainText* obj, wxString& text) const = 0; | |
6471 | ||
6472 | /** | |
6473 | Sets the name of the handler. | |
6474 | */ | |
6475 | void SetName(const wxString& name) { m_name = name; } | |
6476 | ||
6477 | /** | |
6478 | Returns the name of the handler. | |
6479 | */ | |
6480 | wxString GetName() const { return m_name; } | |
6481 | ||
6482 | protected: | |
6483 | ||
6484 | wxString m_name; | |
6485 | }; | |
6486 | ||
6487 | #if wxUSE_DATAOBJ | |
6488 | ||
6489 | /** | |
6490 | @class wxRichTextBufferDataObject | |
6491 | ||
6492 | Implements a rich text data object for clipboard transfer. | |
6493 | ||
6494 | @library{wxrichtext} | |
6495 | @category{richtext} | |
6496 | ||
6497 | @see wxDataObjectSimple, wxRichTextBuffer, wxRichTextCtrl | |
6498 | */ | |
6499 | ||
6500 | class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject: public wxDataObjectSimple | |
6501 | { | |
6502 | public: | |
6503 | /** | |
6504 | The constructor doesn't copy the pointer, so it shouldn't go away while this object | |
6505 | is alive. | |
6506 | */ | |
6507 | wxRichTextBufferDataObject(wxRichTextBuffer* richTextBuffer = NULL); | |
6508 | virtual ~wxRichTextBufferDataObject(); | |
6509 | ||
6510 | /** | |
6511 | After a call to this function, the buffer is owned by the caller and it | |
6512 | is responsible for deleting it. | |
6513 | */ | |
6514 | wxRichTextBuffer* GetRichTextBuffer(); | |
6515 | ||
6516 | /** | |
6517 | Returns the id for the new data format. | |
6518 | */ | |
6519 | static const wxChar* GetRichTextBufferFormatId() { return ms_richTextBufferFormatId; } | |
6520 | ||
6521 | // base class pure virtuals | |
6522 | ||
6523 | virtual wxDataFormat GetPreferredFormat(Direction dir) const; | |
6524 | virtual size_t GetDataSize() const; | |
6525 | virtual bool GetDataHere(void *pBuf) const; | |
6526 | virtual bool SetData(size_t len, const void *buf); | |
6527 | ||
6528 | // prevent warnings | |
6529 | ||
6530 | virtual size_t GetDataSize(const wxDataFormat&) const { return GetDataSize(); } | |
6531 | virtual bool GetDataHere(const wxDataFormat&, void *buf) const { return GetDataHere(buf); } | |
6532 | virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) { return SetData(len, buf); } | |
6533 | ||
6534 | private: | |
6535 | wxDataFormat m_formatRichTextBuffer; // our custom format | |
6536 | wxRichTextBuffer* m_richTextBuffer; // our data | |
6537 | static const wxChar* ms_richTextBufferFormatId; // our format id | |
6538 | }; | |
6539 | ||
6540 | #endif | |
6541 | ||
6542 | /** | |
6543 | @class wxRichTextRenderer | |
6544 | ||
6545 | This class isolates some common drawing functionality. | |
6546 | ||
6547 | @library{wxrichtext} | |
6548 | @category{richtext} | |
6549 | ||
6550 | @see wxRichTextBuffer, wxRichTextCtrl | |
6551 | */ | |
6552 | ||
6553 | class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer: public wxObject | |
6554 | { | |
6555 | public: | |
6556 | /** | |
6557 | Constructor. | |
6558 | */ | |
6559 | wxRichTextRenderer() {} | |
6560 | virtual ~wxRichTextRenderer() {} | |
6561 | ||
6562 | /** | |
6563 | Draws a standard bullet, as specified by the value of GetBulletName. This function should be overridden. | |
6564 | */ | |
6565 | virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect) = 0; | |
6566 | ||
6567 | /** | |
6568 | Draws a bullet that can be described by text, such as numbered or symbol bullets. This function should be overridden. | |
6569 | */ | |
6570 | virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, const wxString& text) = 0; | |
6571 | ||
6572 | /** | |
6573 | Draws a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName. This function should be overridden. | |
6574 | */ | |
6575 | virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect) = 0; | |
6576 | ||
6577 | /** | |
6578 | Enumerate the standard bullet names currently supported. This function should be overridden. | |
6579 | */ | |
6580 | virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0; | |
6581 | }; | |
6582 | ||
6583 | /** | |
6584 | @class wxRichTextStdRenderer | |
6585 | ||
6586 | The standard renderer for drawing bullets. | |
6587 | ||
6588 | @library{wxrichtext} | |
6589 | @category{richtext} | |
6590 | ||
6591 | @see wxRichTextRenderer, wxRichTextBuffer, wxRichTextCtrl | |
6592 | */ | |
6593 | ||
6594 | class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer: public wxRichTextRenderer | |
6595 | { | |
6596 | public: | |
6597 | /** | |
6598 | Constructor. | |
6599 | */ | |
6600 | wxRichTextStdRenderer() {} | |
6601 | ||
6602 | // Draw a standard bullet, as specified by the value of GetBulletName | |
6603 | virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect); | |
6604 | ||
6605 | // Draw a bullet that can be described by text, such as numbered or symbol bullets | |
6606 | virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, const wxString& text); | |
6607 | ||
6608 | // Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName | |
6609 | virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect); | |
6610 | ||
6611 | // Enumerate the standard bullet names currently supported | |
6612 | virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames); | |
6613 | }; | |
6614 | ||
6615 | /*! | |
6616 | * Utilities | |
6617 | * | |
6618 | */ | |
6619 | ||
6620 | inline bool wxRichTextHasStyle(int flags, int style) | |
6621 | { | |
6622 | return ((flags & style) == style); | |
6623 | } | |
6624 | ||
6625 | /// Compare two attribute objects | |
6626 | WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2); | |
6627 | WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2); | |
6628 | ||
6629 | /// Apply one style to another | |
6630 | WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL); | |
6631 | ||
6632 | // Remove attributes | |
6633 | WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style); | |
6634 | ||
6635 | /// Combine two bitlists | |
6636 | WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB); | |
6637 | ||
6638 | /// Compare two bitlists | |
6639 | WXDLLIMPEXP_RICHTEXT bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags); | |
6640 | ||
6641 | /// Split into paragraph and character styles | |
6642 | WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxRichTextAttr& style, wxRichTextAttr& parStyle, wxRichTextAttr& charStyle); | |
6643 | ||
6644 | /// Compare tabs | |
6645 | WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2); | |
6646 | ||
6647 | /// Convert a decimal to Roman numerals | |
6648 | WXDLLIMPEXP_RICHTEXT wxString wxRichTextDecimalToRoman(long n); | |
6649 | ||
6650 | // Collects the attributes that are common to a range of content, building up a note of | |
6651 | // which attributes are absent in some objects and which clash in some objects. | |
6652 | WXDLLIMPEXP_RICHTEXT void wxTextAttrCollectCommonAttributes(wxTextAttr& currentStyle, const wxTextAttr& attr, wxTextAttr& clashingAttr, wxTextAttr& absentAttr); | |
6653 | ||
6654 | WXDLLIMPEXP_RICHTEXT void wxRichTextModuleInit(); | |
6655 | ||
6656 | #endif | |
6657 | // wxUSE_RICHTEXT | |
6658 | ||
6659 | #endif | |
6660 | // _WX_RICHTEXTBUFFER_H_ | |
6661 |