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"
70 #include "wx/dataobj.h"
77 extern WXDLLIMPEXP_RICHTEXT
const wxChar wxRichTextLineBreakChar
;
83 #define wxRICHTEXT_TYPE_ANY 0
84 #define wxRICHTEXT_TYPE_TEXT 1
85 #define wxRICHTEXT_TYPE_XML 2
86 #define wxRICHTEXT_TYPE_HTML 3
87 #define wxRICHTEXT_TYPE_RTF 4
88 #define wxRICHTEXT_TYPE_PDF 5
91 * Forward declarations
94 class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl
;
95 class WXDLLIMPEXP_RICHTEXT wxRichTextObject
;
96 class WXDLLIMPEXP_RICHTEXT wxRichTextCacheObject
;
97 class WXDLLIMPEXP_RICHTEXT wxRichTextObjectList
;
98 class WXDLLIMPEXP_RICHTEXT wxRichTextLine
;
99 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph
;
100 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler
;
101 class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet
;
102 class WXDLLIMPEXP_RICHTEXT wxTextAttrEx
;
103 class WXDLLIMPEXP_RICHTEXT wxRichTextListStyleDefinition
;
104 class WXDLLIMPEXP_RICHTEXT wxRichTextEvent
;
105 class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer
;
106 class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer
;
109 * Flags determining the available space, passed to Layout
112 #define wxRICHTEXT_FIXED_WIDTH 0x01
113 #define wxRICHTEXT_FIXED_HEIGHT 0x02
114 #define wxRICHTEXT_VARIABLE_WIDTH 0x04
115 #define wxRICHTEXT_VARIABLE_HEIGHT 0x08
117 // Only lay out the part of the buffer that lies within
118 // the rect passed to Layout.
119 #define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10
122 * Flags to pass to Draw
125 // Ignore paragraph cache optimization, e.g. for printing purposes
126 // where one line may be drawn higher (on the next page) compared
127 // with the previous line
128 #define wxRICHTEXT_DRAW_IGNORE_CACHE 0x01
131 * Flags returned from hit-testing
134 // The point was not on this object
135 #define wxRICHTEXT_HITTEST_NONE 0x01
136 // The point was before the position returned from HitTest
137 #define wxRICHTEXT_HITTEST_BEFORE 0x02
138 // The point was after the position returned from HitTest
139 #define wxRICHTEXT_HITTEST_AFTER 0x04
140 // The point was on the position returned from HitTest
141 #define wxRICHTEXT_HITTEST_ON 0x08
142 // The point was on space outside content
143 #define wxRICHTEXT_HITTEST_OUTSIDE 0x10
146 * Flags for GetRangeSize
149 #define wxRICHTEXT_FORMATTED 0x01
150 #define wxRICHTEXT_UNFORMATTED 0x02
153 * Flags for SetStyle/SetListStyle
156 #define wxRICHTEXT_SETSTYLE_NONE 0x00
158 // Specifies that this operation should be undoable
159 #define wxRICHTEXT_SETSTYLE_WITH_UNDO 0x01
161 // Specifies that the style should not be applied if the
162 // combined style at this point is already the style in question.
163 #define wxRICHTEXT_SETSTYLE_OPTIMIZE 0x02
165 // Specifies that the style should only be applied to paragraphs,
166 // and not the content. This allows content styling to be
167 // preserved independently from that of e.g. a named paragraph style.
168 #define wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY 0x04
170 // Specifies that the style should only be applied to characters,
171 // and not the paragraph. This allows content styling to be
172 // preserved independently from that of e.g. a named paragraph style.
173 #define wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY 0x08
175 // For SetListStyle only: specifies starting from the given number, otherwise
176 // deduces number from existing attributes
177 #define wxRICHTEXT_SETSTYLE_RENUMBER 0x10
179 // For SetListStyle only: specifies the list level for all paragraphs, otherwise
180 // the current indentation will be used
181 #define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL 0x20
183 // Resets the existing style before applying the new style
184 #define wxRICHTEXT_SETSTYLE_RESET 0x40
186 // Removes the given style instead of applying it
187 #define wxRICHTEXT_SETSTYLE_REMOVE 0x80
190 * Flags for text insertion
193 #define wxRICHTEXT_INSERT_NONE 0x00
194 #define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE 0x01
197 * Extra formatting flags not in wxTextAttr
200 #define wxTEXT_ATTR_PARA_SPACING_AFTER 0x00000800
201 #define wxTEXT_ATTR_PARA_SPACING_BEFORE 0x00001000
202 #define wxTEXT_ATTR_LINE_SPACING 0x00002000
203 #define wxTEXT_ATTR_CHARACTER_STYLE_NAME 0x00004000
204 #define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME 0x00008000
205 #define wxTEXT_ATTR_LIST_STYLE_NAME 0x00010000
206 #define wxTEXT_ATTR_BULLET_STYLE 0x00020000
207 #define wxTEXT_ATTR_BULLET_NUMBER 0x00040000
208 #define wxTEXT_ATTR_BULLET_TEXT 0x00080000
209 #define wxTEXT_ATTR_BULLET_NAME 0x00100000
210 #define wxTEXT_ATTR_URL 0x00200000
211 #define wxTEXT_ATTR_PAGE_BREAK 0x00400000
212 #define wxTEXT_ATTR_EFFECTS 0x00800000
213 #define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000
216 * Styles for wxTextAttrEx::SetBulletStyle
219 #define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000
220 #define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001
221 #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002
222 #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004
223 #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008
224 #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010
225 #define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020
226 #define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040
227 #define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080
228 #define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100
229 #define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200
230 #define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400
231 #define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800
233 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000
234 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000
235 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000
238 * Styles for wxTextAttrEx::SetTextEffects
241 #define wxTEXT_ATTR_EFFECT_NONE 0x00000000
242 #define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001
243 #define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002
244 #define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004
245 #define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008
246 #define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010
247 #define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020
248 #define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040
249 #define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080
250 #define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100
251 #define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200
254 * Line spacing values
257 #define wxTEXT_ATTR_LINE_SPACING_NORMAL 10
258 #define wxTEXT_ATTR_LINE_SPACING_HALF 15
259 #define wxTEXT_ATTR_LINE_SPACING_TWICE 20
262 * Character and paragraph combined styles
265 #define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT|wxTEXT_ATTR_EFFECTS|wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL)
267 #define wxTEXT_ATTR_PARAGRAPH (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\
268 wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\
269 wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME|\
270 wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL)
272 #define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
275 * wxRichTextRange class declaration
276 * This stores beginning and end positions for a range of data.
279 class WXDLLIMPEXP_RICHTEXT wxRichTextRange
284 wxRichTextRange() { m_start
= 0; m_end
= 0; }
285 wxRichTextRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
286 wxRichTextRange(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
287 ~wxRichTextRange() {}
289 void operator =(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
290 bool operator ==(const wxRichTextRange
& range
) const { return (m_start
== range
.m_start
&& m_end
== range
.m_end
); }
291 bool operator !=(const wxRichTextRange
& range
) const { return (m_start
!= range
.m_start
&& m_end
!= range
.m_end
); }
292 wxRichTextRange
operator -(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
- range
.m_start
, m_end
- range
.m_end
); }
293 wxRichTextRange
operator +(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
+ range
.m_start
, m_end
+ range
.m_end
); }
295 void SetRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
297 void SetStart(long start
) { m_start
= start
; }
298 long GetStart() const { return m_start
; }
300 void SetEnd(long end
) { m_end
= end
; }
301 long GetEnd() const { return m_end
; }
303 /// Returns true if this range is completely outside 'range'
304 bool IsOutside(const wxRichTextRange
& range
) const { return range
.m_start
> m_end
|| range
.m_end
< m_start
; }
306 /// Returns true if this range is completely within 'range'
307 bool IsWithin(const wxRichTextRange
& range
) const { return m_start
>= range
.m_start
&& m_end
<= range
.m_end
; }
309 /// Returns true if the given position is within this range. Allow
310 /// for the possibility of an empty range - assume the position
311 /// is within this empty range. NO, I think we should not match with an empty range.
312 // bool Contains(long pos) const { return pos >= m_start && (pos <= m_end || GetLength() == 0); }
313 bool Contains(long pos
) const { return pos
>= m_start
&& pos
<= m_end
; }
315 /// Limit this range to be within 'range'
316 bool LimitTo(const wxRichTextRange
& range
) ;
318 /// Gets the length of the range
319 long GetLength() const { return m_end
- m_start
+ 1; }
321 /// Swaps the start and end
322 void Swap() { long tmp
= m_start
; m_start
= m_end
; m_end
= tmp
; }
324 /// Convert to internal form: (n, n) is the range of a single character.
325 wxRichTextRange
ToInternal() const { return wxRichTextRange(m_start
, m_end
-1); }
327 /// Convert from internal to public API form: (n, n+1) is the range of a single character.
328 wxRichTextRange
FromInternal() const { return wxRichTextRange(m_start
, m_end
+1); }
335 #define wxRICHTEXT_ALL wxRichTextRange(-2, -2)
336 #define wxRICHTEXT_NONE wxRichTextRange(-1, -1)
339 * wxTextAttrEx is an extended version of wxTextAttr with more paragraph attributes.
342 class WXDLLIMPEXP_RICHTEXT wxTextAttrEx
: public wxTextAttr
346 wxTextAttrEx(const wxTextAttrEx
& attr
);
347 wxTextAttrEx(const wxTextAttr
& attr
) { Init(); (*this) = attr
; }
348 wxTextAttrEx() { Init(); }
350 // Initialise this object
354 void Copy(const wxTextAttrEx
& attr
);
356 // Assignment from a wxTextAttrEx object
357 void operator= (const wxTextAttrEx
& attr
);
359 // Assignment from a wxTextAttr object
360 void operator= (const wxTextAttr
& attr
);
363 bool operator== (const wxTextAttrEx
& attr
) const;
366 void SetCharacterStyleName(const wxString
& name
) { m_characterStyleName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_CHARACTER_STYLE_NAME
); }
367 void SetParagraphStyleName(const wxString
& name
) { m_paragraphStyleName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_PARAGRAPH_STYLE_NAME
); }
368 void SetListStyleName(const wxString
& name
) { m_listStyleName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_STYLE_NAME
); }
369 void SetParagraphSpacingAfter(int spacing
) { m_paragraphSpacingAfter
= spacing
; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_AFTER
); }
370 void SetParagraphSpacingBefore(int spacing
) { m_paragraphSpacingBefore
= spacing
; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_BEFORE
); }
371 void SetLineSpacing(int spacing
) { m_lineSpacing
= spacing
; SetFlags(GetFlags() | wxTEXT_ATTR_LINE_SPACING
); }
372 void SetBulletStyle(int style
) { m_bulletStyle
= style
; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_STYLE
); }
373 void SetBulletNumber(int n
) { m_bulletNumber
= n
; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NUMBER
); }
374 void SetBulletText(const wxString
& text
) { m_bulletText
= text
; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_TEXT
); }
375 void SetBulletName(const wxString
& name
) { m_bulletName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NAME
); }
376 void SetBulletFont(const wxString
& bulletFont
) { m_bulletFont
= bulletFont
; }
377 void SetURL(const wxString
& url
) { m_urlTarget
= url
; SetFlags(GetFlags() | wxTEXT_ATTR_URL
); }
378 void SetPageBreak(bool pageBreak
= true) { SetFlags(pageBreak
? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK
) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK
)); }
379 void SetTextEffects(int effects
) { m_textEffects
= effects
; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS
); }
380 void SetTextEffectFlags(int effects
) { m_textEffectFlags
= effects
; }
381 void SetOutlineLevel(int level
) { m_outlineLevel
= level
; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL
); }
383 const wxString
& GetCharacterStyleName() const { return m_characterStyleName
; }
384 const wxString
& GetParagraphStyleName() const { return m_paragraphStyleName
; }
385 const wxString
& GetListStyleName() const { return m_listStyleName
; }
386 int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter
; }
387 int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore
; }
388 int GetLineSpacing() const { return m_lineSpacing
; }
389 int GetBulletStyle() const { return m_bulletStyle
; }
390 int GetBulletNumber() const { return m_bulletNumber
; }
391 const wxString
& GetBulletText() const { return m_bulletText
; }
392 const wxString
& GetBulletName() const { return m_bulletName
; }
393 const wxString
& GetBulletFont() const { return m_bulletFont
; }
394 const wxString
& GetURL() const { return m_urlTarget
; }
395 int GetTextEffects() const { return m_textEffects
; }
396 int GetTextEffectFlags() const { return m_textEffectFlags
; }
397 int GetOutlineLevel() const { return m_outlineLevel
; }
399 bool HasFontWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT
) != 0; }
400 bool HasFontSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE
) != 0; }
401 bool HasFontItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC
) != 0; }
402 bool HasFontUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE
) != 0; }
403 bool HasFontFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE
) != 0; }
405 bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER
); }
406 bool HasParagraphSpacingBefore() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE
); }
407 bool HasLineSpacing() const { return HasFlag(wxTEXT_ATTR_LINE_SPACING
); }
408 bool HasCharacterStyleName() const { return HasFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME
) && !m_characterStyleName
.IsEmpty(); }
409 bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME
) && !m_paragraphStyleName
.IsEmpty(); }
410 bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME
) || !m_listStyleName
.IsEmpty(); }
411 bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE
); }
412 bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER
); }
413 bool HasBulletText() const { return HasFlag(wxTEXT_ATTR_BULLET_TEXT
); }
414 bool HasBulletName() const { return HasFlag(wxTEXT_ATTR_BULLET_NAME
); }
415 bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL
); }
416 bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK
); }
417 bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS
); }
418 bool HasTextEffect(int effect
) const { return HasFlag(wxTEXT_ATTR_EFFECTS
) && ((GetTextEffectFlags() & effect
) != 0); }
419 bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL
); }
421 // Is this a character style?
422 bool IsCharacterStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_CHARACTER
)); }
423 bool IsParagraphStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_PARAGRAPH
)); }
425 // returns false if we have any attributes set, true otherwise
426 bool IsDefault() const
428 return (GetFlags() == 0);
431 // return the attribute having the valid font and colours: it uses the
432 // attributes set in attr and falls back first to attrDefault and then to
433 // the text control font/colours for those attributes which are not set
434 static wxTextAttrEx
CombineEx(const wxTextAttrEx
& attr
,
435 const wxTextAttrEx
& attrDef
,
436 const wxTextCtrlBase
*text
);
440 int m_paragraphSpacingAfter
;
441 int m_paragraphSpacingBefore
;
446 int m_textEffectFlags
;
448 wxString m_bulletText
;
449 wxString m_bulletFont
;
450 wxString m_bulletName
;
451 wxString m_urlTarget
;
454 wxString m_characterStyleName
;
457 wxString m_paragraphStyleName
;
460 wxString m_listStyleName
;
464 * wxRichTextAttr stores attributes without a wxFont object, so is a much more
465 * efficient way to query styles.
468 class WXDLLIMPEXP_RICHTEXT wxRichTextAttr
472 wxRichTextAttr(const wxTextAttrEx
& attr
);
473 wxRichTextAttr(const wxRichTextAttr
& attr
);
474 wxRichTextAttr() { Init(); }
475 wxRichTextAttr(const wxColour
& colText
,
476 const wxColour
& colBack
= wxNullColour
,
477 wxTextAttrAlignment alignment
= wxTEXT_ALIGNMENT_DEFAULT
);
479 // Initialise this object.
483 void Copy(const wxRichTextAttr
& attr
);
485 // Assignment from a wxRichTextAttr object.
486 void operator= (const wxRichTextAttr
& attr
);
488 // Assignment from a wxTextAttrEx object.
489 void operator= (const wxTextAttrEx
& attr
);
492 bool operator== (const wxRichTextAttr
& attr
) const;
494 // Making a wxTextAttrEx object.
495 operator wxTextAttrEx () const ;
497 // Create font from font attributes.
498 wxFont
CreateFont() const;
500 // Get attributes from font.
501 bool GetFontAttributes(const wxFont
& font
);
504 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; m_flags
|= wxTEXT_ATTR_TEXT_COLOUR
; }
505 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; m_flags
|= wxTEXT_ATTR_BACKGROUND_COLOUR
; }
506 void SetAlignment(wxTextAttrAlignment alignment
) { m_textAlignment
= alignment
; m_flags
|= wxTEXT_ATTR_ALIGNMENT
; }
507 void SetTabs(const wxArrayInt
& tabs
) { m_tabs
= tabs
; m_flags
|= wxTEXT_ATTR_TABS
; }
508 void SetLeftIndent(int indent
, int subIndent
= 0) { m_leftIndent
= indent
; m_leftSubIndent
= subIndent
; m_flags
|= wxTEXT_ATTR_LEFT_INDENT
; }
509 void SetRightIndent(int indent
) { m_rightIndent
= indent
; m_flags
|= wxTEXT_ATTR_RIGHT_INDENT
; }
511 void SetFontSize(int pointSize
) { m_fontSize
= pointSize
; m_flags
|= wxTEXT_ATTR_FONT_SIZE
; }
512 void SetFontStyle(int fontStyle
) { m_fontStyle
= fontStyle
; m_flags
|= wxTEXT_ATTR_FONT_ITALIC
; }
513 void SetFontWeight(int fontWeight
) { m_fontWeight
= fontWeight
; m_flags
|= wxTEXT_ATTR_FONT_WEIGHT
; }
514 void SetFontFaceName(const wxString
& faceName
) { m_fontFaceName
= faceName
; m_flags
|= wxTEXT_ATTR_FONT_FACE
; }
515 void SetFontUnderlined(bool underlined
) { m_fontUnderlined
= underlined
; m_flags
|= wxTEXT_ATTR_FONT_UNDERLINE
; }
517 void SetFlags(long flags
) { m_flags
= flags
; }
519 void SetCharacterStyleName(const wxString
& name
) { m_characterStyleName
= name
; m_flags
|= wxTEXT_ATTR_CHARACTER_STYLE_NAME
; }
520 void SetParagraphStyleName(const wxString
& name
) { m_paragraphStyleName
= name
; m_flags
|= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME
; }
521 void SetListStyleName(const wxString
& name
) { m_listStyleName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_STYLE_NAME
); }
522 void SetParagraphSpacingAfter(int spacing
) { m_paragraphSpacingAfter
= spacing
; m_flags
|= wxTEXT_ATTR_PARA_SPACING_AFTER
; }
523 void SetParagraphSpacingBefore(int spacing
) { m_paragraphSpacingBefore
= spacing
; m_flags
|= wxTEXT_ATTR_PARA_SPACING_BEFORE
; }
524 void SetLineSpacing(int spacing
) { m_lineSpacing
= spacing
; m_flags
|= wxTEXT_ATTR_LINE_SPACING
; }
525 void SetBulletStyle(int style
) { m_bulletStyle
= style
; m_flags
|= wxTEXT_ATTR_BULLET_STYLE
; }
526 void SetBulletNumber(int n
) { m_bulletNumber
= n
; m_flags
|= wxTEXT_ATTR_BULLET_NUMBER
; }
527 void SetBulletText(const wxString
& text
) { m_bulletText
= text
; m_flags
|= wxTEXT_ATTR_BULLET_TEXT
; }
528 void SetBulletFont(const wxString
& bulletFont
) { m_bulletFont
= bulletFont
; }
529 void SetBulletName(const wxString
& name
) { m_bulletName
= name
; m_flags
|= wxTEXT_ATTR_BULLET_NAME
; }
530 void SetURL(const wxString
& url
) { m_urlTarget
= url
; m_flags
|= wxTEXT_ATTR_URL
; }
531 void SetPageBreak(bool pageBreak
= true) { SetFlags(pageBreak
? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK
) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK
)); }
532 void SetTextEffects(int effects
) { m_textEffects
= effects
; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS
); }
533 void SetTextEffectFlags(int effects
) { m_textEffectFlags
= effects
; }
534 void SetOutlineLevel(int level
) { m_outlineLevel
= level
; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL
); }
536 const wxColour
& GetTextColour() const { return m_colText
; }
537 const wxColour
& GetBackgroundColour() const { return m_colBack
; }
538 wxTextAttrAlignment
GetAlignment() const { return m_textAlignment
; }
539 const wxArrayInt
& GetTabs() const { return m_tabs
; }
540 long GetLeftIndent() const { return m_leftIndent
; }
541 long GetLeftSubIndent() const { return m_leftSubIndent
; }
542 long GetRightIndent() const { return m_rightIndent
; }
543 long GetFlags() const { return m_flags
; }
545 int GetFontSize() const { return m_fontSize
; }
546 int GetFontStyle() const { return m_fontStyle
; }
547 int GetFontWeight() const { return m_fontWeight
; }
548 bool GetFontUnderlined() const { return m_fontUnderlined
; }
549 const wxString
& GetFontFaceName() const { return m_fontFaceName
; }
551 const wxString
& GetCharacterStyleName() const { return m_characterStyleName
; }
552 const wxString
& GetParagraphStyleName() const { return m_paragraphStyleName
; }
553 const wxString
& GetListStyleName() const { return m_listStyleName
; }
554 int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter
; }
555 int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore
; }
556 int GetLineSpacing() const { return m_lineSpacing
; }
557 int GetBulletStyle() const { return m_bulletStyle
; }
558 int GetBulletNumber() const { return m_bulletNumber
; }
559 const wxString
& GetBulletText() const { return m_bulletText
; }
560 const wxString
& GetBulletFont() const { return m_bulletFont
; }
561 const wxString
& GetBulletName() const { return m_bulletName
; }
562 const wxString
& GetURL() const { return m_urlTarget
; }
563 int GetTextEffects() const { return m_textEffects
; }
564 int GetTextEffectFlags() const { return m_textEffectFlags
; }
565 int GetOutlineLevel() const { return m_outlineLevel
; }
568 bool HasTextColour() const { return m_colText
.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR
) ; }
569 bool HasBackgroundColour() const { return m_colBack
.Ok() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR
) ; }
570 bool HasAlignment() const { return (m_textAlignment
!= wxTEXT_ALIGNMENT_DEFAULT
) || ((m_flags
& wxTEXT_ATTR_ALIGNMENT
) != 0) ; }
571 bool HasTabs() const { return (m_flags
& wxTEXT_ATTR_TABS
) != 0 ; }
572 bool HasLeftIndent() const { return (m_flags
& wxTEXT_ATTR_LEFT_INDENT
) != 0 ; }
573 bool HasRightIndent() const { return (m_flags
& wxTEXT_ATTR_RIGHT_INDENT
) != 0 ; }
574 bool HasFontWeight() const { return (m_flags
& wxTEXT_ATTR_FONT_WEIGHT
) != 0; }
575 bool HasFontSize() const { return (m_flags
& wxTEXT_ATTR_FONT_SIZE
) != 0; }
576 bool HasFontItalic() const { return (m_flags
& wxTEXT_ATTR_FONT_ITALIC
) != 0; }
577 bool HasFontUnderlined() const { return (m_flags
& wxTEXT_ATTR_FONT_UNDERLINE
) != 0; }
578 bool HasFontFaceName() const { return (m_flags
& wxTEXT_ATTR_FONT_FACE
) != 0; }
579 bool HasFont() const { return (m_flags
& (wxTEXT_ATTR_FONT
)) != 0; }
581 bool HasParagraphSpacingAfter() const { return (m_flags
& wxTEXT_ATTR_PARA_SPACING_AFTER
) != 0; }
582 bool HasParagraphSpacingBefore() const { return (m_flags
& wxTEXT_ATTR_PARA_SPACING_BEFORE
) != 0; }
583 bool HasLineSpacing() const { return (m_flags
& wxTEXT_ATTR_LINE_SPACING
) != 0; }
584 bool HasCharacterStyleName() const { return (m_flags
& wxTEXT_ATTR_CHARACTER_STYLE_NAME
) != 0 && !m_characterStyleName
.IsEmpty(); }
585 bool HasParagraphStyleName() const { return (m_flags
& wxTEXT_ATTR_PARAGRAPH_STYLE_NAME
) != 0 && !m_paragraphStyleName
.IsEmpty(); }
586 bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME
) || !m_listStyleName
.IsEmpty(); }
587 bool HasBulletStyle() const { return (m_flags
& wxTEXT_ATTR_BULLET_STYLE
) != 0; }
588 bool HasBulletNumber() const { return (m_flags
& wxTEXT_ATTR_BULLET_NUMBER
) != 0; }
589 bool HasBulletText() const { return (m_flags
& wxTEXT_ATTR_BULLET_TEXT
) != 0; }
590 bool HasBulletName() const { return (m_flags
& wxTEXT_ATTR_BULLET_NAME
) != 0; }
591 bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL
); }
592 bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK
); }
593 bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS
); }
594 bool HasTextEffect(int effect
) const { return HasFlag(wxTEXT_ATTR_EFFECTS
) && ((GetTextEffectFlags() & effect
) != 0); }
595 bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL
); }
597 bool HasFlag(long flag
) const { return (m_flags
& flag
) != 0; }
599 // Is this a character style?
600 bool IsCharacterStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_CHARACTER
)); }
601 bool IsParagraphStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_PARAGRAPH
)); }
603 // returns false if we have any attributes set, true otherwise
604 bool IsDefault() const
606 return GetFlags() == 0;
609 // Merges the given attributes. Does not affect 'this'. If compareWith
610 // is non-NULL, then it will be used to mask out those attributes that are the same in style
611 // and compareWith, for situations where we don't want to explicitly set inherited attributes.
612 bool Apply(const wxRichTextAttr
& style
, const wxRichTextAttr
* compareWith
= NULL
);
614 // Merges the given attributes and returns the result. Does not affect 'this'. If compareWith
615 // is non-NULL, then it will be used to mask out those attributes that are the same in style
616 // and compareWith, for situations where we don't want to explicitly set inherited attributes.
617 wxRichTextAttr
Combine(const wxRichTextAttr
& style
, const wxRichTextAttr
* compareWith
= NULL
) const;
623 wxArrayInt m_tabs
; // array of int: tab stops in 1/10 mm
624 int m_leftIndent
; // left indent in 1/10 mm
625 int m_leftSubIndent
; // left indent for all but the first
626 // line in a paragraph relative to the
627 // first line, in 1/10 mm
628 int m_rightIndent
; // right indent in 1/10 mm
629 wxTextAttrAlignment m_textAlignment
;
631 int m_paragraphSpacingAfter
;
632 int m_paragraphSpacingBefore
;
637 int m_textEffectFlags
;
639 wxString m_bulletText
;
640 wxString m_bulletFont
;
641 wxString m_bulletName
;
642 wxString m_urlTarget
;
650 bool m_fontUnderlined
;
651 wxString m_fontFaceName
;
654 wxString m_characterStyleName
;
657 wxString m_paragraphStyleName
;
660 wxString m_listStyleName
;
664 * wxRichTextObject class declaration
665 * This is the base for drawable objects.
668 class WXDLLIMPEXP_RICHTEXT wxRichTextObject
: public wxObject
670 DECLARE_CLASS(wxRichTextObject
)
674 wxRichTextObject(wxRichTextObject
* parent
= NULL
);
675 virtual ~wxRichTextObject();
679 /// Draw the item, within the given range. Some objects may ignore the range (for
680 /// example paragraphs) while others must obey it (lines, to implement wrapping)
681 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
) = 0;
683 /// Lay the item out at the specified position with the given size constraint.
684 /// Layout must set the cached size.
685 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
) = 0;
687 /// Hit-testing: returns a flag indicating hit test details, plus
688 /// information about position
689 virtual int HitTest(wxDC
& WXUNUSED(dc
), const wxPoint
& WXUNUSED(pt
), long& WXUNUSED(textPosition
)) { return false; }
691 /// Finds the absolute position and row height for the given character position
692 virtual bool FindPosition(wxDC
& WXUNUSED(dc
), long WXUNUSED(index
), wxPoint
& WXUNUSED(pt
), int* WXUNUSED(height
), bool WXUNUSED(forceLineStart
)) { return false; }
694 /// Get the best size, i.e. the ideal starting size for this object irrespective
695 /// of available space. For a short text string, it will be the size that exactly encloses
696 /// the text. For a longer string, it might use the parent width for example.
697 virtual wxSize
GetBestSize() const { return m_size
; }
699 /// Get the object size for the given range. Returns false if the range
700 /// is invalid for this object.
701 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const = 0;
703 /// Do a split, returning an object containing the second part, and setting
704 /// the first part in 'this'.
705 virtual wxRichTextObject
* DoSplit(long WXUNUSED(pos
)) { return NULL
; }
707 /// Calculate range. By default, guess that the object is 1 unit long.
708 virtual void CalculateRange(long start
, long& end
) { end
= start
; m_range
.SetRange(start
, end
); }
711 virtual bool DeleteRange(const wxRichTextRange
& WXUNUSED(range
)) { return false; }
713 /// Returns true if the object is empty
714 virtual bool IsEmpty() const { return false; }
716 /// Get any text in this object for the given range
717 virtual wxString
GetTextForRange(const wxRichTextRange
& WXUNUSED(range
)) const { return wxEmptyString
; }
719 /// Returns true if this object can merge itself with the given one.
720 virtual bool CanMerge(wxRichTextObject
* WXUNUSED(object
)) const { return false; }
722 /// Returns true if this object merged itself with the given one.
723 /// The calling code will then delete the given object.
724 virtual bool Merge(wxRichTextObject
* WXUNUSED(object
)) { return false; }
726 /// Dump to output stream for debugging
727 virtual void Dump(wxTextOutputStream
& stream
);
731 /// Get/set the cached object size as calculated by Layout.
732 virtual wxSize
GetCachedSize() const { return m_size
; }
733 virtual void SetCachedSize(const wxSize
& sz
) { m_size
= sz
; }
735 /// Get/set the object position
736 virtual wxPoint
GetPosition() const { return m_pos
; }
737 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
739 /// Get the rectangle enclosing the object
740 virtual wxRect
GetRect() const { return wxRect(GetPosition(), GetCachedSize()); }
743 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
746 const wxRichTextRange
& GetRange() const { return m_range
; }
747 wxRichTextRange
& GetRange() { return m_range
; }
749 /// Get/set dirty flag (whether the object needs Layout to be called)
750 virtual bool GetDirty() const { return m_dirty
; }
751 virtual void SetDirty(bool dirty
) { m_dirty
= dirty
; }
753 /// Is this composite?
754 virtual bool IsComposite() const { return false; }
756 /// Get/set the parent.
757 virtual wxRichTextObject
* GetParent() const { return m_parent
; }
758 virtual void SetParent(wxRichTextObject
* parent
) { m_parent
= parent
; }
760 /// Set the margin around the object
761 virtual void SetMargins(int margin
);
762 virtual void SetMargins(int leftMargin
, int rightMargin
, int topMargin
, int bottomMargin
);
763 virtual int GetLeftMargin() const { return m_leftMargin
; }
764 virtual int GetRightMargin() const { return m_rightMargin
; }
765 virtual int GetTopMargin() const { return m_topMargin
; }
766 virtual int GetBottomMargin() const { return m_bottomMargin
; }
768 /// Set attributes object
769 void SetAttributes(const wxTextAttrEx
& attr
) { m_attributes
= attr
; }
770 const wxTextAttrEx
& GetAttributes() const { return m_attributes
; }
771 wxTextAttrEx
& GetAttributes() { return m_attributes
; }
773 /// Set/get stored descent
774 void SetDescent(int descent
) { m_descent
= descent
; }
775 int GetDescent() const { return m_descent
; }
777 /// Gets the containing buffer
778 wxRichTextBuffer
* GetBuffer() const;
783 virtual wxRichTextObject
* Clone() const { return NULL
; }
786 void Copy(const wxRichTextObject
& obj
);
788 /// Reference-counting allows us to use the same object in multiple
789 /// lists (not yet used)
790 void Reference() { m_refCount
++; }
793 /// Convert units in tenths of a millimetre to device units
794 int ConvertTenthsMMToPixels(wxDC
& dc
, int units
);
795 static int ConvertTenthsMMToPixels(int ppi
, int units
);
800 int m_descent
; // Descent for this object (if any)
803 wxRichTextObject
* m_parent
;
805 /// The range of this object (start position to end position)
806 wxRichTextRange m_range
;
815 wxTextAttrEx m_attributes
;
818 WX_DECLARE_LIST_WITH_DECL( wxRichTextObject
, wxRichTextObjectList
, class WXDLLIMPEXP_RICHTEXT
);
821 * wxRichTextCompositeObject class declaration
822 * Objects of this class can contain other objects.
825 class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject
: public wxRichTextObject
827 DECLARE_CLASS(wxRichTextCompositeObject
)
831 wxRichTextCompositeObject(wxRichTextObject
* parent
= NULL
);
832 virtual ~wxRichTextCompositeObject();
836 /// Hit-testing: returns a flag indicating hit test details, plus
837 /// information about position
838 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
);
840 /// Finds the absolute position and row height for the given character position
841 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
844 virtual void CalculateRange(long start
, long& end
);
847 virtual bool DeleteRange(const wxRichTextRange
& range
);
849 /// Get any text in this object for the given range
850 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
852 /// Dump to output stream for debugging
853 virtual void Dump(wxTextOutputStream
& stream
);
858 wxRichTextObjectList
& GetChildren() { return m_children
; }
859 const wxRichTextObjectList
& GetChildren() const { return m_children
; }
861 /// Get the child count
862 size_t GetChildCount() const ;
864 /// Get the nth child
865 wxRichTextObject
* GetChild(size_t n
) const ;
867 /// Get/set dirty flag
868 virtual bool GetDirty() const { return m_dirty
; }
869 virtual void SetDirty(bool dirty
) { m_dirty
= dirty
; }
871 /// Is this composite?
872 virtual bool IsComposite() const { return true; }
874 /// Returns true if the buffer is empty
875 virtual bool IsEmpty() const { return GetChildCount() == 0; }
880 void Copy(const wxRichTextCompositeObject
& obj
);
883 void operator= (const wxRichTextCompositeObject
& obj
) { Copy(obj
); }
885 /// Append a child, returning the position
886 size_t AppendChild(wxRichTextObject
* child
) ;
888 /// Insert the child in front of the given object, or at the beginning
889 bool InsertChild(wxRichTextObject
* child
, wxRichTextObject
* inFrontOf
) ;
892 bool RemoveChild(wxRichTextObject
* child
, bool deleteChild
= false) ;
894 /// Delete all children
895 bool DeleteChildren() ;
897 /// Recursively merge all pieces that can be merged.
901 wxRichTextObjectList m_children
;
905 * wxRichTextBox class declaration
906 * This defines a 2D space to lay out objects
909 class WXDLLIMPEXP_RICHTEXT wxRichTextBox
: public wxRichTextCompositeObject
911 DECLARE_DYNAMIC_CLASS(wxRichTextBox
)
915 wxRichTextBox(wxRichTextObject
* parent
= NULL
);
916 wxRichTextBox(const wxRichTextBox
& obj
): wxRichTextCompositeObject() { Copy(obj
); }
921 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
924 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
926 /// Get/set the object size for the given range. Returns false if the range
927 /// is invalid for this object.
928 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const;
935 virtual wxRichTextObject
* Clone() const { return new wxRichTextBox(*this); }
938 void Copy(const wxRichTextBox
& obj
);
944 * wxRichTextParagraphBox class declaration
945 * This box knows how to lay out paragraphs.
948 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphLayoutBox
: public wxRichTextBox
950 DECLARE_DYNAMIC_CLASS(wxRichTextParagraphLayoutBox
)
954 wxRichTextParagraphLayoutBox(wxRichTextObject
* parent
= NULL
);
955 wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox
& obj
): wxRichTextBox() { Init(); Copy(obj
); }
960 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
963 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
965 /// Get/set the object size for the given range. Returns false if the range
966 /// is invalid for this object.
967 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const;
970 virtual bool DeleteRange(const wxRichTextRange
& range
);
972 /// Get any text in this object for the given range
973 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
977 /// Associate a control with the buffer, for operations that for example require refreshing the window.
978 void SetRichTextCtrl(wxRichTextCtrl
* ctrl
) { m_ctrl
= ctrl
; }
980 /// Get the associated control.
981 wxRichTextCtrl
* GetRichTextCtrl() const { return m_ctrl
; }
983 /// Get/set whether the last paragraph is partial or complete
984 void SetPartialParagraph(bool partialPara
) { m_partialParagraph
= partialPara
; }
985 bool GetPartialParagraph() const { return m_partialParagraph
; }
987 /// If this is a buffer, returns the current style sheet. The base layout box
988 /// class doesn't have an associated style sheet.
989 virtual wxRichTextStyleSheet
* GetStyleSheet() const { return NULL
; }
993 /// Initialize the object.
996 /// Clear all children
997 virtual void Clear();
999 /// Clear and initialize with one blank paragraph
1000 virtual void Reset();
1002 /// Convenience function to add a paragraph of text
1003 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxTextAttrEx
* paraStyle
= NULL
);
1005 /// Convenience function to add an image
1006 virtual wxRichTextRange
AddImage(const wxImage
& image
, wxTextAttrEx
* paraStyle
= NULL
);
1008 /// Adds multiple paragraphs, based on newlines.
1009 virtual wxRichTextRange
AddParagraphs(const wxString
& text
, wxTextAttrEx
* paraStyle
= NULL
);
1011 /// Get the line at the given position. If caretPosition is true, the position is
1012 /// a caret position, which is normally a smaller number.
1013 virtual wxRichTextLine
* GetLineAtPosition(long pos
, bool caretPosition
= false) const;
1015 /// Get the line at the given y pixel position, or the last line.
1016 virtual wxRichTextLine
* GetLineAtYPosition(int y
) const;
1018 /// Get the paragraph at the given character or caret position
1019 virtual wxRichTextParagraph
* GetParagraphAtPosition(long pos
, bool caretPosition
= false) const;
1021 /// Get the line size at the given position
1022 virtual wxSize
GetLineSizeAtPosition(long pos
, bool caretPosition
= false) const;
1024 /// Given a position, get the number of the visible line (potentially many to a paragraph),
1025 /// starting from zero at the start of the buffer. We also have to pass a bool (startOfLine)
1026 /// that indicates whether the caret is being shown at the end of the previous line or at the start
1027 /// of the next, since the caret can be shown at 2 visible positions for the same underlying
1029 virtual long GetVisibleLineNumber(long pos
, bool caretPosition
= false, bool startOfLine
= false) const;
1031 /// Given a line number, get the corresponding wxRichTextLine object.
1032 virtual wxRichTextLine
* GetLineForVisibleLineNumber(long lineNumber
) const;
1034 /// Get the leaf object in a paragraph at this position.
1035 /// Given a line number, get the corresponding wxRichTextLine object.
1036 virtual wxRichTextObject
* GetLeafObjectAtPosition(long position
) const;
1038 /// Get the paragraph by number
1039 virtual wxRichTextParagraph
* GetParagraphAtLine(long paragraphNumber
) const;
1041 /// Get the paragraph for a given line
1042 virtual wxRichTextParagraph
* GetParagraphForLine(wxRichTextLine
* line
) const;
1044 /// Get the length of the paragraph
1045 virtual int GetParagraphLength(long paragraphNumber
) const;
1047 /// Get the number of paragraphs
1048 virtual int GetParagraphCount() const { return GetChildCount(); }
1050 /// Get the number of visible lines
1051 virtual int GetLineCount() const;
1053 /// Get the text of the paragraph
1054 virtual wxString
GetParagraphText(long paragraphNumber
) const;
1056 /// Convert zero-based line column and paragraph number to a position.
1057 virtual long XYToPosition(long x
, long y
) const;
1059 /// Convert zero-based position to line column and paragraph number
1060 virtual bool PositionToXY(long pos
, long* x
, long* y
) const;
1062 /// Set text attributes: character and/or paragraph styles.
1063 virtual bool SetStyle(const wxRichTextRange
& range
, const wxRichTextAttr
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1064 virtual bool SetStyle(const wxRichTextRange
& range
, const wxTextAttrEx
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1066 /// Get the conbined text attributes for this position.
1067 virtual bool GetStyle(long position
, wxTextAttrEx
& style
);
1068 virtual bool GetStyle(long position
, wxRichTextAttr
& style
);
1070 /// Get the content (uncombined) attributes for this position.
1071 virtual bool GetUncombinedStyle(long position
, wxTextAttrEx
& style
);
1072 virtual bool GetUncombinedStyle(long position
, wxRichTextAttr
& style
);
1074 /// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and
1075 /// context attributes.
1076 virtual bool DoGetStyle(long position
, wxTextAttrEx
& style
, bool combineStyles
= true);
1078 /// Get the combined style for a range - if any attribute is different within the range,
1079 /// that attribute is not present within the flags
1080 virtual bool GetStyleForRange(const wxRichTextRange
& range
, wxTextAttrEx
& style
);
1082 /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
1084 bool CollectStyle(wxTextAttrEx
& currentStyle
, const wxTextAttrEx
& style
, long& multipleStyleAttributes
, int& multipleTextEffectAttributes
);
1087 virtual bool SetListStyle(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
1088 virtual bool SetListStyle(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
1090 /// Clear list for given range
1091 virtual bool ClearListStyle(const wxRichTextRange
& range
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1093 /// Number/renumber any list elements in the given range.
1094 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
1095 virtual bool NumberList(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
1096 virtual bool NumberList(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
1098 /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1
1099 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
1100 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
1101 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
1103 /// Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously
1104 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
1105 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);
1107 /// Fills in the attributes for numbering a paragraph after previousParagraph.
1108 virtual bool FindNextParagraphNumber(wxRichTextParagraph
* previousParagraph
, wxRichTextAttr
& attr
) const;
1110 /// Test if this whole range has character attributes of the specified kind. If any
1111 /// of the attributes are different within the range, the test fails. You
1112 /// can use this to implement, for example, bold button updating. style must have
1113 /// flags indicating which attributes are of interest.
1114 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxTextAttrEx
& style
) const;
1115 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
1117 /// Test if this whole range has paragraph attributes of the specified kind. If any
1118 /// of the attributes are different within the range, the test fails. You
1119 /// can use this to implement, for example, centering button updating. style must have
1120 /// flags indicating which attributes are of interest.
1121 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxTextAttrEx
& style
) const;
1122 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
1125 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraphLayoutBox(*this); }
1127 /// Insert fragment into this box at the given position. If partialParagraph is true,
1128 /// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
1130 virtual bool InsertFragment(long position
, wxRichTextParagraphLayoutBox
& fragment
);
1132 /// Make a copy of the fragment corresponding to the given range, putting it in 'fragment'.
1133 virtual bool CopyFragment(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
& fragment
);
1135 /// Apply the style sheet to the buffer, for example if the styles have changed.
1136 virtual bool ApplyStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1139 void Copy(const wxRichTextParagraphLayoutBox
& obj
);
1142 void operator= (const wxRichTextParagraphLayoutBox
& obj
) { Copy(obj
); }
1144 /// Calculate ranges
1145 virtual void UpdateRanges() { long end
; CalculateRange(0, end
); }
1147 /// Get all the text
1148 virtual wxString
GetText() const;
1150 /// Set default style for new content. Setting it to a default attribute
1151 /// makes new content take on the 'basic' style.
1152 virtual bool SetDefaultStyle(const wxTextAttrEx
& style
);
1154 /// Get default style
1155 virtual const wxTextAttrEx
& GetDefaultStyle() const { return m_defaultAttributes
; }
1157 /// Set basic (overall) style
1158 virtual void SetBasicStyle(const wxTextAttrEx
& style
) { m_attributes
= style
; }
1159 virtual void SetBasicStyle(const wxRichTextAttr
& style
) { m_attributes
= style
; }
1161 /// Get basic (overall) style
1162 virtual const wxTextAttrEx
& GetBasicStyle() const { return m_attributes
; }
1164 /// Invalidate the buffer. With no argument, invalidates whole buffer.
1165 void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
1167 /// Get invalid range, rounding to entire paragraphs if argument is true.
1168 wxRichTextRange
GetInvalidRange(bool wholeParagraphs
= false) const;
1171 wxRichTextCtrl
* m_ctrl
;
1172 wxTextAttrEx m_defaultAttributes
;
1174 /// The invalidated range that will need full layout
1175 wxRichTextRange m_invalidRange
;
1177 // Is the last paragraph partial or complete?
1178 bool m_partialParagraph
;
1182 * wxRichTextLine class declaration
1183 * This object represents a line in a paragraph, and stores
1184 * offsets from the start of the paragraph representing the
1185 * start and end positions of the line.
1188 class WXDLLIMPEXP_RICHTEXT wxRichTextLine
1193 wxRichTextLine(wxRichTextParagraph
* parent
);
1194 wxRichTextLine(const wxRichTextLine
& obj
) { Init( NULL
); Copy(obj
); }
1195 virtual ~wxRichTextLine() {}
1202 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
1203 void SetRange(long from
, long to
) { m_range
= wxRichTextRange(from
, to
); }
1205 /// Get the parent paragraph
1206 wxRichTextParagraph
* GetParent() { return m_parent
; }
1209 const wxRichTextRange
& GetRange() const { return m_range
; }
1210 wxRichTextRange
& GetRange() { return m_range
; }
1212 /// Get the absolute range
1213 wxRichTextRange
GetAbsoluteRange() const;
1215 /// Get/set the line size as calculated by Layout.
1216 virtual wxSize
GetSize() const { return m_size
; }
1217 virtual void SetSize(const wxSize
& sz
) { m_size
= sz
; }
1219 /// Get/set the object position relative to the parent
1220 virtual wxPoint
GetPosition() const { return m_pos
; }
1221 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
1223 /// Get the absolute object position
1224 virtual wxPoint
GetAbsolutePosition() const;
1226 /// Get the rectangle enclosing the line
1227 virtual wxRect
GetRect() const { return wxRect(GetAbsolutePosition(), GetSize()); }
1229 /// Set/get stored descent
1230 void SetDescent(int descent
) { m_descent
= descent
; }
1231 int GetDescent() const { return m_descent
; }
1236 void Init(wxRichTextParagraph
* parent
);
1239 void Copy(const wxRichTextLine
& obj
);
1242 virtual wxRichTextLine
* Clone() const { return new wxRichTextLine(*this); }
1246 /// The range of the line (start position to end position)
1247 /// This is relative to the parent paragraph.
1248 wxRichTextRange m_range
;
1250 /// Size and position measured relative to top of paragraph
1254 /// Maximum descent for this line (location of text baseline)
1257 // The parent object
1258 wxRichTextParagraph
* m_parent
;
1261 WX_DECLARE_LIST_WITH_DECL( wxRichTextLine
, wxRichTextLineList
, class WXDLLIMPEXP_RICHTEXT
);
1264 * wxRichTextParagraph class declaration
1265 * This object represents a single paragraph (or in a straight text editor, a line).
1268 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph
: public wxRichTextBox
1270 DECLARE_DYNAMIC_CLASS(wxRichTextParagraph
)
1274 wxRichTextParagraph(wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* style
= NULL
);
1275 wxRichTextParagraph(const wxString
& text
, wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* paraStyle
= NULL
, wxTextAttrEx
* charStyle
= NULL
);
1276 virtual ~wxRichTextParagraph();
1277 wxRichTextParagraph(const wxRichTextParagraph
& obj
): wxRichTextBox() { Copy(obj
); }
1282 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
1284 /// Lay the item out
1285 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
1287 /// Get/set the object size for the given range. Returns false if the range
1288 /// is invalid for this object.
1289 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const;
1291 /// Finds the absolute position and row height for the given character position
1292 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
1294 /// Hit-testing: returns a flag indicating hit test details, plus
1295 /// information about position
1296 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
);
1299 virtual void CalculateRange(long start
, long& end
);
1303 /// Get the cached lines
1304 wxRichTextLineList
& GetLines() { return m_cachedLines
; }
1309 void Copy(const wxRichTextParagraph
& obj
);
1312 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraph(*this); }
1314 /// Clear the cached lines
1319 /// Apply paragraph styles such as centering to the wrapped lines
1320 virtual void ApplyParagraphStyle(const wxTextAttrEx
& attr
, const wxRect
& rect
);
1322 /// Insert text at the given position
1323 virtual bool InsertText(long pos
, const wxString
& text
);
1325 /// Split an object at this position if necessary, and return
1326 /// the previous object, or NULL if inserting at beginning.
1327 virtual wxRichTextObject
* SplitAt(long pos
, wxRichTextObject
** previousObject
= NULL
);
1329 /// Move content to a list from this point
1330 virtual void MoveToList(wxRichTextObject
* obj
, wxList
& list
);
1332 /// Add content back from list
1333 virtual void MoveFromList(wxList
& list
);
1335 /// Get the plain text searching from the start or end of the range.
1336 /// The resulting string may be shorter than the range given.
1337 bool GetContiguousPlainText(wxString
& text
, const wxRichTextRange
& range
, bool fromStart
= true);
1339 /// Find a suitable wrap position. wrapPosition is the last position in the line to the left
1341 bool FindWrapPosition(const wxRichTextRange
& range
, wxDC
& dc
, int availableSpace
, long& wrapPosition
);
1343 /// Find the object at the given position
1344 wxRichTextObject
* FindObjectAtPosition(long position
);
1346 /// Get the bullet text for this paragraph.
1347 wxString
GetBulletText();
1349 /// Allocate or reuse a line object
1350 wxRichTextLine
* AllocateLine(int pos
);
1352 /// Clear remaining unused line objects, if any
1353 bool ClearUnusedLines(int lineCount
);
1355 /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically
1356 /// retrieve the actual style.
1357 wxTextAttrEx
GetCombinedAttributes(const wxTextAttrEx
& contentStyle
) const;
1359 /// Get combined attributes of the base style and paragraph style.
1360 wxTextAttrEx
GetCombinedAttributes() const;
1362 /// Get the first position from pos that has a line break character.
1363 long GetFirstLineBreakPosition(long pos
);
1365 /// Create default tabstop array
1366 static void InitDefaultTabs();
1368 /// Clear default tabstop array
1369 static void ClearDefaultTabs();
1371 /// Get default tabstop array
1372 static const wxArrayInt
& GetDefaultTabs() { return sm_defaultTabs
; }
1375 /// The lines that make up the wrapped paragraph
1376 wxRichTextLineList m_cachedLines
;
1378 /// Default tabstops
1379 static wxArrayInt sm_defaultTabs
;
1383 * wxRichTextPlainText class declaration
1384 * This object represents a single piece of text.
1387 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText
: public wxRichTextObject
1389 DECLARE_DYNAMIC_CLASS(wxRichTextPlainText
)
1393 wxRichTextPlainText(const wxString
& text
= wxEmptyString
, wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* style
= NULL
);
1394 wxRichTextPlainText(const wxRichTextPlainText
& obj
): wxRichTextObject() { Copy(obj
); }
1399 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
1401 /// Lay the item out
1402 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
1404 /// Get/set the object size for the given range. Returns false if the range
1405 /// is invalid for this object.
1406 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
/* = wxPoint(0,0)*/) const;
1408 /// Get any text in this object for the given range
1409 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
1411 /// Do a split, returning an object containing the second part, and setting
1412 /// the first part in 'this'.
1413 virtual wxRichTextObject
* DoSplit(long pos
);
1416 virtual void CalculateRange(long start
, long& end
);
1419 virtual bool DeleteRange(const wxRichTextRange
& range
);
1421 /// Returns true if the object is empty
1422 virtual bool IsEmpty() const { return m_text
.empty(); }
1424 /// Returns true if this object can merge itself with the given one.
1425 virtual bool CanMerge(wxRichTextObject
* object
) const;
1427 /// Returns true if this object merged itself with the given one.
1428 /// The calling code will then delete the given object.
1429 virtual bool Merge(wxRichTextObject
* object
);
1431 /// Dump to output stream for debugging
1432 virtual void Dump(wxTextOutputStream
& stream
);
1434 /// Get the first position from pos that has a line break character.
1435 long GetFirstLineBreakPosition(long pos
);
1440 const wxString
& GetText() const { return m_text
; }
1443 void SetText(const wxString
& text
) { m_text
= text
; }
1448 void Copy(const wxRichTextPlainText
& obj
);
1451 virtual wxRichTextObject
* Clone() const { return new wxRichTextPlainText(*this); }
1453 bool DrawTabbedString(wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
, wxString
& str
, wxCoord
& x
, wxCoord
& y
, bool selected
);
1460 * wxRichTextImageBlock stores information about an image, in binary in-memory form
1463 class WXDLLIMPEXP_BASE wxDataInputStream
;
1464 class WXDLLIMPEXP_BASE wxDataOutputStream
;
1466 class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock
: public wxObject
1469 wxRichTextImageBlock();
1470 wxRichTextImageBlock(const wxRichTextImageBlock
& block
);
1471 virtual ~wxRichTextImageBlock();
1476 // Load the original image into a memory block.
1477 // If the image is not a JPEG, we must convert it into a JPEG
1478 // to conserve space.
1479 // If it's not a JPEG we can make use of 'image', already scaled, so we don't have to
1480 // load the image a 2nd time.
1481 virtual bool MakeImageBlock(const wxString
& filename
, int imageType
, wxImage
& image
, bool convertToJPEG
= true);
1483 // Make an image block from the wxImage in the given
1485 virtual bool MakeImageBlock(wxImage
& image
, int imageType
, int quality
= 80);
1488 bool Write(const wxString
& filename
);
1490 // Write data in hex to a stream
1491 bool WriteHex(wxOutputStream
& stream
);
1493 // Read data in hex from a stream
1494 bool ReadHex(wxInputStream
& stream
, int length
, int imageType
);
1496 // Copy from 'block'
1497 void Copy(const wxRichTextImageBlock
& block
);
1499 // Load a wxImage from the block
1500 bool Load(wxImage
& image
);
1503 void operator=(const wxRichTextImageBlock
& block
);
1507 unsigned char* GetData() const { return m_data
; }
1508 size_t GetDataSize() const { return m_dataSize
; }
1509 int GetImageType() const { return m_imageType
; }
1511 void SetData(unsigned char* image
) { m_data
= image
; }
1512 void SetDataSize(size_t size
) { m_dataSize
= size
; }
1513 void SetImageType(int imageType
) { m_imageType
= imageType
; }
1515 bool Ok() const { return IsOk(); }
1516 bool IsOk() const { return GetData() != NULL
; }
1518 // Gets the extension for the block's type
1519 wxString
GetExtension() const;
1523 // Allocate and read from stream as a block of memory
1524 static unsigned char* ReadBlock(wxInputStream
& stream
, size_t size
);
1525 static unsigned char* ReadBlock(const wxString
& filename
, size_t size
);
1527 // Write memory block to stream
1528 static bool WriteBlock(wxOutputStream
& stream
, unsigned char* block
, size_t size
);
1530 // Write memory block to file
1531 static bool WriteBlock(const wxString
& filename
, unsigned char* block
, size_t size
);
1534 // Size in bytes of the image stored.
1535 // This is in the raw, original form such as a JPEG file.
1536 unsigned char* m_data
;
1538 int m_imageType
; // wxWin type id
1543 * wxRichTextImage class declaration
1544 * This object represents an image.
1547 class WXDLLIMPEXP_RICHTEXT wxRichTextImage
: public wxRichTextObject
1549 DECLARE_DYNAMIC_CLASS(wxRichTextImage
)
1553 wxRichTextImage(wxRichTextObject
* parent
= NULL
): wxRichTextObject(parent
) { }
1554 wxRichTextImage(const wxImage
& image
, wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* charStyle
= NULL
);
1555 wxRichTextImage(const wxRichTextImageBlock
& imageBlock
, wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* charStyle
= NULL
);
1556 wxRichTextImage(const wxRichTextImage
& obj
): wxRichTextObject() { Copy(obj
); }
1561 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
1563 /// Lay the item out
1564 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
1566 /// Get the object size for the given range. Returns false if the range
1567 /// is invalid for this object.
1568 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const;
1570 /// Returns true if the object is empty
1571 virtual bool IsEmpty() const { return !m_image
.Ok(); }
1576 const wxImage
& GetImage() const { return m_image
; }
1579 void SetImage(const wxImage
& image
) { m_image
= image
; }
1581 /// Get the image block containing the raw data
1582 wxRichTextImageBlock
& GetImageBlock() { return m_imageBlock
; }
1587 void Copy(const wxRichTextImage
& obj
);
1590 virtual wxRichTextObject
* Clone() const { return new wxRichTextImage(*this); }
1592 /// Load wxImage from the block
1593 virtual bool LoadFromBlock();
1595 /// Make block from the wxImage
1596 virtual bool MakeBlock();
1599 // TODO: reduce the multiple representations of data
1602 wxRichTextImageBlock m_imageBlock
;
1607 * wxRichTextBuffer class declaration
1608 * This is a kind of box, used to represent the whole buffer
1611 class WXDLLIMPEXP_RICHTEXT wxRichTextCommand
;
1612 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
;
1614 class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer
: public wxRichTextParagraphLayoutBox
1616 DECLARE_DYNAMIC_CLASS(wxRichTextBuffer
)
1620 wxRichTextBuffer() { Init(); }
1621 wxRichTextBuffer(const wxRichTextBuffer
& obj
): wxRichTextParagraphLayoutBox() { Init(); Copy(obj
); }
1622 virtual ~wxRichTextBuffer() ;
1626 /// Gets the command processor
1627 wxCommandProcessor
* GetCommandProcessor() const { return m_commandProcessor
; }
1629 /// Set style sheet, if any.
1630 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
) { m_styleSheet
= styleSheet
; }
1631 virtual wxRichTextStyleSheet
* GetStyleSheet() const { return m_styleSheet
; }
1633 /// Set style sheet and notify of the change
1634 bool SetStyleSheetAndNotify(wxRichTextStyleSheet
* sheet
);
1636 /// Push style sheet to top of stack
1637 bool PushStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1639 /// Pop style sheet from top of stack
1640 wxRichTextStyleSheet
* PopStyleSheet();
1647 /// Clears the buffer, adds an empty paragraph, and clears the command processor.
1648 virtual void ResetAndClearCommands();
1651 virtual bool LoadFile(const wxString
& filename
, int type
= wxRICHTEXT_TYPE_ANY
);
1654 virtual bool SaveFile(const wxString
& filename
, int type
= wxRICHTEXT_TYPE_ANY
);
1656 /// Load from a stream
1657 virtual bool LoadFile(wxInputStream
& stream
, int type
= wxRICHTEXT_TYPE_ANY
);
1659 /// Save to a stream
1660 virtual bool SaveFile(wxOutputStream
& stream
, int type
= wxRICHTEXT_TYPE_ANY
);
1662 /// Set the handler flags, controlling loading and saving
1663 void SetHandlerFlags(int flags
) { m_handlerFlags
= flags
; }
1665 /// Get the handler flags, controlling loading and saving
1666 int GetHandlerFlags() const { return m_handlerFlags
; }
1668 /// Convenience function to add a paragraph of text
1669 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxTextAttrEx
* paraStyle
= NULL
) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text
, paraStyle
); }
1671 /// Begin collapsing undo/redo commands. Note that this may not work properly
1672 /// if combining commands that delete or insert content, changing ranges for
1673 /// subsequent actions.
1674 virtual bool BeginBatchUndo(const wxString
& cmdName
);
1676 /// End collapsing undo/redo commands
1677 virtual bool EndBatchUndo();
1679 /// Collapsing commands?
1680 virtual bool BatchingUndo() const { return m_batchedCommandDepth
> 0; }
1682 /// Submit immediately, or delay according to whether collapsing is on
1683 virtual bool SubmitAction(wxRichTextAction
* action
);
1685 /// Get collapsed command
1686 virtual wxRichTextCommand
* GetBatchedCommand() const { return m_batchedCommand
; }
1688 /// Begin suppressing undo/redo commands. The way undo is suppressed may be implemented
1689 /// differently by each command. If not dealt with by a command implementation, then
1690 /// it will be implemented automatically by not storing the command in the undo history
1691 /// when the action is submitted to the command processor.
1692 virtual bool BeginSuppressUndo();
1694 /// End suppressing undo/redo commands.
1695 virtual bool EndSuppressUndo();
1697 /// Collapsing commands?
1698 virtual bool SuppressingUndo() const { return m_suppressUndo
> 0; }
1700 /// Copy the range to the clipboard
1701 virtual bool CopyToClipboard(const wxRichTextRange
& range
);
1703 /// Paste the clipboard content to the buffer
1704 virtual bool PasteFromClipboard(long position
);
1706 /// Can we paste from the clipboard?
1707 virtual bool CanPasteFromClipboard() const;
1709 /// Begin using a style
1710 virtual bool BeginStyle(const wxTextAttrEx
& style
);
1713 virtual bool EndStyle();
1716 virtual bool EndAllStyles();
1718 /// Clear the style stack
1719 virtual void ClearStyleStack();
1721 /// Get the size of the style stack, for example to check correct nesting
1722 virtual size_t GetStyleStackSize() const { return m_attributeStack
.GetCount(); }
1724 /// Begin using bold
1728 bool EndBold() { return EndStyle(); }
1730 /// Begin using italic
1733 /// End using italic
1734 bool EndItalic() { return EndStyle(); }
1736 /// Begin using underline
1737 bool BeginUnderline();
1739 /// End using underline
1740 bool EndUnderline() { return EndStyle(); }
1742 /// Begin using point size
1743 bool BeginFontSize(int pointSize
);
1745 /// End using point size
1746 bool EndFontSize() { return EndStyle(); }
1748 /// Begin using this font
1749 bool BeginFont(const wxFont
& font
);
1751 /// End using a font
1752 bool EndFont() { return EndStyle(); }
1754 /// Begin using this colour
1755 bool BeginTextColour(const wxColour
& colour
);
1757 /// End using a colour
1758 bool EndTextColour() { return EndStyle(); }
1760 /// Begin using alignment
1761 bool BeginAlignment(wxTextAttrAlignment alignment
);
1764 bool EndAlignment() { return EndStyle(); }
1766 /// Begin left indent
1767 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
1770 bool EndLeftIndent() { return EndStyle(); }
1772 /// Begin right indent
1773 bool BeginRightIndent(int rightIndent
);
1775 /// End right indent
1776 bool EndRightIndent() { return EndStyle(); }
1778 /// Begin paragraph spacing
1779 bool BeginParagraphSpacing(int before
, int after
);
1781 /// End paragraph spacing
1782 bool EndParagraphSpacing() { return EndStyle(); }
1784 /// Begin line spacing
1785 bool BeginLineSpacing(int lineSpacing
);
1787 /// End line spacing
1788 bool EndLineSpacing() { return EndStyle(); }
1790 /// Begin numbered bullet
1791 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
1793 /// End numbered bullet
1794 bool EndNumberedBullet() { return EndStyle(); }
1796 /// Begin symbol bullet
1797 bool BeginSymbolBullet(const wxString
& symbol
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
1799 /// End symbol bullet
1800 bool EndSymbolBullet() { return EndStyle(); }
1802 /// Begin standard bullet
1803 bool BeginStandardBullet(const wxString
& bulletName
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_STANDARD
);
1805 /// End standard bullet
1806 bool EndStandardBullet() { return EndStyle(); }
1808 /// Begin named character style
1809 bool BeginCharacterStyle(const wxString
& characterStyle
);
1811 /// End named character style
1812 bool EndCharacterStyle() { return EndStyle(); }
1814 /// Begin named paragraph style
1815 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
1817 /// End named character style
1818 bool EndParagraphStyle() { return EndStyle(); }
1820 /// Begin named list style
1821 bool BeginListStyle(const wxString
& listStyle
, int level
= 1, int number
= 1);
1823 /// End named character style
1824 bool EndListStyle() { return EndStyle(); }
1827 bool BeginURL(const wxString
& url
, const wxString
& characterStyle
= wxEmptyString
);
1830 bool EndURL() { return EndStyle(); }
1834 /// Add an event handler
1835 bool AddEventHandler(wxEvtHandler
* handler
);
1837 /// Remove an event handler
1838 bool RemoveEventHandler(wxEvtHandler
* handler
, bool deleteHandler
= false);
1840 /// Clear event handlers
1841 void ClearEventHandlers();
1843 /// Send event to event handlers. If sendToAll is true, will send to all event handlers,
1844 /// otherwise will stop at the first successful one.
1845 bool SendEvent(wxEvent
& event
, bool sendToAll
= true);
1850 void Copy(const wxRichTextBuffer
& obj
);
1853 virtual wxRichTextObject
* Clone() const { return new wxRichTextBuffer(*this); }
1855 /// Submit command to insert paragraphs
1856 bool InsertParagraphsWithUndo(long pos
, const wxRichTextParagraphLayoutBox
& paragraphs
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1858 /// Submit command to insert the given text
1859 bool InsertTextWithUndo(long pos
, const wxString
& text
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1861 /// Submit command to insert a newline
1862 bool InsertNewlineWithUndo(long pos
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1864 /// Submit command to insert the given image
1865 bool InsertImageWithUndo(long pos
, const wxRichTextImageBlock
& imageBlock
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1867 /// Submit command to delete this range
1868 bool DeleteRangeWithUndo(const wxRichTextRange
& range
, wxRichTextCtrl
* ctrl
);
1871 void Modify(bool modify
= true) { m_modified
= modify
; }
1872 bool IsModified() const { return m_modified
; }
1874 /// Get the style that is appropriate for a new paragraph at this position.
1875 /// If the previous paragraph has a paragraph style name, look up the next-paragraph
1877 wxRichTextAttr
GetStyleForNewParagraph(long pos
, bool caretPosition
= false, bool lookUpNewParaStyle
=false) const;
1879 /// Dumps contents of buffer for debugging purposes
1880 virtual void Dump();
1881 virtual void Dump(wxTextOutputStream
& stream
) { wxRichTextParagraphLayoutBox::Dump(stream
); }
1883 /// Returns the file handlers
1884 static wxList
& GetHandlers() { return sm_handlers
; }
1886 /// Adds a handler to the end
1887 static void AddHandler(wxRichTextFileHandler
*handler
);
1889 /// Inserts a handler at the front
1890 static void InsertHandler(wxRichTextFileHandler
*handler
);
1892 /// Removes a handler
1893 static bool RemoveHandler(const wxString
& name
);
1895 /// Finds a handler by name
1896 static wxRichTextFileHandler
*FindHandler(const wxString
& name
);
1898 /// Finds a handler by extension and type
1899 static wxRichTextFileHandler
*FindHandler(const wxString
& extension
, int imageType
);
1901 /// Finds a handler by filename or, if supplied, type
1902 static wxRichTextFileHandler
*FindHandlerFilenameOrType(const wxString
& filename
, int imageType
);
1904 /// Finds a handler by type
1905 static wxRichTextFileHandler
*FindHandler(int imageType
);
1907 /// Gets a wildcard incorporating all visible handlers. If 'types' is present,
1908 /// will be filled with the file type corresponding to each filter. This can be
1909 /// used to determine the type to pass to LoadFile given a selected filter.
1910 static wxString
GetExtWildcard(bool combine
= false, bool save
= false, wxArrayInt
* types
= NULL
);
1912 /// Clean up handlers
1913 static void CleanUpHandlers();
1915 /// Initialise the standard handlers
1916 static void InitStandardHandlers();
1919 static wxRichTextRenderer
* GetRenderer() { return sm_renderer
; }
1921 /// Set renderer, deleting old one
1922 static void SetRenderer(wxRichTextRenderer
* renderer
);
1924 /// Minimum margin between bullet and paragraph in 10ths of a mm
1925 static int GetBulletRightMargin() { return sm_bulletRightMargin
; }
1926 static void SetBulletRightMargin(int margin
) { sm_bulletRightMargin
= margin
; }
1928 /// Factor to multiply by character height to get a reasonable bullet size
1929 static float GetBulletProportion() { return sm_bulletProportion
; }
1930 static void SetBulletProportion(float prop
) { sm_bulletProportion
= prop
; }
1932 /// Scale factor for calculating dimensions
1933 double GetScale() const { return m_scale
; }
1934 void SetScale(double scale
) { m_scale
= scale
; }
1938 /// Command processor
1939 wxCommandProcessor
* m_commandProcessor
;
1941 /// Has been modified?
1944 /// Collapsed command stack
1945 int m_batchedCommandDepth
;
1947 /// Name for collapsed command
1948 wxString m_batchedCommandsName
;
1950 /// Current collapsed command accumulating actions
1951 wxRichTextCommand
* m_batchedCommand
;
1953 /// Whether to suppress undo
1956 /// Style sheet, if any
1957 wxRichTextStyleSheet
* m_styleSheet
;
1959 /// List of event handlers that will be notified of events
1960 wxList m_eventHandlers
;
1962 /// Stack of attributes for convenience functions
1963 wxList m_attributeStack
;
1965 /// Flags to be passed to handlers
1969 static wxList sm_handlers
;
1972 static wxRichTextRenderer
* sm_renderer
;
1974 /// Minimum margin between bullet and paragraph in 10ths of a mm
1975 static int sm_bulletRightMargin
;
1977 /// Factor to multiply by character height to get a reasonable bullet size
1978 static float sm_bulletProportion
;
1980 /// Scaling factor in use: needed to calculate correct dimensions when printing
1985 * The command identifiers
1989 enum wxRichTextCommandId
1993 wxRICHTEXT_CHANGE_STYLE
1997 * Command classes for undo/redo
2001 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
;
2002 class WXDLLIMPEXP_RICHTEXT wxRichTextCommand
: public wxCommand
2005 // Ctor for one action
2006 wxRichTextCommand(const wxString
& name
, wxRichTextCommandId id
, wxRichTextBuffer
* buffer
,
2007 wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
2009 // Ctor for multiple actions
2010 wxRichTextCommand(const wxString
& name
);
2012 virtual ~wxRichTextCommand();
2017 void AddAction(wxRichTextAction
* action
);
2018 void ClearActions();
2020 wxList
& GetActions() { return m_actions
; }
2028 * wxRichTextAction class declaration
2029 * There can be more than one action in a command.
2032 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
: public wxObject
2035 wxRichTextAction(wxRichTextCommand
* cmd
, const wxString
& name
, wxRichTextCommandId id
, wxRichTextBuffer
* buffer
,
2036 wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
2038 virtual ~wxRichTextAction();
2043 /// Update the control appearance
2044 void UpdateAppearance(long caretPosition
, bool sendUpdateEvent
= false,
2045 wxArrayInt
* optimizationLineCharPositions
= NULL
, wxArrayInt
* optimizationLineYPositions
= NULL
);
2047 /// Replace the buffer paragraphs with the given fragment.
2048 void ApplyParagraphs(const wxRichTextParagraphLayoutBox
& fragment
);
2050 /// Get the fragments
2051 wxRichTextParagraphLayoutBox
& GetNewParagraphs() { return m_newParagraphs
; }
2052 wxRichTextParagraphLayoutBox
& GetOldParagraphs() { return m_oldParagraphs
; }
2054 /// Set/get the position used for e.g. insertion
2055 void SetPosition(long pos
) { m_position
= pos
; }
2056 long GetPosition() const { return m_position
; }
2058 /// Set/get the range for e.g. deletion
2059 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
2060 const wxRichTextRange
& GetRange() const { return m_range
; }
2063 const wxString
& GetName() const { return m_name
; }
2070 wxRichTextBuffer
* m_buffer
;
2073 wxRichTextCtrl
* m_ctrl
;
2075 // Stores the new paragraphs
2076 wxRichTextParagraphLayoutBox m_newParagraphs
;
2078 // Stores the old paragraphs
2079 wxRichTextParagraphLayoutBox m_oldParagraphs
;
2081 // The affected range
2082 wxRichTextRange m_range
;
2084 // The insertion point for this command
2087 // Ignore 1st 'Do' operation because we already did it
2090 // The command identifier
2091 wxRichTextCommandId m_cmdId
;
2098 // Include style sheet when loading and saving
2099 #define wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET 0x0001
2101 // Save images to memory file system in HTML handler
2102 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY 0x0010
2104 // Save images to files in HTML handler
2105 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES 0x0020
2107 // Save images as inline base64 data in HTML handler
2108 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040
2110 // Don't write header and footer (or BODY), so we can include the fragment
2111 // in a larger document
2112 #define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080
2115 * wxRichTextFileHandler
2116 * Base class for file handlers
2119 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler
: public wxObject
2121 DECLARE_CLASS(wxRichTextFileHandler
)
2123 wxRichTextFileHandler(const wxString
& name
= wxEmptyString
, const wxString
& ext
= wxEmptyString
, int type
= 0)
2124 : m_name(name
), m_extension(ext
), m_type(type
), m_flags(0), m_visible(true)
2128 bool LoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
)
2129 { return DoLoadFile(buffer
, stream
); }
2130 bool SaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
)
2131 { return DoSaveFile(buffer
, stream
); }
2134 bool LoadFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
2135 bool SaveFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
2137 /// Can we handle this filename (if using files)? By default, checks the extension.
2138 virtual bool CanHandle(const wxString
& filename
) const;
2140 /// Can we save using this handler?
2141 virtual bool CanSave() const { return false; }
2143 /// Can we load using this handler?
2144 virtual bool CanLoad() const { return false; }
2146 /// Should this handler be visible to the user?
2147 virtual bool IsVisible() const { return m_visible
; }
2148 virtual void SetVisible(bool visible
) { m_visible
= visible
; }
2150 /// The name of the nandler
2151 void SetName(const wxString
& name
) { m_name
= name
; }
2152 wxString
GetName() const { return m_name
; }
2154 /// The default extension to recognise
2155 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
2156 wxString
GetExtension() const { return m_extension
; }
2158 /// The handler type
2159 void SetType(int type
) { m_type
= type
; }
2160 int GetType() const { return m_type
; }
2162 /// Flags controlling how loading and saving is done
2163 void SetFlags(int flags
) { m_flags
= flags
; }
2164 int GetFlags() const { return m_flags
; }
2166 /// Encoding to use when saving a file. If empty, a suitable encoding is chosen
2167 void SetEncoding(const wxString
& encoding
) { m_encoding
= encoding
; }
2168 const wxString
& GetEncoding() const { return m_encoding
; }
2173 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
) = 0;
2174 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
) = 0;
2178 wxString m_encoding
;
2179 wxString m_extension
;
2186 * wxRichTextPlainTextHandler
2187 * Plain text handler
2190 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler
: public wxRichTextFileHandler
2192 DECLARE_CLASS(wxRichTextPlainTextHandler
)
2194 wxRichTextPlainTextHandler(const wxString
& name
= wxT("Text"), const wxString
& ext
= wxT("txt"), int type
= wxRICHTEXT_TYPE_TEXT
)
2195 : wxRichTextFileHandler(name
, ext
, type
)
2198 /// Can we save using this handler?
2199 virtual bool CanSave() const { return true; }
2201 /// Can we load using this handler?
2202 virtual bool CanLoad() const { return true; }
2207 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
2208 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
2216 * The data object for a wxRichTextBuffer
2219 class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject
: public wxDataObjectSimple
2222 // ctor doesn't copy the pointer, so it shouldn't go away while this object
2224 wxRichTextBufferDataObject(wxRichTextBuffer
* richTextBuffer
= (wxRichTextBuffer
*) NULL
);
2225 virtual ~wxRichTextBufferDataObject();
2227 // after a call to this function, the buffer is owned by the caller and it
2228 // is responsible for deleting it
2229 wxRichTextBuffer
* GetRichTextBuffer();
2231 // Returns the id for the new data format
2232 static const wxChar
* GetRichTextBufferFormatId() { return ms_richTextBufferFormatId
; }
2234 // base class pure virtuals
2236 virtual wxDataFormat
GetPreferredFormat(Direction dir
) const;
2237 virtual size_t GetDataSize() const;
2238 virtual bool GetDataHere(void *pBuf
) const;
2239 virtual bool SetData(size_t len
, const void *buf
);
2243 virtual size_t GetDataSize(const wxDataFormat
&) const { return GetDataSize(); }
2244 virtual bool GetDataHere(const wxDataFormat
&, void *buf
) const { return GetDataHere(buf
); }
2245 virtual bool SetData(const wxDataFormat
&, size_t len
, const void *buf
) { return SetData(len
, buf
); }
2248 wxDataFormat m_formatRichTextBuffer
; // our custom format
2249 wxRichTextBuffer
* m_richTextBuffer
; // our data
2250 static const wxChar
* ms_richTextBufferFormatId
; // our format id
2256 * wxRichTextRenderer isolates common drawing functionality
2259 class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer
: public wxObject
2262 wxRichTextRenderer() {}
2263 virtual ~wxRichTextRenderer() {}
2265 /// Draw a standard bullet, as specified by the value of GetBulletName
2266 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
) = 0;
2268 /// Draw a bullet that can be described by text, such as numbered or symbol bullets
2269 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
, const wxString
& text
) = 0;
2271 /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
2272 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
) = 0;
2274 /// Enumerate the standard bullet names currently supported
2275 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
) = 0;
2279 * wxRichTextStdRenderer: standard renderer
2282 class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer
: public wxRichTextRenderer
2285 wxRichTextStdRenderer() {}
2287 /// Draw a standard bullet, as specified by the value of GetBulletName
2288 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
);
2290 /// Draw a bullet that can be described by text, such as numbered or symbol bullets
2291 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
, const wxString
& text
);
2293 /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
2294 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
);
2296 /// Enumerate the standard bullet names currently supported
2297 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
);
2305 inline bool wxRichTextHasStyle(int flags
, int style
)
2307 return ((flags
& style
) == style
);
2310 /// Compare two attribute objects
2311 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxTextAttrEx
& attr1
, const wxTextAttrEx
& attr2
);
2312 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxTextAttr
& attr1
, const wxRichTextAttr
& attr2
);
2314 /// Compare two attribute objects, but take into account the flags
2315 /// specifying attributes of interest.
2316 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEqPartial(const wxTextAttrEx
& attr1
, const wxTextAttrEx
& attr2
, int flags
);
2317 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEqPartial(const wxTextAttrEx
& attr1
, const wxRichTextAttr
& attr2
, int flags
);
2319 /// Apply one style to another
2320 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxTextAttrEx
& destStyle
, const wxTextAttrEx
& style
);
2321 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxRichTextAttr
& destStyle
, const wxTextAttrEx
& style
);
2322 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxTextAttrEx
& destStyle
, const wxRichTextAttr
& style
, wxRichTextAttr
* compareWith
= NULL
);
2323 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxRichTextAttr
& destStyle
, const wxRichTextAttr
& style
, wxRichTextAttr
* compareWith
= NULL
);
2325 // Remove attributes
2326 WXDLLIMPEXP_RICHTEXT
bool wxRichTextRemoveStyle(wxTextAttrEx
& destStyle
, const wxRichTextAttr
& style
);
2328 /// Combine two bitlists
2329 WXDLLIMPEXP_RICHTEXT
bool wxRichTextCombineBitlists(int& valueA
, int valueB
, int& flagsA
, int flagsB
);
2331 /// Compare two bitlists
2332 WXDLLIMPEXP_RICHTEXT
bool wxRichTextBitlistsEqPartial(int valueA
, int valueB
, int flags
);
2334 /// Split into paragraph and character styles
2335 WXDLLIMPEXP_RICHTEXT
bool wxRichTextSplitParaCharStyles(const wxTextAttrEx
& style
, wxTextAttrEx
& parStyle
, wxTextAttrEx
& charStyle
);
2338 WXDLLIMPEXP_RICHTEXT
bool wxRichTextTabsEq(const wxArrayInt
& tabs1
, const wxArrayInt
& tabs2
);
2340 /// Set the font without changing the font attributes
2341 WXDLLIMPEXP_RICHTEXT
void wxSetFontPreservingStyles(wxTextAttr
& attr
, const wxFont
& font
);
2343 /// Convert a decimal to Roman numerals
2344 WXDLLIMPEXP_RICHTEXT wxString
wxRichTextDecimalToRoman(long n
);
2346 WXDLLIMPEXP_RICHTEXT
void wxRichTextModuleInit();
2352 // _WX_RICHTEXTBUFFER_H_