1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextctrl.h
3 // Purpose: interface of wxRichTextEvent
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxRichTextEvent
12 This is the event class for wxRichTextCtrl notifications.
17 class wxRichTextEvent
: public wxNotifyEvent
23 wxRichTextEvent(const wxRichTextEvent
& event
);
29 Window identifier. The value @c wxID_ANY indicates a default value.
31 wxRichTextEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0);
36 wxEvent
* Clone() const;
39 Returns the character pressed, within a wxEVT_COMMAND_RICHTEXT_CHARACTER event.
41 wxChar
GetCharacter() const;
44 Returns flags indicating modifier keys pressed. Possible values are
46 wxRICHTEXT_SHIFT_DOWN, and wxRICHTEXT_ALT_DOWN.
51 Returns the new style sheet. Can be used in a
52 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or
53 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler.
55 wxRichTextStyleSheet
* GetNewStyleSheet() const;
58 Returns the old style sheet. Can be used in a
59 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or
60 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler.
62 wxRichTextStyleSheet
* GetOldStyleSheet() const;
65 Returns the buffer position at which the event occured.
67 long GetPosition() const;
70 Gets the range for the current operation.
72 wxRichTextRange
GetRange() const;
75 Sets the character variable.
77 void SetCharacter(wxChar ch
);
80 Sets flags indicating modifier keys pressed. Possible values are
82 wxRICHTEXT_SHIFT_DOWN, and wxRICHTEXT_ALT_DOWN.
84 void SetFlags(int flags
);
87 Sets the new style sheet variable.
89 void SetNewStyleSheet(wxRichTextStyleSheet
* sheet
);
92 Sets the old style sheet variable.
94 void SetOldStyleSheet(wxRichTextStyleSheet
* sheet
);
97 Sets the buffer position variable.
99 void SetPosition(long pos
);
102 Sets the range variable.
104 void SetRange(const wxRichTextRange
& range
);
110 @class wxRichTextCtrl
112 wxRichTextCtrl provides a generic, ground-up implementation of a text control
113 capable of showing multiple styles and images.
115 wxRichTextCtrl sends notification events: see wxRichTextEvent.
116 It also sends the standard wxTextCtrl events wxEVT_COMMAND_TEXT_ENTER and
117 wxEVT_COMMAND_TEXT_UPDATED,
118 and wxTextUrlEvent when URL content is clicked.
120 For more information, see the @ref overview_richtextctrl.
134 Constructor, creating and showing a rich text control.
137 Parent window. Must not be @NULL.
139 Window identifier. The value @c wxID_ANY indicates a default value.
153 @see Create(), wxValidator
155 wxRichTextCtrl(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
156 const wxString
& value
= wxEmptyString
,
157 const wxPoint
& pos
= wxDefaultPosition
,
158 const wxSize
& size
= wxDefaultSize
,
159 long style
= wxRE_MULTILINE
,
160 const wxValidator
& validator
= wxDefaultValidator
,
161 const wxString
& name
= wxTextCtrlNameStr
);
166 virtual ~wxRichTextCtrl();
169 Adds an image to the control's buffer.
171 virtual wxRichTextRange
AddImage(const wxImage
& image
);
174 Adds a new paragraph of text to the end of the buffer.
176 virtual wxRichTextRange
AddParagraph(const wxString
& text
);
179 Sets the insertion point to the end of the buffer and writes the text.
181 virtual void AppendText(const wxString
& text
);
184 Applies the given alignment to the selection (undoable).
185 For alignment values, see wxTextAttr.
187 virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment
);
190 Apples bold to the selection (undoable).
192 virtual bool ApplyBoldToSelection();
195 Applies italic to the selection (undoable).
197 virtual bool ApplyItalicToSelection();
200 Applies the given style to the selection.
202 virtual bool ApplyStyle(wxRichTextStyleDefinition
* def
);
205 Applies the style sheet to the buffer, matching paragraph styles in the sheet
207 in the buffer. This might be useful if the styles have changed. If @a sheet is
209 sheet set with SetStyleSheet is used.
210 Currently this applies paragraph styles only.
212 bool ApplyStyleSheet(wxRichTextStyleSheet
* sheet
= NULL
);
215 Applies underline to the selection (undoable).
217 virtual bool ApplyUnderlineToSelection();
220 Returns @true if undo commands are being batched.
222 virtual bool BatchingUndo() const;
225 Begins using alignment
226 For alignment values, see wxTextAttr.
228 bool BeginAlignment(wxTextAttrAlignment alignment
);
231 Starts batching undo history for commands.
233 virtual bool BeginBatchUndo(const wxString
& cmdName
);
241 Begins using the named character style.
243 bool BeginCharacterStyle(const wxString
& characterStyle
);
246 Begins using this font.
248 bool BeginFont(const wxFont
& font
);
251 Begins using the given point size.
253 bool BeginFontSize(int pointSize
);
261 Begins applying a left indent and subindent in tenths of a millimetre.
262 The subindent is an offset from the left edge of the paragraph, and is
263 used for all but the first line in a paragraph. A positive value will
264 cause the first line to appear to the left of the subsequent lines, and
265 a negative value will cause the first line to be indented to the right
266 of the subsequent lines.
268 wxRichTextBuffer uses indentation to render a bulleted item. The
269 content of the paragraph, including the first line, starts at the
270 @a leftIndent plus the @a leftSubIndent.
273 The distance between the margin and the bullet.
275 The distance between the left edge of the bullet and the left edge
276 of the actual paragraph.
278 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
281 Begins appling line spacing. @e spacing is a multiple, where 10 means
283 15 means 1.5 spacing, and 20 means double spacing. The following constants are
284 defined for convenience:
286 bool BeginLineSpacing(int lineSpacing
);
289 Begins using a specified list style. Optionally, you can also pass a level and
292 bool BeginListStyle(const wxString
& listStyle
, int level
= 1,
296 Begins a numbered bullet. This call will be needed for each item in the list,
298 application should take care of incrementing the numbering.
299 @a bulletNumber is a number, usually starting with 1.
300 @a leftIndent and @a leftSubIndent are values in tenths of a millimetre.
301 @a bulletStyle is a bitlist of the following values:
303 wxRichTextBuffer uses indentation to render a bulleted item. The left indent is
305 the margin and the bullet. The content of the paragraph, including the first
307 at leftMargin + leftSubIndent. So the distance between the left edge of the
309 left of the actual paragraph is leftSubIndent.
311 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
,
313 int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
316 Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing
320 bool BeginParagraphSpacing(int before
, int after
);
323 Begins applying the named paragraph style.
325 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
328 Begins a right indent, specified in tenths of a millimetre.
330 bool BeginRightIndent(int rightIndent
);
333 Begins applying a style.
335 virtual bool BeginStyle(const wxTextAttr
& style
);
338 Starts suppressing undo history for commands.
340 virtual bool BeginSuppressUndo();
343 Begins applying a symbol bullet, using a character from the current font. See
344 BeginNumberedBullet() for
345 an explanation of how indentation is used to render the bulleted paragraph.
347 bool BeginSymbolBullet(wxChar symbol
, int leftIndent
,
349 int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
352 Begins using this colour.
354 bool BeginTextColour(const wxColour
& colour
);
357 Begins applying wxTEXT_ATTR_URL to the content. Pass a URL and optionally, a
358 character style to apply,
359 since it is common to mark a URL with a familiar style such as blue text with
362 bool BeginURL(const wxString
& url
,
363 const wxString
& characterStyle
= wxEmptyString
);
366 Begins using underlining.
368 bool BeginUnderline();
371 Returns @true if selected content can be copied to the clipboard.
373 virtual bool CanCopy() const;
376 Returns @true if selected content can be copied to the clipboard and deleted.
378 virtual bool CanCut() const;
381 Returns @true if selected content can be deleted.
383 virtual bool CanDeleteSelection() const;
386 Returns @true if the clipboard content can be pasted to the buffer.
388 virtual bool CanPaste() const;
391 Returns @true if there is a command in the command history that can be redone.
393 virtual bool CanRedo() const;
396 Returns @true if there is a command in the command history that can be undone.
398 virtual bool CanUndo() const;
401 Clears the buffer content, leaving a single empty paragraph. Cannot be undone.
403 virtual void Clear();
407 Clears the list style from the given range, clearing list-related attributes
408 and applying any named paragraph style associated with each paragraph.
409 @a flags is a bit list of the following:
410 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
411 See also SetListStyle(), PromoteList(), NumberList().
413 bool ClearListStyle(const wxRichTextRange
& range
,
414 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
415 bool ClearListStyle(const wxRichTextRange
& range
,
416 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
420 Sends the event to the control.
422 virtual void Command(wxCommandEvent
& event
);
425 Copies the selected content (if any) to the clipboard.
430 Creates the underlying window.
432 bool Create(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
433 const wxString
& value
= wxEmptyString
,
434 const wxPoint
& pos
= wxDefaultPosition
,
435 const wxSize
& size
= wxDefaultSize
,
436 long style
= wxRE_MULTILINE
,
437 const wxValidator
& validator
= wxDefaultValidator
,
438 const wxString
& name
= wxTextCtrlNameStr
);
441 Copies the selected content (if any) to the clipboard and deletes the selection.
447 Deletes the content within the given range.
449 virtual bool Delete(const wxRichTextRange
& range
);
452 Deletes content if there is a selection, e.g. when pressing a key.
453 Returns the new caret position in @e newPos, or leaves it if there
454 was no action. This is undoable.
456 bool DeleteSelectedContent(long* newPos
= NULL
);
459 Deletes the content in the selection, if any. This is undoable.
461 virtual void DeleteSelection();
464 Sets the buffer's modified status to @false, and clears the buffer's command
467 virtual void DiscardEdits();
470 Currently this simply returns @c wxSize(10, 10).
472 wxSize
DoGetBestSize() const;
480 Ends application of all styles in the current style stack.
482 virtual bool EndAllStyles();
485 Ends batching undo command history.
487 virtual bool EndBatchUndo();
495 Ends application of a named character style.
497 bool EndCharacterStyle();
505 Ends using a point size.
517 bool EndLeftIndent();
522 bool EndLineSpacing();
525 Ends using a specified list style.
530 Ends application of a numbered bullet.
532 bool EndNumberedBullet();
535 Ends paragraph spacing.
537 bool EndParagraphSpacing();
540 Ends application of a named character style.
542 bool EndParagraphStyle();
547 bool EndRightIndent();
550 Ends the current style.
552 virtual bool EndStyle();
555 Ends suppressing undo command history.
557 virtual bool EndSuppressUndo();
560 Ends applying a symbol bullet.
562 bool EndSymbolBullet();
565 Ends applying a text colour.
567 bool EndTextColour();
575 End applying underlining.
580 Helper function for extending the selection, returning @true if the selection
582 changed. Selections are in caret positions.
584 bool ExtendSelection(long oldPosition
, long newPosition
,
588 Helper function for finding the caret position for the next word. Direction
589 is 1 (forward) or -1 (backwards).
591 virtual long FindNextWordPosition(int direction
= 1) const;
594 Call this function to prevent refresh and allow fast updates, and then Thaw() to
600 Gets the basic (overall) style. This is the style of the whole
601 buffer before further styles are applied, unlike the default style, which
602 only affects the style currently being applied (for example, setting the default
603 style to bold will cause subsequently inserted text to be bold).
605 const wxTextAttr
GetBasicStyle() const;
609 Returns the buffer associated with the control.
611 const wxRichTextBuffer
GetBuffer();
612 const wxRichTextBuffer
& GetBuffer();
616 Returns the current caret position.
618 long GetCaretPosition() const;
621 Returns the caret height and position for the given character position
623 bool GetCaretPositionForIndex(long position
, wxRect
& rect
);
626 Gets the command processor associated with the control's buffer.
628 wxCommandProcessor
* GetCommandProcessor() const;
631 Returns the current default style, which can be used to change how subsequently
635 const wxTextAttr
GetDefaultStyle() const;
638 Gets the size of the buffer beyond which layout is delayed during resizing.
639 This optimizes sizing for large buffers. The default is 20000.
641 long GetDelayedLayoutThreshold() const;
644 Gets the current filename associated with the control.
646 wxString
GetFilename() const;
649 Returns the first visible position in the current view.
651 long GetFirstVisiblePosition() const;
654 Returns flags that change the behaviour of loading or saving. See the
655 documentation for each
656 handler class to see what flags are relevant for each handler.
658 int GetHandlerFlags() const;
661 Returns the current insertion point.
663 virtual long GetInsertionPoint() const;
666 Returns the last position in the buffer.
668 virtual wxTextPos
GetLastPosition() const;
671 Returns the length of the specified line in characters.
673 virtual int GetLineLength(long lineNo
) const;
676 Returns the text for the given line.
678 virtual wxString
GetLineText(long lineNo
) const;
681 Transforms physical window position to logical (unscrolled) position.
683 wxPoint
GetLogicalPoint(const wxPoint
& ptPhysical
) const;
686 Returns the number of lines in the buffer.
688 virtual int GetNumberOfLines() const;
691 Transforms logical (unscrolled) position to physical window position.
693 wxPoint
GetPhysicalPoint(const wxPoint
& ptLogical
) const;
696 Gets the text for the given range.
697 The end point of range is specified as the last character position of the span
700 virtual wxString
GetRange(long from
, long to
) const;
703 Returns the range of the current selection.
704 The end point of range is specified as the last character position of the span
706 If the return values @a from and @a to are the same, there is no selection.
708 virtual void GetSelection(long* from
, long* to
) const;
711 Returns the selection range in character positions. -1, -1 means no selection.
713 const wxRichTextRange
GetSelectionRange() const;
716 Returns the text within the current selection range, if any.
718 virtual wxString
GetStringSelection() const;
721 Gets the attributes at the given position.
722 This function gets the combined style - that is, the style you see on the
724 of combining base style, paragraph style and character style attributes. To get
726 or paragraph style alone, use GetUncombinedStyle().
728 virtual bool GetStyle(long position
, wxTextAttr
& style
);
731 Gets the attributes common to the specified range. Attributes that differ in
732 value within the range will
733 not be included in @e style's flags.
735 bool GetStyleForRange(const wxRichTextRange
& range
,
739 Returns the style sheet associated with the control, if any. A style sheet
741 character and paragraph styles to be applied.
743 wxRichTextStyleSheet
* GetStyleSheet() const;
746 Gets the attributes at the given position.
747 This function gets the @e uncombined style - that is, the attributes associated
749 paragraph or character content, and not necessarily the combined attributes you
751 screen. To get the combined attributes, use GetStyle().
752 If you specify (any) paragraph attribute in @e style's flags, this function
754 the paragraph attributes. Otherwise, it will return the character attributes.
756 virtual bool GetUncombinedStyle(long position
, wxTextAttr
& style
);
759 Returns the content of the entire control as a string.
761 virtual wxString
GetValue() const;
764 Internal helper function returning the line for the visible caret position. If
766 shown at the very end of the line, it means the next character is actually
767 on the following line. So this function gets the line we're expecting to find
770 wxRichTextLine
* GetVisibleLineForCaretPosition(long caretPosition
) const;
773 Test if this whole range has character attributes of the specified kind. If any
774 of the attributes are different within the range, the test fails. You
775 can use this to implement, for example, bold button updating. @a style must have
776 flags indicating which attributes are of interest.
778 bool HasCharacterAttributes(const wxRichTextRange
& range
,
779 const wxTextAttr
& style
) const;
782 Test if this whole range has paragraph attributes of the specified kind. If any
783 of the attributes are different within the range, the test fails. You
784 can use this to implement, for example, centering button updating. @a style
786 flags indicating which attributes are of interest.
788 bool HasParagraphAttributes(const wxRichTextRange
& range
,
789 const wxTextAttr
& style
) const;
792 Returns @true if there is a selection.
794 virtual bool HasSelection() const;
798 Finds the character at the given position in pixels.
799 @a pt is in device coords (not adjusted for the client area origin nor for
802 wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
, long* pos
) const;
803 const wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
805 wxTextCoord
* row
) const;
809 Initialises the members of the control.
814 Initialises the command event.
816 void InitCommandEvent(wxCommandEvent
& event
) const;
819 Returns @true if the user has recently set the default style without moving
821 and therefore the UI needs to reflect the default style and not the style at
823 Below is an example of code that uses this function to determine whether the UI
824 should show that the current style is bold.
826 See also SetAndShowDefaultStyle().
828 bool IsDefaultStyleShowing() const;
831 Returns @true if the control is editable.
833 virtual bool IsEditable() const;
836 Returns @true if Freeze has been called without a Thaw.
838 bool IsFrozen() const;
841 Returns @true if the buffer has been modified.
843 virtual bool IsModified() const;
846 Returns @true if the control is multiline.
848 bool IsMultiLine() const;
851 Returns @true if the given position is visible on the screen.
853 bool IsPositionVisible(long pos
) const;
856 Returns @true if all of the selection is aligned according to the specified
859 virtual bool IsSelectionAligned(wxTextAttrAlignment alignment
);
862 Returns @true if all of the selection is bold.
864 virtual bool IsSelectionBold();
867 Returns @true if all of the selection is italic.
869 virtual bool IsSelectionItalics();
872 Returns @true if all of the selection is underlined.
874 virtual bool IsSelectionUnderlined();
877 Returns @true if the control is single-line. Currently wxRichTextCtrl does not
878 support single-line editing.
880 bool IsSingleLine() const;
883 Helper function implementing keyboard navigation.
885 virtual bool KeyboardNavigate(int keyCode
, int flags
);
888 Lays out the buffer, which must be done before certain operations, such as
889 setting the caret position. This function should not normally be required by the
892 virtual bool LayoutContent(bool onlyVisibleRect
= false);
895 Inserts a line break at the current insertion point. A line break forces
896 wrapping within a paragraph, and
897 can be introduced by using this function, by appending the wxChar value @b
898 wxRichTextLineBreakChar to text content,
899 or by typing Shift-Return.
901 virtual bool LineBreak();
904 Loads content into the control's buffer using the given type. If the specified
906 is wxRICHTEXT_TYPE_ANY, the type is deduced from the filename extension.
907 This function looks for a suitable wxRichTextFileHandler object.
909 bool LoadFile(const wxString
& file
,
910 int type
= wxRICHTEXT_TYPE_ANY
);
913 Marks the buffer as modified.
915 virtual void MarkDirty();
918 Move the caret to the given character position.
920 virtual bool MoveCaret(long pos
, bool showAtLineStart
= false);
923 Move the caret one visual step forward: this may mean setting a flag
924 and keeping the same position if we're going from the end of one line
925 to the start of the next, which may be the exact same caret position.
927 void MoveCaretBack(long oldPosition
);
930 Move the caret one visual step forward: this may mean setting a flag
931 and keeping the same position if we're going from the end of one line
932 to the start of the next, which may be the exact same caret position.
934 void MoveCaretForward(long oldPosition
);
937 Moves the caret down.
939 virtual bool MoveDown(int noLines
= 1, int flags
= 0);
942 Moves to the end of the buffer.
944 virtual bool MoveEnd(int flags
= 0);
947 Moves to the start of the buffer.
949 virtual bool MoveHome(int flags
= 0);
954 virtual bool MoveLeft(int noPositions
= 1, int flags
= 0);
959 virtual bool MoveRight(int noPositions
= 1, int flags
= 0);
962 Moves to the end of the line.
964 virtual bool MoveToLineEnd(int flags
= 0);
967 Moves to the start of the line.
969 virtual bool MoveToLineStart(int flags
= 0);
972 Moves to the end of the paragraph.
974 virtual bool MoveToParagraphEnd(int flags
= 0);
977 Moves to the start of the paragraph.
979 virtual bool MoveToParagraphStart(int flags
= 0);
984 virtual bool MoveUp(int noLines
= 1, int flags
= 0);
987 Inserts a new paragraph at the current insertion point. See also LineBreak().
989 virtual bool Newline();
993 Numbers the paragraphs in the given range. Pass flags to determine how the
995 Either the style definition or the name of the style definition (in the current
996 sheet) can be passed.
997 @a flags is a bit list of the following:
998 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
999 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
1000 startFrom, otherwise existing attributes are used.
1001 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
1002 as the level for all paragraphs, otherwise the current indentation will be used.
1003 See also SetListStyle(), PromoteList(), ClearListStyle().
1005 bool NumberList(const wxRichTextRange
& range
,
1006 const wxRichTextListStyleDefinition
* style
,
1007 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1009 int listLevel
= -1);
1010 bool Number(const wxRichTextRange
& range
,
1011 const wxString
& styleName
,
1012 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1014 int listLevel
= -1);
1018 Standard handler for the wxID_CLEAR command.
1020 void OnClear(wxCommandEvent
& event
);
1023 Shows a standard context menu with undo, redo, cut, copy, paste, clear, and
1024 select all commands.
1026 void OnContextMenu(wxContextMenuEvent
& event
);
1029 Standard handler for the wxID_COPY command.
1031 void OnCopy(wxCommandEvent
& event
);
1034 Standard handler for the wxID_CUT command.
1036 void OnCut(wxCommandEvent
& event
);
1039 Loads the first dropped file.
1041 void OnDropFiles(wxDropFilesEvent
& event
);
1044 Standard handler for the wxID_PASTE command.
1046 void OnPaste(wxCommandEvent
& event
);
1049 Standard handler for the wxID_REDO command.
1051 void OnRedo(wxCommandEvent
& event
);
1054 Standard handler for the wxID_SELECTALL command.
1056 void OnSelectAll(wxCommandEvent
& event
);
1059 Standard handler for the wxID_PASTE command.
1061 void OnUndo(wxCommandEvent
& event
);
1064 Standard update handler for the wxID_CLEAR command.
1066 void OnUpdateClear(wxUpdateUIEvent
& event
);
1069 Standard update handler for the wxID_COPY command.
1071 void OnUpdateCopy(wxUpdateUIEvent
& event
);
1074 Standard update handler for the wxID_CUT command.
1076 void OnUpdateCut(wxUpdateUIEvent
& event
);
1079 Standard update handler for the wxID_PASTE command.
1081 void OnUpdatePaste(wxUpdateUIEvent
& event
);
1084 Standard update handler for the wxID_REDO command.
1086 void OnUpdateRedo(wxUpdateUIEvent
& event
);
1089 Standard update handler for the wxID_SELECTALL command.
1091 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
1094 Standard update handler for the wxID_UNDO command.
1096 void OnUpdateUndo(wxUpdateUIEvent
& event
);
1099 Moves one or more pages down.
1101 virtual bool PageDown(int noPages
= 1, int flags
= 0);
1104 Moves one or more pages up.
1106 virtual bool PageUp(int noPages
= 1, int flags
= 0);
1109 Paints the background.
1111 virtual void PaintBackground(wxDC
& dc
);
1114 Pastes content from the clipboard to the buffer.
1116 virtual void Paste();
1119 Internal function to position the visible caret according to the current caret
1122 virtual void PositionCaret();
1125 Converts a text position to zero-based column and line numbers.
1127 virtual bool PositionToXY(long pos
, long* x
, long* y
) const;
1131 Promotes or demotes the paragraphs in the given range. A positive @a promoteBy
1132 produces a smaller indent, and a negative number
1133 produces a larger indent. Pass flags to determine how the attributes are set.
1134 Either the style definition or the name of the style definition (in the current
1135 sheet) can be passed.
1136 @a flags is a bit list of the following:
1137 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
1138 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
1139 startFrom, otherwise existing attributes are used.
1140 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
1141 as the level for all paragraphs, otherwise the current indentation will be used.
1142 See also SetListStyle(), See also SetListStyle(), ClearListStyle().
1144 bool PromoteList(int promoteBy
, const wxRichTextRange
& range
,
1145 const wxRichTextListStyleDefinition
* style
,
1146 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1147 int listLevel
= -1);
1148 bool PromoteList(int promoteBy
, const wxRichTextRange
& range
,
1149 const wxString
& styleName
,
1150 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1151 int listLevel
= -1);
1155 Redoes the current command.
1157 virtual void Redo();
1160 Removes the content in the specified range.
1162 virtual void Remove(long from
, long to
);
1165 Replaces the content in the specified range with the string specified by @e
1168 virtual void Replace(long from
, long to
, const wxString
& value
);
1171 Saves the buffer content using the given type. If the specified type
1172 is wxRICHTEXT_TYPE_ANY, the type is deduced from the filename extension.
1173 This function looks for a suitable wxRichTextFileHandler object.
1175 bool SaveFile(const wxString
& file
= wxEmptyString
,
1176 int type
= wxRICHTEXT_TYPE_ANY
);
1179 Scrolls @a position into view. This function takes a caret position.
1181 virtual bool ScrollIntoView(long position
, int keyCode
);
1184 Selects all the text in the buffer.
1186 virtual void SelectAll();
1189 Cancels any selection.
1191 virtual void SelectNone();
1194 Sets @a attr as the default style and tells the control that the UI should
1196 this attribute until the user moves the caret.
1197 See also IsDefaultStyleShowing().
1199 void SetAndShowDefaultStyle(const wxTextAttr
& attr
);
1202 Sets the basic (overall) style. This is the style of the whole
1203 buffer before further styles are applied, unlike the default style, which
1204 only affects the style currently being applied (for example, setting the default
1205 style to bold will cause subsequently inserted text to be bold).
1207 virtual void SetBasicStyle(const wxTextAttr
& style
);
1210 The caret position is the character position just before the caret.
1211 A value of -1 means the caret is at the start of the buffer.
1213 void SetCaretPosition(long position
,
1214 bool showAtLineStart
= false);
1217 Sets the current default style, which can be used to change how subsequently
1221 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
1224 Sets the default style to the style under the cursor.
1226 bool SetDefaultStyleToCursorStyle();
1229 Sets the size of the buffer beyond which layout is delayed during resizing.
1230 This optimizes sizing for large buffers. The default is 20000.
1232 void SetDelayedLayoutThreshold(long threshold
);
1235 Makes the control editable, or not.
1237 virtual void SetEditable(bool editable
);
1240 Sets the current filename.
1242 void SetFilename(const wxString
& filename
);
1245 Sets the font, and also the basic and default attributes (see
1246 wxRichTextCtrl::SetDefaultStyle).
1248 virtual bool SetFont(const wxFont
& font
);
1251 Sets flags that change the behaviour of loading or saving. See the
1252 documentation for each
1253 handler class to see what flags are relevant for each handler.
1255 void SetHandlerFlags(int flags
);
1258 Sets the insertion point.
1260 virtual void SetInsertionPoint(long pos
);
1263 Sets the insertion point to the end of the text control.
1265 virtual void SetInsertionPointEnd();
1269 Sets the list attributes for the given range, passing flags to determine how
1270 the attributes are set.
1271 Either the style definition or the name of the style definition (in the current
1272 sheet) can be passed.
1273 @a flags is a bit list of the following:
1274 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
1275 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
1276 startFrom, otherwise existing attributes are used.
1277 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
1278 as the level for all paragraphs, otherwise the current indentation will be used.
1279 See also NumberList(), PromoteList(), ClearListStyle().
1281 bool SetListStyle(const wxRichTextRange
& range
,
1282 const wxRichTextListStyleDefinition
* style
,
1283 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1285 int listLevel
= -1);
1286 bool SetListStyle(const wxRichTextRange
& range
,
1287 const wxString
& styleName
,
1288 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1290 int listLevel
= -1);
1294 Sets the selection to the given range.
1295 The end point of range is specified as the last character position of the span
1297 So, for example, to set the selection for a character at position 5, use the
1300 virtual void SetSelection(long from
, long to
);
1303 Sets the selection to the given range.
1304 The end point of range is specified as the last character position of the span
1306 So, for example, to set the selection for a character at position 5, use the
1309 void SetSelectionRange(const wxRichTextRange
& range
);
1313 Sets the attributes for the given range.
1314 The end point of range is specified as the last character position of the span
1316 So, for example, to set the style for a character at position 5, use the range
1319 bool SetStyle(const wxRichTextRange
& range
,
1320 const wxTextAttr
& style
);
1321 bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
1326 Sets the attributes for the given range, passing flags to determine how the
1328 The end point of range is specified as the last character position of the span
1330 So, for example, to set the style for a character at position 5, use the range
1332 @a flags may contain a bit list of the following values:
1333 wxRICHTEXT_SETSTYLE_NONE: no style flag.
1334 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be
1336 wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied
1338 combined style at this point is already the style in question.
1339 wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be
1340 applied to paragraphs,
1341 and not the content. This allows content styling to be preserved independently
1342 from that of e.g. a named paragraph style.
1343 wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be
1344 applied to characters,
1345 and not the paragraph. This allows content styling to be preserved
1346 independently from that of e.g. a named paragraph style.
1347 wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying
1349 wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags
1350 are used in this operation.
1352 bool SetStyleEx(const wxRichTextRange
& range
,
1353 const wxTextAttr
& style
,
1354 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1355 bool SetStyleEx(long start
, long end
,
1356 const wxTextAttr
& style
,
1357 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1361 Sets the style sheet associated with the control. A style sheet allows named
1362 character and paragraph styles to be applied.
1364 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1367 Replaces existing content with the given text.
1369 void SetValue(const wxString
& value
);
1372 A helper function setting up scrollbars, for example after a resize.
1374 virtual void SetupScrollbars(bool atTop
= false);
1377 Scrolls the buffer so that the given position is in view.
1379 virtual void ShowPosition(long pos
);
1382 Returns @true if undo history suppression is on.
1384 virtual bool SuppressingUndo() const;
1387 Call this function to end a Freeze and refresh the display.
1392 Undoes the command at the top of the command history, if there is one.
1394 virtual void Undo();
1397 Moves a number of words to the left.
1399 virtual bool WordLeft(int noWords
= 1, int flags
= 0);
1402 Move a nuber of words to the right.
1404 virtual bool WordRight(int noWords
= 1, int flags
= 0);
1408 Write a bitmap or image at the current insertion point. Supply an optional type
1410 for internal and file storage of the raw data.
1412 bool WriteImage(const wxString
& filename
, int bitmapType
);
1413 bool WriteImage(const wxRichTextImageBlock
& imageBlock
);
1414 bool WriteImage(const wxBitmap
& bitmap
,
1415 int bitmapType
= wxBITMAP_TYPE_PNG
);
1416 bool WriteImage(const wxImage
& image
,
1417 int bitmapType
= wxBITMAP_TYPE_PNG
);
1421 Writes text at the current position.
1423 virtual void WriteText(const wxString
& text
);
1426 Translates from column and line number to position.
1428 virtual long XYToPosition(long x
, long y
) const;