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
24 wxRichTextEvent(const wxRichTextEvent
& event
);
25 wxRichTextEvent(wxEventType commandType
= wxEVT_NULL
,
32 wxEvent
* Clone() const;
35 Returns the character pressed, within a wxEVT_COMMAND_RICHTEXT_CHARACTER event.
37 wxChar
GetCharacter() const;
40 Returns flags indicating modifier keys pressed. Possible values are
42 wxRICHTEXT_SHIFT_DOWN, and wxRICHTEXT_ALT_DOWN.
47 Returns the new style sheet. Can be used in a
48 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or
49 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler.
51 wxRichTextStyleSheet
* GetNewStyleSheet() const;
54 Returns the old style sheet. Can be used in a
55 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING or
56 wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGED event handler.
58 wxRichTextStyleSheet
* GetOldStyleSheet() const;
61 Returns the buffer position at which the event occured.
63 long GetPosition() const;
66 Gets the range for the current operation.
68 wxRichTextRange
GetRange() const;
71 Sets the character variable.
73 void SetCharacter(wxChar ch
);
76 Sets flags indicating modifier keys pressed. Possible values are
78 wxRICHTEXT_SHIFT_DOWN, and wxRICHTEXT_ALT_DOWN.
80 void SetFlags(int flags
);
83 Sets the new style sheet variable.
85 void SetNewStyleSheet(wxRichTextStyleSheet
* sheet
);
88 Sets the old style sheet variable.
90 void SetOldStyleSheet(wxRichTextStyleSheet
* sheet
);
93 Sets the buffer position variable.
95 void SetPosition(long pos
);
98 Sets the range variable.
100 void SetRange(const wxRichTextRange
& range
);
106 @class wxRichTextCtrl
108 wxRichTextCtrl provides a generic, ground-up implementation of a text control
109 capable of showing multiple styles and images.
111 wxRichTextCtrl sends notification events: see wxRichTextEvent.
112 It also sends the standard wxTextCtrl events wxEVT_COMMAND_TEXT_ENTER and
113 wxEVT_COMMAND_TEXT_UPDATED,
114 and wxTextUrlEvent when URL content is clicked.
116 For more information, see the @ref overview_wxrichtextctrloverview
117 "wxRichTextCtrl overview".
130 wxRichTextCtrl(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
131 const wxString
& value
= wxEmptyString
,
132 const wxPoint
& pos
= wxDefaultPosition
,
133 const wxSize
& size
= wxDefaultSize
,
134 long style
= wxRE_MULTILINE
,
135 const wxValidator
& validator
= wxDefaultValidator
,
136 const wxString
& name
= wxTextCtrlNameStr
);
145 Adds an image to the control's buffer.
147 wxRichTextRange
AddImage(const wxImage
& image
);
150 Adds a new paragraph of text to the end of the buffer.
152 wxRichTextRange
AddParagraph(const wxString
& text
);
155 Sets the insertion point to the end of the buffer and writes the text.
157 void AppendText(const wxString
& text
);
160 Applies the given alignment to the selection (undoable).
161 For alignment values, see wxTextAttr.
163 bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment
);
166 Apples bold to the selection (undoable).
168 bool ApplyBoldToSelection();
171 Applies italic to the selection (undoable).
173 bool ApplyItalicToSelection();
176 Applies the given style to the selection.
178 bool ApplyStyle(wxRichTextStyleDefinition
* def
);
181 Applies the style sheet to the buffer, matching paragraph styles in the sheet
183 in the buffer. This might be useful if the styles have changed. If @a sheet is
185 sheet set with SetStyleSheet is used.
186 Currently this applies paragraph styles only.
188 bool ApplyStyleSheet(wxRichTextStyleSheet
* sheet
= NULL
);
191 Applies underline to the selection (undoable).
193 bool ApplyUnderlineToSelection();
196 Returns @true if undo commands are being batched.
198 bool BatchingUndo() const;
201 Begins using alignment
202 For alignment values, see wxTextAttr.
204 bool BeginAlignment(wxTextAttrAlignment alignment
);
207 Starts batching undo history for commands.
209 bool BeginBatchUndo(const wxString
& cmdName
);
217 Begins using the named character style.
219 bool BeginCharacterStyle(const wxString
& characterStyle
);
222 Begins using this font.
224 bool BeginFont(const wxFont
& font
);
227 Begins using the given point size.
229 bool BeginFontSize(int pointSize
);
237 Begins applying a left indent and subindent in tenths of a millimetre.
238 The sub-indent is an offset from the left of the paragraph, and is used for all
240 first line in a paragraph. A positive value will cause the first line to appear
242 of the subsequent lines, and a negative value will cause the first line to be
244 relative to the subsequent lines.
245 wxRichTextBuffer uses indentation to render a bulleted item. The left indent is
247 the margin and the bullet. The content of the paragraph, including the first
249 at leftMargin + leftSubIndent. So the distance between the left edge of the
251 left of the actual paragraph is leftSubIndent.
253 bool BeginLeftIndent(int leftIndent
, int leftSubIndent
= 0);
256 Begins appling line spacing. @e spacing is a multiple, where 10 means
258 15 means 1.5 spacing, and 20 means double spacing. The following constants are
259 defined for convenience:
261 bool BeginLineSpacing(int lineSpacing
);
264 Begins using a specified list style. Optionally, you can also pass a level and
267 bool BeginListStyle(const wxString
& listStyle
, int level
= 1,
271 Begins a numbered bullet. This call will be needed for each item in the list,
273 application should take care of incrementing the numbering.
274 @a bulletNumber is a number, usually starting with 1.
275 @a leftIndent and @a leftSubIndent are values in tenths of a millimetre.
276 @a bulletStyle is a bitlist of the following values:
278 wxRichTextBuffer uses indentation to render a bulleted item. The left indent is
280 the margin and the bullet. The content of the paragraph, including the first
282 at leftMargin + leftSubIndent. So the distance between the left edge of the
284 left of the actual paragraph is leftSubIndent.
286 bool BeginNumberedBullet(int bulletNumber
, int leftIndent
,
288 int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_ARABIC
|wxTEXT_ATTR_BULLET_STYLE_PERIOD
);
291 Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing
295 bool BeginParagraphSpacing(int before
, int after
);
298 Begins applying the named paragraph style.
300 bool BeginParagraphStyle(const wxString
& paragraphStyle
);
303 Begins a right indent, specified in tenths of a millimetre.
305 bool BeginRightIndent(int rightIndent
);
308 Begins applying a style.
310 bool BeginStyle(const wxTextAttr
& style
);
313 Starts suppressing undo history for commands.
315 bool BeginSuppressUndo();
318 Begins applying a symbol bullet, using a character from the current font. See
319 BeginNumberedBullet() for
320 an explanation of how indentation is used to render the bulleted paragraph.
322 bool BeginSymbolBullet(wxChar symbol
, int leftIndent
,
324 int bulletStyle
= wxTEXT_ATTR_BULLET_STYLE_SYMBOL
);
327 Begins using this colour.
329 bool BeginTextColour(const wxColour
& colour
);
332 Begins applying wxTEXT_ATTR_URL to the content. Pass a URL and optionally, a
333 character style to apply,
334 since it is common to mark a URL with a familiar style such as blue text with
337 bool BeginURL(const wxString
& url
,
338 const wxString
& characterStyle
= wxEmptyString
);
341 Begins using underlining.
343 bool BeginUnderline();
346 Returns @true if selected content can be copied to the clipboard.
348 bool CanCopy() const;
351 Returns @true if selected content can be copied to the clipboard and deleted.
356 Returns @true if selected content can be deleted.
358 bool CanDeleteSelection() const;
361 Returns @true if the clipboard content can be pasted to the buffer.
363 bool CanPaste() const;
366 Returns @true if there is a command in the command history that can be redone.
368 bool CanRedo() const;
371 Returns @true if there is a command in the command history that can be undone.
373 bool CanUndo() const;
376 Clears the buffer content, leaving a single empty paragraph. Cannot be undone.
382 Clears the list style from the given range, clearing list-related attributes
383 and applying any named paragraph style associated with each paragraph.
384 @a flags is a bit list of the following:
385 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
386 See also SetListStyle(), PromoteList(), NumberList().
388 bool ClearListStyle(const wxRichTextRange
& range
,
389 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
390 bool ClearListStyle(const wxRichTextRange
& range
,
391 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
395 Sends the event to the control.
397 void Command(wxCommandEvent
& event
);
400 Copies the selected content (if any) to the clipboard.
405 Creates the underlying window.
407 bool Create(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
408 const wxString
& value
= wxEmptyString
,
409 const wxPoint
& pos
= wxDefaultPosition
,
410 const wxSize
& size
= wxDefaultSize
,
411 long style
= wxRE_MULTILINE
,
412 const wxValidator
& validator
= wxDefaultValidator
,
413 const wxString
& name
= wxTextCtrlNameStr
);
416 Copies the selected content (if any) to the clipboard and deletes the selection.
422 Deletes the content within the given range.
424 bool Delete(const wxRichTextRange
& range
);
427 Deletes content if there is a selection, e.g. when pressing a key.
428 Returns the new caret position in @e newPos, or leaves it if there
429 was no action. This is undoable.
431 bool DeleteSelectedContent(long* newPos
= NULL
);
434 Deletes the content in the selection, if any. This is undoable.
436 void DeleteSelection();
439 Sets the buffer's modified status to @false, and clears the buffer's command
445 Currently this simply returns @c wxSize(10, 10).
447 wxSize
DoGetBestSize() const;
455 Ends application of all styles in the current style stack.
460 Ends batching undo command history.
470 Ends application of a named character style.
472 bool EndCharacterStyle();
480 Ends using a point size.
492 bool EndLeftIndent();
497 bool EndLineSpacing();
500 Ends using a specified list style.
505 Ends application of a numbered bullet.
507 bool EndNumberedBullet();
510 Ends paragraph spacing.
512 bool EndParagraphSpacing();
515 Ends application of a named character style.
517 bool EndParagraphStyle();
522 bool EndRightIndent();
525 Ends the current style.
530 Ends suppressing undo command history.
532 bool EndSuppressUndo();
535 Ends applying a symbol bullet.
537 bool EndSymbolBullet();
540 Ends applying a text colour.
542 bool EndTextColour();
550 End applying underlining.
555 Helper function for extending the selection, returning @true if the selection
557 changed. Selections are in caret positions.
559 bool ExtendSelection(long oldPosition
, long newPosition
,
563 Helper function for finding the caret position for the next word. Direction
564 is 1 (forward) or -1 (backwards).
566 long FindNextWordPosition(int direction
= 1) const;
569 Call this function to prevent refresh and allow fast updates, and then Thaw() to
575 Gets the basic (overall) style. This is the style of the whole
576 buffer before further styles are applied, unlike the default style, which
577 only affects the style currently being applied (for example, setting the default
578 style to bold will cause subsequently inserted text to be bold).
580 const wxTextAttr
GetBasicStyle() const;
584 Returns the buffer associated with the control.
586 const wxRichTextBuffer
GetBuffer();
587 const wxRichTextBuffer
& GetBuffer();
591 Returns the current caret position.
593 long GetCaretPosition() const;
596 Returns the caret height and position for the given character position
598 bool GetCaretPositionForIndex(long position
, wxRect
& rect
);
601 Gets the command processor associated with the control's buffer.
603 wxCommandProcessor
* GetCommandProcessor() const;
606 Returns the current default style, which can be used to change how subsequently
610 const wxTextAttr
GetDefaultStyle() const;
613 Gets the size of the buffer beyond which layout is delayed during resizing.
614 This optimizes sizing for large buffers. The default is 20000.
616 long GetDelayedLayoutThreshold() const;
619 Gets the current filename associated with the control.
621 wxString
GetFilename() const;
624 Returns the first visible position in the current view.
626 long GetFirstVisiblePosition() const;
629 Returns flags that change the behaviour of loading or saving. See the
630 documentation for each
631 handler class to see what flags are relevant for each handler.
633 int GetHandlerFlags() const;
636 Returns the current insertion point.
638 long GetInsertionPoint() const;
641 Returns the last position in the buffer.
643 wxTextPos
GetLastPosition() const;
646 Returns the length of the specified line in characters.
648 int GetLineLength(long lineNo
) const;
651 Returns the text for the given line.
653 wxString
GetLineText(long lineNo
) const;
656 Transforms physical window position to logical (unscrolled) position.
658 wxPoint
GetLogicalPoint(const wxPoint
& ptPhysical
) const;
661 Returns the number of lines in the buffer.
663 int GetNumberOfLines() const;
666 Transforms logical (unscrolled) position to physical window position.
668 wxPoint
GetPhysicalPoint(const wxPoint
& ptLogical
) const;
671 Gets the text for the given range.
672 The end point of range is specified as the last character position of the span
675 wxString
GetRange(long from
, long to
) const;
678 Returns the range of the current selection.
679 The end point of range is specified as the last character position of the span
681 If the return values @a from and @a to are the same, there is no selection.
683 void GetSelection(long* from
, long* to
) const;
686 Returns the selection range in character positions. -1, -1 means no selection.
688 const wxRichTextRange
GetSelectionRange() const;
691 Returns the text within the current selection range, if any.
693 wxString
GetStringSelection() const;
696 Gets the attributes at the given position.
697 This function gets the combined style - that is, the style you see on the
699 of combining base style, paragraph style and character style attributes. To get
701 or paragraph style alone, use GetUncombinedStyle().
703 bool GetStyle(long position
, wxTextAttr
& style
);
706 Gets the attributes common to the specified range. Attributes that differ in
707 value within the range will
708 not be included in @e style's flags.
710 bool GetStyleForRange(const wxRichTextRange
& range
,
714 Returns the style sheet associated with the control, if any. A style sheet
716 character and paragraph styles to be applied.
718 wxRichTextStyleSheet
* GetStyleSheet() const;
721 Gets the attributes at the given position.
722 This function gets the @e uncombined style - that is, the attributes associated
724 paragraph or character content, and not necessarily the combined attributes you
726 screen. To get the combined attributes, use GetStyle().
727 If you specify (any) paragraph attribute in @e style's flags, this function
729 the paragraph attributes. Otherwise, it will return the character attributes.
731 bool GetUncombinedStyle(long position
, wxTextAttr
& style
);
734 Returns the content of the entire control as a string.
736 wxString
GetValue() const;
739 Internal helper function returning the line for the visible caret position. If
741 shown at the very end of the line, it means the next character is actually
742 on the following line. So this function gets the line we're expecting to find
745 wxRichTextLine
* GetVisibleLineForCaretPosition(long caretPosition
) const;
748 Test if this whole range has character attributes of the specified kind. If any
749 of the attributes are different within the range, the test fails. You
750 can use this to implement, for example, bold button updating. @a style must have
751 flags indicating which attributes are of interest.
753 bool HasCharacterAttributes(const wxRichTextRange
& range
,
754 const wxTextAttr
& style
) const;
757 Test if this whole range has paragraph attributes of the specified kind. If any
758 of the attributes are different within the range, the test fails. You
759 can use this to implement, for example, centering button updating. @a style
761 flags indicating which attributes are of interest.
763 bool HasParagraphAttributes(const wxRichTextRange
& range
,
764 const wxTextAttr
& style
) const;
767 Returns @true if there is a selection.
769 bool HasSelection() const;
773 Finds the character at the given position in pixels.
774 @a pt is in device coords (not adjusted for the client area origin nor for
777 wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
, long* pos
) const;
778 const wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
780 wxTextCoord
* row
) const;
784 Initialises the members of the control.
789 Initialises the command event.
791 void InitCommandEvent(wxCommandEvent
& event
) const;
794 Returns @true if the user has recently set the default style without moving
796 and therefore the UI needs to reflect the default style and not the style at
798 Below is an example of code that uses this function to determine whether the UI
799 should show that the current style is bold.
801 See also SetAndShowDefaultStyle().
803 bool IsDefaultStyleShowing() const;
806 Returns @true if the control is editable.
808 bool IsEditable() const;
811 Returns @true if Freeze has been called without a Thaw.
813 bool IsFrozen() const;
816 Returns @true if the buffer has been modified.
818 bool IsModified() const;
821 Returns @true if the control is multiline.
823 bool IsMultiLine() const;
826 Returns @true if the given position is visible on the screen.
828 bool IsPositionVisible(long pos
) const;
831 Returns @true if all of the selection is aligned according to the specified
834 bool IsSelectionAligned(wxTextAttrAlignment alignment
) const;
837 Returns @true if all of the selection is bold.
839 bool IsSelectionBold() const;
842 Returns @true if all of the selection is italic.
844 bool IsSelectionItalics() const;
847 Returns @true if all of the selection is underlined.
849 bool IsSelectionUnderlined() const;
852 Returns @true if the control is single-line. Currently wxRichTextCtrl does not
853 support single-line editing.
855 bool IsSingleLine() const;
858 Helper function implementing keyboard navigation.
860 bool KeyboardNavigate(int keyCode
, int flags
);
863 Lays out the buffer, which must be done before certain operations, such as
864 setting the caret position. This function should not normally be required by the
867 bool LayoutContent(bool onlyVisibleRect
= false);
870 Inserts a line break at the current insertion point. A line break forces
871 wrapping within a paragraph, and
872 can be introduced by using this function, by appending the wxChar value @b
873 wxRichTextLineBreakChar to text content,
874 or by typing Shift-Return.
879 Loads content into the control's buffer using the given type. If the specified
881 is wxRICHTEXT_TYPE_ANY, the type is deduced from the filename extension.
882 This function looks for a suitable wxRichTextFileHandler object.
884 bool LoadFile(const wxString
& file
,
885 int type
= wxRICHTEXT_TYPE_ANY
);
888 Marks the buffer as modified.
893 Move the caret to the given character position.
895 bool MoveCaret(long pos
, bool showAtLineStart
= false);
898 Move the caret one visual step forward: this may mean setting a flag
899 and keeping the same position if we're going from the end of one line
900 to the start of the next, which may be the exact same caret position.
902 void MoveCaretBack(long oldPosition
);
905 Move the caret one visual step forward: this may mean setting a flag
906 and keeping the same position if we're going from the end of one line
907 to the start of the next, which may be the exact same caret position.
909 void MoveCaretForward(long oldPosition
);
912 Moves the caret down.
914 bool MoveDown(int noLines
= 1, int flags
= 0);
917 Moves to the end of the buffer.
919 bool MoveEnd(int flags
= 0);
922 Moves to the start of the buffer.
924 bool MoveHome(int flags
= 0);
929 bool MoveLeft(int noPositions
= 1, int flags
= 0);
934 bool MoveRight(int noPositions
= 1, int flags
= 0);
937 Moves to the end of the line.
939 bool MoveToLineEnd(int flags
= 0);
942 Moves to the start of the line.
944 bool MoveToLineStart(int flags
= 0);
947 Moves to the end of the paragraph.
949 bool MoveToParagraphEnd(int flags
= 0);
952 Moves to the start of the paragraph.
954 bool MoveToParagraphStart(int flags
= 0);
959 bool MoveUp(int noLines
= 1, int flags
= 0);
962 Inserts a new paragraph at the current insertion point. See also LineBreak().
968 Numbers the paragraphs in the given range. Pass flags to determine how the
970 Either the style definition or the name of the style definition (in the current
971 sheet) can be passed.
972 @a flags is a bit list of the following:
973 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
974 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
975 startFrom, otherwise existing attributes are used.
976 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
977 as the level for all paragraphs, otherwise the current indentation will be used.
978 See also SetListStyle(), PromoteList(), ClearListStyle().
980 bool NumberList(const wxRichTextRange
& range
,
981 const wxRichTextListStyleDefinition
* style
,
982 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
985 bool Number(const wxRichTextRange
& range
,
986 const wxString
& styleName
,
987 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
993 Standard handler for the wxID_CLEAR command.
995 void OnClear(wxCommandEvent
& event
);
998 Shows a standard context menu with undo, redo, cut, copy, paste, clear, and
1001 void OnContextMenu(wxContextMenuEvent
& event
);
1004 Standard handler for the wxID_COPY command.
1006 void OnCopy(wxCommandEvent
& event
);
1009 Standard handler for the wxID_CUT command.
1011 void OnCut(wxCommandEvent
& event
);
1014 Loads the first dropped file.
1016 void OnDropFiles(wxDropFilesEvent
& event
);
1019 Standard handler for the wxID_PASTE command.
1021 void OnPaste(wxCommandEvent
& event
);
1024 Standard handler for the wxID_REDO command.
1026 void OnRedo(wxCommandEvent
& event
);
1029 Standard handler for the wxID_SELECTALL command.
1031 void OnSelectAll(wxCommandEvent
& event
);
1034 Standard handler for the wxID_PASTE command.
1036 void OnUndo(wxCommandEvent
& event
);
1039 Standard update handler for the wxID_CLEAR command.
1041 void OnUpdateClear(wxUpdateUIEvent
& event
);
1044 Standard update handler for the wxID_COPY command.
1046 void OnUpdateCopy(wxUpdateUIEvent
& event
);
1049 Standard update handler for the wxID_CUT command.
1051 void OnUpdateCut(wxUpdateUIEvent
& event
);
1054 Standard update handler for the wxID_PASTE command.
1056 void OnUpdatePaste(wxUpdateUIEvent
& event
);
1059 Standard update handler for the wxID_REDO command.
1061 void OnUpdateRedo(wxUpdateUIEvent
& event
);
1064 Standard update handler for the wxID_SELECTALL command.
1066 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
1069 Standard update handler for the wxID_UNDO command.
1071 void OnUpdateUndo(wxUpdateUIEvent
& event
);
1074 Moves one or more pages down.
1076 bool PageDown(int noPages
= 1, int flags
= 0);
1079 Moves one or more pages up.
1081 bool PageUp(int noPages
= 1, int flags
= 0);
1084 Paints the background.
1086 void PaintBackground(wxDC
& dc
);
1089 Pastes content from the clipboard to the buffer.
1094 Internal function to position the visible caret according to the current caret
1097 void PositionCaret();
1100 Converts a text position to zero-based column and line numbers.
1102 bool PositionToXY(long pos
, long* x
, long* y
) const;
1106 Promotes or demotes the paragraphs in the given range. A positive @a promoteBy
1107 produces a smaller indent, and a negative number
1108 produces a larger indent. Pass flags to determine how the attributes are set.
1109 Either the style definition or the name of the style definition (in the current
1110 sheet) can be passed.
1111 @a flags is a bit list of the following:
1112 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
1113 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
1114 startFrom, otherwise existing attributes are used.
1115 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
1116 as the level for all paragraphs, otherwise the current indentation will be used.
1117 See also SetListStyle(), See also SetListStyle(), ClearListStyle().
1119 bool PromoteList(int promoteBy
, const wxRichTextRange
& range
,
1120 const wxRichTextListStyleDefinition
* style
,
1121 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1122 int listLevel
= -1);
1123 bool PromoteList(int promoteBy
, const wxRichTextRange
& range
,
1124 const wxString
& styleName
,
1125 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1126 int listLevel
= -1);
1130 Redoes the current command.
1135 Removes the content in the specified range.
1137 void Remove(long from
, long to
);
1140 Replaces the content in the specified range with the string specified by @e
1143 void Replace(long from
, long to
, const wxString
& value
);
1146 Saves the buffer content using the given type. If the specified type
1147 is wxRICHTEXT_TYPE_ANY, the type is deduced from the filename extension.
1148 This function looks for a suitable wxRichTextFileHandler object.
1150 bool SaveFile(const wxString
& file
= wxEmptyString
,
1151 int type
= wxRICHTEXT_TYPE_ANY
);
1154 Scrolls @a position into view. This function takes a caret position.
1156 bool ScrollIntoView(long position
, int keyCode
);
1159 Selects all the text in the buffer.
1164 Cancels any selection.
1169 Sets @a attr as the default style and tells the control that the UI should
1171 this attribute until the user moves the caret.
1172 See also IsDefaultStyleShowing().
1174 void SetAndShowDefaultStyle(const wxTextAttr
& attr
);
1177 Sets the basic (overall) style. This is the style of the whole
1178 buffer before further styles are applied, unlike the default style, which
1179 only affects the style currently being applied (for example, setting the default
1180 style to bold will cause subsequently inserted text to be bold).
1182 void SetBasicStyle(const wxTextAttr
& style
);
1185 The caret position is the character position just before the caret.
1186 A value of -1 means the caret is at the start of the buffer.
1188 void SetCaretPosition(long position
,
1189 bool showAtLineStart
= false);
1192 Sets the current default style, which can be used to change how subsequently
1196 bool SetDefaultStyle(const wxTextAttr
& style
);
1199 Sets the default style to the style under the cursor.
1201 bool SetDefaultStyleToCursorStyle();
1204 Sets the size of the buffer beyond which layout is delayed during resizing.
1205 This optimizes sizing for large buffers. The default is 20000.
1207 void SetDelayedLayoutThreshold(long threshold
);
1210 Makes the control editable, or not.
1212 void SetEditable(bool editable
);
1215 Sets the current filename.
1217 void SetFilename(const wxString
& filename
);
1220 Sets the font, and also the basic and default attributes (see
1221 wxRichTextCtrl::SetDefaultStyle).
1223 bool SetFont(const wxFont
& font
);
1226 Sets flags that change the behaviour of loading or saving. See the
1227 documentation for each
1228 handler class to see what flags are relevant for each handler.
1230 void SetHandlerFlags(int flags
);
1233 Sets the insertion point.
1235 void SetInsertionPoint(long pos
);
1238 Sets the insertion point to the end of the text control.
1240 void SetInsertionPointEnd();
1244 Sets the list attributes for the given range, passing flags to determine how
1245 the attributes are set.
1246 Either the style definition or the name of the style definition (in the current
1247 sheet) can be passed.
1248 @a flags is a bit list of the following:
1249 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
1250 wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from @e
1251 startFrom, otherwise existing attributes are used.
1252 wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
1253 as the level for all paragraphs, otherwise the current indentation will be used.
1254 See also NumberList(), PromoteList(), ClearListStyle().
1256 bool SetListStyle(const wxRichTextRange
& range
,
1257 const wxRichTextListStyleDefinition
* style
,
1258 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1260 int listLevel
= -1);
1261 bool SetListStyle(const wxRichTextRange
& range
,
1262 const wxString
& styleName
,
1263 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
,
1265 int listLevel
= -1);
1269 Sets the selection to the given range.
1270 The end point of range is specified as the last character position of the span
1272 So, for example, to set the selection for a character at position 5, use the
1275 void SetSelection(long from
, long to
);
1278 Sets the selection to the given range.
1279 The end point of range is specified as the last character position of the span
1281 So, for example, to set the selection for a character at position 5, use the
1284 void SetSelectionRange(const wxRichTextRange
& range
);
1288 Sets the attributes for the given range.
1289 The end point of range is specified as the last character position of the span
1291 So, for example, to set the style for a character at position 5, use the range
1294 bool SetStyle(const wxRichTextRange
& range
,
1295 const wxTextAttr
& style
);
1296 bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
1301 Sets the attributes for the given range, passing flags to determine how the
1303 The end point of range is specified as the last character position of the span
1305 So, for example, to set the style for a character at position 5, use the range
1307 @a flags may contain a bit list of the following values:
1308 wxRICHTEXT_SETSTYLE_NONE: no style flag.
1309 wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be
1311 wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied
1313 combined style at this point is already the style in question.
1314 wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be
1315 applied to paragraphs,
1316 and not the content. This allows content styling to be preserved independently
1317 from that of e.g. a named paragraph style.
1318 wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be
1319 applied to characters,
1320 and not the paragraph. This allows content styling to be preserved
1321 independently from that of e.g. a named paragraph style.
1322 wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying
1324 wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags
1325 are used in this operation.
1327 bool SetStyleEx(const wxRichTextRange
& range
,
1328 const wxTextAttr
& style
,
1329 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1330 bool SetStyleEx(long start
, long end
,
1331 const wxTextAttr
& style
,
1332 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
);
1336 Sets the style sheet associated with the control. A style sheet allows named
1337 character and paragraph styles to be applied.
1339 void SetStyleSheet(wxRichTextStyleSheet
* styleSheet
);
1342 Replaces existing content with the given text.
1344 void SetValue(const wxString
& value
);
1347 A helper function setting up scrollbars, for example after a resize.
1349 void SetupScrollbars(bool atTop
= false);
1352 Scrolls the buffer so that the given position is in view.
1354 void ShowPosition(long pos
);
1357 Returns @true if undo history suppression is on.
1359 bool SuppressingUndo() const;
1362 Call this function to end a Freeze and refresh the display.
1367 Undoes the command at the top of the command history, if there is one.
1372 Moves a number of words to the left.
1374 bool WordLeft(int noWords
= 1, int flags
= 0);
1377 Move a nuber of words to the right.
1379 bool WordRight(int noWords
= 1, int flags
= 0);
1383 Write a bitmap or image at the current insertion point. Supply an optional type
1385 for internal and file storage of the raw data.
1387 bool WriteImage(const wxString
& filename
, int bitmapType
);
1388 bool WriteImage(const wxRichTextImageBlock
& imageBlock
);
1389 bool WriteImage(const wxBitmap
& bitmap
,
1390 int bitmapType
= wxBITMAP_TYPE_PNG
);
1391 bool WriteImage(const wxImage
& image
,
1392 int bitmapType
= wxBITMAP_TYPE_PNG
);
1396 Writes text at the current position.
1398 void WriteText(const wxString
& text
);
1401 Translates from column and line number to position.
1403 long XYToPosition(long x
, long y
) const;