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