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"
73 // Experimental dynamic styles to avoid user-specific character styles from being
74 // overwritten by paragraph styles.
75 #define wxRICHTEXT_USE_DYNAMIC_STYLES 1
81 #define wxRICHTEXT_TYPE_ANY 0
82 #define wxRICHTEXT_TYPE_TEXT 1
83 #define wxRICHTEXT_TYPE_XML 2
84 #define wxRICHTEXT_TYPE_HTML 3
85 #define wxRICHTEXT_TYPE_RTF 4
86 #define wxRICHTEXT_TYPE_PDF 5
89 * Forward declarations
92 class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl
;
93 class WXDLLIMPEXP_RICHTEXT wxRichTextObject
;
94 class WXDLLIMPEXP_RICHTEXT wxRichTextCacheObject
;
95 class WXDLLIMPEXP_RICHTEXT wxRichTextObjectList
;
96 class WXDLLIMPEXP_RICHTEXT wxRichTextLine
;
97 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph
;
98 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler
;
99 class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet
;
100 class WXDLLIMPEXP_RICHTEXT wxTextAttrEx
;
101 class WXDLLIMPEXP_RICHTEXT wxRichTextListStyleDefinition
;
102 class WXDLLIMPEXP_RICHTEXT wxRichTextEvent
;
103 class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer
;
104 class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer
;
107 * Flags determining the available space, passed to Layout
110 #define wxRICHTEXT_FIXED_WIDTH 0x01
111 #define wxRICHTEXT_FIXED_HEIGHT 0x02
112 #define wxRICHTEXT_VARIABLE_WIDTH 0x04
113 #define wxRICHTEXT_VARIABLE_HEIGHT 0x08
115 // Only lay out the part of the buffer that lies within
116 // the rect passed to Layout.
117 #define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10
120 * Flags to pass to Draw
123 // Ignore paragraph cache optimization, e.g. for printing purposes
124 // where one line may be drawn higher (on the next page) compared
125 // with the previous line
126 #define wxRICHTEXT_DRAW_IGNORE_CACHE 0x01
129 * Flags returned from hit-testing
132 // The point was not on this object
133 #define wxRICHTEXT_HITTEST_NONE 0x01
134 // The point was before the position returned from HitTest
135 #define wxRICHTEXT_HITTEST_BEFORE 0x02
136 // The point was after the position returned from HitTest
137 #define wxRICHTEXT_HITTEST_AFTER 0x04
138 // The point was on the position returned from HitTest
139 #define wxRICHTEXT_HITTEST_ON 0x08
142 * Flags for GetRangeSize
145 #define wxRICHTEXT_FORMATTED 0x01
146 #define wxRICHTEXT_UNFORMATTED 0x02
149 * Flags for SetStyle/SetListStyle
152 #define wxRICHTEXT_SETSTYLE_NONE 0x00
154 // Specifies that this operation should be undoable
155 #define wxRICHTEXT_SETSTYLE_WITH_UNDO 0x01
157 // Specifies that the style should not be applied if the
158 // combined style at this point is already the style in question.
159 #define wxRICHTEXT_SETSTYLE_OPTIMIZE 0x02
161 // Specifies that the style should only be applied to paragraphs,
162 // and not the content. This allows content styling to be
163 // preserved independently from that of e.g. a named paragraph style.
164 #define wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY 0x04
166 // Specifies that the style should only be applied to characters,
167 // and not the paragraph. This allows content styling to be
168 // preserved independently from that of e.g. a named paragraph style.
169 #define wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY 0x08
171 // For SetListStyle only: specifies starting from the given number, otherwise
172 // deduces number from existing attributes
173 #define wxRICHTEXT_SETSTYLE_RENUMBER 0x10
175 // For SetListStyle only: specifies the list level for all paragraphs, otherwise
176 // the current indentation will be used
177 #define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL 0x20
180 * Flags for text insertion
183 #define wxRICHTEXT_INSERT_NONE 0x00
184 #define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE 0x01
187 * Extra formatting flags not in wxTextAttr
190 #define wxTEXT_ATTR_PARA_SPACING_AFTER 0x00000800
191 #define wxTEXT_ATTR_PARA_SPACING_BEFORE 0x00001000
192 #define wxTEXT_ATTR_LINE_SPACING 0x00002000
193 #define wxTEXT_ATTR_CHARACTER_STYLE_NAME 0x00004000
194 #define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME 0x00008000
195 #define wxTEXT_ATTR_LIST_STYLE_NAME 0x00010000
196 #define wxTEXT_ATTR_BULLET_STYLE 0x00020000
197 #define wxTEXT_ATTR_BULLET_NUMBER 0x00040000
198 #define wxTEXT_ATTR_BULLET_TEXT 0x00080000
199 #define wxTEXT_ATTR_BULLET_NAME 0x00100000
200 #define wxTEXT_ATTR_URL 0x00200000
201 #define wxTEXT_ATTR_PAGE_BREAK 0x00400000
202 #define wxTEXT_ATTR_EFFECTS 0x00800000
205 * Styles for wxTextAttrEx::SetBulletStyle
208 #define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000
209 #define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001
210 #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002
211 #define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004
212 #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008
213 #define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010
214 #define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020
215 #define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040
216 #define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080
217 #define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100
218 #define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200
219 #define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400
220 #define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800
222 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000
223 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000
224 #define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000
227 * Styles for wxTextAttrEx::SetTextEffects
230 #define wxTEXT_ATTR_EFFECT_NONE 0x00000000
231 #define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001
232 #define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002
233 #define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004
234 #define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008
235 #define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010
236 #define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020
237 #define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040
238 #define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080
239 #define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100
240 #define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200
243 * Line spacing values
246 #define wxTEXT_ATTR_LINE_SPACING_NORMAL 10
247 #define wxTEXT_ATTR_LINE_SPACING_HALF 15
248 #define wxTEXT_ATTR_LINE_SPACING_TWICE 20
251 * Character and paragraph combined styles
254 #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)
256 #define wxTEXT_ATTR_PARAGRAPH (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\
257 wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\
258 wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME|\
259 wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME)
261 #define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
264 * wxRichTextRange class declaration
265 * This stores beginning and end positions for a range of data.
268 class WXDLLIMPEXP_RICHTEXT wxRichTextRange
273 wxRichTextRange() { m_start
= 0; m_end
= 0; }
274 wxRichTextRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
275 wxRichTextRange(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
276 ~wxRichTextRange() {}
278 void operator =(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
279 bool operator ==(const wxRichTextRange
& range
) const { return (m_start
== range
.m_start
&& m_end
== range
.m_end
); }
280 bool operator !=(const wxRichTextRange
& range
) const { return (m_start
!= range
.m_start
&& m_end
!= range
.m_end
); }
281 wxRichTextRange
operator -(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
- range
.m_start
, m_end
- range
.m_end
); }
282 wxRichTextRange
operator +(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
+ range
.m_start
, m_end
+ range
.m_end
); }
284 void SetRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
286 void SetStart(long start
) { m_start
= start
; }
287 long GetStart() const { return m_start
; }
289 void SetEnd(long end
) { m_end
= end
; }
290 long GetEnd() const { return m_end
; }
292 /// Returns true if this range is completely outside 'range'
293 bool IsOutside(const wxRichTextRange
& range
) const { return range
.m_start
> m_end
|| range
.m_end
< m_start
; }
295 /// Returns true if this range is completely within 'range'
296 bool IsWithin(const wxRichTextRange
& range
) const { return m_start
>= range
.m_start
&& m_end
<= range
.m_end
; }
298 /// Returns true if the given position is within this range. Allow
299 /// for the possibility of an empty range - assume the position
300 /// is within this empty range. NO, I think we should not match with an empty range.
301 // bool Contains(long pos) const { return pos >= m_start && (pos <= m_end || GetLength() == 0); }
302 bool Contains(long pos
) const { return pos
>= m_start
&& pos
<= m_end
; }
304 /// Limit this range to be within 'range'
305 bool LimitTo(const wxRichTextRange
& range
) ;
307 /// Gets the length of the range
308 long GetLength() const { return m_end
- m_start
+ 1; }
310 /// Swaps the start and end
311 void Swap() { long tmp
= m_start
; m_start
= m_end
; m_end
= tmp
; }
313 /// Convert to internal form: (n, n) is the range of a single character.
314 wxRichTextRange
ToInternal() const { return wxRichTextRange(m_start
, m_end
-1); }
316 /// Convert from internal to public API form: (n, n+1) is the range of a single character.
317 wxRichTextRange
FromInternal() const { return wxRichTextRange(m_start
, m_end
+1); }
324 #define wxRICHTEXT_ALL wxRichTextRange(-2, -2)
325 #define wxRICHTEXT_NONE wxRichTextRange(-1, -1)
328 * wxTextAttrEx is an extended version of wxTextAttr with more paragraph attributes.
331 class WXDLLIMPEXP_RICHTEXT wxTextAttrEx
: public wxTextAttr
335 wxTextAttrEx(const wxTextAttrEx
& attr
);
336 wxTextAttrEx(const wxTextAttr
& attr
) { Init(); (*this) = attr
; }
337 wxTextAttrEx() { Init(); }
339 // Initialise this object
343 void Copy(const wxTextAttrEx
& attr
);
345 // Assignment from a wxTextAttrEx object
346 void operator= (const wxTextAttrEx
& attr
);
348 // Assignment from a wxTextAttr object
349 void operator= (const wxTextAttr
& attr
);
352 bool operator== (const wxTextAttrEx
& attr
) const;
355 void SetCharacterStyleName(const wxString
& name
) { m_characterStyleName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_CHARACTER_STYLE_NAME
); }
356 void SetParagraphStyleName(const wxString
& name
) { m_paragraphStyleName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_PARAGRAPH_STYLE_NAME
); }
357 void SetListStyleName(const wxString
& name
) { m_listStyleName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_STYLE_NAME
); }
358 void SetParagraphSpacingAfter(int spacing
) { m_paragraphSpacingAfter
= spacing
; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_AFTER
); }
359 void SetParagraphSpacingBefore(int spacing
) { m_paragraphSpacingBefore
= spacing
; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_BEFORE
); }
360 void SetLineSpacing(int spacing
) { m_lineSpacing
= spacing
; SetFlags(GetFlags() | wxTEXT_ATTR_LINE_SPACING
); }
361 void SetBulletStyle(int style
) { m_bulletStyle
= style
; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_STYLE
); }
362 void SetBulletNumber(int n
) { m_bulletNumber
= n
; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NUMBER
); }
363 void SetBulletText(const wxString
& text
) { m_bulletText
= text
; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_TEXT
); }
364 void SetBulletName(const wxString
& name
) { m_bulletName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NAME
); }
365 void SetBulletFont(const wxString
& bulletFont
) { m_bulletFont
= bulletFont
; }
366 void SetURL(const wxString
& url
) { m_urlTarget
= url
; SetFlags(GetFlags() | wxTEXT_ATTR_URL
); }
367 void SetPageBreak(bool pageBreak
= true) { SetFlags(pageBreak
? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK
) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK
)); }
368 void SetTextEffects(int effects
) { m_textEffects
= effects
; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS
); }
369 void SetTextEffectFlags(int effects
) { m_textEffectFlags
= effects
; }
371 const wxString
& GetCharacterStyleName() const { return m_characterStyleName
; }
372 const wxString
& GetParagraphStyleName() const { return m_paragraphStyleName
; }
373 const wxString
& GetListStyleName() const { return m_listStyleName
; }
374 int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter
; }
375 int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore
; }
376 int GetLineSpacing() const { return m_lineSpacing
; }
377 int GetBulletStyle() const { return m_bulletStyle
; }
378 int GetBulletNumber() const { return m_bulletNumber
; }
379 const wxString
& GetBulletText() const { return m_bulletText
; }
380 const wxString
& GetBulletName() const { return m_bulletName
; }
381 const wxString
& GetBulletFont() const { return m_bulletFont
; }
382 const wxString
& GetURL() const { return m_urlTarget
; }
383 int GetTextEffects() const { return m_textEffects
; }
384 int GetTextEffectFlags() const { return m_textEffectFlags
; }
386 bool HasWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT
) != 0; }
387 bool HasSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE
) != 0; }
388 bool HasItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC
) != 0; }
389 bool HasUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE
) != 0; }
390 bool HasFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE
) != 0; }
392 bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER
); }
393 bool HasParagraphSpacingBefore() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE
); }
394 bool HasLineSpacing() const { return HasFlag(wxTEXT_ATTR_LINE_SPACING
); }
395 bool HasCharacterStyleName() const { return HasFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME
) || !m_characterStyleName
.IsEmpty(); }
396 bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME
) || !m_paragraphStyleName
.IsEmpty(); }
397 bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME
) || !m_listStyleName
.IsEmpty(); }
398 bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE
); }
399 bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER
); }
400 bool HasBulletText() const { return HasFlag(wxTEXT_ATTR_BULLET_TEXT
); }
401 bool HasBulletName() const { return HasFlag(wxTEXT_ATTR_BULLET_NAME
); }
402 bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL
); }
403 bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK
); }
404 bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS
); }
405 bool HasTextEffect(int effect
) const { return HasFlag(wxTEXT_ATTR_EFFECTS
) && ((GetTextEffectFlags() & effect
) != 0); }
407 // Is this a character style?
408 bool IsCharacterStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_CHARACTER
)); }
409 bool IsParagraphStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_PARAGRAPH
)); }
411 // returns false if we have any attributes set, true otherwise
412 bool IsDefault() const
414 return (GetFlags() == 0);
417 // return the attribute having the valid font and colours: it uses the
418 // attributes set in attr and falls back first to attrDefault and then to
419 // the text control font/colours for those attributes which are not set
420 static wxTextAttrEx
CombineEx(const wxTextAttrEx
& attr
,
421 const wxTextAttrEx
& attrDef
,
422 const wxTextCtrlBase
*text
);
426 int m_paragraphSpacingAfter
;
427 int m_paragraphSpacingBefore
;
432 int m_textEffectFlags
;
433 wxString m_bulletText
;
434 wxString m_bulletFont
;
435 wxString m_bulletName
;
436 wxString m_urlTarget
;
439 wxString m_characterStyleName
;
442 wxString m_paragraphStyleName
;
445 wxString m_listStyleName
;
449 * wxRichTextAttr stores attributes without a wxFont object, so is a much more
450 * efficient way to query styles.
453 class WXDLLIMPEXP_RICHTEXT wxRichTextAttr
457 wxRichTextAttr(const wxTextAttrEx
& attr
);
458 wxRichTextAttr(const wxRichTextAttr
& attr
);
459 wxRichTextAttr() { Init(); }
460 wxRichTextAttr(const wxColour
& colText
,
461 const wxColour
& colBack
= wxNullColour
,
462 wxTextAttrAlignment alignment
= wxTEXT_ALIGNMENT_DEFAULT
);
464 // Initialise this object.
468 void Copy(const wxRichTextAttr
& attr
);
470 // Assignment from a wxRichTextAttr object.
471 void operator= (const wxRichTextAttr
& attr
);
473 // Assignment from a wxTextAttrEx object.
474 void operator= (const wxTextAttrEx
& attr
);
477 bool operator== (const wxRichTextAttr
& attr
) const;
479 // Making a wxTextAttrEx object.
480 operator wxTextAttrEx () const ;
482 // Copy to a wxTextAttr
483 void CopyTo(wxTextAttrEx
& attr
) const;
485 // Create font from font attributes.
486 wxFont
CreateFont() const;
488 // Get attributes from font.
489 bool GetFontAttributes(const wxFont
& font
);
492 void SetTextColour(const wxColour
& colText
) { m_colText
= colText
; m_flags
|= wxTEXT_ATTR_TEXT_COLOUR
; }
493 void SetBackgroundColour(const wxColour
& colBack
) { m_colBack
= colBack
; m_flags
|= wxTEXT_ATTR_BACKGROUND_COLOUR
; }
494 void SetAlignment(wxTextAttrAlignment alignment
) { m_textAlignment
= alignment
; m_flags
|= wxTEXT_ATTR_ALIGNMENT
; }
495 void SetTabs(const wxArrayInt
& tabs
) { m_tabs
= tabs
; m_flags
|= wxTEXT_ATTR_TABS
; }
496 void SetLeftIndent(int indent
, int subIndent
= 0) { m_leftIndent
= indent
; m_leftSubIndent
= subIndent
; m_flags
|= wxTEXT_ATTR_LEFT_INDENT
; }
497 void SetRightIndent(int indent
) { m_rightIndent
= indent
; m_flags
|= wxTEXT_ATTR_RIGHT_INDENT
; }
499 void SetFontSize(int pointSize
) { m_fontSize
= pointSize
; m_flags
|= wxTEXT_ATTR_FONT_SIZE
; }
500 void SetFontStyle(int fontStyle
) { m_fontStyle
= fontStyle
; m_flags
|= wxTEXT_ATTR_FONT_ITALIC
; }
501 void SetFontWeight(int fontWeight
) { m_fontWeight
= fontWeight
; m_flags
|= wxTEXT_ATTR_FONT_WEIGHT
; }
502 void SetFontFaceName(const wxString
& faceName
) { m_fontFaceName
= faceName
; m_flags
|= wxTEXT_ATTR_FONT_FACE
; }
503 void SetFontUnderlined(bool underlined
) { m_fontUnderlined
= underlined
; m_flags
|= wxTEXT_ATTR_FONT_UNDERLINE
; }
505 void SetFlags(long flags
) { m_flags
= flags
; }
507 void SetCharacterStyleName(const wxString
& name
) { m_characterStyleName
= name
; m_flags
|= wxTEXT_ATTR_CHARACTER_STYLE_NAME
; }
508 void SetParagraphStyleName(const wxString
& name
) { m_paragraphStyleName
= name
; m_flags
|= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME
; }
509 void SetListStyleName(const wxString
& name
) { m_listStyleName
= name
; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_STYLE_NAME
); }
510 void SetParagraphSpacingAfter(int spacing
) { m_paragraphSpacingAfter
= spacing
; m_flags
|= wxTEXT_ATTR_PARA_SPACING_AFTER
; }
511 void SetParagraphSpacingBefore(int spacing
) { m_paragraphSpacingBefore
= spacing
; m_flags
|= wxTEXT_ATTR_PARA_SPACING_BEFORE
; }
512 void SetLineSpacing(int spacing
) { m_lineSpacing
= spacing
; m_flags
|= wxTEXT_ATTR_LINE_SPACING
; }
513 void SetBulletStyle(int style
) { m_bulletStyle
= style
; m_flags
|= wxTEXT_ATTR_BULLET_STYLE
; }
514 void SetBulletNumber(int n
) { m_bulletNumber
= n
; m_flags
|= wxTEXT_ATTR_BULLET_NUMBER
; }
515 void SetBulletText(const wxString
& text
) { m_bulletText
= text
; m_flags
|= wxTEXT_ATTR_BULLET_TEXT
; }
516 void SetBulletFont(const wxString
& bulletFont
) { m_bulletFont
= bulletFont
; }
517 void SetBulletName(const wxString
& name
) { m_bulletName
= name
; m_flags
|= wxTEXT_ATTR_BULLET_NAME
; }
518 void SetURL(const wxString
& url
) { m_urlTarget
= url
; m_flags
|= wxTEXT_ATTR_URL
; }
519 void SetPageBreak(bool pageBreak
= true) { SetFlags(pageBreak
? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK
) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK
)); }
520 void SetTextEffects(int effects
) { m_textEffects
= effects
; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS
); }
521 void SetTextEffectFlags(int effects
) { m_textEffectFlags
= effects
; }
523 const wxColour
& GetTextColour() const { return m_colText
; }
524 const wxColour
& GetBackgroundColour() const { return m_colBack
; }
525 wxTextAttrAlignment
GetAlignment() const { return m_textAlignment
; }
526 const wxArrayInt
& GetTabs() const { return m_tabs
; }
527 long GetLeftIndent() const { return m_leftIndent
; }
528 long GetLeftSubIndent() const { return m_leftSubIndent
; }
529 long GetRightIndent() const { return m_rightIndent
; }
530 long GetFlags() const { return m_flags
; }
532 int GetFontSize() const { return m_fontSize
; }
533 int GetFontStyle() const { return m_fontStyle
; }
534 int GetFontWeight() const { return m_fontWeight
; }
535 bool GetFontUnderlined() const { return m_fontUnderlined
; }
536 const wxString
& GetFontFaceName() const { return m_fontFaceName
; }
538 const wxString
& GetCharacterStyleName() const { return m_characterStyleName
; }
539 const wxString
& GetParagraphStyleName() const { return m_paragraphStyleName
; }
540 const wxString
& GetListStyleName() const { return m_listStyleName
; }
541 int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter
; }
542 int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore
; }
543 int GetLineSpacing() const { return m_lineSpacing
; }
544 int GetBulletStyle() const { return m_bulletStyle
; }
545 int GetBulletNumber() const { return m_bulletNumber
; }
546 const wxString
& GetBulletText() const { return m_bulletText
; }
547 const wxString
& GetBulletFont() const { return m_bulletFont
; }
548 const wxString
& GetBulletName() const { return m_bulletName
; }
549 const wxString
& GetURL() const { return m_urlTarget
; }
550 int GetTextEffects() const { return m_textEffects
; }
551 int GetTextEffectFlags() const { return m_textEffectFlags
; }
554 bool HasTextColour() const { return m_colText
.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR
) ; }
555 bool HasBackgroundColour() const { return m_colBack
.Ok() && HasFlag(wxTEXT_ATTR_BACKGROUND_COLOUR
) ; }
556 bool HasAlignment() const { return (m_textAlignment
!= wxTEXT_ALIGNMENT_DEFAULT
) || ((m_flags
& wxTEXT_ATTR_ALIGNMENT
) != 0) ; }
557 bool HasTabs() const { return (m_flags
& wxTEXT_ATTR_TABS
) != 0 ; }
558 bool HasLeftIndent() const { return (m_flags
& wxTEXT_ATTR_LEFT_INDENT
) != 0 ; }
559 bool HasRightIndent() const { return (m_flags
& wxTEXT_ATTR_RIGHT_INDENT
) != 0 ; }
560 bool HasWeight() const { return (m_flags
& wxTEXT_ATTR_FONT_WEIGHT
) != 0; }
561 bool HasSize() const { return (m_flags
& wxTEXT_ATTR_FONT_SIZE
) != 0; }
562 bool HasItalic() const { return (m_flags
& wxTEXT_ATTR_FONT_ITALIC
) != 0; }
563 bool HasUnderlined() const { return (m_flags
& wxTEXT_ATTR_FONT_UNDERLINE
) != 0; }
564 bool HasFaceName() const { return (m_flags
& wxTEXT_ATTR_FONT_FACE
) != 0; }
565 bool HasFont() const { return (m_flags
& (wxTEXT_ATTR_FONT
)) != 0; }
567 bool HasParagraphSpacingAfter() const { return (m_flags
& wxTEXT_ATTR_PARA_SPACING_AFTER
) != 0; }
568 bool HasParagraphSpacingBefore() const { return (m_flags
& wxTEXT_ATTR_PARA_SPACING_BEFORE
) != 0; }
569 bool HasLineSpacing() const { return (m_flags
& wxTEXT_ATTR_LINE_SPACING
) != 0; }
570 bool HasCharacterStyleName() const { return (m_flags
& wxTEXT_ATTR_CHARACTER_STYLE_NAME
) != 0 || !m_characterStyleName
.IsEmpty(); }
571 bool HasParagraphStyleName() const { return (m_flags
& wxTEXT_ATTR_PARAGRAPH_STYLE_NAME
) != 0 || !m_paragraphStyleName
.IsEmpty(); }
572 bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME
) || !m_listStyleName
.IsEmpty(); }
573 bool HasBulletStyle() const { return (m_flags
& wxTEXT_ATTR_BULLET_STYLE
) != 0; }
574 bool HasBulletNumber() const { return (m_flags
& wxTEXT_ATTR_BULLET_NUMBER
) != 0; }
575 bool HasBulletText() const { return (m_flags
& wxTEXT_ATTR_BULLET_TEXT
) != 0; }
576 bool HasBulletName() const { return (m_flags
& wxTEXT_ATTR_BULLET_NAME
) != 0; }
577 bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL
); }
578 bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK
); }
579 bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS
); }
580 bool HasTextEffect(int effect
) const { return HasFlag(wxTEXT_ATTR_EFFECTS
) && ((GetTextEffectFlags() & effect
) != 0); }
582 bool HasFlag(long flag
) const { return (m_flags
& flag
) != 0; }
584 // Is this a character style?
585 bool IsCharacterStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_CHARACTER
)); }
586 bool IsParagraphStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_PARAGRAPH
)); }
588 // returns false if we have any attributes set, true otherwise
589 bool IsDefault() const
591 return GetFlags() == 0;
594 // return the attribute having the valid font and colours: it uses the
595 // attributes set in attr and falls back first to attrDefault and then to
596 // the text control font/colours for those attributes which are not set
597 static wxRichTextAttr
Combine(const wxRichTextAttr
& attr
,
598 const wxRichTextAttr
& attrDef
,
599 const wxTextCtrlBase
*text
);
604 wxArrayInt m_tabs
; // array of int: tab stops in 1/10 mm
605 int m_leftIndent
; // left indent in 1/10 mm
606 int m_leftSubIndent
; // left indent for all but the first
607 // line in a paragraph relative to the
608 // first line, in 1/10 mm
609 int m_rightIndent
; // right indent in 1/10 mm
610 wxTextAttrAlignment m_textAlignment
;
612 int m_paragraphSpacingAfter
;
613 int m_paragraphSpacingBefore
;
618 int m_textEffectFlags
;
619 wxString m_bulletText
;
620 wxString m_bulletFont
;
621 wxString m_bulletName
;
622 wxString m_urlTarget
;
630 bool m_fontUnderlined
;
631 wxString m_fontFaceName
;
634 wxString m_characterStyleName
;
637 wxString m_paragraphStyleName
;
640 wxString m_listStyleName
;
644 * wxRichTextObject class declaration
645 * This is the base for drawable objects.
648 class WXDLLIMPEXP_RICHTEXT wxRichTextObject
: public wxObject
650 DECLARE_CLASS(wxRichTextObject
)
654 wxRichTextObject(wxRichTextObject
* parent
= NULL
);
655 virtual ~wxRichTextObject();
659 /// Draw the item, within the given range. Some objects may ignore the range (for
660 /// example paragraphs) while others must obey it (lines, to implement wrapping)
661 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
) = 0;
663 /// Lay the item out at the specified position with the given size constraint.
664 /// Layout must set the cached size.
665 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
) = 0;
667 /// Hit-testing: returns a flag indicating hit test details, plus
668 /// information about position
669 virtual int HitTest(wxDC
& WXUNUSED(dc
), const wxPoint
& WXUNUSED(pt
), long& WXUNUSED(textPosition
)) { return false; }
671 /// Finds the absolute position and row height for the given character position
672 virtual bool FindPosition(wxDC
& WXUNUSED(dc
), long WXUNUSED(index
), wxPoint
& WXUNUSED(pt
), int* WXUNUSED(height
), bool WXUNUSED(forceLineStart
)) { return false; }
674 /// Get the best size, i.e. the ideal starting size for this object irrespective
675 /// of available space. For a short text string, it will be the size that exactly encloses
676 /// the text. For a longer string, it might use the parent width for example.
677 virtual wxSize
GetBestSize() const { return m_size
; }
679 /// Get the object size for the given range. Returns false if the range
680 /// is invalid for this object.
681 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const = 0;
683 /// Do a split, returning an object containing the second part, and setting
684 /// the first part in 'this'.
685 virtual wxRichTextObject
* DoSplit(long WXUNUSED(pos
)) { return NULL
; }
687 /// Calculate range. By default, guess that the object is 1 unit long.
688 virtual void CalculateRange(long start
, long& end
) { end
= start
; m_range
.SetRange(start
, end
); }
691 virtual bool DeleteRange(const wxRichTextRange
& WXUNUSED(range
)) { return false; }
693 /// Returns true if the object is empty
694 virtual bool IsEmpty() const { return false; }
696 /// Get any text in this object for the given range
697 virtual wxString
GetTextForRange(const wxRichTextRange
& WXUNUSED(range
)) const { return wxEmptyString
; }
699 /// Returns true if this object can merge itself with the given one.
700 virtual bool CanMerge(wxRichTextObject
* WXUNUSED(object
)) const { return false; }
702 /// Returns true if this object merged itself with the given one.
703 /// The calling code will then delete the given object.
704 virtual bool Merge(wxRichTextObject
* WXUNUSED(object
)) { return false; }
706 /// Dump to output stream for debugging
707 virtual void Dump(wxTextOutputStream
& stream
);
711 /// Get/set the cached object size as calculated by Layout.
712 virtual wxSize
GetCachedSize() const { return m_size
; }
713 virtual void SetCachedSize(const wxSize
& sz
) { m_size
= sz
; }
715 /// Get/set the object position
716 virtual wxPoint
GetPosition() const { return m_pos
; }
717 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
719 /// Get the rectangle enclosing the object
720 virtual wxRect
GetRect() const { return wxRect(GetPosition(), GetCachedSize()); }
723 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
726 const wxRichTextRange
& GetRange() const { return m_range
; }
727 wxRichTextRange
& GetRange() { return m_range
; }
729 /// Get/set dirty flag (whether the object needs Layout to be called)
730 virtual bool GetDirty() const { return m_dirty
; }
731 virtual void SetDirty(bool dirty
) { m_dirty
= dirty
; }
733 /// Is this composite?
734 virtual bool IsComposite() const { return false; }
736 /// Get/set the parent.
737 virtual wxRichTextObject
* GetParent() const { return m_parent
; }
738 virtual void SetParent(wxRichTextObject
* parent
) { m_parent
= parent
; }
740 /// Set the margin around the object
741 virtual void SetMargins(int margin
);
742 virtual void SetMargins(int leftMargin
, int rightMargin
, int topMargin
, int bottomMargin
);
743 virtual int GetLeftMargin() const { return m_leftMargin
; }
744 virtual int GetRightMargin() const { return m_rightMargin
; }
745 virtual int GetTopMargin() const { return m_topMargin
; }
746 virtual int GetBottomMargin() const { return m_bottomMargin
; }
748 /// Set attributes object
749 void SetAttributes(const wxTextAttrEx
& attr
) { m_attributes
= attr
; }
750 const wxTextAttrEx
& GetAttributes() const { return m_attributes
; }
751 wxTextAttrEx
& GetAttributes() { return m_attributes
; }
753 /// Set/get stored descent
754 void SetDescent(int descent
) { m_descent
= descent
; }
755 int GetDescent() const { return m_descent
; }
757 /// Gets the containing buffer
758 wxRichTextBuffer
* GetBuffer() const;
763 virtual wxRichTextObject
* Clone() const { return NULL
; }
766 void Copy(const wxRichTextObject
& obj
);
768 /// Reference-counting allows us to use the same object in multiple
769 /// lists (not yet used)
770 void Reference() { m_refCount
++; }
773 /// Convert units in tenths of a millimetre to device units
774 int ConvertTenthsMMToPixels(wxDC
& dc
, int units
);
775 static int ConvertTenthsMMToPixels(int ppi
, int units
);
780 int m_descent
; // Descent for this object (if any)
783 wxRichTextObject
* m_parent
;
785 /// The range of this object (start position to end position)
786 wxRichTextRange m_range
;
795 wxTextAttrEx m_attributes
;
798 WX_DECLARE_LIST_WITH_DECL( wxRichTextObject
, wxRichTextObjectList
, class WXDLLIMPEXP_RICHTEXT
);
801 * wxRichTextCompositeObject class declaration
802 * Objects of this class can contain other objects.
805 class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject
: public wxRichTextObject
807 DECLARE_CLASS(wxRichTextCompositeObject
)
811 wxRichTextCompositeObject(wxRichTextObject
* parent
= NULL
);
812 virtual ~wxRichTextCompositeObject();
816 /// Hit-testing: returns a flag indicating hit test details, plus
817 /// information about position
818 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
);
820 /// Finds the absolute position and row height for the given character position
821 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
824 virtual void CalculateRange(long start
, long& end
);
827 virtual bool DeleteRange(const wxRichTextRange
& range
);
829 /// Get any text in this object for the given range
830 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
832 /// Dump to output stream for debugging
833 virtual void Dump(wxTextOutputStream
& stream
);
838 wxRichTextObjectList
& GetChildren() { return m_children
; }
839 const wxRichTextObjectList
& GetChildren() const { return m_children
; }
841 /// Get the child count
842 size_t GetChildCount() const ;
844 /// Get the nth child
845 wxRichTextObject
* GetChild(size_t n
) const ;
847 /// Get/set dirty flag
848 virtual bool GetDirty() const { return m_dirty
; }
849 virtual void SetDirty(bool dirty
) { m_dirty
= dirty
; }
851 /// Is this composite?
852 virtual bool IsComposite() const { return true; }
854 /// Returns true if the buffer is empty
855 virtual bool IsEmpty() const { return GetChildCount() == 0; }
860 void Copy(const wxRichTextCompositeObject
& obj
);
863 void operator= (const wxRichTextCompositeObject
& obj
) { Copy(obj
); }
865 /// Append a child, returning the position
866 size_t AppendChild(wxRichTextObject
* child
) ;
868 /// Insert the child in front of the given object, or at the beginning
869 bool InsertChild(wxRichTextObject
* child
, wxRichTextObject
* inFrontOf
) ;
872 bool RemoveChild(wxRichTextObject
* child
, bool deleteChild
= false) ;
874 /// Delete all children
875 bool DeleteChildren() ;
877 /// Recursively merge all pieces that can be merged.
881 wxRichTextObjectList m_children
;
885 * wxRichTextBox class declaration
886 * This defines a 2D space to lay out objects
889 class WXDLLIMPEXP_RICHTEXT wxRichTextBox
: public wxRichTextCompositeObject
891 DECLARE_DYNAMIC_CLASS(wxRichTextBox
)
895 wxRichTextBox(wxRichTextObject
* parent
= NULL
);
896 wxRichTextBox(const wxRichTextBox
& obj
): wxRichTextCompositeObject() { Copy(obj
); }
901 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
904 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
906 /// Get/set the object size for the given range. Returns false if the range
907 /// is invalid for this object.
908 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const;
915 virtual wxRichTextObject
* Clone() const { return new wxRichTextBox(*this); }
918 void Copy(const wxRichTextBox
& obj
);
924 * wxRichTextParagraphBox class declaration
925 * This box knows how to lay out paragraphs.
928 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphLayoutBox
: public wxRichTextBox
930 DECLARE_DYNAMIC_CLASS(wxRichTextParagraphLayoutBox
)
934 wxRichTextParagraphLayoutBox(wxRichTextObject
* parent
= NULL
);
935 wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox
& obj
): wxRichTextBox() { Init(); Copy(obj
); }
940 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
943 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
945 /// Get/set the object size for the given range. Returns false if the range
946 /// is invalid for this object.
947 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const;
950 virtual bool DeleteRange(const wxRichTextRange
& range
);
952 /// Get any text in this object for the given range
953 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
957 /// Associate a control with the buffer, for operations that for example require refreshing the window.
958 void SetRichTextCtrl(wxRichTextCtrl
* ctrl
) { m_ctrl
= ctrl
; }
960 /// Get the associated control.
961 wxRichTextCtrl
* GetRichTextCtrl() const { return m_ctrl
; }
963 /// Get/set whether the last paragraph is partial or complete
964 void SetPartialParagraph(bool partialPara
) { m_partialParagraph
= partialPara
; }
965 bool GetPartialParagraph() const { return m_partialParagraph
; }
967 /// If this is a buffer, returns the current style sheet. The base layout box
968 /// class doesn't have an associated style sheet.
969 virtual wxRichTextStyleSheet
* GetStyleSheet() const { return NULL
; }
973 /// Initialize the object.
976 /// Clear all children
977 virtual void Clear();
979 /// Clear and initialize with one blank paragraph
980 virtual void Reset();
982 /// Convenience function to add a paragraph of text
983 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxTextAttrEx
* paraStyle
= NULL
);
985 /// Convenience function to add an image
986 virtual wxRichTextRange
AddImage(const wxImage
& image
, wxTextAttrEx
* paraStyle
= NULL
);
988 /// Adds multiple paragraphs, based on newlines.
989 virtual wxRichTextRange
AddParagraphs(const wxString
& text
, wxTextAttrEx
* paraStyle
= NULL
);
991 /// Get the line at the given position. If caretPosition is true, the position is
992 /// a caret position, which is normally a smaller number.
993 virtual wxRichTextLine
* GetLineAtPosition(long pos
, bool caretPosition
= false) const;
995 /// Get the line at the given y pixel position, or the last line.
996 virtual wxRichTextLine
* GetLineAtYPosition(int y
) const;
998 /// Get the paragraph at the given character or caret position
999 virtual wxRichTextParagraph
* GetParagraphAtPosition(long pos
, bool caretPosition
= false) const;
1001 /// Get the line size at the given position
1002 virtual wxSize
GetLineSizeAtPosition(long pos
, bool caretPosition
= false) const;
1004 /// Given a position, get the number of the visible line (potentially many to a paragraph),
1005 /// starting from zero at the start of the buffer. We also have to pass a bool (startOfLine)
1006 /// that indicates whether the caret is being shown at the end of the previous line or at the start
1007 /// of the next, since the caret can be shown at 2 visible positions for the same underlying
1009 virtual long GetVisibleLineNumber(long pos
, bool caretPosition
= false, bool startOfLine
= false) const;
1011 /// Given a line number, get the corresponding wxRichTextLine object.
1012 virtual wxRichTextLine
* GetLineForVisibleLineNumber(long lineNumber
) const;
1014 /// Get the leaf object in a paragraph at this position.
1015 /// Given a line number, get the corresponding wxRichTextLine object.
1016 virtual wxRichTextObject
* GetLeafObjectAtPosition(long position
) const;
1018 /// Get the paragraph by number
1019 virtual wxRichTextParagraph
* GetParagraphAtLine(long paragraphNumber
) const;
1021 /// Get the paragraph for a given line
1022 virtual wxRichTextParagraph
* GetParagraphForLine(wxRichTextLine
* line
) const;
1024 /// Get the length of the paragraph
1025 virtual int GetParagraphLength(long paragraphNumber
) const;
1027 /// Get the number of paragraphs
1028 virtual int GetParagraphCount() const { return GetChildCount(); }
1030 /// Get the number of visible lines
1031 virtual int GetLineCount() const;
1033 /// Get the text of the paragraph
1034 virtual wxString
GetParagraphText(long paragraphNumber
) const;
1036 /// Convert zero-based line column and paragraph number to a position.
1037 virtual long XYToPosition(long x
, long y
) const;
1039 /// Convert zero-based position to line column and paragraph number
1040 virtual bool PositionToXY(long pos
, long* x
, long* y
) const;
1042 /// Set text attributes: character and/or paragraph styles.
1043 virtual bool SetStyle(const wxRichTextRange
& range
, const wxRichTextAttr
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1044 virtual bool SetStyle(const wxRichTextRange
& range
, const wxTextAttrEx
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1046 /// Get the conbined text attributes for this position.
1047 virtual bool GetStyle(long position
, wxTextAttrEx
& style
);
1048 virtual bool GetStyle(long position
, wxRichTextAttr
& style
);
1050 /// Get the content (uncombined) attributes for this position.
1051 virtual bool GetUncombinedStyle(long position
, wxTextAttrEx
& style
);
1052 virtual bool GetUncombinedStyle(long position
, wxRichTextAttr
& style
);
1054 /// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and
1055 /// context attributes.
1056 virtual bool DoGetStyle(long position
, wxTextAttrEx
& style
, bool combineStyles
= true);
1058 /// Get the combined style for a range - if any attribute is different within the range,
1059 /// that attribute is not present within the flags
1060 virtual bool GetStyleForRange(const wxRichTextRange
& range
, wxTextAttrEx
& style
);
1062 /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
1064 bool CollectStyle(wxTextAttrEx
& currentStyle
, const wxTextAttrEx
& style
, long& multipleStyleAttributes
, int& multipleTextEffectAttributes
);
1067 virtual bool SetListStyle(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
1068 virtual bool SetListStyle(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
1070 /// Clear list for given range
1071 virtual bool ClearListStyle(const wxRichTextRange
& range
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1073 /// Number/renumber any list elements in the given range.
1074 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
1075 virtual bool NumberList(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
1076 virtual bool NumberList(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
1078 /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1
1079 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
1080 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
1081 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
1083 /// Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously
1084 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
1085 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);
1087 /// Fills in the attributes for numbering a paragraph after previousParagraph.
1088 virtual bool FindNextParagraphNumber(wxRichTextParagraph
* previousParagraph
, wxRichTextAttr
& attr
) const;
1090 /// Test if this whole range has character attributes of the specified kind. If any
1091 /// of the attributes are different within the range, the test fails. You
1092 /// can use this to implement, for example, bold button updating. style must have
1093 /// flags indicating which attributes are of interest.
1094 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxTextAttrEx
& style
) const;
1095 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
1097 /// Test if this whole range has paragraph attributes of the specified kind. If any
1098 /// of the attributes are different within the range, the test fails. You
1099 /// can use this to implement, for example, centering button updating. style must have
1100 /// flags indicating which attributes are of interest.
1101 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxTextAttrEx
& style
) const;
1102 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
1105 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraphLayoutBox(*this); }
1107 /// Insert fragment into this box at the given position. If partialParagraph is true,
1108 /// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
1110 virtual bool InsertFragment(long position
, wxRichTextParagraphLayoutBox
& fragment
);
1112 /// Make a copy of the fragment corresponding to the given range, putting it in 'fragment'.
1113 virtual bool CopyFragment(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
& fragment
);
1115 /// Apply the style sheet to the buffer, for example if the styles have changed.
1116 virtual bool ApplyStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1119 void Copy(const wxRichTextParagraphLayoutBox
& obj
);
1122 void operator= (const wxRichTextParagraphLayoutBox
& obj
) { Copy(obj
); }
1124 /// Calculate ranges
1125 virtual void UpdateRanges() { long end
; CalculateRange(0, end
); }
1127 /// Get all the text
1128 virtual wxString
GetText() const;
1130 /// Set default style for new content. Setting it to a default attribute
1131 /// makes new content take on the 'basic' style.
1132 virtual bool SetDefaultStyle(const wxTextAttrEx
& style
);
1134 /// Get default style
1135 virtual const wxTextAttrEx
& GetDefaultStyle() const { return m_defaultAttributes
; }
1137 /// Set basic (overall) style
1138 virtual void SetBasicStyle(const wxTextAttrEx
& style
) { m_attributes
= style
; }
1139 virtual void SetBasicStyle(const wxRichTextAttr
& style
) { style
.CopyTo(m_attributes
); }
1141 /// Get basic (overall) style
1142 virtual const wxTextAttrEx
& GetBasicStyle() const { return m_attributes
; }
1144 /// Invalidate the buffer. With no argument, invalidates whole buffer.
1145 void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
1147 /// Get invalid range, rounding to entire paragraphs if argument is true.
1148 wxRichTextRange
GetInvalidRange(bool wholeParagraphs
= false) const;
1151 wxRichTextCtrl
* m_ctrl
;
1152 wxTextAttrEx m_defaultAttributes
;
1154 /// The invalidated range that will need full layout
1155 wxRichTextRange m_invalidRange
;
1157 // Is the last paragraph partial or complete?
1158 bool m_partialParagraph
;
1162 * wxRichTextLine class declaration
1163 * This object represents a line in a paragraph, and stores
1164 * offsets from the start of the paragraph representing the
1165 * start and end positions of the line.
1168 class WXDLLIMPEXP_RICHTEXT wxRichTextLine
1173 wxRichTextLine(wxRichTextParagraph
* parent
);
1174 wxRichTextLine(const wxRichTextLine
& obj
) { Init( NULL
); Copy(obj
); }
1175 virtual ~wxRichTextLine() {}
1182 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
1183 void SetRange(long from
, long to
) { m_range
= wxRichTextRange(from
, to
); }
1185 /// Get the parent paragraph
1186 wxRichTextParagraph
* GetParent() { return m_parent
; }
1189 const wxRichTextRange
& GetRange() const { return m_range
; }
1190 wxRichTextRange
& GetRange() { return m_range
; }
1192 /// Get the absolute range
1193 wxRichTextRange
GetAbsoluteRange() const;
1195 /// Get/set the line size as calculated by Layout.
1196 virtual wxSize
GetSize() const { return m_size
; }
1197 virtual void SetSize(const wxSize
& sz
) { m_size
= sz
; }
1199 /// Get/set the object position relative to the parent
1200 virtual wxPoint
GetPosition() const { return m_pos
; }
1201 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
1203 /// Get the absolute object position
1204 virtual wxPoint
GetAbsolutePosition() const;
1206 /// Get the rectangle enclosing the line
1207 virtual wxRect
GetRect() const { return wxRect(GetAbsolutePosition(), GetSize()); }
1209 /// Set/get stored descent
1210 void SetDescent(int descent
) { m_descent
= descent
; }
1211 int GetDescent() const { return m_descent
; }
1216 void Init(wxRichTextParagraph
* parent
);
1219 void Copy(const wxRichTextLine
& obj
);
1222 virtual wxRichTextLine
* Clone() const { return new wxRichTextLine(*this); }
1226 /// The range of the line (start position to end position)
1227 /// This is relative to the parent paragraph.
1228 wxRichTextRange m_range
;
1230 /// Size and position measured relative to top of paragraph
1234 /// Maximum descent for this line (location of text baseline)
1237 // The parent object
1238 wxRichTextParagraph
* m_parent
;
1241 WX_DECLARE_LIST_WITH_DECL( wxRichTextLine
, wxRichTextLineList
, class WXDLLIMPEXP_RICHTEXT
);
1244 * wxRichTextParagraph class declaration
1245 * This object represents a single paragraph (or in a straight text editor, a line).
1248 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph
: public wxRichTextBox
1250 DECLARE_DYNAMIC_CLASS(wxRichTextParagraph
)
1254 wxRichTextParagraph(wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* style
= NULL
);
1255 wxRichTextParagraph(const wxString
& text
, wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* paraStyle
= NULL
, wxTextAttrEx
* charStyle
= NULL
);
1256 virtual ~wxRichTextParagraph();
1257 wxRichTextParagraph(const wxRichTextParagraph
& obj
): wxRichTextBox() { Copy(obj
); }
1262 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
1264 /// Lay the item out
1265 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
1267 /// Get/set the object size for the given range. Returns false if the range
1268 /// is invalid for this object.
1269 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const;
1271 /// Finds the absolute position and row height for the given character position
1272 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
1274 /// Hit-testing: returns a flag indicating hit test details, plus
1275 /// information about position
1276 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
);
1279 virtual void CalculateRange(long start
, long& end
);
1283 /// Get the cached lines
1284 wxRichTextLineList
& GetLines() { return m_cachedLines
; }
1289 void Copy(const wxRichTextParagraph
& obj
);
1292 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraph(*this); }
1294 /// Clear the cached lines
1299 /// Apply paragraph styles such as centering to the wrapped lines
1300 virtual void ApplyParagraphStyle(const wxTextAttrEx
& attr
, const wxRect
& rect
);
1302 /// Insert text at the given position
1303 virtual bool InsertText(long pos
, const wxString
& text
);
1305 /// Split an object at this position if necessary, and return
1306 /// the previous object, or NULL if inserting at beginning.
1307 virtual wxRichTextObject
* SplitAt(long pos
, wxRichTextObject
** previousObject
= NULL
);
1309 /// Move content to a list from this point
1310 virtual void MoveToList(wxRichTextObject
* obj
, wxList
& list
);
1312 /// Add content back from list
1313 virtual void MoveFromList(wxList
& list
);
1315 /// Get the plain text searching from the start or end of the range.
1316 /// The resulting string may be shorter than the range given.
1317 bool GetContiguousPlainText(wxString
& text
, const wxRichTextRange
& range
, bool fromStart
= true);
1319 /// Find a suitable wrap position. wrapPosition is the last position in the line to the left
1321 bool FindWrapPosition(const wxRichTextRange
& range
, wxDC
& dc
, int availableSpace
, long& wrapPosition
);
1323 /// Find the object at the given position
1324 wxRichTextObject
* FindObjectAtPosition(long position
);
1326 /// Get the bullet text for this paragraph.
1327 wxString
GetBulletText();
1329 /// Allocate or reuse a line object
1330 wxRichTextLine
* AllocateLine(int pos
);
1332 /// Clear remaining unused line objects, if any
1333 bool ClearUnusedLines(int lineCount
);
1335 /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically
1336 /// retrieve the actual style.
1337 wxTextAttrEx
GetCombinedAttributes(const wxTextAttrEx
& contentStyle
) const;
1339 /// Get combined attributes of the base style and paragraph style.
1340 wxTextAttrEx
GetCombinedAttributes() const;
1342 /// Create default tabstop array
1343 static void InitDefaultTabs();
1345 /// Clear default tabstop array
1346 static void ClearDefaultTabs();
1348 /// Get default tabstop array
1349 static const wxArrayInt
& GetDefaultTabs() { return sm_defaultTabs
; }
1352 /// The lines that make up the wrapped paragraph
1353 wxRichTextLineList m_cachedLines
;
1355 /// Default tabstops
1356 static wxArrayInt sm_defaultTabs
;
1360 * wxRichTextPlainText class declaration
1361 * This object represents a single piece of text.
1364 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText
: public wxRichTextObject
1366 DECLARE_DYNAMIC_CLASS(wxRichTextPlainText
)
1370 wxRichTextPlainText(const wxString
& text
= wxEmptyString
, wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* style
= NULL
);
1371 wxRichTextPlainText(const wxRichTextPlainText
& obj
): wxRichTextObject() { Copy(obj
); }
1376 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
1378 /// Lay the item out
1379 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
1381 /// Get/set the object size for the given range. Returns false if the range
1382 /// is invalid for this object.
1383 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
/* = wxPoint(0,0)*/) const;
1385 /// Get any text in this object for the given range
1386 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
1388 /// Do a split, returning an object containing the second part, and setting
1389 /// the first part in 'this'.
1390 virtual wxRichTextObject
* DoSplit(long pos
);
1393 virtual void CalculateRange(long start
, long& end
);
1396 virtual bool DeleteRange(const wxRichTextRange
& range
);
1398 /// Returns true if the object is empty
1399 virtual bool IsEmpty() const { return m_text
.empty(); }
1401 /// Returns true if this object can merge itself with the given one.
1402 virtual bool CanMerge(wxRichTextObject
* object
) const;
1404 /// Returns true if this object merged itself with the given one.
1405 /// The calling code will then delete the given object.
1406 virtual bool Merge(wxRichTextObject
* object
);
1408 /// Dump to output stream for debugging
1409 virtual void Dump(wxTextOutputStream
& stream
);
1414 const wxString
& GetText() const { return m_text
; }
1417 void SetText(const wxString
& text
) { m_text
= text
; }
1422 void Copy(const wxRichTextPlainText
& obj
);
1425 virtual wxRichTextObject
* Clone() const { return new wxRichTextPlainText(*this); }
1427 bool DrawTabbedString(wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
, wxString
& str
, wxCoord
& x
, wxCoord
& y
, bool selected
);
1434 * wxRichTextImageBlock stores information about an image, in binary in-memory form
1437 class WXDLLIMPEXP_BASE wxDataInputStream
;
1438 class WXDLLIMPEXP_BASE wxDataOutputStream
;
1440 class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock
: public wxObject
1443 wxRichTextImageBlock();
1444 wxRichTextImageBlock(const wxRichTextImageBlock
& block
);
1445 virtual ~wxRichTextImageBlock();
1450 // Load the original image into a memory block.
1451 // If the image is not a JPEG, we must convert it into a JPEG
1452 // to conserve space.
1453 // If it's not a JPEG we can make use of 'image', already scaled, so we don't have to
1454 // load the image a 2nd time.
1455 virtual bool MakeImageBlock(const wxString
& filename
, int imageType
, wxImage
& image
, bool convertToJPEG
= true);
1457 // Make an image block from the wxImage in the given
1459 virtual bool MakeImageBlock(wxImage
& image
, int imageType
, int quality
= 80);
1462 bool Write(const wxString
& filename
);
1464 // Write data in hex to a stream
1465 bool WriteHex(wxOutputStream
& stream
);
1467 // Read data in hex from a stream
1468 bool ReadHex(wxInputStream
& stream
, int length
, int imageType
);
1470 // Copy from 'block'
1471 void Copy(const wxRichTextImageBlock
& block
);
1473 // Load a wxImage from the block
1474 bool Load(wxImage
& image
);
1477 void operator=(const wxRichTextImageBlock
& block
);
1481 unsigned char* GetData() const { return m_data
; }
1482 size_t GetDataSize() const { return m_dataSize
; }
1483 int GetImageType() const { return m_imageType
; }
1485 void SetData(unsigned char* image
) { m_data
= image
; }
1486 void SetDataSize(size_t size
) { m_dataSize
= size
; }
1487 void SetImageType(int imageType
) { m_imageType
= imageType
; }
1489 bool Ok() const { return IsOk(); }
1490 bool IsOk() const { return GetData() != NULL
; }
1492 // Gets the extension for the block's type
1493 wxString
GetExtension() const;
1497 // Allocate and read from stream as a block of memory
1498 static unsigned char* ReadBlock(wxInputStream
& stream
, size_t size
);
1499 static unsigned char* ReadBlock(const wxString
& filename
, size_t size
);
1501 // Write memory block to stream
1502 static bool WriteBlock(wxOutputStream
& stream
, unsigned char* block
, size_t size
);
1504 // Write memory block to file
1505 static bool WriteBlock(const wxString
& filename
, unsigned char* block
, size_t size
);
1508 // Size in bytes of the image stored.
1509 // This is in the raw, original form such as a JPEG file.
1510 unsigned char* m_data
;
1512 int m_imageType
; // wxWin type id
1517 * wxRichTextImage class declaration
1518 * This object represents an image.
1521 class WXDLLIMPEXP_RICHTEXT wxRichTextImage
: public wxRichTextObject
1523 DECLARE_DYNAMIC_CLASS(wxRichTextImage
)
1527 wxRichTextImage(wxRichTextObject
* parent
= NULL
): wxRichTextObject(parent
) { }
1528 wxRichTextImage(const wxImage
& image
, wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* charStyle
= NULL
);
1529 wxRichTextImage(const wxRichTextImageBlock
& imageBlock
, wxRichTextObject
* parent
= NULL
, wxTextAttrEx
* charStyle
= NULL
);
1530 wxRichTextImage(const wxRichTextImage
& obj
): wxRichTextObject() { Copy(obj
); }
1535 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
1537 /// Lay the item out
1538 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
1540 /// Get the object size for the given range. Returns false if the range
1541 /// is invalid for this object.
1542 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0)) const;
1544 /// Returns true if the object is empty
1545 virtual bool IsEmpty() const { return !m_image
.Ok(); }
1550 const wxImage
& GetImage() const { return m_image
; }
1553 void SetImage(const wxImage
& image
) { m_image
= image
; }
1555 /// Get the image block containing the raw data
1556 wxRichTextImageBlock
& GetImageBlock() { return m_imageBlock
; }
1561 void Copy(const wxRichTextImage
& obj
);
1564 virtual wxRichTextObject
* Clone() const { return new wxRichTextImage(*this); }
1566 /// Load wxImage from the block
1567 virtual bool LoadFromBlock();
1569 /// Make block from the wxImage
1570 virtual bool MakeBlock();
1573 // TODO: reduce the multiple representations of data
1576 wxRichTextImageBlock m_imageBlock
;
1581 * wxRichTextBuffer class declaration
1582 * This is a kind of box, used to represent the whole buffer
1585 class WXDLLIMPEXP_RICHTEXT wxRichTextCommand
;
1586 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
;
1588 class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer
: public wxRichTextParagraphLayoutBox
1590 DECLARE_DYNAMIC_CLASS(wxRichTextBuffer
)
1594 wxRichTextBuffer() { Init(); }
1595 wxRichTextBuffer(const wxRichTextBuffer
& obj
): wxRichTextParagraphLayoutBox() { Init(); Copy(obj
); }
1596 virtual ~wxRichTextBuffer() ;
1600 /// Gets the command processor
1601 wxCommandProcessor
* GetCommandProcessor() const { return m_commandProcessor
; }
1603 /// Set style sheet, if any.
1604 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
) { m_styleSheet
= styleSheet
; }
1605 virtual wxRichTextStyleSheet
* GetStyleSheet() const { return m_styleSheet
; }
1607 /// Set style sheet and notify of the change
1608 bool SetStyleSheetAndNotify(wxRichTextStyleSheet
* sheet
);
1610 /// Push style sheet to top of stack
1611 bool PushStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1613 /// Pop style sheet from top of stack
1614 wxRichTextStyleSheet
* PopStyleSheet();
1621 /// Clears the buffer, adds an empty paragraph, and clears the command processor.
1622 virtual void ResetAndClearCommands();
1625 virtual bool LoadFile(const wxString
& filename
, int type
= wxRICHTEXT_TYPE_ANY
);
1628 virtual bool SaveFile(const wxString
& filename
, int type
= wxRICHTEXT_TYPE_ANY
);
1630 /// Load from a stream
1631 virtual bool LoadFile(wxInputStream
& stream
, int type
= wxRICHTEXT_TYPE_ANY
);
1633 /// Save to a stream
1634 virtual bool SaveFile(wxOutputStream
& stream
, int type
= wxRICHTEXT_TYPE_ANY
);
1636 /// Set the handler flags, controlling loading and saving
1637 void SetHandlerFlags(int flags
) { m_handlerFlags
= flags
; }
1639 /// Get the handler flags, controlling loading and saving
1640 int GetHandlerFlags() const { return m_handlerFlags
; }
1642 /// Convenience function to add a paragraph of text
1643 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxTextAttrEx
* paraStyle
= NULL
) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text
, paraStyle
); }
1645 /// Begin collapsing undo/redo commands. Note that this may not work properly
1646 /// if combining commands that delete or insert content, changing ranges for
1647 /// subsequent actions.
1648 virtual bool BeginBatchUndo(const wxString
& cmdName
);
1650 /// End collapsing undo/redo commands
1651 virtual bool EndBatchUndo();
1653 /// Collapsing commands?
1654 virtual bool BatchingUndo() const { return m_batchedCommandDepth
> 0; }
1656 /// Submit immediately, or delay according to whether collapsing is on
1657 virtual bool SubmitAction(wxRichTextAction
* action
);
1659 /// Get collapsed command
1660 virtual wxRichTextCommand
* GetBatchedCommand() const { return m_batchedCommand
; }
1662 /// Begin suppressing undo/redo commands. The way undo is suppressed may be implemented
1663 /// differently by each command. If not dealt with by a command implementation, then
1664 /// it will be implemented automatically by not storing the command in the undo history
1665 /// when the action is submitted to the command processor.
1666 virtual bool BeginSuppressUndo();
1668 /// End suppressing undo/redo commands.
1669 virtual bool EndSuppressUndo();
1671 /// Collapsing commands?
1672 virtual bool SuppressingUndo() const { return m_suppressUndo
> 0; }
1674 /// Copy the range to the clipboard
1675 virtual bool CopyToClipboard(const wxRichTextRange
& range
);
1677 /// Paste the clipboard content to the buffer
1678 virtual bool PasteFromClipboard(long position
);
1680 /// Can we paste from the clipboard?
1681 virtual bool CanPasteFromClipboard() const;
1683 /// Begin using a style
1684 virtual bool BeginStyle(const wxTextAttrEx
& style
);
1687 virtual bool EndStyle();
1690 virtual bool EndAllStyles();
1692 /// Clear the style stack
1693 virtual void ClearStyleStack();
1695 /// Get the size of the style stack, for example to check correct nesting
1696 virtual size_t GetStyleStackSize() const { return m_attributeStack
.GetCount(); }
1698 /// Begin using bold
1702 bool EndBold() { return EndStyle(); }
1704 /// Begin using italic
1707 /// End using italic
1708 bool EndItalic() { return EndStyle(); }
1710 /// Begin using underline
1711 bool BeginUnderline();
1713 /// End using underline
1714 bool EndUnderline() { return EndStyle(); }
1716 /// Begin using point size
1717 bool BeginFontSize(int pointSize
);
1719 /// End using point size
1720 bool EndFontSize() { return EndStyle(); }
1722 /// Begin using this font
1723 bool BeginFont(const wxFont
& font
);
1725 /// End using a font
1726 bool EndFont() { return EndStyle(); }
1728 /// Begin using this colour
1729 bool BeginTextColour(const wxColour
& colour
);
1731 /// End using a colour
1732 bool EndTextColour() { return EndStyle(); }
1734 /// Begin using alignment
1735 bool BeginAlignment(wxTextAttrAlignment alignment
);
1738 bool EndAlignment() { return EndStyle(); }
1740 /// Begin left indent
1741 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
1744 bool EndLeftIndent() { return EndStyle(); }
1746 /// Begin right indent
1747 bool BeginRightIndent(int rightIndent
);
1749 /// End right indent
1750 bool EndRightIndent() { return EndStyle(); }
1752 /// Begin paragraph spacing
1753 bool BeginParagraphSpacing(int before
, int after
);
1755 /// End paragraph spacing
1756 bool EndParagraphSpacing() { return EndStyle(); }
1758 /// Begin line spacing
1759 bool BeginLineSpacing(int lineSpacing
);
1761 /// End line spacing
1762 bool EndLineSpacing() { return EndStyle(); }
1764 /// Begin numbered bullet
1765 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
1767 /// End numbered bullet
1768 bool EndNumberedBullet() { return EndStyle(); }
1770 /// Begin symbol bullet
1771 bool BeginSymbolBullet(const wxString
& symbol
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
1773 /// End symbol bullet
1774 bool EndSymbolBullet() { return EndStyle(); }
1776 /// Begin standard bullet
1777 bool BeginStandardBullet(const wxString
& bulletName
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_STANDARD
);
1779 /// End standard bullet
1780 bool EndStandardBullet() { return EndStyle(); }
1782 /// Begin named character style
1783 bool BeginCharacterStyle(const wxString
& characterStyle
);
1785 /// End named character style
1786 bool EndCharacterStyle() { return EndStyle(); }
1788 /// Begin named paragraph style
1789 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
1791 /// End named character style
1792 bool EndParagraphStyle() { return EndStyle(); }
1794 /// Begin named list style
1795 bool BeginListStyle(const wxString
& listStyle
, int level
= 1, int number
= 1);
1797 /// End named character style
1798 bool EndListStyle() { return EndStyle(); }
1801 bool BeginURL(const wxString
& url
, const wxString
& characterStyle
= wxEmptyString
);
1804 bool EndURL() { return EndStyle(); }
1808 /// Add an event handler
1809 bool AddEventHandler(wxEvtHandler
* handler
);
1811 /// Remove an event handler
1812 bool RemoveEventHandler(wxEvtHandler
* handler
, bool deleteHandler
= false);
1814 /// Clear event handlers
1815 void ClearEventHandlers();
1817 /// Send event to event handlers. If sendToAll is true, will send to all event handlers,
1818 /// otherwise will stop at the first successful one.
1819 bool SendEvent(wxEvent
& event
, bool sendToAll
= true);
1824 void Copy(const wxRichTextBuffer
& obj
);
1827 virtual wxRichTextObject
* Clone() const { return new wxRichTextBuffer(*this); }
1829 /// Submit command to insert paragraphs
1830 bool InsertParagraphsWithUndo(long pos
, const wxRichTextParagraphLayoutBox
& paragraphs
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1832 /// Submit command to insert the given text
1833 bool InsertTextWithUndo(long pos
, const wxString
& text
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1835 /// Submit command to insert a newline
1836 bool InsertNewlineWithUndo(long pos
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1838 /// Submit command to insert the given image
1839 bool InsertImageWithUndo(long pos
, const wxRichTextImageBlock
& imageBlock
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1841 /// Submit command to delete this range
1842 bool DeleteRangeWithUndo(const wxRichTextRange
& range
, long initialCaretPosition
, long newCaretPositon
, wxRichTextCtrl
* ctrl
);
1845 void Modify(bool modify
= true) { m_modified
= modify
; }
1846 bool IsModified() const { return m_modified
; }
1848 /// Get the style that is appropriate for a new paragraph at this position.
1849 /// If the previous paragraph has a paragraph style name, look up the next-paragraph
1851 wxRichTextAttr
GetStyleForNewParagraph(long pos
, bool caretPosition
= false) const;
1853 /// Dumps contents of buffer for debugging purposes
1854 virtual void Dump();
1855 virtual void Dump(wxTextOutputStream
& stream
) { wxRichTextParagraphLayoutBox::Dump(stream
); }
1857 /// Returns the file handlers
1858 static wxList
& GetHandlers() { return sm_handlers
; }
1860 /// Adds a handler to the end
1861 static void AddHandler(wxRichTextFileHandler
*handler
);
1863 /// Inserts a handler at the front
1864 static void InsertHandler(wxRichTextFileHandler
*handler
);
1866 /// Removes a handler
1867 static bool RemoveHandler(const wxString
& name
);
1869 /// Finds a handler by name
1870 static wxRichTextFileHandler
*FindHandler(const wxString
& name
);
1872 /// Finds a handler by extension and type
1873 static wxRichTextFileHandler
*FindHandler(const wxString
& extension
, int imageType
);
1875 /// Finds a handler by filename or, if supplied, type
1876 static wxRichTextFileHandler
*FindHandlerFilenameOrType(const wxString
& filename
, int imageType
);
1878 /// Finds a handler by type
1879 static wxRichTextFileHandler
*FindHandler(int imageType
);
1881 /// Gets a wildcard incorporating all visible handlers. If 'types' is present,
1882 /// will be filled with the file type corresponding to each filter. This can be
1883 /// used to determine the type to pass to LoadFile given a selected filter.
1884 static wxString
GetExtWildcard(bool combine
= false, bool save
= false, wxArrayInt
* types
= NULL
);
1886 /// Clean up handlers
1887 static void CleanUpHandlers();
1889 /// Initialise the standard handlers
1890 static void InitStandardHandlers();
1893 static wxRichTextRenderer
* GetRenderer() { return sm_renderer
; }
1895 /// Set renderer, deleting old one
1896 static void SetRenderer(wxRichTextRenderer
* renderer
);
1898 /// Minimum margin between bullet and paragraph in 10ths of a mm
1899 static int GetBulletRightMargin() { return sm_bulletRightMargin
; }
1900 static void SetBulletRightMargin(int margin
) { sm_bulletRightMargin
= margin
; }
1902 /// Factor to multiply by character height to get a reasonable bullet size
1903 static float GetBulletProportion() { return sm_bulletProportion
; }
1904 static void SetBulletProportion(float prop
) { sm_bulletProportion
= prop
; }
1906 /// Scale factor for calculating dimensions
1907 double GetScale() const { return m_scale
; }
1908 void SetScale(double scale
) { m_scale
= scale
; }
1912 /// Command processor
1913 wxCommandProcessor
* m_commandProcessor
;
1915 /// Has been modified?
1918 /// Collapsed command stack
1919 int m_batchedCommandDepth
;
1921 /// Name for collapsed command
1922 wxString m_batchedCommandsName
;
1924 /// Current collapsed command accumulating actions
1925 wxRichTextCommand
* m_batchedCommand
;
1927 /// Whether to suppress undo
1930 /// Style sheet, if any
1931 wxRichTextStyleSheet
* m_styleSheet
;
1933 /// List of event handlers that will be notified of events
1934 wxList m_eventHandlers
;
1936 /// Stack of attributes for convenience functions
1937 wxList m_attributeStack
;
1939 /// Flags to be passed to handlers
1943 static wxList sm_handlers
;
1946 static wxRichTextRenderer
* sm_renderer
;
1948 /// Minimum margin between bullet and paragraph in 10ths of a mm
1949 static int sm_bulletRightMargin
;
1951 /// Factor to multiply by character height to get a reasonable bullet size
1952 static float sm_bulletProportion
;
1954 /// Scaling factor in use: needed to calculate correct dimensions when printing
1959 * The command identifiers
1963 enum wxRichTextCommandId
1967 wxRICHTEXT_CHANGE_STYLE
1971 * Command classes for undo/redo
1975 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
;
1976 class WXDLLIMPEXP_RICHTEXT wxRichTextCommand
: public wxCommand
1979 // Ctor for one action
1980 wxRichTextCommand(const wxString
& name
, wxRichTextCommandId id
, wxRichTextBuffer
* buffer
,
1981 wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
1983 // Ctor for multiple actions
1984 wxRichTextCommand(const wxString
& name
);
1986 virtual ~wxRichTextCommand();
1991 void AddAction(wxRichTextAction
* action
);
1992 void ClearActions();
1994 wxList
& GetActions() { return m_actions
; }
2002 * wxRichTextAction class declaration
2003 * There can be more than one action in a command.
2006 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
: public wxObject
2009 wxRichTextAction(wxRichTextCommand
* cmd
, const wxString
& name
, wxRichTextCommandId id
, wxRichTextBuffer
* buffer
,
2010 wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
2012 virtual ~wxRichTextAction();
2017 /// Update the control appearance
2018 void UpdateAppearance(long caretPosition
, bool sendUpdateEvent
= false,
2019 wxArrayInt
* optimizationLineCharPositions
= NULL
, wxArrayInt
* optimizationLineYPositions
= NULL
);
2021 /// Replace the buffer paragraphs with the given fragment.
2022 void ApplyParagraphs(const wxRichTextParagraphLayoutBox
& fragment
);
2024 /// Get the fragments
2025 wxRichTextParagraphLayoutBox
& GetNewParagraphs() { return m_newParagraphs
; }
2026 wxRichTextParagraphLayoutBox
& GetOldParagraphs() { return m_oldParagraphs
; }
2028 /// Set/get the position used for e.g. insertion
2029 void SetPosition(long pos
) { m_position
= pos
; }
2030 long GetPosition() const { return m_position
; }
2032 /// Set/get the range for e.g. deletion
2033 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
2034 const wxRichTextRange
& GetRange() const { return m_range
; }
2037 const wxString
& GetName() const { return m_name
; }
2044 wxRichTextBuffer
* m_buffer
;
2047 wxRichTextCtrl
* m_ctrl
;
2049 // Stores the new paragraphs
2050 wxRichTextParagraphLayoutBox m_newParagraphs
;
2052 // Stores the old paragraphs
2053 wxRichTextParagraphLayoutBox m_oldParagraphs
;
2055 // The affected range
2056 wxRichTextRange m_range
;
2058 // The insertion point for this command
2061 // Ignore 1st 'Do' operation because we already did it
2064 // The command identifier
2065 wxRichTextCommandId m_cmdId
;
2072 // Include style sheet when loading and saving
2073 #define wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET 0x0001
2075 // Save images to memory file system in HTML handler
2076 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY 0x0010
2078 // Save images to files in HTML handler
2079 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES 0x0020
2081 // Save images as inline base64 data in HTML handler
2082 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040
2085 * wxRichTextFileHandler
2086 * Base class for file handlers
2089 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler
: public wxObject
2091 DECLARE_CLASS(wxRichTextFileHandler
)
2093 wxRichTextFileHandler(const wxString
& name
= wxEmptyString
, const wxString
& ext
= wxEmptyString
, int type
= 0)
2094 : m_name(name
), m_extension(ext
), m_type(type
), m_flags(0), m_visible(true)
2098 bool LoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
)
2099 { return DoLoadFile(buffer
, stream
); }
2100 bool SaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
)
2101 { return DoSaveFile(buffer
, stream
); }
2104 bool LoadFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
2105 bool SaveFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
2107 /// Can we handle this filename (if using files)? By default, checks the extension.
2108 virtual bool CanHandle(const wxString
& filename
) const;
2110 /// Can we save using this handler?
2111 virtual bool CanSave() const { return false; }
2113 /// Can we load using this handler?
2114 virtual bool CanLoad() const { return false; }
2116 /// Should this handler be visible to the user?
2117 virtual bool IsVisible() const { return m_visible
; }
2118 virtual void SetVisible(bool visible
) { m_visible
= visible
; }
2120 /// The name of the nandler
2121 void SetName(const wxString
& name
) { m_name
= name
; }
2122 wxString
GetName() const { return m_name
; }
2124 /// The default extension to recognise
2125 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
2126 wxString
GetExtension() const { return m_extension
; }
2128 /// The handler type
2129 void SetType(int type
) { m_type
= type
; }
2130 int GetType() const { return m_type
; }
2132 /// Flags controlling how loading and saving is done
2133 void SetFlags(int flags
) { m_flags
= flags
; }
2134 int GetFlags() const { return m_flags
; }
2136 /// Encoding to use when saving a file. If empty, a suitable encoding is chosen
2137 void SetEncoding(const wxString
& encoding
) { m_encoding
= encoding
; }
2138 const wxString
& GetEncoding() const { return m_encoding
; }
2143 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
) = 0;
2144 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
) = 0;
2148 wxString m_encoding
;
2149 wxString m_extension
;
2156 * wxRichTextPlainTextHandler
2157 * Plain text handler
2160 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler
: public wxRichTextFileHandler
2162 DECLARE_CLASS(wxRichTextPlainTextHandler
)
2164 wxRichTextPlainTextHandler(const wxString
& name
= wxT("Text"), const wxString
& ext
= wxT("txt"), int type
= wxRICHTEXT_TYPE_TEXT
)
2165 : wxRichTextFileHandler(name
, ext
, type
)
2168 /// Can we save using this handler?
2169 virtual bool CanSave() const { return true; }
2171 /// Can we load using this handler?
2172 virtual bool CanLoad() const { return true; }
2177 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
2178 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
2186 * The data object for a wxRichTextBuffer
2189 class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject
: public wxDataObjectSimple
2192 // ctor doesn't copy the pointer, so it shouldn't go away while this object
2194 wxRichTextBufferDataObject(wxRichTextBuffer
* richTextBuffer
= (wxRichTextBuffer
*) NULL
);
2195 virtual ~wxRichTextBufferDataObject();
2197 // after a call to this function, the buffer is owned by the caller and it
2198 // is responsible for deleting it
2199 wxRichTextBuffer
* GetRichTextBuffer();
2201 // Returns the id for the new data format
2202 static const wxChar
* GetRichTextBufferFormatId() { return ms_richTextBufferFormatId
; }
2204 // base class pure virtuals
2206 virtual wxDataFormat
GetPreferredFormat(Direction dir
) const;
2207 virtual size_t GetDataSize() const;
2208 virtual bool GetDataHere(void *pBuf
) const;
2209 virtual bool SetData(size_t len
, const void *buf
);
2213 virtual size_t GetDataSize(const wxDataFormat
&) const { return GetDataSize(); }
2214 virtual bool GetDataHere(const wxDataFormat
&, void *buf
) const { return GetDataHere(buf
); }
2215 virtual bool SetData(const wxDataFormat
&, size_t len
, const void *buf
) { return SetData(len
, buf
); }
2218 wxDataFormat m_formatRichTextBuffer
; // our custom format
2219 wxRichTextBuffer
* m_richTextBuffer
; // our data
2220 static const wxChar
* ms_richTextBufferFormatId
; // our format id
2226 * wxRichTextRenderer isolates common drawing functionality
2229 class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer
: public wxObject
2232 wxRichTextRenderer() {}
2233 virtual ~wxRichTextRenderer() {}
2235 /// Draw a standard bullet, as specified by the value of GetBulletName
2236 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
) = 0;
2238 /// Draw a bullet that can be described by text, such as numbered or symbol bullets
2239 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
, const wxString
& text
) = 0;
2241 /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
2242 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
) = 0;
2244 /// Enumerate the standard bullet names currently supported
2245 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
) = 0;
2249 * wxRichTextStdRenderer: standard renderer
2252 class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer
: public wxRichTextRenderer
2255 wxRichTextStdRenderer() {}
2257 /// Draw a standard bullet, as specified by the value of GetBulletName
2258 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
);
2260 /// Draw a bullet that can be described by text, such as numbered or symbol bullets
2261 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
, const wxString
& text
);
2263 /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
2264 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttrEx
& attr
, const wxRect
& rect
);
2266 /// Enumerate the standard bullet names currently supported
2267 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
);
2275 inline bool wxRichTextHasStyle(int flags
, int style
)
2277 return ((flags
& style
) == style
);
2280 /// Compare two attribute objects
2281 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxTextAttrEx
& attr1
, const wxTextAttrEx
& attr2
);
2282 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxTextAttr
& attr1
, const wxRichTextAttr
& attr2
);
2284 /// Compare two attribute objects, but take into account the flags
2285 /// specifying attributes of interest.
2286 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEqPartial(const wxTextAttrEx
& attr1
, const wxTextAttrEx
& attr2
, int flags
);
2287 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEqPartial(const wxTextAttrEx
& attr1
, const wxRichTextAttr
& attr2
, int flags
);
2289 /// Apply one style to another
2290 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxTextAttrEx
& destStyle
, const wxTextAttrEx
& style
);
2291 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxRichTextAttr
& destStyle
, const wxTextAttrEx
& style
);
2292 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxTextAttrEx
& destStyle
, const wxRichTextAttr
& style
, wxRichTextAttr
* compareWith
= NULL
);
2293 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxRichTextAttr
& destStyle
, const wxRichTextAttr
& style
, wxRichTextAttr
* compareWith
= NULL
);
2295 /// Combine two bitlists
2296 WXDLLIMPEXP_RICHTEXT
bool wxRichTextCombineBitlists(int& valueA
, int valueB
, int& flagsA
, int flagsB
);
2298 /// Compare two bitlists
2299 WXDLLIMPEXP_RICHTEXT
bool wxRichTextBitlistsEqPartial(int valueA
, int valueB
, int flags
);
2301 /// Split into paragraph and character styles
2302 WXDLLIMPEXP_RICHTEXT
bool wxRichTextSplitParaCharStyles(const wxTextAttrEx
& style
, wxTextAttrEx
& parStyle
, wxTextAttrEx
& charStyle
);
2305 WXDLLIMPEXP_RICHTEXT
bool wxRichTextTabsEq(const wxArrayInt
& tabs1
, const wxArrayInt
& tabs2
);
2307 /// Set the font without changing the font attributes
2308 WXDLLIMPEXP_RICHTEXT
void wxSetFontPreservingStyles(wxTextAttr
& attr
, const wxFont
& font
);
2310 /// Convert a decimal to Roman numerals
2311 WXDLLIMPEXP_RICHTEXT wxString
wxRichTextDecimalToRoman(long n
);
2313 WXDLLIMPEXP_RICHTEXT
void wxRichTextModuleInit();
2319 // _WX_RICHTEXTBUFFER_H_