]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/richtext/richtextbuffer.h | |
3 | // Purpose: Buffer for wxRichTextCtrl | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 2005-09-30 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_RICHTEXTBUFFER_H_ | |
13 | #define _WX_RICHTEXTBUFFER_H_ | |
14 | ||
15 | /* | |
16 | ||
17 | Data structures | |
18 | =============== | |
19 | ||
20 | Data is represented by a hierarchy of objects, all derived from | |
21 | wxRichTextObject. | |
22 | ||
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. | |
28 | ||
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. | |
36 | ||
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. | |
41 | ||
42 | Layout | |
43 | ====== | |
44 | ||
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. | |
51 | ||
52 | */ | |
53 | ||
54 | /*! | |
55 | * Includes | |
56 | */ | |
57 | ||
58 | #include "wx/defs.h" | |
59 | ||
60 | #if wxUSE_RICHTEXT | |
61 | ||
62 | #include "wx/list.h" | |
63 | #include "wx/textctrl.h" | |
64 | #include "wx/bitmap.h" | |
65 | #include "wx/image.h" | |
66 | #include "wx/cmdproc.h" | |
67 | #include "wx/txtstrm.h" | |
68 | ||
69 | #if wxUSE_DATAOBJ | |
70 | #include "wx/dataobj.h" | |
71 | #endif | |
72 | ||
73 | // Compatibility | |
74 | #define wxRichTextAttr wxTextAttr | |
75 | #define wxTextAttrEx wxTextAttr | |
76 | ||
77 | // Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a | |
78 | // cursor reliably without using wxClientDC in case there | |
79 | // are platform-specific problems with the generic caret. | |
80 | #ifdef __WXMAC__ | |
81 | #define wxRICHTEXT_USE_OWN_CARET 1 | |
82 | #else | |
83 | #define wxRICHTEXT_USE_OWN_CARET 0 | |
84 | #endif | |
85 | ||
86 | // Switch off for binary compatibility, on for faster drawing | |
87 | // Note: this seems to be buggy (overzealous use of extents) so | |
88 | // don't use for now | |
89 | #define wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING 0 | |
90 | ||
91 | /*! | |
92 | * Special characters | |
93 | */ | |
94 | ||
95 | extern WXDLLIMPEXP_RICHTEXT const wxChar wxRichTextLineBreakChar; | |
96 | ||
97 | /*! | |
98 | * File types in wxRichText context. | |
99 | */ | |
100 | enum wxRichTextFileType | |
101 | { | |
102 | wxRICHTEXT_TYPE_ANY = 0, | |
103 | wxRICHTEXT_TYPE_TEXT, | |
104 | wxRICHTEXT_TYPE_XML, | |
105 | wxRICHTEXT_TYPE_HTML, | |
106 | wxRICHTEXT_TYPE_RTF, | |
107 | wxRICHTEXT_TYPE_PDF | |
108 | }; | |
109 | ||
110 | /*! | |
111 | * Forward declarations | |
112 | */ | |
113 | ||
114 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCtrl; | |
115 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObject; | |
116 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCacheObject; | |
117 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObjectList; | |
118 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextLine; | |
119 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraph; | |
120 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFileHandler; | |
121 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleSheet; | |
122 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextListStyleDefinition; | |
123 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextEvent; | |
124 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextRenderer; | |
125 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextBuffer; | |
126 | ||
127 | /*! | |
128 | * Flags determining the available space, passed to Layout | |
129 | */ | |
130 | ||
131 | #define wxRICHTEXT_FIXED_WIDTH 0x01 | |
132 | #define wxRICHTEXT_FIXED_HEIGHT 0x02 | |
133 | #define wxRICHTEXT_VARIABLE_WIDTH 0x04 | |
134 | #define wxRICHTEXT_VARIABLE_HEIGHT 0x08 | |
135 | ||
136 | // Only lay out the part of the buffer that lies within | |
137 | // the rect passed to Layout. | |
138 | #define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10 | |
139 | ||
140 | /*! | |
141 | * Flags to pass to Draw | |
142 | */ | |
143 | ||
144 | // Ignore paragraph cache optimization, e.g. for printing purposes | |
145 | // where one line may be drawn higher (on the next page) compared | |
146 | // with the previous line | |
147 | #define wxRICHTEXT_DRAW_IGNORE_CACHE 0x01 | |
148 | ||
149 | /*! | |
150 | * Flags returned from hit-testing | |
151 | */ | |
152 | enum wxRichTextHitTestFlags | |
153 | { | |
154 | // The point was not on this object | |
155 | wxRICHTEXT_HITTEST_NONE = 0x01, | |
156 | ||
157 | // The point was before the position returned from HitTest | |
158 | wxRICHTEXT_HITTEST_BEFORE = 0x02, | |
159 | ||
160 | // The point was after the position returned from HitTest | |
161 | wxRICHTEXT_HITTEST_AFTER = 0x04, | |
162 | ||
163 | // The point was on the position returned from HitTest | |
164 | wxRICHTEXT_HITTEST_ON = 0x08, | |
165 | ||
166 | // The point was on space outside content | |
167 | wxRICHTEXT_HITTEST_OUTSIDE = 0x10 | |
168 | }; | |
169 | ||
170 | /*! | |
171 | * Flags for GetRangeSize | |
172 | */ | |
173 | ||
174 | #define wxRICHTEXT_FORMATTED 0x01 | |
175 | #define wxRICHTEXT_UNFORMATTED 0x02 | |
176 | #define wxRICHTEXT_CACHE_SIZE 0x04 | |
177 | #define wxRICHTEXT_HEIGHT_ONLY 0x08 | |
178 | ||
179 | /*! | |
180 | * Flags for SetStyle/SetListStyle | |
181 | */ | |
182 | ||
183 | #define wxRICHTEXT_SETSTYLE_NONE 0x00 | |
184 | ||
185 | // Specifies that this operation should be undoable | |
186 | #define wxRICHTEXT_SETSTYLE_WITH_UNDO 0x01 | |
187 | ||
188 | // Specifies that the style should not be applied if the | |
189 | // combined style at this point is already the style in question. | |
190 | #define wxRICHTEXT_SETSTYLE_OPTIMIZE 0x02 | |
191 | ||
192 | // Specifies that the style should only be applied to paragraphs, | |
193 | // and not the content. This allows content styling to be | |
194 | // preserved independently from that of e.g. a named paragraph style. | |
195 | #define wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY 0x04 | |
196 | ||
197 | // Specifies that the style should only be applied to characters, | |
198 | // and not the paragraph. This allows content styling to be | |
199 | // preserved independently from that of e.g. a named paragraph style. | |
200 | #define wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY 0x08 | |
201 | ||
202 | // For SetListStyle only: specifies starting from the given number, otherwise | |
203 | // deduces number from existing attributes | |
204 | #define wxRICHTEXT_SETSTYLE_RENUMBER 0x10 | |
205 | ||
206 | // For SetListStyle only: specifies the list level for all paragraphs, otherwise | |
207 | // the current indentation will be used | |
208 | #define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL 0x20 | |
209 | ||
210 | // Resets the existing style before applying the new style | |
211 | #define wxRICHTEXT_SETSTYLE_RESET 0x40 | |
212 | ||
213 | // Removes the given style instead of applying it | |
214 | #define wxRICHTEXT_SETSTYLE_REMOVE 0x80 | |
215 | ||
216 | /*! | |
217 | * Flags for text insertion | |
218 | */ | |
219 | ||
220 | #define wxRICHTEXT_INSERT_NONE 0x00 | |
221 | #define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE 0x01 | |
222 | #define wxRICHTEXT_INSERT_INTERACTIVE 0x02 | |
223 | ||
224 | // A special flag telling the buffer to keep the first paragraph style | |
225 | // as-is, when deleting a paragraph marker. In future we might pass a | |
226 | // flag to InsertFragment and DeleteRange to indicate the appropriate mode. | |
227 | #define wxTEXT_ATTR_KEEP_FIRST_PARA_STYLE 0x10000000 | |
228 | ||
229 | /*! | |
230 | * Default superscript/subscript font multiplication factor | |
231 | */ | |
232 | ||
233 | #define wxSCRIPT_MUL_FACTOR 1.5 | |
234 | ||
235 | /*! | |
236 | * wxRichTextFontTable | |
237 | * Manages quick access to a pool of fonts for rendering rich text | |
238 | */ | |
239 | ||
240 | class WXDLLIMPEXP_RICHTEXT wxRichTextFontTable: public wxObject | |
241 | { | |
242 | public: | |
243 | wxRichTextFontTable(); | |
244 | ||
245 | wxRichTextFontTable(const wxRichTextFontTable& table); | |
246 | virtual ~wxRichTextFontTable(); | |
247 | ||
248 | bool IsOk() const { return m_refData != NULL; } | |
249 | ||
250 | wxFont FindFont(const wxTextAttr& fontSpec); | |
251 | void Clear(); | |
252 | ||
253 | void operator= (const wxRichTextFontTable& table); | |
254 | bool operator == (const wxRichTextFontTable& table) const; | |
255 | bool operator != (const wxRichTextFontTable& table) const { return !(*this == table); } | |
256 | ||
257 | protected: | |
258 | ||
259 | DECLARE_DYNAMIC_CLASS(wxRichTextFontTable) | |
260 | }; | |
261 | ||
262 | /*! | |
263 | * wxRichTextRange class declaration | |
264 | * This stores beginning and end positions for a range of data. | |
265 | * TODO: consider renaming wxTextRange and using for all text controls. | |
266 | */ | |
267 | ||
268 | class WXDLLIMPEXP_RICHTEXT wxRichTextRange | |
269 | { | |
270 | public: | |
271 | // Constructors | |
272 | ||
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() {} | |
277 | ||
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); } | |
283 | ||
284 | void SetRange(long start, long end) { m_start = start; m_end = end; } | |
285 | ||
286 | void SetStart(long start) { m_start = start; } | |
287 | long GetStart() const { return m_start; } | |
288 | ||
289 | void SetEnd(long end) { m_end = end; } | |
290 | long GetEnd() const { return m_end; } | |
291 | ||
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; } | |
294 | ||
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; } | |
297 | ||
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 ; } | |
303 | ||
304 | /// Limit this range to be within 'range' | |
305 | bool LimitTo(const wxRichTextRange& range) ; | |
306 | ||
307 | /// Gets the length of the range | |
308 | long GetLength() const { return m_end - m_start + 1; } | |
309 | ||
310 | /// Swaps the start and end | |
311 | void Swap() { long tmp = m_start; m_start = m_end; m_end = tmp; } | |
312 | ||
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); } | |
315 | ||
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); } | |
318 | ||
319 | protected: | |
320 | long m_start; | |
321 | long m_end; | |
322 | }; | |
323 | ||
324 | #define wxRICHTEXT_ALL wxRichTextRange(-2, -2) | |
325 | #define wxRICHTEXT_NONE wxRichTextRange(-1, -1) | |
326 | ||
327 | /*! | |
328 | * wxRichTextObject class declaration | |
329 | * This is the base for drawable objects. | |
330 | */ | |
331 | ||
332 | class WXDLLIMPEXP_RICHTEXT wxRichTextObject: public wxObject | |
333 | { | |
334 | DECLARE_CLASS(wxRichTextObject) | |
335 | public: | |
336 | // Constructors | |
337 | ||
338 | wxRichTextObject(wxRichTextObject* parent = NULL); | |
339 | virtual ~wxRichTextObject(); | |
340 | ||
341 | // Overrideables | |
342 | ||
343 | /// Draw the item, within the given range. Some objects may ignore the range (for | |
344 | /// example paragraphs) while others must obey it (lines, to implement wrapping) | |
345 | virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style) = 0; | |
346 | ||
347 | /// Lay the item out at the specified position with the given size constraint. | |
348 | /// Layout must set the cached size. | |
349 | virtual bool Layout(wxDC& dc, const wxRect& rect, int style) = 0; | |
350 | ||
351 | /// Hit-testing: returns a flag indicating hit test details, plus | |
352 | /// information about position | |
353 | virtual int HitTest(wxDC& WXUNUSED(dc), const wxPoint& WXUNUSED(pt), long& WXUNUSED(textPosition)) { return false; } | |
354 | ||
355 | /// Finds the absolute position and row height for the given character position | |
356 | virtual bool FindPosition(wxDC& WXUNUSED(dc), long WXUNUSED(index), wxPoint& WXUNUSED(pt), int* WXUNUSED(height), bool WXUNUSED(forceLineStart)) { return false; } | |
357 | ||
358 | /// Get the best size, i.e. the ideal starting size for this object irrespective | |
359 | /// of available space. For a short text string, it will be the size that exactly encloses | |
360 | /// the text. For a longer string, it might use the parent width for example. | |
361 | virtual wxSize GetBestSize() const { return m_size; } | |
362 | ||
363 | /// Get the object size for the given range. Returns false if the range | |
364 | /// is invalid for this object. | |
365 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const = 0; | |
366 | ||
367 | /// Do a split, returning an object containing the second part, and setting | |
368 | /// the first part in 'this'. | |
369 | virtual wxRichTextObject* DoSplit(long WXUNUSED(pos)) { return NULL; } | |
370 | ||
371 | /// Calculate range. By default, guess that the object is 1 unit long. | |
372 | virtual void CalculateRange(long start, long& end) { end = start ; m_range.SetRange(start, end); } | |
373 | ||
374 | /// Delete range | |
375 | virtual bool DeleteRange(const wxRichTextRange& WXUNUSED(range)) { return false; } | |
376 | ||
377 | /// Returns true if the object is empty | |
378 | virtual bool IsEmpty() const { return false; } | |
379 | ||
380 | /// Get any text in this object for the given range | |
381 | virtual wxString GetTextForRange(const wxRichTextRange& WXUNUSED(range)) const { return wxEmptyString; } | |
382 | ||
383 | /// Returns true if this object can merge itself with the given one. | |
384 | virtual bool CanMerge(wxRichTextObject* WXUNUSED(object)) const { return false; } | |
385 | ||
386 | /// Returns true if this object merged itself with the given one. | |
387 | /// The calling code will then delete the given object. | |
388 | virtual bool Merge(wxRichTextObject* WXUNUSED(object)) { return false; } | |
389 | ||
390 | /// Dump to output stream for debugging | |
391 | virtual void Dump(wxTextOutputStream& stream); | |
392 | ||
393 | // Accessors | |
394 | ||
395 | /// Get/set the cached object size as calculated by Layout. | |
396 | virtual wxSize GetCachedSize() const { return m_size; } | |
397 | virtual void SetCachedSize(const wxSize& sz) { m_size = sz; } | |
398 | ||
399 | /// Get/set the object position | |
400 | virtual wxPoint GetPosition() const { return m_pos; } | |
401 | virtual void SetPosition(const wxPoint& pos) { m_pos = pos; } | |
402 | ||
403 | /// Get the rectangle enclosing the object | |
404 | virtual wxRect GetRect() const { return wxRect(GetPosition(), GetCachedSize()); } | |
405 | ||
406 | /// Set the range | |
407 | void SetRange(const wxRichTextRange& range) { m_range = range; } | |
408 | ||
409 | /// Get the range | |
410 | const wxRichTextRange& GetRange() const { return m_range; } | |
411 | wxRichTextRange& GetRange() { return m_range; } | |
412 | ||
413 | /// Get/set dirty flag (whether the object needs Layout to be called) | |
414 | virtual bool GetDirty() const { return m_dirty; } | |
415 | virtual void SetDirty(bool dirty) { m_dirty = dirty; } | |
416 | ||
417 | /// Is this composite? | |
418 | virtual bool IsComposite() const { return false; } | |
419 | ||
420 | /// Get/set the parent. | |
421 | virtual wxRichTextObject* GetParent() const { return m_parent; } | |
422 | virtual void SetParent(wxRichTextObject* parent) { m_parent = parent; } | |
423 | ||
424 | /// Set the margin around the object | |
425 | virtual void SetMargins(int margin); | |
426 | virtual void SetMargins(int leftMargin, int rightMargin, int topMargin, int bottomMargin); | |
427 | virtual int GetLeftMargin() const { return m_leftMargin; } | |
428 | virtual int GetRightMargin() const { return m_rightMargin; } | |
429 | virtual int GetTopMargin() const { return m_topMargin; } | |
430 | virtual int GetBottomMargin() const { return m_bottomMargin; } | |
431 | ||
432 | /// Set attributes object | |
433 | void SetAttributes(const wxTextAttr& attr) { m_attributes = attr; } | |
434 | const wxTextAttr& GetAttributes() const { return m_attributes; } | |
435 | wxTextAttr& GetAttributes() { return m_attributes; } | |
436 | ||
437 | /// Set/get stored descent | |
438 | void SetDescent(int descent) { m_descent = descent; } | |
439 | int GetDescent() const { return m_descent; } | |
440 | ||
441 | /// Gets the containing buffer | |
442 | wxRichTextBuffer* GetBuffer() const; | |
443 | ||
444 | // Operations | |
445 | ||
446 | /// Clone the object | |
447 | virtual wxRichTextObject* Clone() const { return NULL; } | |
448 | ||
449 | /// Copy | |
450 | void Copy(const wxRichTextObject& obj); | |
451 | ||
452 | /// Reference-counting allows us to use the same object in multiple | |
453 | /// lists (not yet used) | |
454 | void Reference() { m_refCount ++; } | |
455 | void Dereference(); | |
456 | ||
457 | /// Convert units in tenths of a millimetre to device units | |
458 | int ConvertTenthsMMToPixels(wxDC& dc, int units); | |
459 | static int ConvertTenthsMMToPixels(int ppi, int units); | |
460 | ||
461 | protected: | |
462 | wxSize m_size; | |
463 | wxPoint m_pos; | |
464 | int m_descent; // Descent for this object (if any) | |
465 | bool m_dirty; | |
466 | int m_refCount; | |
467 | wxRichTextObject* m_parent; | |
468 | ||
469 | /// The range of this object (start position to end position) | |
470 | wxRichTextRange m_range; | |
471 | ||
472 | /// Margins | |
473 | int m_leftMargin; | |
474 | int m_rightMargin; | |
475 | int m_topMargin; | |
476 | int m_bottomMargin; | |
477 | ||
478 | /// Attributes | |
479 | wxTextAttr m_attributes; | |
480 | }; | |
481 | ||
482 | WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_RICHTEXT ); | |
483 | ||
484 | /*! | |
485 | * wxRichTextCompositeObject class declaration | |
486 | * Objects of this class can contain other objects. | |
487 | */ | |
488 | ||
489 | class WXDLLIMPEXP_RICHTEXT wxRichTextCompositeObject: public wxRichTextObject | |
490 | { | |
491 | DECLARE_CLASS(wxRichTextCompositeObject) | |
492 | public: | |
493 | // Constructors | |
494 | ||
495 | wxRichTextCompositeObject(wxRichTextObject* parent = NULL); | |
496 | virtual ~wxRichTextCompositeObject(); | |
497 | ||
498 | // Overrideables | |
499 | ||
500 | /// Hit-testing: returns a flag indicating hit test details, plus | |
501 | /// information about position | |
502 | virtual int HitTest(wxDC& dc, const wxPoint& pt, long& textPosition); | |
503 | ||
504 | /// Finds the absolute position and row height for the given character position | |
505 | virtual bool FindPosition(wxDC& dc, long index, wxPoint& pt, int* height, bool forceLineStart); | |
506 | ||
507 | /// Calculate range | |
508 | virtual void CalculateRange(long start, long& end); | |
509 | ||
510 | /// Delete range | |
511 | virtual bool DeleteRange(const wxRichTextRange& range); | |
512 | ||
513 | /// Get any text in this object for the given range | |
514 | virtual wxString GetTextForRange(const wxRichTextRange& range) const; | |
515 | ||
516 | /// Dump to output stream for debugging | |
517 | virtual void Dump(wxTextOutputStream& stream); | |
518 | ||
519 | // Accessors | |
520 | ||
521 | /// Get the children | |
522 | wxRichTextObjectList& GetChildren() { return m_children; } | |
523 | const wxRichTextObjectList& GetChildren() const { return m_children; } | |
524 | ||
525 | /// Get the child count | |
526 | size_t GetChildCount() const ; | |
527 | ||
528 | /// Get the nth child | |
529 | wxRichTextObject* GetChild(size_t n) const ; | |
530 | ||
531 | /// Get/set dirty flag | |
532 | virtual bool GetDirty() const { return m_dirty; } | |
533 | virtual void SetDirty(bool dirty) { m_dirty = dirty; } | |
534 | ||
535 | /// Is this composite? | |
536 | virtual bool IsComposite() const { return true; } | |
537 | ||
538 | /// Returns true if the buffer is empty | |
539 | virtual bool IsEmpty() const { return GetChildCount() == 0; } | |
540 | ||
541 | // Operations | |
542 | ||
543 | /// Copy | |
544 | void Copy(const wxRichTextCompositeObject& obj); | |
545 | ||
546 | /// Assignment | |
547 | void operator= (const wxRichTextCompositeObject& obj) { Copy(obj); } | |
548 | ||
549 | /// Append a child, returning the position | |
550 | size_t AppendChild(wxRichTextObject* child) ; | |
551 | ||
552 | /// Insert the child in front of the given object, or at the beginning | |
553 | bool InsertChild(wxRichTextObject* child, wxRichTextObject* inFrontOf) ; | |
554 | ||
555 | /// Delete the child | |
556 | bool RemoveChild(wxRichTextObject* child, bool deleteChild = false) ; | |
557 | ||
558 | /// Delete all children | |
559 | bool DeleteChildren() ; | |
560 | ||
561 | /// Recursively merge all pieces that can be merged. | |
562 | bool Defragment(const wxRichTextRange& range = wxRICHTEXT_ALL); | |
563 | ||
564 | protected: | |
565 | wxRichTextObjectList m_children; | |
566 | }; | |
567 | ||
568 | /*! | |
569 | * wxRichTextBox class declaration | |
570 | * This defines a 2D space to lay out objects | |
571 | */ | |
572 | ||
573 | class WXDLLIMPEXP_RICHTEXT wxRichTextBox: public wxRichTextCompositeObject | |
574 | { | |
575 | DECLARE_DYNAMIC_CLASS(wxRichTextBox) | |
576 | public: | |
577 | // Constructors | |
578 | ||
579 | wxRichTextBox(wxRichTextObject* parent = NULL); | |
580 | wxRichTextBox(const wxRichTextBox& obj): wxRichTextCompositeObject() { Copy(obj); } | |
581 | ||
582 | // Overrideables | |
583 | ||
584 | /// Draw the item | |
585 | virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); | |
586 | ||
587 | /// Lay the item out | |
588 | virtual bool Layout(wxDC& dc, const wxRect& rect, int style); | |
589 | ||
590 | /// Get/set the object size for the given range. Returns false if the range | |
591 | /// is invalid for this object. | |
592 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const; | |
593 | ||
594 | // Accessors | |
595 | ||
596 | // Operations | |
597 | ||
598 | /// Clone | |
599 | virtual wxRichTextObject* Clone() const { return new wxRichTextBox(*this); } | |
600 | ||
601 | /// Copy | |
602 | void Copy(const wxRichTextBox& obj); | |
603 | ||
604 | protected: | |
605 | }; | |
606 | ||
607 | /*! | |
608 | * wxRichTextParagraphBox class declaration | |
609 | * This box knows how to lay out paragraphs. | |
610 | */ | |
611 | ||
612 | class WXDLLIMPEXP_RICHTEXT wxRichTextParagraphLayoutBox: public wxRichTextBox | |
613 | { | |
614 | DECLARE_DYNAMIC_CLASS(wxRichTextParagraphLayoutBox) | |
615 | public: | |
616 | // Constructors | |
617 | ||
618 | wxRichTextParagraphLayoutBox(wxRichTextObject* parent = NULL); | |
619 | wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox& obj): wxRichTextBox() { Init(); Copy(obj); } | |
620 | ||
621 | // Overrideables | |
622 | ||
623 | /// Draw the item | |
624 | virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); | |
625 | ||
626 | /// Lay the item out | |
627 | virtual bool Layout(wxDC& dc, const wxRect& rect, int style); | |
628 | ||
629 | /// Get/set the object size for the given range. Returns false if the range | |
630 | /// is invalid for this object. | |
631 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const; | |
632 | ||
633 | /// Delete range | |
634 | virtual bool DeleteRange(const wxRichTextRange& range); | |
635 | ||
636 | /// Get any text in this object for the given range | |
637 | virtual wxString GetTextForRange(const wxRichTextRange& range) const; | |
638 | ||
639 | // Accessors | |
640 | ||
641 | /// Associate a control with the buffer, for operations that for example require refreshing the window. | |
642 | void SetRichTextCtrl(wxRichTextCtrl* ctrl) { m_ctrl = ctrl; } | |
643 | ||
644 | /// Get the associated control. | |
645 | wxRichTextCtrl* GetRichTextCtrl() const { return m_ctrl; } | |
646 | ||
647 | /// Get/set whether the last paragraph is partial or complete | |
648 | void SetPartialParagraph(bool partialPara) { m_partialParagraph = partialPara; } | |
649 | bool GetPartialParagraph() const { return m_partialParagraph; } | |
650 | ||
651 | /// If this is a buffer, returns the current style sheet. The base layout box | |
652 | /// class doesn't have an associated style sheet. | |
653 | virtual wxRichTextStyleSheet* GetStyleSheet() const { return NULL; } | |
654 | ||
655 | // Operations | |
656 | ||
657 | /// Initialize the object. | |
658 | void Init(); | |
659 | ||
660 | /// Clear all children | |
661 | virtual void Clear(); | |
662 | ||
663 | /// Clear and initialize with one blank paragraph | |
664 | virtual void Reset(); | |
665 | ||
666 | /// Convenience function to add a paragraph of text | |
667 | virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttr* paraStyle = NULL); | |
668 | ||
669 | /// Convenience function to add an image | |
670 | virtual wxRichTextRange AddImage(const wxImage& image, wxTextAttr* paraStyle = NULL); | |
671 | ||
672 | /// Adds multiple paragraphs, based on newlines. | |
673 | virtual wxRichTextRange AddParagraphs(const wxString& text, wxTextAttr* paraStyle = NULL); | |
674 | ||
675 | /// Get the line at the given position. If caretPosition is true, the position is | |
676 | /// a caret position, which is normally a smaller number. | |
677 | virtual wxRichTextLine* GetLineAtPosition(long pos, bool caretPosition = false) const; | |
678 | ||
679 | /// Get the line at the given y pixel position, or the last line. | |
680 | virtual wxRichTextLine* GetLineAtYPosition(int y) const; | |
681 | ||
682 | /// Get the paragraph at the given character or caret position | |
683 | virtual wxRichTextParagraph* GetParagraphAtPosition(long pos, bool caretPosition = false) const; | |
684 | ||
685 | /// Get the line size at the given position | |
686 | virtual wxSize GetLineSizeAtPosition(long pos, bool caretPosition = false) const; | |
687 | ||
688 | /// Given a position, get the number of the visible line (potentially many to a paragraph), | |
689 | /// starting from zero at the start of the buffer. We also have to pass a bool (startOfLine) | |
690 | /// that indicates whether the caret is being shown at the end of the previous line or at the start | |
691 | /// of the next, since the caret can be shown at 2 visible positions for the same underlying | |
692 | /// position. | |
693 | virtual long GetVisibleLineNumber(long pos, bool caretPosition = false, bool startOfLine = false) const; | |
694 | ||
695 | /// Given a line number, get the corresponding wxRichTextLine object. | |
696 | virtual wxRichTextLine* GetLineForVisibleLineNumber(long lineNumber) const; | |
697 | ||
698 | /// Get the leaf object in a paragraph at this position. | |
699 | /// Given a line number, get the corresponding wxRichTextLine object. | |
700 | virtual wxRichTextObject* GetLeafObjectAtPosition(long position) const; | |
701 | ||
702 | /// Get the paragraph by number | |
703 | virtual wxRichTextParagraph* GetParagraphAtLine(long paragraphNumber) const; | |
704 | ||
705 | /// Get the paragraph for a given line | |
706 | virtual wxRichTextParagraph* GetParagraphForLine(wxRichTextLine* line) const; | |
707 | ||
708 | /// Get the length of the paragraph | |
709 | virtual int GetParagraphLength(long paragraphNumber) const; | |
710 | ||
711 | /// Get the number of paragraphs | |
712 | virtual int GetParagraphCount() const { return static_cast<int>(GetChildCount()); } | |
713 | ||
714 | /// Get the number of visible lines | |
715 | virtual int GetLineCount() const; | |
716 | ||
717 | /// Get the text of the paragraph | |
718 | virtual wxString GetParagraphText(long paragraphNumber) const; | |
719 | ||
720 | /// Convert zero-based line column and paragraph number to a position. | |
721 | virtual long XYToPosition(long x, long y) const; | |
722 | ||
723 | /// Convert zero-based position to line column and paragraph number | |
724 | virtual bool PositionToXY(long pos, long* x, long* y) const; | |
725 | ||
726 | /// Set text attributes: character and/or paragraph styles. | |
727 | virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); | |
728 | ||
729 | /// Get the conbined text attributes for this position. | |
730 | virtual bool GetStyle(long position, wxTextAttr& style); | |
731 | ||
732 | /// Get the content (uncombined) attributes for this position. | |
733 | virtual bool GetUncombinedStyle(long position, wxTextAttr& style); | |
734 | ||
735 | /// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and | |
736 | /// context attributes. | |
737 | virtual bool DoGetStyle(long position, wxTextAttr& style, bool combineStyles = true); | |
738 | ||
739 | /// Get the combined style for a range - if any attribute is different within the range, | |
740 | /// that attribute is not present within the flags | |
741 | virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style); | |
742 | ||
743 | /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of | |
744 | /// content. | |
745 | bool CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes, int& absentStyleAttributes, int& absentTextEffectAttributes); | |
746 | ||
747 | /// Set list style | |
748 | virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
749 | virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
750 | ||
751 | /// Clear list for given range | |
752 | virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); | |
753 | ||
754 | /// Number/renumber any list elements in the given range. | |
755 | /// def/defName can be NULL/empty to indicate that the existing list style should be used. | |
756 | virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
757 | virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1); | |
758 | ||
759 | /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1 | |
760 | /// def/defName can be NULL/empty to indicate that the existing list style should be used. | |
761 | virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); | |
762 | virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1); | |
763 | ||
764 | /// Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously | |
765 | /// def/defName can be NULL/empty to indicate that the existing list style should be used. | |
766 | 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); | |
767 | ||
768 | /// Fills in the attributes for numbering a paragraph after previousParagraph. | |
769 | virtual bool FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxTextAttr& attr) const; | |
770 | ||
771 | /// Test if this whole range has character attributes of the specified kind. If any | |
772 | /// of the attributes are different within the range, the test fails. You | |
773 | /// can use this to implement, for example, bold button updating. style must have | |
774 | /// flags indicating which attributes are of interest. | |
775 | virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttr& style) const; | |
776 | ||
777 | /// Test if this whole range has paragraph attributes of the specified kind. If any | |
778 | /// of the attributes are different within the range, the test fails. You | |
779 | /// can use this to implement, for example, centering button updating. style must have | |
780 | /// flags indicating which attributes are of interest. | |
781 | virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttr& style) const; | |
782 | ||
783 | /// Clone | |
784 | virtual wxRichTextObject* Clone() const { return new wxRichTextParagraphLayoutBox(*this); } | |
785 | ||
786 | /// Insert fragment into this box at the given position. If partialParagraph is true, | |
787 | /// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph | |
788 | /// marker. | |
789 | virtual bool InsertFragment(long position, wxRichTextParagraphLayoutBox& fragment); | |
790 | ||
791 | /// Make a copy of the fragment corresponding to the given range, putting it in 'fragment'. | |
792 | virtual bool CopyFragment(const wxRichTextRange& range, wxRichTextParagraphLayoutBox& fragment); | |
793 | ||
794 | /// Apply the style sheet to the buffer, for example if the styles have changed. | |
795 | virtual bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet); | |
796 | ||
797 | /// Copy | |
798 | void Copy(const wxRichTextParagraphLayoutBox& obj); | |
799 | ||
800 | /// Assignment | |
801 | void operator= (const wxRichTextParagraphLayoutBox& obj) { Copy(obj); } | |
802 | ||
803 | /// Calculate ranges | |
804 | virtual void UpdateRanges() { long end; CalculateRange(0, end); } | |
805 | ||
806 | /// Get all the text | |
807 | virtual wxString GetText() const; | |
808 | ||
809 | /// Set default style for new content. Setting it to a default attribute | |
810 | /// makes new content take on the 'basic' style. | |
811 | virtual bool SetDefaultStyle(const wxTextAttr& style); | |
812 | ||
813 | /// Get default style | |
814 | virtual const wxTextAttr& GetDefaultStyle() const { return m_defaultAttributes; } | |
815 | ||
816 | /// Set basic (overall) style | |
817 | virtual void SetBasicStyle(const wxTextAttr& style) { m_attributes = style; } | |
818 | ||
819 | /// Get basic (overall) style | |
820 | virtual const wxTextAttr& GetBasicStyle() const { return m_attributes; } | |
821 | ||
822 | /// Invalidate the buffer. With no argument, invalidates whole buffer. | |
823 | void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL); | |
824 | ||
825 | /// Get invalid range, rounding to entire paragraphs if argument is true. | |
826 | wxRichTextRange GetInvalidRange(bool wholeParagraphs = false) const; | |
827 | ||
828 | protected: | |
829 | wxRichTextCtrl* m_ctrl; | |
830 | wxTextAttr m_defaultAttributes; | |
831 | ||
832 | /// The invalidated range that will need full layout | |
833 | wxRichTextRange m_invalidRange; | |
834 | ||
835 | // Is the last paragraph partial or complete? | |
836 | bool m_partialParagraph; | |
837 | }; | |
838 | ||
839 | /*! | |
840 | * wxRichTextLine class declaration | |
841 | * This object represents a line in a paragraph, and stores | |
842 | * offsets from the start of the paragraph representing the | |
843 | * start and end positions of the line. | |
844 | */ | |
845 | ||
846 | class WXDLLIMPEXP_RICHTEXT wxRichTextLine | |
847 | { | |
848 | public: | |
849 | // Constructors | |
850 | ||
851 | wxRichTextLine(wxRichTextParagraph* parent); | |
852 | wxRichTextLine(const wxRichTextLine& obj) { Init( NULL); Copy(obj); } | |
853 | virtual ~wxRichTextLine() {} | |
854 | ||
855 | // Overrideables | |
856 | ||
857 | // Accessors | |
858 | ||
859 | /// Set the range | |
860 | void SetRange(const wxRichTextRange& range) { m_range = range; } | |
861 | void SetRange(long from, long to) { m_range = wxRichTextRange(from, to); } | |
862 | ||
863 | /// Get the parent paragraph | |
864 | wxRichTextParagraph* GetParent() { return m_parent; } | |
865 | ||
866 | /// Get the range | |
867 | const wxRichTextRange& GetRange() const { return m_range; } | |
868 | wxRichTextRange& GetRange() { return m_range; } | |
869 | ||
870 | /// Get the absolute range | |
871 | wxRichTextRange GetAbsoluteRange() const; | |
872 | ||
873 | /// Get/set the line size as calculated by Layout. | |
874 | virtual wxSize GetSize() const { return m_size; } | |
875 | virtual void SetSize(const wxSize& sz) { m_size = sz; } | |
876 | ||
877 | /// Get/set the object position relative to the parent | |
878 | virtual wxPoint GetPosition() const { return m_pos; } | |
879 | virtual void SetPosition(const wxPoint& pos) { m_pos = pos; } | |
880 | ||
881 | /// Get the absolute object position | |
882 | virtual wxPoint GetAbsolutePosition() const; | |
883 | ||
884 | /// Get the rectangle enclosing the line | |
885 | virtual wxRect GetRect() const { return wxRect(GetAbsolutePosition(), GetSize()); } | |
886 | ||
887 | /// Set/get stored descent | |
888 | void SetDescent(int descent) { m_descent = descent; } | |
889 | int GetDescent() const { return m_descent; } | |
890 | ||
891 | #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING | |
892 | wxArrayInt& GetObjectSizes() { return m_objectSizes; } | |
893 | const wxArrayInt& GetObjectSizes() const { return m_objectSizes; } | |
894 | #endif | |
895 | ||
896 | // Operations | |
897 | ||
898 | /// Initialisation | |
899 | void Init(wxRichTextParagraph* parent); | |
900 | ||
901 | /// Copy | |
902 | void Copy(const wxRichTextLine& obj); | |
903 | ||
904 | /// Clone | |
905 | virtual wxRichTextLine* Clone() const { return new wxRichTextLine(*this); } | |
906 | ||
907 | protected: | |
908 | ||
909 | /// The range of the line (start position to end position) | |
910 | /// This is relative to the parent paragraph. | |
911 | wxRichTextRange m_range; | |
912 | ||
913 | /// Size and position measured relative to top of paragraph | |
914 | wxPoint m_pos; | |
915 | wxSize m_size; | |
916 | ||
917 | /// Maximum descent for this line (location of text baseline) | |
918 | int m_descent; | |
919 | ||
920 | // The parent object | |
921 | wxRichTextParagraph* m_parent; | |
922 | ||
923 | #if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING | |
924 | wxArrayInt m_objectSizes; | |
925 | #endif | |
926 | }; | |
927 | ||
928 | WX_DECLARE_LIST_WITH_DECL( wxRichTextLine, wxRichTextLineList , class WXDLLIMPEXP_RICHTEXT ); | |
929 | ||
930 | /*! | |
931 | * wxRichTextParagraph class declaration | |
932 | * This object represents a single paragraph (or in a straight text editor, a line). | |
933 | */ | |
934 | ||
935 | class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph: public wxRichTextBox | |
936 | { | |
937 | DECLARE_DYNAMIC_CLASS(wxRichTextParagraph) | |
938 | public: | |
939 | // Constructors | |
940 | ||
941 | wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttr* style = NULL); | |
942 | wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttr* paraStyle = NULL, wxTextAttr* charStyle = NULL); | |
943 | virtual ~wxRichTextParagraph(); | |
944 | wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { Copy(obj); } | |
945 | ||
946 | // Overrideables | |
947 | ||
948 | /// Draw the item | |
949 | virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); | |
950 | ||
951 | /// Lay the item out | |
952 | virtual bool Layout(wxDC& dc, const wxRect& rect, int style); | |
953 | ||
954 | /// Get/set the object size for the given range. Returns false if the range | |
955 | /// is invalid for this object. | |
956 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const; | |
957 | ||
958 | /// Finds the absolute position and row height for the given character position | |
959 | virtual bool FindPosition(wxDC& dc, long index, wxPoint& pt, int* height, bool forceLineStart); | |
960 | ||
961 | /// Hit-testing: returns a flag indicating hit test details, plus | |
962 | /// information about position | |
963 | virtual int HitTest(wxDC& dc, const wxPoint& pt, long& textPosition); | |
964 | ||
965 | /// Calculate range | |
966 | virtual void CalculateRange(long start, long& end); | |
967 | ||
968 | // Accessors | |
969 | ||
970 | /// Get the cached lines | |
971 | wxRichTextLineList& GetLines() { return m_cachedLines; } | |
972 | ||
973 | // Operations | |
974 | ||
975 | /// Copy | |
976 | void Copy(const wxRichTextParagraph& obj); | |
977 | ||
978 | /// Clone | |
979 | virtual wxRichTextObject* Clone() const { return new wxRichTextParagraph(*this); } | |
980 | ||
981 | /// Clear the cached lines | |
982 | void ClearLines(); | |
983 | ||
984 | // Implementation | |
985 | ||
986 | /// Apply paragraph styles such as centering to the wrapped lines | |
987 | virtual void ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect, wxDC& dc); | |
988 | ||
989 | /// Insert text at the given position | |
990 | virtual bool InsertText(long pos, const wxString& text); | |
991 | ||
992 | /// Split an object at this position if necessary, and return | |
993 | /// the previous object, or NULL if inserting at beginning. | |
994 | virtual wxRichTextObject* SplitAt(long pos, wxRichTextObject** previousObject = NULL); | |
995 | ||
996 | /// Move content to a list from this point | |
997 | virtual void MoveToList(wxRichTextObject* obj, wxList& list); | |
998 | ||
999 | /// Add content back from list | |
1000 | virtual void MoveFromList(wxList& list); | |
1001 | ||
1002 | /// Get the plain text searching from the start or end of the range. | |
1003 | /// The resulting string may be shorter than the range given. | |
1004 | bool GetContiguousPlainText(wxString& text, const wxRichTextRange& range, bool fromStart = true); | |
1005 | ||
1006 | /// Find a suitable wrap position. wrapPosition is the last position in the line to the left | |
1007 | /// of the split. | |
1008 | bool FindWrapPosition(const wxRichTextRange& range, wxDC& dc, int availableSpace, long& wrapPosition, wxArrayInt* partialExtents); | |
1009 | ||
1010 | /// Find the object at the given position | |
1011 | wxRichTextObject* FindObjectAtPosition(long position); | |
1012 | ||
1013 | /// Get the bullet text for this paragraph. | |
1014 | wxString GetBulletText(); | |
1015 | ||
1016 | /// Allocate or reuse a line object | |
1017 | wxRichTextLine* AllocateLine(int pos); | |
1018 | ||
1019 | /// Clear remaining unused line objects, if any | |
1020 | bool ClearUnusedLines(int lineCount); | |
1021 | ||
1022 | /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically | |
1023 | /// retrieve the actual style. | |
1024 | wxTextAttr GetCombinedAttributes(const wxTextAttr& contentStyle) const; | |
1025 | ||
1026 | /// Get combined attributes of the base style and paragraph style. | |
1027 | wxTextAttr GetCombinedAttributes() const; | |
1028 | ||
1029 | /// Get the first position from pos that has a line break character. | |
1030 | long GetFirstLineBreakPosition(long pos); | |
1031 | ||
1032 | /// Create default tabstop array | |
1033 | static void InitDefaultTabs(); | |
1034 | ||
1035 | /// Clear default tabstop array | |
1036 | static void ClearDefaultTabs(); | |
1037 | ||
1038 | /// Get default tabstop array | |
1039 | static const wxArrayInt& GetDefaultTabs() { return sm_defaultTabs; } | |
1040 | ||
1041 | protected: | |
1042 | /// The lines that make up the wrapped paragraph | |
1043 | wxRichTextLineList m_cachedLines; | |
1044 | ||
1045 | /// Default tabstops | |
1046 | static wxArrayInt sm_defaultTabs; | |
1047 | }; | |
1048 | ||
1049 | /*! | |
1050 | * wxRichTextPlainText class declaration | |
1051 | * This object represents a single piece of text. | |
1052 | */ | |
1053 | ||
1054 | class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText: public wxRichTextObject | |
1055 | { | |
1056 | DECLARE_DYNAMIC_CLASS(wxRichTextPlainText) | |
1057 | public: | |
1058 | // Constructors | |
1059 | ||
1060 | wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxTextAttr* style = NULL); | |
1061 | wxRichTextPlainText(const wxRichTextPlainText& obj): wxRichTextObject() { Copy(obj); } | |
1062 | ||
1063 | // Overrideables | |
1064 | ||
1065 | /// Draw the item | |
1066 | virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); | |
1067 | ||
1068 | /// Lay the item out | |
1069 | virtual bool Layout(wxDC& dc, const wxRect& rect, int style); | |
1070 | ||
1071 | /// Get/set the object size for the given range. Returns false if the range | |
1072 | /// is invalid for this object. | |
1073 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const; | |
1074 | ||
1075 | /// Get any text in this object for the given range | |
1076 | virtual wxString GetTextForRange(const wxRichTextRange& range) const; | |
1077 | ||
1078 | /// Do a split, returning an object containing the second part, and setting | |
1079 | /// the first part in 'this'. | |
1080 | virtual wxRichTextObject* DoSplit(long pos); | |
1081 | ||
1082 | /// Calculate range | |
1083 | virtual void CalculateRange(long start, long& end); | |
1084 | ||
1085 | /// Delete range | |
1086 | virtual bool DeleteRange(const wxRichTextRange& range); | |
1087 | ||
1088 | /// Returns true if the object is empty | |
1089 | virtual bool IsEmpty() const { return m_text.empty(); } | |
1090 | ||
1091 | /// Returns true if this object can merge itself with the given one. | |
1092 | virtual bool CanMerge(wxRichTextObject* object) const; | |
1093 | ||
1094 | /// Returns true if this object merged itself with the given one. | |
1095 | /// The calling code will then delete the given object. | |
1096 | virtual bool Merge(wxRichTextObject* object); | |
1097 | ||
1098 | /// Dump to output stream for debugging | |
1099 | virtual void Dump(wxTextOutputStream& stream); | |
1100 | ||
1101 | /// Get the first position from pos that has a line break character. | |
1102 | long GetFirstLineBreakPosition(long pos); | |
1103 | ||
1104 | // Accessors | |
1105 | ||
1106 | /// Get the text | |
1107 | const wxString& GetText() const { return m_text; } | |
1108 | ||
1109 | /// Set the text | |
1110 | void SetText(const wxString& text) { m_text = text; } | |
1111 | ||
1112 | // Operations | |
1113 | ||
1114 | /// Copy | |
1115 | void Copy(const wxRichTextPlainText& obj); | |
1116 | ||
1117 | /// Clone | |
1118 | virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); } | |
1119 | private: | |
1120 | bool DrawTabbedString(wxDC& dc, const wxTextAttr& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected); | |
1121 | ||
1122 | protected: | |
1123 | wxString m_text; | |
1124 | }; | |
1125 | ||
1126 | /*! | |
1127 | * wxRichTextImageBlock stores information about an image, in binary in-memory form | |
1128 | */ | |
1129 | ||
1130 | class WXDLLIMPEXP_FWD_BASE wxDataInputStream; | |
1131 | class WXDLLIMPEXP_FWD_BASE wxDataOutputStream; | |
1132 | ||
1133 | class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock: public wxObject | |
1134 | { | |
1135 | public: | |
1136 | wxRichTextImageBlock(); | |
1137 | wxRichTextImageBlock(const wxRichTextImageBlock& block); | |
1138 | virtual ~wxRichTextImageBlock(); | |
1139 | ||
1140 | void Init(); | |
1141 | void Clear(); | |
1142 | ||
1143 | // Load the original image into a memory block. | |
1144 | // If the image is not a JPEG, we must convert it into a JPEG | |
1145 | // to conserve space. | |
1146 | // If it's not a JPEG we can make use of 'image', already scaled, so we don't have to | |
1147 | // load the image a 2nd time. | |
1148 | virtual bool MakeImageBlock(const wxString& filename, wxBitmapType imageType, | |
1149 | wxImage& image, bool convertToJPEG = true); | |
1150 | ||
1151 | // Make an image block from the wxImage in the given | |
1152 | // format. | |
1153 | virtual bool MakeImageBlock(wxImage& image, wxBitmapType imageType, int quality = 80); | |
1154 | ||
1155 | // Write to a file | |
1156 | bool Write(const wxString& filename); | |
1157 | ||
1158 | // Write data in hex to a stream | |
1159 | bool WriteHex(wxOutputStream& stream); | |
1160 | ||
1161 | // Read data in hex from a stream | |
1162 | bool ReadHex(wxInputStream& stream, int length, wxBitmapType imageType); | |
1163 | ||
1164 | // Copy from 'block' | |
1165 | void Copy(const wxRichTextImageBlock& block); | |
1166 | ||
1167 | // Load a wxImage from the block | |
1168 | bool Load(wxImage& image); | |
1169 | ||
1170 | //// Operators | |
1171 | void operator=(const wxRichTextImageBlock& block); | |
1172 | ||
1173 | //// Accessors | |
1174 | ||
1175 | unsigned char* GetData() const { return m_data; } | |
1176 | size_t GetDataSize() const { return m_dataSize; } | |
1177 | wxBitmapType GetImageType() const { return m_imageType; } | |
1178 | ||
1179 | void SetData(unsigned char* image) { m_data = image; } | |
1180 | void SetDataSize(size_t size) { m_dataSize = size; } | |
1181 | void SetImageType(wxBitmapType imageType) { m_imageType = imageType; } | |
1182 | ||
1183 | bool Ok() const { return IsOk(); } | |
1184 | bool IsOk() const { return GetData() != NULL; } | |
1185 | ||
1186 | // Gets the extension for the block's type | |
1187 | wxString GetExtension() const; | |
1188 | ||
1189 | /// Implementation | |
1190 | ||
1191 | // Allocate and read from stream as a block of memory | |
1192 | static unsigned char* ReadBlock(wxInputStream& stream, size_t size); | |
1193 | static unsigned char* ReadBlock(const wxString& filename, size_t size); | |
1194 | ||
1195 | // Write memory block to stream | |
1196 | static bool WriteBlock(wxOutputStream& stream, unsigned char* block, size_t size); | |
1197 | ||
1198 | // Write memory block to file | |
1199 | static bool WriteBlock(const wxString& filename, unsigned char* block, size_t size); | |
1200 | ||
1201 | protected: | |
1202 | // Size in bytes of the image stored. | |
1203 | // This is in the raw, original form such as a JPEG file. | |
1204 | unsigned char* m_data; | |
1205 | size_t m_dataSize; | |
1206 | wxBitmapType m_imageType; | |
1207 | }; | |
1208 | ||
1209 | ||
1210 | /*! | |
1211 | * wxRichTextImage class declaration | |
1212 | * This object represents an image. | |
1213 | */ | |
1214 | ||
1215 | class WXDLLIMPEXP_RICHTEXT wxRichTextImage: public wxRichTextObject | |
1216 | { | |
1217 | DECLARE_DYNAMIC_CLASS(wxRichTextImage) | |
1218 | public: | |
1219 | // Constructors | |
1220 | ||
1221 | wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextObject(parent) { } | |
1222 | wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxTextAttr* charStyle = NULL); | |
1223 | wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxTextAttr* charStyle = NULL); | |
1224 | wxRichTextImage(const wxRichTextImage& obj): wxRichTextObject() { Copy(obj); } | |
1225 | ||
1226 | // Overrideables | |
1227 | ||
1228 | /// Draw the item | |
1229 | virtual bool Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int descent, int style); | |
1230 | ||
1231 | /// Lay the item out | |
1232 | virtual bool Layout(wxDC& dc, const wxRect& rect, int style); | |
1233 | ||
1234 | /// Get the object size for the given range. Returns false if the range | |
1235 | /// is invalid for this object. | |
1236 | virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, int flags, wxPoint position = wxPoint(0,0), wxArrayInt* partialExtents = NULL) const; | |
1237 | ||
1238 | /// Returns true if the object is empty | |
1239 | virtual bool IsEmpty() const { return !m_image.Ok(); } | |
1240 | ||
1241 | // Accessors | |
1242 | ||
1243 | /// Get the image | |
1244 | const wxImage& GetImage() const { return m_image; } | |
1245 | ||
1246 | /// Set the image | |
1247 | void SetImage(const wxImage& image) { m_image = image; } | |
1248 | ||
1249 | /// Get the image block containing the raw data | |
1250 | wxRichTextImageBlock& GetImageBlock() { return m_imageBlock; } | |
1251 | ||
1252 | // Operations | |
1253 | ||
1254 | /// Copy | |
1255 | void Copy(const wxRichTextImage& obj); | |
1256 | ||
1257 | /// Clone | |
1258 | virtual wxRichTextObject* Clone() const { return new wxRichTextImage(*this); } | |
1259 | ||
1260 | /// Load wxImage from the block | |
1261 | virtual bool LoadFromBlock(); | |
1262 | ||
1263 | /// Make block from the wxImage | |
1264 | virtual bool MakeBlock(); | |
1265 | ||
1266 | protected: | |
1267 | // TODO: reduce the multiple representations of data | |
1268 | wxImage m_image; | |
1269 | wxBitmap m_bitmap; | |
1270 | wxRichTextImageBlock m_imageBlock; | |
1271 | }; | |
1272 | ||
1273 | ||
1274 | /*! | |
1275 | * wxRichTextBuffer class declaration | |
1276 | * This is a kind of box, used to represent the whole buffer | |
1277 | */ | |
1278 | ||
1279 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCommand; | |
1280 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction; | |
1281 | ||
1282 | class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer: public wxRichTextParagraphLayoutBox | |
1283 | { | |
1284 | DECLARE_DYNAMIC_CLASS(wxRichTextBuffer) | |
1285 | public: | |
1286 | // Constructors | |
1287 | ||
1288 | wxRichTextBuffer() { Init(); } | |
1289 | wxRichTextBuffer(const wxRichTextBuffer& obj): wxRichTextParagraphLayoutBox() { Init(); Copy(obj); } | |
1290 | virtual ~wxRichTextBuffer() ; | |
1291 | ||
1292 | // Accessors | |
1293 | ||
1294 | /// Gets the command processor | |
1295 | wxCommandProcessor* GetCommandProcessor() const { return m_commandProcessor; } | |
1296 | ||
1297 | /// Set style sheet, if any. | |
1298 | void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { m_styleSheet = styleSheet; } | |
1299 | virtual wxRichTextStyleSheet* GetStyleSheet() const { return m_styleSheet; } | |
1300 | ||
1301 | /// Set style sheet and notify of the change | |
1302 | bool SetStyleSheetAndNotify(wxRichTextStyleSheet* sheet); | |
1303 | ||
1304 | /// Push style sheet to top of stack | |
1305 | bool PushStyleSheet(wxRichTextStyleSheet* styleSheet); | |
1306 | ||
1307 | /// Pop style sheet from top of stack | |
1308 | wxRichTextStyleSheet* PopStyleSheet(); | |
1309 | ||
1310 | /// Set/get table storing fonts | |
1311 | wxRichTextFontTable& GetFontTable() { return m_fontTable; } | |
1312 | const wxRichTextFontTable& GetFontTable() const { return m_fontTable; } | |
1313 | void SetFontTable(const wxRichTextFontTable& table) { m_fontTable = table; } | |
1314 | ||
1315 | // Operations | |
1316 | ||
1317 | /// Initialisation | |
1318 | void Init(); | |
1319 | ||
1320 | /// Clears the buffer, adds an empty paragraph, and clears the command processor. | |
1321 | virtual void ResetAndClearCommands(); | |
1322 | ||
1323 | /// Load a file | |
1324 | virtual bool LoadFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); | |
1325 | ||
1326 | /// Save a file | |
1327 | virtual bool SaveFile(const wxString& filename, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); | |
1328 | ||
1329 | /// Load from a stream | |
1330 | virtual bool LoadFile(wxInputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); | |
1331 | ||
1332 | /// Save to a stream | |
1333 | virtual bool SaveFile(wxOutputStream& stream, wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); | |
1334 | ||
1335 | /// Set the handler flags, controlling loading and saving | |
1336 | void SetHandlerFlags(int flags) { m_handlerFlags = flags; } | |
1337 | ||
1338 | /// Get the handler flags, controlling loading and saving | |
1339 | int GetHandlerFlags() const { return m_handlerFlags; } | |
1340 | ||
1341 | /// Convenience function to add a paragraph of text | |
1342 | virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttr* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); } | |
1343 | ||
1344 | /// Begin collapsing undo/redo commands. Note that this may not work properly | |
1345 | /// if combining commands that delete or insert content, changing ranges for | |
1346 | /// subsequent actions. | |
1347 | virtual bool BeginBatchUndo(const wxString& cmdName); | |
1348 | ||
1349 | /// End collapsing undo/redo commands | |
1350 | virtual bool EndBatchUndo(); | |
1351 | ||
1352 | /// Collapsing commands? | |
1353 | virtual bool BatchingUndo() const { return m_batchedCommandDepth > 0; } | |
1354 | ||
1355 | /// Submit immediately, or delay according to whether collapsing is on | |
1356 | virtual bool SubmitAction(wxRichTextAction* action); | |
1357 | ||
1358 | /// Get collapsed command | |
1359 | virtual wxRichTextCommand* GetBatchedCommand() const { return m_batchedCommand; } | |
1360 | ||
1361 | /// Begin suppressing undo/redo commands. The way undo is suppressed may be implemented | |
1362 | /// differently by each command. If not dealt with by a command implementation, then | |
1363 | /// it will be implemented automatically by not storing the command in the undo history | |
1364 | /// when the action is submitted to the command processor. | |
1365 | virtual bool BeginSuppressUndo(); | |
1366 | ||
1367 | /// End suppressing undo/redo commands. | |
1368 | virtual bool EndSuppressUndo(); | |
1369 | ||
1370 | /// Collapsing commands? | |
1371 | virtual bool SuppressingUndo() const { return m_suppressUndo > 0; } | |
1372 | ||
1373 | /// Copy the range to the clipboard | |
1374 | virtual bool CopyToClipboard(const wxRichTextRange& range); | |
1375 | ||
1376 | /// Paste the clipboard content to the buffer | |
1377 | virtual bool PasteFromClipboard(long position); | |
1378 | ||
1379 | /// Can we paste from the clipboard? | |
1380 | virtual bool CanPasteFromClipboard() const; | |
1381 | ||
1382 | /// Begin using a style | |
1383 | virtual bool BeginStyle(const wxTextAttr& style); | |
1384 | ||
1385 | /// End the style | |
1386 | virtual bool EndStyle(); | |
1387 | ||
1388 | /// End all styles | |
1389 | virtual bool EndAllStyles(); | |
1390 | ||
1391 | /// Clear the style stack | |
1392 | virtual void ClearStyleStack(); | |
1393 | ||
1394 | /// Get the size of the style stack, for example to check correct nesting | |
1395 | virtual size_t GetStyleStackSize() const { return m_attributeStack.GetCount(); } | |
1396 | ||
1397 | /// Begin using bold | |
1398 | bool BeginBold(); | |
1399 | ||
1400 | /// End using bold | |
1401 | bool EndBold() { return EndStyle(); } | |
1402 | ||
1403 | /// Begin using italic | |
1404 | bool BeginItalic(); | |
1405 | ||
1406 | /// End using italic | |
1407 | bool EndItalic() { return EndStyle(); } | |
1408 | ||
1409 | /// Begin using underline | |
1410 | bool BeginUnderline(); | |
1411 | ||
1412 | /// End using underline | |
1413 | bool EndUnderline() { return EndStyle(); } | |
1414 | ||
1415 | /// Begin using point size | |
1416 | bool BeginFontSize(int pointSize); | |
1417 | ||
1418 | /// End using point size | |
1419 | bool EndFontSize() { return EndStyle(); } | |
1420 | ||
1421 | /// Begin using this font | |
1422 | bool BeginFont(const wxFont& font); | |
1423 | ||
1424 | /// End using a font | |
1425 | bool EndFont() { return EndStyle(); } | |
1426 | ||
1427 | /// Begin using this colour | |
1428 | bool BeginTextColour(const wxColour& colour); | |
1429 | ||
1430 | /// End using a colour | |
1431 | bool EndTextColour() { return EndStyle(); } | |
1432 | ||
1433 | /// Begin using alignment | |
1434 | bool BeginAlignment(wxTextAttrAlignment alignment); | |
1435 | ||
1436 | /// End alignment | |
1437 | bool EndAlignment() { return EndStyle(); } | |
1438 | ||
1439 | /// Begin left indent | |
1440 | bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0); | |
1441 | ||
1442 | /// End left indent | |
1443 | bool EndLeftIndent() { return EndStyle(); } | |
1444 | ||
1445 | /// Begin right indent | |
1446 | bool BeginRightIndent(int rightIndent); | |
1447 | ||
1448 | /// End right indent | |
1449 | bool EndRightIndent() { return EndStyle(); } | |
1450 | ||
1451 | /// Begin paragraph spacing | |
1452 | bool BeginParagraphSpacing(int before, int after); | |
1453 | ||
1454 | /// End paragraph spacing | |
1455 | bool EndParagraphSpacing() { return EndStyle(); } | |
1456 | ||
1457 | /// Begin line spacing | |
1458 | bool BeginLineSpacing(int lineSpacing); | |
1459 | ||
1460 | /// End line spacing | |
1461 | bool EndLineSpacing() { return EndStyle(); } | |
1462 | ||
1463 | /// Begin numbered bullet | |
1464 | bool BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD); | |
1465 | ||
1466 | /// End numbered bullet | |
1467 | bool EndNumberedBullet() { return EndStyle(); } | |
1468 | ||
1469 | /// Begin symbol bullet | |
1470 | bool BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL); | |
1471 | ||
1472 | /// End symbol bullet | |
1473 | bool EndSymbolBullet() { return EndStyle(); } | |
1474 | ||
1475 | /// Begin standard bullet | |
1476 | bool BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD); | |
1477 | ||
1478 | /// End standard bullet | |
1479 | bool EndStandardBullet() { return EndStyle(); } | |
1480 | ||
1481 | /// Begin named character style | |
1482 | bool BeginCharacterStyle(const wxString& characterStyle); | |
1483 | ||
1484 | /// End named character style | |
1485 | bool EndCharacterStyle() { return EndStyle(); } | |
1486 | ||
1487 | /// Begin named paragraph style | |
1488 | bool BeginParagraphStyle(const wxString& paragraphStyle); | |
1489 | ||
1490 | /// End named character style | |
1491 | bool EndParagraphStyle() { return EndStyle(); } | |
1492 | ||
1493 | /// Begin named list style | |
1494 | bool BeginListStyle(const wxString& listStyle, int level = 1, int number = 1); | |
1495 | ||
1496 | /// End named character style | |
1497 | bool EndListStyle() { return EndStyle(); } | |
1498 | ||
1499 | /// Begin URL | |
1500 | bool BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString); | |
1501 | ||
1502 | /// End URL | |
1503 | bool EndURL() { return EndStyle(); } | |
1504 | ||
1505 | // Event handling | |
1506 | ||
1507 | /// Add an event handler | |
1508 | bool AddEventHandler(wxEvtHandler* handler); | |
1509 | ||
1510 | /// Remove an event handler | |
1511 | bool RemoveEventHandler(wxEvtHandler* handler, bool deleteHandler = false); | |
1512 | ||
1513 | /// Clear event handlers | |
1514 | void ClearEventHandlers(); | |
1515 | ||
1516 | /// Send event to event handlers. If sendToAll is true, will send to all event handlers, | |
1517 | /// otherwise will stop at the first successful one. | |
1518 | bool SendEvent(wxEvent& event, bool sendToAll = true); | |
1519 | ||
1520 | // Implementation | |
1521 | ||
1522 | /// Copy | |
1523 | void Copy(const wxRichTextBuffer& obj); | |
1524 | ||
1525 | /// Clone | |
1526 | virtual wxRichTextObject* Clone() const { return new wxRichTextBuffer(*this); } | |
1527 | ||
1528 | /// Submit command to insert paragraphs | |
1529 | bool InsertParagraphsWithUndo(long pos, const wxRichTextParagraphLayoutBox& paragraphs, wxRichTextCtrl* ctrl, int flags = 0); | |
1530 | ||
1531 | /// Submit command to insert the given text | |
1532 | bool InsertTextWithUndo(long pos, const wxString& text, wxRichTextCtrl* ctrl, int flags = 0); | |
1533 | ||
1534 | /// Submit command to insert a newline | |
1535 | bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int flags = 0); | |
1536 | ||
1537 | /// Submit command to insert the given image | |
1538 | bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags = 0); | |
1539 | ||
1540 | /// Submit command to delete this range | |
1541 | bool DeleteRangeWithUndo(const wxRichTextRange& range, wxRichTextCtrl* ctrl); | |
1542 | ||
1543 | /// Mark modified | |
1544 | void Modify(bool modify = true) { m_modified = modify; } | |
1545 | bool IsModified() const { return m_modified; } | |
1546 | ||
1547 | /// Get the style that is appropriate for a new paragraph at this position. | |
1548 | /// If the previous paragraph has a paragraph style name, look up the next-paragraph | |
1549 | /// style. | |
1550 | wxTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const; | |
1551 | ||
1552 | /// Dumps contents of buffer for debugging purposes | |
1553 | virtual void Dump(); | |
1554 | virtual void Dump(wxTextOutputStream& stream) { wxRichTextParagraphLayoutBox::Dump(stream); } | |
1555 | ||
1556 | /// Returns the file handlers | |
1557 | static wxList& GetHandlers() { return sm_handlers; } | |
1558 | ||
1559 | /// Adds a handler to the end | |
1560 | static void AddHandler(wxRichTextFileHandler *handler); | |
1561 | ||
1562 | /// Inserts a handler at the front | |
1563 | static void InsertHandler(wxRichTextFileHandler *handler); | |
1564 | ||
1565 | /// Removes a handler | |
1566 | static bool RemoveHandler(const wxString& name); | |
1567 | ||
1568 | /// Finds a handler by name | |
1569 | static wxRichTextFileHandler *FindHandler(const wxString& name); | |
1570 | ||
1571 | /// Finds a handler by extension and type | |
1572 | static wxRichTextFileHandler *FindHandler(const wxString& extension, wxRichTextFileType imageType); | |
1573 | ||
1574 | /// Finds a handler by filename or, if supplied, type | |
1575 | static wxRichTextFileHandler *FindHandlerFilenameOrType(const wxString& filename, | |
1576 | wxRichTextFileType imageType); | |
1577 | ||
1578 | /// Finds a handler by type | |
1579 | static wxRichTextFileHandler *FindHandler(wxRichTextFileType imageType); | |
1580 | ||
1581 | /// Gets a wildcard incorporating all visible handlers. If 'types' is present, | |
1582 | /// will be filled with the file type corresponding to each filter. This can be | |
1583 | /// used to determine the type to pass to LoadFile given a selected filter. | |
1584 | static wxString GetExtWildcard(bool combine = false, bool save = false, wxArrayInt* types = NULL); | |
1585 | ||
1586 | /// Clean up handlers | |
1587 | static void CleanUpHandlers(); | |
1588 | ||
1589 | /// Initialise the standard handlers | |
1590 | static void InitStandardHandlers(); | |
1591 | ||
1592 | /// Get renderer | |
1593 | static wxRichTextRenderer* GetRenderer() { return sm_renderer; } | |
1594 | ||
1595 | /// Set renderer, deleting old one | |
1596 | static void SetRenderer(wxRichTextRenderer* renderer); | |
1597 | ||
1598 | /// Minimum margin between bullet and paragraph in 10ths of a mm | |
1599 | static int GetBulletRightMargin() { return sm_bulletRightMargin; } | |
1600 | static void SetBulletRightMargin(int margin) { sm_bulletRightMargin = margin; } | |
1601 | ||
1602 | /// Factor to multiply by character height to get a reasonable bullet size | |
1603 | static float GetBulletProportion() { return sm_bulletProportion; } | |
1604 | static void SetBulletProportion(float prop) { sm_bulletProportion = prop; } | |
1605 | ||
1606 | /// Scale factor for calculating dimensions | |
1607 | double GetScale() const { return m_scale; } | |
1608 | void SetScale(double scale) { m_scale = scale; } | |
1609 | ||
1610 | protected: | |
1611 | ||
1612 | /// Command processor | |
1613 | wxCommandProcessor* m_commandProcessor; | |
1614 | ||
1615 | /// Table storing fonts | |
1616 | wxRichTextFontTable m_fontTable; | |
1617 | ||
1618 | /// Has been modified? | |
1619 | bool m_modified; | |
1620 | ||
1621 | /// Collapsed command stack | |
1622 | int m_batchedCommandDepth; | |
1623 | ||
1624 | /// Name for collapsed command | |
1625 | wxString m_batchedCommandsName; | |
1626 | ||
1627 | /// Current collapsed command accumulating actions | |
1628 | wxRichTextCommand* m_batchedCommand; | |
1629 | ||
1630 | /// Whether to suppress undo | |
1631 | int m_suppressUndo; | |
1632 | ||
1633 | /// Style sheet, if any | |
1634 | wxRichTextStyleSheet* m_styleSheet; | |
1635 | ||
1636 | /// List of event handlers that will be notified of events | |
1637 | wxList m_eventHandlers; | |
1638 | ||
1639 | /// Stack of attributes for convenience functions | |
1640 | wxList m_attributeStack; | |
1641 | ||
1642 | /// Flags to be passed to handlers | |
1643 | int m_handlerFlags; | |
1644 | ||
1645 | /// File handlers | |
1646 | static wxList sm_handlers; | |
1647 | ||
1648 | /// Renderer | |
1649 | static wxRichTextRenderer* sm_renderer; | |
1650 | ||
1651 | /// Minimum margin between bullet and paragraph in 10ths of a mm | |
1652 | static int sm_bulletRightMargin; | |
1653 | ||
1654 | /// Factor to multiply by character height to get a reasonable bullet size | |
1655 | static float sm_bulletProportion; | |
1656 | ||
1657 | /// Scaling factor in use: needed to calculate correct dimensions when printing | |
1658 | double m_scale; | |
1659 | }; | |
1660 | ||
1661 | /*! | |
1662 | * The command identifiers | |
1663 | * | |
1664 | */ | |
1665 | ||
1666 | enum wxRichTextCommandId | |
1667 | { | |
1668 | wxRICHTEXT_INSERT, | |
1669 | wxRICHTEXT_DELETE, | |
1670 | wxRICHTEXT_CHANGE_STYLE | |
1671 | }; | |
1672 | ||
1673 | /*! | |
1674 | * Command classes for undo/redo | |
1675 | * | |
1676 | */ | |
1677 | ||
1678 | class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction; | |
1679 | class WXDLLIMPEXP_RICHTEXT wxRichTextCommand: public wxCommand | |
1680 | { | |
1681 | public: | |
1682 | // Ctor for one action | |
1683 | wxRichTextCommand(const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, | |
1684 | wxRichTextCtrl* ctrl, bool ignoreFirstTime = false); | |
1685 | ||
1686 | // Ctor for multiple actions | |
1687 | wxRichTextCommand(const wxString& name); | |
1688 | ||
1689 | virtual ~wxRichTextCommand(); | |
1690 | ||
1691 | bool Do(); | |
1692 | bool Undo(); | |
1693 | ||
1694 | void AddAction(wxRichTextAction* action); | |
1695 | void ClearActions(); | |
1696 | ||
1697 | wxList& GetActions() { return m_actions; } | |
1698 | ||
1699 | protected: | |
1700 | ||
1701 | wxList m_actions; | |
1702 | }; | |
1703 | ||
1704 | /*! | |
1705 | * wxRichTextAction class declaration | |
1706 | * There can be more than one action in a command. | |
1707 | */ | |
1708 | ||
1709 | class WXDLLIMPEXP_RICHTEXT wxRichTextAction: public wxObject | |
1710 | { | |
1711 | public: | |
1712 | wxRichTextAction(wxRichTextCommand* cmd, const wxString& name, wxRichTextCommandId id, wxRichTextBuffer* buffer, | |
1713 | wxRichTextCtrl* ctrl, bool ignoreFirstTime = false); | |
1714 | ||
1715 | virtual ~wxRichTextAction(); | |
1716 | ||
1717 | bool Do(); | |
1718 | bool Undo(); | |
1719 | ||
1720 | /// Update the control appearance | |
1721 | void UpdateAppearance(long caretPosition, bool sendUpdateEvent = false, | |
1722 | wxArrayInt* optimizationLineCharPositions = NULL, wxArrayInt* optimizationLineYPositions = NULL, bool isDoCmd = true); | |
1723 | ||
1724 | /// Replace the buffer paragraphs with the given fragment. | |
1725 | void ApplyParagraphs(const wxRichTextParagraphLayoutBox& fragment); | |
1726 | ||
1727 | /// Get the fragments | |
1728 | wxRichTextParagraphLayoutBox& GetNewParagraphs() { return m_newParagraphs; } | |
1729 | wxRichTextParagraphLayoutBox& GetOldParagraphs() { return m_oldParagraphs; } | |
1730 | ||
1731 | /// Calculate arrays for refresh optimization | |
1732 | void CalculateRefreshOptimizations(wxArrayInt& optimizationLineCharPositions, wxArrayInt& optimizationLineYPositions); | |
1733 | ||
1734 | /// Set/get the position used for e.g. insertion | |
1735 | void SetPosition(long pos) { m_position = pos; } | |
1736 | long GetPosition() const { return m_position; } | |
1737 | ||
1738 | /// Set/get the range for e.g. deletion | |
1739 | void SetRange(const wxRichTextRange& range) { m_range = range; } | |
1740 | const wxRichTextRange& GetRange() const { return m_range; } | |
1741 | ||
1742 | /// Get name | |
1743 | const wxString& GetName() const { return m_name; } | |
1744 | ||
1745 | protected: | |
1746 | // Action name | |
1747 | wxString m_name; | |
1748 | ||
1749 | // Buffer | |
1750 | wxRichTextBuffer* m_buffer; | |
1751 | ||
1752 | // Control | |
1753 | wxRichTextCtrl* m_ctrl; | |
1754 | ||
1755 | // Stores the new paragraphs | |
1756 | wxRichTextParagraphLayoutBox m_newParagraphs; | |
1757 | ||
1758 | // Stores the old paragraphs | |
1759 | wxRichTextParagraphLayoutBox m_oldParagraphs; | |
1760 | ||
1761 | // The affected range | |
1762 | wxRichTextRange m_range; | |
1763 | ||
1764 | // The insertion point for this command | |
1765 | long m_position; | |
1766 | ||
1767 | // Ignore 1st 'Do' operation because we already did it | |
1768 | bool m_ignoreThis; | |
1769 | ||
1770 | // The command identifier | |
1771 | wxRichTextCommandId m_cmdId; | |
1772 | }; | |
1773 | ||
1774 | /*! | |
1775 | * Handler flags | |
1776 | */ | |
1777 | ||
1778 | // Include style sheet when loading and saving | |
1779 | #define wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET 0x0001 | |
1780 | ||
1781 | // Save images to memory file system in HTML handler | |
1782 | #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY 0x0010 | |
1783 | ||
1784 | // Save images to files in HTML handler | |
1785 | #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES 0x0020 | |
1786 | ||
1787 | // Save images as inline base64 data in HTML handler | |
1788 | #define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040 | |
1789 | ||
1790 | // Don't write header and footer (or BODY), so we can include the fragment | |
1791 | // in a larger document | |
1792 | #define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080 | |
1793 | ||
1794 | // Convert the more common face names to names that will work on the current platform | |
1795 | // in a larger document | |
1796 | #define wxRICHTEXT_HANDLER_CONVERT_FACENAMES 0x0100 | |
1797 | ||
1798 | /*! | |
1799 | * wxRichTextFileHandler | |
1800 | * Base class for file handlers | |
1801 | */ | |
1802 | ||
1803 | class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler: public wxObject | |
1804 | { | |
1805 | DECLARE_CLASS(wxRichTextFileHandler) | |
1806 | public: | |
1807 | wxRichTextFileHandler(const wxString& name = wxEmptyString, const wxString& ext = wxEmptyString, int type = 0) | |
1808 | : m_name(name), m_extension(ext), m_type(type), m_flags(0), m_visible(true) | |
1809 | { } | |
1810 | ||
1811 | #if wxUSE_STREAMS | |
1812 | bool LoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) | |
1813 | { return DoLoadFile(buffer, stream); } | |
1814 | bool SaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) | |
1815 | { return DoSaveFile(buffer, stream); } | |
1816 | #endif | |
1817 | ||
1818 | #if wxUSE_FFILE && wxUSE_STREAMS | |
1819 | virtual bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename); | |
1820 | virtual bool SaveFile(wxRichTextBuffer *buffer, const wxString& filename); | |
1821 | #endif // wxUSE_STREAMS && wxUSE_STREAMS | |
1822 | ||
1823 | /// Can we handle this filename (if using files)? By default, checks the extension. | |
1824 | virtual bool CanHandle(const wxString& filename) const; | |
1825 | ||
1826 | /// Can we save using this handler? | |
1827 | virtual bool CanSave() const { return false; } | |
1828 | ||
1829 | /// Can we load using this handler? | |
1830 | virtual bool CanLoad() const { return false; } | |
1831 | ||
1832 | /// Should this handler be visible to the user? | |
1833 | virtual bool IsVisible() const { return m_visible; } | |
1834 | virtual void SetVisible(bool visible) { m_visible = visible; } | |
1835 | ||
1836 | /// The name of the nandler | |
1837 | void SetName(const wxString& name) { m_name = name; } | |
1838 | wxString GetName() const { return m_name; } | |
1839 | ||
1840 | /// The default extension to recognise | |
1841 | void SetExtension(const wxString& ext) { m_extension = ext; } | |
1842 | wxString GetExtension() const { return m_extension; } | |
1843 | ||
1844 | /// The handler type | |
1845 | void SetType(int type) { m_type = type; } | |
1846 | int GetType() const { return m_type; } | |
1847 | ||
1848 | /// Flags controlling how loading and saving is done | |
1849 | void SetFlags(int flags) { m_flags = flags; } | |
1850 | int GetFlags() const { return m_flags; } | |
1851 | ||
1852 | /// Encoding to use when saving a file. If empty, a suitable encoding is chosen | |
1853 | void SetEncoding(const wxString& encoding) { m_encoding = encoding; } | |
1854 | const wxString& GetEncoding() const { return m_encoding; } | |
1855 | ||
1856 | protected: | |
1857 | ||
1858 | #if wxUSE_STREAMS | |
1859 | virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream) = 0; | |
1860 | virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream) = 0; | |
1861 | #endif | |
1862 | ||
1863 | wxString m_name; | |
1864 | wxString m_encoding; | |
1865 | wxString m_extension; | |
1866 | int m_type; | |
1867 | int m_flags; | |
1868 | bool m_visible; | |
1869 | }; | |
1870 | ||
1871 | /*! | |
1872 | * wxRichTextPlainTextHandler | |
1873 | * Plain text handler | |
1874 | */ | |
1875 | ||
1876 | class WXDLLIMPEXP_RICHTEXT wxRichTextPlainTextHandler: public wxRichTextFileHandler | |
1877 | { | |
1878 | DECLARE_CLASS(wxRichTextPlainTextHandler) | |
1879 | public: | |
1880 | wxRichTextPlainTextHandler(const wxString& name = wxT("Text"), | |
1881 | const wxString& ext = wxT("txt"), | |
1882 | wxRichTextFileType type = wxRICHTEXT_TYPE_TEXT) | |
1883 | : wxRichTextFileHandler(name, ext, type) | |
1884 | { } | |
1885 | ||
1886 | /// Can we save using this handler? | |
1887 | virtual bool CanSave() const { return true; } | |
1888 | ||
1889 | /// Can we load using this handler? | |
1890 | virtual bool CanLoad() const { return true; } | |
1891 | ||
1892 | protected: | |
1893 | ||
1894 | #if wxUSE_STREAMS | |
1895 | virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream); | |
1896 | virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream); | |
1897 | #endif | |
1898 | ||
1899 | }; | |
1900 | ||
1901 | #if wxUSE_DATAOBJ | |
1902 | ||
1903 | /*! | |
1904 | * The data object for a wxRichTextBuffer | |
1905 | */ | |
1906 | ||
1907 | class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject: public wxDataObjectSimple | |
1908 | { | |
1909 | public: | |
1910 | // ctor doesn't copy the pointer, so it shouldn't go away while this object | |
1911 | // is alive | |
1912 | wxRichTextBufferDataObject(wxRichTextBuffer* richTextBuffer = NULL); | |
1913 | virtual ~wxRichTextBufferDataObject(); | |
1914 | ||
1915 | // after a call to this function, the buffer is owned by the caller and it | |
1916 | // is responsible for deleting it | |
1917 | wxRichTextBuffer* GetRichTextBuffer(); | |
1918 | ||
1919 | // Returns the id for the new data format | |
1920 | static const wxChar* GetRichTextBufferFormatId() { return ms_richTextBufferFormatId; } | |
1921 | ||
1922 | // base class pure virtuals | |
1923 | ||
1924 | virtual wxDataFormat GetPreferredFormat(Direction dir) const; | |
1925 | virtual size_t GetDataSize() const; | |
1926 | virtual bool GetDataHere(void *pBuf) const; | |
1927 | virtual bool SetData(size_t len, const void *buf); | |
1928 | ||
1929 | // prevent warnings | |
1930 | ||
1931 | virtual size_t GetDataSize(const wxDataFormat&) const { return GetDataSize(); } | |
1932 | virtual bool GetDataHere(const wxDataFormat&, void *buf) const { return GetDataHere(buf); } | |
1933 | virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) { return SetData(len, buf); } | |
1934 | ||
1935 | private: | |
1936 | wxDataFormat m_formatRichTextBuffer; // our custom format | |
1937 | wxRichTextBuffer* m_richTextBuffer; // our data | |
1938 | static const wxChar* ms_richTextBufferFormatId; // our format id | |
1939 | }; | |
1940 | ||
1941 | #endif | |
1942 | ||
1943 | /*! | |
1944 | * wxRichTextRenderer isolates common drawing functionality | |
1945 | */ | |
1946 | ||
1947 | class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer: public wxObject | |
1948 | { | |
1949 | public: | |
1950 | wxRichTextRenderer() {} | |
1951 | virtual ~wxRichTextRenderer() {} | |
1952 | ||
1953 | /// Draw a standard bullet, as specified by the value of GetBulletName | |
1954 | virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect) = 0; | |
1955 | ||
1956 | /// Draw a bullet that can be described by text, such as numbered or symbol bullets | |
1957 | virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text) = 0; | |
1958 | ||
1959 | /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName | |
1960 | virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect) = 0; | |
1961 | ||
1962 | /// Enumerate the standard bullet names currently supported | |
1963 | virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0; | |
1964 | }; | |
1965 | ||
1966 | /*! | |
1967 | * wxRichTextStdRenderer: standard renderer | |
1968 | */ | |
1969 | ||
1970 | class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer: public wxRichTextRenderer | |
1971 | { | |
1972 | public: | |
1973 | wxRichTextStdRenderer() {} | |
1974 | ||
1975 | /// Draw a standard bullet, as specified by the value of GetBulletName | |
1976 | virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect); | |
1977 | ||
1978 | /// Draw a bullet that can be described by text, such as numbered or symbol bullets | |
1979 | virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text); | |
1980 | ||
1981 | /// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName | |
1982 | virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect); | |
1983 | ||
1984 | /// Enumerate the standard bullet names currently supported | |
1985 | virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames); | |
1986 | }; | |
1987 | ||
1988 | /*! | |
1989 | * Utilities | |
1990 | * | |
1991 | */ | |
1992 | ||
1993 | inline bool wxRichTextHasStyle(int flags, int style) | |
1994 | { | |
1995 | return ((flags & style) == style); | |
1996 | } | |
1997 | ||
1998 | /// Compare two attribute objects | |
1999 | WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2); | |
2000 | WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2); | |
2001 | ||
2002 | /// Compare two attribute objects, but take into account the flags | |
2003 | /// specifying attributes of interest. | |
2004 | WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttr& attr1, const wxTextAttr& attr2, int flags); | |
2005 | ||
2006 | /// Apply one style to another | |
2007 | WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttr& destStyle, const wxTextAttr& style, wxTextAttr* compareWith = NULL); | |
2008 | ||
2009 | // Remove attributes | |
2010 | WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style); | |
2011 | ||
2012 | /// Combine two bitlists | |
2013 | WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB); | |
2014 | ||
2015 | /// Compare two bitlists | |
2016 | WXDLLIMPEXP_RICHTEXT bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags); | |
2017 | ||
2018 | /// Split into paragraph and character styles | |
2019 | WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle); | |
2020 | ||
2021 | /// Compare tabs | |
2022 | WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2); | |
2023 | ||
2024 | /// Convert a decimal to Roman numerals | |
2025 | WXDLLIMPEXP_RICHTEXT wxString wxRichTextDecimalToRoman(long n); | |
2026 | ||
2027 | WXDLLIMPEXP_RICHTEXT void wxRichTextModuleInit(); | |
2028 | ||
2029 | #endif | |
2030 | // wxUSE_RICHTEXT | |
2031 | ||
2032 | #endif | |
2033 | // _WX_RICHTEXTBUFFER_H_ | |
2034 |