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"
71 #include "wx/dataobj.h"
75 //#define wxRichTextAttr wxTextAttr
76 #define wxTextAttrEx wxTextAttr
78 // Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a
79 // caret reliably without using wxClientDC in case there
80 // are platform-specific problems with the generic caret.
81 #if defined(__WXGTK__) || defined(__WXMAC__)
82 #define wxRICHTEXT_USE_OWN_CARET 1
84 #define wxRICHTEXT_USE_OWN_CARET 0
87 // Switch off for binary compatibility, on for faster drawing
88 // Note: this seems to be buggy (overzealous use of extents) so
90 #define wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING 0
92 // The following two symbols determine whether an output implementation
93 // is present. To switch the relevant one on, set wxRICHTEXT_USE_XMLDOCUMENT_OUTPUT in
94 // richtextxml.cpp. By default, the faster direct output implementation is used.
96 // Include the wxXmlDocument implementation for output
97 #define wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT 1
99 // Include the faster, direct implementation for output
100 #define wxRICHTEXT_HAVE_DIRECT_OUTPUT 1
106 extern WXDLLIMPEXP_RICHTEXT
const wxChar wxRichTextLineBreakChar
;
109 * File types in wxRichText context.
111 enum wxRichTextFileType
113 wxRICHTEXT_TYPE_ANY
= 0,
114 wxRICHTEXT_TYPE_TEXT
,
116 wxRICHTEXT_TYPE_HTML
,
122 * Forward declarations
125 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCtrl
;
126 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObject
;
127 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextImage
;
128 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCacheObject
;
129 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObjectList
;
130 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextLine
;
131 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraph
;
132 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFileHandler
;
133 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleSheet
;
134 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextListStyleDefinition
;
135 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextEvent
;
136 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextRenderer
;
137 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextBuffer
;
138 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextXMLHandler
;
139 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraphLayoutBox
;
140 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextImageBlock
;
141 class WXDLLIMPEXP_FWD_XML wxXmlNode
;
142 class wxRichTextFloatCollector
;
145 * Flags determining the available space, passed to Layout
148 #define wxRICHTEXT_FIXED_WIDTH 0x01
149 #define wxRICHTEXT_FIXED_HEIGHT 0x02
150 #define wxRICHTEXT_VARIABLE_WIDTH 0x04
151 #define wxRICHTEXT_VARIABLE_HEIGHT 0x08
153 // Only lay out the part of the buffer that lies within
154 // the rect passed to Layout.
155 #define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10
158 * Flags to pass to Draw
161 // Ignore paragraph cache optimization, e.g. for printing purposes
162 // where one line may be drawn higher (on the next page) compared
163 // with the previous line
164 #define wxRICHTEXT_DRAW_IGNORE_CACHE 0x01
165 #define wxRICHTEXT_DRAW_SELECTED 0x02
166 #define wxRICHTEXT_DRAW_PRINT 0x04
167 #define wxRICHTEXT_DRAW_GUIDELINES 0x08
170 * Flags returned from hit-testing, or passed to hit-test function.
172 enum wxRichTextHitTestFlags
174 // The point was not on this object
175 wxRICHTEXT_HITTEST_NONE
= 0x01,
177 // The point was before the position returned from HitTest
178 wxRICHTEXT_HITTEST_BEFORE
= 0x02,
180 // The point was after the position returned from HitTest
181 wxRICHTEXT_HITTEST_AFTER
= 0x04,
183 // The point was on the position returned from HitTest
184 wxRICHTEXT_HITTEST_ON
= 0x08,
186 // The point was on space outside content
187 wxRICHTEXT_HITTEST_OUTSIDE
= 0x10,
189 // Only do hit-testing at the current level (don't traverse into top-level objects)
190 wxRICHTEXT_HITTEST_NO_NESTED_OBJECTS
= 0x20,
192 // Ignore floating objects
193 wxRICHTEXT_HITTEST_NO_FLOATING_OBJECTS
= 0x40
197 * Flags for GetRangeSize
200 #define wxRICHTEXT_FORMATTED 0x01
201 #define wxRICHTEXT_UNFORMATTED 0x02
202 #define wxRICHTEXT_CACHE_SIZE 0x04
203 #define wxRICHTEXT_HEIGHT_ONLY 0x08
206 * Flags for SetStyle/SetListStyle
209 #define wxRICHTEXT_SETSTYLE_NONE 0x00
211 // Specifies that this operation should be undoable
212 #define wxRICHTEXT_SETSTYLE_WITH_UNDO 0x01
214 // Specifies that the style should not be applied if the
215 // combined style at this point is already the style in question.
216 #define wxRICHTEXT_SETSTYLE_OPTIMIZE 0x02
218 // Specifies that the style should only be applied to paragraphs,
219 // and not the content. This allows content styling to be
220 // preserved independently from that of e.g. a named paragraph style.
221 #define wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY 0x04
223 // Specifies that the style should only be applied to characters,
224 // and not the paragraph. This allows content styling to be
225 // preserved independently from that of e.g. a named paragraph style.
226 #define wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY 0x08
228 // For SetListStyle only: specifies starting from the given number, otherwise
229 // deduces number from existing attributes
230 #define wxRICHTEXT_SETSTYLE_RENUMBER 0x10
232 // For SetListStyle only: specifies the list level for all paragraphs, otherwise
233 // the current indentation will be used
234 #define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL 0x20
236 // Resets the existing style before applying the new style
237 #define wxRICHTEXT_SETSTYLE_RESET 0x40
239 // Removes the given style instead of applying it
240 #define wxRICHTEXT_SETSTYLE_REMOVE 0x80
243 * Flags for object insertion
246 #define wxRICHTEXT_INSERT_NONE 0x00
247 #define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE 0x01
248 #define wxRICHTEXT_INSERT_INTERACTIVE 0x02
250 // A special flag telling the buffer to keep the first paragraph style
251 // as-is, when deleting a paragraph marker. In future we might pass a
252 // flag to InsertFragment and DeleteRange to indicate the appropriate mode.
253 #define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x10000000
256 * Default superscript/subscript font multiplication factor
259 #define wxSCRIPT_MUL_FACTOR 1.5
261 typedef unsigned short wxTextAttrDimensionFlags
;
263 // Miscellaneous text box flags
264 enum wxTextBoxAttrFlags
266 wxTEXT_BOX_ATTR_FLOAT
= 0x00000001,
267 wxTEXT_BOX_ATTR_CLEAR
= 0x00000002,
268 wxTEXT_BOX_ATTR_COLLAPSE_BORDERS
= 0x00000004,
269 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
= 0x00000004
272 // Whether a value is present, used in dimension flags
273 enum wxTextAttrValueFlags
275 wxTEXT_ATTR_VALUE_VALID
= 0x1000,
276 wxTEXT_ATTR_VALUE_VALID_MASK
= 0x1000
279 // Units - included in the dimension value
282 wxTEXT_ATTR_UNITS_TENTHS_MM
= 0x0001,
283 wxTEXT_ATTR_UNITS_PIXELS
= 0x0002,
284 wxTEXT_ATTR_UNITS_PERCENTAGE
= 0x0004,
285 wxTEXT_ATTR_UNITS_POINTS
= 0x0008,
287 wxTEXT_ATTR_UNITS_MASK
= 0x000F
290 // Position - included in the dimension flags
291 enum wxTextBoxAttrPosition
293 wxTEXT_BOX_ATTR_POSITION_STATIC
= 0x0000, // Default is static, i.e. as per normal layout
294 wxTEXT_BOX_ATTR_POSITION_RELATIVE
= 0x0010, // Relative to the relevant edge
295 wxTEXT_BOX_ATTR_POSITION_ABSOLUTE
= 0x0020,
297 wxTEXT_BOX_ATTR_POSITION_MASK
= 0x00F0
301 @class wxTextAttrDimension
303 A class representing a rich text dimension, including units and position.
308 @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimensions
311 class WXDLLIMPEXP_RICHTEXT wxTextAttrDimension
317 wxTextAttrDimension() { Reset(); }
319 Constructor taking value and units flag.
321 wxTextAttrDimension(int value
, wxTextAttrUnits units
= wxTEXT_ATTR_UNITS_TENTHS_MM
) { m_value
= value
; m_flags
= units
|wxTEXT_ATTR_VALUE_VALID
; }
324 Resets the dimension value and flags.
326 void Reset() { m_value
= 0; m_flags
= 0; }
329 Partial equality test.
331 bool EqPartial(const wxTextAttrDimension
& dim
) const;
333 /** Apply the dimension, but not those identical to @a compareWith if present.
335 bool Apply(const wxTextAttrDimension
& dim
, const wxTextAttrDimension
* compareWith
= NULL
);
337 /** Collects the attributes that are common to a range of content, building up a note of
338 which attributes are absent in some objects and which clash in some objects.
340 void CollectCommonAttributes(const wxTextAttrDimension
& attr
, wxTextAttrDimension
& clashingAttr
, wxTextAttrDimension
& absentAttr
);
345 bool operator==(const wxTextAttrDimension
& dim
) const { return m_value
== dim
.m_value
&& m_flags
== dim
.m_flags
; }
348 Returns the integer value of the dimension.
350 int GetValue() const { return m_value
; }
353 Returns the floating-pointing value of the dimension in mm.
356 float GetValueMM() const { return float(m_value
) / 10.0; }
359 Sets the value of the dimension in mm.
361 void SetValueMM(float value
) { m_value
= (int) ((value
* 10.0) + 0.5); m_flags
|= wxTEXT_ATTR_VALUE_VALID
; }
364 Sets the integer value of the dimension.
366 void SetValue(int value
) { m_value
= value
; m_flags
|= wxTEXT_ATTR_VALUE_VALID
; }
369 Sets the integer value of the dimension, passing dimension flags.
371 void SetValue(int value
, wxTextAttrDimensionFlags flags
) { SetValue(value
); m_flags
= flags
; }
374 Sets the integer value and units.
376 void SetValue(int value
, wxTextAttrUnits units
) { m_value
= value
; m_flags
= units
| wxTEXT_ATTR_VALUE_VALID
; }
381 void SetValue(const wxTextAttrDimension
& dim
) { (*this) = dim
; }
384 Gets the units of the dimension.
386 wxTextAttrUnits
GetUnits() const { return (wxTextAttrUnits
) (m_flags
& wxTEXT_ATTR_UNITS_MASK
); }
389 Sets the units of the dimension.
391 void SetUnits(wxTextAttrUnits units
) { m_flags
&= ~wxTEXT_ATTR_UNITS_MASK
; m_flags
|= units
; }
394 Gets the position flags.
396 wxTextBoxAttrPosition
GetPosition() const { return (wxTextBoxAttrPosition
) (m_flags
& wxTEXT_BOX_ATTR_POSITION_MASK
); }
399 Sets the position flags.
401 void SetPosition(wxTextBoxAttrPosition pos
) { m_flags
&= ~wxTEXT_BOX_ATTR_POSITION_MASK
; m_flags
|= pos
; }
404 Returns @true if the dimension is valid.
406 bool IsValid() const { return (m_flags
& wxTEXT_ATTR_VALUE_VALID
) != 0; }
411 void SetValid(bool b
) { m_flags
&= ~wxTEXT_ATTR_VALUE_VALID_MASK
; m_flags
|= (b
? wxTEXT_ATTR_VALUE_VALID
: 0); }
414 Gets the dimension flags.
416 wxTextAttrDimensionFlags
GetFlags() const { return m_flags
; }
419 Sets the dimension flags.
421 void SetFlags(wxTextAttrDimensionFlags flags
) { m_flags
= flags
; }
424 wxTextAttrDimensionFlags m_flags
;
428 @class wxTextAttrDimensions
429 A class for left, right, top and bottom dimensions.
434 @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension
437 class WXDLLIMPEXP_RICHTEXT wxTextAttrDimensions
443 wxTextAttrDimensions() {}
446 Resets the value and flags for all dimensions.
448 void Reset() { m_left
.Reset(); m_top
.Reset(); m_right
.Reset(); m_bottom
.Reset(); }
453 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
; }
456 Partial equality test.
459 bool EqPartial(const wxTextAttrDimensions
& dims
) const;
462 Apply border to 'this', but not if the same as @a compareWith.
465 bool Apply(const wxTextAttrDimensions
& dims
, const wxTextAttrDimensions
* compareWith
= NULL
);
468 Collects the attributes that are common to a range of content, building up a note of
469 which attributes are absent in some objects and which clash in some objects.
472 void CollectCommonAttributes(const wxTextAttrDimensions
& attr
, wxTextAttrDimensions
& clashingAttr
, wxTextAttrDimensions
& absentAttr
);
475 Remove specified attributes from this object.
477 bool RemoveStyle(const wxTextAttrDimensions
& attr
);
480 Gets the left dimension.
482 const wxTextAttrDimension
& GetLeft() const { return m_left
; }
483 wxTextAttrDimension
& GetLeft() { return m_left
; }
486 Gets the right dimension.
489 const wxTextAttrDimension
& GetRight() const { return m_right
; }
490 wxTextAttrDimension
& GetRight() { return m_right
; }
493 Gets the top dimension.
496 const wxTextAttrDimension
& GetTop() const { return m_top
; }
497 wxTextAttrDimension
& GetTop() { return m_top
; }
500 Gets the bottom dimension.
503 const wxTextAttrDimension
& GetBottom() const { return m_bottom
; }
504 wxTextAttrDimension
& GetBottom() { return m_bottom
; }
506 wxTextAttrDimension m_left
;
507 wxTextAttrDimension m_top
;
508 wxTextAttrDimension m_right
;
509 wxTextAttrDimension m_bottom
;
513 @class wxTextAttrSize
514 A class for representing width and height.
519 @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension
522 class WXDLLIMPEXP_RICHTEXT wxTextAttrSize
531 Resets the width and height dimensions.
533 void Reset() { m_width
.Reset(); m_height
.Reset(); }
538 bool operator==(const wxTextAttrSize
& size
) const { return m_width
== size
.m_width
&& m_height
== size
.m_height
; }
541 Partial equality test.
543 bool EqPartial(const wxTextAttrSize
& dims
) const;
546 Apply border to this object, but not if the same as @a compareWith.
548 bool Apply(const wxTextAttrSize
& dims
, const wxTextAttrSize
* compareWith
= NULL
);
551 Collects the attributes that are common to a range of content, building up a note of
552 which attributes are absent in some objects and which clash in some objects.
554 void CollectCommonAttributes(const wxTextAttrSize
& attr
, wxTextAttrSize
& clashingAttr
, wxTextAttrSize
& absentAttr
);
557 Removes the specified attributes from this object.
559 bool RemoveStyle(const wxTextAttrSize
& attr
);
564 wxTextAttrDimension
& GetWidth() { return m_width
; }
565 const wxTextAttrDimension
& GetWidth() const { return m_width
; }
570 void SetWidth(int value
, wxTextAttrDimensionFlags flags
) { m_width
.SetValue(value
, flags
); }
574 void SetWidth(int value
, wxTextAttrUnits units
) { m_width
.SetValue(value
, units
); }
578 void SetWidth(const wxTextAttrDimension
& dim
) { m_width
.SetValue(dim
); }
583 wxTextAttrDimension
& GetHeight() { return m_height
; }
584 const wxTextAttrDimension
& GetHeight() const { return m_height
; }
589 void SetHeight(int value
, wxTextAttrDimensionFlags flags
) { m_height
.SetValue(value
, flags
); }
593 void SetHeight(int value
, wxTextAttrUnits units
) { m_height
.SetValue(value
, units
); }
597 void SetHeight(const wxTextAttrDimension
& dim
) { m_height
.SetValue(dim
); }
599 wxTextAttrDimension m_width
;
600 wxTextAttrDimension m_height
;
604 @class wxTextAttrDimensionConverter
605 A class to make it easier to convert dimensions.
610 @see wxRichTextAttr, wxRichTextCtrl, wxTextAttrDimension
613 class WXDLLIMPEXP_RICHTEXT wxTextAttrDimensionConverter
619 wxTextAttrDimensionConverter(wxDC
& dc
, double scale
= 1.0, const wxSize
& parentSize
= wxDefaultSize
);
623 wxTextAttrDimensionConverter(int ppi
, double scale
= 1.0, const wxSize
& parentSize
= wxDefaultSize
);
626 Gets the pixel size for the given dimension.
628 int GetPixels(const wxTextAttrDimension
& dim
, int direction
= wxHORIZONTAL
) const;
630 Gets the mm size for the given dimension.
632 int GetTenthsMM(const wxTextAttrDimension
& dim
) const;
635 Converts tenths of a mm to pixels.
637 int ConvertTenthsMMToPixels(int units
) const;
639 Converts pixels to tenths of a mm.
641 int ConvertPixelsToTenthsMM(int pixels
) const;
649 enum wxTextAttrBorderStyle
651 wxTEXT_BOX_ATTR_BORDER_NONE
= 0,
652 wxTEXT_BOX_ATTR_BORDER_SOLID
= 1,
653 wxTEXT_BOX_ATTR_BORDER_DOTTED
= 2,
654 wxTEXT_BOX_ATTR_BORDER_DASHED
= 3,
655 wxTEXT_BOX_ATTR_BORDER_DOUBLE
= 4,
656 wxTEXT_BOX_ATTR_BORDER_GROOVE
= 5,
657 wxTEXT_BOX_ATTR_BORDER_RIDGE
= 6,
658 wxTEXT_BOX_ATTR_BORDER_INSET
= 7,
659 wxTEXT_BOX_ATTR_BORDER_OUTSET
= 8
662 // Border style presence flags
663 enum wxTextAttrBorderFlags
665 wxTEXT_BOX_ATTR_BORDER_STYLE
= 0x0001,
666 wxTEXT_BOX_ATTR_BORDER_COLOUR
= 0x0002
669 // Border width symbols for qualitative widths
670 enum wxTextAttrBorderWidth
672 wxTEXT_BOX_ATTR_BORDER_THIN
= -1,
673 wxTEXT_BOX_ATTR_BORDER_MEDIUM
= -2,
674 wxTEXT_BOX_ATTR_BORDER_THICK
= -3
678 enum wxTextBoxAttrFloatStyle
680 wxTEXT_BOX_ATTR_FLOAT_NONE
= 0,
681 wxTEXT_BOX_ATTR_FLOAT_LEFT
= 1,
682 wxTEXT_BOX_ATTR_FLOAT_RIGHT
= 2
686 enum wxTextBoxAttrClearStyle
688 wxTEXT_BOX_ATTR_CLEAR_NONE
= 0,
689 wxTEXT_BOX_ATTR_CLEAR_LEFT
= 1,
690 wxTEXT_BOX_ATTR_CLEAR_RIGHT
= 2,
691 wxTEXT_BOX_ATTR_CLEAR_BOTH
= 3
694 // Collapse mode styles. TODO: can they be switched on per side?
695 enum wxTextBoxAttrCollapseMode
697 wxTEXT_BOX_ATTR_COLLAPSE_NONE
= 0,
698 wxTEXT_BOX_ATTR_COLLAPSE_FULL
= 1
701 // Vertical alignment values
702 enum wxTextBoxAttrVerticalAlignment
704 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE
= 0,
705 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP
= 1,
706 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE
= 2,
707 wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM
= 3
711 @class wxTextAttrBorder
712 A class representing a rich text object border.
717 @see wxRichTextAttr, wxRichTextCtrl, wxRichTextAttrBorders
720 class WXDLLIMPEXP_RICHTEXT wxTextAttrBorder
726 wxTextAttrBorder() { Reset(); }
731 bool operator==(const wxTextAttrBorder
& border
) const
733 return m_flags
== border
.m_flags
&& m_borderStyle
== border
.m_borderStyle
&&
734 m_borderColour
== border
.m_borderColour
&& m_borderWidth
== border
.m_borderWidth
;
738 Resets the border style, colour, width and flags.
740 void Reset() { m_borderStyle
= 0; m_borderColour
= 0; m_flags
= 0; m_borderWidth
.Reset(); }
743 Partial equality test.
745 bool EqPartial(const wxTextAttrBorder
& border
) const;
748 Applies the border to this object, but not if the same as @a compareWith.
751 bool Apply(const wxTextAttrBorder
& border
, const wxTextAttrBorder
* compareWith
= NULL
);
754 Removes the specified attributes from this object.
756 bool RemoveStyle(const wxTextAttrBorder
& attr
);
759 Collects the attributes that are common to a range of content, building up a note of
760 which attributes are absent in some objects and which clash in some objects.
762 void CollectCommonAttributes(const wxTextAttrBorder
& attr
, wxTextAttrBorder
& clashingAttr
, wxTextAttrBorder
& absentAttr
);
765 Sets the border style.
767 void SetStyle(int style
) { m_borderStyle
= style
; m_flags
|= wxTEXT_BOX_ATTR_BORDER_STYLE
; }
770 Gets the border style.
773 int GetStyle() const { return m_borderStyle
; }
776 Sets the border colour.
778 void SetColour(unsigned long colour
) { m_borderColour
= colour
; m_flags
|= wxTEXT_BOX_ATTR_BORDER_COLOUR
; }
781 Sets the border colour.
783 void SetColour(const wxColour
& colour
) { m_borderColour
= colour
.GetRGB(); m_flags
|= wxTEXT_BOX_ATTR_BORDER_COLOUR
; }
786 Gets the colour as a long.
788 unsigned long GetColourLong() const { return m_borderColour
; }
793 wxColour
GetColour() const { return wxColour(m_borderColour
); }
796 Gets the border width.
798 wxTextAttrDimension
& GetWidth() { return m_borderWidth
; }
799 const wxTextAttrDimension
& GetWidth() const { return m_borderWidth
; }
802 Sets the border width.
804 void SetWidth(const wxTextAttrDimension
& width
) { m_borderWidth
= width
; }
806 Sets the border width.
808 void SetWidth(int value
, wxTextAttrUnits units
= wxTEXT_ATTR_UNITS_TENTHS_MM
) { SetWidth(wxTextAttrDimension(value
, units
)); }
811 True if the border has a valid style.
813 bool HasStyle() const { return (m_flags
& wxTEXT_BOX_ATTR_BORDER_STYLE
) != 0; }
816 True if the border has a valid colour.
818 bool HasColour() const { return (m_flags
& wxTEXT_BOX_ATTR_BORDER_COLOUR
) != 0; }
821 True if the border has a valid width.
823 bool HasWidth() const { return m_borderWidth
.IsValid(); }
826 True if the border is valid.
828 bool IsValid() const { return HasWidth(); }
831 Set the valid flag for this border.
833 void MakeValid() { m_borderWidth
.SetValid(true); }
836 Returns the border flags.
838 int GetFlags() const { return m_flags
; }
841 Sets the border flags.
843 void SetFlags(int flags
) { m_flags
= flags
; }
848 void AddFlag(int flag
) { m_flags
|= flag
; }
851 Removes a border flag.
853 void RemoveFlag(int flag
) { m_flags
&= ~flag
; }
856 unsigned long m_borderColour
;
857 wxTextAttrDimension m_borderWidth
;
862 @class wxTextAttrBorders
863 A class representing a rich text object's borders.
868 @see wxRichTextAttr, wxRichTextCtrl, wxRichTextAttrBorder
871 class WXDLLIMPEXP_RICHTEXT wxTextAttrBorders
877 wxTextAttrBorders() { }
882 bool operator==(const wxTextAttrBorders
& borders
) const
884 return m_left
== borders
.m_left
&& m_right
== borders
.m_right
&&
885 m_top
== borders
.m_top
&& m_bottom
== borders
.m_bottom
;
889 Sets the style of all borders.
891 void SetStyle(int style
);
894 Sets colour of all borders.
896 void SetColour(unsigned long colour
);
899 Sets the colour for all borders.
901 void SetColour(const wxColour
& colour
);
904 Sets the width of all borders.
906 void SetWidth(const wxTextAttrDimension
& width
);
909 Sets the width of all borders.
911 void SetWidth(int value
, wxTextAttrUnits units
= wxTEXT_ATTR_UNITS_TENTHS_MM
) { SetWidth(wxTextAttrDimension(value
, units
)); }
916 void Reset() { m_left
.Reset(); m_right
.Reset(); m_top
.Reset(); m_bottom
.Reset(); }
919 Partial equality test.
921 bool EqPartial(const wxTextAttrBorders
& borders
) const;
924 Applies border to this object, but not if the same as @a compareWith.
926 bool Apply(const wxTextAttrBorders
& borders
, const wxTextAttrBorders
* compareWith
= NULL
);
929 Removes the specified attributes from this object.
931 bool RemoveStyle(const wxTextAttrBorders
& attr
);
934 Collects the attributes that are common to a range of content, building up a note of
935 which attributes are absent in some objects and which clash in some objects.
937 void CollectCommonAttributes(const wxTextAttrBorders
& attr
, wxTextAttrBorders
& clashingAttr
, wxTextAttrBorders
& absentAttr
);
940 Returns @true if all borders are valid.
942 bool IsValid() const { return m_left
.IsValid() || m_right
.IsValid() || m_top
.IsValid() || m_bottom
.IsValid(); }
945 Returns the left border.
947 const wxTextAttrBorder
& GetLeft() const { return m_left
; }
948 wxTextAttrBorder
& GetLeft() { return m_left
; }
951 Returns the right border.
953 const wxTextAttrBorder
& GetRight() const { return m_right
; }
954 wxTextAttrBorder
& GetRight() { return m_right
; }
957 Returns the top border.
959 const wxTextAttrBorder
& GetTop() const { return m_top
; }
960 wxTextAttrBorder
& GetTop() { return m_top
; }
963 Returns the bottom border.
965 const wxTextAttrBorder
& GetBottom() const { return m_bottom
; }
966 wxTextAttrBorder
& GetBottom() { return m_bottom
; }
968 wxTextAttrBorder m_left
, m_right
, m_top
, m_bottom
;
974 A class representing the box attributes of a rich text object.
979 @see wxRichTextAttr, wxRichTextCtrl
982 class WXDLLIMPEXP_RICHTEXT wxTextBoxAttr
988 wxTextBoxAttr() { Init(); }
993 wxTextBoxAttr(const wxTextBoxAttr
& attr
) { Init(); (*this) = attr
; }
996 Initialises this object.
998 void Init() { Reset(); }
1005 // Copy. Unnecessary since we let it do a binary copy
1006 //void Copy(const wxTextBoxAttr& attr);
1009 //void operator= (const wxTextBoxAttr& attr);
1014 bool operator== (const wxTextBoxAttr
& attr
) const;
1017 Partial equality test, ignoring unset attributes.
1020 bool EqPartial(const wxTextBoxAttr
& attr
) const;
1023 Merges the given attributes. If @a compareWith is non-NULL, then it will be used
1024 to mask out those attributes that are the same in style and @a compareWith, for
1025 situations where we don't want to explicitly set inherited attributes.
1027 bool Apply(const wxTextBoxAttr
& style
, const wxTextBoxAttr
* compareWith
= NULL
);
1030 Collects the attributes that are common to a range of content, building up a note of
1031 which attributes are absent in some objects and which clash in some objects.
1033 void CollectCommonAttributes(const wxTextBoxAttr
& attr
, wxTextBoxAttr
& clashingAttr
, wxTextBoxAttr
& absentAttr
);
1036 Removes the specified attributes from this object.
1038 bool RemoveStyle(const wxTextBoxAttr
& attr
);
1043 void SetFlags(int flags
) { m_flags
= flags
; }
1048 int GetFlags() const { return m_flags
; }
1051 Is this flag present?
1053 bool HasFlag(wxTextBoxAttrFlags flag
) const { return (m_flags
& flag
) != 0; }
1058 void RemoveFlag(wxTextBoxAttrFlags flag
) { m_flags
&= ~flag
; }
1063 void AddFlag(wxTextBoxAttrFlags flag
) { m_flags
|= flag
; }
1066 Returns @true if no attributes are set.
1068 bool IsDefault() const;
1071 Returns the float mode.
1073 wxTextBoxAttrFloatStyle
GetFloatMode() const { return m_floatMode
; }
1076 Sets the float mode.
1078 void SetFloatMode(wxTextBoxAttrFloatStyle mode
) { m_floatMode
= mode
; m_flags
|= wxTEXT_BOX_ATTR_FLOAT
; }
1081 Returns @true if float mode is active.
1083 bool HasFloatMode() const { return HasFlag(wxTEXT_BOX_ATTR_FLOAT
); }
1086 Returns @true if this object is floating?
1088 bool IsFloating() const { return HasFloatMode() && GetFloatMode() != wxTEXT_BOX_ATTR_FLOAT_NONE
; }
1091 Returns the clear mode - whether to wrap text after object. Currently unimplemented.
1093 wxTextBoxAttrClearStyle
GetClearMode() const { return m_clearMode
; }
1096 Set the clear mode. Currently unimplemented.
1098 void SetClearMode(wxTextBoxAttrClearStyle mode
) { m_clearMode
= mode
; m_flags
|= wxTEXT_BOX_ATTR_CLEAR
; }
1101 Returns @true if we have a clear flag.
1103 bool HasClearMode() const { return HasFlag(wxTEXT_BOX_ATTR_CLEAR
); }
1106 Returns the collapse mode - whether to collapse borders. Currently unimplemented.
1108 wxTextBoxAttrCollapseMode
GetCollapseBorders() const { return m_collapseMode
; }
1111 Sets the collapse mode - whether to collapse borders. Currently unimplemented.
1113 void SetCollapseBorders(wxTextBoxAttrCollapseMode collapse
) { m_collapseMode
= collapse
; m_flags
|= wxTEXT_BOX_ATTR_COLLAPSE_BORDERS
; }
1116 Returns @true if the collapse borders flag is present.
1118 bool HasCollapseBorders() const { return HasFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS
); }
1121 Returns the vertical alignment.
1123 wxTextBoxAttrVerticalAlignment
GetVerticalAlignment() const { return m_verticalAlignment
; }
1126 Sets the vertical alignment.
1128 void SetVerticalAlignment(wxTextBoxAttrVerticalAlignment verticalAlignment
) { m_verticalAlignment
= verticalAlignment
; m_flags
|= wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
; }
1131 Returns @true if a vertical alignment flag is present.
1133 bool HasVerticalAlignment() const { return HasFlag(wxTEXT_BOX_ATTR_VERTICAL_ALIGNMENT
); }
1136 Returns the margin values.
1138 wxTextAttrDimensions
& GetMargins() { return m_margins
; }
1139 const wxTextAttrDimensions
& GetMargins() const { return m_margins
; }
1142 Returns the left margin.
1144 wxTextAttrDimension
& GetLeftMargin() { return m_margins
.m_left
; }
1145 const wxTextAttrDimension
& GetLeftMargin() const { return m_margins
.m_left
; }
1148 Returns the right margin.
1150 wxTextAttrDimension
& GetRightMargin() { return m_margins
.m_right
; }
1151 const wxTextAttrDimension
& GetRightMargin() const { return m_margins
.m_right
; }
1154 Returns the top margin.
1156 wxTextAttrDimension
& GetTopMargin() { return m_margins
.m_top
; }
1157 const wxTextAttrDimension
& GetTopMargin() const { return m_margins
.m_top
; }
1160 Returns the bottom margin.
1162 wxTextAttrDimension
& GetBottomMargin() { return m_margins
.m_bottom
; }
1163 const wxTextAttrDimension
& GetBottomMargin() const { return m_margins
.m_bottom
; }
1166 Returns the position.
1168 wxTextAttrDimensions
& GetPosition() { return m_position
; }
1169 const wxTextAttrDimensions
& GetPosition() const { return m_position
; }
1172 Returns the left position.
1174 wxTextAttrDimension
& GetLeft() { return m_position
.m_left
; }
1175 const wxTextAttrDimension
& GetLeft() const { return m_position
.m_left
; }
1178 Returns the right position.
1180 wxTextAttrDimension
& GetRight() { return m_position
.m_right
; }
1181 const wxTextAttrDimension
& GetRight() const { return m_position
.m_right
; }
1184 Returns the top position.
1186 wxTextAttrDimension
& GetTop() { return m_position
.m_top
; }
1187 const wxTextAttrDimension
& GetTop() const { return m_position
.m_top
; }
1190 Returns the bottom position.
1192 wxTextAttrDimension
& GetBottom() { return m_position
.m_bottom
; }
1193 const wxTextAttrDimension
& GetBottom() const { return m_position
.m_bottom
; }
1196 Returns the padding values.
1198 wxTextAttrDimensions
& GetPadding() { return m_padding
; }
1199 const wxTextAttrDimensions
& GetPadding() const { return m_padding
; }
1202 Returns the left padding value.
1204 wxTextAttrDimension
& GetLeftPadding() { return m_padding
.m_left
; }
1205 const wxTextAttrDimension
& GetLeftPadding() const { return m_padding
.m_left
; }
1208 Returns the right padding value.
1210 wxTextAttrDimension
& GetRightPadding() { return m_padding
.m_right
; }
1211 const wxTextAttrDimension
& GetRightPadding() const { return m_padding
.m_right
; }
1214 Returns the top padding value.
1216 wxTextAttrDimension
& GetTopPadding() { return m_padding
.m_top
; }
1217 const wxTextAttrDimension
& GetTopPadding() const { return m_padding
.m_top
; }
1220 Returns the bottom padding value.
1222 wxTextAttrDimension
& GetBottomPadding() { return m_padding
.m_bottom
; }
1223 const wxTextAttrDimension
& GetBottomPadding() const { return m_padding
.m_bottom
; }
1226 Returns the borders.
1228 wxTextAttrBorders
& GetBorder() { return m_border
; }
1229 const wxTextAttrBorders
& GetBorder() const { return m_border
; }
1232 Returns the left border.
1234 wxTextAttrBorder
& GetLeftBorder() { return m_border
.m_left
; }
1235 const wxTextAttrBorder
& GetLeftBorder() const { return m_border
.m_left
; }
1238 Returns the top border.
1240 wxTextAttrBorder
& GetTopBorder() { return m_border
.m_top
; }
1241 const wxTextAttrBorder
& GetTopBorder() const { return m_border
.m_top
; }
1244 Returns the right border.
1246 wxTextAttrBorder
& GetRightBorder() { return m_border
.m_right
; }
1247 const wxTextAttrBorder
& GetRightBorder() const { return m_border
.m_right
; }
1250 Returns the bottom border.
1252 wxTextAttrBorder
& GetBottomBorder() { return m_border
.m_bottom
; }
1253 const wxTextAttrBorder
& GetBottomBorder() const { return m_border
.m_bottom
; }
1256 Returns the outline.
1258 wxTextAttrBorders
& GetOutline() { return m_outline
; }
1259 const wxTextAttrBorders
& GetOutline() const { return m_outline
; }
1262 Returns the left outline.
1264 wxTextAttrBorder
& GetLeftOutline() { return m_outline
.m_left
; }
1265 const wxTextAttrBorder
& GetLeftOutline() const { return m_outline
.m_left
; }
1268 Returns the top outline.
1270 wxTextAttrBorder
& GetTopOutline() { return m_outline
.m_top
; }
1271 const wxTextAttrBorder
& GetTopOutline() const { return m_outline
.m_top
; }
1274 Returns the right outline.
1276 wxTextAttrBorder
& GetRightOutline() { return m_outline
.m_right
; }
1277 const wxTextAttrBorder
& GetRightOutline() const { return m_outline
.m_right
; }
1280 Returns the bottom outline.
1282 wxTextAttrBorder
& GetBottomOutline() { return m_outline
.m_bottom
; }
1283 const wxTextAttrBorder
& GetBottomOutline() const { return m_outline
.m_bottom
; }
1286 Returns the object size.
1288 wxTextAttrSize
& GetSize() { return m_size
; }
1289 const wxTextAttrSize
& GetSize() const { return m_size
; }
1292 Sets the object size.
1294 void SetSize(const wxTextAttrSize
& sz
) { m_size
= sz
; }
1297 Returns the object width.
1299 wxTextAttrDimension
& GetWidth() { return m_size
.m_width
; }
1300 const wxTextAttrDimension
& GetWidth() const { return m_size
.m_width
; }
1303 Returns the object height.
1305 wxTextAttrDimension
& GetHeight() { return m_size
.m_height
; }
1306 const wxTextAttrDimension
& GetHeight() const { return m_size
.m_height
; }
1312 wxTextAttrDimensions m_margins
;
1313 wxTextAttrDimensions m_padding
;
1314 wxTextAttrDimensions m_position
;
1316 wxTextAttrSize m_size
;
1318 wxTextAttrBorders m_border
;
1319 wxTextAttrBorders m_outline
;
1321 wxTextBoxAttrFloatStyle m_floatMode
;
1322 wxTextBoxAttrClearStyle m_clearMode
;
1323 wxTextBoxAttrCollapseMode m_collapseMode
;
1324 wxTextBoxAttrVerticalAlignment m_verticalAlignment
;
1328 @class wxRichTextAttr
1329 A class representing enhanced attributes for rich text objects.
1330 This adds a wxTextBoxAttr member to the basic wxTextAttr class.
1332 @library{wxrichtext}
1335 @see wxRichTextAttr, wxTextBoxAttr, wxRichTextCtrl
1338 class WXDLLIMPEXP_RICHTEXT wxRichTextAttr
: public wxTextAttr
1342 Constructor taking a wxTextAttr.
1344 wxRichTextAttr(const wxTextAttr
& attr
) { wxTextAttr::Copy(attr
); }
1349 wxRichTextAttr(const wxRichTextAttr
& attr
): wxTextAttr() { Copy(attr
); }
1352 Default constructor.
1359 void Copy(const wxRichTextAttr
& attr
);
1362 Assignment operator.
1364 void operator=(const wxRichTextAttr
& attr
) { Copy(attr
); }
1367 Assignment operator.
1369 void operator=(const wxTextAttr
& attr
) { wxTextAttr::Copy(attr
); }
1374 bool operator==(const wxRichTextAttr
& attr
) const;
1377 Partial equality test taking comparison object into account.
1379 bool EqPartial(const wxRichTextAttr
& attr
) const;
1382 Merges the given attributes. If @a compareWith
1383 is non-NULL, then it will be used to mask out those attributes that are the same in style
1384 and @a compareWith, for situations where we don't want to explicitly set inherited attributes.
1386 bool Apply(const wxRichTextAttr
& style
, const wxRichTextAttr
* compareWith
= NULL
);
1389 Collects the attributes that are common to a range of content, building up a note of
1390 which attributes are absent in some objects and which clash in some objects.
1392 void CollectCommonAttributes(const wxRichTextAttr
& attr
, wxRichTextAttr
& clashingAttr
, wxRichTextAttr
& absentAttr
);
1395 Removes the specified attributes from this object.
1397 bool RemoveStyle(const wxRichTextAttr
& attr
);
1400 Returns the text box attributes.
1402 wxTextBoxAttr
& GetTextBoxAttr() { return m_textBoxAttr
; }
1403 const wxTextBoxAttr
& GetTextBoxAttr() const { return m_textBoxAttr
; }
1406 Set the text box attributes.
1408 void SetTextBoxAttr(const wxTextBoxAttr
& attr
) { m_textBoxAttr
= attr
; }
1410 wxTextBoxAttr m_textBoxAttr
;
1413 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxVariant
, wxRichTextVariantArray
, WXDLLIMPEXP_RICHTEXT
);
1416 @class wxRichTextProperties
1417 A simple property class using wxVariants. This is used to give each rich text object the
1418 ability to store custom properties that can be used by the application.
1420 @library{wxrichtext}
1423 @see wxRichTextBuffer, wxRichTextObject, wxRichTextCtrl
1426 class WXDLLIMPEXP_RICHTEXT wxRichTextProperties
: public wxObject
1428 DECLARE_DYNAMIC_CLASS(wxRichTextProperties
)
1432 Default constructor.
1434 wxRichTextProperties() {}
1439 wxRichTextProperties(const wxRichTextProperties
& props
): wxObject() { Copy(props
); }
1442 Assignment operator.
1444 void operator=(const wxRichTextProperties
& props
) { Copy(props
); }
1449 bool operator==(const wxRichTextProperties
& props
) const;
1452 Copies from @a props.
1454 void Copy(const wxRichTextProperties
& props
) { m_properties
= props
.m_properties
; }
1457 Returns the variant at the given index.
1459 const wxVariant
& operator[](size_t idx
) const { return m_properties
[idx
]; }
1462 Returns the variant at the given index.
1464 wxVariant
& operator[](size_t idx
) { return m_properties
[idx
]; }
1467 Clears the properties.
1469 void Clear() { m_properties
.Clear(); }
1472 Returns the array of variants implementing the properties.
1474 const wxRichTextVariantArray
& GetProperties() const { return m_properties
; }
1477 Returns the array of variants implementing the properties.
1479 wxRichTextVariantArray
& GetProperties() { return m_properties
; }
1482 Sets the array of variants.
1484 void SetProperties(const wxRichTextVariantArray
& props
) { m_properties
= props
; }
1487 Returns all the property names.
1489 wxArrayString
GetPropertyNames() const;
1492 Returns a count of the properties.
1494 size_t GetCount() const { return m_properties
.GetCount(); }
1497 Returns @true if the given property is found.
1499 bool HasProperty(const wxString
& name
) const { return Find(name
) != -1; }
1502 Finds the given property.
1504 int Find(const wxString
& name
) const;
1507 Gets the property variant by name.
1509 const wxVariant
& GetProperty(const wxString
& name
) const;
1512 Finds or creates a property with the given name, returning a pointer to the variant.
1514 wxVariant
* FindOrCreateProperty(const wxString
& name
);
1517 Gets the value of the named property as a string.
1519 wxString
GetPropertyString(const wxString
& name
) const;
1522 Gets the value of the named property as a long integer.
1524 long GetPropertyLong(const wxString
& name
) const;
1527 Gets the value of the named property as a boolean.
1529 bool GetPropertyBool(const wxString
& name
) const;
1532 Gets the value of the named property as a double.
1534 double GetPropertyDouble(const wxString
& name
) const;
1537 Sets the property by passing a variant which contains a name and value.
1539 void SetProperty(const wxVariant
& variant
);
1542 Sets a property by name and variant.
1544 void SetProperty(const wxString
& name
, const wxVariant
& variant
);
1547 Sets a property by name and string value.
1549 void SetProperty(const wxString
& name
, const wxString
& value
);
1552 Sets property by name and long integer value.
1554 void SetProperty(const wxString
& name
, long value
);
1557 Sets property by name and double value.
1559 void SetProperty(const wxString
& name
, double value
);
1562 Sets property by name and boolean value.
1564 void SetProperty(const wxString
& name
, bool value
);
1567 wxRichTextVariantArray m_properties
;
1572 @class wxRichTextFontTable
1573 Manages quick access to a pool of fonts for rendering rich text.
1575 @library{wxrichtext}
1578 @see wxRichTextBuffer, wxRichTextCtrl
1581 class WXDLLIMPEXP_RICHTEXT wxRichTextFontTable
: public wxObject
1585 Default constructor.
1587 wxRichTextFontTable();
1592 wxRichTextFontTable(const wxRichTextFontTable
& table
);
1593 virtual ~wxRichTextFontTable();
1596 Returns @true if the font table is valid.
1598 bool IsOk() const { return m_refData
!= NULL
; }
1601 Finds a font for the given attribute object.
1603 wxFont
FindFont(const wxRichTextAttr
& fontSpec
);
1606 Clears the font table.
1611 Assignment operator.
1613 void operator= (const wxRichTextFontTable
& table
);
1618 bool operator == (const wxRichTextFontTable
& table
) const;
1621 Inequality operator.
1623 bool operator != (const wxRichTextFontTable
& table
) const { return !(*this == table
); }
1627 DECLARE_DYNAMIC_CLASS(wxRichTextFontTable
)
1631 @class wxRichTextRange
1633 This stores beginning and end positions for a range of data.
1635 @library{wxrichtext}
1638 @see wxRichTextBuffer, wxRichTextCtrl
1641 class WXDLLIMPEXP_RICHTEXT wxRichTextRange
1647 Default constructor.
1649 wxRichTextRange() { m_start
= 0; m_end
= 0; }
1652 Constructor taking start and end positions.
1654 wxRichTextRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
1659 wxRichTextRange(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
1660 ~wxRichTextRange() {}
1663 Assignment operator.
1665 void operator =(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
1670 bool operator ==(const wxRichTextRange
& range
) const { return (m_start
== range
.m_start
&& m_end
== range
.m_end
); }
1673 Inequality operator.
1675 bool operator !=(const wxRichTextRange
& range
) const { return (m_start
!= range
.m_start
|| m_end
!= range
.m_end
); }
1678 Subtracts a range from this range.
1680 wxRichTextRange
operator -(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
- range
.m_start
, m_end
- range
.m_end
); }
1683 Adds a range to this range.
1685 wxRichTextRange
operator +(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
+ range
.m_start
, m_end
+ range
.m_end
); }
1688 Sets the range start and end positions.
1690 void SetRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
1693 Sets the start position.
1695 void SetStart(long start
) { m_start
= start
; }
1698 Returns the start position.
1700 long GetStart() const { return m_start
; }
1703 Sets the end position.
1705 void SetEnd(long end
) { m_end
= end
; }
1708 Gets the end position.
1710 long GetEnd() const { return m_end
; }
1713 Returns true if this range is completely outside @a range.
1715 bool IsOutside(const wxRichTextRange
& range
) const { return range
.m_start
> m_end
|| range
.m_end
< m_start
; }
1718 Returns true if this range is completely within @a range.
1720 bool IsWithin(const wxRichTextRange
& range
) const { return m_start
>= range
.m_start
&& m_end
<= range
.m_end
; }
1723 Returns true if @a pos was within the range.
1725 bool Contains(long pos
) const { return pos
>= m_start
&& pos
<= m_end
; }
1728 Limit this range to be within @a range.
1730 bool LimitTo(const wxRichTextRange
& range
) ;
1733 Gets the length of the range.
1735 long GetLength() const { return m_end
- m_start
+ 1; }
1738 Swaps the start and end.
1740 void Swap() { long tmp
= m_start
; m_start
= m_end
; m_end
= tmp
; }
1743 Convert to internal form: (n, n) is the range of a single character.
1745 wxRichTextRange
ToInternal() const { return wxRichTextRange(m_start
, m_end
-1); }
1748 Convert from internal to public API form: (n, n+1) is the range of a single character.
1750 wxRichTextRange
FromInternal() const { return wxRichTextRange(m_start
, m_end
+1); }
1757 WX_DECLARE_USER_EXPORTED_OBJARRAY(wxRichTextRange
, wxRichTextRangeArray
, WXDLLIMPEXP_RICHTEXT
);
1759 #define wxRICHTEXT_ALL wxRichTextRange(-2, -2)
1760 #define wxRICHTEXT_NONE wxRichTextRange(-1, -1)
1762 #define wxRICHTEXT_NO_SELECTION wxRichTextRange(-2, -2)
1765 @class wxRichTextSelection
1767 Stores selection information. The selection does not have to be contiguous, though currently non-contiguous
1768 selections are only supported for a range of table cells (a geometric block of cells can consist
1769 of a set of non-contiguous positions).
1771 The selection consists of an array of ranges, and the container that is the context for the selection. It
1772 follows that a single selection object can only represent ranges with the same parent container.
1774 @library{wxrichtext}
1777 @see wxRichTextBuffer, wxRichTextCtrl
1780 class WXDLLIMPEXP_RICHTEXT wxRichTextSelection
1786 wxRichTextSelection(const wxRichTextSelection
& sel
) { Copy(sel
); }
1789 Creates a selection from a range and a container.
1791 wxRichTextSelection(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
* container
) { m_ranges
.Add(range
); m_container
= container
; }
1794 Default constructor.
1796 wxRichTextSelection() { Reset(); }
1799 Resets the selection.
1801 void Reset() { m_ranges
.Clear(); m_container
= NULL
; }
1807 void Set(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
* container
)
1808 { m_ranges
.Clear(); m_ranges
.Add(range
); m_container
= container
; }
1813 void Add(const wxRichTextRange
& range
)
1814 { m_ranges
.Add(range
); }
1817 Sets the selections from an array of ranges and a container object.
1819 void Set(const wxRichTextRangeArray
& ranges
, wxRichTextParagraphLayoutBox
* container
)
1820 { m_ranges
= ranges
; m_container
= container
; }
1825 void Copy(const wxRichTextSelection
& sel
)
1826 { m_ranges
= sel
.m_ranges
; m_container
= sel
.m_container
; }
1829 Assignment operator.
1831 void operator=(const wxRichTextSelection
& sel
) { Copy(sel
); }
1836 bool operator==(const wxRichTextSelection
& sel
) const;
1841 wxRichTextRange
operator[](size_t i
) const { return GetRange(i
); }
1844 Returns the selection ranges.
1846 wxRichTextRangeArray
& GetRanges() { return m_ranges
; }
1849 Returns the selection ranges.
1851 const wxRichTextRangeArray
& GetRanges() const { return m_ranges
; }
1854 Sets the selection ranges.
1856 void SetRanges(const wxRichTextRangeArray
& ranges
) { m_ranges
= ranges
; }
1859 Returns the number of ranges in the selection.
1861 size_t GetCount() const { return m_ranges
.GetCount(); }
1864 Returns the range at the given index.
1867 wxRichTextRange
GetRange(size_t i
) const { return m_ranges
[i
]; }
1870 Returns the first range if there is one, otherwise wxRICHTEXT_NO_SELECTION.
1872 wxRichTextRange
GetRange() const { return (m_ranges
.GetCount() > 0) ? (m_ranges
[0]) : wxRICHTEXT_NO_SELECTION
; }
1875 Sets a single range.
1877 void SetRange(const wxRichTextRange
& range
) { m_ranges
.Clear(); m_ranges
.Add(range
); }
1880 Returns the container for which the selection is valid.
1882 wxRichTextParagraphLayoutBox
* GetContainer() const { return m_container
; }
1885 Sets the container for which the selection is valid.
1887 void SetContainer(wxRichTextParagraphLayoutBox
* container
) { m_container
= container
; }
1890 Returns @true if the selection is valid.
1892 bool IsValid() const { return m_ranges
.GetCount() > 0 && GetContainer(); }
1895 Returns the selection appropriate to the specified object, if any; returns an empty array if none
1896 at the level of the object's container.
1898 wxRichTextRangeArray
GetSelectionForObject(wxRichTextObject
* obj
) const;
1901 Returns @true if the given position is within the selection.
1903 bool WithinSelection(long pos
, wxRichTextObject
* obj
) const;
1906 Returns @true if the given position is within the selection.
1909 bool WithinSelection(long pos
) const { return WithinSelection(pos
, m_ranges
); }
1912 Returns @true if the given position is within the selection range.
1914 static bool WithinSelection(long pos
, const wxRichTextRangeArray
& ranges
);
1917 Returns @true if the given range is within the selection range.
1919 static bool WithinSelection(const wxRichTextRange
& range
, const wxRichTextRangeArray
& ranges
);
1921 wxRichTextRangeArray m_ranges
;
1922 wxRichTextParagraphLayoutBox
* m_container
;
1926 * wxRichTextObject class declaration
1927 * This is the base for drawable objects.
1930 class WXDLLIMPEXP_RICHTEXT wxRichTextObject
: public wxObject
1932 DECLARE_CLASS(wxRichTextObject
)
1936 wxRichTextObject(wxRichTextObject
* parent
= NULL
);
1937 virtual ~wxRichTextObject();
1941 /// Draw the item, within the given range. Some objects may ignore the range (for
1942 /// example paragraphs) while others must obey it (lines, to implement wrapping)
1943 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
) = 0;
1945 /// Lay the item out at the specified position with the given size constraint.
1946 /// Layout must set the cached size.
1947 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
) = 0;
1949 /// Hit-testing: returns a flag indicating hit test details, plus
1950 /// information about position. contextObj is returned to specify what object
1951 /// position is relevant to, since otherwise there's an ambiguity.
1952 /// obj may not a child of contextObj, since we may be referring to the container itself
1953 /// if we have no hit on a child - for example if we click outside an object.
1954 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
1956 /// Finds the absolute position and row height for the given character position
1957 virtual bool FindPosition(wxDC
& WXUNUSED(dc
), long WXUNUSED(index
), wxPoint
& WXUNUSED(pt
), int* WXUNUSED(height
), bool WXUNUSED(forceLineStart
)) { return false; }
1959 /// Get the best size, i.e. the ideal starting size for this object irrespective
1960 /// of available space. For a short text string, it will be the size that exactly encloses
1961 /// the text. For a longer string, it might use the parent width for example.
1962 virtual wxSize
GetBestSize() const { return m_size
; }
1965 Gets the object size for the given range. Returns false if the range
1966 is invalid for this object.
1969 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const = 0;
1971 /// Do a split, returning an object containing the second part, and setting
1972 /// the first part in 'this'.
1973 virtual wxRichTextObject
* DoSplit(long WXUNUSED(pos
)) { return NULL
; }
1975 /// Calculate range. By default, guess that the object is 1 unit long.
1976 virtual void CalculateRange(long start
, long& end
) { end
= start
; m_range
.SetRange(start
, end
); }
1979 virtual bool DeleteRange(const wxRichTextRange
& WXUNUSED(range
)) { return false; }
1981 /// Returns true if the object is empty
1982 virtual bool IsEmpty() const { return false; }
1984 /// Whether this object floatable
1985 virtual bool IsFloatable() const { return false; }
1987 /// Whether this object is currently floating
1988 virtual bool IsFloating() const { return GetAttributes().GetTextBoxAttr().IsFloating(); }
1990 /// Whether this object is a place holding one
1991 // virtual bool IsPlaceHolding() const { return false; }
1993 /// The floating direction
1994 virtual int GetFloatDirection() const { return GetAttributes().GetTextBoxAttr().GetFloatMode(); }
1996 /// Get any text in this object for the given range
1997 virtual wxString
GetTextForRange(const wxRichTextRange
& WXUNUSED(range
)) const { return wxEmptyString
; }
1999 /// Returns true if this object can merge itself with the given one.
2000 virtual bool CanMerge(wxRichTextObject
* WXUNUSED(object
)) const { return false; }
2002 /// Returns true if this object merged itself with the given one.
2003 /// The calling code will then delete the given object.
2004 virtual bool Merge(wxRichTextObject
* WXUNUSED(object
)) { return false; }
2006 /// Dump to output stream for debugging
2007 virtual void Dump(wxTextOutputStream
& stream
);
2009 /// Can we edit properties via a GUI?
2010 virtual bool CanEditProperties() const { return false; }
2012 /// Edit properties via a GUI
2013 virtual bool EditProperties(wxWindow
* WXUNUSED(parent
), wxRichTextBuffer
* WXUNUSED(buffer
)) { return false; }
2015 /// Return the label to be used for the properties context menu item.
2016 virtual wxString
GetPropertiesMenuLabel() const { return wxEmptyString
; }
2018 /// Returns true if objects of this class can accept the focus, i.e. a call to SetFocusObject
2019 /// is possible. For example, containers supporting text, such as a text box object, can accept the focus,
2020 /// but a table can't (set the focus to individual cells instead).
2021 virtual bool AcceptsFocus() const { return false; }
2024 /// Import this object from XML
2025 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
2028 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2029 /// Export this object directly to the given stream.
2030 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
2033 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2034 /// Export this object to the given parent node, usually creating at least one child node.
2035 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
2038 /// Does this object take note of paragraph attributes? Text and image objects don't.
2039 virtual bool UsesParagraphAttributes() const { return true; }
2041 /// What is the XML node name of this object?
2042 virtual wxString
GetXMLNodeName() const { return wxT("unknown"); }
2044 /// Invalidate the buffer. With no argument, invalidates whole buffer.
2045 virtual void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
2047 /// Can this object handle the selections of its children? FOr example, a table.
2048 virtual bool HandlesChildSelections() const { return false; }
2050 /// Returns a selection object specifying the selections between start and end character positions.
2051 /// For example, a table would deduce what cells (of range length 1) are selected when dragging across the table.
2052 virtual wxRichTextSelection
GetSelection(long WXUNUSED(start
), long WXUNUSED(end
)) const { return wxRichTextSelection(); }
2056 /// Get/set the cached object size as calculated by Layout.
2057 virtual wxSize
GetCachedSize() const { return m_size
; }
2058 virtual void SetCachedSize(const wxSize
& sz
) { m_size
= sz
; }
2060 /// Get/set the maximum object size as calculated by Layout. This allows
2061 /// us to fit an object to its contents or allocate extra space if required.
2062 virtual wxSize
GetMaxSize() const { return m_maxSize
; }
2063 virtual void SetMaxSize(const wxSize
& sz
) { m_maxSize
= sz
; }
2065 /// Get/set the minimum object size as calculated by Layout. This allows
2066 /// us to constrain an object to its absolute minimum size if necessary.
2067 virtual wxSize
GetMinSize() const { return m_minSize
; }
2068 virtual void SetMinSize(const wxSize
& sz
) { m_minSize
= sz
; }
2070 /// Get the 'natural' size for an object. For an image, it would be the
2072 virtual wxTextAttrSize
GetNaturalSize() const { return wxTextAttrSize(); }
2074 /// Get/set the object position
2075 virtual wxPoint
GetPosition() const { return m_pos
; }
2076 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
2078 /// Get the absolute object position, by traversing up the child/parent hierarchy
2079 /// TODO: may not be needed, if all object positions are in fact relative to the
2080 /// top of the coordinate space.
2081 virtual wxPoint
GetAbsolutePosition() const;
2083 /// Get the rectangle enclosing the object
2084 virtual wxRect
GetRect() const { return wxRect(GetPosition(), GetCachedSize()); }
2087 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
2090 const wxRichTextRange
& GetRange() const { return m_range
; }
2091 wxRichTextRange
& GetRange() { return m_range
; }
2093 /// Set the 'own' range, for a top-level object with its own position space
2094 void SetOwnRange(const wxRichTextRange
& range
) { m_ownRange
= range
; }
2096 /// Get own range (valid if top-level)
2097 const wxRichTextRange
& GetOwnRange() const { return m_ownRange
; }
2098 wxRichTextRange
& GetOwnRange() { return m_ownRange
; }
2100 /// Get own range only if a top-level object
2101 wxRichTextRange
GetOwnRangeIfTopLevel() const { return IsTopLevel() ? m_ownRange
: m_range
; }
2103 /// Is this composite?
2104 virtual bool IsComposite() const { return false; }
2106 /// Get/set the parent.
2107 virtual wxRichTextObject
* GetParent() const { return m_parent
; }
2108 virtual void SetParent(wxRichTextObject
* parent
) { m_parent
= parent
; }
2110 /// Get/set the top-level container of this object.
2111 /// May return itself if it's a container; use GetParentContainer to return
2112 /// a different container.
2113 virtual wxRichTextParagraphLayoutBox
* GetContainer() const;
2115 /// Get/set the top-level container of this object.
2116 /// Returns a different container than itself, unless there's no parent, in which case it will return NULL.
2117 virtual wxRichTextParagraphLayoutBox
* GetParentContainer() const { return GetParent() ? GetParent()->GetContainer() : GetContainer(); }
2119 /// Set the margin around the object, in pixels
2120 virtual void SetMargins(int margin
);
2121 virtual void SetMargins(int leftMargin
, int rightMargin
, int topMargin
, int bottomMargin
);
2122 virtual int GetLeftMargin() const;
2123 virtual int GetRightMargin() const;
2124 virtual int GetTopMargin() const;
2125 virtual int GetBottomMargin() const;
2127 /// Calculate the available content space in the given rectangle, given the
2128 /// margins, border and padding specified in the object's attributes.
2129 virtual wxRect
GetAvailableContentArea(wxDC
& dc
, const wxRect
& outerRect
) const;
2131 /// Lays out the object first with a given amount of space, and then if no width was specified in attr,
2132 /// lays out the object again using the minimum size
2133 virtual bool LayoutToBestSize(wxDC
& dc
, wxRichTextBuffer
* buffer
,
2134 const wxRichTextAttr
& parentAttr
, const wxRichTextAttr
& attr
, const wxRect
& availableParentSpace
, int style
);
2136 /// Set/get attributes object
2137 void SetAttributes(const wxRichTextAttr
& attr
) { m_attributes
= attr
; }
2138 const wxRichTextAttr
& GetAttributes() const { return m_attributes
; }
2139 wxRichTextAttr
& GetAttributes() { return m_attributes
; }
2141 /// Set/get properties
2142 wxRichTextProperties
& GetProperties() { return m_properties
; }
2143 const wxRichTextProperties
& GetProperties() const { return m_properties
; }
2144 void SetProperties(const wxRichTextProperties
& props
) { m_properties
= props
; }
2146 /// Set/get stored descent
2147 void SetDescent(int descent
) { m_descent
= descent
; }
2148 int GetDescent() const { return m_descent
; }
2150 /// Gets the containing buffer
2151 wxRichTextBuffer
* GetBuffer() const;
2153 /// Sets the identifying name for this object, as a property.
2154 void SetName(const wxString
& name
) { m_properties
.SetProperty(wxT("name"), name
); }
2156 /// Gets the identifying name for this object.
2157 wxString
GetName() const { return m_properties
.GetPropertyString(wxT("name")); }
2159 /// Is this object top-level, i.e. with its own paragraphs, such as a text box?
2160 virtual bool IsTopLevel() const { return false; }
2162 /// Returns @true if the object will be shown, @false otherwise.
2163 bool IsShown() const { return m_show
; }
2167 /// Call to show or hide this object. This function does not cause the content to be
2168 /// laid out or redrawn.
2169 virtual void Show(bool show
) { m_show
= show
; }
2171 /// Clone the object
2172 virtual wxRichTextObject
* Clone() const { return NULL
; }
2175 void Copy(const wxRichTextObject
& obj
);
2177 /// Reference-counting allows us to use the same object in multiple
2178 /// lists (not yet used)
2179 void Reference() { m_refCount
++; }
2182 /// Move the object recursively, by adding the offset from old to new
2183 virtual void Move(const wxPoint
& pt
);
2185 /// Convert units in tenths of a millimetre to device units
2186 int ConvertTenthsMMToPixels(wxDC
& dc
, int units
) const;
2187 static int ConvertTenthsMMToPixels(int ppi
, int units
, double scale
= 1.0);
2189 /// Convert units in pixels to tenths of a millimetre
2190 int ConvertPixelsToTenthsMM(wxDC
& dc
, int pixels
) const;
2191 static int ConvertPixelsToTenthsMM(int ppi
, int pixels
, double scale
= 1.0);
2193 /// Draw the borders and background for the given rectangle and attributes.
2194 /// Width and height are taken to be the outer margin size, not the content.
2195 static bool DrawBoxAttributes(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxRichTextAttr
& attr
, const wxRect
& boxRect
, int flags
= 0);
2198 static bool DrawBorder(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxTextAttrBorders
& attr
, const wxRect
& rect
, int flags
= 0);
2200 /// Get the various rectangles of the box model in pixels. You can either specify contentRect (inner)
2201 /// or marginRect (outer), and the other must be the default rectangle (no width or height).
2202 /// Note that the outline doesn't affect the position of the rectangle, it's drawn in whatever space
2204 static bool GetBoxRects(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxRichTextAttr
& attr
, wxRect
& marginRect
, wxRect
& borderRect
, wxRect
& contentRect
, wxRect
& paddingRect
, wxRect
& outlineRect
);
2206 /// Get the total margin for the object in pixels, taking into account margin, padding and border size
2207 static bool GetTotalMargin(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxRichTextAttr
& attr
, int& leftMargin
, int& rightMargin
,
2208 int& topMargin
, int& bottomMargin
);
2210 /// Returns the rectangle which the child has available to it given restrictions specified in the
2211 /// child attribute, e.g. 50% width of the parent, 400 pixels, x position 20% of the parent, etc.
2212 static wxRect
AdjustAvailableSpace(wxDC
& dc
, wxRichTextBuffer
* buffer
, const wxRichTextAttr
& parentAttr
, const wxRichTextAttr
& childAttr
, const wxRect
& availableParentSpace
);
2219 int m_descent
; // Descent for this object (if any)
2222 wxRichTextObject
* m_parent
;
2224 /// The range of this object (start position to end position)
2225 wxRichTextRange m_range
;
2227 /// The internal range of this object, if it's a top-level object with its own range space
2228 wxRichTextRange m_ownRange
;
2231 wxRichTextAttr m_attributes
;
2234 wxRichTextProperties m_properties
;
2237 WX_DECLARE_LIST_WITH_DECL( wxRichTextObject
, wxRichTextObjectList
, class WXDLLIMPEXP_RICHTEXT
);
2240 * wxRichTextCompositeObject class declaration
2241 * Objects of this class can contain other objects.
2244 class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject
: public wxRichTextObject
2246 DECLARE_CLASS(wxRichTextCompositeObject
)
2250 wxRichTextCompositeObject(wxRichTextObject
* parent
= NULL
);
2251 virtual ~wxRichTextCompositeObject();
2255 /// Hit-testing: returns a flag indicating hit test details, plus
2256 /// information about position
2257 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
2259 /// Finds the absolute position and row height for the given character position
2260 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
2263 virtual void CalculateRange(long start
, long& end
);
2266 virtual bool DeleteRange(const wxRichTextRange
& range
);
2268 /// Get any text in this object for the given range
2269 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
2271 /// Gets the object size for the given range. Returns false if the range
2272 /// is invalid for this object.
2273 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
2275 /// Dump to output stream for debugging
2276 virtual void Dump(wxTextOutputStream
& stream
);
2278 /// Invalidate the buffer. With no argument, invalidates whole buffer.
2279 virtual void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
2283 /// Get the children
2284 wxRichTextObjectList
& GetChildren() { return m_children
; }
2285 const wxRichTextObjectList
& GetChildren() const { return m_children
; }
2287 /// Get the child count
2288 size_t GetChildCount() const ;
2290 /// Get the nth child
2291 wxRichTextObject
* GetChild(size_t n
) const ;
2293 /// Is this composite?
2294 virtual bool IsComposite() const { return true; }
2296 /// Returns true if the buffer is empty
2297 virtual bool IsEmpty() const { return GetChildCount() == 0; }
2299 /// Get the child object at the given character position
2300 virtual wxRichTextObject
* GetChildAtPosition(long pos
) const;
2305 void Copy(const wxRichTextCompositeObject
& obj
);
2308 void operator= (const wxRichTextCompositeObject
& obj
) { Copy(obj
); }
2310 /// Append a child, returning the position
2311 size_t AppendChild(wxRichTextObject
* child
) ;
2313 /// Insert the child in front of the given object, or at the beginning
2314 bool InsertChild(wxRichTextObject
* child
, wxRichTextObject
* inFrontOf
) ;
2316 /// Delete the child
2317 bool RemoveChild(wxRichTextObject
* child
, bool deleteChild
= false) ;
2319 /// Delete all children
2320 bool DeleteChildren() ;
2322 /// Recursively merge all pieces that can be merged.
2323 bool Defragment(const wxRichTextRange
& range
= wxRICHTEXT_ALL
);
2325 /// Move the object recursively, by adding the offset from old to new
2326 virtual void Move(const wxPoint
& pt
);
2329 wxRichTextObjectList m_children
;
2333 * wxRichTextParagraphBox class declaration
2334 * This box knows how to lay out paragraphs.
2337 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphLayoutBox
: public wxRichTextCompositeObject
2339 DECLARE_DYNAMIC_CLASS(wxRichTextParagraphLayoutBox
)
2343 wxRichTextParagraphLayoutBox(wxRichTextObject
* parent
= NULL
);
2344 wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox
& obj
): wxRichTextCompositeObject() { Init(); Copy(obj
); }
2345 ~wxRichTextParagraphLayoutBox();
2349 /// Hit-testing: returns a flag indicating hit test details, plus
2350 /// information about position
2351 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
2354 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
2356 /// Lay the item out
2357 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
2359 /// Gets the object size for the given range. Returns false if the range
2360 /// is invalid for this object.
2361 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
2364 virtual bool DeleteRange(const wxRichTextRange
& range
);
2366 /// Get any text in this object for the given range
2367 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
2370 /// Import this object from XML
2371 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
2374 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
2375 /// Export this object directly to the given stream.
2376 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
2379 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
2380 /// Export this object to the given parent node, usually creating at least one child node.
2381 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
2384 /// What is the XML node name of this object?
2385 virtual wxString
GetXMLNodeName() const { return wxT("paragraphlayout"); }
2387 /// Returns true if objects of this class can accept the focus, i.e. a call to SetFocusObject
2388 /// is possible. For example, containers supporting text, such as a text box object, can accept the focus,
2389 /// but a table can't (set the focus to individual cells instead).
2390 virtual bool AcceptsFocus() const { return true; }
2394 /// Associate a control with the buffer, for operations that for example require refreshing the window.
2395 void SetRichTextCtrl(wxRichTextCtrl
* ctrl
) { m_ctrl
= ctrl
; }
2397 /// Get the associated control.
2398 wxRichTextCtrl
* GetRichTextCtrl() const { return m_ctrl
; }
2400 /// Get/set whether the last paragraph is partial or complete
2401 void SetPartialParagraph(bool partialPara
) { m_partialParagraph
= partialPara
; }
2402 bool GetPartialParagraph() const { return m_partialParagraph
; }
2404 /// Returns the style sheet associated with the overall buffer.
2405 virtual wxRichTextStyleSheet
* GetStyleSheet() const;
2407 /// Is this object top-level, i.e. with its own paragraphs, such as a text box?
2408 virtual bool IsTopLevel() const { return true; }
2412 /// Submit command to insert paragraphs
2413 bool InsertParagraphsWithUndo(long pos
, const wxRichTextParagraphLayoutBox
& paragraphs
, wxRichTextCtrl
* ctrl
, wxRichTextBuffer
* buffer
, int flags
= 0);
2415 /// Submit command to insert the given text
2416 bool InsertTextWithUndo(long pos
, const wxString
& text
, wxRichTextCtrl
* ctrl
, wxRichTextBuffer
* buffer
, int flags
= 0);
2418 /// Submit command to insert the given text
2419 bool InsertNewlineWithUndo(long pos
, wxRichTextCtrl
* ctrl
, wxRichTextBuffer
* buffer
, int flags
= 0);
2421 /// Submit command to insert the given image
2422 bool InsertImageWithUndo(long pos
, const wxRichTextImageBlock
& imageBlock
,
2423 wxRichTextCtrl
* ctrl
, wxRichTextBuffer
* buffer
, int flags
,
2424 const wxRichTextAttr
& textAttr
);
2426 /// Get the style that is appropriate for a new paragraph at this position.
2427 /// If the previous paragraph has a paragraph style name, look up the next-paragraph
2429 wxRichTextAttr
GetStyleForNewParagraph(wxRichTextBuffer
* buffer
, long pos
, bool caretPosition
= false, bool lookUpNewParaStyle
=false) const;
2431 /// Insert an object.
2432 wxRichTextObject
* InsertObjectWithUndo(long pos
, wxRichTextObject
*object
, wxRichTextCtrl
* ctrl
, wxRichTextBuffer
* buffer
, int flags
= 0);
2434 /// Submit command to delete this range
2435 bool DeleteRangeWithUndo(const wxRichTextRange
& range
, wxRichTextCtrl
* ctrl
, wxRichTextBuffer
* buffer
);
2437 /// Draw the floats of this buffer
2438 void DrawFloats(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
2440 /// Move an anchored object to another paragraph
2441 void MoveAnchoredObjectToParagraph(wxRichTextParagraph
* from
, wxRichTextParagraph
* to
, wxRichTextObject
* obj
);
2443 /// Initialize the object.
2446 /// Clear all children
2447 virtual void Clear();
2449 /// Clear and initialize with one blank paragraph
2450 virtual void Reset();
2452 /// Convenience function to add a paragraph of text
2453 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxRichTextAttr
* paraStyle
= NULL
);
2455 /// Convenience function to add an image
2456 virtual wxRichTextRange
AddImage(const wxImage
& image
, wxRichTextAttr
* paraStyle
= NULL
);
2458 /// Adds multiple paragraphs, based on newlines.
2459 virtual wxRichTextRange
AddParagraphs(const wxString
& text
, wxRichTextAttr
* paraStyle
= NULL
);
2461 /// Get the line at the given position. If caretPosition is true, the position is
2462 /// a caret position, which is normally a smaller number.
2463 virtual wxRichTextLine
* GetLineAtPosition(long pos
, bool caretPosition
= false) const;
2465 /// Get the line at the given y pixel position, or the last line.
2466 virtual wxRichTextLine
* GetLineAtYPosition(int y
) const;
2468 /// Get the paragraph at the given character or caret position
2469 virtual wxRichTextParagraph
* GetParagraphAtPosition(long pos
, bool caretPosition
= false) const;
2471 /// Get the line size at the given position
2472 virtual wxSize
GetLineSizeAtPosition(long pos
, bool caretPosition
= false) const;
2474 /// Given a position, get the number of the visible line (potentially many to a paragraph),
2475 /// starting from zero at the start of the buffer. We also have to pass a bool (startOfLine)
2476 /// that indicates whether the caret is being shown at the end of the previous line or at the start
2477 /// of the next, since the caret can be shown at 2 visible positions for the same underlying
2479 virtual long GetVisibleLineNumber(long pos
, bool caretPosition
= false, bool startOfLine
= false) const;
2481 /// Given a line number, get the corresponding wxRichTextLine object.
2482 virtual wxRichTextLine
* GetLineForVisibleLineNumber(long lineNumber
) const;
2484 /// Get the leaf object in a paragraph at this position.
2485 /// Given a position, get the corresponding wxRichTextLine object.
2486 virtual wxRichTextObject
* GetLeafObjectAtPosition(long position
) const;
2488 /// Get the paragraph by number
2489 virtual wxRichTextParagraph
* GetParagraphAtLine(long paragraphNumber
) const;
2491 /// Get the paragraph for a given line
2492 virtual wxRichTextParagraph
* GetParagraphForLine(wxRichTextLine
* line
) const;
2494 /// Get the length of the paragraph
2495 virtual int GetParagraphLength(long paragraphNumber
) const;
2497 /// Get the number of paragraphs
2498 virtual int GetParagraphCount() const { return static_cast<int>(GetChildCount()); }
2500 /// Get the number of visible lines
2501 virtual int GetLineCount() const;
2503 /// Get the text of the paragraph
2504 virtual wxString
GetParagraphText(long paragraphNumber
) const;
2506 /// Convert zero-based line column and paragraph number to a position.
2507 virtual long XYToPosition(long x
, long y
) const;
2509 /// Convert zero-based position to line column and paragraph number
2510 virtual bool PositionToXY(long pos
, long* x
, long* y
) const;
2512 /// Set text attributes: character and/or paragraph styles.
2513 virtual bool SetStyle(const wxRichTextRange
& range
, const wxRichTextAttr
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
2515 /// Set the attributes for the given object only, for example the box attributes for a text box.
2516 virtual void SetStyle(wxRichTextObject
*obj
, const wxRichTextAttr
& textAttr
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
2518 /// Get the combined text attributes for this position.
2519 virtual bool GetStyle(long position
, wxRichTextAttr
& style
);
2521 /// Get the content (uncombined) attributes for this position.
2522 virtual bool GetUncombinedStyle(long position
, wxRichTextAttr
& style
);
2524 /// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and
2525 /// context attributes.
2526 virtual bool DoGetStyle(long position
, wxRichTextAttr
& style
, bool combineStyles
= true);
2528 /// Get the combined style for a range - if any attribute is different within the range,
2529 /// that attribute is not present within the flags
2530 virtual bool GetStyleForRange(const wxRichTextRange
& range
, wxRichTextAttr
& style
);
2532 /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
2534 bool CollectStyle(wxRichTextAttr
& currentStyle
, const wxRichTextAttr
& style
, wxRichTextAttr
& clashingAttr
, wxRichTextAttr
& absentAttr
);
2537 virtual bool SetListStyle(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
2538 virtual bool SetListStyle(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
2540 /// Clear list for given range
2541 virtual bool ClearListStyle(const wxRichTextRange
& range
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
2543 /// Number/renumber any list elements in the given range.
2544 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
2545 virtual bool NumberList(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
2546 virtual bool NumberList(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
2548 /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1
2549 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
2550 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
2551 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
2553 /// Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously
2554 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
2555 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);
2557 /// Fills in the attributes for numbering a paragraph after previousParagraph.
2558 virtual bool FindNextParagraphNumber(wxRichTextParagraph
* previousParagraph
, wxRichTextAttr
& attr
) const;
2560 /// Test if this whole range has character attributes of the specified kind. If any
2561 /// of the attributes are different within the range, the test fails. You
2562 /// can use this to implement, for example, bold button updating. style must have
2563 /// flags indicating which attributes are of interest.
2564 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
2566 /// Test if this whole range has paragraph attributes of the specified kind. If any
2567 /// of the attributes are different within the range, the test fails. You
2568 /// can use this to implement, for example, centering button updating. style must have
2569 /// flags indicating which attributes are of interest.
2570 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
2573 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraphLayoutBox(*this); }
2575 /// Insert fragment into this box at the given position. If partialParagraph is true,
2576 /// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
2578 virtual bool InsertFragment(long position
, wxRichTextParagraphLayoutBox
& fragment
);
2580 /// Make a copy of the fragment corresponding to the given range, putting it in 'fragment'.
2581 virtual bool CopyFragment(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
& fragment
);
2583 /// Apply the style sheet to the buffer, for example if the styles have changed.
2584 virtual bool ApplyStyleSheet(wxRichTextStyleSheet
* styleSheet
);
2587 void Copy(const wxRichTextParagraphLayoutBox
& obj
);
2590 void operator= (const wxRichTextParagraphLayoutBox
& obj
) { Copy(obj
); }
2592 /// Calculate ranges
2593 virtual void UpdateRanges();
2595 /// Get all the text
2596 virtual wxString
GetText() const;
2598 /// Set default style for new content. Setting it to a default attribute
2599 /// makes new content take on the 'basic' style.
2600 virtual bool SetDefaultStyle(const wxRichTextAttr
& style
);
2602 /// Get default style
2603 virtual const wxRichTextAttr
& GetDefaultStyle() const { return m_defaultAttributes
; }
2605 /// Set basic (overall) style
2606 virtual void SetBasicStyle(const wxRichTextAttr
& style
) { m_attributes
= style
; }
2608 /// Get basic (overall) style
2609 virtual const wxRichTextAttr
& GetBasicStyle() const { return m_attributes
; }
2611 /// Invalidate the buffer. With no argument, invalidates whole buffer.
2612 virtual void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
2614 /// Do the (in)validation for this object only
2615 virtual void DoInvalidate(const wxRichTextRange
& invalidRange
);
2617 /// Do the (in)validation both up and down the hierarchy
2618 virtual void InvalidateHierarchy(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
2620 /// Gather information about floating objects. If untilObj is non-NULL,
2621 /// will stop getting information if the current object is this, since we
2622 /// will collect the rest later.
2623 virtual bool UpdateFloatingObjects(const wxRect
& availableRect
, wxRichTextObject
* untilObj
= NULL
);
2625 /// Get invalid range, rounding to entire paragraphs if argument is true.
2626 wxRichTextRange
GetInvalidRange(bool wholeParagraphs
= false) const;
2628 /// Does this object need layout?
2629 bool IsDirty() const { return m_invalidRange
!= wxRICHTEXT_NONE
; }
2631 /// Get the wxRichTextFloatCollector of this object
2632 wxRichTextFloatCollector
* GetFloatCollector() { return m_floatCollector
; }
2634 /// Get the number of floating objects at this level
2635 int GetFloatingObjectCount() const;
2637 /// Get a list of floating objects
2638 bool GetFloatingObjects(wxRichTextObjectList
& objects
) const;
2641 wxRichTextCtrl
* m_ctrl
;
2642 wxRichTextAttr m_defaultAttributes
;
2644 /// The invalidated range that will need full layout
2645 wxRichTextRange m_invalidRange
;
2647 // Is the last paragraph partial or complete?
2648 bool m_partialParagraph
;
2650 // The floating layout state
2651 wxRichTextFloatCollector
* m_floatCollector
;
2655 @class wxRichTextBox
2657 wxRichTextBox is a floating or inline text box, containing paragraphs.
2660 class WXDLLIMPEXP_RICHTEXT wxRichTextBox
: public wxRichTextParagraphLayoutBox
2662 DECLARE_DYNAMIC_CLASS(wxRichTextBox
)
2667 Default constructor; optionally pass the parent object.
2670 wxRichTextBox(wxRichTextObject
* parent
= NULL
);
2676 wxRichTextBox(const wxRichTextBox
& obj
): wxRichTextParagraphLayoutBox() { Copy(obj
); }
2684 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
2687 Returns the XML node name of this object.
2690 virtual wxString
GetXMLNodeName() const { return wxT("textbox"); }
2692 /// Can we edit properties via a GUI?
2693 virtual bool CanEditProperties() const { return true; }
2695 /// Edit properties via a GUI
2696 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
2698 /// Return the label to be used for the properties context menu item.
2699 virtual wxString
GetPropertiesMenuLabel() const { return _("&Box"); }
2706 Makes a clone of this object.
2708 virtual wxRichTextObject
* Clone() const { return new wxRichTextBox(*this); }
2713 void Copy(const wxRichTextBox
& obj
);
2719 * wxRichTextLine class declaration
2720 * This object represents a line in a paragraph, and stores
2721 * offsets from the start of the paragraph representing the
2722 * start and end positions of the line.
2725 class WXDLLIMPEXP_RICHTEXT wxRichTextLine
2730 wxRichTextLine(wxRichTextParagraph
* parent
);
2731 wxRichTextLine(const wxRichTextLine
& obj
) { Init( NULL
); Copy(obj
); }
2732 virtual ~wxRichTextLine() {}
2739 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
2740 void SetRange(long from
, long to
) { m_range
= wxRichTextRange(from
, to
); }
2742 /// Get the parent paragraph
2743 wxRichTextParagraph
* GetParent() { return m_parent
; }
2746 const wxRichTextRange
& GetRange() const { return m_range
; }
2747 wxRichTextRange
& GetRange() { return m_range
; }
2749 /// Get the absolute range
2750 wxRichTextRange
GetAbsoluteRange() const;
2752 /// Get/set the line size as calculated by Layout.
2753 virtual wxSize
GetSize() const { return m_size
; }
2754 virtual void SetSize(const wxSize
& sz
) { m_size
= sz
; }
2756 /// Get/set the object position relative to the parent
2757 virtual wxPoint
GetPosition() const { return m_pos
; }
2758 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
2760 /// Get the absolute object position
2761 virtual wxPoint
GetAbsolutePosition() const;
2763 /// Get the rectangle enclosing the line
2764 virtual wxRect
GetRect() const { return wxRect(GetAbsolutePosition(), GetSize()); }
2766 /// Set/get stored descent
2767 void SetDescent(int descent
) { m_descent
= descent
; }
2768 int GetDescent() const { return m_descent
; }
2770 #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING
2771 wxArrayInt
& GetObjectSizes() { return m_objectSizes
; }
2772 const wxArrayInt
& GetObjectSizes() const { return m_objectSizes
; }
2778 void Init(wxRichTextParagraph
* parent
);
2781 void Copy(const wxRichTextLine
& obj
);
2784 virtual wxRichTextLine
* Clone() const { return new wxRichTextLine(*this); }
2788 /// The range of the line (start position to end position)
2789 /// This is relative to the parent paragraph.
2790 wxRichTextRange m_range
;
2792 /// Size and position measured relative to top of paragraph
2796 /// Maximum descent for this line (location of text baseline)
2799 // The parent object
2800 wxRichTextParagraph
* m_parent
;
2802 #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING
2803 wxArrayInt m_objectSizes
;
2807 WX_DECLARE_LIST_WITH_DECL( wxRichTextLine
, wxRichTextLineList
, class WXDLLIMPEXP_RICHTEXT
);
2810 * wxRichTextParagraph class declaration
2811 * This object represents a single paragraph (or in a straight text editor, a line).
2814 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph
: public wxRichTextCompositeObject
2816 DECLARE_DYNAMIC_CLASS(wxRichTextParagraph
)
2820 wxRichTextParagraph(wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* style
= NULL
);
2821 wxRichTextParagraph(const wxString
& text
, wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* paraStyle
= NULL
, wxRichTextAttr
* charStyle
= NULL
);
2822 virtual ~wxRichTextParagraph();
2823 wxRichTextParagraph(const wxRichTextParagraph
& obj
): wxRichTextCompositeObject() { Copy(obj
); }
2828 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
2830 /// Lay the item out
2831 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
2833 /// Gets the object size for the given range. Returns false if the range
2834 /// is invalid for this object.
2835 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
2837 /// Finds the absolute position and row height for the given character position
2838 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
2840 /// Hit-testing: returns a flag indicating hit test details, plus
2841 /// information about position and the object that was found.
2842 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
2845 virtual void CalculateRange(long start
, long& end
);
2847 /// What is the XML node name of this object?
2848 virtual wxString
GetXMLNodeName() const { return wxT("paragraph"); }
2852 /// Get the cached lines
2853 wxRichTextLineList
& GetLines() { return m_cachedLines
; }
2858 void Copy(const wxRichTextParagraph
& obj
);
2861 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraph(*this); }
2863 /// Clear the cached lines
2868 /// Apply paragraph styles such as centering to the wrapped lines
2869 virtual void ApplyParagraphStyle(wxRichTextLine
* line
, const wxRichTextAttr
& attr
, const wxRect
& rect
, wxDC
& dc
);
2871 /// Insert text at the given position
2872 virtual bool InsertText(long pos
, const wxString
& text
);
2874 /// Split an object at this position if necessary, and return
2875 /// the previous object, or NULL if inserting at beginning.
2876 virtual wxRichTextObject
* SplitAt(long pos
, wxRichTextObject
** previousObject
= NULL
);
2878 /// Move content to a list from this point
2879 virtual void MoveToList(wxRichTextObject
* obj
, wxList
& list
);
2881 /// Add content back from list
2882 virtual void MoveFromList(wxList
& list
);
2884 /// Get the plain text searching from the start or end of the range.
2885 /// The resulting string may be shorter than the range given.
2886 bool GetContiguousPlainText(wxString
& text
, const wxRichTextRange
& range
, bool fromStart
= true);
2888 /// Find a suitable wrap position. wrapPosition is the last position in the line to the left
2890 bool FindWrapPosition(const wxRichTextRange
& range
, wxDC
& dc
, int availableSpace
, long& wrapPosition
, wxArrayInt
* partialExtents
);
2892 /// Find the object at the given position
2893 wxRichTextObject
* FindObjectAtPosition(long position
);
2895 /// Get the bullet text for this paragraph.
2896 wxString
GetBulletText();
2898 /// Allocate or reuse a line object
2899 wxRichTextLine
* AllocateLine(int pos
);
2901 /// Clear remaining unused line objects, if any
2902 bool ClearUnusedLines(int lineCount
);
2904 /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically
2905 /// retrieve the actual style.
2906 wxRichTextAttr
GetCombinedAttributes(const wxRichTextAttr
& contentStyle
, bool includingBoxAttr
= false) const;
2908 /// Get combined attributes of the base style and paragraph style.
2909 wxRichTextAttr
GetCombinedAttributes(bool includingBoxAttr
= false) const;
2911 /// Get the first position from pos that has a line break character.
2912 long GetFirstLineBreakPosition(long pos
);
2914 /// Create default tabstop array
2915 static void InitDefaultTabs();
2917 /// Clear default tabstop array
2918 static void ClearDefaultTabs();
2920 /// Get default tabstop array
2921 static const wxArrayInt
& GetDefaultTabs() { return sm_defaultTabs
; }
2923 /// Layout the floats object
2924 void LayoutFloat(wxDC
& dc
, const wxRect
& rect
, int style
, wxRichTextFloatCollector
* floatCollector
);
2927 /// The lines that make up the wrapped paragraph
2928 wxRichTextLineList m_cachedLines
;
2930 /// Default tabstops
2931 static wxArrayInt sm_defaultTabs
;
2933 friend class wxRichTextFloatCollector
;
2937 * wxRichTextPlainText class declaration
2938 * This object represents a single piece of text.
2941 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText
: public wxRichTextObject
2943 DECLARE_DYNAMIC_CLASS(wxRichTextPlainText
)
2947 wxRichTextPlainText(const wxString
& text
= wxEmptyString
, wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* style
= NULL
);
2948 wxRichTextPlainText(const wxRichTextPlainText
& obj
): wxRichTextObject() { Copy(obj
); }
2953 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
2955 /// Lay the item out
2956 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
2958 /// Gets the object size for the given range. Returns false if the range
2959 /// is invalid for this object.
2960 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
2962 /// Get any text in this object for the given range
2963 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
2965 /// Do a split, returning an object containing the second part, and setting
2966 /// the first part in 'this'.
2967 virtual wxRichTextObject
* DoSplit(long pos
);
2970 virtual void CalculateRange(long start
, long& end
);
2973 virtual bool DeleteRange(const wxRichTextRange
& range
);
2975 /// Returns true if the object is empty
2976 virtual bool IsEmpty() const { return m_text
.empty(); }
2978 /// Returns true if this object can merge itself with the given one.
2979 virtual bool CanMerge(wxRichTextObject
* object
) const;
2981 /// Returns true if this object merged itself with the given one.
2982 /// The calling code will then delete the given object.
2983 virtual bool Merge(wxRichTextObject
* object
);
2985 /// Dump to output stream for debugging
2986 virtual void Dump(wxTextOutputStream
& stream
);
2988 /// Get the first position from pos that has a line break character.
2989 long GetFirstLineBreakPosition(long pos
);
2991 /// Does this object take note of paragraph attributes? Text and image objects don't.
2992 virtual bool UsesParagraphAttributes() const { return false; }
2995 /// Import this object from XML
2996 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
2999 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
3000 /// Export this object directly to the given stream.
3001 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
3004 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
3005 /// Export this object to the given parent node, usually creating at least one child node.
3006 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
3009 /// What is the XML node name of this object?
3010 virtual wxString
GetXMLNodeName() const { return wxT("text"); }
3015 const wxString
& GetText() const { return m_text
; }
3018 void SetText(const wxString
& text
) { m_text
= text
; }
3023 void Copy(const wxRichTextPlainText
& obj
);
3026 virtual wxRichTextObject
* Clone() const { return new wxRichTextPlainText(*this); }
3028 bool DrawTabbedString(wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
, wxString
& str
, wxCoord
& x
, wxCoord
& y
, bool selected
);
3035 * wxRichTextImageBlock stores information about an image, in binary in-memory form
3038 class WXDLLIMPEXP_FWD_BASE wxDataInputStream
;
3039 class WXDLLIMPEXP_FWD_BASE wxDataOutputStream
;
3041 class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock
: public wxObject
3044 wxRichTextImageBlock();
3045 wxRichTextImageBlock(const wxRichTextImageBlock
& block
);
3046 virtual ~wxRichTextImageBlock();
3051 // Load the original image into a memory block.
3052 // If the image is not a JPEG, we must convert it into a JPEG
3053 // to conserve space.
3054 // If it's not a JPEG we can make use of 'image', already scaled, so we don't have to
3055 // load the image a 2nd time.
3056 virtual bool MakeImageBlock(const wxString
& filename
, wxBitmapType imageType
,
3057 wxImage
& image
, bool convertToJPEG
= true);
3059 // Make an image block from the wxImage in the given
3061 virtual bool MakeImageBlock(wxImage
& image
, wxBitmapType imageType
, int quality
= 80);
3063 // Uses a const wxImage for efficiency, but can't set quality (only relevant for JPEG)
3064 virtual bool MakeImageBlockDefaultQuality(const wxImage
& image
, wxBitmapType imageType
);
3066 // Makes the image block
3067 virtual bool DoMakeImageBlock(const wxImage
& image
, wxBitmapType imageType
);
3070 bool Write(const wxString
& filename
);
3072 // Write data in hex to a stream
3073 bool WriteHex(wxOutputStream
& stream
);
3075 // Read data in hex from a stream
3076 bool ReadHex(wxInputStream
& stream
, int length
, wxBitmapType imageType
);
3078 // Copy from 'block'
3079 void Copy(const wxRichTextImageBlock
& block
);
3081 // Load a wxImage from the block
3082 bool Load(wxImage
& image
);
3085 void operator=(const wxRichTextImageBlock
& block
);
3089 unsigned char* GetData() const { return m_data
; }
3090 size_t GetDataSize() const { return m_dataSize
; }
3091 wxBitmapType
GetImageType() const { return m_imageType
; }
3093 void SetData(unsigned char* image
) { m_data
= image
; }
3094 void SetDataSize(size_t size
) { m_dataSize
= size
; }
3095 void SetImageType(wxBitmapType imageType
) { m_imageType
= imageType
; }
3097 bool Ok() const { return IsOk(); }
3098 bool IsOk() const { return GetData() != NULL
; }
3100 // Gets the extension for the block's type
3101 wxString
GetExtension() const;
3105 // Allocate and read from stream as a block of memory
3106 static unsigned char* ReadBlock(wxInputStream
& stream
, size_t size
);
3107 static unsigned char* ReadBlock(const wxString
& filename
, size_t size
);
3109 // Write memory block to stream
3110 static bool WriteBlock(wxOutputStream
& stream
, unsigned char* block
, size_t size
);
3112 // Write memory block to file
3113 static bool WriteBlock(const wxString
& filename
, unsigned char* block
, size_t size
);
3116 // Size in bytes of the image stored.
3117 // This is in the raw, original form such as a JPEG file.
3118 unsigned char* m_data
;
3120 wxBitmapType m_imageType
;
3124 * wxRichTextImage class declaration
3125 * This object represents an image.
3128 class WXDLLIMPEXP_RICHTEXT wxRichTextImage
: public wxRichTextObject
3130 DECLARE_DYNAMIC_CLASS(wxRichTextImage
)
3134 wxRichTextImage(wxRichTextObject
* parent
= NULL
): wxRichTextObject(parent
) { }
3135 wxRichTextImage(const wxImage
& image
, wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* charStyle
= NULL
);
3136 wxRichTextImage(const wxRichTextImageBlock
& imageBlock
, wxRichTextObject
* parent
= NULL
, wxRichTextAttr
* charStyle
= NULL
);
3137 wxRichTextImage(const wxRichTextImage
& obj
): wxRichTextObject(obj
) { Copy(obj
); }
3142 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
3144 /// Lay the item out
3145 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
3147 /// Get the object size for the given range. Returns false if the range
3148 /// is invalid for this object.
3149 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
3151 /// Get the 'natural' size for an object. For an image, it would be the
3153 virtual wxTextAttrSize
GetNaturalSize() const;
3155 /// Returns true if the object is empty. An image is never empty; if the image is broken, that's not the same thing as empty.
3156 virtual bool IsEmpty() const { return false; /* !m_imageBlock.Ok(); */ }
3158 /// Can we edit properties via a GUI?
3159 virtual bool CanEditProperties() const { return true; }
3161 /// Edit properties via a GUI
3162 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
3164 /// Return the label to be used for the properties context menu item.
3165 virtual wxString
GetPropertiesMenuLabel() const { return _("&Picture"); }
3167 /// Does this object take note of paragraph attributes? Text and image objects don't.
3168 virtual bool UsesParagraphAttributes() const { return false; }
3171 /// Import this object from XML
3172 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
3175 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
3176 /// Export this object directly to the given stream.
3177 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
3180 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
3181 /// Export this object to the given parent node, usually creating at least one child node.
3182 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
3185 // Images can be floatable (optionally).
3186 virtual bool IsFloatable() const { return true; }
3188 /// What is the XML node name of this object?
3189 virtual wxString
GetXMLNodeName() const { return wxT("image"); }
3193 /// Get the image cache (scaled bitmap)
3194 const wxBitmap
& GetImageCache() const { return m_imageCache
; }
3196 /// Set the image cache
3197 void SetImageCache(const wxBitmap
& bitmap
) { m_imageCache
= bitmap
; }
3199 /// Reset the image cache
3200 void ResetImageCache() { m_imageCache
= wxNullBitmap
; }
3202 /// Get the image block containing the raw data
3203 wxRichTextImageBlock
& GetImageBlock() { return m_imageBlock
; }
3208 void Copy(const wxRichTextImage
& obj
);
3211 virtual wxRichTextObject
* Clone() const { return new wxRichTextImage(*this); }
3213 /// Create a cached image at the required size
3214 virtual bool LoadImageCache(wxDC
& dc
, bool resetCache
= false);
3217 wxRichTextImageBlock m_imageBlock
;
3218 wxBitmap m_imageCache
;
3223 * wxRichTextBuffer class declaration
3224 * This is a kind of box, used to represent the whole buffer
3227 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCommand
;
3228 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction
;
3230 class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer
: public wxRichTextParagraphLayoutBox
3232 DECLARE_DYNAMIC_CLASS(wxRichTextBuffer
)
3236 wxRichTextBuffer() { Init(); }
3237 wxRichTextBuffer(const wxRichTextBuffer
& obj
): wxRichTextParagraphLayoutBox() { Init(); Copy(obj
); }
3238 virtual ~wxRichTextBuffer() ;
3242 /// Gets the command processor
3243 wxCommandProcessor
* GetCommandProcessor() const { return m_commandProcessor
; }
3245 /// Set style sheet, if any.
3246 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
) { m_styleSheet
= styleSheet
; }
3247 virtual wxRichTextStyleSheet
* GetStyleSheet() const { return m_styleSheet
; }
3249 /// Set style sheet and notify of the change
3250 bool SetStyleSheetAndNotify(wxRichTextStyleSheet
* sheet
);
3252 /// Push style sheet to top of stack
3253 bool PushStyleSheet(wxRichTextStyleSheet
* styleSheet
);
3255 /// Pop style sheet from top of stack
3256 wxRichTextStyleSheet
* PopStyleSheet();
3258 /// Set/get table storing fonts
3259 wxRichTextFontTable
& GetFontTable() { return m_fontTable
; }
3260 const wxRichTextFontTable
& GetFontTable() const { return m_fontTable
; }
3261 void SetFontTable(const wxRichTextFontTable
& table
) { m_fontTable
= table
; }
3268 /// Clears the buffer, adds an empty paragraph, and clears the command processor.
3269 virtual void ResetAndClearCommands();
3272 virtual bool LoadFile(const wxString
& filename
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
3275 virtual bool SaveFile(const wxString
& filename
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
3277 /// Load from a stream
3278 virtual bool LoadFile(wxInputStream
& stream
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
3280 /// Save to a stream
3281 virtual bool SaveFile(wxOutputStream
& stream
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
3283 /// Set the handler flags, controlling loading and saving
3284 void SetHandlerFlags(int flags
) { m_handlerFlags
= flags
; }
3286 /// Get the handler flags, controlling loading and saving
3287 int GetHandlerFlags() const { return m_handlerFlags
; }
3289 /// Convenience function to add a paragraph of text
3290 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxRichTextAttr
* paraStyle
= NULL
) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text
, paraStyle
); }
3292 /// Begin collapsing undo/redo commands. Note that this may not work properly
3293 /// if combining commands that delete or insert content, changing ranges for
3294 /// subsequent actions.
3295 virtual bool BeginBatchUndo(const wxString
& cmdName
);
3297 /// End collapsing undo/redo commands
3298 virtual bool EndBatchUndo();
3300 /// Collapsing commands?
3301 virtual bool BatchingUndo() const { return m_batchedCommandDepth
> 0; }
3303 /// Submit immediately, or delay according to whether collapsing is on
3304 virtual bool SubmitAction(wxRichTextAction
* action
);
3306 /// Get collapsed command
3307 virtual wxRichTextCommand
* GetBatchedCommand() const { return m_batchedCommand
; }
3309 /// Begin suppressing undo/redo commands. The way undo is suppressed may be implemented
3310 /// differently by each command. If not dealt with by a command implementation, then
3311 /// it will be implemented automatically by not storing the command in the undo history
3312 /// when the action is submitted to the command processor.
3313 virtual bool BeginSuppressUndo();
3315 /// End suppressing undo/redo commands.
3316 virtual bool EndSuppressUndo();
3318 /// Collapsing commands?
3319 virtual bool SuppressingUndo() const { return m_suppressUndo
> 0; }
3321 /// Copy the range to the clipboard
3322 virtual bool CopyToClipboard(const wxRichTextRange
& range
);
3324 /// Paste the clipboard content to the buffer
3325 virtual bool PasteFromClipboard(long position
);
3327 /// Can we paste from the clipboard?
3328 virtual bool CanPasteFromClipboard() const;
3330 /// Begin using a style
3331 virtual bool BeginStyle(const wxRichTextAttr
& style
);
3334 virtual bool EndStyle();
3337 virtual bool EndAllStyles();
3339 /// Clear the style stack
3340 virtual void ClearStyleStack();
3342 /// Get the size of the style stack, for example to check correct nesting
3343 virtual size_t GetStyleStackSize() const { return m_attributeStack
.GetCount(); }
3345 /// Begin using bold
3349 bool EndBold() { return EndStyle(); }
3351 /// Begin using italic
3354 /// End using italic
3355 bool EndItalic() { return EndStyle(); }
3357 /// Begin using underline
3358 bool BeginUnderline();
3360 /// End using underline
3361 bool EndUnderline() { return EndStyle(); }
3363 /// Begin using point size
3364 bool BeginFontSize(int pointSize
);
3366 /// End using point size
3367 bool EndFontSize() { return EndStyle(); }
3369 /// Begin using this font
3370 bool BeginFont(const wxFont
& font
);
3372 /// End using a font
3373 bool EndFont() { return EndStyle(); }
3375 /// Begin using this colour
3376 bool BeginTextColour(const wxColour
& colour
);
3378 /// End using a colour
3379 bool EndTextColour() { return EndStyle(); }
3381 /// Begin using alignment
3382 bool BeginAlignment(wxTextAttrAlignment alignment
);
3385 bool EndAlignment() { return EndStyle(); }
3387 /// Begin left indent
3388 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
3391 bool EndLeftIndent() { return EndStyle(); }
3393 /// Begin right indent
3394 bool BeginRightIndent(int rightIndent
);
3396 /// End right indent
3397 bool EndRightIndent() { return EndStyle(); }
3399 /// Begin paragraph spacing
3400 bool BeginParagraphSpacing(int before
, int after
);
3402 /// End paragraph spacing
3403 bool EndParagraphSpacing() { return EndStyle(); }
3405 /// Begin line spacing
3406 bool BeginLineSpacing(int lineSpacing
);
3408 /// End line spacing
3409 bool EndLineSpacing() { return EndStyle(); }
3411 /// Begin numbered bullet
3412 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
3414 /// End numbered bullet
3415 bool EndNumberedBullet() { return EndStyle(); }
3417 /// Begin symbol bullet
3418 bool BeginSymbolBullet(const wxString
& symbol
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
3420 /// End symbol bullet
3421 bool EndSymbolBullet() { return EndStyle(); }
3423 /// Begin standard bullet
3424 bool BeginStandardBullet(const wxString
& bulletName
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_STANDARD
);
3426 /// End standard bullet
3427 bool EndStandardBullet() { return EndStyle(); }
3429 /// Begin named character style
3430 bool BeginCharacterStyle(const wxString
& characterStyle
);
3432 /// End named character style
3433 bool EndCharacterStyle() { return EndStyle(); }
3435 /// Begin named paragraph style
3436 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
3438 /// End named character style
3439 bool EndParagraphStyle() { return EndStyle(); }
3441 /// Begin named list style
3442 bool BeginListStyle(const wxString
& listStyle
, int level
= 1, int number
= 1);
3444 /// End named character style
3445 bool EndListStyle() { return EndStyle(); }
3448 bool BeginURL(const wxString
& url
, const wxString
& characterStyle
= wxEmptyString
);
3451 bool EndURL() { return EndStyle(); }
3455 /// Add an event handler
3456 bool AddEventHandler(wxEvtHandler
* handler
);
3458 /// Remove an event handler
3459 bool RemoveEventHandler(wxEvtHandler
* handler
, bool deleteHandler
= false);
3461 /// Clear event handlers
3462 void ClearEventHandlers();
3464 /// Send event to event handlers. If sendToAll is true, will send to all event handlers,
3465 /// otherwise will stop at the first successful one.
3466 bool SendEvent(wxEvent
& event
, bool sendToAll
= true);
3470 /// Hit-testing: returns a flag indicating hit test details, plus
3471 /// information about position
3472 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
, wxRichTextObject
** obj
, wxRichTextObject
** contextObj
, int flags
= 0);
3475 void Copy(const wxRichTextBuffer
& obj
);
3478 void operator= (const wxRichTextBuffer
& obj
) { Copy(obj
); }
3481 virtual wxRichTextObject
* Clone() const { return new wxRichTextBuffer(*this); }
3483 /// Submit command to insert paragraphs
3484 bool InsertParagraphsWithUndo(long pos
, const wxRichTextParagraphLayoutBox
& paragraphs
, wxRichTextCtrl
* ctrl
, int flags
= 0);
3486 /// Submit command to insert the given text
3487 bool InsertTextWithUndo(long pos
, const wxString
& text
, wxRichTextCtrl
* ctrl
, int flags
= 0);
3489 /// Submit command to insert a newline
3490 bool InsertNewlineWithUndo(long pos
, wxRichTextCtrl
* ctrl
, int flags
= 0);
3492 /// Submit command to insert the given image
3493 bool InsertImageWithUndo(long pos
, const wxRichTextImageBlock
& imageBlock
, wxRichTextCtrl
* ctrl
, int flags
= 0,
3494 const wxRichTextAttr
& textAttr
= wxRichTextAttr());
3496 /// Submit command to insert an object
3497 wxRichTextObject
* InsertObjectWithUndo(long pos
, wxRichTextObject
*object
, wxRichTextCtrl
* ctrl
, int flags
);
3499 /// Submit command to delete this range
3500 bool DeleteRangeWithUndo(const wxRichTextRange
& range
, wxRichTextCtrl
* ctrl
);
3503 void Modify(bool modify
= true) { m_modified
= modify
; }
3504 bool IsModified() const { return m_modified
; }
3506 /// Dumps contents of buffer for debugging purposes
3507 virtual void Dump();
3508 virtual void Dump(wxTextOutputStream
& stream
) { wxRichTextParagraphLayoutBox::Dump(stream
); }
3510 /// Returns the file handlers
3511 static wxList
& GetHandlers() { return sm_handlers
; }
3513 /// Adds a handler to the end
3514 static void AddHandler(wxRichTextFileHandler
*handler
);
3516 /// Inserts a handler at the front
3517 static void InsertHandler(wxRichTextFileHandler
*handler
);
3519 /// Removes a handler
3520 static bool RemoveHandler(const wxString
& name
);
3522 /// Finds a handler by name
3523 static wxRichTextFileHandler
*FindHandler(const wxString
& name
);
3525 /// Finds a handler by extension and type
3526 static wxRichTextFileHandler
*FindHandler(const wxString
& extension
, wxRichTextFileType imageType
);
3528 /// Finds a handler by filename or, if supplied, type
3529 static wxRichTextFileHandler
*FindHandlerFilenameOrType(const wxString
& filename
,
3530 wxRichTextFileType imageType
);
3532 /// Finds a handler by type
3533 static wxRichTextFileHandler
*FindHandler(wxRichTextFileType imageType
);
3535 /// Gets a wildcard incorporating all visible handlers. If 'types' is present,
3536 /// will be filled with the file type corresponding to each filter. This can be
3537 /// used to determine the type to pass to LoadFile given a selected filter.
3538 static wxString
GetExtWildcard(bool combine
= false, bool save
= false, wxArrayInt
* types
= NULL
);
3540 /// Clean up handlers
3541 static void CleanUpHandlers();
3543 /// Initialise the standard handlers
3544 static void InitStandardHandlers();
3547 static wxRichTextRenderer
* GetRenderer() { return sm_renderer
; }
3549 /// Set renderer, deleting old one
3550 static void SetRenderer(wxRichTextRenderer
* renderer
);
3552 /// Minimum margin between bullet and paragraph in 10ths of a mm
3553 static int GetBulletRightMargin() { return sm_bulletRightMargin
; }
3554 static void SetBulletRightMargin(int margin
) { sm_bulletRightMargin
= margin
; }
3556 /// Factor to multiply by character height to get a reasonable bullet size
3557 static float GetBulletProportion() { return sm_bulletProportion
; }
3558 static void SetBulletProportion(float prop
) { sm_bulletProportion
= prop
; }
3560 /// Scale factor for calculating dimensions
3561 double GetScale() const { return m_scale
; }
3562 void SetScale(double scale
) { m_scale
= scale
; }
3566 /// Command processor
3567 wxCommandProcessor
* m_commandProcessor
;
3569 /// Table storing fonts
3570 wxRichTextFontTable m_fontTable
;
3572 /// Has been modified?
3575 /// Collapsed command stack
3576 int m_batchedCommandDepth
;
3578 /// Name for collapsed command
3579 wxString m_batchedCommandsName
;
3581 /// Current collapsed command accumulating actions
3582 wxRichTextCommand
* m_batchedCommand
;
3584 /// Whether to suppress undo
3587 /// Style sheet, if any
3588 wxRichTextStyleSheet
* m_styleSheet
;
3590 /// List of event handlers that will be notified of events
3591 wxList m_eventHandlers
;
3593 /// Stack of attributes for convenience functions
3594 wxList m_attributeStack
;
3596 /// Flags to be passed to handlers
3600 static wxList sm_handlers
;
3603 static wxRichTextRenderer
* sm_renderer
;
3605 /// Minimum margin between bullet and paragraph in 10ths of a mm
3606 static int sm_bulletRightMargin
;
3608 /// Factor to multiply by character height to get a reasonable bullet size
3609 static float sm_bulletProportion
;
3611 /// Scaling factor in use: needed to calculate correct dimensions when printing
3616 @class wxRichTextCell
3618 wxRichTextCell is the cell in a table.
3621 class WXDLLIMPEXP_RICHTEXT wxRichTextCell
: public wxRichTextBox
3623 DECLARE_DYNAMIC_CLASS(wxRichTextCell
)
3628 Default constructor; optionally pass the parent object.
3631 wxRichTextCell(wxRichTextObject
* parent
= NULL
);
3637 wxRichTextCell(const wxRichTextCell
& obj
): wxRichTextBox() { Copy(obj
); }
3645 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
3648 Returns the XML node name of this object.
3651 virtual wxString
GetXMLNodeName() const { return wxT("cell"); }
3653 /// Can we edit properties via a GUI?
3654 virtual bool CanEditProperties() const { return true; }
3656 /// Edit properties via a GUI
3657 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
3659 /// Return the label to be used for the properties context menu item.
3660 virtual wxString
GetPropertiesMenuLabel() const { return _("&Cell"); }
3667 Makes a clone of this object.
3669 virtual wxRichTextObject
* Clone() const { return new wxRichTextCell(*this); }
3674 void Copy(const wxRichTextCell
& obj
);
3680 @class wxRichTextTable
3682 wxRichTextTable represents a table with arbitrary columns and rows.
3685 WX_DEFINE_ARRAY_PTR(wxRichTextObject
*, wxRichTextObjectPtrArray
);
3686 WX_DECLARE_OBJARRAY(wxRichTextObjectPtrArray
, wxRichTextObjectPtrArrayArray
);
3688 class WXDLLIMPEXP_RICHTEXT wxRichTextTable
: public wxRichTextBox
3690 DECLARE_DYNAMIC_CLASS(wxRichTextTable
)
3696 Default constructor; optionally pass the parent object.
3699 wxRichTextTable(wxRichTextObject
* parent
= NULL
);
3705 wxRichTextTable(const wxRichTextTable
& obj
): wxRichTextBox() { Copy(obj
); }
3709 // Draws the object.
3710 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextSelection
& selection
, const wxRect
& rect
, int descent
, int style
);
3712 // Returns the XML node name of this object.
3713 virtual wxString
GetXMLNodeName() const { return wxT("table"); }
3715 // Lays the object out.
3716 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
3718 // Gets the range size.
3719 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
3721 // Deletes content in the given range.
3722 virtual bool DeleteRange(const wxRichTextRange
& range
);
3724 // Gets any text in this object for the given range.
3725 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
3728 // Import this object from XML
3729 virtual bool ImportFromXML(wxRichTextBuffer
* buffer
, wxXmlNode
* node
, wxRichTextXMLHandler
* handler
, bool* recurse
);
3732 #if wxRICHTEXT_HAVE_DIRECT_OUTPUT
3733 // Export this object directly to the given stream.
3734 virtual bool ExportXML(wxOutputStream
& stream
, int indent
, wxRichTextXMLHandler
* handler
);
3737 #if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
3738 // Export this object to the given parent node, usually creating at least one child node.
3739 virtual bool ExportXML(wxXmlNode
* parent
, wxRichTextXMLHandler
* handler
);
3742 /// Finds the absolute position and row height for the given character position
3743 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
3746 virtual void CalculateRange(long start
, long& end
);
3748 /// Can this object handle the selections of its children? FOr example, a table.
3749 virtual bool HandlesChildSelections() const { return true; }
3751 /// Returns a selection object specifying the selections between start and end character positions.
3752 /// For example, a table would deduce what cells (of range length 1) are selected when dragging across the table.
3753 virtual wxRichTextSelection
GetSelection(long start
, long end
) const;
3755 /// Can we edit properties via a GUI?
3756 virtual bool CanEditProperties() const { return true; }
3758 /// Edit properties via a GUI
3759 virtual bool EditProperties(wxWindow
* parent
, wxRichTextBuffer
* buffer
);
3761 /// Return the label to be used for the properties context menu item.
3762 virtual wxString
GetPropertiesMenuLabel() const { return _("&Table"); }
3764 /// Returns true if objects of this class can accept the focus, i.e. a call to SetFocusObject
3765 /// is possible. For example, containers supporting text, such as a text box object, can accept the focus,
3766 /// but a table can't (set the focus to individual cells instead).
3767 virtual bool AcceptsFocus() const { return false; }
3771 const wxRichTextObjectPtrArrayArray
& GetCells() const { return m_cells
; }
3772 wxRichTextObjectPtrArrayArray
& GetCells() { return m_cells
; }
3774 int GetRowCount() const { return m_rowCount
; }
3775 int GetColumnCount() const { return m_colCount
; }
3777 /// Get the cell at the given row/column position
3778 virtual wxRichTextCell
* GetCell(int row
, int col
) const;
3780 /// Get the cell at the given character position (in the range of the table).
3781 virtual wxRichTextCell
* GetCell(long pos
) const;
3783 /// Get the row/column for a given character position
3784 virtual bool GetCellRowColumnPosition(long pos
, int& row
, int& col
) const;
3792 virtual void ClearTable();
3795 Creates a table of the given dimensions.
3798 virtual bool CreateTable(int rows
, int cols
);
3801 Sets the attributes for the cells specified by the selection.
3804 virtual bool SetCellStyle(const wxRichTextSelection
& selection
, const wxRichTextAttr
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
3807 Deletes rows from the given row position.
3810 virtual bool DeleteRows(int startRow
, int noRows
= 1);
3813 Deletes columns from the given column position.
3816 virtual bool DeleteColumns(int startCol
, int noCols
= 1);
3819 Adds rows from the given row position.
3822 virtual bool AddRows(int startRow
, int noRows
= 1, const wxRichTextAttr
& attr
= wxRichTextAttr());
3825 Adds columns from the given column position.
3828 virtual bool AddColumns(int startCol
, int noCols
= 1, const wxRichTextAttr
& attr
= wxRichTextAttr());
3830 // Makes a clone of this object.
3831 virtual wxRichTextObject
* Clone() const { return new wxRichTextTable(*this); }
3833 // Copies this object.
3834 void Copy(const wxRichTextTable
& obj
);
3841 // An array of rows, each of which is a wxRichTextObjectPtrArray containing
3842 // the cell objects. The cell objects are also children of this object.
3843 // Problem: if boxes are immediate children of a box, this will cause problems
3844 // with wxRichTextParagraphLayoutBox functions (and functions elsewhere) that
3845 // expect to find just paragraphs. May have to adjust the way we handle the
3846 // hierarchy to accept non-paragraph objects in a a paragraph layout box.
3847 // We'll be overriding much wxRichTextParagraphLayoutBox functionality so this
3848 // may not be such a problem. Perhaps the table should derive from a different
3850 wxRichTextObjectPtrArrayArray m_cells
;
3855 * The command identifiers
3859 enum wxRichTextCommandId
3863 wxRICHTEXT_CHANGE_ATTRIBUTES
,
3864 wxRICHTEXT_CHANGE_STYLE
,
3865 wxRICHTEXT_CHANGE_OBJECT
3869 * A class for specifying an object anywhere in an object hierarchy,
3870 * without using a pointer, necessary since wxRTC commands may delete
3871 * and recreate sub-objects so physical object addresses change. An array
3872 * of positions (one per hierarchy level) is used.
3876 class WXDLLIMPEXP_RICHTEXT wxRichTextObjectAddress
3879 // Creates the address given container and object.
3880 wxRichTextObjectAddress(wxRichTextParagraphLayoutBox
* topLevelContainer
, wxRichTextObject
* obj
) { Create(topLevelContainer
, obj
); }
3881 wxRichTextObjectAddress() { Init(); }
3882 wxRichTextObjectAddress(const wxRichTextObjectAddress
& address
) { Copy(address
); }
3885 void Copy(const wxRichTextObjectAddress
& address
) { m_address
= address
.m_address
; }
3886 void operator=(const wxRichTextObjectAddress
& address
) { Copy(address
); }
3888 wxRichTextObject
* GetObject(wxRichTextParagraphLayoutBox
* topLevelContainer
) const;
3889 bool Create(wxRichTextParagraphLayoutBox
* topLevelContainer
, wxRichTextObject
* obj
);
3891 wxArrayInt
& GetAddress() { return m_address
; }
3892 const wxArrayInt
& GetAddress() const { return m_address
; }
3893 void SetAddress(const wxArrayInt
& address
) { m_address
= address
; }
3897 wxArrayInt m_address
;
3901 * Command classes for undo/redo
3905 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction
;
3906 class WXDLLIMPEXP_RICHTEXT wxRichTextCommand
: public wxCommand
3909 // Ctor for one action
3910 wxRichTextCommand(const wxString
& name
, wxRichTextCommandId id
, wxRichTextBuffer
* buffer
,
3911 wxRichTextParagraphLayoutBox
* container
, wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
3913 // Ctor for multiple actions
3914 wxRichTextCommand(const wxString
& name
);
3916 virtual ~wxRichTextCommand();
3921 void AddAction(wxRichTextAction
* action
);
3922 void ClearActions();
3924 wxList
& GetActions() { return m_actions
; }
3932 * wxRichTextAction class declaration
3933 * There can be more than one action in a command.
3936 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
: public wxObject
3939 /// Constructor. 'buffer' is the top-level buffer, while 'container' is the object within
3940 /// which the action is taking place. In the simplest case, they are the same.
3941 wxRichTextAction(wxRichTextCommand
* cmd
, const wxString
& name
, wxRichTextCommandId id
,
3942 wxRichTextBuffer
* buffer
, wxRichTextParagraphLayoutBox
* container
,
3943 wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
3945 virtual ~wxRichTextAction();
3950 /// Update the control appearance
3951 void UpdateAppearance(long caretPosition
, bool sendUpdateEvent
= false,
3952 wxArrayInt
* optimizationLineCharPositions
= NULL
, wxArrayInt
* optimizationLineYPositions
= NULL
, bool isDoCmd
= true);
3954 /// Replace the buffer paragraphs with the given fragment.
3955 void ApplyParagraphs(const wxRichTextParagraphLayoutBox
& fragment
);
3957 /// Get the fragments
3958 wxRichTextParagraphLayoutBox
& GetNewParagraphs() { return m_newParagraphs
; }
3959 wxRichTextParagraphLayoutBox
& GetOldParagraphs() { return m_oldParagraphs
; }
3961 /// Get the attributes
3962 wxRichTextAttr
& GetAttributes() { return m_attributes
; }
3964 /// An object to replace the one at the position
3965 /// defined by the container address and the action's range start position.
3966 wxRichTextObject
* GetObject() const { return m_object
; }
3967 void SetObject(wxRichTextObject
* obj
) { m_object
= obj
; m_objectAddress
.Create(m_buffer
, m_object
); }
3968 void MakeObject(wxRichTextObject
* obj
) { m_objectAddress
.Create(m_buffer
, obj
); }
3970 /// Calculate arrays for refresh optimization
3971 void CalculateRefreshOptimizations(wxArrayInt
& optimizationLineCharPositions
, wxArrayInt
& optimizationLineYPositions
);
3973 /// Set/get the position used for e.g. insertion
3974 void SetPosition(long pos
) { m_position
= pos
; }
3975 long GetPosition() const { return m_position
; }
3977 /// Set/get the range for e.g. deletion
3978 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
3979 const wxRichTextRange
& GetRange() const { return m_range
; }
3981 /// The address (nested position) of the container within the buffer being manipulated
3982 wxRichTextObjectAddress
& GetContainerAddress() { return m_containerAddress
; }
3983 const wxRichTextObjectAddress
& GetContainerAddress() const { return m_containerAddress
; }
3984 void SetContainerAddress(const wxRichTextObjectAddress
& address
) { m_containerAddress
= address
; }
3985 void SetContainerAddress(wxRichTextParagraphLayoutBox
* container
, wxRichTextObject
* obj
) { m_containerAddress
.Create(container
, obj
); }
3987 /// Returns the container that this action refers to, using the container address and top-level buffer.
3988 wxRichTextParagraphLayoutBox
* GetContainer() const;
3990 const wxString
& GetName() const { return m_name
; }
3997 wxRichTextBuffer
* m_buffer
;
3999 // The address (nested position) of the container being manipulated.
4000 // This is necessary because objects are deleted, and we can't
4001 // therefore store actual pointers.
4002 wxRichTextObjectAddress m_containerAddress
;
4005 wxRichTextCtrl
* m_ctrl
;
4007 // Stores the new paragraphs
4008 wxRichTextParagraphLayoutBox m_newParagraphs
;
4010 // Stores the old paragraphs
4011 wxRichTextParagraphLayoutBox m_oldParagraphs
;
4013 // Stores an object to replace the one at the position
4014 // defined by the container address and the action's range start position.
4015 wxRichTextObject
* m_object
;
4017 // Stores the attributes
4018 wxRichTextAttr m_attributes
;
4020 // The address of the object being manipulated (used for changing an individual object or its attributes)
4021 wxRichTextObjectAddress m_objectAddress
;
4023 // Stores the old attributes
4024 // wxRichTextAttr m_oldAttributes;
4026 // The affected range
4027 wxRichTextRange m_range
;
4029 // The insertion point for this command
4032 // Ignore 1st 'Do' operation because we already did it
4035 // The command identifier
4036 wxRichTextCommandId m_cmdId
;
4043 // Include style sheet when loading and saving
4044 #define wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET 0x0001
4046 // Save images to memory file system in HTML handler
4047 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY 0x0010
4049 // Save images to files in HTML handler
4050 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES 0x0020
4052 // Save images as inline base64 data in HTML handler
4053 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040
4055 // Don't write header and footer (or BODY), so we can include the fragment
4056 // in a larger document
4057 #define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080
4059 // Convert the more common face names to names that will work on the current platform
4060 // in a larger document
4061 #define wxRICHTEXT_HANDLER_CONVERT_FACENAMES 0x0100
4064 * wxRichTextFileHandler
4065 * Base class for file handlers
4068 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler
: public wxObject
4070 DECLARE_CLASS(wxRichTextFileHandler
)
4072 wxRichTextFileHandler(const wxString
& name
= wxEmptyString
, const wxString
& ext
= wxEmptyString
, int type
= 0)
4073 : m_name(name
), m_extension(ext
), m_type(type
), m_flags(0), m_visible(true)
4077 bool LoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
)
4078 { return DoLoadFile(buffer
, stream
); }
4079 bool SaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
)
4080 { return DoSaveFile(buffer
, stream
); }
4083 #if wxUSE_FFILE && wxUSE_STREAMS
4084 virtual bool LoadFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
4085 virtual bool SaveFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
4086 #endif // wxUSE_STREAMS && wxUSE_STREAMS
4088 /// Can we handle this filename (if using files)? By default, checks the extension.
4089 virtual bool CanHandle(const wxString
& filename
) const;
4091 /// Can we save using this handler?
4092 virtual bool CanSave() const { return false; }
4094 /// Can we load using this handler?
4095 virtual bool CanLoad() const { return false; }
4097 /// Should this handler be visible to the user?
4098 virtual bool IsVisible() const { return m_visible
; }
4099 virtual void SetVisible(bool visible
) { m_visible
= visible
; }
4101 /// The name of the nandler
4102 void SetName(const wxString
& name
) { m_name
= name
; }
4103 wxString
GetName() const { return m_name
; }
4105 /// The default extension to recognise
4106 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
4107 wxString
GetExtension() const { return m_extension
; }
4109 /// The handler type
4110 void SetType(int type
) { m_type
= type
; }
4111 int GetType() const { return m_type
; }
4113 /// Flags controlling how loading and saving is done
4114 void SetFlags(int flags
) { m_flags
= flags
; }
4115 int GetFlags() const { return m_flags
; }
4117 /// Encoding to use when saving a file. If empty, a suitable encoding is chosen
4118 void SetEncoding(const wxString
& encoding
) { m_encoding
= encoding
; }
4119 const wxString
& GetEncoding() const { return m_encoding
; }
4124 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
) = 0;
4125 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
) = 0;
4129 wxString m_encoding
;
4130 wxString m_extension
;
4137 * wxRichTextPlainTextHandler
4138 * Plain text handler
4141 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler
: public wxRichTextFileHandler
4143 DECLARE_CLASS(wxRichTextPlainTextHandler
)
4145 wxRichTextPlainTextHandler(const wxString
& name
= wxT("Text"),
4146 const wxString
& ext
= wxT("txt"),
4147 wxRichTextFileType type
= wxRICHTEXT_TYPE_TEXT
)
4148 : wxRichTextFileHandler(name
, ext
, type
)
4151 /// Can we save using this handler?
4152 virtual bool CanSave() const { return true; }
4154 /// Can we load using this handler?
4155 virtual bool CanLoad() const { return true; }
4160 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
4161 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
4169 * The data object for a wxRichTextBuffer
4172 class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject
: public wxDataObjectSimple
4175 // ctor doesn't copy the pointer, so it shouldn't go away while this object
4177 wxRichTextBufferDataObject(wxRichTextBuffer
* richTextBuffer
= NULL
);
4178 virtual ~wxRichTextBufferDataObject();
4180 // after a call to this function, the buffer is owned by the caller and it
4181 // is responsible for deleting it
4182 wxRichTextBuffer
* GetRichTextBuffer();
4184 // Returns the id for the new data format
4185 static const wxChar
* GetRichTextBufferFormatId() { return ms_richTextBufferFormatId
; }
4187 // base class pure virtuals
4189 virtual wxDataFormat
GetPreferredFormat(Direction dir
) const;
4190 virtual size_t GetDataSize() const;
4191 virtual bool GetDataHere(void *pBuf
) const;
4192 virtual bool SetData(size_t len
, const void *buf
);
4196 virtual size_t GetDataSize(const wxDataFormat
&) const { return GetDataSize(); }
4197 virtual bool GetDataHere(const wxDataFormat
&, void *buf
) const { return GetDataHere(buf
); }
4198 virtual bool SetData(const wxDataFormat
&, size_t len
, const void *buf
) { return SetData(len
, buf
); }
4201 wxDataFormat m_formatRichTextBuffer
; // our custom format
4202 wxRichTextBuffer
* m_richTextBuffer
; // our data
4203 static const wxChar
* ms_richTextBufferFormatId
; // our format id
4209 * wxRichTextRenderer isolates common drawing functionality
4212 class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer
: public wxObject
4215 wxRichTextRenderer() {}
4216 virtual ~wxRichTextRenderer() {}
4218 /// Draw a standard bullet, as specified by the value of GetBulletName
4219 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
) = 0;
4221 /// Draw a bullet that can be described by text, such as numbered or symbol bullets
4222 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
, const wxString
& text
) = 0;
4224 /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
4225 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
) = 0;
4227 /// Enumerate the standard bullet names currently supported
4228 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
) = 0;
4232 * wxRichTextStdRenderer: standard renderer
4235 class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer
: public wxRichTextRenderer
4238 wxRichTextStdRenderer() {}
4240 /// Draw a standard bullet, as specified by the value of GetBulletName
4241 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
);
4243 /// Draw a bullet that can be described by text, such as numbered or symbol bullets
4244 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
, const wxString
& text
);
4246 /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
4247 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxRichTextAttr
& attr
, const wxRect
& rect
);
4249 /// Enumerate the standard bullet names currently supported
4250 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
);
4258 inline bool wxRichTextHasStyle(int flags
, int style
)
4260 return ((flags
& style
) == style
);
4263 /// Compare two attribute objects
4264 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxRichTextAttr
& attr1
, const wxRichTextAttr
& attr2
);
4265 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxRichTextAttr
& attr1
, const wxRichTextAttr
& attr2
);
4267 /// Compare two attribute objects, but take into account the flags
4268 /// specifying attributes of interest.
4269 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEqPartial(const wxRichTextAttr
& attr1
, const wxRichTextAttr
& attr2
);
4271 /// Apply one style to another
4272 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxRichTextAttr
& destStyle
, const wxRichTextAttr
& style
, wxRichTextAttr
* compareWith
= NULL
);
4274 // Remove attributes
4275 WXDLLIMPEXP_RICHTEXT
bool wxRichTextRemoveStyle(wxRichTextAttr
& destStyle
, const wxRichTextAttr
& style
);
4277 /// Combine two bitlists
4278 WXDLLIMPEXP_RICHTEXT
bool wxRichTextCombineBitlists(int& valueA
, int valueB
, int& flagsA
, int flagsB
);
4280 /// Compare two bitlists
4281 WXDLLIMPEXP_RICHTEXT
bool wxRichTextBitlistsEqPartial(int valueA
, int valueB
, int flags
);
4283 /// Split into paragraph and character styles
4284 WXDLLIMPEXP_RICHTEXT
bool wxRichTextSplitParaCharStyles(const wxRichTextAttr
& style
, wxRichTextAttr
& parStyle
, wxRichTextAttr
& charStyle
);
4287 WXDLLIMPEXP_RICHTEXT
bool wxRichTextTabsEq(const wxArrayInt
& tabs1
, const wxArrayInt
& tabs2
);
4289 /// Convert a decimal to Roman numerals
4290 WXDLLIMPEXP_RICHTEXT wxString
wxRichTextDecimalToRoman(long n
);
4292 // Collects the attributes that are common to a range of content, building up a note of
4293 // which attributes are absent in some objects and which clash in some objects.
4294 WXDLLIMPEXP_RICHTEXT
void wxTextAttrCollectCommonAttributes(wxTextAttr
& currentStyle
, const wxTextAttr
& attr
, wxTextAttr
& clashingAttr
, wxTextAttr
& absentAttr
);
4296 WXDLLIMPEXP_RICHTEXT
void wxRichTextModuleInit();
4302 // _WX_RICHTEXTBUFFER_H_