1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richtextctrl.h
3 // Purpose: A rich edit control
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
19 #define wxRE_READONLY 0x0010
20 #define wxRE_MULTILINE 0x0020
21 #define wxRE_CENTRE_CARET 0x8000
22 #define wxRE_CENTER_CARET wxRE_CENTRE_CARET
28 #define wxRICHTEXT_SHIFT_DOWN 0x01
29 #define wxRICHTEXT_CTRL_DOWN 0x02
30 #define wxRICHTEXT_ALT_DOWN 0x04
36 // Don't draw guide lines around boxes and tables
37 #define wxRICHTEXT_EX_NO_GUIDELINES 0x00000100
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
61 #define wxID_RICHTEXT_PROPERTIES1 (wxID_HIGHEST + 1)
62 #define wxID_RICHTEXT_PROPERTIES2 (wxID_HIGHEST + 2)
63 #define wxID_RICHTEXT_PROPERTIES3 (wxID_HIGHEST + 3)
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.
71 enum wxRichTextCtrlSelectionState
73 wxRichTextCtrlSelectionState_Normal
,
74 wxRichTextCtrlSelectionState_CommonAncestor
78 @class wxRichTextContextMenuPropertiesInfo
80 wxRichTextContextMenuPropertiesInfo keeps track of objects that appear in the context menu,
81 whose properties are available to be edited.
84 class wxRichTextContextMenuPropertiesInfo
90 wxRichTextContextMenuPropertiesInfo();
102 bool AddItem(const wxString
& label
, wxRichTextObject
* obj
);
105 Returns the number of menu items that were added.
107 int AddMenuItems(wxMenu
* menu
, int startCmd
= wxID_RICHTEXT_PROPERTIES1
) const;
110 Adds appropriate menu items for the current container and clicked on object
111 (and container's parent, if appropriate).
113 int AddItems(wxRichTextCtrl
* ctrl
, wxRichTextObject
* container
, wxRichTextObject
* obj
);
123 Returns the nth label.
125 wxString
GetLabel(int n
) const;
128 Returns the nth object.
130 wxRichTextObject
* GetObject(int n
) const;
133 Returns the array of objects.
135 wxRichTextObjectPtrArray
& GetObjects();
138 Returns the array of objects.
140 const wxRichTextObjectPtrArray
& GetObjects() const;
143 Returns the array of labels.
145 wxArrayString
& GetLabels();
148 Returns the array of labels.
150 const wxArrayString
& GetLabels() const;
153 Returns the number of items.
155 int GetCount() const;
157 wxRichTextObjectPtrArray m_objects
;
158 wxArrayString m_labels
;
162 @class wxRichTextCtrl
164 wxRichTextCtrl provides a generic, ground-up implementation of a text control
165 capable of showing multiple styles and images.
167 wxRichTextCtrl sends notification events: see wxRichTextEvent.
169 It also sends the standard wxTextCtrl events @c wxEVT_TEXT_ENTER and
170 @c wxEVT_TEXT, and wxTextUrlEvent when URL content is clicked.
172 For more information, see the @ref overview_richtextctrl.
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.
186 @appearance{richtextctrl}
190 class wxRichTextCtrl
: public wxControl
,
191 public wxTextCtrlIface
,
192 public wxScrollHelper
203 Constructor, creating and showing a rich text control.
206 Parent window. Must not be @NULL.
208 Window identifier. The value @c wxID_ANY indicates a default value.
222 @see Create(), wxValidator
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
);
230 virtual ~wxRichTextCtrl( );
235 Creates the underlying window.
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
);
241 Initialises the members of the control.
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.
252 virtual wxString
GetRange(long from
, long to
) const;
255 Returns the length of the specified line in characters.
257 virtual int GetLineLength(long lineNo
) const ;
260 Returns the text for the given line.
262 virtual wxString
GetLineText(long lineNo
) const ;
265 Returns the number of lines in the buffer.
267 virtual int GetNumberOfLines() const ;
270 Returns @true if the buffer has been modified.
272 virtual bool IsModified() const ;
275 Returns @true if the control is editable.
277 virtual bool IsEditable() const ;
280 Returns @true if the control is single-line.
281 Currently wxRichTextCtrl does not support single-line editing.
283 bool IsSingleLine() const;
286 Returns @true if the control is multiline.
288 bool IsMultiLine() const;
292 Returns the range of the current selection.
293 The end point of range is specified as the last character position of the span
295 If the return values @a from and @a to are the same, there is no selection.
297 virtual void GetSelection(long* from
, long* to
) const;
298 const wxRichTextSelection
& GetSelection() const;
299 wxRichTextSelection
& GetSelection();
303 Returns the text within the current selection range, if any.
305 virtual wxString
GetStringSelection() const;
308 Gets the current filename associated with the control.
310 wxString
GetFilename() const;
313 Sets the current filename.
315 void SetFilename(const wxString
& filename
);
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.
321 void SetDelayedLayoutThreshold(long threshold
);
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.
327 long GetDelayedLayoutThreshold() const;
331 bool GetFullLayoutRequired() const;
335 void SetFullLayoutRequired(bool b
);
339 wxLongLong
GetFullLayoutTime() const;
343 void SetFullLayoutTime(wxLongLong t
);
347 long GetFullLayoutSavedPosition() const;
351 void SetFullLayoutSavedPosition(long p
);
353 // Force any pending layout due to large buffer
356 void ForceDelayedLayout();
359 Sets the text (normal) cursor.
361 void SetTextCursor(const wxCursor
& cursor
);
364 Returns the text (normal) cursor.
366 wxCursor
GetTextCursor() const;
369 Sets the cursor to be used over URLs.
371 void SetURLCursor(const wxCursor
& cursor
);
374 Returns the cursor to be used over URLs.
376 wxCursor
GetURLCursor() const;
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.
382 bool GetCaretAtLineStart() const;
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.
388 void SetCaretAtLineStart(bool atStart
);
391 Returns @true if we are extending a selection.
393 bool GetDragging() const;
396 Sets a flag to remember if we are extending a selection.
398 void SetDragging(bool dragging
);
401 Are we trying to start Drag'n'Drop?
403 bool GetPreDrag() const;
406 Set if we're trying to start Drag'n'Drop
408 void SetPreDrag(bool pd
);
411 Get the possible Drag'n'Drop start point
413 const wxPoint
GetDragStartPoint() const;
416 Set the possible Drag'n'Drop start point
418 void SetDragStartPoint(wxPoint sp
);
421 Get the possible Drag'n'Drop start time
423 const wxDateTime
GetDragStartTime() const;
426 Set the possible Drag'n'Drop start time
428 void SetDragStartTime(wxDateTime st
);
430 #if wxRICHTEXT_BUFFERED_PAINTING
433 Returns the buffer bitmap if using buffered painting.
435 const wxBitmap
& GetBufferBitmap() const;
436 wxBitmap
& GetBufferBitmap();
441 Returns the current context menu.
443 wxMenu
* GetContextMenu() const;
446 Sets the current context menu.
448 void SetContextMenu(wxMenu
* menu
);
451 Returns an anchor so we know how to extend the selection.
452 It's a caret position since it's between two characters.
454 long GetSelectionAnchor() const;
457 Sets an anchor so we know how to extend the selection.
458 It's a caret position since it's between two characters.
460 void SetSelectionAnchor(long anchor
);
463 Returns the anchor object if selecting multiple containers.
465 wxRichTextObject
* GetSelectionAnchorObject() const;
468 Sets the anchor object if selecting multiple containers.
470 void SetSelectionAnchorObject(wxRichTextObject
* anchor
);
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.
480 wxRichTextContextMenuPropertiesInfo
& GetContextMenuPropertiesInfo();
481 const wxRichTextContextMenuPropertiesInfo
& GetContextMenuPropertiesInfo() const;
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.
488 wxRichTextParagraphLayoutBox
* GetFocusObject() const;
491 Setter for m_focusObject.
493 void StoreFocusObject(wxRichTextParagraphLayoutBox
* obj
);
496 Sets the wxRichTextObject object that currently has the editing focus.
498 The wxRichTextObject to set focus on.
499 @param setCaretPosition
500 Optionally set the caret position.
502 bool SetFocusObject(wxRichTextParagraphLayoutBox
* obj
, bool setCaretPosition
= true);
507 Invalidates the whole buffer to trigger painting later.
512 Clears the buffer content, leaving a single empty paragraph. Cannot be undone.
514 virtual void Clear();
517 Replaces the content in the specified range with the string specified by
520 virtual void Replace(long from
, long to
, const wxString
& value
);
523 Removes the content in the specified range.
525 virtual void Remove(long from
, long to
);
528 Loads content into the control's buffer using the given type.
530 If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
531 the filename extension.
533 This function looks for a suitable wxRichTextFileHandler object.
535 bool LoadFile(const wxString
& file
,
536 int type
= wxRICHTEXT_TYPE_ANY
);
539 Helper function for LoadFile(). Loads content into the control's buffer using the given type.
541 If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
542 the filename extension.
544 This function looks for a suitable wxRichTextFileHandler object.
546 virtual bool DoLoadFile(const wxString
& file
, int fileType
);
549 Saves the buffer content using the given type.
551 If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
552 the filename extension.
554 This function looks for a suitable wxRichTextFileHandler object.
556 bool SaveFile(const wxString
& file
= wxEmptyString
,
557 int type
= wxRICHTEXT_TYPE_ANY
);
560 Helper function for SaveFile(). Saves the buffer content using the given type.
562 If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
563 the filename extension.
565 This function looks for a suitable wxRichTextFileHandler object.
567 virtual bool DoSaveFile(const wxString
& file
= wxEmptyString
,
568 int fileType
= wxRICHTEXT_TYPE_ANY
);
571 Sets flags that change the behaviour of loading or saving.
573 See the documentation for each handler class to see what flags are
574 relevant for each handler.
576 void SetHandlerFlags(int flags
);
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.
583 int GetHandlerFlags() const;
586 Marks the buffer as modified.
588 virtual void MarkDirty();
591 Sets the buffer's modified status to @false, and clears the buffer's command
594 virtual void DiscardEdits();
597 void SetModified(bool modified
);
600 Sets the maximum number of characters that may be entered in a single line
601 text control. For compatibility only; currently does nothing.
603 virtual void SetMaxLength(unsigned long len
);
606 Writes text at the current position.
608 virtual void WriteText(const wxString
& text
);
611 Sets the insertion point to the end of the buffer and writes the text.
613 virtual void AppendText(const wxString
& text
);
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
622 To get the character or paragraph style alone, use GetUncombinedStyle().
625 In wxPerl this method is implemented as GetStyle(@a position)
626 returning a 2-element list (ok, attr).
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
);
636 Sets the attributes for the given range.
637 The end point of range is specified as the last character position of the span
640 So, for example, to set the style for a character at position 5, use the range
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
);
650 Sets the attributes for a single object
652 virtual void SetStyle(wxRichTextObject
*obj
, const wxRichTextAttr
& textAttr
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
656 Gets the attributes common to the specified range.
657 Attributes that differ in value within the range will not be included
661 In wxPerl this method is implemented as GetStyleForRange(@a position)
662 returning a 2-element list (ok, attr).
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
);
671 Sets the attributes for the given range, passing flags to determine how the
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).
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
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
694 - wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags
695 are used in this operation.
697 virtual bool SetStyleEx(const wxRichTextRange
& range
, const wxRichTextAttr
& style
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
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().
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.
712 In wxPerl this method is implemented as GetUncombinedStyle(@a position)
713 returning a 2-element list (ok, attr).
716 virtual bool GetUncombinedStyle(long position
, wxRichTextAttr
& style
);
717 virtual bool GetUncombinedStyle(long position
, wxRichTextAttr
& style
, wxRichTextParagraphLayoutBox
* container
);
722 Sets the current default style, which can be used to change how subsequently
723 inserted text is displayed.
725 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
726 virtual bool SetDefaultStyle(const wxRichTextAttr
& style
);
730 Returns the current default style, which can be used to change how subsequently
731 inserted text is displayed.
733 virtual const wxRichTextAttr
& GetDefaultStyleEx() const;
735 //virtual const wxTextAttr& GetDefaultStyle() const;
739 Sets the list attributes for the given range, passing flags to determine how
740 the attributes are set.
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.
751 @see NumberList(), PromoteList(), ClearListStyle().
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);
758 Clears the list style from the given range, clearing list-related attributes
759 and applying any named paragraph style associated with each paragraph.
761 @a flags is a bit list of the following:
762 - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
764 @see SetListStyle(), PromoteList(), NumberList().
766 virtual bool ClearListStyle(const wxRichTextRange
& range
, int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
770 Numbers the paragraphs in the given range.
771 Pass flags to determine how the attributes are set.
773 Either the style definition or the name of the style definition (in the current
774 sheet) can be passed.
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.
783 @see SetListStyle(), PromoteList(), ClearListStyle().
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);
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.
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.
804 @see SetListStyle(), @see SetListStyle(), ClearListStyle().
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);
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.
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).
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
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
828 - wxRICHTEXT_SETPROPERTIES_REMOVE: removes the specified properties.
830 virtual bool SetProperties(const wxRichTextRange
& range
, const wxRichTextProperties
& properties
, int flags
= wxRICHTEXT_SETPROPERTIES_WITH_UNDO
);
833 Deletes the content within the given range.
835 virtual bool Delete(const wxRichTextRange
& range
);
838 Translates from column and line number to position.
840 virtual long XYToPosition(long x
, long y
) const;
843 Converts a text position to zero-based column and line numbers.
845 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
848 Scrolls the buffer so that the given position is in view.
850 virtual void ShowPosition(long pos
);
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
858 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
, long *pos
) const;
859 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
861 wxTextCoord
*row
) const;
864 Finds the container at the given point, which is assumed to be in client coordinates.
866 wxRichTextParagraphLayoutBox
* FindContainerAtPoint(const wxPoint pt
, long& position
, int& hit
, wxRichTextObject
* hitObj
, int flags
= 0);
869 // Clipboard operations
872 Copies the selected content (if any) to the clipboard.
877 Copies the selected content (if any) to the clipboard and deletes the selection.
883 Pastes content from the clipboard to the buffer.
885 virtual void Paste();
888 Deletes the content in the selection, if any. This is undoable.
890 virtual void DeleteSelection();
893 Returns @true if selected content can be copied to the clipboard.
895 virtual bool CanCopy() const;
898 Returns @true if selected content can be copied to the clipboard and deleted.
900 virtual bool CanCut() const;
903 Returns @true if the clipboard content can be pasted to the buffer.
905 virtual bool CanPaste() const;
908 Returns @true if selected content can be deleted.
910 virtual bool CanDeleteSelection() const;
913 Undoes the command at the top of the command history, if there is one.
918 Redoes the current command.
923 Returns @true if there is a command in the command history that can be undone.
925 virtual bool CanUndo() const;
928 Returns @true if there is a command in the command history that can be redone.
930 virtual bool CanRedo() const;
933 Sets the insertion point and causes the current editing style to be taken from
934 the new position (unlike wxRichTextCtrl::SetCaretPosition).
936 virtual void SetInsertionPoint(long pos
);
939 Sets the insertion point to the end of the text control.
941 virtual void SetInsertionPointEnd();
944 Returns the current insertion point.
946 virtual long GetInsertionPoint() const;
949 Returns the last position in the buffer.
951 virtual wxTextPos
GetLastPosition() const;
955 Sets the selection to the given range.
956 The end point of range is specified as the last character position of the span
959 So, for example, to set the selection for a character at position 5, use the
962 virtual void SetSelection(long from
, long to
);
963 void SetSelection(const wxRichTextSelection
& sel
);
968 Selects all the text in the buffer.
970 virtual void SelectAll();
973 Makes the control editable, or not.
975 virtual void SetEditable(bool editable
);
978 Returns @true if there is a selection and the object containing the selection
979 was the same as the current focus object.
981 virtual bool HasSelection() const;
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.
987 virtual bool HasUnfocusedSelection() const;
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.
994 virtual bool WriteImage(const wxImage
& image
, wxBitmapType bitmapType
= wxBITMAP_TYPE_PNG
,
995 const wxRichTextAttr
& textAttr
= wxRichTextAttr());
997 virtual bool WriteImage(const wxBitmap
& bitmap
, wxBitmapType bitmapType
= wxBITMAP_TYPE_PNG
,
998 const wxRichTextAttr
& textAttr
= wxRichTextAttr());
1002 Loads an image from a file and writes it at the current insertion point.
1004 virtual bool WriteImage(const wxString
& filename
, wxBitmapType bitmapType
,
1005 const wxRichTextAttr
& textAttr
= wxRichTextAttr());
1008 Writes an image block at the current insertion point.
1010 virtual bool WriteImage(const wxRichTextImageBlock
& imageBlock
,
1011 const wxRichTextAttr
& textAttr
= wxRichTextAttr());
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.
1017 virtual wxRichTextBox
* WriteTextBox(const wxRichTextAttr
& textAttr
= wxRichTextAttr());
1020 Writes a field at the current insertion point.
1023 The field type, matching an existing field type definition.
1025 Extra data for the field.
1027 Optional attributes.
1029 @see wxRichTextField, wxRichTextFieldType, wxRichTextFieldTypeStandard
1031 virtual wxRichTextField
* WriteField(const wxString
& fieldType
, const wxRichTextProperties
& properties
,
1032 const wxRichTextAttr
& textAttr
= wxRichTextAttr());
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.
1038 virtual wxRichTextTable
* WriteTable(int rows
, int cols
, const wxRichTextAttr
& tableAttr
= wxRichTextAttr(), const wxRichTextAttr
& cellAttr
= wxRichTextAttr());
1041 Inserts a new paragraph at the current insertion point. @see LineBreak().
1043 virtual bool Newline();
1046 Inserts a line break at the current insertion point.
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.
1052 virtual bool LineBreak();
1055 Sets the basic (overall) style.
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).
1062 virtual void SetBasicStyle(const wxRichTextAttr
& style
);
1065 Gets the basic (overall) style.
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).
1072 virtual const wxRichTextAttr
& GetBasicStyle() const;
1075 Begins applying a style.
1077 virtual bool BeginStyle(const wxRichTextAttr
& style
);
1080 Ends the current style.
1082 virtual bool EndStyle();
1085 Ends application of all styles in the current style stack.
1087 virtual bool EndAllStyles();
1100 Begins using italic.
1110 Begins using underlining.
1112 bool BeginUnderline();
1115 End applying underlining.
1117 bool EndUnderline();
1120 Begins using the given point size.
1122 bool BeginFontSize(int pointSize
);
1125 Ends using a point size.
1130 Begins using this font.
1132 bool BeginFont(const wxFont
& font
);
1140 Begins using this colour.
1142 bool BeginTextColour(const wxColour
& colour
);
1145 Ends applying a text colour.
1147 bool EndTextColour();
1150 Begins using alignment.
1151 For alignment values, see wxTextAttr.
1153 bool BeginAlignment(wxTextAttrAlignment alignment
);
1158 bool EndAlignment();
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.
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.
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.
1178 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
1183 bool EndLeftIndent();
1186 Begins a right indent, specified in tenths of a millimetre.
1188 bool BeginRightIndent(int rightIndent
);
1193 bool EndRightIndent();
1196 Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing
1197 in tenths of a millimetre.
1199 bool BeginParagraphSpacing(int before
, int after
);
1202 Ends paragraph spacing.
1204 bool EndParagraphSpacing();
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.
1210 The ::wxTextAttrLineSpacing constants are defined for convenience.
1212 bool BeginLineSpacing(int lineSpacing
);
1217 bool EndLineSpacing();
1220 Begins a numbered bullet.
1222 This call will be needed for each item in the list, and the
1223 application should take care of incrementing the numbering.
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.
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.
1236 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
1239 Ends application of a numbered bullet.
1241 bool EndNumberedBullet();
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.
1248 bool BeginSymbolBullet(const wxString
& symbol
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
1251 Ends applying a symbol bullet.
1253 bool EndSymbolBullet();
1256 Begins applying a symbol bullet.
1258 bool BeginStandardBullet(const wxString
& bulletName
, int leftIndent
, int leftSubIndent
, int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_STANDARD
);
1261 Begins applying a standard bullet.
1263 bool EndStandardBullet();
1266 Begins using the named character style.
1268 bool BeginCharacterStyle(const wxString
& characterStyle
);
1271 Ends application of a named character style.
1273 bool EndCharacterStyle();
1276 Begins applying the named paragraph style.
1278 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
1281 Ends application of a named paragraph style.
1283 bool EndParagraphStyle();
1286 Begins using a specified list style.
1287 Optionally, you can also pass a level and a number.
1289 bool BeginListStyle(const wxString
& listStyle
, int level
= 1, int number
= 1);
1292 Ends using a specified list style.
1294 bool EndListStyle();
1297 Begins applying wxTEXT_ATTR_URL to the content.
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.
1302 bool BeginURL(const wxString
& url
, const wxString
& characterStyle
= wxEmptyString
);
1305 Ends applying a URL.
1310 Sets the default style to the style under the cursor.
1312 bool SetDefaultStyleToCursorStyle();
1315 Cancels any selection.
1317 virtual void SelectNone();
1320 Selects the word at the given character position.
1322 virtual bool SelectWord(long position
);
1325 Returns the selection range in character positions. -1, -1 means no selection.
1327 The range is in API convention, i.e. a single character selection is denoted
1330 wxRichTextRange
GetSelectionRange() const;
1333 Sets the selection to the given range.
1334 The end point of range is specified as the last character position of the span
1337 So, for example, to set the selection for a character at position 5, use the
1340 void SetSelectionRange(const wxRichTextRange
& range
);
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
1348 wxRichTextRange
GetInternalSelectionRange() const;
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
1356 void SetInternalSelectionRange(const wxRichTextRange
& range
);
1359 Adds a new paragraph of text to the end of the buffer.
1361 virtual wxRichTextRange
AddParagraph(const wxString
& text
);
1364 Adds an image to the control's buffer.
1366 virtual wxRichTextRange
AddImage(const wxImage
& image
);
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.
1373 virtual bool LayoutContent(bool onlyVisibleRect
= false);
1376 Move the caret to the given character position.
1378 Please note that this does not update the current editing style
1379 from the new position; to do that, call wxRichTextCtrl::SetInsertionPoint instead.
1381 virtual bool MoveCaret(long pos
, bool showAtLineStart
= false, wxRichTextParagraphLayoutBox
* container
= NULL
);
1386 virtual bool MoveRight(int noPositions
= 1, int flags
= 0);
1391 virtual bool MoveLeft(int noPositions
= 1, int flags
= 0);
1394 Moves to the start of the paragraph.
1396 virtual bool MoveUp(int noLines
= 1, int flags
= 0);
1399 Moves the caret down.
1401 virtual bool MoveDown(int noLines
= 1, int flags
= 0);
1404 Moves to the end of the line.
1406 virtual bool MoveToLineEnd(int flags
= 0);
1409 Moves to the start of the line.
1411 virtual bool MoveToLineStart(int flags
= 0);
1414 Moves to the end of the paragraph.
1416 virtual bool MoveToParagraphEnd(int flags
= 0);
1419 Moves to the start of the paragraph.
1421 virtual bool MoveToParagraphStart(int flags
= 0);
1424 Moves to the start of the buffer.
1426 virtual bool MoveHome(int flags
= 0);
1429 Moves to the end of the buffer.
1431 virtual bool MoveEnd(int flags
= 0);
1434 Moves one or more pages up.
1436 virtual bool PageUp(int noPages
= 1, int flags
= 0);
1439 Moves one or more pages down.
1441 virtual bool PageDown(int noPages
= 1, int flags
= 0);
1444 Moves a number of words to the left.
1446 virtual bool WordLeft(int noPages
= 1, int flags
= 0);
1449 Move a nuber of words to the right.
1451 virtual bool WordRight(int noPages
= 1, int flags
= 0);
1455 Returns the buffer associated with the control.
1457 wxRichTextBuffer
& GetBuffer();
1458 const wxRichTextBuffer
& GetBuffer() const;
1462 Starts batching undo history for commands.
1464 virtual bool BeginBatchUndo(const wxString
& cmdName
);
1467 Ends batching undo command history.
1469 virtual bool EndBatchUndo();
1472 Returns @true if undo commands are being batched.
1474 virtual bool BatchingUndo() const;
1477 Starts suppressing undo history for commands.
1479 virtual bool BeginSuppressUndo();
1482 Ends suppressing undo command history.
1484 virtual bool EndSuppressUndo();
1487 Returns @true if undo history suppression is on.
1489 virtual bool SuppressingUndo() const;
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.
1495 You can use this to implement, for example, bold button updating.
1496 @a style must have flags indicating which attributes are of interest.
1498 virtual bool HasCharacterAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
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.
1507 virtual bool HasParagraphAttributes(const wxRichTextRange
& range
, const wxRichTextAttr
& style
) const;
1511 Returns @true if all of the selection, or the content at the caret position, is bold.
1513 virtual bool IsSelectionBold();
1516 Returns @true if all of the selection, or the content at the caret position, is italic.
1518 virtual bool IsSelectionItalics();
1521 Returns @true if all of the selection, or the content at the caret position, is underlined.
1523 virtual bool IsSelectionUnderlined();
1526 Returns @true if all of the selection, or the content at the current caret position, has the supplied wxTextAttrEffects flag(s).
1528 virtual bool DoesSelectionHaveTextEffectFlag(int flag
);
1531 Returns @true if all of the selection is aligned according to the specified flag.
1533 virtual bool IsSelectionAligned(wxTextAttrAlignment alignment
);
1536 Apples bold to the selection or the default style (undoable).
1538 virtual bool ApplyBoldToSelection();
1541 Applies italic to the selection or the default style (undoable).
1543 virtual bool ApplyItalicToSelection();
1546 Applies underline to the selection or the default style (undoable).
1548 virtual bool ApplyUnderlineToSelection();
1551 Applies one or more wxTextAttrEffects flags to the selection (undoable).
1552 If there is no selection, it is applied to the default style.
1554 virtual bool ApplyTextEffectToSelection(int flags
);
1557 Applies the given alignment to the selection or the default style (undoable).
1558 For alignment values, see wxTextAttr.
1560 virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment
);
1563 Applies the style sheet to the buffer, matching paragraph styles in the sheet
1564 against named styles in the buffer.
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.
1570 virtual bool ApplyStyle(wxRichTextStyleDefinition
* def
);
1573 Sets the style sheet associated with the control.
1574 A style sheet allows named character and paragraph styles to be applied.
1576 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1579 Returns the style sheet associated with the control, if any.
1580 A style sheet allows named character and paragraph styles to be applied.
1582 wxRichTextStyleSheet
* GetStyleSheet() const;
1585 Push the style sheet to top of stack.
1587 bool PushStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1590 Pops the style sheet from top of stack.
1592 wxRichTextStyleSheet
* PopStyleSheet();
1595 Applies the style sheet to the buffer, for example if the styles have changed.
1597 bool ApplyStyleSheet(wxRichTextStyleSheet
* styleSheet
= NULL
);
1600 Shows the given context menu, optionally adding appropriate property-editing commands for the current position in the object hierarchy.
1602 virtual bool ShowContextMenu(wxMenu
* menu
, const wxPoint
& pt
, bool addPropertyCommands
);
1605 Prepares the context menu, optionally adding appropriate property-editing commands.
1606 Returns the number of property commands added.
1608 virtual int PrepareContextMenu(wxMenu
* menu
, const wxPoint
& pt
, bool addPropertyCommands
);
1611 Returns @true if we can edit the object's properties via a GUI.
1613 virtual bool CanEditProperties(wxRichTextObject
* obj
) const;
1616 Edits the object's properties via a GUI.
1618 virtual bool EditProperties(wxRichTextObject
* obj
, wxWindow
* parent
);
1621 Gets the object's properties menu label.
1623 virtual wxString
GetPropertiesMenuLabel(wxRichTextObject
* obj
);
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.
1629 virtual void PrepareContent(wxRichTextParagraphLayoutBox
& container
);
1632 Can we delete this range?
1633 Sends an event to the control.
1635 virtual bool CanDeleteRange(wxRichTextParagraphLayoutBox
& container
, const wxRichTextRange
& range
) const;
1638 Can we insert content at this position?
1639 Sends an event to the control.
1641 virtual bool CanInsertContent(wxRichTextParagraphLayoutBox
& container
, long pos
) const;
1644 Enable or disable the vertical scrollbar.
1646 virtual void EnableVerticalScrollbar(bool enable
);
1649 Returns @true if the vertical scrollbar is enabled.
1651 virtual bool GetVerticalScrollbarEnabled() const;
1654 Sets the scale factor for displaying fonts, for example for more comfortable
1657 void SetFontScale(double fontScale
, bool refresh
= false);
1660 Returns the scale factor for displaying fonts, for example for more comfortable
1663 double GetFontScale() const { return GetBuffer().GetFontScale(); }
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.
1670 void SetDimensionScale(double dimScale
, bool refresh
= false);
1673 Returns the scale factor for displaying certain dimensions such as indentation
1674 and inter-paragraph spacing.
1676 double GetDimensionScale() const { return GetBuffer().GetDimensionScale(); }
1679 Sets an overall scale factor for displaying and editing the content.
1681 void SetScale(double scale
, bool refresh
= false);
1684 Returns an overall scale factor for displaying and editing the content.
1686 double GetScale() const;
1689 Returns an unscaled point.
1691 wxPoint
GetUnscaledPoint(const wxPoint
& pt
) const;
1694 Returns a scaled point.
1696 wxPoint
GetScaledPoint(const wxPoint
& pt
) const;
1699 Returns an unscaled size.
1701 wxSize
GetUnscaledSize(const wxSize
& sz
) const;
1704 Returns a scaled size.
1706 wxSize
GetScaledSize(const wxSize
& sz
) const;
1709 Returns an unscaled rectangle.
1711 wxRect
GetUnscaledRect(const wxRect
& rect
) const;
1714 Returns a scaled rectangle.
1716 wxRect
GetScaledRect(const wxRect
& rect
) const;
1719 Returns @true if this control can use virtual attributes and virtual text.
1720 The default is @false.
1722 bool GetVirtualAttributesEnabled() const;
1725 Pass @true to let the control use virtual attributes.
1726 The default is @false.
1728 void EnableVirtualAttributes(bool b
);
1733 Sends the event to the control.
1735 void Command(wxCommandEvent
& event
);
1738 Loads the first dropped file.
1740 void OnDropFiles(wxDropFilesEvent
& event
);
1742 void OnCaptureLost(wxMouseCaptureLostEvent
& event
);
1743 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
1746 Standard handler for the wxID_CUT command.
1748 void OnCut(wxCommandEvent
& event
);
1751 Standard handler for the wxID_COPY command.
1753 void OnCopy(wxCommandEvent
& event
);
1756 Standard handler for the wxID_PASTE command.
1758 void OnPaste(wxCommandEvent
& event
);
1761 Standard handler for the wxID_UNDO command.
1763 void OnUndo(wxCommandEvent
& event
);
1766 Standard handler for the wxID_REDO command.
1768 void OnRedo(wxCommandEvent
& event
);
1771 Standard handler for the wxID_SELECTALL command.
1773 void OnSelectAll(wxCommandEvent
& event
);
1776 Standard handler for property commands.
1778 void OnProperties(wxCommandEvent
& event
);
1781 Standard handler for the wxID_CLEAR command.
1783 void OnClear(wxCommandEvent
& event
);
1786 Standard update handler for the wxID_CUT command.
1788 void OnUpdateCut(wxUpdateUIEvent
& event
);
1791 Standard update handler for the wxID_COPY command.
1793 void OnUpdateCopy(wxUpdateUIEvent
& event
);
1796 Standard update handler for the wxID_PASTE command.
1798 void OnUpdatePaste(wxUpdateUIEvent
& event
);
1801 Standard update handler for the wxID_UNDO command.
1803 void OnUpdateUndo(wxUpdateUIEvent
& event
);
1806 Standard update handler for the wxID_REDO command.
1808 void OnUpdateRedo(wxUpdateUIEvent
& event
);
1811 Standard update handler for the wxID_SELECTALL command.
1813 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
1816 Standard update handler for property commands.
1819 void OnUpdateProperties(wxUpdateUIEvent
& event
);
1822 Standard update handler for the wxID_CLEAR command.
1824 void OnUpdateClear(wxUpdateUIEvent
& event
);
1827 Shows a standard context menu with undo, redo, cut, copy, paste, clear, and
1828 select all commands.
1830 void OnContextMenu(wxContextMenuEvent
& event
);
1835 void OnPaint(wxPaintEvent
& event
);
1836 void OnEraseBackground(wxEraseEvent
& event
);
1839 void OnLeftClick(wxMouseEvent
& event
);
1842 void OnLeftUp(wxMouseEvent
& event
);
1845 void OnMoveMouse(wxMouseEvent
& event
);
1847 // Left-double-click
1848 void OnLeftDClick(wxMouseEvent
& event
);
1851 void OnMiddleClick(wxMouseEvent
& event
);
1854 void OnRightClick(wxMouseEvent
& event
);
1857 void OnChar(wxKeyEvent
& event
);
1860 void OnSize(wxSizeEvent
& event
);
1862 // Setting/losing focus
1863 void OnSetFocus(wxFocusEvent
& event
);
1864 void OnKillFocus(wxFocusEvent
& event
);
1866 // Idle-time processing
1867 void OnIdle(wxIdleEvent
& event
);
1870 void OnScroll(wxScrollWinEvent
& event
);
1873 Sets the font, and also the basic and default attributes
1874 (see wxRichTextCtrl::SetDefaultStyle).
1876 virtual bool SetFont(const wxFont
& font
);
1879 A helper function setting up scrollbars, for example after a resize.
1881 virtual void SetupScrollbars(bool atTop
= false);
1884 Helper function implementing keyboard navigation.
1886 virtual bool KeyboardNavigate(int keyCode
, int flags
);
1889 Paints the background.
1891 virtual void PaintBackground(wxDC
& dc
);
1894 Other user defined painting after everything else (i.e.\ all text) is painted.
1898 virtual void PaintAboveContent(wxDC
& WXUNUSED(dc
)) {}
1900 #if wxRICHTEXT_BUFFERED_PAINTING
1902 Recreates the buffer bitmap if necessary.
1904 virtual bool RecreateBuffer(const wxSize
& size
= wxDefaultSize
);
1908 virtual void DoWriteText(const wxString
& value
, int flags
= 0);
1910 // Should we inherit colours?
1911 virtual bool ShouldInheritColours() const;
1914 Internal function to position the visible caret according to the current caret
1917 virtual void PositionCaret(wxRichTextParagraphLayoutBox
* container
= NULL
);
1920 Helper function for extending the selection, returning @true if the selection
1921 was changed. Selections are in caret positions.
1923 virtual bool ExtendSelection(long oldPosition
, long newPosition
, int flags
);
1926 Scrolls @a position into view. This function takes a caret position.
1928 virtual bool ScrollIntoView(long position
, int keyCode
);
1931 Refreshes the area affected by a selection change.
1933 bool RefreshForSelectionChange(const wxRichTextSelection
& oldSelection
, const wxRichTextSelection
& newSelection
);
1936 Sets the caret position.
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.
1944 void SetCaretPosition(long position
, bool showAtLineStart
= false) ;
1947 Returns the current caret position.
1949 long GetCaretPosition() const;
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.
1956 long GetAdjustedCaretPosition(long caretPos
) const;
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.
1963 void MoveCaretForward(long oldPosition
) ;
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.
1970 void MoveCaretBack(long oldPosition
) ;
1973 Returns the caret height and position for the given character position.
1974 If container is null, the current focus object will be used.
1977 In wxPerl this method is implemented as
1978 GetCaretPositionForIndex(@a position) returning a
1979 2-element list (ok, rect).
1982 bool GetCaretPositionForIndex(long position
, wxRect
& rect
, wxRichTextParagraphLayoutBox
* container
= NULL
);
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.
1990 wxRichTextLine
* GetVisibleLineForCaretPosition(long caretPosition
) const;
1993 Gets the command processor associated with the control's buffer.
1995 wxCommandProcessor
* GetCommandProcessor() const;
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.
2003 In wxPerl this method takes no arguments and returns a 2-element
2007 bool DeleteSelectedContent(long* newPos
= NULL
);
2010 Transforms logical (unscrolled) position to physical window position.
2012 wxPoint
GetPhysicalPoint(const wxPoint
& ptLogical
) const;
2015 Transforms physical window position to logical (unscrolled) position.
2017 wxPoint
GetLogicalPoint(const wxPoint
& ptPhysical
) const;
2020 Helper function for finding the caret position for the next word.
2021 Direction is 1 (forward) or -1 (backwards).
2023 virtual long FindNextWordPosition(int direction
= 1) const;
2026 Returns @true if the given position is visible on the screen.
2028 bool IsPositionVisible(long pos
) const;
2031 Returns the first visible position in the current view.
2033 long GetFirstVisiblePosition() const;
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.
2041 long GetCaretPositionForDefaultStyle() const;
2044 Set the caret position for the default style that the user is selecting.
2046 void SetCaretPositionForDefaultStyle(long pos
);
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.
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.
2056 @see SetAndShowDefaultStyle().
2058 bool IsDefaultStyleShowing() const;
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.
2064 @see IsDefaultStyleShowing().
2066 void SetAndShowDefaultStyle(const wxRichTextAttr
& attr
);
2069 Returns the first visible point in the window.
2071 wxPoint
GetFirstVisiblePoint() const;
2074 Returns the content of the entire control as a string.
2076 virtual wxString
GetValue() const;
2079 Replaces existing content with the given text.
2081 virtual void SetValue(const wxString
& value
);
2087 Processes the back key.
2089 virtual bool ProcessBackKey(wxKeyEvent
& event
, int flags
);
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.
2095 virtual wxRichTextRange
FindRangeForList(long pos
, bool& isNumberedList
);
2098 Sets up the caret for the given position and container, after a mouse click.
2100 bool SetCaretPositionAfterClick(wxRichTextParagraphLayoutBox
* container
, long position
, int hitTestFlags
, bool extendSelection
= false);
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).
2107 long FindCaretPositionForCharacterPosition(long position
, int hitTestFlags
, wxRichTextParagraphLayoutBox
* container
,
2108 bool& caretLineStart
);
2111 Processes mouse movement in order to change the cursor
2113 virtual bool ProcessMouseMovement(wxRichTextParagraphLayoutBox
* container
, wxRichTextObject
* obj
, long position
, const wxPoint
& pos
);
2116 Font names take a long time to retrieve, so cache them (on demand).
2118 static const wxArrayString
& GetAvailableFontNames();
2121 Clears the cache of available font names.
2123 static void ClearAvailableFontNames();
2125 // implement wxTextEntry methods
2126 virtual wxString
DoGetValue() const;
2129 // implement the wxTextEntry pure virtual method
2130 virtual wxWindow
*GetEditableWindow();
2132 // margins functions
2133 virtual bool DoSetMargins(const wxPoint
& pt
);
2134 virtual wxPoint
DoGetMargins() const;
2141 Currently this simply returns @c wxSize(10, 10).
2143 virtual wxSize
DoGetBestSize() const ;
2145 virtual void DoSetValue(const wxString
& value
, int flags
= 0);
2147 virtual void DoThaw();
2152 #if wxRICHTEXT_BUFFERED_PAINTING
2154 wxBitmap m_bufferBitmap
;
2158 wxRichTextBuffer m_buffer
;
2160 wxMenu
* m_contextMenu
;
2162 /// Caret position (1 less than the character position, so -1 is the
2163 /// first caret position).
2164 long m_caretPosition
;
2166 /// Caret position when the default formatting has been changed. As
2167 /// soon as this position changes, we no longer reflect the default style
2169 long m_caretPositionForDefaultStyle
;
2171 /// Selection range in character positions. -2, -2 means no selection.
2172 wxRichTextSelection m_selection
;
2174 wxRichTextCtrlSelectionState m_selectionState
;
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
;
2180 /// Anchor object if selecting multiple container objects, such as grid cells.
2181 wxRichTextObject
* m_selectionAnchorObject
;
2183 /// Are we editable?
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
;
2190 /// Are we dragging a selection?
2193 /// Do we need full layout in idle?
2194 bool m_fullLayoutRequired
;
2195 wxLongLong m_fullLayoutTime
;
2196 long m_fullLayoutSavedPosition
;
2198 /// Threshold for doing delayed layout
2199 long m_delayedLayoutThreshold
;
2202 wxCursor m_textCursor
;
2203 wxCursor m_urlCursor
;
2205 static wxArrayString sm_availableFontNames
;
2207 wxRichTextContextMenuPropertiesInfo m_contextMenuPropertiesInfo
;
2209 /// The object that currently has the editing focus
2210 wxRichTextParagraphLayoutBox
* m_focusObject
;
2214 @class wxRichTextEvent
2216 This is the event class for wxRichTextCtrl notifications.
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.
2283 @library{wxrichtext}
2284 @category{events,richtext}
2287 class wxRichTextEvent
: public wxNotifyEvent
2294 The type of the event.
2296 Window identifier. The value @c wxID_ANY indicates a default value.
2298 wxRichTextEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0);
2303 wxRichTextEvent(const wxRichTextEvent
& event
);
2306 Returns the buffer position at which the event occurred.
2308 long GetPosition() const;
2311 Sets the buffer position variable.
2313 void SetPosition(long pos
);
2316 Returns flags indicating modifier keys pressed.
2318 Possible values are @c wxRICHTEXT_CTRL_DOWN, @c wxRICHTEXT_SHIFT_DOWN, and @c wxRICHTEXT_ALT_DOWN.
2320 int GetFlags() const;
2323 Sets flags indicating modifier keys pressed.
2325 Possible values are @c wxRICHTEXT_CTRL_DOWN, @c wxRICHTEXT_SHIFT_DOWN, and @c wxRICHTEXT_ALT_DOWN.
2327 void SetFlags(int flags
);
2330 Returns the old style sheet.
2332 Can be used in a @c wxEVT_RICHTEXT_STYLESHEET_CHANGING or
2333 @c wxEVT_RICHTEXT_STYLESHEET_CHANGED event handler.
2335 wxRichTextStyleSheet
* GetOldStyleSheet() const;
2338 Sets the old style sheet variable.
2340 void SetOldStyleSheet(wxRichTextStyleSheet
* sheet
);
2343 Returns the new style sheet.
2345 Can be used in a @c wxEVT_RICHTEXT_STYLESHEET_CHANGING or
2346 @c wxEVT_RICHTEXT_STYLESHEET_CHANGED event handler.
2348 wxRichTextStyleSheet
* GetNewStyleSheet() const;
2351 Sets the new style sheet variable.
2353 void SetNewStyleSheet(wxRichTextStyleSheet
* sheet
);
2356 Gets the range for the current operation.
2358 const wxRichTextRange
& GetRange() const;
2361 Sets the range variable.
2363 void SetRange(const wxRichTextRange
& range
);
2366 Returns the character pressed, within a @c wxEVT_RICHTEXT_CHARACTER event.
2368 wxChar
GetCharacter() const;
2371 Sets the character variable.
2373 void SetCharacter(wxChar ch
);
2376 Returns the container for which the event is relevant.
2378 wxRichTextParagraphLayoutBox
* GetContainer() const;
2381 Sets the container for which the event is relevant.
2383 void SetContainer(wxRichTextParagraphLayoutBox
* container
);
2386 Returns the old container, for a focus change event.
2388 wxRichTextParagraphLayoutBox
* GetOldContainer() const;
2391 Sets the old container, for a focus change event.
2393 void SetOldContainer(wxRichTextParagraphLayoutBox
* container
);
2395 virtual wxEvent
*Clone() const;
2400 wxRichTextStyleSheet
* m_oldStyleSheet
;
2401 wxRichTextStyleSheet
* m_newStyleSheet
;
2402 wxRichTextRange m_range
;
2404 wxRichTextParagraphLayoutBox
* m_container
;
2405 wxRichTextParagraphLayoutBox
* m_oldContainer
;
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
;
2418 wxEventType wxEVT_RICHTEXT_STYLESHEET_CHANGING
;
2419 wxEventType wxEVT_RICHTEXT_STYLESHEET_CHANGED
;
2420 wxEventType wxEVT_RICHTEXT_STYLESHEET_REPLACING
;
2421 wxEventType wxEVT_RICHTEXT_STYLESHEET_REPLACED
;
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
;