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"
74 #define wxRichTextAttr wxTextAttr
75 #define wxTextAttrEx wxTextAttr
77 // Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a non-flashing
78 // cursor reliably without using wxClientDC in case there
79 // are platform-specific problems with the generic caret.
80 #define wxRICHTEXT_USE_OWN_CARET 0
82 // Switch off for binary compatibility, on for faster drawing
83 #define wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING 1
89 extern WXDLLIMPEXP_RICHTEXT
const wxChar wxRichTextLineBreakChar
;
94 enum wxRichTextFileType
96 wxRICHTEXT_TYPE_ANY
= 0,
105 * Forward declarations
108 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCtrl
;
109 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObject
;
110 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCacheObject
;
111 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObjectList
;
112 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextLine
;
113 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraph
;
114 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFileHandler
;
115 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleSheet
;
116 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextListStyleDefinition
;
117 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextEvent
;
118 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextRenderer
;
119 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextBuffer
;
122 * Flags determining the available space, passed to Layout
125 #define wxRICHTEXT_FIXED_WIDTH 0x01
126 #define wxRICHTEXT_FIXED_HEIGHT 0x02
127 #define wxRICHTEXT_VARIABLE_WIDTH 0x04
128 #define wxRICHTEXT_VARIABLE_HEIGHT 0x08
130 // Only lay out the part of the buffer that lies within
131 // the rect passed to Layout.
132 #define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10
135 * Flags to pass to Draw
138 // Ignore paragraph cache optimization, e.g. for printing purposes
139 // where one line may be drawn higher (on the next page) compared
140 // with the previous line
141 #define wxRICHTEXT_DRAW_IGNORE_CACHE 0x01
144 * Flags returned from hit-testing
147 // The point was not on this object
148 #define wxRICHTEXT_HITTEST_NONE 0x01
149 // The point was before the position returned from HitTest
150 #define wxRICHTEXT_HITTEST_BEFORE 0x02
151 // The point was after the position returned from HitTest
152 #define wxRICHTEXT_HITTEST_AFTER 0x04
153 // The point was on the position returned from HitTest
154 #define wxRICHTEXT_HITTEST_ON 0x08
155 // The point was on space outside content
156 #define wxRICHTEXT_HITTEST_OUTSIDE 0x10
159 * Flags for GetRangeSize
162 #define wxRICHTEXT_FORMATTED 0x01
163 #define wxRICHTEXT_UNFORMATTED 0x02
164 #define wxRICHTEXT_CACHE_SIZE 0x04
165 #define wxRICHTEXT_HEIGHT_ONLY 0x08
168 * Flags for SetStyle/SetListStyle
171 #define wxRICHTEXT_SETSTYLE_NONE 0x00
173 // Specifies that this operation should be undoable
174 #define wxRICHTEXT_SETSTYLE_WITH_UNDO 0x01
176 // Specifies that the style should not be applied if the
177 // combined style at this point is already the style in question.
178 #define wxRICHTEXT_SETSTYLE_OPTIMIZE 0x02
180 // Specifies that the style should only be applied to paragraphs,
181 // and not the content. This allows content styling to be
182 // preserved independently from that of e.g. a named paragraph style.
183 #define wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY 0x04
185 // Specifies that the style should only be applied to characters,
186 // and not the paragraph. This allows content styling to be
187 // preserved independently from that of e.g. a named paragraph style.
188 #define wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY 0x08
190 // For SetListStyle only: specifies starting from the given number, otherwise
191 // deduces number from existing attributes
192 #define wxRICHTEXT_SETSTYLE_RENUMBER 0x10
194 // For SetListStyle only: specifies the list level for all paragraphs, otherwise
195 // the current indentation will be used
196 #define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL 0x20
198 // Resets the existing style before applying the new style
199 #define wxRICHTEXT_SETSTYLE_RESET 0x40
201 // Removes the given style instead of applying it
202 #define wxRICHTEXT_SETSTYLE_REMOVE 0x80
205 * Flags for text insertion
208 #define wxRICHTEXT_INSERT_NONE 0x00
209 #define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE 0x01
210 #define wxRICHTEXT_INSERT_INTERACTIVE 0x02
212 // A special flag telling the buffer to keep the first paragraph style
213 // as-is, when deleting a paragraph marker. In future we might pass a
214 // flag to InsertFragment and DeleteRange to indicate the appropriate mode.
215 #define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x10000000
218 * Default superscript/subscript font multiplication factor
221 #define wxSCRIPT_MUL_FACTOR 1.5
224 * wxRichTextFontTable
225 * Manages quick access to a pool of fonts for rendering rich text
228 class WXDLLIMPEXP_RICHTEXT wxRichTextFontTable
: public wxObject
231 wxRichTextFontTable();
233 wxRichTextFontTable(const wxRichTextFontTable
& table
);
234 virtual ~wxRichTextFontTable();
236 bool IsOk() const { return m_refData
!= NULL
; }
238 wxFont
FindFont(const wxTextAttr
& fontSpec
);
241 void operator= (const wxRichTextFontTable
& table
);
242 bool operator == (const wxRichTextFontTable
& table
) const;
243 bool operator != (const wxRichTextFontTable
& table
) const { return !(*this == table
); }
247 DECLARE_DYNAMIC_CLASS(wxRichTextFontTable
)
251 * wxRichTextRange class declaration
252 * This stores beginning and end positions for a range of data.
253 * TODO: consider renaming wxTextRange and using for all text controls.
256 class WXDLLIMPEXP_RICHTEXT wxRichTextRange
261 wxRichTextRange() { m_start
= 0; m_end
= 0; }
262 wxRichTextRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
263 wxRichTextRange(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
264 ~wxRichTextRange() {}
266 void operator =(const wxRichTextRange
& range
) { m_start
= range
.m_start
; m_end
= range
.m_end
; }
267 bool operator ==(const wxRichTextRange
& range
) const { return (m_start
== range
.m_start
&& m_end
== range
.m_end
); }
268 bool operator !=(const wxRichTextRange
& range
) const { return (m_start
!= range
.m_start
&& m_end
!= range
.m_end
); }
269 wxRichTextRange
operator -(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
- range
.m_start
, m_end
- range
.m_end
); }
270 wxRichTextRange
operator +(const wxRichTextRange
& range
) const { return wxRichTextRange(m_start
+ range
.m_start
, m_end
+ range
.m_end
); }
272 void SetRange(long start
, long end
) { m_start
= start
; m_end
= end
; }
274 void SetStart(long start
) { m_start
= start
; }
275 long GetStart() const { return m_start
; }
277 void SetEnd(long end
) { m_end
= end
; }
278 long GetEnd() const { return m_end
; }
280 /// Returns true if this range is completely outside 'range'
281 bool IsOutside(const wxRichTextRange
& range
) const { return range
.m_start
> m_end
|| range
.m_end
< m_start
; }
283 /// Returns true if this range is completely within 'range'
284 bool IsWithin(const wxRichTextRange
& range
) const { return m_start
>= range
.m_start
&& m_end
<= range
.m_end
; }
286 /// Returns true if the given position is within this range. Allow
287 /// for the possibility of an empty range - assume the position
288 /// is within this empty range. NO, I think we should not match with an empty range.
289 // bool Contains(long pos) const { return pos >= m_start && (pos <= m_end || GetLength() == 0); }
290 bool Contains(long pos
) const { return pos
>= m_start
&& pos
<= m_end
; }
292 /// Limit this range to be within 'range'
293 bool LimitTo(const wxRichTextRange
& range
) ;
295 /// Gets the length of the range
296 long GetLength() const { return m_end
- m_start
+ 1; }
298 /// Swaps the start and end
299 void Swap() { long tmp
= m_start
; m_start
= m_end
; m_end
= tmp
; }
301 /// Convert to internal form: (n, n) is the range of a single character.
302 wxRichTextRange
ToInternal() const { return wxRichTextRange(m_start
, m_end
-1); }
304 /// Convert from internal to public API form: (n, n+1) is the range of a single character.
305 wxRichTextRange
FromInternal() const { return wxRichTextRange(m_start
, m_end
+1); }
312 #define wxRICHTEXT_ALL wxRichTextRange(-2, -2)
313 #define wxRICHTEXT_NONE wxRichTextRange(-1, -1)
316 * wxRichTextObject class declaration
317 * This is the base for drawable objects.
320 class WXDLLIMPEXP_RICHTEXT wxRichTextObject
: public wxObject
322 DECLARE_CLASS(wxRichTextObject
)
326 wxRichTextObject(wxRichTextObject
* parent
= NULL
);
327 virtual ~wxRichTextObject();
331 /// Draw the item, within the given range. Some objects may ignore the range (for
332 /// example paragraphs) while others must obey it (lines, to implement wrapping)
333 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
) = 0;
335 /// Lay the item out at the specified position with the given size constraint.
336 /// Layout must set the cached size.
337 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
) = 0;
339 /// Hit-testing: returns a flag indicating hit test details, plus
340 /// information about position
341 virtual int HitTest(wxDC
& WXUNUSED(dc
), const wxPoint
& WXUNUSED(pt
), long& WXUNUSED(textPosition
)) { return false; }
343 /// Finds the absolute position and row height for the given character position
344 virtual bool FindPosition(wxDC
& WXUNUSED(dc
), long WXUNUSED(index
), wxPoint
& WXUNUSED(pt
), int* WXUNUSED(height
), bool WXUNUSED(forceLineStart
)) { return false; }
346 /// Get the best size, i.e. the ideal starting size for this object irrespective
347 /// of available space. For a short text string, it will be the size that exactly encloses
348 /// the text. For a longer string, it might use the parent width for example.
349 virtual wxSize
GetBestSize() const { return m_size
; }
351 /// Get the object size for the given range. Returns false if the range
352 /// is invalid for this object.
353 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const = 0;
355 /// Do a split, returning an object containing the second part, and setting
356 /// the first part in 'this'.
357 virtual wxRichTextObject
* DoSplit(long WXUNUSED(pos
)) { return NULL
; }
359 /// Calculate range. By default, guess that the object is 1 unit long.
360 virtual void CalculateRange(long start
, long& end
) { end
= start
; m_range
.SetRange(start
, end
); }
363 virtual bool DeleteRange(const wxRichTextRange
& WXUNUSED(range
)) { return false; }
365 /// Returns true if the object is empty
366 virtual bool IsEmpty() const { return false; }
368 /// Get any text in this object for the given range
369 virtual wxString
GetTextForRange(const wxRichTextRange
& WXUNUSED(range
)) const { return wxEmptyString
; }
371 /// Returns true if this object can merge itself with the given one.
372 virtual bool CanMerge(wxRichTextObject
* WXUNUSED(object
)) const { return false; }
374 /// Returns true if this object merged itself with the given one.
375 /// The calling code will then delete the given object.
376 virtual bool Merge(wxRichTextObject
* WXUNUSED(object
)) { return false; }
378 /// Dump to output stream for debugging
379 virtual void Dump(wxTextOutputStream
& stream
);
383 /// Get/set the cached object size as calculated by Layout.
384 virtual wxSize
GetCachedSize() const { return m_size
; }
385 virtual void SetCachedSize(const wxSize
& sz
) { m_size
= sz
; }
387 /// Get/set the object position
388 virtual wxPoint
GetPosition() const { return m_pos
; }
389 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
391 /// Get the rectangle enclosing the object
392 virtual wxRect
GetRect() const { return wxRect(GetPosition(), GetCachedSize()); }
395 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
398 const wxRichTextRange
& GetRange() const { return m_range
; }
399 wxRichTextRange
& GetRange() { return m_range
; }
401 /// Get/set dirty flag (whether the object needs Layout to be called)
402 virtual bool GetDirty() const { return m_dirty
; }
403 virtual void SetDirty(bool dirty
) { m_dirty
= dirty
; }
405 /// Is this composite?
406 virtual bool IsComposite() const { return false; }
408 /// Get/set the parent.
409 virtual wxRichTextObject
* GetParent() const { return m_parent
; }
410 virtual void SetParent(wxRichTextObject
* parent
) { m_parent
= parent
; }
412 /// Set the margin around the object
413 virtual void SetMargins(int margin
);
414 virtual void SetMargins(int leftMargin
, int rightMargin
, int topMargin
, int bottomMargin
);
415 virtual int GetLeftMargin() const { return m_leftMargin
; }
416 virtual int GetRightMargin() const { return m_rightMargin
; }
417 virtual int GetTopMargin() const { return m_topMargin
; }
418 virtual int GetBottomMargin() const { return m_bottomMargin
; }
420 /// Set attributes object
421 void SetAttributes(const wxTextAttr
& attr
) { m_attributes
= attr
; }
422 const wxTextAttr
& GetAttributes() const { return m_attributes
; }
423 wxTextAttr
& GetAttributes() { return m_attributes
; }
425 /// Set/get stored descent
426 void SetDescent(int descent
) { m_descent
= descent
; }
427 int GetDescent() const { return m_descent
; }
429 /// Gets the containing buffer
430 wxRichTextBuffer
* GetBuffer() const;
435 virtual wxRichTextObject
* Clone() const { return NULL
; }
438 void Copy(const wxRichTextObject
& obj
);
440 /// Reference-counting allows us to use the same object in multiple
441 /// lists (not yet used)
442 void Reference() { m_refCount
++; }
445 /// Convert units in tenths of a millimetre to device units
446 int ConvertTenthsMMToPixels(wxDC
& dc
, int units
);
447 static int ConvertTenthsMMToPixels(int ppi
, int units
);
452 int m_descent
; // Descent for this object (if any)
455 wxRichTextObject
* m_parent
;
457 /// The range of this object (start position to end position)
458 wxRichTextRange m_range
;
467 wxTextAttr m_attributes
;
470 WX_DECLARE_LIST_WITH_DECL( wxRichTextObject
, wxRichTextObjectList
, class WXDLLIMPEXP_RICHTEXT
);
473 * wxRichTextCompositeObject class declaration
474 * Objects of this class can contain other objects.
477 class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject
: public wxRichTextObject
479 DECLARE_CLASS(wxRichTextCompositeObject
)
483 wxRichTextCompositeObject(wxRichTextObject
* parent
= NULL
);
484 virtual ~wxRichTextCompositeObject();
488 /// Hit-testing: returns a flag indicating hit test details, plus
489 /// information about position
490 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
);
492 /// Finds the absolute position and row height for the given character position
493 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
496 virtual void CalculateRange(long start
, long& end
);
499 virtual bool DeleteRange(const wxRichTextRange
& range
);
501 /// Get any text in this object for the given range
502 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
504 /// Dump to output stream for debugging
505 virtual void Dump(wxTextOutputStream
& stream
);
510 wxRichTextObjectList
& GetChildren() { return m_children
; }
511 const wxRichTextObjectList
& GetChildren() const { return m_children
; }
513 /// Get the child count
514 size_t GetChildCount() const ;
516 /// Get the nth child
517 wxRichTextObject
* GetChild(size_t n
) const ;
519 /// Get/set dirty flag
520 virtual bool GetDirty() const { return m_dirty
; }
521 virtual void SetDirty(bool dirty
) { m_dirty
= dirty
; }
523 /// Is this composite?
524 virtual bool IsComposite() const { return true; }
526 /// Returns true if the buffer is empty
527 virtual bool IsEmpty() const { return GetChildCount() == 0; }
532 void Copy(const wxRichTextCompositeObject
& obj
);
535 void operator= (const wxRichTextCompositeObject
& obj
) { Copy(obj
); }
537 /// Append a child, returning the position
538 size_t AppendChild(wxRichTextObject
* child
) ;
540 /// Insert the child in front of the given object, or at the beginning
541 bool InsertChild(wxRichTextObject
* child
, wxRichTextObject
* inFrontOf
) ;
544 bool RemoveChild(wxRichTextObject
* child
, bool deleteChild
= false) ;
546 /// Delete all children
547 bool DeleteChildren() ;
549 /// Recursively merge all pieces that can be merged.
550 bool Defragment(const wxRichTextRange
& range
= wxRICHTEXT_ALL
);
553 wxRichTextObjectList m_children
;
557 * wxRichTextBox class declaration
558 * This defines a 2D space to lay out objects
561 class WXDLLIMPEXP_RICHTEXT wxRichTextBox
: public wxRichTextCompositeObject
563 DECLARE_DYNAMIC_CLASS(wxRichTextBox
)
567 wxRichTextBox(wxRichTextObject
* parent
= NULL
);
568 wxRichTextBox(const wxRichTextBox
& obj
): wxRichTextCompositeObject() { Copy(obj
); }
573 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
576 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
578 /// Get/set the object size for the given range. Returns false if the range
579 /// is invalid for this object.
580 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
587 virtual wxRichTextObject
* Clone() const { return new wxRichTextBox(*this); }
590 void Copy(const wxRichTextBox
& obj
);
596 * wxRichTextParagraphBox class declaration
597 * This box knows how to lay out paragraphs.
600 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphLayoutBox
: public wxRichTextBox
602 DECLARE_DYNAMIC_CLASS(wxRichTextParagraphLayoutBox
)
606 wxRichTextParagraphLayoutBox(wxRichTextObject
* parent
= NULL
);
607 wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox
& obj
): wxRichTextBox() { Init(); Copy(obj
); }
612 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
615 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
617 /// Get/set the object size for the given range. Returns false if the range
618 /// is invalid for this object.
619 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
622 virtual bool DeleteRange(const wxRichTextRange
& range
);
624 /// Get any text in this object for the given range
625 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
629 /// Associate a control with the buffer, for operations that for example require refreshing the window.
630 void SetRichTextCtrl(wxRichTextCtrl
* ctrl
) { m_ctrl
= ctrl
; }
632 /// Get the associated control.
633 wxRichTextCtrl
* GetRichTextCtrl() const { return m_ctrl
; }
635 /// Get/set whether the last paragraph is partial or complete
636 void SetPartialParagraph(bool partialPara
) { m_partialParagraph
= partialPara
; }
637 bool GetPartialParagraph() const { return m_partialParagraph
; }
639 /// If this is a buffer, returns the current style sheet. The base layout box
640 /// class doesn't have an associated style sheet.
641 virtual wxRichTextStyleSheet
* GetStyleSheet() const { return NULL
; }
645 /// Initialize the object.
648 /// Clear all children
649 virtual void Clear();
651 /// Clear and initialize with one blank paragraph
652 virtual void Reset();
654 /// Convenience function to add a paragraph of text
655 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxTextAttr
* paraStyle
= NULL
);
657 /// Convenience function to add an image
658 virtual wxRichTextRange
AddImage(const wxImage
& image
, wxTextAttr
* paraStyle
= NULL
);
660 /// Adds multiple paragraphs, based on newlines.
661 virtual wxRichTextRange
AddParagraphs(const wxString
& text
, wxTextAttr
* paraStyle
= NULL
);
663 /// Get the line at the given position. If caretPosition is true, the position is
664 /// a caret position, which is normally a smaller number.
665 virtual wxRichTextLine
* GetLineAtPosition(long pos
, bool caretPosition
= false) const;
667 /// Get the line at the given y pixel position, or the last line.
668 virtual wxRichTextLine
* GetLineAtYPosition(int y
) const;
670 /// Get the paragraph at the given character or caret position
671 virtual wxRichTextParagraph
* GetParagraphAtPosition(long pos
, bool caretPosition
= false) const;
673 /// Get the line size at the given position
674 virtual wxSize
GetLineSizeAtPosition(long pos
, bool caretPosition
= false) const;
676 /// Given a position, get the number of the visible line (potentially many to a paragraph),
677 /// starting from zero at the start of the buffer. We also have to pass a bool (startOfLine)
678 /// that indicates whether the caret is being shown at the end of the previous line or at the start
679 /// of the next, since the caret can be shown at 2 visible positions for the same underlying
681 virtual long GetVisibleLineNumber(long pos
, bool caretPosition
= false, bool startOfLine
= false) const;
683 /// Given a line number, get the corresponding wxRichTextLine object.
684 virtual wxRichTextLine
* GetLineForVisibleLineNumber(long lineNumber
) const;
686 /// Get the leaf object in a paragraph at this position.
687 /// Given a line number, get the corresponding wxRichTextLine object.
688 virtual wxRichTextObject
* GetLeafObjectAtPosition(long position
) const;
690 /// Get the paragraph by number
691 virtual wxRichTextParagraph
* GetParagraphAtLine(long paragraphNumber
) const;
693 /// Get the paragraph for a given line
694 virtual wxRichTextParagraph
* GetParagraphForLine(wxRichTextLine
* line
) const;
696 /// Get the length of the paragraph
697 virtual int GetParagraphLength(long paragraphNumber
) const;
699 /// Get the number of paragraphs
700 virtual int GetParagraphCount() const { return GetChildCount(); }
702 /// Get the number of visible lines
703 virtual int GetLineCount() const;
705 /// Get the text of the paragraph
706 virtual wxString
GetParagraphText(long paragraphNumber
) const;
708 /// Convert zero-based line column and paragraph number to a position.
709 virtual long XYToPosition(long x
, long y
) const;
711 /// Convert zero-based position to line column and paragraph number
712 virtual bool PositionToXY(long pos
, long* x
, long* y
) const;
714 /// Set text attributes: character and/or paragraph styles.
715 virtual bool SetStyle(const wxRichTextRange
& range
, const wxTextAttr
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
717 /// Get the conbined text attributes for this position.
718 virtual bool GetStyle(long position
, wxTextAttr
& style
);
720 /// Get the content (uncombined) attributes for this position.
721 virtual bool GetUncombinedStyle(long position
, wxTextAttr
& style
);
723 /// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and
724 /// context attributes.
725 virtual bool DoGetStyle(long position
, wxTextAttr
& style
, bool combineStyles
= true);
727 /// Get the combined style for a range - if any attribute is different within the range,
728 /// that attribute is not present within the flags
729 virtual bool GetStyleForRange(const wxRichTextRange
& range
, wxTextAttr
& style
);
731 /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
733 bool CollectStyle(wxTextAttr
& currentStyle
, const wxTextAttr
& style
, long& multipleStyleAttributes
, int& multipleTextEffectAttributes
);
736 virtual bool SetListStyle(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
737 virtual bool SetListStyle(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
739 /// Clear list for given range
740 virtual bool ClearListStyle(const wxRichTextRange
& range
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
742 /// Number/renumber any list elements in the given range.
743 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
744 virtual bool NumberList(const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
745 virtual bool NumberList(const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int startFrom
= 1, int specifiedLevel
= -1);
747 /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1
748 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
749 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, wxRichTextListStyleDefinition
* def
= NULL
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
750 virtual bool PromoteList(int promoteBy
, const wxRichTextRange
& range
, const wxString
& defName
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
, int specifiedLevel
= -1);
752 /// Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously
753 /// def/defName can be NULL/empty to indicate that the existing list style should be used.
754 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);
756 /// Fills in the attributes for numbering a paragraph after previousParagraph.
757 virtual bool FindNextParagraphNumber(wxRichTextParagraph
* previousParagraph
, wxTextAttr
& attr
) const;
759 /// Test if this whole range has character attributes of the specified kind. If any
760 /// of the attributes are different within the range, the test fails. You
761 /// can use this to implement, for example, bold button updating. style must have
762 /// flags indicating which attributes are of interest.
763 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxTextAttr
& style
) const;
765 /// Test if this whole range has paragraph attributes of the specified kind. If any
766 /// of the attributes are different within the range, the test fails. You
767 /// can use this to implement, for example, centering button updating. style must have
768 /// flags indicating which attributes are of interest.
769 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxTextAttr
& style
) const;
772 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraphLayoutBox(*this); }
774 /// Insert fragment into this box at the given position. If partialParagraph is true,
775 /// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
777 virtual bool InsertFragment(long position
, wxRichTextParagraphLayoutBox
& fragment
);
779 /// Make a copy of the fragment corresponding to the given range, putting it in 'fragment'.
780 virtual bool CopyFragment(const wxRichTextRange
& range
, wxRichTextParagraphLayoutBox
& fragment
);
782 /// Apply the style sheet to the buffer, for example if the styles have changed.
783 virtual bool ApplyStyleSheet(wxRichTextStyleSheet
* styleSheet
);
786 void Copy(const wxRichTextParagraphLayoutBox
& obj
);
789 void operator= (const wxRichTextParagraphLayoutBox
& obj
) { Copy(obj
); }
792 virtual void UpdateRanges() { long end
; CalculateRange(0, end
); }
795 virtual wxString
GetText() const;
797 /// Set default style for new content. Setting it to a default attribute
798 /// makes new content take on the 'basic' style.
799 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
801 /// Get default style
802 virtual const wxTextAttr
& GetDefaultStyle() const { return m_defaultAttributes
; }
804 /// Set basic (overall) style
805 virtual void SetBasicStyle(const wxTextAttr
& style
) { m_attributes
= style
; }
807 /// Get basic (overall) style
808 virtual const wxTextAttr
& GetBasicStyle() const { return m_attributes
; }
810 /// Invalidate the buffer. With no argument, invalidates whole buffer.
811 void Invalidate(const wxRichTextRange
& invalidRange
= wxRICHTEXT_ALL
);
813 /// Get invalid range, rounding to entire paragraphs if argument is true.
814 wxRichTextRange
GetInvalidRange(bool wholeParagraphs
= false) const;
817 wxRichTextCtrl
* m_ctrl
;
818 wxTextAttr m_defaultAttributes
;
820 /// The invalidated range that will need full layout
821 wxRichTextRange m_invalidRange
;
823 // Is the last paragraph partial or complete?
824 bool m_partialParagraph
;
828 * wxRichTextLine class declaration
829 * This object represents a line in a paragraph, and stores
830 * offsets from the start of the paragraph representing the
831 * start and end positions of the line.
834 class WXDLLIMPEXP_RICHTEXT wxRichTextLine
839 wxRichTextLine(wxRichTextParagraph
* parent
);
840 wxRichTextLine(const wxRichTextLine
& obj
) { Init( NULL
); Copy(obj
); }
841 virtual ~wxRichTextLine() {}
848 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
849 void SetRange(long from
, long to
) { m_range
= wxRichTextRange(from
, to
); }
851 /// Get the parent paragraph
852 wxRichTextParagraph
* GetParent() { return m_parent
; }
855 const wxRichTextRange
& GetRange() const { return m_range
; }
856 wxRichTextRange
& GetRange() { return m_range
; }
858 /// Get the absolute range
859 wxRichTextRange
GetAbsoluteRange() const;
861 /// Get/set the line size as calculated by Layout.
862 virtual wxSize
GetSize() const { return m_size
; }
863 virtual void SetSize(const wxSize
& sz
) { m_size
= sz
; }
865 /// Get/set the object position relative to the parent
866 virtual wxPoint
GetPosition() const { return m_pos
; }
867 virtual void SetPosition(const wxPoint
& pos
) { m_pos
= pos
; }
869 /// Get the absolute object position
870 virtual wxPoint
GetAbsolutePosition() const;
872 /// Get the rectangle enclosing the line
873 virtual wxRect
GetRect() const { return wxRect(GetAbsolutePosition(), GetSize()); }
875 /// Set/get stored descent
876 void SetDescent(int descent
) { m_descent
= descent
; }
877 int GetDescent() const { return m_descent
; }
879 #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING
880 wxArrayInt
& GetObjectSizes() { return m_objectSizes
; }
881 const wxArrayInt
& GetObjectSizes() const { return m_objectSizes
; }
887 void Init(wxRichTextParagraph
* parent
);
890 void Copy(const wxRichTextLine
& obj
);
893 virtual wxRichTextLine
* Clone() const { return new wxRichTextLine(*this); }
897 /// The range of the line (start position to end position)
898 /// This is relative to the parent paragraph.
899 wxRichTextRange m_range
;
901 /// Size and position measured relative to top of paragraph
905 /// Maximum descent for this line (location of text baseline)
909 wxRichTextParagraph
* m_parent
;
911 #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING
912 wxArrayInt m_objectSizes
;
916 WX_DECLARE_LIST_WITH_DECL( wxRichTextLine
, wxRichTextLineList
, class WXDLLIMPEXP_RICHTEXT
);
919 * wxRichTextParagraph class declaration
920 * This object represents a single paragraph (or in a straight text editor, a line).
923 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph
: public wxRichTextBox
925 DECLARE_DYNAMIC_CLASS(wxRichTextParagraph
)
929 wxRichTextParagraph(wxRichTextObject
* parent
= NULL
, wxTextAttr
* style
= NULL
);
930 wxRichTextParagraph(const wxString
& text
, wxRichTextObject
* parent
= NULL
, wxTextAttr
* paraStyle
= NULL
, wxTextAttr
* charStyle
= NULL
);
931 virtual ~wxRichTextParagraph();
932 wxRichTextParagraph(const wxRichTextParagraph
& obj
): wxRichTextBox() { Copy(obj
); }
937 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
940 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
942 /// Get/set the object size for the given range. Returns false if the range
943 /// is invalid for this object.
944 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
946 /// Finds the absolute position and row height for the given character position
947 virtual bool FindPosition(wxDC
& dc
, long index
, wxPoint
& pt
, int* height
, bool forceLineStart
);
949 /// Hit-testing: returns a flag indicating hit test details, plus
950 /// information about position
951 virtual int HitTest(wxDC
& dc
, const wxPoint
& pt
, long& textPosition
);
954 virtual void CalculateRange(long start
, long& end
);
958 /// Get the cached lines
959 wxRichTextLineList
& GetLines() { return m_cachedLines
; }
964 void Copy(const wxRichTextParagraph
& obj
);
967 virtual wxRichTextObject
* Clone() const { return new wxRichTextParagraph(*this); }
969 /// Clear the cached lines
974 /// Apply paragraph styles such as centering to the wrapped lines
975 virtual void ApplyParagraphStyle(const wxTextAttr
& attr
, const wxRect
& rect
);
977 /// Insert text at the given position
978 virtual bool InsertText(long pos
, const wxString
& text
);
980 /// Split an object at this position if necessary, and return
981 /// the previous object, or NULL if inserting at beginning.
982 virtual wxRichTextObject
* SplitAt(long pos
, wxRichTextObject
** previousObject
= NULL
);
984 /// Move content to a list from this point
985 virtual void MoveToList(wxRichTextObject
* obj
, wxList
& list
);
987 /// Add content back from list
988 virtual void MoveFromList(wxList
& list
);
990 /// Get the plain text searching from the start or end of the range.
991 /// The resulting string may be shorter than the range given.
992 bool GetContiguousPlainText(wxString
& text
, const wxRichTextRange
& range
, bool fromStart
= true);
994 /// Find a suitable wrap position. wrapPosition is the last position in the line to the left
996 bool FindWrapPosition(const wxRichTextRange
& range
, wxDC
& dc
, int availableSpace
, long& wrapPosition
, wxArrayInt
* partialExtents
);
998 /// Find the object at the given position
999 wxRichTextObject
* FindObjectAtPosition(long position
);
1001 /// Get the bullet text for this paragraph.
1002 wxString
GetBulletText();
1004 /// Allocate or reuse a line object
1005 wxRichTextLine
* AllocateLine(int pos
);
1007 /// Clear remaining unused line objects, if any
1008 bool ClearUnusedLines(int lineCount
);
1010 /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically
1011 /// retrieve the actual style.
1012 wxTextAttr
GetCombinedAttributes(const wxTextAttr
& contentStyle
) const;
1014 /// Get combined attributes of the base style and paragraph style.
1015 wxTextAttr
GetCombinedAttributes() const;
1017 /// Get the first position from pos that has a line break character.
1018 long GetFirstLineBreakPosition(long pos
);
1020 /// Create default tabstop array
1021 static void InitDefaultTabs();
1023 /// Clear default tabstop array
1024 static void ClearDefaultTabs();
1026 /// Get default tabstop array
1027 static const wxArrayInt
& GetDefaultTabs() { return sm_defaultTabs
; }
1030 /// The lines that make up the wrapped paragraph
1031 wxRichTextLineList m_cachedLines
;
1033 /// Default tabstops
1034 static wxArrayInt sm_defaultTabs
;
1038 * wxRichTextPlainText class declaration
1039 * This object represents a single piece of text.
1042 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText
: public wxRichTextObject
1044 DECLARE_DYNAMIC_CLASS(wxRichTextPlainText
)
1048 wxRichTextPlainText(const wxString
& text
= wxEmptyString
, wxRichTextObject
* parent
= NULL
, wxTextAttr
* style
= NULL
);
1049 wxRichTextPlainText(const wxRichTextPlainText
& obj
): wxRichTextObject() { Copy(obj
); }
1054 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
1056 /// Lay the item out
1057 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
1059 /// Get/set the object size for the given range. Returns false if the range
1060 /// is invalid for this object.
1061 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
1063 /// Get any text in this object for the given range
1064 virtual wxString
GetTextForRange(const wxRichTextRange
& range
) const;
1066 /// Do a split, returning an object containing the second part, and setting
1067 /// the first part in 'this'.
1068 virtual wxRichTextObject
* DoSplit(long pos
);
1071 virtual void CalculateRange(long start
, long& end
);
1074 virtual bool DeleteRange(const wxRichTextRange
& range
);
1076 /// Returns true if the object is empty
1077 virtual bool IsEmpty() const { return m_text
.empty(); }
1079 /// Returns true if this object can merge itself with the given one.
1080 virtual bool CanMerge(wxRichTextObject
* object
) const;
1082 /// Returns true if this object merged itself with the given one.
1083 /// The calling code will then delete the given object.
1084 virtual bool Merge(wxRichTextObject
* object
);
1086 /// Dump to output stream for debugging
1087 virtual void Dump(wxTextOutputStream
& stream
);
1089 /// Get the first position from pos that has a line break character.
1090 long GetFirstLineBreakPosition(long pos
);
1095 const wxString
& GetText() const { return m_text
; }
1098 void SetText(const wxString
& text
) { m_text
= text
; }
1103 void Copy(const wxRichTextPlainText
& obj
);
1106 virtual wxRichTextObject
* Clone() const { return new wxRichTextPlainText(*this); }
1108 bool DrawTabbedString(wxDC
& dc
, const wxTextAttr
& attr
, const wxRect
& rect
, wxString
& str
, wxCoord
& x
, wxCoord
& y
, bool selected
);
1115 * wxRichTextImageBlock stores information about an image, in binary in-memory form
1118 class WXDLLIMPEXP_FWD_BASE wxDataInputStream
;
1119 class WXDLLIMPEXP_FWD_BASE wxDataOutputStream
;
1121 class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock
: public wxObject
1124 wxRichTextImageBlock();
1125 wxRichTextImageBlock(const wxRichTextImageBlock
& block
);
1126 virtual ~wxRichTextImageBlock();
1131 // Load the original image into a memory block.
1132 // If the image is not a JPEG, we must convert it into a JPEG
1133 // to conserve space.
1134 // If it's not a JPEG we can make use of 'image', already scaled, so we don't have to
1135 // load the image a 2nd time.
1136 virtual bool MakeImageBlock(const wxString
& filename
, wxBitmapType imageType
,
1137 wxImage
& image
, bool convertToJPEG
= true);
1139 // Make an image block from the wxImage in the given
1141 virtual bool MakeImageBlock(wxImage
& image
, wxBitmapType imageType
, int quality
= 80);
1144 bool Write(const wxString
& filename
);
1146 // Write data in hex to a stream
1147 bool WriteHex(wxOutputStream
& stream
);
1149 // Read data in hex from a stream
1150 bool ReadHex(wxInputStream
& stream
, int length
, wxBitmapType imageType
);
1152 // Copy from 'block'
1153 void Copy(const wxRichTextImageBlock
& block
);
1155 // Load a wxImage from the block
1156 bool Load(wxImage
& image
);
1159 void operator=(const wxRichTextImageBlock
& block
);
1163 unsigned char* GetData() const { return m_data
; }
1164 size_t GetDataSize() const { return m_dataSize
; }
1165 wxBitmapType
GetImageType() const { return m_imageType
; }
1167 void SetData(unsigned char* image
) { m_data
= image
; }
1168 void SetDataSize(size_t size
) { m_dataSize
= size
; }
1169 void SetImageType(wxBitmapType imageType
) { m_imageType
= imageType
; }
1171 bool Ok() const { return IsOk(); }
1172 bool IsOk() const { return GetData() != NULL
; }
1174 // Gets the extension for the block's type
1175 wxString
GetExtension() const;
1179 // Allocate and read from stream as a block of memory
1180 static unsigned char* ReadBlock(wxInputStream
& stream
, size_t size
);
1181 static unsigned char* ReadBlock(const wxString
& filename
, size_t size
);
1183 // Write memory block to stream
1184 static bool WriteBlock(wxOutputStream
& stream
, unsigned char* block
, size_t size
);
1186 // Write memory block to file
1187 static bool WriteBlock(const wxString
& filename
, unsigned char* block
, size_t size
);
1190 // Size in bytes of the image stored.
1191 // This is in the raw, original form such as a JPEG file.
1192 unsigned char* m_data
;
1194 wxBitmapType m_imageType
;
1199 * wxRichTextImage class declaration
1200 * This object represents an image.
1203 class WXDLLIMPEXP_RICHTEXT wxRichTextImage
: public wxRichTextObject
1205 DECLARE_DYNAMIC_CLASS(wxRichTextImage
)
1209 wxRichTextImage(wxRichTextObject
* parent
= NULL
): wxRichTextObject(parent
) { }
1210 wxRichTextImage(const wxImage
& image
, wxRichTextObject
* parent
= NULL
, wxTextAttr
* charStyle
= NULL
);
1211 wxRichTextImage(const wxRichTextImageBlock
& imageBlock
, wxRichTextObject
* parent
= NULL
, wxTextAttr
* charStyle
= NULL
);
1212 wxRichTextImage(const wxRichTextImage
& obj
): wxRichTextObject() { Copy(obj
); }
1217 virtual bool Draw(wxDC
& dc
, const wxRichTextRange
& range
, const wxRichTextRange
& selectionRange
, const wxRect
& rect
, int descent
, int style
);
1219 /// Lay the item out
1220 virtual bool Layout(wxDC
& dc
, const wxRect
& rect
, int style
);
1222 /// Get the object size for the given range. Returns false if the range
1223 /// is invalid for this object.
1224 virtual bool GetRangeSize(const wxRichTextRange
& range
, wxSize
& size
, int& descent
, wxDC
& dc
, int flags
, wxPoint position
= wxPoint(0,0), wxArrayInt
* partialExtents
= NULL
) const;
1226 /// Returns true if the object is empty
1227 virtual bool IsEmpty() const { return !m_image
.Ok(); }
1232 const wxImage
& GetImage() const { return m_image
; }
1235 void SetImage(const wxImage
& image
) { m_image
= image
; }
1237 /// Get the image block containing the raw data
1238 wxRichTextImageBlock
& GetImageBlock() { return m_imageBlock
; }
1243 void Copy(const wxRichTextImage
& obj
);
1246 virtual wxRichTextObject
* Clone() const { return new wxRichTextImage(*this); }
1248 /// Load wxImage from the block
1249 virtual bool LoadFromBlock();
1251 /// Make block from the wxImage
1252 virtual bool MakeBlock();
1255 // TODO: reduce the multiple representations of data
1258 wxRichTextImageBlock m_imageBlock
;
1263 * wxRichTextBuffer class declaration
1264 * This is a kind of box, used to represent the whole buffer
1267 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCommand
;
1268 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction
;
1270 class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer
: public wxRichTextParagraphLayoutBox
1272 DECLARE_DYNAMIC_CLASS(wxRichTextBuffer
)
1276 wxRichTextBuffer() { Init(); }
1277 wxRichTextBuffer(const wxRichTextBuffer
& obj
): wxRichTextParagraphLayoutBox() { Init(); Copy(obj
); }
1278 virtual ~wxRichTextBuffer() ;
1282 /// Gets the command processor
1283 wxCommandProcessor
* GetCommandProcessor() const { return m_commandProcessor
; }
1285 /// Set style sheet, if any.
1286 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
) { m_styleSheet
= styleSheet
; }
1287 virtual wxRichTextStyleSheet
* GetStyleSheet() const { return m_styleSheet
; }
1289 /// Set style sheet and notify of the change
1290 bool SetStyleSheetAndNotify(wxRichTextStyleSheet
* sheet
);
1292 /// Push style sheet to top of stack
1293 bool PushStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1295 /// Pop style sheet from top of stack
1296 wxRichTextStyleSheet
* PopStyleSheet();
1298 /// Set/get table storing fonts
1299 wxRichTextFontTable
& GetFontTable() { return m_fontTable
; }
1300 const wxRichTextFontTable
& GetFontTable() const { return m_fontTable
; }
1301 void SetFontTable(const wxRichTextFontTable
& table
) { m_fontTable
= table
; }
1308 /// Clears the buffer, adds an empty paragraph, and clears the command processor.
1309 virtual void ResetAndClearCommands();
1312 virtual bool LoadFile(const wxString
& filename
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
1315 virtual bool SaveFile(const wxString
& filename
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
1317 /// Load from a stream
1318 virtual bool LoadFile(wxInputStream
& stream
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
1320 /// Save to a stream
1321 virtual bool SaveFile(wxOutputStream
& stream
, wxRichTextFileType type
= wxRICHTEXT_TYPE_ANY
);
1323 /// Set the handler flags, controlling loading and saving
1324 void SetHandlerFlags(int flags
) { m_handlerFlags
= flags
; }
1326 /// Get the handler flags, controlling loading and saving
1327 int GetHandlerFlags() const { return m_handlerFlags
; }
1329 /// Convenience function to add a paragraph of text
1330 virtual wxRichTextRange
AddParagraph(const wxString
& text
, wxTextAttr
* paraStyle
= NULL
) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text
, paraStyle
); }
1332 /// Begin collapsing undo/redo commands. Note that this may not work properly
1333 /// if combining commands that delete or insert content, changing ranges for
1334 /// subsequent actions.
1335 virtual bool BeginBatchUndo(const wxString
& cmdName
);
1337 /// End collapsing undo/redo commands
1338 virtual bool EndBatchUndo();
1340 /// Collapsing commands?
1341 virtual bool BatchingUndo() const { return m_batchedCommandDepth
> 0; }
1343 /// Submit immediately, or delay according to whether collapsing is on
1344 virtual bool SubmitAction(wxRichTextAction
* action
);
1346 /// Get collapsed command
1347 virtual wxRichTextCommand
* GetBatchedCommand() const { return m_batchedCommand
; }
1349 /// Begin suppressing undo/redo commands. The way undo is suppressed may be implemented
1350 /// differently by each command. If not dealt with by a command implementation, then
1351 /// it will be implemented automatically by not storing the command in the undo history
1352 /// when the action is submitted to the command processor.
1353 virtual bool BeginSuppressUndo();
1355 /// End suppressing undo/redo commands.
1356 virtual bool EndSuppressUndo();
1358 /// Collapsing commands?
1359 virtual bool SuppressingUndo() const { return m_suppressUndo
> 0; }
1361 /// Copy the range to the clipboard
1362 virtual bool CopyToClipboard(const wxRichTextRange
& range
);
1364 /// Paste the clipboard content to the buffer
1365 virtual bool PasteFromClipboard(long position
);
1367 /// Can we paste from the clipboard?
1368 virtual bool CanPasteFromClipboard() const;
1370 /// Begin using a style
1371 virtual bool BeginStyle(const wxTextAttr
& style
);
1374 virtual bool EndStyle();
1377 virtual bool EndAllStyles();
1379 /// Clear the style stack
1380 virtual void ClearStyleStack();
1382 /// Get the size of the style stack, for example to check correct nesting
1383 virtual size_t GetStyleStackSize() const { return m_attributeStack
.GetCount(); }
1385 /// Begin using bold
1389 bool EndBold() { return EndStyle(); }
1391 /// Begin using italic
1394 /// End using italic
1395 bool EndItalic() { return EndStyle(); }
1397 /// Begin using underline
1398 bool BeginUnderline();
1400 /// End using underline
1401 bool EndUnderline() { return EndStyle(); }
1403 /// Begin using point size
1404 bool BeginFontSize(int pointSize
);
1406 /// End using point size
1407 bool EndFontSize() { return EndStyle(); }
1409 /// Begin using this font
1410 bool BeginFont(const wxFont
& font
);
1412 /// End using a font
1413 bool EndFont() { return EndStyle(); }
1415 /// Begin using this colour
1416 bool BeginTextColour(const wxColour
& colour
);
1418 /// End using a colour
1419 bool EndTextColour() { return EndStyle(); }
1421 /// Begin using alignment
1422 bool BeginAlignment(wxTextAttrAlignment alignment
);
1425 bool EndAlignment() { return EndStyle(); }
1427 /// Begin left indent
1428 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
1431 bool EndLeftIndent() { return EndStyle(); }
1433 /// Begin right indent
1434 bool BeginRightIndent(int rightIndent
);
1436 /// End right indent
1437 bool EndRightIndent() { return EndStyle(); }
1439 /// Begin paragraph spacing
1440 bool BeginParagraphSpacing(int before
, int after
);
1442 /// End paragraph spacing
1443 bool EndParagraphSpacing() { return EndStyle(); }
1445 /// Begin line spacing
1446 bool BeginLineSpacing(int lineSpacing
);
1448 /// End line spacing
1449 bool EndLineSpacing() { return EndStyle(); }
1451 /// Begin numbered bullet
1452 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
1454 /// End numbered bullet
1455 bool EndNumberedBullet() { return EndStyle(); }
1457 /// Begin symbol bullet
1458 bool BeginSymbolBullet(const wxString
& symbol
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
1460 /// End symbol bullet
1461 bool EndSymbolBullet() { return EndStyle(); }
1463 /// Begin standard bullet
1464 bool BeginStandardBullet(const wxString
& bulletName
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_STANDARD
);
1466 /// End standard bullet
1467 bool EndStandardBullet() { return EndStyle(); }
1469 /// Begin named character style
1470 bool BeginCharacterStyle(const wxString
& characterStyle
);
1472 /// End named character style
1473 bool EndCharacterStyle() { return EndStyle(); }
1475 /// Begin named paragraph style
1476 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
1478 /// End named character style
1479 bool EndParagraphStyle() { return EndStyle(); }
1481 /// Begin named list style
1482 bool BeginListStyle(const wxString
& listStyle
, int level
= 1, int number
= 1);
1484 /// End named character style
1485 bool EndListStyle() { return EndStyle(); }
1488 bool BeginURL(const wxString
& url
, const wxString
& characterStyle
= wxEmptyString
);
1491 bool EndURL() { return EndStyle(); }
1495 /// Add an event handler
1496 bool AddEventHandler(wxEvtHandler
* handler
);
1498 /// Remove an event handler
1499 bool RemoveEventHandler(wxEvtHandler
* handler
, bool deleteHandler
= false);
1501 /// Clear event handlers
1502 void ClearEventHandlers();
1504 /// Send event to event handlers. If sendToAll is true, will send to all event handlers,
1505 /// otherwise will stop at the first successful one.
1506 bool SendEvent(wxEvent
& event
, bool sendToAll
= true);
1511 void Copy(const wxRichTextBuffer
& obj
);
1514 virtual wxRichTextObject
* Clone() const { return new wxRichTextBuffer(*this); }
1516 /// Submit command to insert paragraphs
1517 bool InsertParagraphsWithUndo(long pos
, const wxRichTextParagraphLayoutBox
& paragraphs
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1519 /// Submit command to insert the given text
1520 bool InsertTextWithUndo(long pos
, const wxString
& text
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1522 /// Submit command to insert a newline
1523 bool InsertNewlineWithUndo(long pos
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1525 /// Submit command to insert the given image
1526 bool InsertImageWithUndo(long pos
, const wxRichTextImageBlock
& imageBlock
, wxRichTextCtrl
* ctrl
, int flags
= 0);
1528 /// Submit command to delete this range
1529 bool DeleteRangeWithUndo(const wxRichTextRange
& range
, wxRichTextCtrl
* ctrl
);
1532 void Modify(bool modify
= true) { m_modified
= modify
; }
1533 bool IsModified() const { return m_modified
; }
1535 /// Get the style that is appropriate for a new paragraph at this position.
1536 /// If the previous paragraph has a paragraph style name, look up the next-paragraph
1538 wxTextAttr
GetStyleForNewParagraph(long pos
, bool caretPosition
= false, bool lookUpNewParaStyle
=false) const;
1540 /// Dumps contents of buffer for debugging purposes
1541 virtual void Dump();
1542 virtual void Dump(wxTextOutputStream
& stream
) { wxRichTextParagraphLayoutBox::Dump(stream
); }
1544 /// Returns the file handlers
1545 static wxList
& GetHandlers() { return sm_handlers
; }
1547 /// Adds a handler to the end
1548 static void AddHandler(wxRichTextFileHandler
*handler
);
1550 /// Inserts a handler at the front
1551 static void InsertHandler(wxRichTextFileHandler
*handler
);
1553 /// Removes a handler
1554 static bool RemoveHandler(const wxString
& name
);
1556 /// Finds a handler by name
1557 static wxRichTextFileHandler
*FindHandler(const wxString
& name
);
1559 /// Finds a handler by extension and type
1560 static wxRichTextFileHandler
*FindHandler(const wxString
& extension
, wxRichTextFileType imageType
);
1562 /// Finds a handler by filename or, if supplied, type
1563 static wxRichTextFileHandler
*FindHandlerFilenameOrType(const wxString
& filename
,
1564 wxRichTextFileType imageType
);
1566 /// Finds a handler by type
1567 static wxRichTextFileHandler
*FindHandler(wxRichTextFileType imageType
);
1569 /// Gets a wildcard incorporating all visible handlers. If 'types' is present,
1570 /// will be filled with the file type corresponding to each filter. This can be
1571 /// used to determine the type to pass to LoadFile given a selected filter.
1572 static wxString
GetExtWildcard(bool combine
= false, bool save
= false, wxArrayInt
* types
= NULL
);
1574 /// Clean up handlers
1575 static void CleanUpHandlers();
1577 /// Initialise the standard handlers
1578 static void InitStandardHandlers();
1581 static wxRichTextRenderer
* GetRenderer() { return sm_renderer
; }
1583 /// Set renderer, deleting old one
1584 static void SetRenderer(wxRichTextRenderer
* renderer
);
1586 /// Minimum margin between bullet and paragraph in 10ths of a mm
1587 static int GetBulletRightMargin() { return sm_bulletRightMargin
; }
1588 static void SetBulletRightMargin(int margin
) { sm_bulletRightMargin
= margin
; }
1590 /// Factor to multiply by character height to get a reasonable bullet size
1591 static float GetBulletProportion() { return sm_bulletProportion
; }
1592 static void SetBulletProportion(float prop
) { sm_bulletProportion
= prop
; }
1594 /// Scale factor for calculating dimensions
1595 double GetScale() const { return m_scale
; }
1596 void SetScale(double scale
) { m_scale
= scale
; }
1600 /// Command processor
1601 wxCommandProcessor
* m_commandProcessor
;
1603 /// Table storing fonts
1604 wxRichTextFontTable m_fontTable
;
1606 /// Has been modified?
1609 /// Collapsed command stack
1610 int m_batchedCommandDepth
;
1612 /// Name for collapsed command
1613 wxString m_batchedCommandsName
;
1615 /// Current collapsed command accumulating actions
1616 wxRichTextCommand
* m_batchedCommand
;
1618 /// Whether to suppress undo
1621 /// Style sheet, if any
1622 wxRichTextStyleSheet
* m_styleSheet
;
1624 /// List of event handlers that will be notified of events
1625 wxList m_eventHandlers
;
1627 /// Stack of attributes for convenience functions
1628 wxList m_attributeStack
;
1630 /// Flags to be passed to handlers
1634 static wxList sm_handlers
;
1637 static wxRichTextRenderer
* sm_renderer
;
1639 /// Minimum margin between bullet and paragraph in 10ths of a mm
1640 static int sm_bulletRightMargin
;
1642 /// Factor to multiply by character height to get a reasonable bullet size
1643 static float sm_bulletProportion
;
1645 /// Scaling factor in use: needed to calculate correct dimensions when printing
1650 * The command identifiers
1654 enum wxRichTextCommandId
1658 wxRICHTEXT_CHANGE_STYLE
1662 * Command classes for undo/redo
1666 class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction
;
1667 class WXDLLIMPEXP_RICHTEXT wxRichTextCommand
: public wxCommand
1670 // Ctor for one action
1671 wxRichTextCommand(const wxString
& name
, wxRichTextCommandId id
, wxRichTextBuffer
* buffer
,
1672 wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
1674 // Ctor for multiple actions
1675 wxRichTextCommand(const wxString
& name
);
1677 virtual ~wxRichTextCommand();
1682 void AddAction(wxRichTextAction
* action
);
1683 void ClearActions();
1685 wxList
& GetActions() { return m_actions
; }
1693 * wxRichTextAction class declaration
1694 * There can be more than one action in a command.
1697 class WXDLLIMPEXP_RICHTEXT wxRichTextAction
: public wxObject
1700 wxRichTextAction(wxRichTextCommand
* cmd
, const wxString
& name
, wxRichTextCommandId id
, wxRichTextBuffer
* buffer
,
1701 wxRichTextCtrl
* ctrl
, bool ignoreFirstTime
= false);
1703 virtual ~wxRichTextAction();
1708 /// Update the control appearance
1709 void UpdateAppearance(long caretPosition
, bool sendUpdateEvent
= false,
1710 wxArrayInt
* optimizationLineCharPositions
= NULL
, wxArrayInt
* optimizationLineYPositions
= NULL
, bool isDoCmd
= true);
1712 /// Replace the buffer paragraphs with the given fragment.
1713 void ApplyParagraphs(const wxRichTextParagraphLayoutBox
& fragment
);
1715 /// Get the fragments
1716 wxRichTextParagraphLayoutBox
& GetNewParagraphs() { return m_newParagraphs
; }
1717 wxRichTextParagraphLayoutBox
& GetOldParagraphs() { return m_oldParagraphs
; }
1719 /// Calculate arrays for refresh optimization
1720 void CalculateRefreshOptimizations(wxArrayInt
& optimizationLineCharPositions
, wxArrayInt
& optimizationLineYPositions
);
1722 /// Set/get the position used for e.g. insertion
1723 void SetPosition(long pos
) { m_position
= pos
; }
1724 long GetPosition() const { return m_position
; }
1726 /// Set/get the range for e.g. deletion
1727 void SetRange(const wxRichTextRange
& range
) { m_range
= range
; }
1728 const wxRichTextRange
& GetRange() const { return m_range
; }
1731 const wxString
& GetName() const { return m_name
; }
1738 wxRichTextBuffer
* m_buffer
;
1741 wxRichTextCtrl
* m_ctrl
;
1743 // Stores the new paragraphs
1744 wxRichTextParagraphLayoutBox m_newParagraphs
;
1746 // Stores the old paragraphs
1747 wxRichTextParagraphLayoutBox m_oldParagraphs
;
1749 // The affected range
1750 wxRichTextRange m_range
;
1752 // The insertion point for this command
1755 // Ignore 1st 'Do' operation because we already did it
1758 // The command identifier
1759 wxRichTextCommandId m_cmdId
;
1766 // Include style sheet when loading and saving
1767 #define wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET 0x0001
1769 // Save images to memory file system in HTML handler
1770 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY 0x0010
1772 // Save images to files in HTML handler
1773 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES 0x0020
1775 // Save images as inline base64 data in HTML handler
1776 #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040
1778 // Don't write header and footer (or BODY), so we can include the fragment
1779 // in a larger document
1780 #define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080
1783 * wxRichTextFileHandler
1784 * Base class for file handlers
1787 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler
: public wxObject
1789 DECLARE_CLASS(wxRichTextFileHandler
)
1791 wxRichTextFileHandler(const wxString
& name
= wxEmptyString
, const wxString
& ext
= wxEmptyString
, int type
= 0)
1792 : m_name(name
), m_extension(ext
), m_type(type
), m_flags(0), m_visible(true)
1796 bool LoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
)
1797 { return DoLoadFile(buffer
, stream
); }
1798 bool SaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
)
1799 { return DoSaveFile(buffer
, stream
); }
1802 #if wxUSE_FFILE && wxUSE_STREAMS
1803 virtual bool LoadFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
1804 virtual bool SaveFile(wxRichTextBuffer
*buffer
, const wxString
& filename
);
1805 #endif // wxUSE_STREAMS && wxUSE_STREAMS
1807 /// Can we handle this filename (if using files)? By default, checks the extension.
1808 virtual bool CanHandle(const wxString
& filename
) const;
1810 /// Can we save using this handler?
1811 virtual bool CanSave() const { return false; }
1813 /// Can we load using this handler?
1814 virtual bool CanLoad() const { return false; }
1816 /// Should this handler be visible to the user?
1817 virtual bool IsVisible() const { return m_visible
; }
1818 virtual void SetVisible(bool visible
) { m_visible
= visible
; }
1820 /// The name of the nandler
1821 void SetName(const wxString
& name
) { m_name
= name
; }
1822 wxString
GetName() const { return m_name
; }
1824 /// The default extension to recognise
1825 void SetExtension(const wxString
& ext
) { m_extension
= ext
; }
1826 wxString
GetExtension() const { return m_extension
; }
1828 /// The handler type
1829 void SetType(int type
) { m_type
= type
; }
1830 int GetType() const { return m_type
; }
1832 /// Flags controlling how loading and saving is done
1833 void SetFlags(int flags
) { m_flags
= flags
; }
1834 int GetFlags() const { return m_flags
; }
1836 /// Encoding to use when saving a file. If empty, a suitable encoding is chosen
1837 void SetEncoding(const wxString
& encoding
) { m_encoding
= encoding
; }
1838 const wxString
& GetEncoding() const { return m_encoding
; }
1843 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
) = 0;
1844 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
) = 0;
1848 wxString m_encoding
;
1849 wxString m_extension
;
1856 * wxRichTextPlainTextHandler
1857 * Plain text handler
1860 class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler
: public wxRichTextFileHandler
1862 DECLARE_CLASS(wxRichTextPlainTextHandler
)
1864 wxRichTextPlainTextHandler(const wxString
& name
= wxT("Text"),
1865 const wxString
& ext
= wxT("txt"),
1866 wxRichTextFileType type
= wxRICHTEXT_TYPE_TEXT
)
1867 : wxRichTextFileHandler(name
, ext
, type
)
1870 /// Can we save using this handler?
1871 virtual bool CanSave() const { return true; }
1873 /// Can we load using this handler?
1874 virtual bool CanLoad() const { return true; }
1879 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
1880 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
1888 * The data object for a wxRichTextBuffer
1891 class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject
: public wxDataObjectSimple
1894 // ctor doesn't copy the pointer, so it shouldn't go away while this object
1896 wxRichTextBufferDataObject(wxRichTextBuffer
* richTextBuffer
= (wxRichTextBuffer
*) NULL
);
1897 virtual ~wxRichTextBufferDataObject();
1899 // after a call to this function, the buffer is owned by the caller and it
1900 // is responsible for deleting it
1901 wxRichTextBuffer
* GetRichTextBuffer();
1903 // Returns the id for the new data format
1904 static const wxChar
* GetRichTextBufferFormatId() { return ms_richTextBufferFormatId
; }
1906 // base class pure virtuals
1908 virtual wxDataFormat
GetPreferredFormat(Direction dir
) const;
1909 virtual size_t GetDataSize() const;
1910 virtual bool GetDataHere(void *pBuf
) const;
1911 virtual bool SetData(size_t len
, const void *buf
);
1915 virtual size_t GetDataSize(const wxDataFormat
&) const { return GetDataSize(); }
1916 virtual bool GetDataHere(const wxDataFormat
&, void *buf
) const { return GetDataHere(buf
); }
1917 virtual bool SetData(const wxDataFormat
&, size_t len
, const void *buf
) { return SetData(len
, buf
); }
1920 wxDataFormat m_formatRichTextBuffer
; // our custom format
1921 wxRichTextBuffer
* m_richTextBuffer
; // our data
1922 static const wxChar
* ms_richTextBufferFormatId
; // our format id
1928 * wxRichTextRenderer isolates common drawing functionality
1931 class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer
: public wxObject
1934 wxRichTextRenderer() {}
1935 virtual ~wxRichTextRenderer() {}
1937 /// Draw a standard bullet, as specified by the value of GetBulletName
1938 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttr
& attr
, const wxRect
& rect
) = 0;
1940 /// Draw a bullet that can be described by text, such as numbered or symbol bullets
1941 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttr
& attr
, const wxRect
& rect
, const wxString
& text
) = 0;
1943 /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
1944 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttr
& attr
, const wxRect
& rect
) = 0;
1946 /// Enumerate the standard bullet names currently supported
1947 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
) = 0;
1951 * wxRichTextStdRenderer: standard renderer
1954 class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer
: public wxRichTextRenderer
1957 wxRichTextStdRenderer() {}
1959 /// Draw a standard bullet, as specified by the value of GetBulletName
1960 virtual bool DrawStandardBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttr
& attr
, const wxRect
& rect
);
1962 /// Draw a bullet that can be described by text, such as numbered or symbol bullets
1963 virtual bool DrawTextBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttr
& attr
, const wxRect
& rect
, const wxString
& text
);
1965 /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
1966 virtual bool DrawBitmapBullet(wxRichTextParagraph
* paragraph
, wxDC
& dc
, const wxTextAttr
& attr
, const wxRect
& rect
);
1968 /// Enumerate the standard bullet names currently supported
1969 virtual bool EnumerateStandardBulletNames(wxArrayString
& bulletNames
);
1977 inline bool wxRichTextHasStyle(int flags
, int style
)
1979 return ((flags
& style
) == style
);
1982 /// Compare two attribute objects
1983 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxTextAttr
& attr1
, const wxTextAttr
& attr2
);
1984 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEq(const wxTextAttr
& attr1
, const wxTextAttr
& attr2
);
1986 /// Compare two attribute objects, but take into account the flags
1987 /// specifying attributes of interest.
1988 WXDLLIMPEXP_RICHTEXT
bool wxTextAttrEqPartial(const wxTextAttr
& attr1
, const wxTextAttr
& attr2
, int flags
);
1990 /// Apply one style to another
1991 WXDLLIMPEXP_RICHTEXT
bool wxRichTextApplyStyle(wxTextAttr
& destStyle
, const wxTextAttr
& style
, wxTextAttr
* compareWith
= NULL
);
1993 // Remove attributes
1994 WXDLLIMPEXP_RICHTEXT
bool wxRichTextRemoveStyle(wxTextAttr
& destStyle
, const wxTextAttr
& style
);
1996 /// Combine two bitlists
1997 WXDLLIMPEXP_RICHTEXT
bool wxRichTextCombineBitlists(int& valueA
, int valueB
, int& flagsA
, int flagsB
);
1999 /// Compare two bitlists
2000 WXDLLIMPEXP_RICHTEXT
bool wxRichTextBitlistsEqPartial(int valueA
, int valueB
, int flags
);
2002 /// Split into paragraph and character styles
2003 WXDLLIMPEXP_RICHTEXT
bool wxRichTextSplitParaCharStyles(const wxTextAttr
& style
, wxTextAttr
& parStyle
, wxTextAttr
& charStyle
);
2006 WXDLLIMPEXP_RICHTEXT
bool wxRichTextTabsEq(const wxArrayInt
& tabs1
, const wxArrayInt
& tabs2
);
2008 /// Convert a decimal to Roman numerals
2009 WXDLLIMPEXP_RICHTEXT wxString
wxRichTextDecimalToRoman(long n
);
2011 WXDLLIMPEXP_RICHTEXT
void wxRichTextModuleInit();
2017 // _WX_RICHTEXTBUFFER_H_