1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richtextbuffer.h
3 // Purpose: Buffer for wxRichTextCtrl
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RICHTEXTBUFFER_H_
13 #define _WX_RICHTEXTBUFFER_H_
20 Data is represented by a hierarchy of objects, all derived from
23 The top of the hierarchy is the buffer, a kind of wxRichTextParagraphLayoutBox.
24 These boxes will allow flexible placement of text boxes on a page, but
25 for now there is a single box representing the document, and this box is
26 a wxRichTextParagraphLayoutBox which contains further wxRichTextParagraph
27 objects, each of which can include text and images.
29 Each object maintains a range (start and end position) measured
30 from the start of the main parent box.
31 A paragraph object knows its range, and a text fragment knows its range
32 too. So, a character or image in a page has a position relative to the
33 start of the document, and a character in an embedded text box has
34 a position relative to that text box. For now, we will not be dealing with
35 embedded objects but it's something to bear in mind for later.
37 Note that internally, a range (5,5) represents a range of one character.
38 In the public wx[Rich]TextCtrl API, this would be passed to e.g. SetSelection
39 as (5,6). A paragraph with one character might have an internal range of (0, 1)
40 since the end of the paragraph takes up one position.
45 When Layout is called on an object, it is given a size which the object
46 must limit itself to, or one or more flexible directions (vertical
47 or horizontal). So for example a centered paragraph is given the page
48 width to play with (minus any margins), but can extend indefinitely
49 in the vertical direction. The implementation of Layout can then
50 cache the calculated size and position within the parent.
63 #include "wx/textctrl.h"
64 #include "wx/bitmap.h"
66 #include "wx/cmdproc.h"
67 #include "wx/txtstrm.h"
68 #include "wx/variant.h"
69 #include "wx/position.h"
72 #include "wx/dataobj.h"
76 //#define wxRichTextAttr wxTextAttr
77 #define wxTextAttrEx wxTextAttr
79 // Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a
80 // caret reliably without using wxClientDC in case there
81 // are platform-specific problems with the generic caret.
82 #if defined(__WXGTK__) || defined(__WXMAC__)
83 #define wxRICHTEXT_USE_OWN_CARET 1
85 #define wxRICHTEXT_USE_OWN_CARET 0
88 // Switch off for binary compatibility, on for faster drawing
89 // Note: this seems to be buggy (overzealous use of extents) so
91 #define wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING 0
93 // The following two symbols determine whether an output implementation
94 // is present. To switch the relevant one on, set wxRICHTEXT_USE_XMLDOCUMENT_OUTPUT in
95 // richtextxml.cpp. By default, the faster direct output implementation is used.
97 // Include the wxXmlDocument implementation for output
98 #define wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT 1
100 // Include the faster, direct implementation for output
101 #define wxRICHTEXT_HAVE_DIRECT_OUTPUT 1
104 The line break character that can be embedded in content.
107 extern WXDLLIMPEXP_RICHTEXT
const wxChar wxRichTextLineBreakChar
;
110 File types in wxRichText context.
112 enum wxRichTextFileType
114 wxRICHTEXT_TYPE_ANY
= 0,
115 wxRICHTEXT_TYPE_TEXT
,
117 wxRICHTEXT_TYPE_HTML
,
123 * Forward declarations
126 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCtrl
;
127 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObject
;
128 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextImage
;
129 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextPlainText
;
130 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCacheObject
;
131 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObjectList
;
132 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextLine
;
133 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraph
;
134 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFileHandler
;
135 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextDrawingHandler
;
136 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextField
;
137 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFieldType
;
138 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleSheet
;
139 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextListStyleDefinition
;
140 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextEvent
;
141 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextRenderer
;
142 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextBuffer
;
143 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextXMLHandler
;
144 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraphLayoutBox
;
145 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextImageBlock
;
146 class WXDLLIMPEXP_FWD_XML wxXmlNode
;
147 class wxRichTextFloatCollector
;
148 class WXDLLIMPEXP_FWD_BASE wxDataInputStream
;
149 class WXDLLIMPEXP_FWD_BASE wxDataOutputStream
;
152 Flags determining the available space, passed to Layout.
155 #define wxRICHTEXT_FIXED_WIDTH 0x01
156 #define wxRICHTEXT_FIXED_HEIGHT 0x02
157 #define wxRICHTEXT_VARIABLE_WIDTH 0x04
158 #define wxRICHTEXT_VARIABLE_HEIGHT 0x08
160 // Only lay out the part of the buffer that lies within
161 // the rect passed to Layout.
162 #define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10
165 Flags to pass to Draw
168 // Ignore paragraph cache optimization, e.g. for printing purposes
169 // where one line may be drawn higher (on the next page) compared
170 // with the previous line
171 #define wxRICHTEXT_DRAW_IGNORE_CACHE 0x01
172 #define wxRICHTEXT_DRAW_SELECTED 0x02
173 #define wxRICHTEXT_DRAW_PRINT 0x04
174 #define wxRICHTEXT_DRAW_GUIDELINES 0x08
177 Flags returned from hit-testing, or passed to hit-test function.
179 enum wxRichTextHitTestFlags
181 // The point was not on this object
182 wxRICHTEXT_HITTEST_NONE
= 0x01,
184 // The point was before the position returned from HitTest
185 wxRICHTEXT_HITTEST_BEFORE
= 0x02,
187 // The point was after the position returned from HitTest
188 wxRICHTEXT_HITTEST_AFTER
= 0x04,
190 // The point was on the position returned from HitTest
191 wxRICHTEXT_HITTEST_ON
= 0x08,
193 // The point was on space outside content
194 wxRICHTEXT_HITTEST_OUTSIDE
= 0x10,
196 // Only do hit-testing at the current level (don't traverse into top-level objects)
197 wxRICHTEXT_HITTEST_NO_NESTED_OBJECTS
= 0x20,
199 // Ignore floating objects
200 wxRICHTEXT_HITTEST_NO_FLOATING_OBJECTS
= 0x40,
202 // Don't recurse into objects marked as atomic
203 wxRICHTEXT_HITTEST_HONOUR_ATOMIC
= 0x80
207 Flags for GetRangeSize.
210 #define wxRICHTEXT_FORMATTED 0x01
211 #define wxRICHTEXT_UNFORMATTED 0x02
212 #define wxRICHTEXT_CACHE_SIZE 0x04
213 #define wxRICHTEXT_HEIGHT_ONLY 0x08
216 Flags for SetStyle/SetListStyle.
219 #define wxRICHTEXT_SETSTYLE_NONE 0x00
221 // Specifies that this operation should be undoable
222 #define wxRICHTEXT_SETSTYLE_WITH_UNDO 0x01
224 // Specifies that the style should not be applied if the
225 // combined style at this point is already the style in question.
226 #define wxRICHTEXT_SETSTYLE_OPTIMIZE 0x02
228 // Specifies that the style should only be applied to paragraphs,
229 // and not the content. This allows content styling to be
230 // preserved independently from that of e.g. a named paragraph style.
231 #define wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY 0x04
233 // Specifies that the style should only be applied to characters,
234 // and not the paragraph. This allows content styling to be
235 // preserved independently from that of e.g. a named paragraph style.
236 #define wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY 0x08
238 // For SetListStyle only: specifies starting from the given number, otherwise
239 // deduces number from existing attributes
240 #define wxRICHTEXT_SETSTYLE_RENUMBER 0x10
242 // For SetListStyle only: specifies the list level for all paragraphs, otherwise
243 // the current indentation will be used
244 #define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL 0x20
246 // Resets the existing style before applying the new style
247 #define wxRICHTEXT_SETSTYLE_RESET 0x40
249 // Removes the given style instead of applying it
250 #define wxRICHTEXT_SETSTYLE_REMOVE 0x80
253 Flags for SetProperties.
256 #define wxRICHTEXT_SETPROPERTIES_NONE 0x00
258 // Specifies that this operation should be undoable
259 #define wxRICHTEXT_SETPROPERTIES_WITH_UNDO 0x01
261 // Specifies that the properties should only be applied to paragraphs,
262 // and not the content.
263 #define wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY 0x02
265 // Specifies that the properties should only be applied to characters,
266 // and not the paragraph.
267 #define wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY 0x04
269 // Resets the existing properties before applying the new properties.
270 #define wxRICHTEXT_SETPROPERTIES_RESET 0x08
272 // Removes the given properties instead of applying them.
273 #define wxRICHTEXT_SETPROPERTIES_REMOVE 0x10
276 Flags for object insertion.
279 #define wxRICHTEXT_INSERT_NONE 0x00
280 #define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE 0x01
281 #define wxRICHTEXT_INSERT_INTERACTIVE 0x02
283 // A special flag telling the buffer to keep the first paragraph style
284 // as-is, when deleting a paragraph marker. In future we might pass a
285 // flag to InsertFragment and DeleteRange to indicate the appropriate mode.
286 #define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x20000000
289 Default superscript/subscript font multiplication factor.
292 #define wxSCRIPT_MUL_FACTOR 1.5
295 The type for wxTextAttrDimension flags.
297 typedef unsigned short wxTextAttrDimensionFlags
;
300 Miscellaneous text box flags
302 enum wxTextBoxAttrFlags
304 wxTEXT_BOX_ATTR_FLOAT
= 0x00000001,
305 wxTEXT_BOX_ATTR_CLEAR
= 0x00000002,
306 wxTEXT_BOX_ATTR_COLLAPSE_BORDERS
= 0x00000004,
307 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
= 0x00000008,
308 wxTEXT_BOX_ATTR_BOX_STYLE_NAME
= 0x00000010
312 Whether a value is present, used in dimension flags.
314 enum wxTextAttrValueFlags
316 wxTEXT_ATTR_VALUE_VALID
= 0x1000,
317 wxTEXT_ATTR_VALUE_VALID_MASK
= 0x1000
321 Units, included in the dimension value.
325 wxTEXT_ATTR_UNITS_TENTHS_MM
= 0x0001,
326 wxTEXT_ATTR_UNITS_PIXELS
= 0x0002,
327 wxTEXT_ATTR_UNITS_PERCENTAGE
= 0x0004,
328 wxTEXT_ATTR_UNITS_POINTS
= 0x0008,
330 wxTEXT_ATTR_UNITS_MASK
= 0x000F
334 Position alternatives, included in the dimension flags.
336 enum wxTextBoxAttrPosition
338 wxTEXT_BOX_ATTR_POSITION_STATIC
= 0x0000, // Default is static, i.e. as per normal layout
339 wxTEXT_BOX_ATTR_POSITION_RELATIVE
= 0x0010, // Relative to the relevant edge
340 wxTEXT_BOX_ATTR_POSITION_ABSOLUTE
= 0x0020, // Relative to the parent
341 wxTEXT_BOX_ATTR_POSITION_FIXED
= 0x0040, // Relative to the top-level window
343 wxTEXT_BOX_ATTR_POSITION_MASK
= 0x00F0
347 @class wxTextAttrDimension
349 A class representing a rich text dimension, including units and position.
354 @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimensions
357 class WXDLLIMPEXP_RICHTEXT wxTextAttrDimension
363 wxTextAttrDimension() { Reset(); }
365 Constructor taking value and units flag.
367 wxTextAttrDimension(int value
, wxTextAttrUnits units
= wxTEXT_ATTR_UNITS_TENTHS_MM
) { m_value
= value
; m_flags
= units
|wxTEXT_ATTR_VALUE_VALID
; }
370 Resets the dimension value and flags.
372 void Reset() { m_value
= 0; m_flags
= 0; }
375 Partial equality test. If @a weakTest is @true, attributes of this object do not
376 have to be present if those attributes of @a dim are present. If @a weakTest is
377 @false, the function will fail if an attribute is present in @a dim but not
380 bool EqPartial(const wxTextAttrDimension
& dim
, bool weakTest
= true) const;
382 /** Apply the dimension, but not those identical to @a compareWith if present.
384 bool Apply(const wxTextAttrDimension
& dim
, const wxTextAttrDimension
* compareWith
= NULL
);
386 /** Collects the attributes that are common to a range of content, building up a note of
387 which attributes are absent in some objects and which clash in some objects.
389 void CollectCommonAttributes(const wxTextAttrDimension
& attr
, wxTextAttrDimension
& clashingAttr
, wxTextAttrDimension
& absentAttr
);
394 bool operator==(const wxTextAttrDimension
& dim
) const { return m_value
== dim
.m_value
&& m_flags
== dim
.m_flags
; }
397 Returns the integer value of the dimension.
399 int GetValue() const { return m_value
; }
402 Returns the floating-pointing value of the dimension in mm.
405 float GetValueMM() const { return float(m_value
) / 10.0; }
408 Sets the value of the dimension in mm.
410 void SetValueMM(float value
) { m_value
= (int) ((value
* 10.0) + 0.5); m_flags
|= wxTEXT_ATTR_VALUE_VALID
; }
413 Sets the integer value of the dimension.
415 void SetValue(int value
) { m_value
= value
; m_flags
|= wxTEXT_ATTR_VALUE_VALID
; }
418 Sets the integer value of the dimension, passing dimension flags.
420 void SetValue(int value
, wxTextAttrDimensionFlags flags
) { SetValue(value
); m_flags
= flags
; }
423 Sets the integer value and units.
425 void SetValue(int value
, wxTextAttrUnits units
) { m_value
= value
; m_flags
= units
| wxTEXT_ATTR_VALUE_VALID
; }
430 void SetValue(const wxTextAttrDimension
& dim
) { (*this) = dim
; }
433 Gets the units of the dimension.
435 wxTextAttrUnits
GetUnits() const { return (wxTextAttrUnits
) (m_flags
& wxTEXT_ATTR_UNITS_MASK
); }
438 Sets the units of the dimension.
440 void SetUnits(wxTextAttrUnits units
) { m_flags
&= ~wxTEXT_ATTR_UNITS_MASK
; m_flags
|= units
; }
443 Gets the position flags.
445 wxTextBoxAttrPosition
GetPosition() const { return (wxTextBoxAttrPosition
) (m_flags
& wxTEXT_BOX_ATTR_POSITION_MASK
); }
448 Sets the position flags.
450 void SetPosition(wxTextBoxAttrPosition pos
) { m_flags
&= ~wxTEXT_BOX_ATTR_POSITION_MASK
; m_flags
|= pos
; }
453 Returns @true if the dimension is valid.
455 bool IsValid() const { return (m_flags
& wxTEXT_ATTR_VALUE_VALID
) != 0; }
460 void SetValid(bool b
) { m_flags
&= ~wxTEXT_ATTR_VALUE_VALID_MASK
; m_flags
|= (b
? wxTEXT_ATTR_VALUE_VALID
: 0); }
463 Gets the dimension flags.
465 wxTextAttrDimensionFlags
GetFlags() const { return m_flags
; }
468 Sets the dimension flags.
470 void SetFlags(wxTextAttrDimensionFlags flags
) { m_flags
= flags
; }
473 wxTextAttrDimensionFlags m_flags
;
477 @class wxTextAttrDimensions
478 A class for left, right, top and bottom dimensions.
483 @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension
486 class WXDLLIMPEXP_RICHTEXT wxTextAttrDimensions
492 wxTextAttrDimensions() {}
495 Resets the value and flags for all dimensions.
497 void Reset() { m_left
.Reset(); m_top
.Reset(); m_right
.Reset(); m_bottom
.Reset(); }
502 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
; }
505 Partial equality test. If @a weakTest is @true, attributes of this object do not
506 have to be present if those attributes of @a dim sare present. If @a weakTest is
507 @false, the function will fail if an attribute is present in @a dims but not
511 bool EqPartial(const wxTextAttrDimensions
& dims
, bool weakTest
= true) const;
514 Apply to 'this', but not if the same as @a compareWith.
517 bool Apply(const wxTextAttrDimensions
& dims
, const wxTextAttrDimensions
* compareWith
= NULL
);
520 Collects the attributes that are common to a range of content, building up a note of
521 which attributes are absent in some objects and which clash in some objects.
524 void CollectCommonAttributes(const wxTextAttrDimensions
& attr
, wxTextAttrDimensions
& clashingAttr
, wxTextAttrDimensions
& absentAttr
);
527 Remove specified attributes from this object.
529 bool RemoveStyle(const wxTextAttrDimensions
& attr
);
532 Gets the left dimension.
534 const wxTextAttrDimension
& GetLeft() const { return m_left
; }
535 wxTextAttrDimension
& GetLeft() { return m_left
; }
538 Gets the right dimension.
541 const wxTextAttrDimension
& GetRight() const { return m_right
; }
542 wxTextAttrDimension
& GetRight() { return m_right
; }
545 Gets the top dimension.
548 const wxTextAttrDimension
& GetTop() const { return m_top
; }
549 wxTextAttrDimension
& GetTop() { return m_top
; }
552 Gets the bottom dimension.
555 const wxTextAttrDimension
& GetBottom() const { return m_bottom
; }
556 wxTextAttrDimension
& GetBottom() { return m_bottom
; }
559 Are all dimensions valid?
562 bool IsValid() const { return m_left
.IsValid() && m_top
.IsValid() && m_right
.IsValid() && m_bottom
.IsValid(); }
564 wxTextAttrDimension m_left
;
565 wxTextAttrDimension m_top
;
566 wxTextAttrDimension m_right
;
567 wxTextAttrDimension m_bottom
;
571 @class wxTextAttrSize
572 A class for representing width and height.
577 @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension
580 class WXDLLIMPEXP_RICHTEXT wxTextAttrSize
589 Resets the width and height dimensions.
591 void Reset() { m_width
.Reset(); m_height
.Reset(); }
596 bool operator==(const wxTextAttrSize
& size
) const { return m_width
== size
.m_width
&& m_height
== size
.m_height
; }
599 Partial equality test. If @a weakTest is @true, attributes of this object do not
600 have to be present if those attributes of @a size are present. If @a weakTest is
601 @false, the function will fail if an attribute is present in @a size but not
604 bool EqPartial(const wxTextAttrSize
& size
, bool weakTest
= true) const;
607 Apply to this object, but not if the same as @a compareWith.
609 bool Apply(const wxTextAttrSize
& dims
, const wxTextAttrSize
* compareWith
= NULL
);
612 Collects the attributes that are common to a range of content, building up a note of
613 which attributes are absent in some objects and which clash in some objects.
615 void CollectCommonAttributes(const wxTextAttrSize
& attr
, wxTextAttrSize
& clashingAttr
, wxTextAttrSize
& absentAttr
);
618 Removes the specified attributes from this object.
620 bool RemoveStyle(const wxTextAttrSize
& attr
);
625 wxTextAttrDimension
& GetWidth() { return m_width
; }
626 const wxTextAttrDimension
& GetWidth() const { return m_width
; }
631 void SetWidth(int value
, wxTextAttrDimensionFlags flags
) { m_width
.SetValue(value
, flags
); }
636 void SetWidth(int value
, wxTextAttrUnits units
) { m_width
.SetValue(value
, units
); }
641 void SetWidth(const wxTextAttrDimension
& dim
) { m_width
.SetValue(dim
); }
646 wxTextAttrDimension
& GetHeight() { return m_height
; }
647 const wxTextAttrDimension
& GetHeight() const { return m_height
; }
652 void SetHeight(int value
, wxTextAttrDimensionFlags flags
) { m_height
.SetValue(value
, flags
); }
657 void SetHeight(int value
, wxTextAttrUnits units
) { m_height
.SetValue(value
, units
); }
662 void SetHeight(const wxTextAttrDimension
& dim
) { m_height
.SetValue(dim
); }
667 bool IsValid() const { return m_width
.IsValid() && m_height
.IsValid(); }
669 wxTextAttrDimension m_width
;
670 wxTextAttrDimension m_height
;
674 @class wxTextAttrDimensionConverter
675 A class to make it easier to convert dimensions.
680 @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension
683 class WXDLLIMPEXP_RICHTEXT wxTextAttrDimensionConverter
689 wxTextAttrDimensionConverter(wxDC
& dc
, double scale
= 1.0, const wxSize
& parentSize
= wxDefaultSize
);
693 wxTextAttrDimensionConverter(int ppi
, double scale
= 1.0, const wxSize
& parentSize
= wxDefaultSize
);
696 Gets the pixel size for the given dimension.
698 int GetPixels(const wxTextAttrDimension
& dim
, int direction
= wxHORIZONTAL
) const;
700 Gets the mm size for the given dimension.
702 int GetTenthsMM(const wxTextAttrDimension
& dim
) const;
705 Converts tenths of a mm to pixels.
707 int ConvertTenthsMMToPixels(int units
) const;
709 Converts pixels to tenths of a mm.
711 int ConvertPixelsToTenthsMM(int pixels
) const;
719 Border styles, used with wxTextAttrBorder.
721 enum wxTextAttrBorderStyle
723 wxTEXT_BOX_ATTR_BORDER_NONE
= 0,
724 wxTEXT_BOX_ATTR_BORDER_SOLID
= 1,
725 wxTEXT_BOX_ATTR_BORDER_DOTTED
= 2,
726 wxTEXT_BOX_ATTR_BORDER_DASHED
= 3,
727 wxTEXT_BOX_ATTR_BORDER_DOUBLE
= 4,
728 wxTEXT_BOX_ATTR_BORDER_GROOVE
= 5,
729 wxTEXT_BOX_ATTR_BORDER_RIDGE
= 6,
730 wxTEXT_BOX_ATTR_BORDER_INSET
= 7,
731 wxTEXT_BOX_ATTR_BORDER_OUTSET
= 8
735 Border style presence flags, used with wxTextAttrBorder.
737 enum wxTextAttrBorderFlags
739 wxTEXT_BOX_ATTR_BORDER_STYLE
= 0x0001,
740 wxTEXT_BOX_ATTR_BORDER_COLOUR
= 0x0002
744 Border width symbols for qualitative widths, used with wxTextAttrBorder.
746 enum wxTextAttrBorderWidth
748 wxTEXT_BOX_ATTR_BORDER_THIN
= -1,
749 wxTEXT_BOX_ATTR_BORDER_MEDIUM
= -2,
750 wxTEXT_BOX_ATTR_BORDER_THICK
= -3
756 enum wxTextBoxAttrFloatStyle
758 wxTEXT_BOX_ATTR_FLOAT_NONE
= 0,
759 wxTEXT_BOX_ATTR_FLOAT_LEFT
= 1,
760 wxTEXT_BOX_ATTR_FLOAT_RIGHT
= 2
766 enum wxTextBoxAttrClearStyle
768 wxTEXT_BOX_ATTR_CLEAR_NONE
= 0,
769 wxTEXT_BOX_ATTR_CLEAR_LEFT
= 1,
770 wxTEXT_BOX_ATTR_CLEAR_RIGHT
= 2,
771 wxTEXT_BOX_ATTR_CLEAR_BOTH
= 3
775 Collapse mode styles. TODO: can they be switched on per side?
777 enum wxTextBoxAttrCollapseMode
779 wxTEXT_BOX_ATTR_COLLAPSE_NONE
= 0,
780 wxTEXT_BOX_ATTR_COLLAPSE_FULL
= 1
784 Vertical alignment values.
786 enum wxTextBoxAttrVerticalAlignment
788 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE
= 0,
789 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP
= 1,
790 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE
= 2,
791 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM
= 3
795 @class wxTextAttrBorder
796 A class representing a rich text object border.
801 @see wxRichTextAttr, wxRichTextCtrl, wxRichTextAttrBorders
804 class WXDLLIMPEXP_RICHTEXT wxTextAttrBorder
810 wxTextAttrBorder() { Reset(); }
815 bool operator==(const wxTextAttrBorder
& border
) const
817 return m_flags
== border
.m_flags
&& m_borderStyle
== border
.m_borderStyle
&&
818 m_borderColour
== border
.m_borderColour
&& m_borderWidth
== border
.m_borderWidth
;
822 Resets the border style, colour, width and flags.
824 void Reset() { m_borderStyle
= 0; m_borderColour
= 0; m_flags
= 0; m_borderWidth
.Reset(); }
827 Partial equality test. If @a weakTest is @true, attributes of this object do not
828 have to be present if those attributes of @a border are present. If @a weakTest is
829 @false, the function will fail if an attribute is present in @a border but not
832 bool EqPartial(const wxTextAttrBorder
& border
, bool weakTest
= true) const;
835 Applies the border to this object, but not if the same as @a compareWith.
838 bool Apply(const wxTextAttrBorder
& border
, const wxTextAttrBorder
* compareWith
= NULL
);
841 Removes the specified attributes from this object.
843 bool RemoveStyle(const wxTextAttrBorder
& attr
);
846 Collects the attributes that are common to a range of content, building up a note of
847 which attributes are absent in some objects and which clash in some objects.
849 void CollectCommonAttributes(const wxTextAttrBorder
& attr
, wxTextAttrBorder
& clashingAttr
, wxTextAttrBorder
& absentAttr
);
852 Sets the border style.
854 void SetStyle(int style
) { m_borderStyle
= style
; m_flags
|= wxTEXT_BOX_ATTR_BORDER_STYLE
; }
857 Gets the border style.
860 int GetStyle() const { return m_borderStyle
; }
863 Sets the border colour.
865 void SetColour(unsigned long colour
) { m_borderColour
= colour
; m_flags
|= wxTEXT_BOX_ATTR_BORDER_COLOUR
; }
868 Sets the border colour.
870 void SetColour(const wxColour
& colour
) { m_borderColour
= colour
.GetRGB(); m_flags
|= wxTEXT_BOX_ATTR_BORDER_COLOUR
; }
873 Gets the colour as a long.
875 unsigned long GetColourLong() const { return m_borderColour
; }
880 wxColour
GetColour() const { return wxColour(m_borderColour
); }
883 Gets the border width.
885 wxTextAttrDimension
& GetWidth() { return m_borderWidth
; }
886 const wxTextAttrDimension
& GetWidth() const { return m_borderWidth
; }
889 Sets the border width.
891 void SetWidth(const wxTextAttrDimension
& width
) { m_borderWidth
= width
; }
893 Sets the border width.
895 void SetWidth(int value
, wxTextAttrUnits units
= wxTEXT_ATTR_UNITS_TENTHS_MM
) { SetWidth(wxTextAttrDimension(value
, units
)); }
898 True if the border has a valid style.
900 bool HasStyle() const { return (m_flags
& wxTEXT_BOX_ATTR_BORDER_STYLE
) != 0; }
903 True if the border has a valid colour.
905 bool HasColour() const { return (m_flags
& wxTEXT_BOX_ATTR_BORDER_COLOUR
) != 0; }
908 True if the border has a valid width.
910 bool HasWidth() const { return m_borderWidth
.IsValid(); }
913 True if the border is valid.
915 bool IsValid() const { return HasWidth(); }
918 Set the valid flag for this border.
920 void MakeValid() { m_borderWidth
.SetValid(true); }
923 Returns the border flags.
925 int GetFlags() const { return m_flags
; }
928 Sets the border flags.
930 void SetFlags(int flags
) { m_flags
= flags
; }
935 void AddFlag(int flag
) { m_flags
|= flag
; }
938 Removes a border flag.
940 void RemoveFlag(int flag
) { m_flags
&= ~flag
; }
943 unsigned long m_borderColour
;
944 wxTextAttrDimension m_borderWidth
;
949 @class wxTextAttrBorders
950 A class representing a rich text object's borders.
955 @see wxRichTextAttr, wxRichTextCtrl, wxRichTextAttrBorder
958 class WXDLLIMPEXP_RICHTEXT wxTextAttrBorders
964 wxTextAttrBorders() { }
969 bool operator==(const wxTextAttrBorders
& borders
) const
971 return m_left
== borders
.m_left
&& m_right
== borders
.m_right
&&
972 m_top
== borders
.m_top
&& m_bottom
== borders
.m_bottom
;
976 Sets the style of all borders.
978 void SetStyle(int style
);
981 Sets colour of all borders.
983 void SetColour(unsigned long colour
);
986 Sets the colour for all borders.
988 void SetColour(const wxColour
& colour
);
991 Sets the width of all borders.
993 void SetWidth(const wxTextAttrDimension
& width
);
996 Sets the width of all borders.
998 void SetWidth(int value
, wxTextAttrUnits units
= wxTEXT_ATTR_UNITS_TENTHS_MM
) { SetWidth(wxTextAttrDimension(value
, units
)); }
1003 void Reset() { m_left
.Reset(); m_right
.Reset(); m_top
.Reset(); m_bottom
.Reset(); }
1006 Partial equality test. If @a weakTest is @true, attributes of this object do not
1007 have to be present if those attributes of @a borders are present. If @a weakTest is
1008 @false, the function will fail if an attribute is present in @a borders but not
1011 bool EqPartial(const wxTextAttrBorders
& borders
, bool weakTest
= true) const;
1014 Applies border to this object, but not if the same as @a compareWith.
1016 bool Apply(const wxTextAttrBorders
& borders
, const wxTextAttrBorders
* compareWith
= NULL
);
1019 Removes the specified attributes from this object.
1021 bool RemoveStyle(const wxTextAttrBorders
& attr
);
1024 Collects the attributes that are common to a range of content, building up a note of
1025 which attributes are absent in some objects and which clash in some objects.
1027 void CollectCommonAttributes(const wxTextAttrBorders
& attr
, wxTextAttrBorders
& clashingAttr
, wxTextAttrBorders
& absentAttr
);
1030 Returns @true if all borders are valid.
1032 bool IsValid() const { return m_left
.IsValid() || m_right
.IsValid() || m_top
.IsValid() || m_bottom
.IsValid(); }
1035 Returns the left border.
1037 const wxTextAttrBorder
& GetLeft() const { return m_left
; }
1038 wxTextAttrBorder
& GetLeft() { return m_left
; }
1041 Returns the right border.
1043 const wxTextAttrBorder
& GetRight() const { return m_right
; }
1044 wxTextAttrBorder
& GetRight() { return m_right
; }
1047 Returns the top border.
1049 const wxTextAttrBorder
& GetTop() const { return m_top
; }
1050 wxTextAttrBorder
& GetTop() { return m_top
; }
1053 Returns the bottom border.
1055 const wxTextAttrBorder
& GetBottom() const { return m_bottom
; }
1056 wxTextAttrBorder
& GetBottom() { return m_bottom
; }
1058 wxTextAttrBorder m_left
, m_right
, m_top
, m_bottom
;
1063 @class wxTextBoxAttr
1064 A class representing the box attributes of a rich text object.
1066 @library{wxrichtext}
1069 @see wxRichTextAttr, wxRichTextCtrl
1072 class WXDLLIMPEXP_RICHTEXT wxTextBoxAttr
1076 Default constructor.
1078 wxTextBoxAttr() { Init(); }
1083 wxTextBoxAttr(const wxTextBoxAttr
& attr
) { Init(); (*this) = attr
; }
1086 Initialises this object.
1088 void Init() { Reset(); }
1095 // Copy. Unnecessary since we let it do a binary copy
1096 //void Copy(const wxTextBoxAttr& attr);
1099 //void operator= (const wxTextBoxAttr& attr);
1104 bool operator== (const wxTextBoxAttr
& attr
) const;
1107 Partial equality test, ignoring unset attributes. If @a weakTest is @true, attributes of this object do not
1108 have to be present if those attributes of @a attr are present. If @a weakTest is
1109 @false, the function will fail if an attribute is present in @a attr but not
1113 bool EqPartial(const wxTextBoxAttr
& attr
, bool weakTest
= true) const;
1116 Merges the given attributes. If @a compareWith is non-NULL, then it will be used
1117 to mask out those attributes that are the same in style and @a compareWith, for
1118 situations where we don't want to explicitly set inherited attributes.
1120 bool Apply(const wxTextBoxAttr
& style
, const wxTextBoxAttr
* compareWith
= NULL
);
1123 Collects the attributes that are common to a range of content, building up a note of
1124 which attributes are absent in some objects and which clash in some objects.
1126 void CollectCommonAttributes(const wxTextBoxAttr
& attr
, wxTextBoxAttr
& clashingAttr
, wxTextBoxAttr
& absentAttr
);
1129 Removes the specified attributes from this object.
1131 bool RemoveStyle(const wxTextBoxAttr
& attr
);
1136 void SetFlags(int flags
) { m_flags
= flags
; }
1141 int GetFlags() const { return m_flags
; }
1144 Is this flag present?
1146 bool HasFlag(wxTextBoxAttrFlags flag
) const { return (m_flags
& flag
) != 0; }
1151 void RemoveFlag(wxTextBoxAttrFlags flag
) { m_flags
&= ~flag
; }
1156 void AddFlag(wxTextBoxAttrFlags flag
) { m_flags
|= flag
; }
1159 Returns @true if no attributes are set.
1161 bool IsDefault() const;
1164 Returns the float mode.
1166 wxTextBoxAttrFloatStyle
GetFloatMode() const { return m_floatMode
; }
1169 Sets the float mode.
1171 void SetFloatMode(wxTextBoxAttrFloatStyle mode
) { m_floatMode
= mode
; m_flags
|= wxTEXT_BOX_ATTR_FLOAT
; }
1174 Returns @true if float mode is active.
1176 bool HasFloatMode() const { return HasFlag(wxTEXT_BOX_ATTR_FLOAT
); }
1179 Returns @true if this object is floating.
1181 bool IsFloating() const { return HasFloatMode() && GetFloatMode() != wxTEXT_BOX_ATTR_FLOAT_NONE
; }
1184 Returns the clear mode - whether to wrap text after object. Currently unimplemented.
1186 wxTextBoxAttrClearStyle
GetClearMode() const { return m_clearMode
; }
1189 Set the clear mode. Currently unimplemented.
1191 void SetClearMode(wxTextBoxAttrClearStyle mode
) { m_clearMode
= mode
; m_flags
|= wxTEXT_BOX_ATTR_CLEAR
; }
1194 Returns @true if we have a clear flag.
1196 bool HasClearMode() const { return HasFlag(wxTEXT_BOX_ATTR_CLEAR
); }
1199 Returns the collapse mode - whether to collapse borders. Currently unimplemented.
1201 wxTextBoxAttrCollapseMode
GetCollapseBorders() const { return m_collapseMode
; }
1204 Sets the collapse mode - whether to collapse borders. Currently unimplemented.
1206 void SetCollapseBorders(wxTextBoxAttrCollapseMode collapse
) { m_collapseMode
= collapse
; m_flags
|= wxTEXT_BOX_ATTR_COLLAPSE_BORDERS
; }
1209 Returns @true if the collapse borders flag is present.
1211 bool HasCollapseBorders() const { return HasFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS
); }
1214 Returns the vertical alignment.
1216 wxTextBoxAttrVerticalAlignment
GetVerticalAlignment() const { return m_verticalAlignment
; }
1219 Sets the vertical alignment.
1221 void SetVerticalAlignment(wxTextBoxAttrVerticalAlignment verticalAlignment
) { m_verticalAlignment
= verticalAlignment
; m_flags
|= wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
; }
1224 Returns @true if a vertical alignment flag is present.
1226 bool HasVerticalAlignment() const { return HasFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
); }
1229 Returns the margin values.
1231 wxTextAttrDimensions
& GetMargins() { return m_margins
; }
1232 const wxTextAttrDimensions
& GetMargins() const { return m_margins
; }
1235 Returns the left margin.
1237 wxTextAttrDimension
& GetLeftMargin() { return m_margins
.m_left
; }
1238 const wxTextAttrDimension
& GetLeftMargin() const { return m_margins
.m_left
; }
1241 Returns the right margin.
1243 wxTextAttrDimension
& GetRightMargin() { return m_margins
.m_right
; }
1244 const wxTextAttrDimension
& GetRightMargin() const { return m_margins
.m_right
; }
1247 Returns the top margin.
1249 wxTextAttrDimension
& GetTopMargin() { return m_margins
.m_top
; }
1250 const wxTextAttrDimension
& GetTopMargin() const { return m_margins
.m_top
; }
1253 Returns the bottom margin.
1255 wxTextAttrDimension
& GetBottomMargin() { return m_margins
.m_bottom
; }
1256 const wxTextAttrDimension
& GetBottomMargin() const { return m_margins
.m_bottom
; }
1259 Returns the position.
1261 wxTextAttrDimensions
& GetPosition() { return m_position
; }
1262 const wxTextAttrDimensions
& GetPosition() const { return m_position
; }
1265 Returns the left position.
1267 wxTextAttrDimension
& GetLeft() { return m_position
.m_left
; }
1268 const wxTextAttrDimension
& GetLeft() const { return m_position
.m_left
; }
1271 Returns the right position.
1273 wxTextAttrDimension
& GetRight() { return m_position
.m_right
; }
1274 const wxTextAttrDimension
& GetRight() const { return m_position
.m_right
; }
1277 Returns the top position.
1279 wxTextAttrDimension
& GetTop() { return m_position
.m_top
; }
1280 const wxTextAttrDimension
& GetTop() const { return m_position
.m_top
; }
1283 Returns the bottom position.
1285 wxTextAttrDimension
& GetBottom() { return m_position
.m_bottom
; }
1286 const wxTextAttrDimension
& GetBottom() const { return m_position
.m_bottom
; }
1289 Returns the padding values.
1291 wxTextAttrDimensions
& GetPadding() { return m_padding
; }
1292 const wxTextAttrDimensions
& GetPadding() const { return m_padding
; }
1295 Returns the left padding value.
1297 wxTextAttrDimension
& GetLeftPadding() { return m_padding
.m_left
; }
1298 const wxTextAttrDimension
& GetLeftPadding() const { return m_padding
.m_left
; }
1301 Returns the right padding value.
1303 wxTextAttrDimension
& GetRightPadding() { return m_padding
.m_right
; }
1304 const wxTextAttrDimension
& GetRightPadding() const { return m_padding
.m_right
; }
1307 Returns the top padding value.
1309 wxTextAttrDimension
& GetTopPadding() { return m_padding
.m_top
; }
1310 const wxTextAttrDimension
& GetTopPadding() const { return m_padding
.m_top
; }
1313 Returns the bottom padding value.
1315 wxTextAttrDimension
& GetBottomPadding() { return m_padding
.m_bottom
; }
1316 const wxTextAttrDimension
& GetBottomPadding() const { return m_padding
.m_bottom
; }
1319 Returns the borders.
1321 wxTextAttrBorders
& GetBorder() { return m_border
; }
1322 const wxTextAttrBorders
& GetBorder() const { return m_border
; }
1325 Returns the left border.
1327 wxTextAttrBorder
& GetLeftBorder() { return m_border
.m_left
; }
1328 const wxTextAttrBorder
& GetLeftBorder() const { return m_border
.m_left
; }
1331 Returns the top border.
1333 wxTextAttrBorder
& GetTopBorder() { return m_border
.m_top
; }
1334 const wxTextAttrBorder
& GetTopBorder() const { return m_border
.m_top
; }
1337 Returns the right border.
1339 wxTextAttrBorder
& GetRightBorder() { return m_border
.m_right
; }
1340 const wxTextAttrBorder
& GetRightBorder() const { return m_border
.m_right
; }
1343 Returns the bottom border.
1345 wxTextAttrBorder
& GetBottomBorder() { return m_border
.m_bottom
; }
1346 const wxTextAttrBorder
& GetBottomBorder() const { return m_border
.m_bottom
; }
1349 Returns the outline.
1351 wxTextAttrBorders
& GetOutline() { return m_outline
; }
1352 const wxTextAttrBorders
& GetOutline() const { return m_outline
; }
1355 Returns the left outline.
1357 wxTextAttrBorder
& GetLeftOutline() { return m_outline
.m_left
; }
1358 const wxTextAttrBorder
& GetLeftOutline() const { return m_outline
.m_left
; }
1361 Returns the top outline.
1363 wxTextAttrBorder
& GetTopOutline() { return m_outline
.m_top
; }
1364 const wxTextAttrBorder
& GetTopOutline() const { return m_outline
.m_top
; }
1367 Returns the right outline.
1369 wxTextAttrBorder
& GetRightOutline() { return m_outline
.m_right
; }
1370 const wxTextAttrBorder
& GetRightOutline() const { return m_outline
.m_right
; }
1373 Returns the bottom outline.
1375 wxTextAttrBorder
& GetBottomOutline() { return m_outline
.m_bottom
; }
1376 const wxTextAttrBorder
& GetBottomOutline() const { return m_outline
.m_bottom
; }
1379 Returns the object size.
1381 wxTextAttrSize
& GetSize() { return m_size
; }
1382 const wxTextAttrSize
& GetSize() const { return m_size
; }
1385 Returns the object minimum size.
1388 wxTextAttrSize
& GetMinSize() { return m_minSize
; }
1389 const wxTextAttrSize
& GetMinSize() const { return m_minSize
; }
1392 Returns the object maximum size.
1395 wxTextAttrSize
& GetMaxSize() { return m_maxSize
; }
1396 const wxTextAttrSize
& GetMaxSize() const { return m_maxSize
; }
1399 Sets the object size.
1401 void SetSize(const wxTextAttrSize
& sz
) { m_size
= sz
; }
1404 Sets the object minimum size.
1406 void SetMinSize(const wxTextAttrSize
& sz
) { m_minSize
= sz
; }
1409 Sets the object maximum size.
1411 void SetMaxSize(const wxTextAttrSize
& sz
) { m_maxSize
= sz
; }
1414 Returns the object width.
1416 wxTextAttrDimension
& GetWidth() { return m_size
.m_width
; }
1417 const wxTextAttrDimension
& GetWidth() const { return m_size
.m_width
; }
1420 Returns the object height.
1422 wxTextAttrDimension
& GetHeight() { return m_size
.m_height
; }
1423 const wxTextAttrDimension
& GetHeight() const { return m_size
.m_height
; }
1426 Returns the box style name.
1428 const wxString
& GetBoxStyleName() const { return m_boxStyleName
; }
1431 Sets the box style name.
1433 void SetBoxStyleName(const wxString
& name
) { m_boxStyleName
= name
; AddFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME
); }
1436 Returns @true if the box style name is present.
1438 bool HasBoxStyleName() const { return HasFlag(wxTEXT_BOX_ATTR_BOX_STYLE_NAME
); }
1444 wxTextAttrDimensions m_margins
;
1445 wxTextAttrDimensions m_padding
;
1446 wxTextAttrDimensions m_position
;
1448 wxTextAttrSize m_size
;
1449 wxTextAttrSize m_minSize
;
1450 wxTextAttrSize m_maxSize
;
1452 wxTextAttrBorders m_border
;
1453 wxTextAttrBorders m_outline
;
1455 wxTextBoxAttrFloatStyle m_floatMode
;
1456 wxTextBoxAttrClearStyle m_clearMode
;
1457 wxTextBoxAttrCollapseMode m_collapseMode
;
1458 wxTextBoxAttrVerticalAlignment m_verticalAlignment
;
1459 wxString m_boxStyleName
;
1463 @class wxRichTextAttr
1464 A class representing enhanced attributes for rich text objects.
1465 This adds a wxTextBoxAttr member to the basic wxTextAttr class.
1467 @library{wxrichtext}
1470 @see wxRichTextAttr, wxTextBoxAttr, wxRichTextCtrl
1473 class WXDLLIMPEXP_RICHTEXT wxRichTextAttr
: public wxTextAttr
1477 Constructor taking a wxTextAttr.
1479 wxRichTextAttr(const wxTextAttr
& attr
) { wxTextAttr::Copy(attr
); }
1484 wxRichTextAttr(const wxRichTextAttr
& attr
): wxTextAttr() { Copy(attr
); }
1487 Default constructor.
1494 void Copy(const wxRichTextAttr
& attr
);
1497 Assignment operator.
1499 void operator=(const wxRichTextAttr
& attr
) { Copy(attr
); }
1502 Assignment operator.
1504 void operator=(const wxTextAttr
& attr
) { wxTextAttr::Copy(attr
); }
1509 bool operator==(const wxRichTextAttr
& attr
) const;
1512 Partial equality test. If @a weakTest is @true, attributes of this object do not
1513 have to be present if those attributes of @a attr are present. If @a weakTest is
1514 @false, the function will fail if an attribute is present in @a attr but not
1517 bool EqPartial(const wxRichTextAttr
& attr
, bool weakTest
= true) const;
1520 Merges the given attributes. If @a compareWith
1521 is non-NULL, then it will be used to mask out those attributes that are the same in style
1522 and @a compareWith, for situations where we don't want to explicitly set inherited attributes.
1524 bool Apply(const wxRichTextAttr
& style
, const wxRichTextAttr
* compareWith
= NULL
);
1527 Collects the attributes that are common to a range of content, building up a note of
1528 which attributes are absent in some objects and which clash in some objects.
1530 void CollectCommonAttributes(const wxRichTextAttr
& attr
, wxRichTextAttr
& clashingAttr
, wxRichTextAttr
& absentAttr
);
1533 Removes the specified attributes from this object.
1535 bool RemoveStyle(const wxRichTextAttr
& attr
);
1538 Returns the text box attributes.
1540 wxTextBoxAttr
& GetTextBoxAttr() { return m_textBoxAttr
; }
1541 const wxTextBoxAttr
& GetTextBoxAttr() const { return m_textBoxAttr
; }
1544 Set the text box attributes.
1546 void SetTextBoxAttr(const wxTextBoxAttr
& attr
) { m_textBoxAttr
= attr
; }
1549 Returns @true if no attributes are set.
1551 bool IsDefault() const { return (GetFlags() == 0) && m_textBoxAttr
.IsDefault(); }
1553 wxTextBoxAttr m_textBoxAttr
;
1556 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRichTextAttr
, wxRichTextAttrArray
, WXDLLIMPEXP_RICHTEXT
);
1558 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxVariant
, wxRichTextVariantArray
, WXDLLIMPEXP_RICHTEXT
);
1561 @class wxRichTextProperties
1562 A simple property class using wxVariants. This is used to give each rich text object the
1563 ability to store custom properties that can be used by the application.
1565 @library{wxrichtext}
1568 @see wxRichTextBuffer, wxRichTextObject, wxRichTextCtrl
1571 class WXDLLIMPEXP_RICHTEXT wxRichTextProperties
: public wxObject
1573 DECLARE_DYNAMIC_CLASS(wxRichTextProperties
)
1577 Default constructor.
1579 wxRichTextProperties() {}
1584 wxRichTextProperties(const wxRichTextProperties
& props
): wxObject() { Copy(props
); }
1587 Assignment operator.
1589 void operator=(const wxRichTextProperties
& props
) { Copy(props
); }
1594 bool operator==(const wxRichTextProperties
& props
) const;
1597 Copies from @a props.
1599 void Copy(const wxRichTextProperties
& props
) { m_properties
= props
.m_properties
; }
1602 Returns the variant at the given index.
1604 const wxVariant
& operator[](size_t idx
) const { return m_properties
[idx
]; }
1607 Returns the variant at the given index.
1609 wxVariant
& operator[](size_t idx
) { return m_properties
[idx
]; }
1612 Clears the properties.
1614 void Clear() { m_properties
.Clear(); }
1617 Returns the array of variants implementing the properties.
1619 const wxRichTextVariantArray
& GetProperties() const { return m_properties
; }
1622 Returns the array of variants implementing the properties.
1624 wxRichTextVariantArray
& GetProperties() { return m_properties
; }
1627 Sets the array of variants.
1629 void SetProperties(const wxRichTextVariantArray
& props
) { m_properties
= props
; }
1632 Returns all the property names.
1634 wxArrayString
GetPropertyNames() const;
1637 Returns a count of the properties.
1639 size_t GetCount() const { return m_properties
.GetCount(); }
1642 Returns @true if the given property is found.
1644 bool HasProperty(const wxString
& name
) const { return Find(name
) != -1; }
1647 Finds the given property.
1649 int Find(const wxString
& name
) const;
1652 Removes the given property.
1654 bool Remove(const wxString
& name
);
1657 Gets the property variant by name.
1659 const wxVariant
& GetProperty(const wxString
& name
) const;
1662 Finds or creates a property with the given name, returning a pointer to the variant.
1664 wxVariant
* FindOrCreateProperty(const wxString
& name
);
1667 Gets the value of the named property as a string.
1669 wxString
GetPropertyString(const wxString
& name
) const;
1672 Gets the value of the named property as a long integer.
1674 long GetPropertyLong(const wxString
& name
) const;
1677 Gets the value of the named property as a boolean.
1679 bool GetPropertyBool(const wxString
& name
) const;
1682 Gets the value of the named property as a double.
1684 double GetPropertyDouble(const wxString
& name
) const;
1687 Sets the property by passing a variant which contains a name and value.
1689 void SetProperty(const wxVariant
& variant
);
1692 Sets a property by name and variant.
1694 void SetProperty(const wxString
& name
, const wxVariant
& variant
);
1697 Sets a property by name and string value.
1699 void SetProperty(const wxString
& name
, const wxString
& value
);
1702 Sets property by name and long integer value.
1704 void SetProperty(const wxString
& name
, long value
);
1707 Sets property by name and double value.
1709 void SetProperty(const wxString
& name
, double value
);
1712 Sets property by name and boolean value.
1714 void SetProperty(const wxString
& name
, bool value
);
1717 Removes the given properties from these properties.
1719 void RemoveProperties(const wxRichTextProperties
& properties
);
1722 Merges the given properties with these properties.
1724 void MergeProperties(const wxRichTextProperties
& properties
);
1727 wxRichTextVariantArray m_properties
;
1732 @class wxRichTextFontTable
1733 Manages quick access to a pool of fonts for rendering rich text.
1735 @library{wxrichtext}
1738 @see wxRichTextBuffer, wxRichTextCtrl
1741 class WXDLLIMPEXP_RICHTEXT wxRichTextFontTable
: public wxObject
1745 Default constructor.
1747 wxRichTextFontTable();
1752 wxRichTextFontTable(const wxRichTextFontTable
& table
);
1753 virtual ~wxRichTextFontTable();
1756 Returns @true if the font table is valid.
1758 bool IsOk() const { return m_refData
!= NULL
; }
1761 Finds a font for the given attribute object.
1763 wxFont
FindFont(const wxRichTextAttr
& fontSpec
);
1766 Clears the font table.
1771 Assignment operator.
1773 void operator= (const wxRichTextFontTable
& table
);
1778 bool operator == (const wxRichTextFontTable
& table
) const;
1781 Inequality operator.
1783 bool operator != (const wxRichTextFontTable
& table
) const { return !(*this == table
); }
1786 Set the font scale factor.
1788 void SetFontScale(double fontScale
);
1794 DECLARE_DYNAMIC_CLASS(wxRichTextFontTable
)
1798 @class wxRichTextRange
1800 This stores beginning and end positions for a range of data.
1802 @library{wxrichtext}
1805 @see wxRichTextBuffer, wxRichTextCtrl
1808 class WXDLLIMPEXP_RICHTEXT wxRichTextRange
1814 Default constructor.
1816 wxRichTextRange() { m_start
= 0; m_end
= 0; }
1819 Constructor taking start and end positions.
1821 wxRichTextRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
1826 wxRichTextRange(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
1827 ~wxRichTextRange() {}
1830 Assigns @a range to this range.
1832 void operator =(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
1835 Equality operator. Returns @true if @a range is the same as this range.
1837 bool operator ==(const wxRichTextRange
& range
) const { return (m_start
== range
.m_start
&& m_end
== range
.m_end
); }
1840 Inequality operator.
1842 bool operator !=(const wxRichTextRange
& range
) const { return (m_start
!= range
.m_start
|| m_end
!= range
.m_end
); }
1845 Subtracts a range from this range.
1847 wxRichTextRange
operator -(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
- range
.m_start
, m_end
- range
.m_end
); }
1850 Adds a range to this range.
1852 wxRichTextRange
operator +(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
+ range
.m_start
, m_end
+ range
.m_end
); }
1855 Sets the range start and end positions.
1857 void SetRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
1860 Sets the start position.
1862 void SetStart(long start
) { m_start
= start
; }
1865 Returns the start position.
1867 long GetStart() const { return m_start
; }
1870 Sets the end position.
1872 void SetEnd(long end
) { m_end
= end
; }
1875 Gets the end position.
1877 long GetEnd() const { return m_end
; }
1880 Returns true if this range is completely outside @a range.
1882 bool IsOutside(const wxRichTextRange
& range
) const { return range
.m_start
> m_end
|| range
.m_end
< m_start
; }
1885 Returns true if this range is completely within @a range.
1887 bool IsWithin(const wxRichTextRange
& range
) const { return m_start
>= range
.m_start
&& m_end
<= range
.m_end
; }
1890 Returns true if @a pos was within the range. Does not match if the range is empty.
1892 bool Contains(long pos
) const { return pos
>= m_start
&& pos
<= m_end
; }
1895 Limit this range to be within @a range.
1897 bool LimitTo(const wxRichTextRange
& range
) ;
1900 Gets the length of the range.
1902 long GetLength() const { return m_end
- m_start
+ 1; }
1905 Swaps the start and end.
1907 void Swap() { long tmp
= m_start
; m_start
= m_end
; m_end
= tmp
; }
1910 Converts the API-standard range, whose end is one past the last character in
1911 the range, to the internal form, which uses the first and last character
1912 positions of the range. In other words, one is subtracted from the end position.
1913 (n, n) is the range of a single character.
1915 wxRichTextRange
ToInternal() const { return wxRichTextRange(m_start
, m_end
-1); }
1918 Converts the internal range, which uses the first and last character positions
1919 of the range, to the API-standard range, whose end is one past the last
1920 character in the range. In other words, one is added to the end position.
1921 (n, n+1) is the range of a single character.
1923 wxRichTextRange
FromInternal() const { return wxRichTextRange(m_start
, m_end
+1); }
1930 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRichTextRange
, wxRichTextRangeArray
, WXDLLIMPEXP_RICHTEXT
);
1932 #define wxRICHTEXT_ALL wxRichTextRange(-2, -2)
1933 #define wxRICHTEXT_NONE wxRichTextRange(-1, -1)
1935 #define wxRICHTEXT_NO_SELECTION wxRichTextRange(-2, -2)
1938 @class wxRichTextSelection
1940 Stores selection information. The selection does not have to be contiguous, though currently non-contiguous
1941 selections are only supported for a range of table cells (a geometric block of cells can consist
1942 of a set of non-contiguous positions).
1944 The selection consists of an array of ranges, and the container that is the context for the selection. It
1945 follows that a single selection object can only represent ranges with the same parent container.
1947 @library{wxrichtext}
1950 @see wxRichTextBuffer, wxRichTextCtrl
1953 class WXDLLIMPEXP_RICHTEXT wxRichTextSelection
1959 wxRichTextSelection(const wxRichTextSelection
& sel
) { Copy(sel
); }
1962 Creates a selection from a range and a container.
1964 wxRichTextSelection(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
* container
) { m_ranges
.Add(range
); m_container
= container
; }
1967 Default constructor.
1969 wxRichTextSelection() { Reset(); }
1972 Resets the selection.
1974 void Reset() { m_ranges
.Clear(); m_container
= NULL
; }
1980 void Set(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
* container
)
1981 { m_ranges
.Clear(); m_ranges
.Add(range
); m_container
= container
; }
1984 Adds a range to the selection.
1986 void Add(const wxRichTextRange
& range
)
1987 { m_ranges
.Add(range
); }
1990 Sets the selections from an array of ranges and a container object.
1992 void Set(const wxRichTextRangeArray
& ranges
, wxRichTextParagraphLayoutBox
* container
)
1993 { m_ranges
= ranges
; m_container
= container
; }
1998 void Copy(const wxRichTextSelection
& sel
)
1999 { m_ranges
= sel
.m_ranges
; m_container
= sel
.m_container
; }
2002 Assignment operator.
2004 void operator=(const wxRichTextSelection
& sel
) { Copy(sel
); }
2009 bool operator==(const wxRichTextSelection
& sel
) const;
2014 wxRichTextRange
operator[](size_t i
) const { return GetRange(i
); }
2017 Returns the selection ranges.
2019 wxRichTextRangeArray
& GetRanges() { return m_ranges
; }
2022 Returns the selection ranges.
2024 const wxRichTextRangeArray
& GetRanges() const { return m_ranges
; }
2027 Sets the selection ranges.
2029 void SetRanges(const wxRichTextRangeArray
& ranges
) { m_ranges
= ranges
; }
2032 Returns the number of ranges in the selection.
2034 size_t GetCount() const { return m_ranges
.GetCount(); }
2037 Returns the range at the given index.
2040 wxRichTextRange
GetRange(size_t i
) const { return m_ranges
[i
]; }
2043 Returns the first range if there is one, otherwise wxRICHTEXT_NO_SELECTION.
2045 wxRichTextRange
GetRange() const { return (m_ranges
.GetCount() > 0) ? (m_ranges
[0]) : wxRICHTEXT_NO_SELECTION
; }
2048 Sets a single range.
2050 void SetRange(const wxRichTextRange
& range
) { m_ranges
.Clear(); m_ranges
.Add(range
); }
2053 Returns the container for which the selection is valid.
2055 wxRichTextParagraphLayoutBox
* GetContainer() const { return m_container
; }
2058 Sets the container for which the selection is valid.
2060 void SetContainer(wxRichTextParagraphLayoutBox
* container
) { m_container
= container
; }
2063 Returns @true if the selection is valid.
2065 bool IsValid() const { return m_ranges
.GetCount() > 0 && GetContainer(); }
2068 Returns the selection appropriate to the specified object, if any; returns an empty array if none
2069 at the level of the object's container.
2071 wxRichTextRangeArray
GetSelectionForObject(wxRichTextObject
* obj
) const;
2074 Returns @true if the given position is within the selection.
2076 bool WithinSelection(long pos
, wxRichTextObject
* obj
) const;
2079 Returns @true if the given position is within the selection.
2082 bool WithinSelection(long pos
) const { return WithinSelection(pos
, m_ranges
); }
2085 Returns @true if the given position is within the selection range.
2087 static bool WithinSelection(long pos
, const wxRichTextRangeArray
& ranges
);
2090 Returns @true if the given range is within the selection range.
2092 static bool WithinSelection(const wxRichTextRange
& range
, const wxRichTextRangeArray
& ranges
);
2094 wxRichTextRangeArray m_ranges
;
2095 wxRichTextParagraphLayoutBox
* m_container
;
2099 @class wxRichTextDrawingContext
2101 A class for passing information to drawing and measuring functions.
2103 @library{wxrichtext}
2106 @see wxRichTextBuffer, wxRichTextCtrl
2109 class WXDLLIMPEXP_RICHTEXT wxRichTextDrawingContext
: public wxObject
2111 DECLARE_CLASS(wxRichTextDrawingContext
)
2115 Pass the buffer to the context so the context can retrieve information
2116 such as virtual attributes.
2118 wxRichTextDrawingContext(wxRichTextBuffer
* buffer
);
2120 void Init() { m_buffer
= NULL
; m_enableVirtualAttributes
= true; }
2123 Does this object have virtual attributes?
2124 Virtual attributes can be provided for visual cues without
2125 affecting the actual styling.
2127 bool HasVirtualAttributes(wxRichTextObject
* obj
) const;
2130 Returns the virtual attributes for this object.
2131 Virtual attributes can be provided for visual cues without
2132 affecting the actual styling.
2134 wxRichTextAttr
GetVirtualAttributes(wxRichTextObject
* obj
) const;
2137 Applies any virtual attributes relevant to this object.
2139 bool ApplyVirtualAttributes(wxRichTextAttr
& attr
, wxRichTextObject
* obj
) const;
2142 Gets the count for mixed virtual attributes for individual positions within the object.
2143 For example, individual characters within a text object may require special highlighting.
2145 int GetVirtualSubobjectAttributesCount(wxRichTextObject
* obj
) const;
2148 Gets the mixed virtual attributes for individual positions within the object.
2149 For example, individual characters within a text object may require special highlighting.
2150 The function is passed the count returned by GetVirtualSubobjectAttributesCount.
2152 int GetVirtualSubobjectAttributes(wxRichTextObject
* obj
, wxArrayInt
& positions
, wxRichTextAttrArray
& attributes
) const;
2155 Do we have virtual text for this object? Virtual text allows an application
2156 to replace characters in an object for editing and display purposes, for example
2157 for highlighting special characters.
2159 bool HasVirtualText(const wxRichTextPlainText
* obj
) const;
2162 Gets the virtual text for this object.
2164 bool GetVirtualText(const wxRichTextPlainText
* obj
, wxString
& text
) const;
2167 Enables virtual attribute processing.
2170 void EnableVirtualAttributes(bool b
) { m_enableVirtualAttributes
= b
; }
2173 Returns @true if virtual attribute processing is enabled.
2176 bool GetVirtualAttributesEnabled() const { return m_enableVirtualAttributes
; }
2178 wxRichTextBuffer
* m_buffer
;
2179 bool m_enableVirtualAttributes
;
2183 @class wxRichTextObject
2185 This is the base for drawable rich text objects.
2187 @library{wxrichtext}
2190 @see wxRichTextBuffer, wxRichTextCtrl
2193 class WXDLLIMPEXP_RICHTEXT wxRichTextObject
: public wxObject
2195 DECLARE_CLASS(wxRichTextObject
)
2198 Constructor, taking an optional parent pointer.
2200 wxRichTextObject(wxRichTextObject
* parent
= NULL
);
2202 virtual ~wxRichTextObject();
2207 Draw the item, within the given range. Some objects may ignore the range (for
2208 example paragraphs) while others must obey it (lines, to implement wrapping)
2210 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
) = 0;
2213 Lay the item out at the specified position with the given size constraint.
2214 Layout must set the cached size. @rect is the available space for the object,
2215 and @a parentRect is the container that is used to determine a relative size
2216 or position (for example if a text box must be 50% of the parent text box).
2218 virtual bool Layout(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
) = 0;
2221 Hit-testing: returns a flag indicating hit test details, plus
2222 information about position. @a contextObj is returned to specify what object
2223 position is relevant to, since otherwise there's an ambiguity.
2224 @ obj might not be a child of @a contextObj, since we may be referring to the container itself
2225 if we have no hit on a child - for example if we click outside an object.
2227 The function puts the position in @a textPosition if one is found.
2228 @a pt is in logical units (a zero y position is at the beginning of the buffer).
2230 Pass wxRICHTEXT_HITTEST_NO_NESTED_OBJECTS if you only want to consider objects
2231 directly under the object you are calling HitTest on. Otherwise, it will recurse
2232 and potentially find a nested object.
2234 @return One of the ::wxRichTextHitTestFlags values.
2237 virtual int HitTest(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
2240 Finds the absolute position and row height for the given character position.
2242 virtual bool FindPosition(wxDC
& WXUNUSED(dc
), wxRichTextDrawingContext
& WXUNUSED(context
), long WXUNUSED(index
), wxPoint
& WXUNUSED(pt
), int* WXUNUSED(height
), bool WXUNUSED(forceLineStart
)) { return false; }
2245 Returns the best size, i.e. the ideal starting size for this object irrespective
2246 of available space. For a short text string, it will be the size that exactly encloses
2247 the text. For a longer string, it might use the parent width for example.
2249 virtual wxSize
GetBestSize() const { return m_size
; }
2252 Returns the object size for the given range. Returns @false if the range
2253 is invalid for this object.
2256 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;
2259 Do a split from @a pos, returning an object containing the second part, and setting
2260 the first part in 'this'.
2262 virtual wxRichTextObject
* DoSplit(long WXUNUSED(pos
)) { return NULL
; }
2265 Calculates the range of the object. By default, guess that the object is 1 unit long.
2267 virtual void CalculateRange(long start
, long& end
) { end
= start
; m_range
.SetRange(start
, end
); }
2270 Deletes the given range.
2272 virtual bool DeleteRange(const wxRichTextRange
& WXUNUSED(range
)) { return false; }
2275 Returns @true if the object is empty.
2277 virtual bool IsEmpty() const { return false; }
2280 Returns @true if this class of object is floatable.
2282 virtual bool IsFloatable() const { return false; }
2285 Returns @true if this object is currently floating.
2287 virtual bool IsFloating() const { return GetAttributes().GetTextBoxAttr().IsFloating(); }
2290 Returns the floating direction.
2292 virtual int GetFloatDirection() const { return GetAttributes().GetTextBoxAttr().GetFloatMode(); }
2295 Returns any text in this object for the given range.
2297 virtual wxString
GetTextForRange(const wxRichTextRange
& WXUNUSED(range
)) const { return wxEmptyString
; }
2300 Returns @true if this object can merge itself with the given one.
2302 virtual bool CanMerge(wxRichTextObject
* WXUNUSED(object
), wxRichTextDrawingContext
& WXUNUSED(context
)) const { return false; }
2305 Returns @true if this object merged itself with the given one.
2306 The calling code will then delete the given object.
2308 virtual bool Merge(wxRichTextObject
* WXUNUSED(object
), wxRichTextDrawingContext
& WXUNUSED(context
)) { return false; }
2312 Returns @true if this object can potentially be split, by virtue of having
2313 different virtual attributes for individual sub-objects.
2315 virtual bool CanSplit(wxRichTextDrawingContext
& WXUNUSED(context
)) const { return false; }
2318 Returns the final object in the split objects if this object was split due to differences between sub-object virtual attributes.
2319 Returns itself if it was not split.
2321 virtual wxRichTextObject
* Split(wxRichTextDrawingContext
& WXUNUSED(context
)) { return this; }
2324 Dump object data to the given output stream for debugging.
2326 virtual void Dump(wxTextOutputStream
& stream
);
2329 Returns @true if we can edit the object's properties via a GUI.
2331 virtual bool CanEditProperties() const { return false; }
2334 Edits the object's properties via a GUI.
2336 virtual bool EditProperties(wxWindow
* WXUNUSED(parent
), wxRichTextBuffer
* WXUNUSED(buffer
)) { return false; }
2339 Returns the label to be used for the properties context menu item.
2341 virtual wxString
GetPropertiesMenuLabel() const { return wxEmptyString
; }
2344 Returns @true if objects of this class can accept the focus, i.e. a call to SetFocusObject
2345 is possible. For example, containers supporting text, such as a text box object, can accept the focus,
2346 but a table can't (set the focus to individual cells instead).
2348 virtual bool AcceptsFocus() const { return false; }
2352 Imports this object from XML.
2354 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
2357 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2359 Exports this object directly to the given stream, bypassing the creation of a wxXmlNode hierarchy.
2360 This method is considerably faster than creating a tree first. However, both versions of ExportXML must be
2361 implemented so that if the tree method is made efficient in the future, we can deprecate the
2362 more verbose direct output method. Compiled only if wxRICHTEXT_HAVE_DIRECT_OUTPUT is defined (on by default).
2364 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
2367 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2369 Exports this object to the given parent node, usually creating at least one child node.
2370 This method is less efficient than the direct-to-stream method but is retained to allow for
2371 switching to this method if we make it more efficient. Compiled only if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT is defined
2374 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
2378 Returns @true if this object takes note of paragraph attributes (text and image objects don't).
2380 virtual bool UsesParagraphAttributes() const { return true; }
2383 Returns the XML node name of this object. This must be overridden for wxXmlNode-base XML export to work.
2385 virtual wxString
GetXMLNodeName() const { return wxT("unknown"); }
2388 Invalidates the object at the given range. With no argument, invalidates the whole object.
2390 virtual void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
2393 Returns @true if this object can handle the selections of its children, fOr example a table.
2394 Required for composite selection handling to work.
2396 virtual bool HandlesChildSelections() const { return false; }
2399 Returns a selection object specifying the selections between start and end character positions.
2400 For example, a table would deduce what cells (of range length 1) are selected when dragging across the table.
2402 virtual wxRichTextSelection
GetSelection(long WXUNUSED(start
), long WXUNUSED(end
)) const { return wxRichTextSelection(); }
2407 Gets the cached object size as calculated by Layout.
2409 virtual wxSize
GetCachedSize() const { return m_size
; }
2412 Sets the cached object size as calculated by Layout.
2414 virtual void SetCachedSize(const wxSize
& sz
) { m_size
= sz
; }
2417 Gets the maximum object size as calculated by Layout. This allows
2418 us to fit an object to its contents or allocate extra space if required.
2420 virtual wxSize
GetMaxSize() const { return m_maxSize
; }
2423 Sets the maximum object size as calculated by Layout. This allows
2424 us to fit an object to its contents or allocate extra space if required.
2426 virtual void SetMaxSize(const wxSize
& sz
) { m_maxSize
= sz
; }
2429 Gets the minimum object size as calculated by Layout. This allows
2430 us to constrain an object to its absolute minimum size if necessary.
2432 virtual wxSize
GetMinSize() const { return m_minSize
; }
2435 Sets the minimum object size as calculated by Layout. This allows
2436 us to constrain an object to its absolute minimum size if necessary.
2438 virtual void SetMinSize(const wxSize
& sz
) { m_minSize
= sz
; }
2441 Gets the 'natural' size for an object. For an image, it would be the
2444 virtual wxTextAttrSize
GetNaturalSize() const { return wxTextAttrSize(); }
2447 Returns the object position in pixels.
2449 virtual wxPoint
GetPosition() const { return m_pos
; }
2452 Sets the object position in pixels.
2454 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
2457 Returns the absolute object position, by traversing up the child/parent hierarchy.
2458 TODO: may not be needed, if all object positions are in fact relative to the
2459 top of the coordinate space.
2461 virtual wxPoint
GetAbsolutePosition() const;
2464 Returns the rectangle enclosing the object.
2466 virtual wxRect
GetRect() const { return wxRect(GetPosition(), GetCachedSize()); }
2469 Sets the object's range within its container.
2471 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
2474 Returns the object's range.
2476 const wxRichTextRange
& GetRange() const { return m_range
; }
2479 Returns the object's range.
2481 wxRichTextRange
& GetRange() { return m_range
; }
2484 Set the object's own range, for a top-level object with its own position space.
2486 void SetOwnRange(const wxRichTextRange
& range
) { m_ownRange
= range
; }
2489 Returns the object's own range (valid if top-level).
2491 const wxRichTextRange
& GetOwnRange() const { return m_ownRange
; }
2494 Returns the object's own range (valid if top-level).
2496 wxRichTextRange
& GetOwnRange() { return m_ownRange
; }
2499 Returns the object's own range only if a top-level object.
2501 wxRichTextRange
GetOwnRangeIfTopLevel() const { return IsTopLevel() ? m_ownRange
: m_range
; }
2504 Returns @true if this object is composite.
2506 virtual bool IsComposite() const { return false; }
2509 Returns @true if no user editing can be done inside the object. This returns @true for simple objects,
2510 @false for most composite objects, but @true for fields, which if composite, should not be user-edited.
2512 virtual bool IsAtomic() const { return true; }
2515 Returns a pointer to the parent object.
2517 virtual wxRichTextObject
* GetParent() const { return m_parent
; }
2520 Sets the pointer to the parent object.
2522 virtual void SetParent(wxRichTextObject
* parent
) { m_parent
= parent
; }
2525 Returns the top-level container of this object.
2526 May return itself if it's a container; use GetParentContainer to return
2527 a different container.
2529 virtual wxRichTextParagraphLayoutBox
* GetContainer() const;
2532 Returns the top-level container of this object.
2533 Returns a different container than itself, unless there's no parent, in which case it will return NULL.
2535 virtual wxRichTextParagraphLayoutBox
* GetParentContainer() const { return GetParent() ? GetParent()->GetContainer() : GetContainer(); }
2538 Set the margin around the object, in pixels.
2540 virtual void SetMargins(int margin
);
2543 Set the margin around the object, in pixels.
2545 virtual void SetMargins(int leftMargin
, int rightMargin
, int topMargin
, int bottomMargin
);
2548 Returns the left margin of the object, in pixels.
2550 virtual int GetLeftMargin() const;
2553 Returns the right margin of the object, in pixels.
2555 virtual int GetRightMargin() const;
2558 Returns the top margin of the object, in pixels.
2560 virtual int GetTopMargin() const;
2563 Returns the bottom margin of the object, in pixels.
2565 virtual int GetBottomMargin() const;
2568 Calculates the available content space in the given rectangle, given the
2569 margins, border and padding specified in the object's attributes.
2571 virtual wxRect
GetAvailableContentArea(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& outerRect
) const;
2574 Lays out the object first with a given amount of space, and then if no width was specified in attr,
2575 lays out the object again using the minimum size. @a availableParentSpace is the maximum space
2576 for the object, whereas @a availableContainerSpace is the container with which relative positions and
2577 sizes should be computed. For example, a text box whose space has already been constrained
2578 in a previous layout pass to @a availableParentSpace, but should have a width of 50% of @a availableContainerSpace.
2579 (If these two rects were the same, a 2nd pass could see the object getting too small.)
2581 virtual bool LayoutToBestSize(wxDC
& dc
, wxRichTextDrawingContext
& context
, wxRichTextBuffer
* buffer
,
2582 const wxRichTextAttr
& parentAttr
, const wxRichTextAttr
& attr
,
2583 const wxRect
& availableParentSpace
, const wxRect
& availableContainerSpace
, int style
);
2586 Sets the object's attributes.
2588 void SetAttributes(const wxRichTextAttr
& attr
) { m_attributes
= attr
; }
2591 Returns the object's attributes.
2593 const wxRichTextAttr
& GetAttributes() const { return m_attributes
; }
2596 Returns the object's attributes.
2598 wxRichTextAttr
& GetAttributes() { return m_attributes
; }
2601 Returns the object's properties.
2603 wxRichTextProperties
& GetProperties() { return m_properties
; }
2606 Returns the object's properties.
2608 const wxRichTextProperties
& GetProperties() const { return m_properties
; }
2611 Sets the object's properties.
2613 void SetProperties(const wxRichTextProperties
& props
) { m_properties
= props
; }
2616 Sets the stored descent value.
2618 void SetDescent(int descent
) { m_descent
= descent
; }
2621 Returns the stored descent value.
2623 int GetDescent() const { return m_descent
; }
2626 Returns the containing buffer.
2628 wxRichTextBuffer
* GetBuffer() const;
2631 Sets the identifying name for this object as a property using the "name" key.
2633 void SetName(const wxString
& name
) { m_properties
.SetProperty(wxT("name"), name
); }
2636 Returns the identifying name for this object from the properties, using the "name" key.
2638 wxString
GetName() const { return m_properties
.GetPropertyString(wxT("name")); }
2641 Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box.
2643 virtual bool IsTopLevel() const { return false; }
2646 Returns @true if the object will be shown, @false otherwise.
2648 bool IsShown() const { return m_show
; }
2653 Call to show or hide this object. This function does not cause the content to be
2654 laid out or redrawn.
2656 virtual void Show(bool show
) { m_show
= show
; }
2661 virtual wxRichTextObject
* Clone() const { return NULL
; }
2666 void Copy(const wxRichTextObject
& obj
);
2669 Reference-counting allows us to use the same object in multiple
2670 lists (not yet used).
2673 void Reference() { m_refCount
++; }
2676 Reference-counting allows us to use the same object in multiple
2677 lists (not yet used).
2682 Moves the object recursively, by adding the offset from old to new.
2684 virtual void Move(const wxPoint
& pt
);
2687 Converts units in tenths of a millimetre to device units.
2689 int ConvertTenthsMMToPixels(wxDC
& dc
, int units
) const;
2692 Converts units in tenths of a millimetre to device units.
2694 static int ConvertTenthsMMToPixels(int ppi
, int units
, double scale
= 1.0);
2697 Convert units in pixels to tenths of a millimetre.
2699 int ConvertPixelsToTenthsMM(wxDC
& dc
, int pixels
) const;
2702 Convert units in pixels to tenths of a millimetre.
2704 static int ConvertPixelsToTenthsMM(int ppi
, int pixels
, double scale
= 1.0);
2707 Draws the borders and background for the given rectangle and attributes.
2708 @a boxRect is taken to be the outer margin box, not the box around the content.
2710 static bool DrawBoxAttributes(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxRichTextAttr
& attr
, const wxRect
& boxRect
, int flags
= 0);
2715 static bool DrawBorder(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxTextAttrBorders
& attr
, const wxRect
& rect
, int flags
= 0);
2718 Returns the various rectangles of the box model in pixels. You can either specify @a contentRect (inner)
2719 or @a marginRect (outer), and the other must be the default rectangle (no width or height).
2720 Note that the outline doesn't affect the position of the rectangle, it's drawn in whatever space
2723 static bool GetBoxRects(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxRichTextAttr
& attr
, wxRect
& marginRect
, wxRect
& borderRect
, wxRect
& contentRect
, wxRect
& paddingRect
, wxRect
& outlineRect
);
2726 Returns the total margin for the object in pixels, taking into account margin, padding and border size.
2728 static bool GetTotalMargin(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxRichTextAttr
& attr
, int& leftMargin
, int& rightMargin
,
2729 int& topMargin
, int& bottomMargin
);
2732 Returns the rectangle which the child has available to it given restrictions specified in the
2733 child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc.
2734 availableContainerSpace might be a parent that the cell has to compute its width relative to.
2735 E.g. a cell that's 50% of its parent.
2737 static wxRect
AdjustAvailableSpace(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxRichTextAttr
& parentAttr
, const wxRichTextAttr
& childAttr
,
2738 const wxRect
& availableParentSpace
, const wxRect
& availableContainerSpace
);
2745 int m_descent
; // Descent for this object (if any)
2748 wxRichTextObject
* m_parent
;
2750 // The range of this object (start position to end position)
2751 wxRichTextRange m_range
;
2753 // The internal range of this object, if it's a top-level object with its own range space
2754 wxRichTextRange m_ownRange
;
2757 wxRichTextAttr m_attributes
;
2760 wxRichTextProperties m_properties
;
2763 WX_DECLARE_LIST_WITH_DECL( wxRichTextObject
, wxRichTextObjectList
, class WXDLLIMPEXP_RICHTEXT
);
2766 @class wxRichTextCompositeObject
2768 Objects of this class can contain other objects.
2770 @library{wxrichtext}
2773 @see wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl
2776 class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject
: public wxRichTextObject
2778 DECLARE_CLASS(wxRichTextCompositeObject
)
2782 wxRichTextCompositeObject(wxRichTextObject
* parent
= NULL
);
2783 virtual ~wxRichTextCompositeObject();
2787 virtual int HitTest(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
2789 virtual bool FindPosition(wxDC
& dc
, wxRichTextDrawingContext
& context
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
2791 virtual void CalculateRange(long start
, long& end
);
2793 virtual bool DeleteRange(const wxRichTextRange
& range
);
2795 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
2797 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 virtual void Dump(wxTextOutputStream
& stream
);
2801 virtual void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
2806 Returns the children.
2808 wxRichTextObjectList
& GetChildren() { return m_children
; }
2810 Returns the children.
2812 const wxRichTextObjectList
& GetChildren() const { return m_children
; }
2815 Returns the number of children.
2817 size_t GetChildCount() const ;
2820 Returns the nth child.
2822 wxRichTextObject
* GetChild(size_t n
) const ;
2825 Returns @true if this object is composite.
2827 virtual bool IsComposite() const { return true; }
2830 Returns @true if no user editing can be done inside the object. This returns @true for simple objects,
2831 @false for most composite objects, but @true for fields, which if composite, should not be user-edited.
2833 virtual bool IsAtomic() const { return false; }
2836 Returns true if the buffer is empty.
2838 virtual bool IsEmpty() const { return GetChildCount() == 0; }
2841 Returns the child object at the given character position.
2843 virtual wxRichTextObject
* GetChildAtPosition(long pos
) const;
2847 void Copy(const wxRichTextCompositeObject
& obj
);
2849 void operator= (const wxRichTextCompositeObject
& obj
) { Copy(obj
); }
2852 Appends a child, returning the position.
2854 size_t AppendChild(wxRichTextObject
* child
) ;
2857 Inserts the child in front of the given object, or at the beginning.
2859 bool InsertChild(wxRichTextObject
* child
, wxRichTextObject
* inFrontOf
) ;
2862 Removes and optionally deletes the specified child.
2864 bool RemoveChild(wxRichTextObject
* child
, bool deleteChild
= false) ;
2867 Deletes all the children.
2869 bool DeleteChildren() ;
2872 Recursively merges all pieces that can be merged.
2874 bool Defragment(wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
= wxRICHTEXT_ALL
);
2877 Moves the object recursively, by adding the offset from old to new.
2879 virtual void Move(const wxPoint
& pt
);
2882 wxRichTextObjectList m_children
;
2886 @class wxRichTextParagraphBox
2888 This class knows how to lay out paragraphs.
2890 @library{wxrichtext}
2893 @see wxRichTextCompositeObject, wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl
2896 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphLayoutBox
: public wxRichTextCompositeObject
2898 DECLARE_DYNAMIC_CLASS(wxRichTextParagraphLayoutBox
)
2902 wxRichTextParagraphLayoutBox(wxRichTextObject
* parent
= NULL
);
2903 wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox
& obj
): wxRichTextCompositeObject() { Init(); Copy(obj
); }
2904 ~wxRichTextParagraphLayoutBox();
2908 virtual int HitTest(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
2910 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
2912 virtual bool Layout(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
);
2914 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 virtual bool DeleteRange(const wxRichTextRange
& range
);
2918 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
2921 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
2924 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2925 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
2928 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2929 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
2932 virtual wxString
GetXMLNodeName() const { return wxT("paragraphlayout"); }
2934 virtual bool AcceptsFocus() const { return true; }
2939 Associates a control with the buffer, for operations that for example require refreshing the window.
2941 void SetRichTextCtrl(wxRichTextCtrl
* ctrl
) { m_ctrl
= ctrl
; }
2944 Returns the associated control.
2946 wxRichTextCtrl
* GetRichTextCtrl() const { return m_ctrl
; }
2949 Sets a flag indicating whether the last paragraph is partial or complete.
2951 void SetPartialParagraph(bool partialPara
) { m_partialParagraph
= partialPara
; }
2954 Returns a flag indicating whether the last paragraph is partial or complete.
2956 bool GetPartialParagraph() const { return m_partialParagraph
; }
2959 Returns the style sheet associated with the overall buffer.
2961 virtual wxRichTextStyleSheet
* GetStyleSheet() const;
2963 virtual bool IsTopLevel() const { return true; }
2968 Submits a command to insert paragraphs.
2970 bool InsertParagraphsWithUndo(wxRichTextBuffer
* buffer
, long pos
, const wxRichTextParagraphLayoutBox
& paragraphs
, wxRichTextCtrl
* ctrl
, int flags
= 0);
2973 Submits a command to insert the given text.
2975 bool InsertTextWithUndo(wxRichTextBuffer
* buffer
, long pos
, const wxString
& text
, wxRichTextCtrl
* ctrl
, int flags
= 0);
2978 Submits a command to insert the given text.
2980 bool InsertNewlineWithUndo(wxRichTextBuffer
* buffer
, long pos
, wxRichTextCtrl
* ctrl
, int flags
= 0);
2983 Submits a command to insert the given image.
2985 bool InsertImageWithUndo(wxRichTextBuffer
* buffer
, long pos
, const wxRichTextImageBlock
& imageBlock
,
2986 wxRichTextCtrl
* ctrl
, int flags
, const wxRichTextAttr
& textAttr
);
2989 Submits a command to insert the given field. Field data can be included in properties.
2991 @see wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard
2993 wxRichTextField
* InsertFieldWithUndo(wxRichTextBuffer
* buffer
, long pos
, const wxString
& fieldType
,
2994 const wxRichTextProperties
& properties
,
2995 wxRichTextCtrl
* ctrl
, int flags
,
2996 const wxRichTextAttr
& textAttr
);
2999 Returns the style that is appropriate for a new paragraph at this position.
3000 If the previous paragraph has a paragraph style name, looks up the next-paragraph
3003 wxRichTextAttr
GetStyleForNewParagraph(wxRichTextBuffer
* buffer
, long pos
, bool caretPosition
= false, bool lookUpNewParaStyle
=false) const;
3008 wxRichTextObject
* InsertObjectWithUndo(wxRichTextBuffer
* buffer
, long pos
, wxRichTextObject
*object
, wxRichTextCtrl
* ctrl
, int flags
= 0);
3011 Submits a command to delete this range.
3013 bool DeleteRangeWithUndo(const wxRichTextRange
& range
, wxRichTextCtrl
* ctrl
, wxRichTextBuffer
* buffer
);
3016 Draws the floating objects in this buffer.
3018 void DrawFloats(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
3021 Moves an anchored object to another paragraph.
3023 void MoveAnchoredObjectToParagraph(wxRichTextParagraph
* from
, wxRichTextParagraph
* to
, wxRichTextObject
* obj
);
3026 Initializes the object.
3031 Clears all the children.
3033 virtual void Clear();
3036 Clears and initializes with one blank paragraph.
3038 virtual void Reset();
3041 Convenience function to add a paragraph of text.
3043 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxRichTextAttr
* paraStyle
= NULL
);
3046 Convenience function to add an image.
3048 virtual wxRichTextRange
AddImage(const wxImage
& image
, wxRichTextAttr
* paraStyle
= NULL
);
3051 Adds multiple paragraphs, based on newlines.
3053 virtual wxRichTextRange
AddParagraphs(const wxString
& text
, wxRichTextAttr
* paraStyle
= NULL
);
3056 Returns the line at the given position. If @a caretPosition is true, the position is
3057 a caret position, which is normally a smaller number.
3059 virtual wxRichTextLine
* GetLineAtPosition(long pos
, bool caretPosition
= false) const;
3062 Returns the line at the given y pixel position, or the last line.
3064 virtual wxRichTextLine
* GetLineAtYPosition(int y
) const;
3067 Returns the paragraph at the given character or caret position.
3069 virtual wxRichTextParagraph
* GetParagraphAtPosition(long pos
, bool caretPosition
= false) const;
3072 Returns the line size at the given position.
3074 virtual wxSize
GetLineSizeAtPosition(long pos
, bool caretPosition
= false) const;
3077 Given a position, returns the number of the visible line (potentially many to a paragraph),
3078 starting from zero at the start of the buffer. We also have to pass a bool (@a startOfLine)
3079 that indicates whether the caret is being shown at the end of the previous line or at the start
3080 of the next, since the caret can be shown at two visible positions for the same underlying
3083 virtual long GetVisibleLineNumber(long pos
, bool caretPosition
= false, bool startOfLine
= false) const;
3086 Given a line number, returns the corresponding wxRichTextLine object.
3088 virtual wxRichTextLine
* GetLineForVisibleLineNumber(long lineNumber
) const;
3091 Returns the leaf object in a paragraph at this position.
3093 virtual wxRichTextObject
* GetLeafObjectAtPosition(long position
) const;
3096 Returns the paragraph by number.
3098 virtual wxRichTextParagraph
* GetParagraphAtLine(long paragraphNumber
) const;
3101 Returns the paragraph for a given line.
3103 virtual wxRichTextParagraph
* GetParagraphForLine(wxRichTextLine
* line
) const;
3106 Returns the length of the paragraph.
3108 virtual int GetParagraphLength(long paragraphNumber
) const;
3111 Returns the number of paragraphs.
3113 virtual int GetParagraphCount() const { return static_cast<int>(GetChildCount()); }
3116 Returns the number of visible lines.
3118 virtual int GetLineCount() const;
3121 Returns the text of the paragraph.
3123 virtual wxString
GetParagraphText(long paragraphNumber
) const;
3126 Converts zero-based line column and paragraph number to a position.
3128 virtual long XYToPosition(long x
, long y
) const;
3131 Converts a zero-based position to line column and paragraph number.
3133 virtual bool PositionToXY(long pos
, long* x
, long* y
) const;
3136 Sets the attributes for the given range. Pass flags to determine how the
3139 The end point of range is specified as the last character position of the span
3140 of text. So, for example, to set the style for a character at position 5,
3141 use the range (5,5).
3142 This differs from the wxRichTextCtrl API, where you would specify (5,6).
3144 @a flags may contain a bit list of the following values:
3145 - wxRICHTEXT_SETSTYLE_NONE: no style flag.
3146 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be
3148 - wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied
3149 if the combined style at this point is already the style in question.
3150 - wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be
3151 applied to paragraphs, and not the content.
3152 This allows content styling to be preserved independently from that
3153 of e.g. a named paragraph style.
3154 - wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be
3155 applied to characters, and not the paragraph.
3156 This allows content styling to be preserved independently from that
3157 of e.g. a named paragraph style.
3158 - wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying
3160 - wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style.
3161 Only the style flags are used in this operation.
3163 virtual bool SetStyle(const wxRichTextRange
& range
, const wxRichTextAttr
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
3166 Sets the attributes for the given object only, for example the box attributes for a text box.
3168 virtual void SetStyle(wxRichTextObject
*obj
, const wxRichTextAttr
& textAttr
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
3171 Returns the combined text attributes for this position.
3173 This function gets the @e uncombined style - that is, the attributes associated
3174 with the paragraph or character content, and not necessarily the combined
3175 attributes you see on the screen. To get the combined attributes, use GetStyle().
3176 If you specify (any) paragraph attribute in @e style's flags, this function
3177 will fetch the paragraph attributes.
3178 Otherwise, it will return the character attributes.
3180 virtual bool GetStyle(long position
, wxRichTextAttr
& style
);
3183 Returns the content (uncombined) attributes for this position.
3185 virtual bool GetUncombinedStyle(long position
, wxRichTextAttr
& style
);
3188 Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and
3191 virtual bool DoGetStyle(long position
, wxRichTextAttr
& style
, bool combineStyles
= true);
3194 This function gets a style representing the common, combined attributes in the
3196 Attributes which have different values within the specified range will not be
3197 included the style flags.
3199 The function is used to get the attributes to display in the formatting dialog:
3200 the user can edit the attributes common to the selection, and optionally specify the
3201 values of further attributes to be applied uniformly.
3203 To apply the edited attributes, you can use SetStyle() specifying
3204 the wxRICHTEXT_SETSTYLE_OPTIMIZE flag, which will only apply attributes that
3205 are different from the @e combined attributes within the range.
3206 So, the user edits the effective, displayed attributes for the range,
3207 but his choice won't be applied unnecessarily to content. As an example,
3208 say the style for a paragraph specifies bold, but the paragraph text doesn't
3210 The combined style is bold, and this is what the user will see on-screen and
3211 in the formatting dialog. The user now specifies red text, in addition to bold.
3212 When applying with SetStyle(), the content font weight attributes won't be
3213 changed to bold because this is already specified by the paragraph.
3214 However the text colour attributes @e will be changed to show red.
3216 virtual bool GetStyleForRange(const wxRichTextRange
& range
, wxRichTextAttr
& style
);
3219 Combines @a style with @a currentStyle for the purpose of summarising the attributes of a range of
3222 bool CollectStyle(wxRichTextAttr
& currentStyle
, const wxRichTextAttr
& style
, wxRichTextAttr
& clashingAttr
, wxRichTextAttr
& absentAttr
);
3226 Sets the list attributes for the given range, passing flags to determine how
3227 the attributes are set.
3228 Either the style definition or the name of the style definition (in the current
3229 sheet) can be passed.
3231 @a flags is a bit list of the following:
3232 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
3233 - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
3234 @a startFrom, otherwise existing attributes are used.
3235 - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
3236 as the level for all paragraphs, otherwise the current indentation will be used.
3238 @see NumberList(), PromoteList(), ClearListStyle().
3240 virtual bool SetListStyle(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
3241 virtual bool SetListStyle(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
3245 Clears the list style from the given range, clearing list-related attributes
3246 and applying any named paragraph style associated with each paragraph.
3248 @a flags is a bit list of the following:
3249 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
3251 @see SetListStyle(), PromoteList(), NumberList()
3253 virtual bool ClearListStyle(const wxRichTextRange
& range
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
3257 Numbers the paragraphs in the given range.
3259 Pass flags to determine how the attributes are set.
3260 Either the style definition or the name of the style definition (in the current
3261 sheet) can be passed.
3263 @a flags is a bit list of the following:
3264 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
3265 - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
3266 @a startFrom, otherwise existing attributes are used.
3267 - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
3268 as the level for all paragraphs, otherwise the current indentation will be used.
3270 @a def can be NULL to indicate that the existing list style should be used.
3272 @see SetListStyle(), PromoteList(), ClearListStyle()
3274 virtual bool NumberList(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
3275 virtual bool NumberList(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
3280 Promotes the list items within the given range.
3281 A positive @a promoteBy produces a smaller indent, and a negative number
3282 produces a larger indent. Pass flags to determine how the attributes are set.
3283 Either the style definition or the name of the style definition (in the current
3284 sheet) can be passed.
3286 @a flags is a bit list of the following:
3287 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
3288 - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
3289 @a startFrom, otherwise existing attributes are used.
3290 - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
3291 as the level for all paragraphs, otherwise the current indentation will be used.
3293 @see SetListStyle(), SetListStyle(), ClearListStyle()
3295 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
3296 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
3300 Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously
3301 @a def can be NULL/empty to indicate that the existing list style should be used.
3303 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);
3306 Fills in the attributes for numbering a paragraph after previousParagraph.
3308 virtual bool FindNextParagraphNumber(wxRichTextParagraph
* previousParagraph
, wxRichTextAttr
& attr
) const;
3311 Sets the properties for the given range, passing flags to determine how the
3312 attributes are set. You can merge properties or replace them.
3314 The end point of range is specified as the last character position of the span
3315 of text, plus one. So, for example, to set the properties for a character at
3316 position 5, use the range (5,6).
3318 @a flags may contain a bit list of the following values:
3319 - wxRICHTEXT_SETPROPERTIES_NONE: no flag.
3320 - wxRICHTEXT_SETPROPERTIES_WITH_UNDO: specifies that this operation should be
3322 - wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY: specifies that the properties should only be
3323 applied to paragraphs, and not the content.
3324 - wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY: specifies that the properties should only be
3325 applied to characters, and not the paragraph.
3326 - wxRICHTEXT_SETPROPERTIES_RESET: resets (clears) the existing properties before applying
3328 - wxRICHTEXT_SETPROPERTIES_REMOVE: removes the specified properties.
3330 virtual bool SetProperties(const wxRichTextRange
& range
, const wxRichTextProperties
& properties
, int flags
= wxRICHTEXT_SETPROPERTIES_WITH_UNDO
);
3333 Test if this whole range has character attributes of the specified kind. If any
3334 of the attributes are different within the range, the test fails. You
3335 can use this to implement, for example, bold button updating. style must have
3336 flags indicating which attributes are of interest.
3338 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
3341 Test if this whole range has paragraph attributes of the specified kind. If any
3342 of the attributes are different within the range, the test fails. You
3343 can use this to implement, for example, centering button updating. style must have
3344 flags indicating which attributes are of interest.
3346 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
3348 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraphLayoutBox(*this); }
3351 Prepares the content just before insertion (or after buffer reset).
3352 Currently is only called if undo mode is on.
3354 virtual void PrepareContent(wxRichTextParagraphLayoutBox
& container
);
3357 Insert fragment into this box at the given position. If partialParagraph is true,
3358 it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
3361 virtual bool InsertFragment(long position
, wxRichTextParagraphLayoutBox
& fragment
);
3364 Make a copy of the fragment corresponding to the given range, putting it in @a fragment.
3366 virtual bool CopyFragment(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
& fragment
);
3369 Apply the style sheet to the buffer, for example if the styles have changed.
3371 virtual bool ApplyStyleSheet(wxRichTextStyleSheet
* styleSheet
);
3373 void Copy(const wxRichTextParagraphLayoutBox
& obj
);
3375 void operator= (const wxRichTextParagraphLayoutBox
& obj
) { Copy(obj
); }
3380 virtual void UpdateRanges();
3385 virtual wxString
GetText() const;
3388 Sets the default style, affecting the style currently being applied
3389 (for example, setting the default style to bold will cause subsequently
3390 inserted text to be bold).
3392 This is not cumulative - setting the default style will replace the previous
3395 Setting it to a default attribute object makes new content take on the 'basic' style.
3397 virtual bool SetDefaultStyle(const wxRichTextAttr
& style
);
3400 Returns the current default style, affecting the style currently being applied
3401 (for example, setting the default style to bold will cause subsequently
3402 inserted text to be bold).
3404 virtual const wxRichTextAttr
& GetDefaultStyle() const { return m_defaultAttributes
; }
3407 Sets the basic (overall) style. This is the style of the whole
3408 buffer before further styles are applied, unlike the default style, which
3409 only affects the style currently being applied (for example, setting the default
3410 style to bold will cause subsequently inserted text to be bold).
3412 virtual void SetBasicStyle(const wxRichTextAttr
& style
) { m_attributes
= style
; }
3415 Returns the basic (overall) style.
3417 This is the style of the whole buffer before further styles are applied,
3418 unlike the default style, which only affects the style currently being
3419 applied (for example, setting the default style to bold will cause
3420 subsequently inserted text to be bold).
3422 virtual const wxRichTextAttr
& GetBasicStyle() const { return m_attributes
; }
3425 Invalidates the buffer. With no argument, invalidates whole buffer.
3427 virtual void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
3430 Do the (in)validation for this object only.
3432 virtual void DoInvalidate(const wxRichTextRange
& invalidRange
);
3435 Do the (in)validation both up and down the hierarchy.
3437 virtual void InvalidateHierarchy(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
3440 Gather information about floating objects. If untilObj is non-NULL,
3441 will stop getting information if the current object is this, since we
3442 will collect the rest later.
3444 virtual bool UpdateFloatingObjects(const wxRect
& availableRect
, wxRichTextObject
* untilObj
= NULL
);
3447 Get invalid range, rounding to entire paragraphs if argument is true.
3449 wxRichTextRange
GetInvalidRange(bool wholeParagraphs
= false) const;
3452 Returns @true if this object needs layout.
3454 bool IsDirty() const { return m_invalidRange
!= wxRICHTEXT_NONE
; }
3457 Returns the wxRichTextFloatCollector of this object.
3459 wxRichTextFloatCollector
* GetFloatCollector() { return m_floatCollector
; }
3462 Returns the number of floating objects at this level.
3464 int GetFloatingObjectCount() const;
3467 Returns a list of floating objects.
3469 bool GetFloatingObjects(wxRichTextObjectList
& objects
) const;
3472 wxRichTextCtrl
* m_ctrl
;
3473 wxRichTextAttr m_defaultAttributes
;
3475 // The invalidated range that will need full layout
3476 wxRichTextRange m_invalidRange
;
3478 // Is the last paragraph partial or complete?
3479 bool m_partialParagraph
;
3481 // The floating layout state
3482 wxRichTextFloatCollector
* m_floatCollector
;
3486 @class wxRichTextBox
3488 This class implements a floating or inline text box, containing paragraphs.
3490 @library{wxrichtext}
3493 @see wxRichTextParagraphLayoutBox, wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl
3496 class WXDLLIMPEXP_RICHTEXT wxRichTextBox
: public wxRichTextParagraphLayoutBox
3498 DECLARE_DYNAMIC_CLASS(wxRichTextBox
)
3503 Default constructor; optionally pass the parent object.
3506 wxRichTextBox(wxRichTextObject
* parent
= NULL
);
3512 wxRichTextBox(const wxRichTextBox
& obj
): wxRichTextParagraphLayoutBox() { Copy(obj
); }
3516 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
3518 virtual wxString
GetXMLNodeName() const { return wxT("textbox"); }
3520 virtual bool CanEditProperties() const { return true; }
3522 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
3524 virtual wxString
GetPropertiesMenuLabel() const { return _("&Box"); }
3530 virtual wxRichTextObject
* Clone() const { return new wxRichTextBox(*this); }
3532 void Copy(const wxRichTextBox
& obj
);
3538 @class wxRichTextField
3540 This class implements the general concept of a field, an object that represents
3541 additional functionality such as a footnote, a bookmark, a page number, a table
3542 of contents, and so on. Extra information (such as a bookmark name) can be stored
3543 in the object properties.
3545 Drawing, layout, and property editing is delegated to classes derived
3546 from wxRichTextFieldType, such as instances of wxRichTextFieldTypeStandard; this makes
3547 the use of fields an efficient method of introducing extra functionality, since
3548 most of the information required to draw a field (such as a bitmap) is kept centrally
3549 in a single field type definition.
3551 The FieldType property, accessed by SetFieldType/GetFieldType, is used to retrieve
3552 the field type definition. So be careful not to overwrite this property.
3554 wxRichTextField is derived from wxRichTextParagraphLayoutBox, which means that it
3555 can contain its own read-only content, refreshed when the application calls the UpdateField
3556 function. Whether a field is treated as a composite or a single graphic is determined
3557 by the field type definition. If using wxRichTextFieldTypeStandard, passing the display
3558 type wxRICHTEXT_FIELD_STYLE_COMPOSITE to the field type definition causes the field
3559 to behave like a composite; the other display styles display a simple graphic.
3560 When implementing a composite field, you will still need to derive from wxRichTextFieldTypeStandard
3561 or wxRichTextFieldType, if only to implement UpdateField to refresh the field content
3562 appropriately. wxRichTextFieldTypeStandard is only one possible implementation, but
3563 covers common needs especially for simple, static fields using text or a bitmap.
3565 Register field types on application initialisation with the static function
3566 wxRichTextBuffer::AddFieldType. They will be deleted automatically on
3569 An application can write a field to a control with wxRichTextCtrl::WriteField,
3570 taking a field type, the properties for the field, and optional attributes.
3572 @library{wxrichtext}
3575 @see wxRichTextFieldTypeStandard, wxRichTextFieldType, wxRichTextParagraphLayoutBox, wxRichTextProperties, wxRichTextCtrl
3578 class WXDLLIMPEXP_RICHTEXT wxRichTextField
: public wxRichTextParagraphLayoutBox
3580 DECLARE_DYNAMIC_CLASS(wxRichTextField
)
3585 Default constructor; optionally pass the parent object.
3588 wxRichTextField(const wxString
& fieldType
= wxEmptyString
, wxRichTextObject
* parent
= NULL
);
3594 wxRichTextField(const wxRichTextField
& obj
): wxRichTextParagraphLayoutBox() { Copy(obj
); }
3598 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
3600 virtual bool Layout(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
);
3602 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;
3604 virtual wxString
GetXMLNodeName() const { return wxT("field"); }
3606 virtual bool CanEditProperties() const;
3608 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
3610 virtual wxString
GetPropertiesMenuLabel() const;
3612 virtual bool AcceptsFocus() const { return false; }
3614 virtual void CalculateRange(long start
, long& end
);
3617 If a field has children, we don't want the user to be able to edit it.
3619 virtual bool IsAtomic() const { return true; }
3621 virtual bool IsEmpty() const { return false; }
3623 virtual bool IsTopLevel() const;
3627 void SetFieldType(const wxString
& fieldType
) { GetProperties().SetProperty(wxT("FieldType"), fieldType
); }
3628 wxString
GetFieldType() const { return GetProperties().GetPropertyString(wxT("FieldType")); }
3633 Update the field; delegated to the associated field type. This would typically expand the field to its value,
3634 if this is a dynamically changing and/or composite field.
3636 virtual bool UpdateField(wxRichTextBuffer
* buffer
);
3638 virtual wxRichTextObject
* Clone() const { return new wxRichTextField(*this); }
3640 void Copy(const wxRichTextField
& obj
);
3646 @class wxRichTextFieldType
3648 The base class for custom field types. Each type definition handles one
3649 field type. Override functions to provide drawing, layout, updating and
3650 property editing functionality for a field.
3652 Register field types on application initialisation with the static function
3653 wxRichTextBuffer::AddFieldType. They will be deleted automatically on
3656 @library{wxrichtext}
3659 @see wxRichTextFieldTypeStandard, wxRichTextField, wxRichTextCtrl
3662 class WXDLLIMPEXP_RICHTEXT wxRichTextFieldType
: public wxObject
3664 DECLARE_CLASS(wxRichTextFieldType
)
3667 Creates a field type definition.
3669 wxRichTextFieldType(const wxString
& name
= wxEmptyString
)
3676 wxRichTextFieldType(const wxRichTextFieldType
& fieldType
)
3677 : wxObject(fieldType
)
3678 { Copy(fieldType
); }
3680 void Copy(const wxRichTextFieldType
& fieldType
) { m_name
= fieldType
.m_name
; }
3683 Draw the item, within the given range. Some objects may ignore the range (for
3684 example paragraphs) while others must obey it (lines, to implement wrapping)
3686 virtual bool Draw(wxRichTextField
* obj
, wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
) = 0;
3689 Lay the item out at the specified position with the given size constraint.
3690 Layout must set the cached size. @rect is the available space for the object,
3691 and @a parentRect is the container that is used to determine a relative size
3692 or position (for example if a text box must be 50% of the parent text box).
3694 virtual bool Layout(wxRichTextField
* obj
, wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
) = 0;
3697 Returns the object size for the given range. Returns @false if the range
3698 is invalid for this object.
3700 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;
3703 Returns @true if we can edit the object's properties via a GUI.
3705 virtual bool CanEditProperties(wxRichTextField
* WXUNUSED(obj
)) const { return false; }
3708 Edits the object's properties via a GUI.
3710 virtual bool EditProperties(wxRichTextField
* WXUNUSED(obj
), wxWindow
* WXUNUSED(parent
), wxRichTextBuffer
* WXUNUSED(buffer
)) { return false; }
3713 Returns the label to be used for the properties context menu item.
3715 virtual wxString
GetPropertiesMenuLabel(wxRichTextField
* WXUNUSED(obj
)) const { return wxEmptyString
; }
3718 Update the field. This would typically expand the field to its value,
3719 if this is a dynamically changing and/or composite field.
3721 virtual bool UpdateField(wxRichTextBuffer
* WXUNUSED(buffer
), wxRichTextField
* WXUNUSED(obj
)) { return false; }
3724 Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box.
3726 virtual bool IsTopLevel(wxRichTextField
* WXUNUSED(obj
)) const { return true; }
3729 Sets the field type name. There should be a unique name per field type object.
3731 void SetName(const wxString
& name
) { m_name
= name
; }
3734 Returns the field type name. There should be a unique name per field type object.
3736 wxString
GetName() const { return m_name
; }
3743 WX_DECLARE_STRING_HASH_MAP(wxRichTextFieldType
*, wxRichTextFieldTypeHashMap
);
3746 @class wxRichTextFieldTypeStandard
3748 A field type that can handle fields with text or bitmap labels, with a small range
3749 of styles for implementing rectangular fields and fields that can be used for start
3752 The border, text and background colours can be customised; the default is
3753 white text on a black background.
3755 The following display styles can be used.
3758 @style{wxRICHTEXT_FIELD_STYLE_COMPOSITE}
3759 Creates a composite field; you will probably need to derive a new class to implement UpdateField.
3760 @style{wxRICHTEXT_FIELD_STYLE_RECTANGLE}
3761 Shows a rounded rectangle background.
3762 @style{wxRICHTEXT_FIELD_STYLE_NO_BORDER}
3763 Suppresses the background and border; mostly used with a bitmap label.
3764 @style{wxRICHTEXT_FIELD_STYLE_START_TAG}
3765 Shows a start tag background, with the pointy end facing right.
3766 @style{wxRICHTEXT_FIELD_STYLE_END_TAG}
3767 Shows an end tag background, with the pointy end facing left.
3770 @library{wxrichtext}
3773 @see wxRichTextFieldType, wxRichTextField, wxRichTextBuffer, wxRichTextCtrl
3776 class WXDLLIMPEXP_RICHTEXT wxRichTextFieldTypeStandard
: public wxRichTextFieldType
3778 DECLARE_CLASS(wxRichTextFieldTypeStandard
)
3781 // Display style types
3782 enum { wxRICHTEXT_FIELD_STYLE_COMPOSITE
= 0x01,
3783 wxRICHTEXT_FIELD_STYLE_RECTANGLE
= 0x02,
3784 wxRICHTEXT_FIELD_STYLE_NO_BORDER
= 0x04,
3785 wxRICHTEXT_FIELD_STYLE_START_TAG
= 0x08,
3786 wxRICHTEXT_FIELD_STYLE_END_TAG
= 0x10
3790 Constructor, creating a field type definition with a text label.
3793 The name of the type definition. This must be unique, and is the type
3794 name used when adding a field to a control.
3796 The text label to be shown on the field.
3798 The display style: one of wxRICHTEXT_FIELD_STYLE_RECTANGLE,
3799 wxRICHTEXT_FIELD_STYLE_NO_BORDER, wxRICHTEXT_FIELD_STYLE_START_TAG,
3800 wxRICHTEXT_FIELD_STYLE_END_TAG.
3803 wxRichTextFieldTypeStandard(const wxString
& name
, const wxString
& label
, int displayStyle
= wxRICHTEXT_FIELD_STYLE_RECTANGLE
);
3806 Constructor, creating a field type definition with a bitmap label.
3809 The name of the type definition. This must be unique, and is the type
3810 name used when adding a field to a control.
3812 The bitmap label to be shown on the field.
3814 The display style: one of wxRICHTEXT_FIELD_STYLE_RECTANGLE,
3815 wxRICHTEXT_FIELD_STYLE_NO_BORDER, wxRICHTEXT_FIELD_STYLE_START_TAG,
3816 wxRICHTEXT_FIELD_STYLE_END_TAG.
3819 wxRichTextFieldTypeStandard(const wxString
& name
, const wxBitmap
& bitmap
, int displayStyle
= wxRICHTEXT_FIELD_STYLE_NO_BORDER
);
3822 The default constructor.
3825 wxRichTextFieldTypeStandard() { Init(); }
3828 The copy constructor.
3831 wxRichTextFieldTypeStandard(const wxRichTextFieldTypeStandard
& field
)
3832 : wxRichTextFieldType(field
)
3836 Initialises the object.
3843 void Copy(const wxRichTextFieldTypeStandard
& field
);
3846 The assignment operator.
3848 void operator=(const wxRichTextFieldTypeStandard
& field
) { Copy(field
); }
3851 Draw the item, within the given range. Some objects may ignore the range (for
3852 example paragraphs) while others must obey it (lines, to implement wrapping)
3854 virtual bool Draw(wxRichTextField
* obj
, wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
3857 Lay the item out at the specified position with the given size constraint.
3858 Layout must set the cached size. @rect is the available space for the object,
3859 and @a parentRect is the container that is used to determine a relative size
3860 or position (for example if a text box must be 50% of the parent text box).
3862 virtual bool Layout(wxRichTextField
* obj
, wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
);
3865 Returns the object size for the given range. Returns @false if the range
3866 is invalid for this object.
3868 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;
3871 Get the size of the field, given the label, font size, and so on.
3873 wxSize
GetSize(wxRichTextField
* obj
, wxDC
& dc
, wxRichTextDrawingContext
& context
, int style
) const;
3876 Returns @true if the display type is wxRICHTEXT_FIELD_STYLE_COMPOSITE, @false otherwise.
3878 virtual bool IsTopLevel(wxRichTextField
* WXUNUSED(obj
)) const { return (GetDisplayStyle() & wxRICHTEXT_FIELD_STYLE_COMPOSITE
) != 0; }
3881 Sets the text label for fields of this type.
3883 void SetLabel(const wxString
& label
) { m_label
= label
; }
3886 Returns the text label for fields of this type.
3888 const wxString
& GetLabel() const { return m_label
; }
3891 Sets the bitmap label for fields of this type.
3893 void SetBitmap(const wxBitmap
& bitmap
) { m_bitmap
= bitmap
; }
3896 Gets the bitmap label for fields of this type.
3898 const wxBitmap
& GetBitmap() const { return m_bitmap
; }
3901 Gets the display style for fields of this type.
3903 int GetDisplayStyle() const { return m_displayStyle
; }
3906 Sets the display style for fields of this type.
3908 void SetDisplayStyle(int displayStyle
) { m_displayStyle
= displayStyle
; }
3911 Gets the font used for drawing the text label.
3913 const wxFont
& GetFont() const { return m_font
; }
3916 Sets the font used for drawing the text label.
3918 void SetFont(const wxFont
& font
) { m_font
= font
; }
3921 Gets the colour used for drawing the text label.
3923 const wxColour
& GetTextColour() const { return m_textColour
; }
3926 Sets the colour used for drawing the text label.
3928 void SetTextColour(const wxColour
& colour
) { m_textColour
= colour
; }
3931 Gets the colour used for drawing the field border.
3933 const wxColour
& GetBorderColour() const { return m_borderColour
; }
3936 Sets the colour used for drawing the field border.
3938 void SetBorderColour(const wxColour
& colour
) { m_borderColour
= colour
; }
3941 Gets the colour used for drawing the field background.
3943 const wxColour
& GetBackgroundColour() const { return m_backgroundColour
; }
3946 Sets the colour used for drawing the field background.
3948 void SetBackgroundColour(const wxColour
& colour
) { m_backgroundColour
= colour
; }
3951 Sets the vertical padding (the distance between the border and the text).
3953 void SetVerticalPadding(int padding
) { m_verticalPadding
= padding
; }
3956 Gets the vertical padding (the distance between the border and the text).
3958 int GetVerticalPadding() const { return m_verticalPadding
; }
3961 Sets the horizontal padding (the distance between the border and the text).
3963 void SetHorizontalPadding(int padding
) { m_horizontalPadding
= padding
; }
3966 Sets the horizontal padding (the distance between the border and the text).
3968 int GetHorizontalPadding() const { return m_horizontalPadding
; }
3971 Sets the horizontal margin surrounding the field object.
3973 void SetHorizontalMargin(int margin
) { m_horizontalMargin
= margin
; }
3976 Gets the horizontal margin surrounding the field object.
3978 int GetHorizontalMargin() const { return m_horizontalMargin
; }
3981 Sets the vertical margin surrounding the field object.
3983 void SetVerticalMargin(int margin
) { m_verticalMargin
= margin
; }
3986 Gets the vertical margin surrounding the field object.
3988 int GetVerticalMargin() const { return m_verticalMargin
; }
3995 wxColour m_textColour
;
3996 wxColour m_borderColour
;
3997 wxColour m_backgroundColour
;
3998 int m_verticalPadding
;
3999 int m_horizontalPadding
;
4000 int m_horizontalMargin
;
4001 int m_verticalMargin
;
4006 @class wxRichTextLine
4008 This object represents a line in a paragraph, and stores
4009 offsets from the start of the paragraph representing the
4010 start and end positions of the line.
4012 @library{wxrichtext}
4015 @see wxRichTextBuffer, wxRichTextCtrl
4018 class WXDLLIMPEXP_RICHTEXT wxRichTextLine
4023 wxRichTextLine(wxRichTextParagraph
* parent
);
4024 wxRichTextLine(const wxRichTextLine
& obj
) { Init( NULL
); Copy(obj
); }
4025 virtual ~wxRichTextLine() {}
4032 Sets the range associated with this line.
4034 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
4036 Sets the range associated with this line.
4038 void SetRange(long from
, long to
) { m_range
= wxRichTextRange(from
, to
); }
4041 Returns the parent paragraph.
4043 wxRichTextParagraph
* GetParent() { return m_parent
; }
4048 const wxRichTextRange
& GetRange() const { return m_range
; }
4052 wxRichTextRange
& GetRange() { return m_range
; }
4055 Returns the absolute range.
4057 wxRichTextRange
GetAbsoluteRange() const;
4060 Returns the line size as calculated by Layout.
4062 virtual wxSize
GetSize() const { return m_size
; }
4065 Sets the line size as calculated by Layout.
4067 virtual void SetSize(const wxSize
& sz
) { m_size
= sz
; }
4070 Returns the object position relative to the parent.
4072 virtual wxPoint
GetPosition() const { return m_pos
; }
4075 Sets the object position relative to the parent.
4077 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
4080 Returns the absolute object position.
4082 virtual wxPoint
GetAbsolutePosition() const;
4085 Returns the rectangle enclosing the line.
4087 virtual wxRect
GetRect() const { return wxRect(GetAbsolutePosition(), GetSize()); }
4090 Sets the stored descent.
4092 void SetDescent(int descent
) { m_descent
= descent
; }
4095 Returns the stored descent.
4097 int GetDescent() const { return m_descent
; }
4099 #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING
4100 wxArrayInt
& GetObjectSizes() { return m_objectSizes
; }
4101 const wxArrayInt
& GetObjectSizes() const { return m_objectSizes
; }
4107 Initialises the object.
4109 void Init(wxRichTextParagraph
* parent
);
4114 void Copy(const wxRichTextLine
& obj
);
4116 virtual wxRichTextLine
* Clone() const { return new wxRichTextLine(*this); }
4120 // The range of the line (start position to end position)
4121 // This is relative to the parent paragraph.
4122 wxRichTextRange m_range
;
4124 // Size and position measured relative to top of paragraph
4128 // Maximum descent for this line (location of text baseline)
4131 // The parent object
4132 wxRichTextParagraph
* m_parent
;
4134 #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING
4135 wxArrayInt m_objectSizes
;
4139 WX_DECLARE_LIST_WITH_DECL( wxRichTextLine
, wxRichTextLineList
, class WXDLLIMPEXP_RICHTEXT
);
4142 @class wxRichTextParagraph
4144 This object represents a single paragraph containing various objects such as text content, images, and further paragraph layout objects.
4146 @library{wxrichtext}
4149 @see wxRichTextBuffer, wxRichTextCtrl
4152 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph
: public wxRichTextCompositeObject
4154 DECLARE_DYNAMIC_CLASS(wxRichTextParagraph
)
4159 Constructor taking a parent and style.
4161 wxRichTextParagraph(wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* style
= NULL
);
4163 Constructor taking a text string, a parent and paragraph and character attributes.
4165 wxRichTextParagraph(const wxString
& text
, wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* paraStyle
= NULL
, wxRichTextAttr
* charStyle
= NULL
);
4166 virtual ~wxRichTextParagraph();
4167 wxRichTextParagraph(const wxRichTextParagraph
& obj
): wxRichTextCompositeObject() { Copy(obj
); }
4171 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
4173 virtual bool Layout(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
);
4175 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;
4177 virtual bool FindPosition(wxDC
& dc
, wxRichTextDrawingContext
& context
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
4179 virtual int HitTest(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
4181 virtual void CalculateRange(long start
, long& end
);
4183 virtual wxString
GetXMLNodeName() const { return wxT("paragraph"); }
4188 Returns the cached lines.
4190 wxRichTextLineList
& GetLines() { return m_cachedLines
; }
4197 void Copy(const wxRichTextParagraph
& obj
);
4199 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraph(*this); }
4202 Clears the cached lines.
4209 Applies paragraph styles such as centering to the wrapped lines.
4211 virtual void ApplyParagraphStyle(wxRichTextLine
* line
, const wxRichTextAttr
& attr
, const wxRect
& rect
, wxDC
& dc
);
4214 Inserts text at the given position.
4216 virtual bool InsertText(long pos
, const wxString
& text
);
4219 Splits an object at this position if necessary, and returns
4220 the previous object, or NULL if inserting at the beginning.
4222 virtual wxRichTextObject
* SplitAt(long pos
, wxRichTextObject
** previousObject
= NULL
);
4225 Moves content to a list from this point.
4227 virtual void MoveToList(wxRichTextObject
* obj
, wxList
& list
);
4230 Adds content back from a list.
4232 virtual void MoveFromList(wxList
& list
);
4235 Returns the plain text searching from the start or end of the range.
4236 The resulting string may be shorter than the range given.
4238 bool GetContiguousPlainText(wxString
& text
, const wxRichTextRange
& range
, bool fromStart
= true);
4241 Finds a suitable wrap position. @a wrapPosition is the last position in the line to the left
4244 bool FindWrapPosition(const wxRichTextRange
& range
, wxDC
& dc
, wxRichTextDrawingContext
& context
, int availableSpace
, long& wrapPosition
, wxArrayInt
* partialExtents
);
4247 Finds the object at the given position.
4249 wxRichTextObject
* FindObjectAtPosition(long position
);
4252 Returns the bullet text for this paragraph.
4254 wxString
GetBulletText();
4257 Allocates or reuses a line object.
4259 wxRichTextLine
* AllocateLine(int pos
);
4262 Clears remaining unused line objects, if any.
4264 bool ClearUnusedLines(int lineCount
);
4267 Returns combined attributes of the base style, paragraph style and character style. We use this to dynamically
4268 retrieve the actual style.
4270 wxRichTextAttr
GetCombinedAttributes(const wxRichTextAttr
& contentStyle
, bool includingBoxAttr
= false) const;
4273 Returns the combined attributes of the base style and paragraph style.
4275 wxRichTextAttr
GetCombinedAttributes(bool includingBoxAttr
= false) const;
4278 Returns the first position from pos that has a line break character.
4280 long GetFirstLineBreakPosition(long pos
);
4283 Creates a default tabstop array.
4285 static void InitDefaultTabs();
4288 Clears the default tabstop array.
4290 static void ClearDefaultTabs();
4293 Returns the default tabstop array.
4295 static const wxArrayInt
& GetDefaultTabs() { return sm_defaultTabs
; }
4298 Lays out the floating objects.
4300 void LayoutFloat(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
, wxRichTextFloatCollector
* floatCollector
);
4304 // The lines that make up the wrapped paragraph
4305 wxRichTextLineList m_cachedLines
;
4308 static wxArrayInt sm_defaultTabs
;
4310 friend class wxRichTextFloatCollector
;
4314 @class wxRichTextPlainText
4316 This object represents a single piece of text.
4318 @library{wxrichtext}
4321 @see wxRichTextBuffer, wxRichTextCtrl
4324 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText
: public wxRichTextObject
4326 DECLARE_DYNAMIC_CLASS(wxRichTextPlainText
)
4333 wxRichTextPlainText(const wxString
& text
= wxEmptyString
, wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* style
= NULL
);
4338 wxRichTextPlainText(const wxRichTextPlainText
& obj
): wxRichTextObject() { Copy(obj
); }
4342 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
4344 virtual bool Layout(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
);
4346 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;
4348 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
4350 virtual wxRichTextObject
* DoSplit(long pos
);
4352 virtual void CalculateRange(long start
, long& end
);
4354 virtual bool DeleteRange(const wxRichTextRange
& range
);
4356 virtual bool IsEmpty() const { return m_text
.empty(); }
4358 virtual bool CanMerge(wxRichTextObject
* object
, wxRichTextDrawingContext
& context
) const;
4360 virtual bool Merge(wxRichTextObject
* object
, wxRichTextDrawingContext
& context
);
4362 virtual void Dump(wxTextOutputStream
& stream
);
4364 virtual bool CanSplit(wxRichTextDrawingContext
& context
) const;
4366 virtual wxRichTextObject
* Split(wxRichTextDrawingContext
& context
);
4369 Get the first position from pos that has a line break character.
4371 long GetFirstLineBreakPosition(long pos
);
4373 /// Does this object take note of paragraph attributes? Text and image objects don't.
4374 virtual bool UsesParagraphAttributes() const { return false; }
4377 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
4380 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
4381 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
4384 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
4385 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
4388 virtual wxString
GetXMLNodeName() const { return wxT("text"); }
4395 const wxString
& GetText() const { return m_text
; }
4400 void SetText(const wxString
& text
) { m_text
= text
; }
4404 // Copies the text object,
4405 void Copy(const wxRichTextPlainText
& obj
);
4407 // Clones the text object.
4408 virtual wxRichTextObject
* Clone() const { return new wxRichTextPlainText(*this); }
4411 bool DrawTabbedString(wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
, wxString
& str
, wxCoord
& x
, wxCoord
& y
, bool selected
);
4418 @class wxRichTextImageBlock
4420 This class stores information about an image, in binary in-memory form.
4422 @library{wxrichtext}
4425 @see wxRichTextBuffer, wxRichTextCtrl
4428 class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock
: public wxObject
4434 wxRichTextImageBlock();
4439 wxRichTextImageBlock(const wxRichTextImageBlock
& block
);
4440 virtual ~wxRichTextImageBlock();
4443 Initialises the block.
4454 Load the original image into a memory block.
4455 If the image is not a JPEG, we must convert it into a JPEG
4457 If it's not a JPEG we can make use of @a image, already scaled, so we don't have to
4458 load the image a second time.
4460 virtual bool MakeImageBlock(const wxString
& filename
, wxBitmapType imageType
,
4461 wxImage
& image
, bool convertToJPEG
= true);
4464 Make an image block from the wxImage in the given
4467 virtual bool MakeImageBlock(wxImage
& image
, wxBitmapType imageType
, int quality
= 80);
4470 Uses a const wxImage for efficiency, but can't set quality (only relevant for JPEG)
4472 virtual bool MakeImageBlockDefaultQuality(const wxImage
& image
, wxBitmapType imageType
);
4475 Makes the image block.
4477 virtual bool DoMakeImageBlock(const wxImage
& image
, wxBitmapType imageType
);
4480 Writes the block to a file.
4482 bool Write(const wxString
& filename
);
4485 Writes the data in hex to a stream.
4487 bool WriteHex(wxOutputStream
& stream
);
4490 Reads the data in hex from a stream.
4492 bool ReadHex(wxInputStream
& stream
, int length
, wxBitmapType imageType
);
4497 void Copy(const wxRichTextImageBlock
& block
);
4499 // Load a wxImage from the block
4502 bool Load(wxImage
& image
);
4507 Assignment operation.
4509 void operator=(const wxRichTextImageBlock
& block
);
4514 Returns the raw data.
4516 unsigned char* GetData() const { return m_data
; }
4519 Returns the data size in bytes.
4521 size_t GetDataSize() const { return m_dataSize
; }
4524 Returns the image type.
4526 wxBitmapType
GetImageType() const { return m_imageType
; }
4530 void SetData(unsigned char* image
) { m_data
= image
; }
4535 void SetDataSize(size_t size
) { m_dataSize
= size
; }
4538 Sets the image type.
4540 void SetImageType(wxBitmapType imageType
) { m_imageType
= imageType
; }
4543 Returns @true if the data is non-NULL.
4545 bool IsOk() const { return GetData() != NULL
; }
4546 bool Ok() const { return IsOk(); }
4549 Gets the extension for the block's type.
4551 wxString
GetExtension() const;
4556 Allocates and reads from a stream as a block of memory.
4558 static unsigned char* ReadBlock(wxInputStream
& stream
, size_t size
);
4561 Allocates and reads from a file as a block of memory.
4563 static unsigned char* ReadBlock(const wxString
& filename
, size_t size
);
4566 Writes a memory block to stream.
4568 static bool WriteBlock(wxOutputStream
& stream
, unsigned char* block
, size_t size
);
4571 Writes a memory block to a file.
4573 static bool WriteBlock(const wxString
& filename
, unsigned char* block
, size_t size
);
4576 // Size in bytes of the image stored.
4577 // This is in the raw, original form such as a JPEG file.
4578 unsigned char* m_data
;
4580 wxBitmapType m_imageType
;
4584 @class wxRichTextImage
4586 This class implements a graphic object.
4588 @library{wxrichtext}
4591 @see wxRichTextBuffer, wxRichTextCtrl, wxRichTextImageBlock
4594 class WXDLLIMPEXP_RICHTEXT wxRichTextImage
: public wxRichTextObject
4596 DECLARE_DYNAMIC_CLASS(wxRichTextImage
)
4601 Default constructor.
4603 wxRichTextImage(wxRichTextObject
* parent
= NULL
): wxRichTextObject(parent
) { Init(); }
4606 Creates a wxRichTextImage from a wxImage.
4608 wxRichTextImage(const wxImage
& image
, wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* charStyle
= NULL
);
4611 Creates a wxRichTextImage from an image block.
4613 wxRichTextImage(const wxRichTextImageBlock
& imageBlock
, wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* charStyle
= NULL
);
4618 wxRichTextImage(const wxRichTextImage
& obj
): wxRichTextObject(obj
) { Copy(obj
); }
4632 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
4634 virtual bool Layout(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
);
4636 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;
4639 Returns the 'natural' size for this object - the image size.
4641 virtual wxTextAttrSize
GetNaturalSize() const;
4643 virtual bool IsEmpty() const { return false; /* !m_imageBlock.IsOk(); */ }
4645 virtual bool CanEditProperties() const { return true; }
4647 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
4649 virtual wxString
GetPropertiesMenuLabel() const { return _("&Picture"); }
4651 virtual bool UsesParagraphAttributes() const { return false; }
4654 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
4657 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
4658 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
4661 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
4662 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
4665 // Images can be floatable (optionally).
4666 virtual bool IsFloatable() const { return true; }
4668 virtual wxString
GetXMLNodeName() const { return wxT("image"); }
4673 Returns the image cache (a scaled bitmap).
4675 const wxBitmap
& GetImageCache() const { return m_imageCache
; }
4678 Sets the image cache.
4680 void SetImageCache(const wxBitmap
& bitmap
) { m_imageCache
= bitmap
; m_originalImageSize
= wxSize(bitmap
.GetWidth(), bitmap
.GetHeight()); }
4683 Resets the image cache.
4685 void ResetImageCache() { m_imageCache
= wxNullBitmap
; m_originalImageSize
= wxSize(-1, -1); }
4688 Returns the image block containing the raw data.
4690 wxRichTextImageBlock
& GetImageBlock() { return m_imageBlock
; }
4695 Copies the image object.
4697 void Copy(const wxRichTextImage
& obj
);
4700 Clones the image object.
4702 virtual wxRichTextObject
* Clone() const { return new wxRichTextImage(*this); }
4705 Creates a cached image at the required size.
4707 virtual bool LoadImageCache(wxDC
& dc
, bool resetCache
= false, const wxSize
& parentSize
= wxDefaultSize
);
4710 Gets the original image size.
4712 wxSize
GetOriginalImageSize() const { return m_originalImageSize
; }
4715 Sets the original image size.
4717 void SetOriginalImageSize(const wxSize
& sz
) { m_originalImageSize
= sz
; }
4720 wxRichTextImageBlock m_imageBlock
;
4721 wxBitmap m_imageCache
;
4722 wxSize m_originalImageSize
;
4725 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCommand
;
4726 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction
;
4729 @class wxRichTextBuffer
4731 This is a kind of paragraph layout box, used to represent the whole buffer.
4733 @library{wxrichtext}
4736 @see wxRichTextParagraphLayoutBox, wxRichTextCtrl
4739 class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer
: public wxRichTextParagraphLayoutBox
4741 DECLARE_DYNAMIC_CLASS(wxRichTextBuffer
)
4746 Default constructor.
4748 wxRichTextBuffer() { Init(); }
4753 wxRichTextBuffer(const wxRichTextBuffer
& obj
): wxRichTextParagraphLayoutBox() { Init(); Copy(obj
); }
4755 virtual ~wxRichTextBuffer() ;
4760 Returns the command processor.
4761 A text buffer always creates its own command processor when it is initialized.
4763 wxCommandProcessor
* GetCommandProcessor() const { return m_commandProcessor
; }
4766 Sets style sheet, if any. This will allow the application to use named character and paragraph
4767 styles found in the style sheet.
4769 Neither the buffer nor the control owns the style sheet so must be deleted by the application.
4771 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
) { m_styleSheet
= styleSheet
; }
4774 Returns the style sheet.
4776 virtual wxRichTextStyleSheet
* GetStyleSheet() const { return m_styleSheet
; }
4779 Sets the style sheet and sends a notification of the change.
4781 bool SetStyleSheetAndNotify(wxRichTextStyleSheet
* sheet
);
4784 Pushes the style sheet to the top of the style sheet stack.
4786 bool PushStyleSheet(wxRichTextStyleSheet
* styleSheet
);
4789 Pops the style sheet from the top of the style sheet stack.
4791 wxRichTextStyleSheet
* PopStyleSheet();
4794 Returns the table storing fonts, for quick access and font reuse.
4796 wxRichTextFontTable
& GetFontTable() { return m_fontTable
; }
4799 Returns the table storing fonts, for quick access and font reuse.
4801 const wxRichTextFontTable
& GetFontTable() const { return m_fontTable
; }
4804 Sets table storing fonts, for quick access and font reuse.
4806 void SetFontTable(const wxRichTextFontTable
& table
) { m_fontTable
= table
; }
4809 Sets the scale factor for displaying fonts, for example for more comfortable
4812 void SetFontScale(double fontScale
);
4815 Returns the scale factor for displaying fonts, for example for more comfortable
4818 double GetFontScale() const { return m_fontScale
; }
4821 Sets the scale factor for displaying certain dimensions such as indentation and
4822 inter-paragraph spacing. This can be useful when editing in a small control
4823 where you still want legible text, but a minimum of wasted white space.
4825 void SetDimensionScale(double dimScale
);
4828 Returns the scale factor for displaying certain dimensions such as indentation
4829 and inter-paragraph spacing.
4831 double GetDimensionScale() const { return m_dimensionScale
; }
4841 Clears the buffer, adds an empty paragraph, and clears the command processor.
4843 virtual void ResetAndClearCommands();
4847 Loads content from a stream or file.
4848 Not all handlers will implement file loading.
4850 virtual bool LoadFile(const wxString
& filename
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
4851 virtual bool LoadFile(wxInputStream
& stream
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
4856 Saves content to a stream or file.
4857 Not all handlers will implement file saving.
4859 virtual bool SaveFile(const wxString
& filename
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
4860 virtual bool SaveFile(wxOutputStream
& stream
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
4864 Sets the handler flags, controlling loading and saving.
4866 void SetHandlerFlags(int flags
) { m_handlerFlags
= flags
; }
4869 Gets the handler flags, controlling loading and saving.
4871 int GetHandlerFlags() const { return m_handlerFlags
; }
4874 Convenience function to add a paragraph of text.
4876 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxRichTextAttr
* paraStyle
= NULL
) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text
, paraStyle
); }
4879 Begin collapsing undo/redo commands. Note that this may not work properly
4880 if combining commands that delete or insert content, changing ranges for
4883 @a cmdName should be the name of the combined command that will appear
4884 next to Undo and Redo in the edit menu.
4886 virtual bool BeginBatchUndo(const wxString
& cmdName
);
4889 End collapsing undo/redo commands.
4891 virtual bool EndBatchUndo();
4894 Returns @true if we are collapsing commands.
4896 virtual bool BatchingUndo() const { return m_batchedCommandDepth
> 0; }
4899 Submit the action immediately, or delay according to whether collapsing is on.
4901 virtual bool SubmitAction(wxRichTextAction
* action
);
4904 Returns the collapsed command.
4906 virtual wxRichTextCommand
* GetBatchedCommand() const { return m_batchedCommand
; }
4909 Begin suppressing undo/redo commands. The way undo is suppressed may be implemented
4910 differently by each command. If not dealt with by a command implementation, then
4911 it will be implemented automatically by not storing the command in the undo history
4912 when the action is submitted to the command processor.
4914 virtual bool BeginSuppressUndo();
4917 End suppressing undo/redo commands.
4919 virtual bool EndSuppressUndo();
4922 Are we suppressing undo??
4924 virtual bool SuppressingUndo() const { return m_suppressUndo
> 0; }
4927 Copy the range to the clipboard.
4929 virtual bool CopyToClipboard(const wxRichTextRange
& range
);
4932 Paste the clipboard content to the buffer.
4934 virtual bool PasteFromClipboard(long position
);
4937 Returns @true if we can paste from the clipboard.
4939 virtual bool CanPasteFromClipboard() const;
4942 Begin using a style.
4944 virtual bool BeginStyle(const wxRichTextAttr
& style
);
4949 virtual bool EndStyle();
4954 virtual bool EndAllStyles();
4957 Clears the style stack.
4959 virtual void ClearStyleStack();
4962 Returns the size of the style stack, for example to check correct nesting.
4964 virtual size_t GetStyleStackSize() const { return m_attributeStack
.GetCount(); }
4974 bool EndBold() { return EndStyle(); }
4977 Begins using italic.
4984 bool EndItalic() { return EndStyle(); }
4987 Begins using underline.
4989 bool BeginUnderline();
4992 Ends using underline.
4994 bool EndUnderline() { return EndStyle(); }
4997 Begins using point size.
4999 bool BeginFontSize(int pointSize
);
5002 Ends using point size.
5004 bool EndFontSize() { return EndStyle(); }
5007 Begins using this font.
5009 bool BeginFont(const wxFont
& font
);
5014 bool EndFont() { return EndStyle(); }
5017 Begins using this colour.
5019 bool BeginTextColour(const wxColour
& colour
);
5022 Ends using a colour.
5024 bool EndTextColour() { return EndStyle(); }
5027 Begins using alignment.
5029 bool BeginAlignment(wxTextAttrAlignment alignment
);
5034 bool EndAlignment() { return EndStyle(); }
5037 Begins using @a leftIndent for the left indent, and optionally @a leftSubIndent for
5038 the sub-indent. Both are expressed in tenths of a millimetre.
5040 The sub-indent is an offset from the left of the paragraph, and is used for all
5041 but the first line in a paragraph. A positive value will cause the first line to appear
5042 to the left of the subsequent lines, and a negative value will cause the first line to be
5043 indented relative to the subsequent lines.
5045 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
5050 bool EndLeftIndent() { return EndStyle(); }
5053 Begins a right indent, specified in tenths of a millimetre.
5055 bool BeginRightIndent(int rightIndent
);
5060 bool EndRightIndent() { return EndStyle(); }
5063 Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing
5064 in tenths of a millimetre.
5066 bool BeginParagraphSpacing(int before
, int after
);
5069 Ends paragraph spacing.
5071 bool EndParagraphSpacing() { return EndStyle(); }
5074 Begins line spacing using the specified value. @e spacing is a multiple, where
5075 10 means single-spacing, 15 means 1.5 spacing, and 20 means double spacing.
5077 The ::wxTextAttrLineSpacing enumeration values are defined for convenience.
5079 bool BeginLineSpacing(int lineSpacing
);
5084 bool EndLineSpacing() { return EndStyle(); }
5087 Begins numbered bullet.
5089 This call will be needed for each item in the list, and the
5090 application should take care of incrementing the numbering.
5092 @a bulletNumber is a number, usually starting with 1.
5093 @a leftIndent and @a leftSubIndent are values in tenths of a millimetre.
5094 @a bulletStyle is a bitlist of the following values:
5096 wxRichTextBuffer uses indentation to render a bulleted item.
5097 The left indent is the distance between the margin and the bullet.
5098 The content of the paragraph, including the first line, starts
5099 at leftMargin + leftSubIndent.
5100 So the distance between the left edge of the bullet and the
5101 left of the actual paragraph is leftSubIndent.
5103 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
5106 Ends numbered bullet.
5108 bool EndNumberedBullet() { return EndStyle(); }
5111 Begins applying a symbol bullet, using a character from the current font.
5113 See BeginNumberedBullet() for an explanation of how indentation is used
5114 to render the bulleted paragraph.
5116 bool BeginSymbolBullet(const wxString
& symbol
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
5121 bool EndSymbolBullet() { return EndStyle(); }
5124 Begins applying a standard bullet, using one of the standard bullet names
5125 (currently @c standard/circle or @c standard/square.
5127 See BeginNumberedBullet() for an explanation of how indentation is used to
5128 render the bulleted paragraph.
5130 bool BeginStandardBullet(const wxString
& bulletName
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_STANDARD
);
5133 Ends standard bullet.
5135 bool EndStandardBullet() { return EndStyle(); }
5138 Begins named character style.
5140 bool BeginCharacterStyle(const wxString
& characterStyle
);
5143 Ends named character style.
5145 bool EndCharacterStyle() { return EndStyle(); }
5148 Begins named paragraph style.
5150 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
5153 Ends named character style.
5155 bool EndParagraphStyle() { return EndStyle(); }
5158 Begins named list style.
5160 Optionally, you can also pass a level and a number.
5162 bool BeginListStyle(const wxString
& listStyle
, int level
= 1, int number
= 1);
5165 Ends named character style.
5167 bool EndListStyle() { return EndStyle(); }
5170 Begins applying wxTEXT_ATTR_URL to the content.
5172 Pass a URL and optionally, a character style to apply, since it is common
5173 to mark a URL with a familiar style such as blue text with underlining.
5175 bool BeginURL(const wxString
& url
, const wxString
& characterStyle
= wxEmptyString
);
5180 bool EndURL() { return EndStyle(); }
5185 Adds an event handler.
5187 A buffer associated with a control has the control as the only event handler,
5188 but the application is free to add more if further notification is required.
5189 All handlers are notified of an event originating from the buffer, such as
5190 the replacement of a style sheet during loading.
5192 The buffer never deletes any of the event handlers, unless RemoveEventHandler()
5193 is called with @true as the second argument.
5195 bool AddEventHandler(wxEvtHandler
* handler
);
5198 Removes an event handler from the buffer's list of handlers, deleting the
5199 object if @a deleteHandler is @true.
5201 bool RemoveEventHandler(wxEvtHandler
* handler
, bool deleteHandler
= false);
5204 Clear event handlers.
5206 void ClearEventHandlers();
5209 Send event to event handlers. If sendToAll is true, will send to all event handlers,
5210 otherwise will stop at the first successful one.
5212 bool SendEvent(wxEvent
& event
, bool sendToAll
= true);
5216 virtual int HitTest(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
5221 void Copy(const wxRichTextBuffer
& obj
);
5224 Assignment operator.
5226 void operator= (const wxRichTextBuffer
& obj
) { Copy(obj
); }
5231 virtual wxRichTextObject
* Clone() const { return new wxRichTextBuffer(*this); }
5234 Submits a command to insert paragraphs.
5236 bool InsertParagraphsWithUndo(long pos
, const wxRichTextParagraphLayoutBox
& paragraphs
, wxRichTextCtrl
* ctrl
, int flags
= 0);
5239 Submits a command to insert the given text.
5241 bool InsertTextWithUndo(long pos
, const wxString
& text
, wxRichTextCtrl
* ctrl
, int flags
= 0);
5244 Submits a command to insert a newline.
5246 bool InsertNewlineWithUndo(long pos
, wxRichTextCtrl
* ctrl
, int flags
= 0);
5249 Submits a command to insert the given image.
5251 bool InsertImageWithUndo(long pos
, const wxRichTextImageBlock
& imageBlock
, wxRichTextCtrl
* ctrl
, int flags
= 0,
5252 const wxRichTextAttr
& textAttr
= wxRichTextAttr());
5255 Submits a command to insert an object.
5257 wxRichTextObject
* InsertObjectWithUndo(long pos
, wxRichTextObject
*object
, wxRichTextCtrl
* ctrl
, int flags
);
5260 Submits a command to delete this range.
5262 bool DeleteRangeWithUndo(const wxRichTextRange
& range
, wxRichTextCtrl
* ctrl
);
5267 void Modify(bool modify
= true) { m_modified
= modify
; }
5270 Returns @true if the buffer was modified.
5272 bool IsModified() const { return m_modified
; }
5276 Dumps contents of buffer for debugging purposes.
5278 virtual void Dump();
5279 virtual void Dump(wxTextOutputStream
& stream
) { wxRichTextParagraphLayoutBox::Dump(stream
); }
5283 Returns the file handlers.
5285 static wxList
& GetHandlers() { return sm_handlers
; }
5288 Adds a file handler to the end.
5290 static void AddHandler(wxRichTextFileHandler
*handler
);
5293 Inserts a file handler at the front.
5295 static void InsertHandler(wxRichTextFileHandler
*handler
);
5298 Removes a file handler.
5300 static bool RemoveHandler(const wxString
& name
);
5303 Finds a file handler by name.
5305 static wxRichTextFileHandler
*FindHandler(const wxString
& name
);
5308 Finds a file handler by extension and type.
5310 static wxRichTextFileHandler
*FindHandler(const wxString
& extension
, wxRichTextFileType imageType
);
5313 Finds a handler by filename or, if supplied, type.
5315 static wxRichTextFileHandler
*FindHandlerFilenameOrType(const wxString
& filename
,
5316 wxRichTextFileType imageType
);
5319 Finds a handler by type.
5321 static wxRichTextFileHandler
*FindHandler(wxRichTextFileType imageType
);
5324 Gets a wildcard incorporating all visible handlers. If @a types is present,
5325 it will be filled with the file type corresponding to each filter. This can be
5326 used to determine the type to pass to LoadFile given a selected filter.
5328 static wxString
GetExtWildcard(bool combine
= false, bool save
= false, wxArrayInt
* types
= NULL
);
5331 Clean up file handlers.
5333 static void CleanUpHandlers();
5336 Initialise the standard file handlers.
5337 Currently, only the plain text loading/saving handler is initialised by default.
5339 static void InitStandardHandlers();
5342 Returns the drawing handlers.
5344 static wxList
& GetDrawingHandlers() { return sm_drawingHandlers
; }
5347 Adds a drawing handler to the end.
5349 static void AddDrawingHandler(wxRichTextDrawingHandler
*handler
);
5352 Inserts a drawing handler at the front.
5354 static void InsertDrawingHandler(wxRichTextDrawingHandler
*handler
);
5357 Removes a drawing handler.
5359 static bool RemoveDrawingHandler(const wxString
& name
);
5362 Finds a drawing handler by name.
5364 static wxRichTextDrawingHandler
*FindDrawingHandler(const wxString
& name
);
5367 Clean up drawing handlers.
5369 static void CleanUpDrawingHandlers();
5372 Returns the field types.
5374 static wxRichTextFieldTypeHashMap
& GetFieldTypes() { return sm_fieldTypes
; }
5379 @see RemoveFieldType(), FindFieldType(), wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard
5382 static void AddFieldType(wxRichTextFieldType
*fieldType
);
5385 Removes a field type by name.
5387 @see AddFieldType(), FindFieldType(), wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard
5389 static bool RemoveFieldType(const wxString
& name
);
5392 Finds a field type by name.
5394 @see RemoveFieldType(), AddFieldType(), wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard
5396 static wxRichTextFieldType
*FindFieldType(const wxString
& name
);
5399 Cleans up field types.
5401 static void CleanUpFieldTypes();
5404 Returns the renderer object.
5406 static wxRichTextRenderer
* GetRenderer() { return sm_renderer
; }
5409 Sets @a renderer as the object to be used to render certain aspects of the
5410 content, such as bullets.
5412 You can override default rendering by deriving a new class from
5413 wxRichTextRenderer or wxRichTextStdRenderer, overriding one or more
5414 virtual functions, and setting an instance of the class using this function.
5416 static void SetRenderer(wxRichTextRenderer
* renderer
);
5419 Returns the minimum margin between bullet and paragraph in 10ths of a mm.
5421 static int GetBulletRightMargin() { return sm_bulletRightMargin
; }
5424 Sets the minimum margin between bullet and paragraph in 10ths of a mm.
5426 static void SetBulletRightMargin(int margin
) { sm_bulletRightMargin
= margin
; }
5429 Returns the factor to multiply by character height to get a reasonable bullet size.
5431 static float GetBulletProportion() { return sm_bulletProportion
; }
5434 Sets the factor to multiply by character height to get a reasonable bullet size.
5436 static void SetBulletProportion(float prop
) { sm_bulletProportion
= prop
; }
5439 Returns the scale factor for calculating dimensions.
5441 double GetScale() const { return m_scale
; }
5444 Sets the scale factor for calculating dimensions.
5446 void SetScale(double scale
) { m_scale
= scale
; }
5449 Sets the floating layout mode. Pass @false to speed up editing by not performing
5450 floating layout. This setting affects all buffers.
5453 static void SetFloatingLayoutMode(bool mode
) { sm_floatingLayoutMode
= mode
; }
5456 Returns the floating layout mode. The default is @true, where objects
5457 are laid out according to their floating status.
5459 static bool GetFloatingLayoutMode() { return sm_floatingLayoutMode
; }
5463 /// Command processor
5464 wxCommandProcessor
* m_commandProcessor
;
5466 /// Table storing fonts
5467 wxRichTextFontTable m_fontTable
;
5469 /// Has been modified?
5472 /// Collapsed command stack
5473 int m_batchedCommandDepth
;
5475 /// Name for collapsed command
5476 wxString m_batchedCommandsName
;
5478 /// Current collapsed command accumulating actions
5479 wxRichTextCommand
* m_batchedCommand
;
5481 /// Whether to suppress undo
5484 /// Style sheet, if any
5485 wxRichTextStyleSheet
* m_styleSheet
;
5487 /// List of event handlers that will be notified of events
5488 wxList m_eventHandlers
;
5490 /// Stack of attributes for convenience functions
5491 wxList m_attributeStack
;
5493 /// Flags to be passed to handlers
5497 static wxList sm_handlers
;
5499 /// Drawing handlers
5500 static wxList sm_drawingHandlers
;
5503 static wxRichTextFieldTypeHashMap sm_fieldTypes
;
5506 static wxRichTextRenderer
* sm_renderer
;
5508 /// Minimum margin between bullet and paragraph in 10ths of a mm
5509 static int sm_bulletRightMargin
;
5511 /// Factor to multiply by character height to get a reasonable bullet size
5512 static float sm_bulletProportion
;
5514 /// Floating layout mode, @true by default
5515 static bool sm_floatingLayoutMode
;
5517 /// Scaling factor in use: needed to calculate correct dimensions when printing
5520 /// Font scale for adjusting the text size when editing
5523 /// Dimension scale for reducing redundant whitespace when editing
5524 double m_dimensionScale
;
5528 @class wxRichTextCell
5530 wxRichTextCell is the cell in a table.
5533 class WXDLLIMPEXP_RICHTEXT wxRichTextCell
: public wxRichTextBox
5535 DECLARE_DYNAMIC_CLASS(wxRichTextCell
)
5540 Default constructor; optionally pass the parent object.
5543 wxRichTextCell(wxRichTextObject
* parent
= NULL
);
5549 wxRichTextCell(const wxRichTextCell
& obj
): wxRichTextBox() { Copy(obj
); }
5553 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
5555 virtual wxString
GetXMLNodeName() const { return wxT("cell"); }
5557 virtual bool CanEditProperties() const { return true; }
5559 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
5561 virtual wxString
GetPropertiesMenuLabel() const { return _("&Cell"); }
5567 virtual wxRichTextObject
* Clone() const { return new wxRichTextCell(*this); }
5569 void Copy(const wxRichTextCell
& obj
);
5575 @class wxRichTextTable
5577 wxRichTextTable represents a table with arbitrary columns and rows.
5580 WX_DEFINE_ARRAY_PTR(wxRichTextObject
*, wxRichTextObjectPtrArray
);
5581 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRichTextObjectPtrArray
, wxRichTextObjectPtrArrayArray
, WXDLLIMPEXP_RICHTEXT
);
5583 class WXDLLIMPEXP_RICHTEXT wxRichTextTable
: public wxRichTextBox
5585 DECLARE_DYNAMIC_CLASS(wxRichTextTable
)
5591 Default constructor; optionally pass the parent object.
5594 wxRichTextTable(wxRichTextObject
* parent
= NULL
);
5600 wxRichTextTable(const wxRichTextTable
& obj
): wxRichTextBox() { Copy(obj
); }
5604 virtual bool Draw(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
5606 virtual wxString
GetXMLNodeName() const { return wxT("table"); }
5608 virtual bool Layout(wxDC
& dc
, wxRichTextDrawingContext
& context
, const wxRect
& rect
, const wxRect
& parentRect
, int style
);
5610 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;
5612 virtual bool DeleteRange(const wxRichTextRange
& range
);
5614 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
5617 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
5620 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
5621 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
5624 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
5625 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
5628 virtual bool FindPosition(wxDC
& dc
, wxRichTextDrawingContext
& context
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
5630 virtual void CalculateRange(long start
, long& end
);
5632 // Can this object handle the selections of its children? FOr example, a table.
5633 virtual bool HandlesChildSelections() const { return true; }
5635 /// Returns a selection object specifying the selections between start and end character positions.
5636 /// For example, a table would deduce what cells (of range length 1) are selected when dragging across the table.
5637 virtual wxRichTextSelection
GetSelection(long start
, long end
) const;
5639 virtual bool CanEditProperties() const { return true; }
5641 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
5643 virtual wxString
GetPropertiesMenuLabel() const { return _("&Table"); }
5645 // Returns true if objects of this class can accept the focus, i.e. a call to SetFocusObject
5646 // is possible. For example, containers supporting text, such as a text box object, can accept the focus,
5647 // but a table can't (set the focus to individual cells instead).
5648 virtual bool AcceptsFocus() const { return false; }
5653 Returns the cells array.
5655 const wxRichTextObjectPtrArrayArray
& GetCells() const { return m_cells
; }
5658 Returns the cells array.
5660 wxRichTextObjectPtrArrayArray
& GetCells() { return m_cells
; }
5663 Returns the row count.
5665 int GetRowCount() const { return m_rowCount
; }
5668 Returns the column count.
5670 int GetColumnCount() const { return m_colCount
; }
5673 Returns the cell at the given row/column position.
5675 virtual wxRichTextCell
* GetCell(int row
, int col
) const;
5678 Returns the cell at the given character position (in the range of the table).
5680 virtual wxRichTextCell
* GetCell(long pos
) const;
5683 Returns the row/column for a given character position.
5685 virtual bool GetCellRowColumnPosition(long pos
, int& row
, int& col
) const;
5688 Returns the coordinates of the cell with keyboard focus, or (-1,-1) if none.
5690 virtual wxPosition
GetFocusedCell() const;
5698 virtual void ClearTable();
5701 Creates a table of the given dimensions.
5704 virtual bool CreateTable(int rows
, int cols
);
5707 Sets the attributes for the cells specified by the selection.
5710 virtual bool SetCellStyle(const wxRichTextSelection
& selection
, const wxRichTextAttr
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
5713 Deletes rows from the given row position.
5716 virtual bool DeleteRows(int startRow
, int noRows
= 1);
5719 Deletes columns from the given column position.
5722 virtual bool DeleteColumns(int startCol
, int noCols
= 1);
5725 Adds rows from the given row position.
5728 virtual bool AddRows(int startRow
, int noRows
= 1, const wxRichTextAttr
& attr
= wxRichTextAttr());
5731 Adds columns from the given column position.
5734 virtual bool AddColumns(int startCol
, int noCols
= 1, const wxRichTextAttr
& attr
= wxRichTextAttr());
5736 // Makes a clone of this object.
5737 virtual wxRichTextObject
* Clone() const { return new wxRichTextTable(*this); }
5739 // Copies this object.
5740 void Copy(const wxRichTextTable
& obj
);
5747 // An array of rows, each of which is a wxRichTextObjectPtrArray containing
5748 // the cell objects. The cell objects are also children of this object.
5749 // Problem: if boxes are immediate children of a box, this will cause problems
5750 // with wxRichTextParagraphLayoutBox functions (and functions elsewhere) that
5751 // expect to find just paragraphs. May have to adjust the way we handle the
5752 // hierarchy to accept non-paragraph objects in a paragraph layout box.
5753 // We'll be overriding much wxRichTextParagraphLayoutBox functionality so this
5754 // may not be such a problem. Perhaps the table should derive from a different
5756 wxRichTextObjectPtrArrayArray m_cells
;
5761 The command identifiers for Do/Undo.
5764 enum wxRichTextCommandId
5768 wxRICHTEXT_CHANGE_ATTRIBUTES
,
5769 wxRICHTEXT_CHANGE_STYLE
,
5770 wxRICHTEXT_CHANGE_PROPERTIES
,
5771 wxRICHTEXT_CHANGE_OBJECT
5775 @class wxRichTextObjectAddress
5777 A class for specifying an object anywhere in an object hierarchy,
5778 without using a pointer, necessary since wxRTC commands may delete
5779 and recreate sub-objects so physical object addresses change. An array
5780 of positions (one per hierarchy level) is used.
5782 @library{wxrichtext}
5785 @see wxRichTextCommand
5788 class WXDLLIMPEXP_RICHTEXT wxRichTextObjectAddress
5792 Creates the address given a container and an object.
5794 wxRichTextObjectAddress(wxRichTextParagraphLayoutBox
* topLevelContainer
, wxRichTextObject
* obj
) { Create(topLevelContainer
, obj
); }
5797 wxRichTextObjectAddress() { Init(); }
5800 wxRichTextObjectAddress(const wxRichTextObjectAddress
& address
) { Copy(address
); }
5807 void Copy(const wxRichTextObjectAddress
& address
) { m_address
= address
.m_address
; }
5810 Assignment operator.
5812 void operator=(const wxRichTextObjectAddress
& address
) { Copy(address
); }
5815 Returns the object specified by the address, given a top level container.
5817 wxRichTextObject
* GetObject(wxRichTextParagraphLayoutBox
* topLevelContainer
) const;
5820 Creates the address given a container and an object.
5822 bool Create(wxRichTextParagraphLayoutBox
* topLevelContainer
, wxRichTextObject
* obj
);
5825 Returns the array of integers representing the object address.
5827 wxArrayInt
& GetAddress() { return m_address
; }
5830 Returns the array of integers representing the object address.
5832 const wxArrayInt
& GetAddress() const { return m_address
; }
5835 Sets the address from an array of integers.
5837 void SetAddress(const wxArrayInt
& address
) { m_address
= address
; }
5841 wxArrayInt m_address
;
5844 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction
;
5847 @class wxRichTextCommand
5849 Implements a command on the undo/redo stack. A wxRichTextCommand object contains one or more wxRichTextAction
5850 objects, allowing aggregation of a number of operations into one command.
5852 @library{wxrichtext}
5855 @see wxRichTextAction
5858 class WXDLLIMPEXP_RICHTEXT wxRichTextCommand
: public wxCommand
5862 Constructor for one action.
5864 wxRichTextCommand(const wxString
& name
, wxRichTextCommandId id
, wxRichTextBuffer
* buffer
,
5865 wxRichTextParagraphLayoutBox
* container
, wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
5868 Constructor for multiple actions.
5870 wxRichTextCommand(const wxString
& name
);
5872 virtual ~wxRichTextCommand();
5875 Performs the command.
5885 Adds an action to the action list.
5887 void AddAction(wxRichTextAction
* action
);
5890 Clears the action list.
5892 void ClearActions();
5895 Returns the action list.
5897 wxList
& GetActions() { return m_actions
; }
5905 @class wxRichTextAction
5907 Implements a part of a command.
5909 @library{wxrichtext}
5912 @see wxRichTextCommand
5915 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
: public wxObject
5919 Constructor. @a buffer is the top-level buffer, while @a container is the object within
5920 which the action is taking place. In the simplest case, they are the same.
5922 wxRichTextAction(wxRichTextCommand
* cmd
, const wxString
& name
, wxRichTextCommandId id
,
5923 wxRichTextBuffer
* buffer
, wxRichTextParagraphLayoutBox
* container
,
5924 wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
5926 virtual ~wxRichTextAction();
5929 Performs the action.
5939 Updates the control appearance, optimizing if possible given information from the call to Layout.
5941 void UpdateAppearance(long caretPosition
, bool sendUpdateEvent
= false,
5942 wxArrayInt
* optimizationLineCharPositions
= NULL
, wxArrayInt
* optimizationLineYPositions
= NULL
, bool isDoCmd
= true);
5945 Replaces the buffer paragraphs with the given fragment.
5947 void ApplyParagraphs(const wxRichTextParagraphLayoutBox
& fragment
);
5950 Returns the new fragments.
5952 wxRichTextParagraphLayoutBox
& GetNewParagraphs() { return m_newParagraphs
; }
5955 Returns the old fragments.
5957 wxRichTextParagraphLayoutBox
& GetOldParagraphs() { return m_oldParagraphs
; }
5960 Returns the attributes, for single-object commands.
5962 wxRichTextAttr
& GetAttributes() { return m_attributes
; }
5965 Returns the object to replace the one at the position defined by the container address
5966 and the action's range start position.
5968 wxRichTextObject
* GetObject() const { return m_object
; }
5971 Stores the object to replace the one at the position defined by the container address
5972 without making an address for it (cf SetObject() and MakeObject()).
5974 void StoreObject(wxRichTextObject
* obj
) { m_object
= obj
; }
5977 Sets the object to replace the one at the position defined by the container address
5978 and the action's range start position.
5980 void SetObject(wxRichTextObject
* obj
) { m_object
= obj
; m_objectAddress
.Create(m_buffer
, m_object
); }
5983 Makes an address from the given object.
5985 void MakeObject(wxRichTextObject
* obj
) { m_objectAddress
.Create(m_buffer
, obj
); }
5988 Calculate arrays for refresh optimization.
5990 void CalculateRefreshOptimizations(wxArrayInt
& optimizationLineCharPositions
, wxArrayInt
& optimizationLineYPositions
);
5993 Sets the position used for e.g. insertion.
5995 void SetPosition(long pos
) { m_position
= pos
; }
5998 Returns the position used for e.g. insertion.
6000 long GetPosition() const { return m_position
; }
6003 Sets the range for e.g. deletion.
6005 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
6008 Returns the range for e.g. deletion.
6010 const wxRichTextRange
& GetRange() const { return m_range
; }
6013 Returns the address (nested position) of the container within the buffer being manipulated.
6015 wxRichTextObjectAddress
& GetContainerAddress() { return m_containerAddress
; }
6018 Returns the address (nested position) of the container within the buffer being manipulated.
6020 const wxRichTextObjectAddress
& GetContainerAddress() const { return m_containerAddress
; }
6023 Sets the address (nested position) of the container within the buffer being manipulated.
6025 void SetContainerAddress(const wxRichTextObjectAddress
& address
) { m_containerAddress
= address
; }
6028 Sets the address (nested position) of the container within the buffer being manipulated.
6030 void SetContainerAddress(wxRichTextParagraphLayoutBox
* container
, wxRichTextObject
* obj
) { m_containerAddress
.Create(container
, obj
); }
6033 Returns the container that this action refers to, using the container address and top-level buffer.
6035 wxRichTextParagraphLayoutBox
* GetContainer() const;
6038 Returns the action name.
6040 const wxString
& GetName() const { return m_name
; }
6047 wxRichTextBuffer
* m_buffer
;
6049 // The address (nested position) of the container being manipulated.
6050 // This is necessary because objects are deleted, and we can't
6051 // therefore store actual pointers.
6052 wxRichTextObjectAddress m_containerAddress
;
6055 wxRichTextCtrl
* m_ctrl
;
6057 // Stores the new paragraphs
6058 wxRichTextParagraphLayoutBox m_newParagraphs
;
6060 // Stores the old paragraphs
6061 wxRichTextParagraphLayoutBox m_oldParagraphs
;
6063 // Stores an object to replace the one at the position
6064 // defined by the container address and the action's range start position.
6065 wxRichTextObject
* m_object
;
6067 // Stores the attributes
6068 wxRichTextAttr m_attributes
;
6070 // The address of the object being manipulated (used for changing an individual object or its attributes)
6071 wxRichTextObjectAddress m_objectAddress
;
6073 // Stores the old attributes
6074 // wxRichTextAttr m_oldAttributes;
6076 // The affected range
6077 wxRichTextRange m_range
;
6079 // The insertion point for this command
6082 // Ignore 1st 'Do' operation because we already did it
6085 // The command identifier
6086 wxRichTextCommandId m_cmdId
;
6093 // Include style sheet when loading and saving
6094 #define wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET 0x0001
6096 // Save images to memory file system in HTML handler
6097 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY 0x0010
6099 // Save images to files in HTML handler
6100 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES 0x0020
6102 // Save images as inline base64 data in HTML handler
6103 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040
6105 // Don't write header and footer (or BODY), so we can include the fragment
6106 // in a larger document
6107 #define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080
6109 // Convert the more common face names to names that will work on the current platform
6110 // in a larger document
6111 #define wxRICHTEXT_HANDLER_CONVERT_FACENAMES 0x0100
6114 @class wxRichTextFileHandler
6116 The base class for file handlers.
6118 @library{wxrichtext}
6121 @see wxRichTextBuffer, wxRichTextCtrl
6124 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler
: public wxObject
6126 DECLARE_CLASS(wxRichTextFileHandler
)
6129 Creates a file handler object.
6131 wxRichTextFileHandler(const wxString
& name
= wxEmptyString
, const wxString
& ext
= wxEmptyString
, int type
= 0)
6132 : m_name(name
), m_extension(ext
), m_type(type
), m_flags(0), m_visible(true)
6137 Loads the buffer from a stream.
6138 Not all handlers will implement file loading.
6140 bool LoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
)
6141 { return DoLoadFile(buffer
, stream
); }
6144 Saves the buffer to a stream.
6145 Not all handlers will implement file saving.
6147 bool SaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
)
6148 { return DoSaveFile(buffer
, stream
); }
6151 #if wxUSE_FFILE && wxUSE_STREAMS
6153 Loads the buffer from a file.
6155 virtual bool LoadFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
6158 Saves the buffer to a file.
6160 virtual bool SaveFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
6161 #endif // wxUSE_STREAMS && wxUSE_STREAMS
6164 Returns @true if we handle this filename (if using files). By default, checks the extension.
6166 virtual bool CanHandle(const wxString
& filename
) const;
6169 Returns @true if we can save using this handler.
6171 virtual bool CanSave() const { return false; }
6174 Returns @true if we can load using this handler.
6176 virtual bool CanLoad() const { return false; }
6179 Returns @true if this handler should be visible to the user.
6181 virtual bool IsVisible() const { return m_visible
; }
6184 Sets whether the handler should be visible to the user (via the application's
6185 load and save dialogs).
6187 virtual void SetVisible(bool visible
) { m_visible
= visible
; }
6190 Sets the name of the handler.
6192 void SetName(const wxString
& name
) { m_name
= name
; }
6195 Returns the name of the handler.
6197 wxString
GetName() const { return m_name
; }
6200 Sets the default extension to recognise.
6202 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
6205 Returns the default extension to recognise.
6207 wxString
GetExtension() const { return m_extension
; }
6210 Sets the handler type.
6212 void SetType(int type
) { m_type
= type
; }
6215 Returns the handler type.
6217 int GetType() const { return m_type
; }
6220 Sets flags that change the behaviour of loading or saving.
6221 See the documentation for each handler class to see what flags are relevant
6224 You call this function directly if you are using a file handler explicitly
6225 (without going through the text control or buffer LoadFile/SaveFile API).
6226 Or, you can call the control or buffer's SetHandlerFlags function to set
6227 the flags that will be used for subsequent load and save operations.
6229 void SetFlags(int flags
) { m_flags
= flags
; }
6232 Returns flags controlling how loading and saving is done.
6234 int GetFlags() const { return m_flags
; }
6237 Sets the encoding to use when saving a file. If empty, a suitable encoding is chosen.
6239 void SetEncoding(const wxString
& encoding
) { m_encoding
= encoding
; }
6242 Returns the encoding to use when saving a file. If empty, a suitable encoding is chosen.
6244 const wxString
& GetEncoding() const { return m_encoding
; }
6250 Override to load content from @a stream into @a buffer.
6252 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
) = 0;
6255 Override to save content to @a stream from @a buffer.
6257 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
) = 0;
6261 wxString m_encoding
;
6262 wxString m_extension
;
6269 @class wxRichTextPlainTextHandler
6271 Implements saving a buffer to plain text.
6273 @library{wxrichtext}
6276 @see wxRichTextFileHandler, wxRichTextBuffer, wxRichTextCtrl
6279 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler
: public wxRichTextFileHandler
6281 DECLARE_CLASS(wxRichTextPlainTextHandler
)
6283 wxRichTextPlainTextHandler(const wxString
& name
= wxT("Text"),
6284 const wxString
& ext
= wxT("txt"),
6285 wxRichTextFileType type
= wxRICHTEXT_TYPE_TEXT
)
6286 : wxRichTextFileHandler(name
, ext
, type
)
6289 // Can we save using this handler?
6290 virtual bool CanSave() const { return true; }
6292 // Can we load using this handler?
6293 virtual bool CanLoad() const { return true; }
6298 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
6299 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
6305 @class wxRichTextDrawingHandler
6307 The base class for custom drawing handlers.
6308 Currently, drawing handlers can provide virtual attributes.
6310 @library{wxrichtext}
6313 @see wxRichTextBuffer, wxRichTextCtrl
6316 class WXDLLIMPEXP_RICHTEXT wxRichTextDrawingHandler
: public wxObject
6318 DECLARE_CLASS(wxRichTextDrawingHandler
)
6321 Creates a drawing handler object.
6323 wxRichTextDrawingHandler(const wxString
& name
= wxEmptyString
)
6328 Returns @true if this object has virtual attributes that we can provide.
6330 virtual bool HasVirtualAttributes(wxRichTextObject
* obj
) const = 0;
6333 Provides virtual attributes that we can provide.
6335 virtual bool GetVirtualAttributes(wxRichTextAttr
& attr
, wxRichTextObject
* obj
) const = 0;
6338 Gets the count for mixed virtual attributes for individual positions within the object.
6339 For example, individual characters within a text object may require special highlighting.
6341 virtual int GetVirtualSubobjectAttributesCount(wxRichTextObject
* obj
) const = 0;
6344 Gets the mixed virtual attributes for individual positions within the object.
6345 For example, individual characters within a text object may require special highlighting.
6346 Returns the number of virtual attributes found.
6348 virtual int GetVirtualSubobjectAttributes(wxRichTextObject
* obj
, wxArrayInt
& positions
, wxRichTextAttrArray
& attributes
) const = 0;
6351 Do we have virtual text for this object? Virtual text allows an application
6352 to replace characters in an object for editing and display purposes, for example
6353 for highlighting special characters.
6355 virtual bool HasVirtualText(const wxRichTextPlainText
* obj
) const = 0;
6358 Gets the virtual text for this object.
6360 virtual bool GetVirtualText(const wxRichTextPlainText
* obj
, wxString
& text
) const = 0;
6363 Sets the name of the handler.
6365 void SetName(const wxString
& name
) { m_name
= name
; }
6368 Returns the name of the handler.
6370 wxString
GetName() const { return m_name
; }
6380 @class wxRichTextBufferDataObject
6382 Implements a rich text data object for clipboard transfer.
6384 @library{wxrichtext}
6387 @see wxDataObjectSimple, wxRichTextBuffer, wxRichTextCtrl
6390 class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject
: public wxDataObjectSimple
6394 The constructor doesn't copy the pointer, so it shouldn't go away while this object
6397 wxRichTextBufferDataObject(wxRichTextBuffer
* richTextBuffer
= NULL
);
6398 virtual ~wxRichTextBufferDataObject();
6401 After a call to this function, the buffer is owned by the caller and it
6402 is responsible for deleting it.
6404 wxRichTextBuffer
* GetRichTextBuffer();
6407 Returns the id for the new data format.
6409 static const wxChar
* GetRichTextBufferFormatId() { return ms_richTextBufferFormatId
; }
6411 // base class pure virtuals
6413 virtual wxDataFormat
GetPreferredFormat(Direction dir
) const;
6414 virtual size_t GetDataSize() const;
6415 virtual bool GetDataHere(void *pBuf
) const;
6416 virtual bool SetData(size_t len
, const void *buf
);
6420 virtual size_t GetDataSize(const wxDataFormat
&) const { return GetDataSize(); }
6421 virtual bool GetDataHere(const wxDataFormat
&, void *buf
) const { return GetDataHere(buf
); }
6422 virtual bool SetData(const wxDataFormat
&, size_t len
, const void *buf
) { return SetData(len
, buf
); }
6425 wxDataFormat m_formatRichTextBuffer
; // our custom format
6426 wxRichTextBuffer
* m_richTextBuffer
; // our data
6427 static const wxChar
* ms_richTextBufferFormatId
; // our format id
6433 @class wxRichTextRenderer
6435 This class isolates some common drawing functionality.
6437 @library{wxrichtext}
6440 @see wxRichTextBuffer, wxRichTextCtrl
6443 class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer
: public wxObject
6449 wxRichTextRenderer() {}
6450 virtual ~wxRichTextRenderer() {}
6453 Draws a standard bullet, as specified by the value of GetBulletName. This function should be overridden.
6455 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
) = 0;
6458 Draws a bullet that can be described by text, such as numbered or symbol bullets. This function should be overridden.
6460 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
, const wxString
& text
) = 0;
6463 Draws a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName. This function should be overridden.
6465 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
) = 0;
6468 Enumerate the standard bullet names currently supported. This function should be overridden.
6470 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
) = 0;
6474 @class wxRichTextStdRenderer
6476 The standard renderer for drawing bullets.
6478 @library{wxrichtext}
6481 @see wxRichTextRenderer, wxRichTextBuffer, wxRichTextCtrl
6484 class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer
: public wxRichTextRenderer
6490 wxRichTextStdRenderer() {}
6492 // Draw a standard bullet, as specified by the value of GetBulletName
6493 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
);
6495 // Draw a bullet that can be described by text, such as numbered or symbol bullets
6496 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
, const wxString
& text
);
6498 // Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
6499 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
);
6501 // Enumerate the standard bullet names currently supported
6502 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
);
6510 inline bool wxRichTextHasStyle(int flags
, int style
)
6512 return ((flags
& style
) == style
);
6515 /// Compare two attribute objects
6516 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxRichTextAttr
& attr1
, const wxRichTextAttr
& attr2
);
6517 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxRichTextAttr
& attr1
, const wxRichTextAttr
& attr2
);
6519 /// Apply one style to another
6520 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxRichTextAttr
& destStyle
, const wxRichTextAttr
& style
, wxRichTextAttr
* compareWith
= NULL
);
6522 // Remove attributes
6523 WXDLLIMPEXP_RICHTEXT
bool wxRichTextRemoveStyle(wxRichTextAttr
& destStyle
, const wxRichTextAttr
& style
);
6525 /// Combine two bitlists
6526 WXDLLIMPEXP_RICHTEXT
bool wxRichTextCombineBitlists(int& valueA
, int valueB
, int& flagsA
, int flagsB
);
6528 /// Compare two bitlists
6529 WXDLLIMPEXP_RICHTEXT
bool wxRichTextBitlistsEqPartial(int valueA
, int valueB
, int flags
);
6531 /// Split into paragraph and character styles
6532 WXDLLIMPEXP_RICHTEXT
bool wxRichTextSplitParaCharStyles(const wxRichTextAttr
& style
, wxRichTextAttr
& parStyle
, wxRichTextAttr
& charStyle
);
6535 WXDLLIMPEXP_RICHTEXT
bool wxRichTextTabsEq(const wxArrayInt
& tabs1
, const wxArrayInt
& tabs2
);
6537 /// Convert a decimal to Roman numerals
6538 WXDLLIMPEXP_RICHTEXT wxString
wxRichTextDecimalToRoman(long n
);
6540 // Collects the attributes that are common to a range of content, building up a note of
6541 // which attributes are absent in some objects and which clash in some objects.
6542 WXDLLIMPEXP_RICHTEXT
void wxTextAttrCollectCommonAttributes(wxTextAttr
& currentStyle
, const wxTextAttr
& attr
, wxTextAttr
& clashingAttr
, wxTextAttr
& absentAttr
);
6544 WXDLLIMPEXP_RICHTEXT
void wxRichTextModuleInit();
6550 // _WX_RICHTEXTBUFFER_H_