1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextctrl.h
3 // Purpose: documentation for wxRichTextEvent class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxRichTextEvent
11 @headerfile richtextctrl.h wx/richtext/richtextctrl.h
13 This is the event class for wxRichTextCtrl notifications.
18 class wxRichTextEvent
: public wxNotifyEvent
25 wxRichTextEvent(const wxRichTextEvent
& event
);
26 wxRichTextEvent(wxEventType commandType
= wxEVT_@NULL
,
36 Returns the character pressed, within a wxEVT_COMMAND_RICHTEXT_CHARACTER event.
38 wxChar
GetCharacter();
41 Returns flags indicating modifier keys pressed. Possible values are
43 wxRICHTEXT_SHIFT_DOWN, and wxRICHTEXT_ALT_DOWN.
48 Returns the new style sheet. Can be used in a
49 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or
50 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler.
52 wxRichTextStyleSheet
* GetNewStyleSheet();
55 Returns the old style sheet. Can be used in a
56 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or
57 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler.
59 wxRichTextStyleSheet
* GetOldStyleSheet();
62 Returns the buffer position at which the event occured.
67 Gets the range for the current operation.
69 wxRichTextRange
GetRange();
72 Sets the character variable.
74 void SetCharacter(wxChar ch
);
77 Sets flags indicating modifier keys pressed. Possible values are
79 wxRICHTEXT_SHIFT_DOWN, and wxRICHTEXT_ALT_DOWN.
81 void SetFlags(int flags
);
84 Sets the new style sheet variable.
86 void SetNewStyleSheet(wxRichTextStyleSheet
* sheet
);
89 Sets the old style sheet variable.
91 void SetOldStyleSheet(wxRichTextStyleSheet
* sheet
);
94 Sets the buffer position variable.
96 void SetPosition(long pos
);
99 Sets the range variable.
101 void SetRange(const wxRichTextRange
& range
);
106 @class wxRichTextCtrl
107 @headerfile richtextctrl.h wx/richtext/richtextctrl.h
109 wxRichTextCtrl provides a generic, ground-up implementation of a text control
110 capable of showing multiple styles and images.
112 wxRichTextCtrl sends notification events: see wxRichTextEvent.
113 It also sends the standard wxTextCtrl events wxEVT_COMMAND_TEXT_ENTER and
114 wxEVT_COMMAND_TEXT_UPDATED,
115 and wxTextUrlEvent when URL content is clicked.
117 For more information, see the @ref overview_wxrichtextctrloverview
118 "wxRichTextCtrl overview".
122 @appearance{richtextctrl.png}
132 wxRichTextCtrl(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
133 const wxString
& value
= wxEmptyString
,
134 const wxPoint
& pos
= wxDefaultPosition
,
135 const wxSize
& size
= wxDefaultSize
,
136 long style
= wxRE_MULTILINE
,
137 const wxValidator
& validator
= wxDefaultValidator
,
138 const wxString
& name
= wxTextCtrlNameStr
);
147 Adds an image to the control's buffer.
149 wxRichTextRange
AddImage(const wxImage
& image
);
152 Adds a new paragraph of text to the end of the buffer.
154 wxRichTextRange
AddParagraph(const wxString
& text
);
157 Sets the insertion point to the end of the buffer and writes the text.
159 void AppendText(const wxString
& text
);
162 Applies the given alignment to the selection (undoable).
164 For alignment values, see wxTextAttr.
166 bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment
);
169 Apples bold to the selection (undoable).
171 bool ApplyBoldToSelection();
174 Applies italic to the selection (undoable).
176 bool ApplyItalicToSelection();
179 Applies the given style to the selection.
181 bool ApplyStyle(wxRichTextStyleDefinition
* def
);
184 Applies the style sheet to the buffer, matching paragraph styles in the sheet
186 in the buffer. This might be useful if the styles have changed. If @e sheet is
188 sheet set with SetStyleSheet is used.
190 Currently this applies paragraph styles only.
192 bool ApplyStyleSheet(wxRichTextStyleSheet
* sheet
= @NULL
);
195 Applies underline to the selection (undoable).
197 bool ApplyUnderlineToSelection();
200 Returns @true if undo commands are being batched.
205 Begins using alignment
207 For alignment values, see wxTextAttr.
209 bool BeginAlignment(wxTextAttrAlignment alignment
);
212 Starts batching undo history for commands.
214 bool BeginBatchUndo(const wxString
& cmdName
);
222 Begins using the named character style.
224 bool BeginCharacterStyle(const wxString
& characterStyle
);
227 Begins using this font.
229 bool BeginFont(const wxFont
& font
);
232 Begins using the given point size.
234 bool BeginFontSize(int pointSize
);
242 Begins applying a left indent and subindent in tenths of a millimetre.
244 The sub-indent is an offset from the left of the paragraph, and is used for all
246 first line in a paragraph. A positive value will cause the first line to appear
248 of the subsequent lines, and a negative value will cause the first line to be
250 relative to the subsequent lines.
252 wxRichTextBuffer uses indentation to render a bulleted item. The left indent is
254 the margin and the bullet. The content of the paragraph, including the first
256 at leftMargin + leftSubIndent. So the distance between the left edge of the
258 left of the actual paragraph is leftSubIndent.
260 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
263 Begins appling line spacing. @e spacing is a multiple, where 10 means
265 15 means 1.5 spacing, and 20 means double spacing. The following constants are
266 defined for convenience:
268 bool BeginLineSpacing(int lineSpacing
);
271 Begins using a specified list style. Optionally, you can also pass a level and
274 bool BeginListStyle(const wxString
& listStyle
, int level
=1,
278 Begins a numbered bullet. This call will be needed for each item in the list,
280 application should take care of incrementing the numbering.
282 @e bulletNumber is a number, usually starting with 1.
284 @e leftIndent and @e leftSubIndent are values in tenths of a millimetre.
286 @e bulletStyle is a bitlist of the following values:
289 wxRichTextBuffer uses indentation to render a bulleted item. The left indent is
291 the margin and the bullet. The content of the paragraph, including the first
293 at leftMargin + leftSubIndent. So the distance between the left edge of the
295 left of the actual paragraph is leftSubIndent.
297 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
,
299 int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
302 Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing
306 bool BeginParagraphSpacing(int before
, int after
);
309 Begins applying the named paragraph style.
311 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
314 Begins a right indent, specified in tenths of a millimetre.
316 bool BeginRightIndent(int rightIndent
);
319 Begins applying a style.
321 bool BeginStyle(const wxTextAttr
& style
);
324 Starts suppressing undo history for commands.
326 bool BeginSuppressUndo();
329 Begins applying a symbol bullet, using a character from the current font. See
330 BeginNumberedBullet() for
331 an explanation of how indentation is used to render the bulleted paragraph.
333 bool BeginSymbolBullet(wxChar symbol
, int leftIndent
,
335 int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
338 Begins using this colour.
340 bool BeginTextColour(const wxColour
& colour
);
343 Begins applying wxTEXT_ATTR_URL to the content. Pass a URL and optionally, a
344 character style to apply,
345 since it is common to mark a URL with a familiar style such as blue text with
348 bool BeginURL(const wxString
& url
,
349 const wxString
& characterStyle
= wxEmptyString
);
352 Begins using underlining.
354 bool BeginUnderline();
357 Returns @true if selected content can be copied to the clipboard.
362 Returns @true if selected content can be copied to the clipboard and deleted.
367 Returns @true if selected content can be deleted.
369 bool CanDeleteSelection();
372 Returns @true if the clipboard content can be pasted to the buffer.
377 Returns @true if there is a command in the command history that can be redone.
382 Returns @true if there is a command in the command history that can be undone.
387 Clears the buffer content, leaving a single empty paragraph. Cannot be undone.
393 Clears the list style from the given range, clearing list-related attributes
394 and applying any named paragraph style associated with each paragraph.
396 @e flags is a bit list of the following:
398 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
400 See also SetListStyle(), PromoteList(), NumberList().
402 bool ClearListStyle(const wxRichTextRange
& range
,
403 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
404 bool ClearListStyle(const wxRichTextRange
& range
,
405 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
409 Sends the event to the control.
411 void Command(wxCommandEvent
& event
);
414 Copies the selected content (if any) to the clipboard.
419 Creates the underlying window.
421 bool Create(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
422 const wxString
& value
= wxEmptyString
,
423 const wxPoint
& pos
= wxDefaultPosition
,
424 const wxSize
& size
= wxDefaultSize
,
425 long style
= wxRE_MULTILINE
,
426 const wxValidator
& validator
= wxDefaultValidator
,
427 const wxString
& name
= wxTextCtrlNameStr
);
430 Copies the selected content (if any) to the clipboard and deletes the selection.
433 #define void Cut() /* implementation is private */
436 Deletes the content within the given range.
438 bool Delete(const wxRichTextRange
& range
);
441 Deletes content if there is a selection, e.g. when pressing a key.
442 Returns the new caret position in @e newPos, or leaves it if there
443 was no action. This is undoable.
445 bool DeleteSelectedContent(long* newPos
= @NULL
);
448 Deletes the content in the selection, if any. This is undoable.
450 void DeleteSelection();
453 Sets the buffer's modified status to @false, and clears the buffer's command
459 Currently this simply returns @c wxSize(10, 10).
461 wxSize
DoGetBestSize();
469 Ends application of all styles in the current style stack.
474 Ends batching undo command history.
484 Ends application of a named character style.
486 bool EndCharacterStyle();
494 Ends using a point size.
506 bool EndLeftIndent();
511 bool EndLineSpacing();
514 Ends using a specified list style.
519 Ends application of a numbered bullet.
521 bool EndNumberedBullet();
524 Ends paragraph spacing.
526 bool EndParagraphSpacing();
529 Ends application of a named character style.
531 bool EndParagraphStyle();
536 bool EndRightIndent();
539 Ends the current style.
544 Ends suppressing undo command history.
546 bool EndSuppressUndo();
549 Ends applying a symbol bullet.
551 bool EndSymbolBullet();
554 Ends applying a text colour.
556 bool EndTextColour();
561 #define bool EndURL() /* implementation is private */
564 End applying underlining.
569 Helper function for extending the selection, returning @true if the selection
571 changed. Selections are in caret positions.
573 bool ExtendSelection(long oldPosition
, long newPosition
,
577 Helper function for finding the caret position for the next word. Direction
578 is 1 (forward) or -1 (backwards).
580 long FindNextWordPosition(int direction
= 1);
583 Call this function to prevent refresh and allow fast updates, and then Thaw() to
589 Gets the basic (overall) style. This is the style of the whole
590 buffer before further styles are applied, unlike the default style, which
591 only affects the style currently being applied (for example, setting the default
592 style to bold will cause subsequently inserted text to be bold).
594 const wxTextAttr
GetBasicStyle();
598 Returns the buffer associated with the control.
600 const wxRichTextBuffer
GetBuffer();
601 wxRichTextBuffer
GetBuffer();
605 Returns the current caret position.
607 long GetCaretPosition();
610 Returns the caret height and position for the given character position
612 bool GetCaretPositionForIndex(long position
, wxRect
& rect
);
615 Gets the command processor associated with the control's buffer.
617 wxCommandProcessor
* GetCommandProcessor();
620 Returns the current default style, which can be used to change how subsequently
624 const wxTextAttr
GetDefaultStyle();
627 Gets the size of the buffer beyond which layout is delayed during resizing.
628 This optimizes sizing for large buffers. The default is 20000.
630 long GetDelayedLayoutThreshold();
633 Gets the current filename associated with the control.
635 wxString
GetFilename();
638 Returns the first visible position in the current view.
640 long GetFirstVisiblePosition();
643 Returns flags that change the behaviour of loading or saving. See the
644 documentation for each
645 handler class to see what flags are relevant for each handler.
647 int GetHandlerFlags();
650 Returns the current insertion point.
652 long GetInsertionPoint();
655 Returns the last position in the buffer.
657 wxTextPos
GetLastPosition();
660 Returns the length of the specified line in characters.
662 int GetLineLength(long lineNo
);
665 Returns the text for the given line.
667 wxString
GetLineText(long lineNo
);
670 Transforms physical window position to logical (unscrolled) position.
672 wxPoint
GetLogicalPoint(const wxPoint
& ptPhysical
);
675 Returns the number of lines in the buffer.
677 int GetNumberOfLines();
680 Transforms logical (unscrolled) position to physical window position.
682 wxPoint
GetPhysicalPoint(const wxPoint
& ptLogical
);
685 Gets the text for the given range.
687 The end point of range is specified as the last character position of the span
690 wxString
GetRange(long from
, long to
);
693 Returns the range of the current selection.
695 The end point of range is specified as the last character position of the span
698 If the return values @e from and @e to are the same, there is no selection.
700 void GetSelection(long* from
, long* to
);
703 Returns the selection range in character positions. -1, -1 means no selection.
705 const wxRichTextRange
GetSelectionRange();
708 Returns the text within the current selection range, if any.
710 wxString
GetStringSelection();
713 Gets the attributes at the given position.
715 This function gets the combined style - that is, the style you see on the
717 of combining base style, paragraph style and character style attributes. To get
719 or paragraph style alone, use GetUncombinedStyle().
721 bool GetStyle(long position
, wxTextAttr
& style
);
724 Gets the attributes common to the specified range. Attributes that differ in
725 value within the range will
726 not be included in @e style's flags.
728 bool GetStyleForRange(const wxRichTextRange
& range
,
732 Returns the style sheet associated with the control, if any. A style sheet
734 character and paragraph styles to be applied.
736 wxRichTextStyleSheet
* GetStyleSheet();
739 Gets the attributes at the given position.
741 This function gets the @e uncombined style - that is, the attributes associated
743 paragraph or character content, and not necessarily the combined attributes you
745 screen. To get the combined attributes, use GetStyle().
747 If you specify (any) paragraph attribute in @e style's flags, this function
749 the paragraph attributes. Otherwise, it will return the character attributes.
751 bool GetUncombinedStyle(long position
, wxTextAttr
& style
);
754 Returns the content of the entire control as a string.
759 Internal helper function returning the line for the visible caret position. If
761 shown at the very end of the line, it means the next character is actually
762 on the following line. So this function gets the line we're expecting to find
765 wxRichTextLine
* GetVisibleLineForCaretPosition(long caretPosition
);
768 Test if this whole range has character attributes of the specified kind. If any
769 of the attributes are different within the range, the test fails. You
770 can use this to implement, for example, bold button updating. @e style must have
771 flags indicating which attributes are of interest.
773 bool HasCharacterAttributes(const wxRichTextRange
& range
,
774 const wxTextAttr
& style
);
777 Test if this whole range has paragraph attributes of the specified kind. If any
778 of the attributes are different within the range, the test fails. You
779 can use this to implement, for example, centering button updating. @e style
781 flags indicating which attributes are of interest.
783 bool HasParagraphAttributes(const wxRichTextRange
& range
,
784 const wxTextAttr
& style
);
787 Returns @true if there is a selection.
793 Finds the character at the given position in pixels.
795 @e pt is in device coords (not adjusted for the client area origin nor for
798 wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
, long* pos
);
799 wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
805 Initialises the members of the control.
810 Initialises the command event.
812 void InitCommandEvent(wxCommandEvent
& event
);
815 Returns @true if the user has recently set the default style without moving
817 and therefore the UI needs to reflect the default style and not the style at
820 Below is an example of code that uses this function to determine whether the UI
821 should show that the current style is bold.
822 See also SetAndShowDefaultStyle().
824 bool IsDefaultStyleShowing();
827 Returns @true if the control is editable.
832 Returns @true if Freeze has been called without a Thaw.
837 Returns @true if the buffer has been modified.
842 Returns @true if the control is multiline.
847 Returns @true if the given position is visible on the screen.
849 bool IsPositionVisible(long pos
);
852 Returns @true if all of the selection is aligned according to the specified
855 bool IsSelectionAligned(wxTextAttrAlignment alignment
);
858 Returns @true if all of the selection is bold.
860 bool IsSelectionBold();
863 Returns @true if all of the selection is italic.
865 bool IsSelectionItalics();
868 Returns @true if all of the selection is underlined.
870 bool IsSelectionUnderlined();
873 Returns @true if the control is single-line. Currently wxRichTextCtrl does not
874 support single-line editing.
879 Helper function implementing keyboard navigation.
881 bool KeyboardNavigate(int keyCode
, int flags
);
884 Lays out the buffer, which must be done before certain operations, such as
885 setting the caret position. This function should not normally be required by the
888 bool LayoutContent(bool onlyVisibleRect
= @
false);
891 Inserts a line break at the current insertion point. A line break forces
892 wrapping within a paragraph, and
893 can be introduced by using this function, by appending the wxChar value @b
894 wxRichTextLineBreakChar to text content,
895 or by typing Shift-Return.
900 Loads content into the control's buffer using the given type. If the specified
902 is wxRICHTEXT_TYPE_ANY, the type is deduced from the filename extension.
904 This function looks for a suitable wxRichTextFileHandler object.
906 bool LoadFile(const wxString
& file
,
907 int type
= wxRICHTEXT_TYPE_ANY
);
910 Marks the buffer as modified.
915 Move the caret to the given character position.
917 bool MoveCaret(long pos
, bool showAtLineStart
= @
false);
920 Move the caret one visual step forward: this may mean setting a flag
921 and keeping the same position if we're going from the end of one line
922 to the start of the next, which may be the exact same caret position.
924 void MoveCaretBack(long oldPosition
);
927 Move the caret one visual step forward: this may mean setting a flag
928 and keeping the same position if we're going from the end of one line
929 to the start of the next, which may be the exact same caret position.
931 void MoveCaretForward(long oldPosition
);
934 Moves the caret down.
936 bool MoveDown(int noLines
= 1, int flags
= 0);
939 Moves to the end of the buffer.
941 bool MoveEnd(int flags
= 0);
944 Moves to the start of the buffer.
946 bool MoveHome(int flags
= 0);
951 bool MoveLeft(int noPositions
= 1, int flags
= 0);
956 bool MoveRight(int noPositions
= 1, int flags
= 0);
959 Moves to the end of the line.
961 bool MoveToLineEnd(int flags
= 0);
964 Moves to the start of the line.
966 bool MoveToLineStart(int flags
= 0);
969 Moves to the end of the paragraph.
971 bool MoveToParagraphEnd(int flags
= 0);
974 Moves to the start of the paragraph.
976 bool MoveToParagraphStart(int flags
= 0);
981 bool MoveUp(int noLines
= 1, int flags
= 0);
984 Inserts a new paragraph at the current insertion point. See also LineBreak().
990 Numbers the paragraphs in the given range. Pass flags to determine how the
992 Either the style definition or the name of the style definition (in the current
993 sheet) can be passed.
995 @e flags is a bit list of the following:
997 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
998 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
999 startFrom, otherwise existing attributes are used.
1000 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @e listLevel should be used
1001 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 bool PageDown(int noPages
= 1, int flags
= 0);
1104 Moves one or more pages up.
1106 bool PageUp(int noPages
= 1, int flags
= 0);
1109 Paints the background.
1111 void PaintBackground(wxDC
& dc
);
1114 Pastes content from the clipboard to the buffer.
1119 Internal function to position the visible caret according to the current caret
1122 void PositionCaret();
1125 Converts a text position to zero-based column and line numbers.
1127 bool PositionToXY(long pos
, long* x
, long* y
);
1131 Promotes or demotes the paragraphs in the given range. A positive @e 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.
1137 @e flags is a bit list of the following:
1139 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
1140 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
1141 startFrom, otherwise existing attributes are used.
1142 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @e listLevel should be used
1143 as the level for all paragraphs, otherwise the current indentation will be used.
1145 See also SetListStyle(), See also SetListStyle(), ClearListStyle().
1147 bool PromoteList(int promoteBy
, const wxRichTextRange
& range
,
1148 const wxRichTextListStyleDefinition
* style
,
1149 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1150 int listLevel
= -1);
1151 bool PromoteList(int promoteBy
, const wxRichTextRange
& range
,
1152 const wxString
& styleName
,
1153 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1154 int listLevel
= -1);
1158 Redoes the current command.
1163 Removes the content in the specified range.
1165 void Remove(long from
, long to
);
1168 Replaces the content in the specified range with the string specified by @e
1171 void Replace(long from
, long to
, const wxString
& value
);
1174 Saves the buffer content using the given type. If the specified type
1175 is wxRICHTEXT_TYPE_ANY, the type is deduced from the filename extension.
1177 This function looks for a suitable wxRichTextFileHandler object.
1179 bool SaveFile(const wxString
& file
= wxEmptyString
,
1180 int type
= wxRICHTEXT_TYPE_ANY
);
1183 Scrolls @e position into view. This function takes a caret position.
1185 bool ScrollIntoView(long position
, int keyCode
);
1188 Selects all the text in the buffer.
1193 Cancels any selection.
1198 Sets @e attr as the default style and tells the control that the UI should
1200 this attribute until the user moves the caret.
1202 See also IsDefaultStyleShowing().
1204 void SetAndShowDefaultStyle(const wxTextAttr
& attr
);
1207 Sets the basic (overall) style. This is the style of the whole
1208 buffer before further styles are applied, unlike the default style, which
1209 only affects the style currently being applied (for example, setting the default
1210 style to bold will cause subsequently inserted text to be bold).
1212 void SetBasicStyle(const wxTextAttr
& style
);
1215 The caret position is the character position just before the caret.
1216 A value of -1 means the caret is at the start of the buffer.
1218 void SetCaretPosition(long position
,
1219 bool showAtLineStart
= @
false);
1222 Sets the current default style, which can be used to change how subsequently
1226 bool SetDefaultStyle(const wxTextAttr
& style
);
1229 Sets the default style to the style under the cursor.
1231 bool SetDefaultStyleToCursorStyle();
1234 Sets the size of the buffer beyond which layout is delayed during resizing.
1235 This optimizes sizing for large buffers. The default is 20000.
1237 void SetDelayedLayoutThreshold(long threshold
);
1240 Makes the control editable, or not.
1242 void SetEditable(bool editable
);
1245 Sets the current filename.
1247 void SetFilename(const wxString
& filename
);
1250 Sets the font, and also the basic and default attributes (see
1251 wxRichTextCtrl::SetDefaultStyle).
1253 bool SetFont(const wxFont
& font
);
1256 Sets flags that change the behaviour of loading or saving. See the
1257 documentation for each
1258 handler class to see what flags are relevant for each handler.
1260 void SetHandlerFlags(int flags
);
1263 Sets the insertion point.
1265 void SetInsertionPoint(long pos
);
1268 Sets the insertion point to the end of the text control.
1270 void SetInsertionPointEnd();
1274 Sets the list attributes for the given range, passing flags to determine how
1275 the attributes are set.
1276 Either the style definition or the name of the style definition (in the current
1277 sheet) can be passed.
1279 @e flags is a bit list of the following:
1281 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
1282 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
1283 startFrom, otherwise existing attributes are used.
1284 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @e listLevel should be used
1285 as the level for all paragraphs, otherwise the current indentation will be used.
1287 See also NumberList(), PromoteList(), ClearListStyle().
1289 bool SetListStyle(const wxRichTextRange
& range
,
1290 const wxRichTextListStyleDefinition
* style
,
1291 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1293 int listLevel
= -1);
1294 bool SetListStyle(const wxRichTextRange
& range
,
1295 const wxString
& styleName
,
1296 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1298 int listLevel
= -1);
1302 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 SetSelection(long from
, long to
);
1312 Sets the selection to 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 selection for a character at position 5, use the
1319 void SetSelectionRange(const wxRichTextRange
& range
);
1323 Sets the attributes for the given range.
1325 The end point of range is specified as the last character position of the span
1327 So, for example, to set the style for a character at position 5, use the range
1330 bool SetStyle(const wxRichTextRange
& range
,
1331 const wxTextAttr
& style
);
1332 bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
1337 Sets the attributes for the given range, passing flags to determine how the
1340 The end point of range is specified as the last character position of the span
1342 So, for example, to set the style for a character at position 5, use the range
1345 @e flags may contain a bit list of the following values:
1347 wxRICHTEXT_SETSTYLE_NONE: no style flag.
1348 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be
1350 wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied
1352 combined style at this point is already the style in question.
1353 wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be
1354 applied to paragraphs,
1355 and not the content. This allows content styling to be preserved independently
1356 from that of e.g. a named paragraph style.
1357 wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be
1358 applied to characters,
1359 and not the paragraph. This allows content styling to be preserved
1360 independently from that of e.g. a named paragraph style.
1361 wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying
1363 wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags
1364 are used in this operation.
1366 bool SetStyleEx(const wxRichTextRange
& range
,
1367 const wxTextAttr
& style
,
1368 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1369 bool SetStyleEx(long start
, long end
,
1370 const wxTextAttr
& style
,
1371 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1375 Sets the style sheet associated with the control. A style sheet allows named
1376 character and paragraph styles to be applied.
1378 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1381 Replaces existing content with the given text.
1383 void SetValue(const wxString
& value
);
1386 A helper function setting up scrollbars, for example after a resize.
1388 void SetupScrollbars(bool atTop
= @
false);
1391 Scrolls the buffer so that the given position is in view.
1393 void ShowPosition(long pos
);
1396 Returns @true if undo history suppression is on.
1398 bool SuppressingUndo();
1401 Call this function to end a Freeze and refresh the display.
1406 Undoes the command at the top of the command history, if there is one.
1411 Moves a number of words to the left.
1413 bool WordLeft(int noWords
= 1, int flags
= 0);
1416 Move a nuber of words to the right.
1418 bool WordRight(int noWords
= 1, int flags
= 0);
1422 Write a bitmap or image at the current insertion point. Supply an optional type
1424 for internal and file storage of the raw data.
1426 bool WriteImage(const wxString
& filename
, int bitmapType
);
1427 bool WriteImage(const wxRichTextImageBlock
& imageBlock
);
1428 bool WriteImage(const wxBitmap
& bitmap
,
1429 int bitmapType
= wxBITMAP_TYPE_PNG
);
1430 bool WriteImage(const wxImage
& image
,
1431 int bitmapType
= wxBITMAP_TYPE_PNG
);
1435 Writes text at the current position.
1437 void WriteText(const wxString
& text
);
1440 Translates from column and line number to position.
1442 long XYToPosition(long x
, long y
);