Fix warnings in rich text documentation.
[wxWidgets.git] / interface / wx / richtext / richtextctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richtextctrl.h
3 // Purpose: A rich edit control
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 2005-09-30
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 /*
12 * Styles and flags
13 */
14
15 /**
16 Styles
17 */
18
19 #define wxRE_READONLY 0x0010
20 #define wxRE_MULTILINE 0x0020
21 #define wxRE_CENTRE_CARET 0x8000
22 #define wxRE_CENTER_CARET wxRE_CENTRE_CARET
23
24 /**
25 Flags
26 */
27
28 #define wxRICHTEXT_SHIFT_DOWN 0x01
29 #define wxRICHTEXT_CTRL_DOWN 0x02
30 #define wxRICHTEXT_ALT_DOWN 0x04
31
32 /**
33 Extra flags
34 */
35
36 // Don't draw guide lines around boxes and tables
37 #define wxRICHTEXT_EX_NO_GUIDELINES 0x00000100
38
39
40 /*
41 Defaults
42 */
43
44 #define wxRICHTEXT_DEFAULT_OVERALL_SIZE wxSize(-1, -1)
45 #define wxRICHTEXT_DEFAULT_IMAGE_SIZE wxSize(80, 80)
46 #define wxRICHTEXT_DEFAULT_SPACING 3
47 #define wxRICHTEXT_DEFAULT_MARGIN 3
48 #define wxRICHTEXT_DEFAULT_UNFOCUSSED_BACKGROUND wxColour(175, 175, 175)
49 #define wxRICHTEXT_DEFAULT_FOCUSSED_BACKGROUND wxColour(140, 140, 140)
50 #define wxRICHTEXT_DEFAULT_UNSELECTED_BACKGROUND wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE)
51 #define wxRICHTEXT_DEFAULT_TYPE_COLOUR wxColour(0, 0, 200)
52 #define wxRICHTEXT_DEFAULT_FOCUS_RECT_COLOUR wxColour(100, 80, 80)
53 #define wxRICHTEXT_DEFAULT_CARET_WIDTH 2
54 // Minimum buffer size before delayed layout kicks in
55 #define wxRICHTEXT_DEFAULT_DELAYED_LAYOUT_THRESHOLD 20000
56 // Milliseconds before layout occurs after resize
57 #define wxRICHTEXT_DEFAULT_LAYOUT_INTERVAL 50
58
59 /* Identifiers
60 */
61 #define wxID_RICHTEXT_PROPERTIES1 (wxID_HIGHEST + 1)
62 #define wxID_RICHTEXT_PROPERTIES2 (wxID_HIGHEST + 2)
63 #define wxID_RICHTEXT_PROPERTIES3 (wxID_HIGHEST + 3)
64
65 /*
66 Normal selection occurs initially and as user drags within one container.
67 Common ancestor selection occurs when the user starts dragging across containers
68 that have a common ancestor, for example the cells in a table.
69 */
70
71 enum wxRichTextCtrlSelectionState
72 {
73 wxRichTextCtrlSelectionState_Normal,
74 wxRichTextCtrlSelectionState_CommonAncestor
75 };
76
77 /**
78 @class wxRichTextContextMenuPropertiesInfo
79
80 wxRichTextContextMenuPropertiesInfo keeps track of objects that appear in the context menu,
81 whose properties are available to be edited.
82 */
83
84 class wxRichTextContextMenuPropertiesInfo
85 {
86 public:
87 /**
88 Constructor.
89 */
90 wxRichTextContextMenuPropertiesInfo();
91
92 // Operations
93
94 /**
95 Initialisation.
96 */
97 void Init();
98
99 /**
100 Adds an item.
101 */
102 bool AddItem(const wxString& label, wxRichTextObject* obj);
103
104 /**
105 Returns the number of menu items that were added.
106 */
107 int AddMenuItems(wxMenu* menu, int startCmd = wxID_RICHTEXT_PROPERTIES1) const;
108
109 /**
110 Adds appropriate menu items for the current container and clicked on object
111 (and container's parent, if appropriate).
112 */
113 int AddItems(wxRichTextCtrl* ctrl, wxRichTextObject* container, wxRichTextObject* obj);
114
115 /**
116 Clears the items.
117 */
118 void Clear();
119
120 // Accessors
121
122 /**
123 Returns the nth label.
124 */
125 wxString GetLabel(int n) const;
126
127 /**
128 Returns the nth object.
129 */
130 wxRichTextObject* GetObject(int n) const;
131
132 /**
133 Returns the array of objects.
134 */
135 wxRichTextObjectPtrArray& GetObjects();
136
137 /**
138 Returns the array of objects.
139 */
140 const wxRichTextObjectPtrArray& GetObjects() const;
141
142 /**
143 Returns the array of labels.
144 */
145 wxArrayString& GetLabels();
146
147 /**
148 Returns the array of labels.
149 */
150 const wxArrayString& GetLabels() const;
151
152 /**
153 Returns the number of items.
154 */
155 int GetCount() const;
156
157 wxRichTextObjectPtrArray m_objects;
158 wxArrayString m_labels;
159 };
160
161 /**
162 @class wxRichTextCtrl
163
164 wxRichTextCtrl provides a generic, ground-up implementation of a text control
165 capable of showing multiple styles and images.
166
167 wxRichTextCtrl sends notification events: see wxRichTextEvent.
168
169 It also sends the standard wxTextCtrl events @c wxEVT_TEXT_ENTER and
170 @c wxEVT_TEXT, and wxTextUrlEvent when URL content is clicked.
171
172 For more information, see the @ref overview_richtextctrl.
173
174 @beginStyleTable
175 @style{wxRE_CENTRE_CARET}
176 The control will try to keep the caret line centred vertically while editing.
177 wxRE_CENTER_CARET is a synonym for this style.
178 @style{wxRE_MULTILINE}
179 The control will be multiline (mandatory).
180 @style{wxRE_READONLY}
181 The control will not be editable.
182 @endStyleTable
183
184 @library{wxrichtext}
185 @category{richtext}
186 @appearance{richtextctrl}
187
188 */
189
190 class wxRichTextCtrl : public wxControl,
191 public wxTextCtrlIface,
192 public wxScrollHelper
193 {
194 public:
195 // Constructors
196
197 /**
198 Default constructor.
199 */
200 wxRichTextCtrl( );
201
202 /**
203 Constructor, creating and showing a rich text control.
204
205 @param parent
206 Parent window. Must not be @NULL.
207 @param id
208 Window identifier. The value @c wxID_ANY indicates a default value.
209 @param value
210 Default string.
211 @param pos
212 Window position.
213 @param size
214 Window size.
215 @param style
216 Window style.
217 @param validator
218 Window validator.
219 @param name
220 Window name.
221
222 @see Create(), wxValidator
223 */
224 wxRichTextCtrl( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
225 long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr);
226
227 /**
228 Destructor.
229 */
230 virtual ~wxRichTextCtrl( );
231
232 // Operations
233
234 /**
235 Creates the underlying window.
236 */
237 bool Create( wxWindow* parent, wxWindowID id = -1, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
238 long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr );
239
240 /**
241 Initialises the members of the control.
242 */
243 void Init();
244
245 // Accessors
246
247 /**
248 Gets the text for the given range.
249 The end point of range is specified as the last character position of
250 the span of text, plus one.
251 */
252 virtual wxString GetRange(long from, long to) const;
253
254 /**
255 Returns the length of the specified line in characters.
256 */
257 virtual int GetLineLength(long lineNo) const ;
258
259 /**
260 Returns the text for the given line.
261 */
262 virtual wxString GetLineText(long lineNo) const ;
263
264 /**
265 Returns the number of lines in the buffer.
266 */
267 virtual int GetNumberOfLines() const ;
268
269 /**
270 Returns @true if the buffer has been modified.
271 */
272 virtual bool IsModified() const ;
273
274 /**
275 Returns @true if the control is editable.
276 */
277 virtual bool IsEditable() const ;
278
279 /**
280 Returns @true if the control is single-line.
281 Currently wxRichTextCtrl does not support single-line editing.
282 */
283 bool IsSingleLine() const;
284
285 /**
286 Returns @true if the control is multiline.
287 */
288 bool IsMultiLine() const;
289
290 //@{
291 /**
292 Returns the range of the current selection.
293 The end point of range is specified as the last character position of the span
294 of text, plus one.
295 If the return values @a from and @a to are the same, there is no selection.
296 */
297 virtual void GetSelection(long* from, long* to) const;
298 const wxRichTextSelection& GetSelection() const;
299 wxRichTextSelection& GetSelection();
300 //@}
301
302 /**
303 Returns the text within the current selection range, if any.
304 */
305 virtual wxString GetStringSelection() const;
306
307 /**
308 Gets the current filename associated with the control.
309 */
310 wxString GetFilename() const;
311
312 /**
313 Sets the current filename.
314 */
315 void SetFilename(const wxString& filename);
316
317 /**
318 Sets the size of the buffer beyond which layout is delayed during resizing.
319 This optimizes sizing for large buffers. The default is 20000.
320 */
321 void SetDelayedLayoutThreshold(long threshold);
322
323 /**
324 Gets the size of the buffer beyond which layout is delayed during resizing.
325 This optimizes sizing for large buffers. The default is 20000.
326 */
327 long GetDelayedLayoutThreshold() const;
328
329 /**
330 */
331 bool GetFullLayoutRequired() const;
332
333 /**
334 */
335 void SetFullLayoutRequired(bool b);
336
337 /**
338 */
339 wxLongLong GetFullLayoutTime() const;
340
341 /**
342 */
343 void SetFullLayoutTime(wxLongLong t);
344
345 /**
346 */
347 long GetFullLayoutSavedPosition() const;
348
349 /**
350 */
351 void SetFullLayoutSavedPosition(long p);
352
353 // Force any pending layout due to large buffer
354 /**
355 */
356 void ForceDelayedLayout();
357
358 /**
359 Sets the text (normal) cursor.
360 */
361 void SetTextCursor(const wxCursor& cursor );
362
363 /**
364 Returns the text (normal) cursor.
365 */
366 wxCursor GetTextCursor() const;
367
368 /**
369 Sets the cursor to be used over URLs.
370 */
371 void SetURLCursor(const wxCursor& cursor );
372
373 /**
374 Returns the cursor to be used over URLs.
375 */
376 wxCursor GetURLCursor() const;
377
378 /**
379 Returns @true if we are showing the caret position at the start of a line
380 instead of at the end of the previous one.
381 */
382 bool GetCaretAtLineStart() const;
383
384 /**
385 Sets a flag to remember that we are showing the caret position at the start of a line
386 instead of at the end of the previous one.
387 */
388 void SetCaretAtLineStart(bool atStart);
389
390 /**
391 Returns @true if we are extending a selection.
392 */
393 bool GetDragging() const;
394
395 /**
396 Sets a flag to remember if we are extending a selection.
397 */
398 void SetDragging(bool dragging);
399
400 /**
401 Are we trying to start Drag'n'Drop?
402 */
403 bool GetPreDrag() const;
404
405 /**
406 Set if we're trying to start Drag'n'Drop
407 */
408 void SetPreDrag(bool pd);
409
410 /**
411 Get the possible Drag'n'Drop start point
412 */
413 const wxPoint GetDragStartPoint() const;
414
415 /**
416 Set the possible Drag'n'Drop start point
417 */
418 void SetDragStartPoint(wxPoint sp);
419
420 /**
421 Get the possible Drag'n'Drop start time
422 */
423 const wxDateTime GetDragStartTime() const;
424
425 /**
426 Set the possible Drag'n'Drop start time
427 */
428 void SetDragStartTime(wxDateTime st);
429
430 #if wxRICHTEXT_BUFFERED_PAINTING
431 //@{
432 /**
433 Returns the buffer bitmap if using buffered painting.
434 */
435 const wxBitmap& GetBufferBitmap() const;
436 wxBitmap& GetBufferBitmap();
437 //@}
438 #endif
439
440 /**
441 Returns the current context menu.
442 */
443 wxMenu* GetContextMenu() const;
444
445 /**
446 Sets the current context menu.
447 */
448 void SetContextMenu(wxMenu* menu);
449
450 /**
451 Returns an anchor so we know how to extend the selection.
452 It's a caret position since it's between two characters.
453 */
454 long GetSelectionAnchor() const;
455
456 /**
457 Sets an anchor so we know how to extend the selection.
458 It's a caret position since it's between two characters.
459 */
460 void SetSelectionAnchor(long anchor);
461
462 /**
463 Returns the anchor object if selecting multiple containers.
464 */
465 wxRichTextObject* GetSelectionAnchorObject() const;
466
467 /**
468 Sets the anchor object if selecting multiple containers.
469 */
470 void SetSelectionAnchorObject(wxRichTextObject* anchor);
471
472 //@{
473 /**
474 Returns an object that stores information about context menu property item(s),
475 in order to communicate between the context menu event handler and the code
476 that responds to it. The wxRichTextContextMenuPropertiesInfo stores one
477 item for each object that could respond to a property-editing event. If
478 objects are nested, several might be editable.
479 */
480 wxRichTextContextMenuPropertiesInfo& GetContextMenuPropertiesInfo();
481 const wxRichTextContextMenuPropertiesInfo& GetContextMenuPropertiesInfo() const;
482 //@}
483
484 /**
485 Returns the wxRichTextObject object that currently has the editing focus.
486 If there are no composite objects, this will be the top-level buffer.
487 */
488 wxRichTextParagraphLayoutBox* GetFocusObject() const;
489
490 /**
491 Setter for m_focusObject.
492 */
493 void StoreFocusObject(wxRichTextParagraphLayoutBox* obj);
494
495 /**
496 Sets the wxRichTextObject object that currently has the editing focus.
497 @param obj
498 The wxRichTextObject to set focus on.
499 @param setCaretPosition
500 Optionally set the caret position.
501 */
502 bool SetFocusObject(wxRichTextParagraphLayoutBox* obj, bool setCaretPosition = true);
503
504 // Operations
505
506 /**
507 Invalidates the whole buffer to trigger painting later.
508 */
509 void Invalidate();
510
511 /**
512 Clears the buffer content, leaving a single empty paragraph. Cannot be undone.
513 */
514 virtual void Clear();
515
516 /**
517 Replaces the content in the specified range with the string specified by
518 @a value.
519 */
520 virtual void Replace(long from, long to, const wxString& value);
521
522 /**
523 Removes the content in the specified range.
524 */
525 virtual void Remove(long from, long to);
526
527 /**
528 Loads content into the control's buffer using the given type.
529
530 If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
531 the filename extension.
532
533 This function looks for a suitable wxRichTextFileHandler object.
534 */
535 bool LoadFile(const wxString& file,
536 int type = wxRICHTEXT_TYPE_ANY);
537
538 /**
539 Helper function for LoadFile(). Loads content into the control's buffer using the given type.
540
541 If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
542 the filename extension.
543
544 This function looks for a suitable wxRichTextFileHandler object.
545 */
546 virtual bool DoLoadFile(const wxString& file, int fileType);
547
548 /**
549 Saves the buffer content using the given type.
550
551 If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
552 the filename extension.
553
554 This function looks for a suitable wxRichTextFileHandler object.
555 */
556 bool SaveFile(const wxString& file = wxEmptyString,
557 int type = wxRICHTEXT_TYPE_ANY);
558
559 /**
560 Helper function for SaveFile(). Saves the buffer content using the given type.
561
562 If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
563 the filename extension.
564
565 This function looks for a suitable wxRichTextFileHandler object.
566 */
567 virtual bool DoSaveFile(const wxString& file = wxEmptyString,
568 int fileType = wxRICHTEXT_TYPE_ANY);
569
570 /**
571 Sets flags that change the behaviour of loading or saving.
572
573 See the documentation for each handler class to see what flags are
574 relevant for each handler.
575 */
576 void SetHandlerFlags(int flags);
577
578 /**
579 Returns flags that change the behaviour of loading or saving.
580 See the documentation for each handler class to see what flags are
581 relevant for each handler.
582 */
583 int GetHandlerFlags() const;
584
585 /**
586 Marks the buffer as modified.
587 */
588 virtual void MarkDirty();
589
590 /**
591 Sets the buffer's modified status to @false, and clears the buffer's command
592 history.
593 */
594 virtual void DiscardEdits();
595
596
597 void SetModified(bool modified);
598
599 /**
600 Sets the maximum number of characters that may be entered in a single line
601 text control. For compatibility only; currently does nothing.
602 */
603 virtual void SetMaxLength(unsigned long len);
604
605 /**
606 Writes text at the current position.
607 */
608 virtual void WriteText(const wxString& text);
609
610 /**
611 Sets the insertion point to the end of the buffer and writes the text.
612 */
613 virtual void AppendText(const wxString& text);
614
615 //@{
616 /**
617 Gets the attributes at the given position.
618 This function gets the combined style - that is, the style you see on the
619 screen as a result of combining base style, paragraph style and character
620 style attributes.
621
622 To get the character or paragraph style alone, use GetUncombinedStyle().
623
624 @beginWxPerlOnly
625 In wxPerl this method is implemented as GetStyle(@a position)
626 returning a 2-element list (ok, attr).
627 @endWxPerlOnly
628 */
629 virtual bool GetStyle(long position, wxTextAttr& style);
630 virtual bool GetStyle(long position, wxRichTextAttr& style);
631 virtual bool GetStyle(long position, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container);
632 //@}
633
634 //@{
635 /**
636 Sets the attributes for the given range.
637 The end point of range is specified as the last character position of the span
638 of text, plus one.
639
640 So, for example, to set the style for a character at position 5, use the range
641 (5,6).
642 */
643 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
644 virtual bool SetStyle(long start, long end, const wxRichTextAttr& style);
645 virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style);
646 virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style);
647 //@}
648
649 /**
650 Sets the attributes for a single object
651 */
652 virtual void SetStyle(wxRichTextObject *obj, const wxRichTextAttr& textAttr, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
653
654 //@{
655 /**
656 Gets the attributes common to the specified range.
657 Attributes that differ in value within the range will not be included
658 in @a style flags.
659
660 @beginWxPerlOnly
661 In wxPerl this method is implemented as GetStyleForRange(@a position)
662 returning a 2-element list (ok, attr).
663 @endWxPerlOnly
664 */
665 virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style);
666 virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
667 virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container);
668 //@}
669
670 /**
671 Sets the attributes for the given range, passing flags to determine how the
672 attributes are set.
673
674 The end point of range is specified as the last character position of the span
675 of text, plus one. So, for example, to set the style for a character at
676 position 5, use the range (5,6).
677
678 @a flags may contain a bit list of the following values:
679 - wxRICHTEXT_SETSTYLE_NONE: no style flag.
680 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be
681 undoable.
682 - wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied
683 if the combined style at this point is already the style in question.
684 - wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be
685 applied to paragraphs, and not the content.
686 This allows content styling to be preserved independently from that
687 of e.g. a named paragraph style.
688 - wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be
689 applied to characters, and not the paragraph.
690 This allows content styling to be preserved independently from that
691 of e.g. a named paragraph style.
692 - wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying
693 the new style.
694 - wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags
695 are used in this operation.
696 */
697 virtual bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
698
699 //@{
700 /**
701 Gets the attributes at the given position.
702 This function gets the @e uncombined style - that is, the attributes associated
703 with the paragraph or character content, and not necessarily the combined
704 attributes you see on the screen.
705 To get the combined attributes, use GetStyle().
706
707 If you specify (any) paragraph attribute in @e style's flags, this function
708 will fetch the paragraph attributes.
709 Otherwise, it will return the character attributes.
710
711 @beginWxPerlOnly
712 In wxPerl this method is implemented as GetUncombinedStyle(@a position)
713 returning a 2-element list (ok, attr).
714 @endWxPerlOnly
715 */
716 virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style);
717 virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container);
718 //@}
719
720 //@{
721 /**
722 Sets the current default style, which can be used to change how subsequently
723 inserted text is displayed.
724 */
725 virtual bool SetDefaultStyle(const wxTextAttr& style);
726 virtual bool SetDefaultStyle(const wxRichTextAttr& style);
727 //@}
728
729 /**
730 Returns the current default style, which can be used to change how subsequently
731 inserted text is displayed.
732 */
733 virtual const wxRichTextAttr& GetDefaultStyleEx() const;
734
735 //virtual const wxTextAttr& GetDefaultStyle() const;
736
737 //@{
738 /**
739 Sets the list attributes for the given range, passing flags to determine how
740 the attributes are set.
741
742 Either the style definition or the name of the style definition (in the current
743 sheet) can be passed.
744 @a flags is a bit list of the following:
745 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
746 - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
747 @a startFrom, otherwise existing attributes are used.
748 - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
749 as the level for all paragraphs, otherwise the current indentation will be used.
750
751 @see NumberList(), PromoteList(), ClearListStyle().
752 */
753 virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
754 virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
755 //@}
756
757 /**
758 Clears the list style from the given range, clearing list-related attributes
759 and applying any named paragraph style associated with each paragraph.
760
761 @a flags is a bit list of the following:
762 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
763
764 @see SetListStyle(), PromoteList(), NumberList().
765 */
766 virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
767
768 //@{
769 /**
770 Numbers the paragraphs in the given range.
771 Pass flags to determine how the attributes are set.
772
773 Either the style definition or the name of the style definition (in the current
774 sheet) can be passed.
775
776 @a flags is a bit list of the following:
777 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
778 - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
779 @a startFrom, otherwise existing attributes are used.
780 - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
781 as the level for all paragraphs, otherwise the current indentation will be used.
782
783 @see SetListStyle(), PromoteList(), ClearListStyle().
784 */
785 virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
786 virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
787 //@}
788
789 //@{
790 /**
791 Promotes or demotes the paragraphs in the given range.
792 A positive @a promoteBy produces a smaller indent, and a negative number
793 produces a larger indent. Pass flags to determine how the attributes are set.
794 Either the style definition or the name of the style definition (in the current
795 sheet) can be passed.
796
797 @a flags is a bit list of the following:
798 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
799 - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
800 @a startFrom, otherwise existing attributes are used.
801 - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
802 as the level for all paragraphs, otherwise the current indentation will be used.
803
804 @see SetListStyle(), @see SetListStyle(), ClearListStyle().
805 */
806 virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
807 virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
808 //@}
809
810 /**
811 Sets the properties for the given range, passing flags to determine how the
812 attributes are set. You can merge properties or replace them.
813
814 The end point of range is specified as the last character position of the span
815 of text, plus one. So, for example, to set the properties for a character at
816 position 5, use the range (5,6).
817
818 @a flags may contain a bit list of the following values:
819 - wxRICHTEXT_SETSPROPERTIES_NONE: no flag.
820 - wxRICHTEXT_SETPROPERTIES_WITH_UNDO: specifies that this operation should be
821 undoable.
822 - wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY: specifies that the properties should only be
823 applied to paragraphs, and not the content.
824 - wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY: specifies that the properties should only be
825 applied to characters, and not the paragraph.
826 - wxRICHTEXT_SETPROPERTIES_RESET: resets (clears) the existing properties before applying
827 the new properties.
828 - wxRICHTEXT_SETPROPERTIES_REMOVE: removes the specified properties.
829 */
830 virtual bool SetProperties(const wxRichTextRange& range, const wxRichTextProperties& properties, int flags = wxRICHTEXT_SETPROPERTIES_WITH_UNDO);
831
832 /**
833 Deletes the content within the given range.
834 */
835 virtual bool Delete(const wxRichTextRange& range);
836
837 /**
838 Translates from column and line number to position.
839 */
840 virtual long XYToPosition(long x, long y) const;
841
842 /**
843 Converts a text position to zero-based column and line numbers.
844 */
845 virtual bool PositionToXY(long pos, long *x, long *y) const;
846
847 /**
848 Scrolls the buffer so that the given position is in view.
849 */
850 virtual void ShowPosition(long pos);
851
852 //@{
853 /**
854 Finds the character at the given position in pixels.
855 @a pt is in device coords (not adjusted for the client area origin nor for
856 scrolling).
857 */
858 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
859 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
860 wxTextCoord *col,
861 wxTextCoord *row) const;
862
863 /**
864 Finds the container at the given point, which is assumed to be in client coordinates.
865 */
866 wxRichTextParagraphLayoutBox* FindContainerAtPoint(const wxPoint pt, long& position, int& hit, wxRichTextObject* hitObj, int flags = 0);
867 //@}
868
869 // Clipboard operations
870
871 /**
872 Copies the selected content (if any) to the clipboard.
873 */
874 virtual void Copy();
875
876 /**
877 Copies the selected content (if any) to the clipboard and deletes the selection.
878 This is undoable.
879 */
880 virtual void Cut();
881
882 /**
883 Pastes content from the clipboard to the buffer.
884 */
885 virtual void Paste();
886
887 /**
888 Deletes the content in the selection, if any. This is undoable.
889 */
890 virtual void DeleteSelection();
891
892 /**
893 Returns @true if selected content can be copied to the clipboard.
894 */
895 virtual bool CanCopy() const;
896
897 /**
898 Returns @true if selected content can be copied to the clipboard and deleted.
899 */
900 virtual bool CanCut() const;
901
902 /**
903 Returns @true if the clipboard content can be pasted to the buffer.
904 */
905 virtual bool CanPaste() const;
906
907 /**
908 Returns @true if selected content can be deleted.
909 */
910 virtual bool CanDeleteSelection() const;
911
912 /**
913 Undoes the command at the top of the command history, if there is one.
914 */
915 virtual void Undo();
916
917 /**
918 Redoes the current command.
919 */
920 virtual void Redo();
921
922 /**
923 Returns @true if there is a command in the command history that can be undone.
924 */
925 virtual bool CanUndo() const;
926
927 /**
928 Returns @true if there is a command in the command history that can be redone.
929 */
930 virtual bool CanRedo() const;
931
932 /**
933 Sets the insertion point and causes the current editing style to be taken from
934 the new position (unlike wxRichTextCtrl::SetCaretPosition).
935 */
936 virtual void SetInsertionPoint(long pos);
937
938 /**
939 Sets the insertion point to the end of the text control.
940 */
941 virtual void SetInsertionPointEnd();
942
943 /**
944 Returns the current insertion point.
945 */
946 virtual long GetInsertionPoint() const;
947
948 /**
949 Returns the last position in the buffer.
950 */
951 virtual wxTextPos GetLastPosition() const;
952
953 //@{
954 /**
955 Sets the selection to the given range.
956 The end point of range is specified as the last character position of the span
957 of text, plus one.
958
959 So, for example, to set the selection for a character at position 5, use the
960 range (5,6).
961 */
962 virtual void SetSelection(long from, long to);
963 void SetSelection(const wxRichTextSelection& sel);
964 //@}
965
966
967 /**
968 Selects all the text in the buffer.
969 */
970 virtual void SelectAll();
971
972 /**
973 Makes the control editable, or not.
974 */
975 virtual void SetEditable(bool editable);
976
977 /**
978 Returns @true if there is a selection and the object containing the selection
979 was the same as the current focus object.
980 */
981 virtual bool HasSelection() const;
982
983 /**
984 Returns @true if there was a selection, whether or not the current focus object
985 is the same as the selection's container object.
986 */
987 virtual bool HasUnfocusedSelection() const;
988
989 //@{
990 /**
991 Write a bitmap or image at the current insertion point.
992 Supply an optional type to use for internal and file storage of the raw data.
993 */
994 virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG,
995 const wxRichTextAttr& textAttr = wxRichTextAttr());
996
997 virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG,
998 const wxRichTextAttr& textAttr = wxRichTextAttr());
999 //@}
1000
1001 /**
1002 Loads an image from a file and writes it at the current insertion point.
1003 */
1004 virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType,
1005 const wxRichTextAttr& textAttr = wxRichTextAttr());
1006
1007 /**
1008 Writes an image block at the current insertion point.
1009 */
1010 virtual bool WriteImage(const wxRichTextImageBlock& imageBlock,
1011 const wxRichTextAttr& textAttr = wxRichTextAttr());
1012
1013 /**
1014 Write a text box at the current insertion point, returning the text box.
1015 You can then call SetFocusObject() to set the focus to the new object.
1016 */
1017 virtual wxRichTextBox* WriteTextBox(const wxRichTextAttr& textAttr = wxRichTextAttr());
1018
1019 /**
1020 Writes a field at the current insertion point.
1021
1022 @param fieldType
1023 The field type, matching an existing field type definition.
1024 @param properties
1025 Extra data for the field.
1026 @param textAttr
1027 Optional attributes.
1028
1029 @see wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard
1030 */
1031 virtual wxRichTextField* WriteField(const wxString& fieldType, const wxRichTextProperties& properties,
1032 const wxRichTextAttr& textAttr = wxRichTextAttr());
1033
1034 /**
1035 Write a table at the current insertion point, returning the table.
1036 You can then call SetFocusObject() to set the focus to the new object.
1037 */
1038 virtual wxRichTextTable* WriteTable(int rows, int cols, const wxRichTextAttr& tableAttr = wxRichTextAttr(), const wxRichTextAttr& cellAttr = wxRichTextAttr());
1039
1040 /**
1041 Inserts a new paragraph at the current insertion point. @see LineBreak().
1042 */
1043 virtual bool Newline();
1044
1045 /**
1046 Inserts a line break at the current insertion point.
1047
1048 A line break forces wrapping within a paragraph, and can be introduced by
1049 using this function, by appending the wxChar value @b wxRichTextLineBreakChar
1050 to text content, or by typing Shift-Return.
1051 */
1052 virtual bool LineBreak();
1053
1054 /**
1055 Sets the basic (overall) style.
1056
1057 This is the style of the whole buffer before further styles are applied,
1058 unlike the default style, which only affects the style currently being
1059 applied (for example, setting the default style to bold will cause
1060 subsequently inserted text to be bold).
1061 */
1062 virtual void SetBasicStyle(const wxRichTextAttr& style);
1063
1064 /**
1065 Gets the basic (overall) style.
1066
1067 This is the style of the whole buffer before further styles are applied,
1068 unlike the default style, which only affects the style currently being
1069 applied (for example, setting the default style to bold will cause
1070 subsequently inserted text to be bold).
1071 */
1072 virtual const wxRichTextAttr& GetBasicStyle() const;
1073
1074 /**
1075 Begins applying a style.
1076 */
1077 virtual bool BeginStyle(const wxRichTextAttr& style);
1078
1079 /**
1080 Ends the current style.
1081 */
1082 virtual bool EndStyle();
1083
1084 /**
1085 Ends application of all styles in the current style stack.
1086 */
1087 virtual bool EndAllStyles();
1088
1089 /**
1090 Begins using bold.
1091 */
1092 bool BeginBold();
1093
1094 /**
1095 Ends using bold.
1096 */
1097 bool EndBold();
1098
1099 /**
1100 Begins using italic.
1101 */
1102 bool BeginItalic();
1103
1104 /**
1105 Ends using italic.
1106 */
1107 bool EndItalic();
1108
1109 /**
1110 Begins using underlining.
1111 */
1112 bool BeginUnderline();
1113
1114 /**
1115 End applying underlining.
1116 */
1117 bool EndUnderline();
1118
1119 /**
1120 Begins using the given point size.
1121 */
1122 bool BeginFontSize(int pointSize);
1123
1124 /**
1125 Ends using a point size.
1126 */
1127 bool EndFontSize();
1128
1129 /**
1130 Begins using this font.
1131 */
1132 bool BeginFont(const wxFont& font);
1133
1134 /**
1135 Ends using a font.
1136 */
1137 bool EndFont();
1138
1139 /**
1140 Begins using this colour.
1141 */
1142 bool BeginTextColour(const wxColour& colour);
1143
1144 /**
1145 Ends applying a text colour.
1146 */
1147 bool EndTextColour();
1148
1149 /**
1150 Begins using alignment.
1151 For alignment values, see wxTextAttr.
1152 */
1153 bool BeginAlignment(wxTextAttrAlignment alignment);
1154
1155 /**
1156 Ends alignment.
1157 */
1158 bool EndAlignment();
1159
1160 /**
1161 Begins applying a left indent and subindent in tenths of a millimetre.
1162 The subindent is an offset from the left edge of the paragraph, and is
1163 used for all but the first line in a paragraph. A positive value will
1164 cause the first line to appear to the left of the subsequent lines, and
1165 a negative value will cause the first line to be indented to the right
1166 of the subsequent lines.
1167
1168 wxRichTextBuffer uses indentation to render a bulleted item. The
1169 content of the paragraph, including the first line, starts at the
1170 @a leftIndent plus the @a leftSubIndent.
1171
1172 @param leftIndent
1173 The distance between the margin and the bullet.
1174 @param leftSubIndent
1175 The distance between the left edge of the bullet and the left edge
1176 of the actual paragraph.
1177 */
1178 bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0);
1179
1180 /**
1181 Ends left indent.
1182 */
1183 bool EndLeftIndent();
1184
1185 /**
1186 Begins a right indent, specified in tenths of a millimetre.
1187 */
1188 bool BeginRightIndent(int rightIndent);
1189
1190 /**
1191 Ends right indent.
1192 */
1193 bool EndRightIndent();
1194
1195 /**
1196 Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing
1197 in tenths of a millimetre.
1198 */
1199 bool BeginParagraphSpacing(int before, int after);
1200
1201 /**
1202 Ends paragraph spacing.
1203 */
1204 bool EndParagraphSpacing();
1205
1206 /**
1207 Begins appling line spacing. @e spacing is a multiple, where 10 means
1208 single-spacing, 15 means 1.5 spacing, and 20 means double spacing.
1209
1210 The ::wxTextAttrLineSpacing constants are defined for convenience.
1211 */
1212 bool BeginLineSpacing(int lineSpacing);
1213
1214 /**
1215 Ends line spacing.
1216 */
1217 bool EndLineSpacing();
1218
1219 /**
1220 Begins a numbered bullet.
1221
1222 This call will be needed for each item in the list, and the
1223 application should take care of incrementing the numbering.
1224
1225 @a bulletNumber is a number, usually starting with 1.
1226 @a leftIndent and @a leftSubIndent are values in tenths of a millimetre.
1227 @a bulletStyle is a bitlist of the ::wxTextAttrBulletStyle values.
1228
1229 wxRichTextBuffer uses indentation to render a bulleted item.
1230 The left indent is the distance between the margin and the bullet.
1231 The content of the paragraph, including the first line, starts
1232 at leftMargin + leftSubIndent.
1233 So the distance between the left edge of the bullet and the
1234 left of the actual paragraph is leftSubIndent.
1235 */
1236 bool BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD);
1237
1238 /**
1239 Ends application of a numbered bullet.
1240 */
1241 bool EndNumberedBullet();
1242
1243 /**
1244 Begins applying a symbol bullet, using a character from the current font.
1245 See BeginNumberedBullet() for an explanation of how indentation is used
1246 to render the bulleted paragraph.
1247 */
1248 bool BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL);
1249
1250 /**
1251 Ends applying a symbol bullet.
1252 */
1253 bool EndSymbolBullet();
1254
1255 /**
1256 Begins applying a symbol bullet.
1257 */
1258 bool BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD);
1259
1260 /**
1261 Begins applying a standard bullet.
1262 */
1263 bool EndStandardBullet();
1264
1265 /**
1266 Begins using the named character style.
1267 */
1268 bool BeginCharacterStyle(const wxString& characterStyle);
1269
1270 /**
1271 Ends application of a named character style.
1272 */
1273 bool EndCharacterStyle();
1274
1275 /**
1276 Begins applying the named paragraph style.
1277 */
1278 bool BeginParagraphStyle(const wxString& paragraphStyle);
1279
1280 /**
1281 Ends application of a named paragraph style.
1282 */
1283 bool EndParagraphStyle();
1284
1285 /**
1286 Begins using a specified list style.
1287 Optionally, you can also pass a level and a number.
1288 */
1289 bool BeginListStyle(const wxString& listStyle, int level = 1, int number = 1);
1290
1291 /**
1292 Ends using a specified list style.
1293 */
1294 bool EndListStyle();
1295
1296 /**
1297 Begins applying wxTEXT_ATTR_URL to the content.
1298
1299 Pass a URL and optionally, a character style to apply, since it is common
1300 to mark a URL with a familiar style such as blue text with underlining.
1301 */
1302 bool BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString);
1303
1304 /**
1305 Ends applying a URL.
1306 */
1307 bool EndURL();
1308
1309 /**
1310 Sets the default style to the style under the cursor.
1311 */
1312 bool SetDefaultStyleToCursorStyle();
1313
1314 /**
1315 Cancels any selection.
1316 */
1317 virtual void SelectNone();
1318
1319 /**
1320 Selects the word at the given character position.
1321 */
1322 virtual bool SelectWord(long position);
1323
1324 /**
1325 Returns the selection range in character positions. -1, -1 means no selection.
1326
1327 The range is in API convention, i.e. a single character selection is denoted
1328 by (n, n+1)
1329 */
1330 wxRichTextRange GetSelectionRange() const;
1331
1332 /**
1333 Sets the selection to the given range.
1334 The end point of range is specified as the last character position of the span
1335 of text, plus one.
1336
1337 So, for example, to set the selection for a character at position 5, use the
1338 range (5,6).
1339 */
1340 void SetSelectionRange(const wxRichTextRange& range);
1341
1342 /**
1343 Returns the selection range in character positions. -2, -2 means no selection
1344 -1, -1 means select everything.
1345 The range is in internal format, i.e. a single character selection is denoted
1346 by (n, n)
1347 */
1348 wxRichTextRange GetInternalSelectionRange() const;
1349
1350 /**
1351 Sets the selection range in character positions. -2, -2 means no selection
1352 -1, -1 means select everything.
1353 The range is in internal format, i.e. a single character selection is denoted
1354 by (n, n)
1355 */
1356 void SetInternalSelectionRange(const wxRichTextRange& range);
1357
1358 /**
1359 Adds a new paragraph of text to the end of the buffer.
1360 */
1361 virtual wxRichTextRange AddParagraph(const wxString& text);
1362
1363 /**
1364 Adds an image to the control's buffer.
1365 */
1366 virtual wxRichTextRange AddImage(const wxImage& image);
1367
1368 /**
1369 Lays out the buffer, which must be done before certain operations, such as
1370 setting the caret position.
1371 This function should not normally be required by the application.
1372 */
1373 virtual bool LayoutContent(bool onlyVisibleRect = false);
1374
1375 /**
1376 Move the caret to the given character position.
1377
1378 Please note that this does not update the current editing style
1379 from the new position; to do that, call wxRichTextCtrl::SetInsertionPoint instead.
1380 */
1381 virtual bool MoveCaret(long pos, bool showAtLineStart = false, wxRichTextParagraphLayoutBox* container = NULL);
1382
1383 /**
1384 Moves right.
1385 */
1386 virtual bool MoveRight(int noPositions = 1, int flags = 0);
1387
1388 /**
1389 Moves left.
1390 */
1391 virtual bool MoveLeft(int noPositions = 1, int flags = 0);
1392
1393 /**
1394 Moves to the start of the paragraph.
1395 */
1396 virtual bool MoveUp(int noLines = 1, int flags = 0);
1397
1398 /**
1399 Moves the caret down.
1400 */
1401 virtual bool MoveDown(int noLines = 1, int flags = 0);
1402
1403 /**
1404 Moves to the end of the line.
1405 */
1406 virtual bool MoveToLineEnd(int flags = 0);
1407
1408 /**
1409 Moves to the start of the line.
1410 */
1411 virtual bool MoveToLineStart(int flags = 0);
1412
1413 /**
1414 Moves to the end of the paragraph.
1415 */
1416 virtual bool MoveToParagraphEnd(int flags = 0);
1417
1418 /**
1419 Moves to the start of the paragraph.
1420 */
1421 virtual bool MoveToParagraphStart(int flags = 0);
1422
1423 /**
1424 Moves to the start of the buffer.
1425 */
1426 virtual bool MoveHome(int flags = 0);
1427
1428 /**
1429 Moves to the end of the buffer.
1430 */
1431 virtual bool MoveEnd(int flags = 0);
1432
1433 /**
1434 Moves one or more pages up.
1435 */
1436 virtual bool PageUp(int noPages = 1, int flags = 0);
1437
1438 /**
1439 Moves one or more pages down.
1440 */
1441 virtual bool PageDown(int noPages = 1, int flags = 0);
1442
1443 /**
1444 Moves a number of words to the left.
1445 */
1446 virtual bool WordLeft(int noPages = 1, int flags = 0);
1447
1448 /**
1449 Move a nuber of words to the right.
1450 */
1451 virtual bool WordRight(int noPages = 1, int flags = 0);
1452
1453 //@{
1454 /**
1455 Returns the buffer associated with the control.
1456 */
1457 wxRichTextBuffer& GetBuffer();
1458 const wxRichTextBuffer& GetBuffer() const;
1459 //@}
1460
1461 /**
1462 Starts batching undo history for commands.
1463 */
1464 virtual bool BeginBatchUndo(const wxString& cmdName);
1465
1466 /**
1467 Ends batching undo command history.
1468 */
1469 virtual bool EndBatchUndo();
1470
1471 /**
1472 Returns @true if undo commands are being batched.
1473 */
1474 virtual bool BatchingUndo() const;
1475
1476 /**
1477 Starts suppressing undo history for commands.
1478 */
1479 virtual bool BeginSuppressUndo();
1480
1481 /**
1482 Ends suppressing undo command history.
1483 */
1484 virtual bool EndSuppressUndo();
1485
1486 /**
1487 Returns @true if undo history suppression is on.
1488 */
1489 virtual bool SuppressingUndo() const;
1490
1491 /**
1492 Test if this whole range has character attributes of the specified kind.
1493 If any of the attributes are different within the range, the test fails.
1494
1495 You can use this to implement, for example, bold button updating.
1496 @a style must have flags indicating which attributes are of interest.
1497 */
1498 virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const;
1499
1500
1501 /**
1502 Test if this whole range has paragraph attributes of the specified kind.
1503 If any of the attributes are different within the range, the test fails.
1504 You can use this to implement, for example, centering button updating.
1505 @a style must have flags indicating which attributes are of interest.
1506 */
1507 virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const;
1508
1509
1510 /**
1511 Returns @true if all of the selection, or the content at the caret position, is bold.
1512 */
1513 virtual bool IsSelectionBold();
1514
1515 /**
1516 Returns @true if all of the selection, or the content at the caret position, is italic.
1517 */
1518 virtual bool IsSelectionItalics();
1519
1520 /**
1521 Returns @true if all of the selection, or the content at the caret position, is underlined.
1522 */
1523 virtual bool IsSelectionUnderlined();
1524
1525 /**
1526 Returns @true if all of the selection, or the content at the current caret position, has the supplied wxTextAttrEffects flag(s).
1527 */
1528 virtual bool DoesSelectionHaveTextEffectFlag(int flag);
1529
1530 /**
1531 Returns @true if all of the selection is aligned according to the specified flag.
1532 */
1533 virtual bool IsSelectionAligned(wxTextAttrAlignment alignment);
1534
1535 /**
1536 Apples bold to the selection or the default style (undoable).
1537 */
1538 virtual bool ApplyBoldToSelection();
1539
1540 /**
1541 Applies italic to the selection or the default style (undoable).
1542 */
1543 virtual bool ApplyItalicToSelection();
1544
1545 /**
1546 Applies underline to the selection or the default style (undoable).
1547 */
1548 virtual bool ApplyUnderlineToSelection();
1549
1550 /**
1551 Applies one or more wxTextAttrEffects flags to the selection (undoable).
1552 If there is no selection, it is applied to the default style.
1553 */
1554 virtual bool ApplyTextEffectToSelection(int flags);
1555
1556 /**
1557 Applies the given alignment to the selection or the default style (undoable).
1558 For alignment values, see wxTextAttr.
1559 */
1560 virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment);
1561
1562 /**
1563 Applies the style sheet to the buffer, matching paragraph styles in the sheet
1564 against named styles in the buffer.
1565
1566 This might be useful if the styles have changed.
1567 If @a sheet is @NULL, the sheet set with SetStyleSheet() is used.
1568 Currently this applies paragraph styles only.
1569 */
1570 virtual bool ApplyStyle(wxRichTextStyleDefinition* def);
1571
1572 /**
1573 Sets the style sheet associated with the control.
1574 A style sheet allows named character and paragraph styles to be applied.
1575 */
1576 void SetStyleSheet(wxRichTextStyleSheet* styleSheet);
1577
1578 /**
1579 Returns the style sheet associated with the control, if any.
1580 A style sheet allows named character and paragraph styles to be applied.
1581 */
1582 wxRichTextStyleSheet* GetStyleSheet() const;
1583
1584 /**
1585 Push the style sheet to top of stack.
1586 */
1587 bool PushStyleSheet(wxRichTextStyleSheet* styleSheet);
1588
1589 /**
1590 Pops the style sheet from top of stack.
1591 */
1592 wxRichTextStyleSheet* PopStyleSheet();
1593
1594 /**
1595 Applies the style sheet to the buffer, for example if the styles have changed.
1596 */
1597 bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL);
1598
1599 /**
1600 Shows the given context menu, optionally adding appropriate property-editing commands for the current position in the object hierarchy.
1601 */
1602 virtual bool ShowContextMenu(wxMenu* menu, const wxPoint& pt, bool addPropertyCommands);
1603
1604 /**
1605 Prepares the context menu, optionally adding appropriate property-editing commands.
1606 Returns the number of property commands added.
1607 */
1608 virtual int PrepareContextMenu(wxMenu* menu, const wxPoint& pt, bool addPropertyCommands);
1609
1610 /**
1611 Returns @true if we can edit the object's properties via a GUI.
1612 */
1613 virtual bool CanEditProperties(wxRichTextObject* obj) const;
1614
1615 /**
1616 Edits the object's properties via a GUI.
1617 */
1618 virtual bool EditProperties(wxRichTextObject* obj, wxWindow* parent);
1619
1620 /**
1621 Gets the object's properties menu label.
1622 */
1623 virtual wxString GetPropertiesMenuLabel(wxRichTextObject* obj);
1624
1625 /**
1626 Prepares the content just before insertion (or after buffer reset). Called by the same function in wxRichTextBuffer.
1627 Currently is only called if undo mode is on.
1628 */
1629 virtual void PrepareContent(wxRichTextParagraphLayoutBox& container);
1630
1631 /**
1632 Can we delete this range?
1633 Sends an event to the control.
1634 */
1635 virtual bool CanDeleteRange(wxRichTextParagraphLayoutBox& container, const wxRichTextRange& range) const;
1636
1637 /**
1638 Can we insert content at this position?
1639 Sends an event to the control.
1640 */
1641 virtual bool CanInsertContent(wxRichTextParagraphLayoutBox& container, long pos) const;
1642
1643 /**
1644 Enable or disable the vertical scrollbar.
1645 */
1646 virtual void EnableVerticalScrollbar(bool enable);
1647
1648 /**
1649 Returns @true if the vertical scrollbar is enabled.
1650 */
1651 virtual bool GetVerticalScrollbarEnabled() const;
1652
1653 /**
1654 Sets the scale factor for displaying fonts, for example for more comfortable
1655 editing.
1656 */
1657 void SetFontScale(double fontScale, bool refresh = false);
1658
1659 /**
1660 Returns the scale factor for displaying fonts, for example for more comfortable
1661 editing.
1662 */
1663 double GetFontScale() const { return GetBuffer().GetFontScale(); }
1664
1665 /**
1666 Sets the scale factor for displaying certain dimensions such as indentation and
1667 inter-paragraph spacing. This can be useful when editing in a small control
1668 where you still want legible text, but a minimum of wasted white space.
1669 */
1670 void SetDimensionScale(double dimScale, bool refresh = false);
1671
1672 /**
1673 Returns the scale factor for displaying certain dimensions such as indentation
1674 and inter-paragraph spacing.
1675 */
1676 double GetDimensionScale() const { return GetBuffer().GetDimensionScale(); }
1677
1678 /**
1679 Sets an overall scale factor for displaying and editing the content.
1680 */
1681 void SetScale(double scale, bool refresh = false);
1682
1683 /**
1684 Returns an overall scale factor for displaying and editing the content.
1685 */
1686 double GetScale() const;
1687
1688 /**
1689 Returns an unscaled point.
1690 */
1691 wxPoint GetUnscaledPoint(const wxPoint& pt) const;
1692
1693 /**
1694 Returns a scaled point.
1695 */
1696 wxPoint GetScaledPoint(const wxPoint& pt) const;
1697
1698 /**
1699 Returns an unscaled size.
1700 */
1701 wxSize GetUnscaledSize(const wxSize& sz) const;
1702
1703 /**
1704 Returns a scaled size.
1705 */
1706 wxSize GetScaledSize(const wxSize& sz) const;
1707
1708 /**
1709 Returns an unscaled rectangle.
1710 */
1711 wxRect GetUnscaledRect(const wxRect& rect) const;
1712
1713 /**
1714 Returns a scaled rectangle.
1715 */
1716 wxRect GetScaledRect(const wxRect& rect) const;
1717
1718 /**
1719 Returns @true if this control can use virtual attributes and virtual text.
1720 The default is @false.
1721 */
1722 bool GetVirtualAttributesEnabled() const;
1723
1724 /**
1725 Pass @true to let the control use virtual attributes.
1726 The default is @false.
1727 */
1728 void EnableVirtualAttributes(bool b);
1729
1730 // Command handlers
1731
1732 /**
1733 Sends the event to the control.
1734 */
1735 void Command(wxCommandEvent& event);
1736
1737 /**
1738 Loads the first dropped file.
1739 */
1740 void OnDropFiles(wxDropFilesEvent& event);
1741
1742 void OnCaptureLost(wxMouseCaptureLostEvent& event);
1743 void OnSysColourChanged(wxSysColourChangedEvent& event);
1744
1745 /**
1746 Standard handler for the wxID_CUT command.
1747 */
1748 void OnCut(wxCommandEvent& event);
1749
1750 /**
1751 Standard handler for the wxID_COPY command.
1752 */
1753 void OnCopy(wxCommandEvent& event);
1754
1755 /**
1756 Standard handler for the wxID_PASTE command.
1757 */
1758 void OnPaste(wxCommandEvent& event);
1759
1760 /**
1761 Standard handler for the wxID_UNDO command.
1762 */
1763 void OnUndo(wxCommandEvent& event);
1764
1765 /**
1766 Standard handler for the wxID_REDO command.
1767 */
1768 void OnRedo(wxCommandEvent& event);
1769
1770 /**
1771 Standard handler for the wxID_SELECTALL command.
1772 */
1773 void OnSelectAll(wxCommandEvent& event);
1774
1775 /**
1776 Standard handler for property commands.
1777 */
1778 void OnProperties(wxCommandEvent& event);
1779
1780 /**
1781 Standard handler for the wxID_CLEAR command.
1782 */
1783 void OnClear(wxCommandEvent& event);
1784
1785 /**
1786 Standard update handler for the wxID_CUT command.
1787 */
1788 void OnUpdateCut(wxUpdateUIEvent& event);
1789
1790 /**
1791 Standard update handler for the wxID_COPY command.
1792 */
1793 void OnUpdateCopy(wxUpdateUIEvent& event);
1794
1795 /**
1796 Standard update handler for the wxID_PASTE command.
1797 */
1798 void OnUpdatePaste(wxUpdateUIEvent& event);
1799
1800 /**
1801 Standard update handler for the wxID_UNDO command.
1802 */
1803 void OnUpdateUndo(wxUpdateUIEvent& event);
1804
1805 /**
1806 Standard update handler for the wxID_REDO command.
1807 */
1808 void OnUpdateRedo(wxUpdateUIEvent& event);
1809
1810 /**
1811 Standard update handler for the wxID_SELECTALL command.
1812 */
1813 void OnUpdateSelectAll(wxUpdateUIEvent& event);
1814
1815 /**
1816 Standard update handler for property commands.
1817 */
1818
1819 void OnUpdateProperties(wxUpdateUIEvent& event);
1820
1821 /**
1822 Standard update handler for the wxID_CLEAR command.
1823 */
1824 void OnUpdateClear(wxUpdateUIEvent& event);
1825
1826 /**
1827 Shows a standard context menu with undo, redo, cut, copy, paste, clear, and
1828 select all commands.
1829 */
1830 void OnContextMenu(wxContextMenuEvent& event);
1831
1832 // Event handlers
1833
1834 // Painting
1835 void OnPaint(wxPaintEvent& event);
1836 void OnEraseBackground(wxEraseEvent& event);
1837
1838 // Left-click
1839 void OnLeftClick(wxMouseEvent& event);
1840
1841 // Left-up
1842 void OnLeftUp(wxMouseEvent& event);
1843
1844 // Motion
1845 void OnMoveMouse(wxMouseEvent& event);
1846
1847 // Left-double-click
1848 void OnLeftDClick(wxMouseEvent& event);
1849
1850 // Middle-click
1851 void OnMiddleClick(wxMouseEvent& event);
1852
1853 // Right-click
1854 void OnRightClick(wxMouseEvent& event);
1855
1856 // Key press
1857 void OnChar(wxKeyEvent& event);
1858
1859 // Sizing
1860 void OnSize(wxSizeEvent& event);
1861
1862 // Setting/losing focus
1863 void OnSetFocus(wxFocusEvent& event);
1864 void OnKillFocus(wxFocusEvent& event);
1865
1866 // Idle-time processing
1867 void OnIdle(wxIdleEvent& event);
1868
1869 // Scrolling
1870 void OnScroll(wxScrollWinEvent& event);
1871
1872 /**
1873 Sets the font, and also the basic and default attributes
1874 (see wxRichTextCtrl::SetDefaultStyle).
1875 */
1876 virtual bool SetFont(const wxFont& font);
1877
1878 /**
1879 A helper function setting up scrollbars, for example after a resize.
1880 */
1881 virtual void SetupScrollbars(bool atTop = false);
1882
1883 /**
1884 Helper function implementing keyboard navigation.
1885 */
1886 virtual bool KeyboardNavigate(int keyCode, int flags);
1887
1888 /**
1889 Paints the background.
1890 */
1891 virtual void PaintBackground(wxDC& dc);
1892
1893 /**
1894 Other user defined painting after everything else (i.e.\ all text) is painted.
1895
1896 @since 2.9.1
1897 */
1898 virtual void PaintAboveContent(wxDC& WXUNUSED(dc)) {}
1899
1900 #if wxRICHTEXT_BUFFERED_PAINTING
1901 /**
1902 Recreates the buffer bitmap if necessary.
1903 */
1904 virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
1905 #endif
1906
1907 // Write text
1908 virtual void DoWriteText(const wxString& value, int flags = 0);
1909
1910 // Should we inherit colours?
1911 virtual bool ShouldInheritColours() const;
1912
1913 /**
1914 Internal function to position the visible caret according to the current caret
1915 position.
1916 */
1917 virtual void PositionCaret(wxRichTextParagraphLayoutBox* container = NULL);
1918
1919 /**
1920 Helper function for extending the selection, returning @true if the selection
1921 was changed. Selections are in caret positions.
1922 */
1923 virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
1924
1925 /**
1926 Scrolls @a position into view. This function takes a caret position.
1927 */
1928 virtual bool ScrollIntoView(long position, int keyCode);
1929
1930 /**
1931 Refreshes the area affected by a selection change.
1932 */
1933 bool RefreshForSelectionChange(const wxRichTextSelection& oldSelection, const wxRichTextSelection& newSelection);
1934
1935 /**
1936 Sets the caret position.
1937
1938 The caret position is the character position just before the caret.
1939 A value of -1 means the caret is at the start of the buffer.
1940 Please note that this does not update the current editing style
1941 from the new position or cause the actual caret to be refreshed; to do that,
1942 call wxRichTextCtrl::SetInsertionPoint instead.
1943 */
1944 void SetCaretPosition(long position, bool showAtLineStart = false) ;
1945
1946 /**
1947 Returns the current caret position.
1948 */
1949 long GetCaretPosition() const;
1950
1951 /**
1952 The adjusted caret position is the character position adjusted to take
1953 into account whether we're at the start of a paragraph, in which case
1954 style information should be taken from the next position, not current one.
1955 */
1956 long GetAdjustedCaretPosition(long caretPos) const;
1957
1958 /**
1959 Move the caret one visual step forward: this may mean setting a flag
1960 and keeping the same position if we're going from the end of one line
1961 to the start of the next, which may be the exact same caret position.
1962 */
1963 void MoveCaretForward(long oldPosition) ;
1964
1965 /**
1966 Move the caret one visual step forward: this may mean setting a flag
1967 and keeping the same position if we're going from the end of one line
1968 to the start of the next, which may be the exact same caret position.
1969 */
1970 void MoveCaretBack(long oldPosition) ;
1971
1972 /**
1973 Returns the caret height and position for the given character position.
1974 If container is null, the current focus object will be used.
1975
1976 @beginWxPerlOnly
1977 In wxPerl this method is implemented as
1978 GetCaretPositionForIndex(@a position) returning a
1979 2-element list (ok, rect).
1980 @endWxPerlOnly
1981 */
1982 bool GetCaretPositionForIndex(long position, wxRect& rect, wxRichTextParagraphLayoutBox* container = NULL);
1983
1984 /**
1985 Internal helper function returning the line for the visible caret position.
1986 If the caret is shown at the very end of the line, it means the next character
1987 is actually on the following line.
1988 So this function gets the line we're expecting to find if this is the case.
1989 */
1990 wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
1991
1992 /**
1993 Gets the command processor associated with the control's buffer.
1994 */
1995 wxCommandProcessor* GetCommandProcessor() const;
1996
1997 /**
1998 Deletes content if there is a selection, e.g. when pressing a key.
1999 Returns the new caret position in @e newPos, or leaves it if there
2000 was no action. This is undoable.
2001
2002 @beginWxPerlOnly
2003 In wxPerl this method takes no arguments and returns a 2-element
2004 list (ok, newPos).
2005 @endWxPerlOnly
2006 */
2007 bool DeleteSelectedContent(long* newPos= NULL);
2008
2009 /**
2010 Transforms logical (unscrolled) position to physical window position.
2011 */
2012 wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
2013
2014 /**
2015 Transforms physical window position to logical (unscrolled) position.
2016 */
2017 wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
2018
2019 /**
2020 Helper function for finding the caret position for the next word.
2021 Direction is 1 (forward) or -1 (backwards).
2022 */
2023 virtual long FindNextWordPosition(int direction = 1) const;
2024
2025 /**
2026 Returns @true if the given position is visible on the screen.
2027 */
2028 bool IsPositionVisible(long pos) const;
2029
2030 /**
2031 Returns the first visible position in the current view.
2032 */
2033 long GetFirstVisiblePosition() const;
2034
2035 /**
2036 Returns the caret position since the default formatting was changed. As
2037 soon as this position changes, we no longer reflect the default style
2038 in the UI. A value of -2 means that we should only reflect the style of the
2039 content under the caret.
2040 */
2041 long GetCaretPositionForDefaultStyle() const;
2042
2043 /**
2044 Set the caret position for the default style that the user is selecting.
2045 */
2046 void SetCaretPositionForDefaultStyle(long pos);
2047
2048 /**
2049 Returns @true if the user has recently set the default style without moving
2050 the caret, and therefore the UI needs to reflect the default style and not
2051 the style at the caret.
2052
2053 Below is an example of code that uses this function to determine whether the UI
2054 should show that the current style is bold.
2055
2056 @see SetAndShowDefaultStyle().
2057 */
2058 bool IsDefaultStyleShowing() const;
2059
2060 /**
2061 Sets @a attr as the default style and tells the control that the UI should
2062 reflect this attribute until the user moves the caret.
2063
2064 @see IsDefaultStyleShowing().
2065 */
2066 void SetAndShowDefaultStyle(const wxRichTextAttr& attr);
2067
2068 /**
2069 Returns the first visible point in the window.
2070 */
2071 wxPoint GetFirstVisiblePoint() const;
2072
2073 /**
2074 Returns the content of the entire control as a string.
2075 */
2076 virtual wxString GetValue() const;
2077
2078 /**
2079 Replaces existing content with the given text.
2080 */
2081 virtual void SetValue(const wxString& value);
2082
2083
2084 // Implementation
2085
2086 /**
2087 Processes the back key.
2088 */
2089 virtual bool ProcessBackKey(wxKeyEvent& event, int flags);
2090
2091 /**
2092 Given a character position at which there is a list style, find the range
2093 encompassing the same list style by looking backwards and forwards.
2094 */
2095 virtual wxRichTextRange FindRangeForList(long pos, bool& isNumberedList);
2096
2097 /**
2098 Sets up the caret for the given position and container, after a mouse click.
2099 */
2100 bool SetCaretPositionAfterClick(wxRichTextParagraphLayoutBox* container, long position, int hitTestFlags, bool extendSelection = false);
2101
2102 /**
2103 Find the caret position for the combination of hit-test flags and character position.
2104 Returns the caret position and also an indication of where to place the caret (caretLineStart)
2105 since this is ambiguous (same position used for end of line and start of next).
2106 */
2107 long FindCaretPositionForCharacterPosition(long position, int hitTestFlags, wxRichTextParagraphLayoutBox* container,
2108 bool& caretLineStart);
2109
2110 /**
2111 Processes mouse movement in order to change the cursor
2112 */
2113 virtual bool ProcessMouseMovement(wxRichTextParagraphLayoutBox* container, wxRichTextObject* obj, long position, const wxPoint& pos);
2114
2115 /**
2116 Font names take a long time to retrieve, so cache them (on demand).
2117 */
2118 static const wxArrayString& GetAvailableFontNames();
2119
2120 /**
2121 Clears the cache of available font names.
2122 */
2123 static void ClearAvailableFontNames();
2124
2125 // implement wxTextEntry methods
2126 virtual wxString DoGetValue() const;
2127
2128 protected:
2129 // implement the wxTextEntry pure virtual method
2130 virtual wxWindow *GetEditableWindow();
2131
2132 // margins functions
2133 virtual bool DoSetMargins(const wxPoint& pt);
2134 virtual wxPoint DoGetMargins() const;
2135
2136
2137 // Overrides
2138 protected:
2139
2140 /**
2141 Currently this simply returns @c wxSize(10, 10).
2142 */
2143 virtual wxSize DoGetBestSize() const ;
2144
2145 virtual void DoSetValue(const wxString& value, int flags = 0);
2146
2147 virtual void DoThaw();
2148
2149
2150 // Data members
2151 protected:
2152 #if wxRICHTEXT_BUFFERED_PAINTING
2153 /// Buffer bitmap
2154 wxBitmap m_bufferBitmap;
2155 #endif
2156
2157 /// Text buffer
2158 wxRichTextBuffer m_buffer;
2159
2160 wxMenu* m_contextMenu;
2161
2162 /// Caret position (1 less than the character position, so -1 is the
2163 /// first caret position).
2164 long m_caretPosition;
2165
2166 /// Caret position when the default formatting has been changed. As
2167 /// soon as this position changes, we no longer reflect the default style
2168 /// in the UI.
2169 long m_caretPositionForDefaultStyle;
2170
2171 /// Selection range in character positions. -2, -2 means no selection.
2172 wxRichTextSelection m_selection;
2173
2174 wxRichTextCtrlSelectionState m_selectionState;
2175
2176 /// Anchor so we know how to extend the selection
2177 /// It's a caret position since it's between two characters.
2178 long m_selectionAnchor;
2179
2180 /// Anchor object if selecting multiple container objects, such as grid cells.
2181 wxRichTextObject* m_selectionAnchorObject;
2182
2183 /// Are we editable?
2184 bool m_editable;
2185
2186 /// Are we showing the caret position at the start of a line
2187 /// instead of at the end of the previous one?
2188 bool m_caretAtLineStart;
2189
2190 /// Are we dragging a selection?
2191 bool m_dragging;
2192
2193 /// Do we need full layout in idle?
2194 bool m_fullLayoutRequired;
2195 wxLongLong m_fullLayoutTime;
2196 long m_fullLayoutSavedPosition;
2197
2198 /// Threshold for doing delayed layout
2199 long m_delayedLayoutThreshold;
2200
2201 /// Cursors
2202 wxCursor m_textCursor;
2203 wxCursor m_urlCursor;
2204
2205 static wxArrayString sm_availableFontNames;
2206
2207 wxRichTextContextMenuPropertiesInfo m_contextMenuPropertiesInfo;
2208
2209 /// The object that currently has the editing focus
2210 wxRichTextParagraphLayoutBox* m_focusObject;
2211 };
2212
2213 /**
2214 @class wxRichTextEvent
2215
2216 This is the event class for wxRichTextCtrl notifications.
2217
2218 @beginEventTable{wxRichTextEvent}
2219 @event{EVT_RICHTEXT_LEFT_CLICK(id, func)}
2220 Process a @c wxEVT_RICHTEXT_LEFT_CLICK event, generated when the user
2221 releases the left mouse button over an object.
2222 @event{EVT_RICHTEXT_RIGHT_CLICK(id, func)}
2223 Process a @c wxEVT_RICHTEXT_RIGHT_CLICK event, generated when the user
2224 releases the right mouse button over an object.
2225 @event{EVT_RICHTEXT_MIDDLE_CLICK(id, func)}
2226 Process a @c wxEVT_RICHTEXT_MIDDLE_CLICK event, generated when the user
2227 releases the middle mouse button over an object.
2228 @event{EVT_RICHTEXT_LEFT_DCLICK(id, func)}
2229 Process a @c wxEVT_RICHTEXT_LEFT_DCLICK event, generated when the user
2230 double-clicks an object.
2231 @event{EVT_RICHTEXT_RETURN(id, func)}
2232 Process a @c wxEVT_RICHTEXT_RETURN event, generated when the user
2233 presses the return key. Valid event functions: GetFlags, GetPosition.
2234 @event{EVT_RICHTEXT_CHARACTER(id, func)}
2235 Process a @c wxEVT_RICHTEXT_CHARACTER event, generated when the user
2236 presses a character key. Valid event functions: GetFlags, GetPosition, GetCharacter.
2237 @event{EVT_RICHTEXT_DELETE(id, func)}
2238 Process a @c wxEVT_RICHTEXT_DELETE event, generated when the user
2239 presses the backspace or delete key. Valid event functions: GetFlags, GetPosition.
2240 @event{EVT_RICHTEXT_RETURN(id, func)}
2241 Process a @c wxEVT_RICHTEXT_RETURN event, generated when the user
2242 presses the return key. Valid event functions: GetFlags, GetPosition.
2243 @event{EVT_RICHTEXT_STYLE_CHANGED(id, func)}
2244 Process a @c wxEVT_RICHTEXT_STYLE_CHANGED event, generated when
2245 styling has been applied to the control. Valid event functions: GetPosition, GetRange.
2246 @event{EVT_RICHTEXT_STYLESHEET_CHANGED(id, func)}
2247 Process a @c wxEVT_RICHTEXT_STYLESHEET_CHANGING event, generated
2248 when the control's stylesheet has changed, for example the user added,
2249 edited or deleted a style. Valid event functions: GetRange, GetPosition.
2250 @event{EVT_RICHTEXT_STYLESHEET_REPLACING(id, func)}
2251 Process a @c wxEVT_RICHTEXT_STYLESHEET_REPLACING event, generated
2252 when the control's stylesheet is about to be replaced, for example when
2253 a file is loaded into the control.
2254 Valid event functions: Veto, GetOldStyleSheet, GetNewStyleSheet.
2255 @event{EVT_RICHTEXT_STYLESHEET_REPLACED(id, func)}
2256 Process a @c wxEVT_RICHTEXT_STYLESHEET_REPLACED event, generated
2257 when the control's stylesheet has been replaced, for example when a file
2258 is loaded into the control.
2259 Valid event functions: GetOldStyleSheet, GetNewStyleSheet.
2260 @event{EVT_RICHTEXT_PROPERTIES_CHANGED(id, func)}
2261 Process a @c wxEVT_RICHTEXT_PROPERTIES_CHANGED event, generated when
2262 properties have been applied to the control. Valid event functions: GetPosition, GetRange.
2263 @event{EVT_RICHTEXT_CONTENT_INSERTED(id, func)}
2264 Process a @c wxEVT_RICHTEXT_CONTENT_INSERTED event, generated when
2265 content has been inserted into the control.
2266 Valid event functions: GetPosition, GetRange.
2267 @event{EVT_RICHTEXT_CONTENT_DELETED(id, func)}
2268 Process a @c wxEVT_RICHTEXT_CONTENT_DELETED event, generated when
2269 content has been deleted from the control.
2270 Valid event functions: GetPosition, GetRange.
2271 @event{EVT_RICHTEXT_BUFFER_RESET(id, func)}
2272 Process a @c wxEVT_RICHTEXT_BUFFER_RESET event, generated when the
2273 buffer has been reset by deleting all content.
2274 You can use this to set a default style for the first new paragraph.
2275 @event{EVT_RICHTEXT_SELECTION_CHANGED(id, func)}
2276 Process a @c wxEVT_RICHTEXT_SELECTION_CHANGED event, generated when the
2277 selection range has changed.
2278 @event{EVT_RICHTEXT_FOCUS_OBJECT_CHANGED(id, func)}
2279 Process a @c wxEVT_RICHTEXT_FOCUS_OBJECT_CHANGED event, generated when the
2280 current focus object has changed.
2281 @endEventTable
2282
2283 @library{wxrichtext}
2284 @category{events,richtext}
2285 */
2286
2287 class wxRichTextEvent : public wxNotifyEvent
2288 {
2289 public:
2290 /**
2291 Constructor.
2292
2293 @param commandType
2294 The type of the event.
2295 @param winid
2296 Window identifier. The value @c wxID_ANY indicates a default value.
2297 */
2298 wxRichTextEvent(wxEventType commandType = wxEVT_NULL, int winid = 0);
2299
2300 /**
2301 Copy constructor.
2302 */
2303 wxRichTextEvent(const wxRichTextEvent& event);
2304
2305 /**
2306 Returns the buffer position at which the event occurred.
2307 */
2308 long GetPosition() const;
2309
2310 /**
2311 Sets the buffer position variable.
2312 */
2313 void SetPosition(long pos);
2314
2315 /**
2316 Returns flags indicating modifier keys pressed.
2317
2318 Possible values are @c wxRICHTEXT_CTRL_DOWN, @c wxRICHTEXT_SHIFT_DOWN, and @c wxRICHTEXT_ALT_DOWN.
2319 */
2320 int GetFlags() const;
2321
2322 /**
2323 Sets flags indicating modifier keys pressed.
2324
2325 Possible values are @c wxRICHTEXT_CTRL_DOWN, @c wxRICHTEXT_SHIFT_DOWN, and @c wxRICHTEXT_ALT_DOWN.
2326 */
2327 void SetFlags(int flags);
2328
2329 /**
2330 Returns the old style sheet.
2331
2332 Can be used in a @c wxEVT_RICHTEXT_STYLESHEET_CHANGING or
2333 @c wxEVT_RICHTEXT_STYLESHEET_CHANGED event handler.
2334 */
2335 wxRichTextStyleSheet* GetOldStyleSheet() const;
2336
2337 /**
2338 Sets the old style sheet variable.
2339 */
2340 void SetOldStyleSheet(wxRichTextStyleSheet* sheet);
2341
2342 /**
2343 Returns the new style sheet.
2344
2345 Can be used in a @c wxEVT_RICHTEXT_STYLESHEET_CHANGING or
2346 @c wxEVT_RICHTEXT_STYLESHEET_CHANGED event handler.
2347 */
2348 wxRichTextStyleSheet* GetNewStyleSheet() const;
2349
2350 /**
2351 Sets the new style sheet variable.
2352 */
2353 void SetNewStyleSheet(wxRichTextStyleSheet* sheet);
2354
2355 /**
2356 Gets the range for the current operation.
2357 */
2358 const wxRichTextRange& GetRange() const;
2359
2360 /**
2361 Sets the range variable.
2362 */
2363 void SetRange(const wxRichTextRange& range);
2364
2365 /**
2366 Returns the character pressed, within a @c wxEVT_RICHTEXT_CHARACTER event.
2367 */
2368 wxChar GetCharacter() const;
2369
2370 /**
2371 Sets the character variable.
2372 */
2373 void SetCharacter(wxChar ch);
2374
2375 /**
2376 Returns the container for which the event is relevant.
2377 */
2378 wxRichTextParagraphLayoutBox* GetContainer() const;
2379
2380 /**
2381 Sets the container for which the event is relevant.
2382 */
2383 void SetContainer(wxRichTextParagraphLayoutBox* container);
2384
2385 /**
2386 Returns the old container, for a focus change event.
2387 */
2388 wxRichTextParagraphLayoutBox* GetOldContainer() const;
2389
2390 /**
2391 Sets the old container, for a focus change event.
2392 */
2393 void SetOldContainer(wxRichTextParagraphLayoutBox* container);
2394
2395 virtual wxEvent *Clone() const;
2396
2397 protected:
2398 int m_flags;
2399 long m_position;
2400 wxRichTextStyleSheet* m_oldStyleSheet;
2401 wxRichTextStyleSheet* m_newStyleSheet;
2402 wxRichTextRange m_range;
2403 wxChar m_char;
2404 wxRichTextParagraphLayoutBox* m_container;
2405 wxRichTextParagraphLayoutBox* m_oldContainer;
2406
2407 };
2408
2409
2410 wxEventType wxEVT_RICHTEXT_LEFT_CLICK;
2411 wxEventType wxEVT_RICHTEXT_RIGHT_CLICK;
2412 wxEventType wxEVT_RICHTEXT_MIDDLE_CLICK;
2413 wxEventType wxEVT_RICHTEXT_LEFT_DCLICK;
2414 wxEventType wxEVT_RICHTEXT_RETURN;
2415 wxEventType wxEVT_RICHTEXT_CHARACTER;
2416 wxEventType wxEVT_RICHTEXT_DELETE;
2417
2418 wxEventType wxEVT_RICHTEXT_STYLESHEET_CHANGING;
2419 wxEventType wxEVT_RICHTEXT_STYLESHEET_CHANGED;
2420 wxEventType wxEVT_RICHTEXT_STYLESHEET_REPLACING;
2421 wxEventType wxEVT_RICHTEXT_STYLESHEET_REPLACED;
2422
2423 wxEventType wxEVT_RICHTEXT_CONTENT_INSERTED;
2424 wxEventType wxEVT_RICHTEXT_CONTENT_DELETED;
2425 wxEventType wxEVT_RICHTEXT_STYLE_CHANGED;
2426 wxEventType wxEVT_RICHTEXT_PROPERTIES_CHANGED;
2427 wxEventType wxEVT_RICHTEXT_SELECTION_CHANGED;
2428 wxEventType wxEVT_RICHTEXT_BUFFER_RESET;
2429 wxEventType wxEVT_RICHTEXT_FOCUS_OBJECT_CHANGED;