Contents Up Previous Next

wxRichTextCtrl

wxRichTextCtrl provides a generic, ground-up implementation of a text control capable of showing multiple styles and images.

wxRichTextCtrl sends notification events: see wxRichTextEvent. It also sends the standard wxTextCtrl events wxEVT_COMMAND_TEXT_ENTER and wxEVT_COMMAND_TEXT_UPDATED, and wxTextUrlEvent when URL content is clicked.

For more information, see the wxRichTextCtrl overview.

Derived from

wxTextCtrlBase

Include files

<wx/richtext/richtextctrl.h>

Data structures

Members

wxRichTextCtrl::wxRichTextCtrl
wxRichTextCtrl::~wxRichTextCtrl
wxRichTextCtrl::AddImage
wxRichTextCtrl::AddParagraph
wxRichTextCtrl::AppendText
wxRichTextCtrl::ApplyAlignmentToSelection
wxRichTextCtrl::ApplyBoldToSelection
wxRichTextCtrl::ApplyItalicToSelection
wxRichTextCtrl::ApplyStyle
wxRichTextCtrl::ApplyStyleSheet
wxRichTextCtrl::ApplyUnderlineToSelection
wxRichTextCtrl::BatchingUndo
wxRichTextCtrl::BeginAlignment
wxRichTextCtrl::BeginBatchUndo
wxRichTextCtrl::BeginBold
wxRichTextCtrl::BeginCharacterStyle
wxRichTextCtrl::BeginFont
wxRichTextCtrl::BeginFontSize
wxRichTextCtrl::BeginItalic
wxRichTextCtrl::BeginLeftIndent
wxRichTextCtrl::BeginLineSpacing
wxRichTextCtrl::BeginListStyle
wxRichTextCtrl::BeginNumberedBullet
wxRichTextCtrl::BeginParagraphSpacing
wxRichTextCtrl::BeginParagraphStyle
wxRichTextCtrl::BeginRightIndent
wxRichTextCtrl::BeginStyle
wxRichTextCtrl::BeginSuppressUndo
wxRichTextCtrl::BeginSymbolBullet
wxRichTextCtrl::BeginTextColour
wxRichTextCtrl::BeginUnderline
wxRichTextCtrl::BeginURL
wxRichTextCtrl::CanCopy
wxRichTextCtrl::CanCut
wxRichTextCtrl::CanDeleteSelection
wxRichTextCtrl::CanPaste
wxRichTextCtrl::CanRedo
wxRichTextCtrl::CanUndo
wxRichTextCtrl::Clear
wxRichTextCtrl::ClearListStyle
wxRichTextCtrl::Command
wxRichTextCtrl::Copy
wxRichTextCtrl::Create
wxRichTextCtrl::Cut
wxRichTextCtrl::Delete
wxRichTextCtrl::DeleteSelectedContent
wxRichTextCtrl::DeleteSelection
wxRichTextCtrl::DiscardEdits
wxRichTextCtrl::DoGetBestSize
wxRichTextCtrl::EndAlignment
wxRichTextCtrl::EndAllStyles
wxRichTextCtrl::EndBatchUndo
wxRichTextCtrl::EndBold
wxRichTextCtrl::EndCharacterStyle
wxRichTextCtrl::EndFont
wxRichTextCtrl::EndFontSize
wxRichTextCtrl::EndItalic
wxRichTextCtrl::EndLeftIndent
wxRichTextCtrl::EndLineSpacing
wxRichTextCtrl::EndListStyle
wxRichTextCtrl::EndNumberedBullet
wxRichTextCtrl::EndParagraphSpacing
wxRichTextCtrl::EndParagraphStyle
wxRichTextCtrl::EndRightIndent
wxRichTextCtrl::EndStyle
wxRichTextCtrl::EndSuppressUndo
wxRichTextCtrl::EndSymbolBullet
wxRichTextCtrl::EndTextColour
wxRichTextCtrl::EndUnderline
wxRichTextCtrl::EndURL
wxRichTextCtrl::ExtendSelection
wxRichTextCtrl::FindNextWordPosition
wxRichTextCtrl::Freeze
wxRichTextCtrl::GetBasicStyle
wxRichTextCtrl::GetBuffer
wxRichTextCtrl::GetCaretPosition
wxRichTextCtrl::GetCaretPositionForIndex
wxRichTextCtrl::GetCommandProcessor
wxRichTextCtrl::GetDefaultStyleEx
wxRichTextCtrl::GetDelayedLayoutThreshold
wxRichTextCtrl::GetFilename
wxRichTextCtrl::GetFirstVisiblePosition
wxRichTextCtrl::GetHandlerFlags
wxRichTextCtrl::GetInsertionPoint
wxRichTextCtrl::GetLastPosition
wxRichTextCtrl::GetLineLength
wxRichTextCtrl::GetLineText
wxRichTextCtrl::GetLogicalPoint
wxRichTextCtrl::GetNumberOfLines
wxRichTextCtrl::GetPhysicalPoint
wxRichTextCtrl::GetRange
wxRichTextCtrl::GetSelection
wxRichTextCtrl::GetSelectionRange
wxRichTextCtrl::GetStringSelection
wxRichTextCtrl::GetStyle
wxRichTextCtrl::GetStyleForRange
wxRichTextCtrl::GetStyleSheet
wxRichTextCtrl::GetUncombinedStyle
wxRichTextCtrl::GetValue
wxRichTextCtrl::GetVisibleLineForCaretPosition
wxRichTextCtrl::HasCharacterAttributes
wxRichTextCtrl::HasParagraphAttributes
wxRichTextCtrl::HasSelection
wxRichTextCtrl::HitTest
wxRichTextCtrl::Init
wxRichTextCtrl::InitCommandEvent
wxRichTextCtrl::IsDefaultStyleShowing
wxRichTextCtrl::IsEditable
wxRichTextCtrl::IsFrozen
wxRichTextCtrl::IsModified
wxRichTextCtrl::IsMultiLine
wxRichTextCtrl::IsPositionVisible
wxRichTextCtrl::IsSelectionAligned
wxRichTextCtrl::IsSelectionBold
wxRichTextCtrl::IsSelectionItalics
wxRichTextCtrl::IsSelectionUnderlined
wxRichTextCtrl::IsSingleLine
wxRichTextCtrl::KeyboardNavigate
wxRichTextCtrl::LayoutContent
wxRichTextCtrl::LineBreak
wxRichTextCtrl::LoadFile
wxRichTextCtrl::MarkDirty
wxRichTextCtrl::MoveCaret
wxRichTextCtrl::MoveCaretBack
wxRichTextCtrl::MoveCaretForward
wxRichTextCtrl::MoveDown
wxRichTextCtrl::MoveEnd
wxRichTextCtrl::MoveHome
wxRichTextCtrl::MoveLeft
wxRichTextCtrl::MoveRight
wxRichTextCtrl::MoveToLineEnd
wxRichTextCtrl::MoveToLineStart
wxRichTextCtrl::MoveToParagraphEnd
wxRichTextCtrl::MoveToParagraphStart
wxRichTextCtrl::MoveUp
wxRichTextCtrl::Newline
wxRichTextCtrl::NumberList
wxRichTextCtrl::OnClear
wxRichTextCtrl::OnContextMenu
wxRichTextCtrl::OnCopy
wxRichTextCtrl::OnCut
wxRichTextCtrl::OnDropFiles
wxRichTextCtrl::OnPaste
wxRichTextCtrl::OnRedo
wxRichTextCtrl::OnSelectAll
wxRichTextCtrl::OnUndo
wxRichTextCtrl::OnUpdateClear
wxRichTextCtrl::OnUpdateCopy
wxRichTextCtrl::OnUpdateCut
wxRichTextCtrl::OnUpdatePaste
wxRichTextCtrl::OnUpdateRedo
wxRichTextCtrl::OnUpdateSelectAll
wxRichTextCtrl::OnUpdateUndo
wxRichTextCtrl::PageDown
wxRichTextCtrl::PageUp
wxRichTextCtrl::PaintBackground
wxRichTextCtrl::Paste
wxRichTextCtrl::PositionCaret
wxRichTextCtrl::PositionToXY
wxRichTextCtrl::PromoteList
wxRichTextCtrl::Redo
wxRichTextCtrl::Remove
wxRichTextCtrl::Replace
wxRichTextCtrl::SaveFile
wxRichTextCtrl::ScrollIntoView
wxRichTextCtrl::SelectAll
wxRichTextCtrl::SelectNone
wxRichTextCtrl::SetAndShowDefaultStyle
wxRichTextCtrl::SetBasicStyle
wxRichTextCtrl::SetCaretPosition
wxRichTextCtrl::SetDefaultStyle
wxRichTextCtrl::SetDefaultStyleToCursorStyle
wxRichTextCtrl::SetDelayedLayoutThreshold
wxRichTextCtrl::SetEditable
wxRichTextCtrl::SetFilename
wxRichTextCtrl::SetFont
wxRichTextCtrl::SetHandlerFlags
wxRichTextCtrl::SetInsertionPoint
wxRichTextCtrl::SetInsertionPointEnd
wxRichTextCtrl::SetListStyle
wxRichTextCtrl::SetSelection
wxRichTextCtrl::SetSelectionRange
wxRichTextCtrl::SetStyle
wxRichTextCtrl::SetStyleEx
wxRichTextCtrl::SetStyleSheet
wxRichTextCtrl::SetValue
wxRichTextCtrl::SetupScrollbars
wxRichTextCtrl::ShowPosition
wxRichTextCtrl::SuppressingUndo
wxRichTextCtrl::Thaw
wxRichTextCtrl::Undo
wxRichTextCtrl::WordLeft
wxRichTextCtrl::WordRight
wxRichTextCtrl::WriteImage
wxRichTextCtrl::WriteText
wxRichTextCtrl::XYToPosition


wxRichTextCtrl::wxRichTextCtrl

wxRichTextCtrl()

wxRichTextCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr)

Constructors.


wxRichTextCtrl::~wxRichTextCtrl

~wxRichTextCtrl()

Destructor.


wxRichTextCtrl::AddImage

wxRichTextRange AddImage(const wxImage& image)

Adds an image to the control's buffer.


wxRichTextCtrl::AddParagraph

wxRichTextRange AddParagraph(const wxString& text)

Adds a new paragraph of text to the end of the buffer.


wxRichTextCtrl::AppendText

void AppendText(const wxString& text)

Sets the insertion point to the end of the buffer and writes the text.


wxRichTextCtrl::ApplyAlignmentToSelection

bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment)

Applies the given alignment to the selection (undoable).

For alignment values, see wxTextAttrEx.


wxRichTextCtrl::ApplyBoldToSelection

bool ApplyBoldToSelection()

Apples bold to the selection (undoable).


wxRichTextCtrl::ApplyItalicToSelection

bool ApplyItalicToSelection()

Applies italic to the selection (undoable).


wxRichTextCtrl::ApplyStyle

bool ApplyStyle(wxRichTextStyleDefinition* def)

Applies the given style to the selection.


wxRichTextCtrl::ApplyStyleSheet

bool ApplyStyleSheet(wxRichTextStyleSheet* sheet = NULL)

Applies the style sheet to the buffer, matching paragraph styles in the sheet against named styles in the buffer. This might be useful if the styles have changed. If sheet is NULL, the sheet set with SetStyleSheet is used.

Currently this applies paragraph styles only.


wxRichTextCtrl::ApplyUnderlineToSelection

bool ApplyUnderlineToSelection()

Applies underline to the selection (undoable).


wxRichTextCtrl::BatchingUndo

bool BatchingUndo() const

Returns true if undo commands are being batched.


wxRichTextCtrl::BeginAlignment

bool BeginAlignment(wxTextAttrAlignment alignment)

Begins using alignment

For alignment values, see wxTextAttrEx.


wxRichTextCtrl::BeginBatchUndo

bool BeginBatchUndo(const wxString& cmdName)

Starts batching undo history for commands.


wxRichTextCtrl::BeginBold

bool BeginBold()

Begins using bold.


wxRichTextCtrl::BeginCharacterStyle

bool BeginCharacterStyle(const wxString& characterStyle)

Begins using the named character style.


wxRichTextCtrl::BeginFont

bool BeginFont(const wxFont& font)

Begins using this font.


wxRichTextCtrl::BeginFontSize

bool BeginFontSize(int pointSize)

Begins using the given point size.


wxRichTextCtrl::BeginItalic

bool BeginItalic()

Begins using italic.


wxRichTextCtrl::BeginLeftIndent

bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0)

Begins applying a left indent and subindent in tenths of a millimetre.

The sub-indent is an offset from the left of the paragraph, and is used for all but the first line in a paragraph. A positive value will cause the first line to appear to the left of the subsequent lines, and a negative value will cause the first line to be indented relative to the subsequent lines.

wxRichTextBuffer uses indentation to render a bulleted item. The left indent is the distance between the margin and the bullet. The content of the paragraph, including the first line, starts at leftMargin + leftSubIndent. So the distance between the left edge of the bullet and the left of the actual paragraph is leftSubIndent.


wxRichTextCtrl::BeginLineSpacing

bool BeginLineSpacing(int lineSpacing)

Begins appling line spacing. spacing is a multiple, where 10 means single-spacing, 15 means 1.5 spacing, and 20 means double spacing. The following constants are defined for convenience:

#define wxTEXT_ATTR_LINE_SPACING_NORMAL         10
#define wxTEXT_ATTR_LINE_SPACING_HALF           15
#define wxTEXT_ATTR_LINE_SPACING_TWICE          20


wxRichTextCtrl::BeginListStyle

bool BeginListStyle(const wxString& listStyle, int level=1, int number=1)

Begins using a specified list style. Optionally, you can also pass a level and a number.


wxRichTextCtrl::BeginNumberedBullet

bool BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_ARABIC|wxTEXT_ATTR_BULLET_STYLE_PERIOD)

Begins a numbered bullet. This call will be needed for each item in the list, and the application should take care of incrementing the numbering.

bulletNumber is a number, usually starting with 1.

leftIndent and leftSubIndent are values in tenths of a millimetre.

bulletStyle is a bitlist of the following values:

#define wxTEXT_ATTR_BULLET_STYLE_NONE               0x00000000
#define wxTEXT_ATTR_BULLET_STYLE_ARABIC             0x00000001
#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER      0x00000002
#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER      0x00000004
#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER        0x00000008
#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER        0x00000010
#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL             0x00000020
#define wxTEXT_ATTR_BULLET_STYLE_BITMAP             0x00000040
#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES        0x00000080
#define wxTEXT_ATTR_BULLET_STYLE_PERIOD             0x00000100
#define wxTEXT_ATTR_BULLET_STYLE_STANDARD           0x00000200
#define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS  0x00000400
#define wxTEXT_ATTR_BULLET_STYLE_OUTLINE            0x00000800
#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT         0x00000000
#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT        0x00001000
#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE       0x00002000

wxRichTextBuffer uses indentation to render a bulleted item. The left indent is the distance between the margin and the bullet. The content of the paragraph, including the first line, starts at leftMargin + leftSubIndent. So the distance between the left edge of the bullet and the left of the actual paragraph is leftSubIndent.


wxRichTextCtrl::BeginParagraphSpacing

bool BeginParagraphSpacing(int before, int after)

Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing in tenths of a millimetre.


wxRichTextCtrl::BeginParagraphStyle

bool BeginParagraphStyle(const wxString& paragraphStyle)

Begins applying the named paragraph style.


wxRichTextCtrl::BeginRightIndent

bool BeginRightIndent(int rightIndent)

Begins a right indent, specified in tenths of a millimetre.


wxRichTextCtrl::BeginStyle

bool BeginStyle(const wxTextAttrEx& style)

Begins applying a style.


wxRichTextCtrl::BeginSuppressUndo

bool BeginSuppressUndo()

Starts suppressing undo history for commands.


wxRichTextCtrl::BeginSymbolBullet

bool BeginSymbolBullet(wxChar symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL)

Begins applying a symbol bullet, using a character from the current font. See BeginNumberedBullet for an explanation of how indentation is used to render the bulleted paragraph.


wxRichTextCtrl::BeginTextColour

bool BeginTextColour(const wxColour& colour)

Begins using this colour.


wxRichTextCtrl::BeginUnderline

bool BeginUnderline()

Begins using underlining.


wxRichTextCtrl::BeginURL

bool BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString)

Begins applying wxTEXT_ATTR_URL to the content. Pass a URL and optionally, a character style to apply, since it is common to mark a URL with a familiar style such as blue text with underlining.


wxRichTextCtrl::CanCopy

bool CanCopy() const

Returns true if selected content can be copied to the clipboard.


wxRichTextCtrl::CanCut

bool CanCut() const

Returns true if selected content can be copied to the clipboard and deleted.


wxRichTextCtrl::CanDeleteSelection

bool CanDeleteSelection() const

Returns true if selected content can be deleted.


wxRichTextCtrl::CanPaste

bool CanPaste() const

Returns true if the clipboard content can be pasted to the buffer.


wxRichTextCtrl::CanRedo

bool CanRedo() const

Returns true if there is a command in the command history that can be redone.


wxRichTextCtrl::CanUndo

bool CanUndo() const

Returns true if there is a command in the command history that can be undone.


wxRichTextCtrl::Clear

void Clear()

Clears the buffer content, leaving a single empty paragraph. Cannot be undone.


wxRichTextCtrl::ClearListStyle

bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO)

bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO)

Clears the list style from the given range, clearing list-related attributes and applying any named paragraph style associated with each paragraph.

flags is a bit list of the following:

See also wxRichTextCtrl::SetListStyle, wxRichTextCtrl::PromoteList, wxRichTextCtrl::NumberList.


wxRichTextCtrl::Command

void Command(wxCommandEvent& event)

Sends the event to the control.


wxRichTextCtrl::Copy

void Copy()

Copies the selected content (if any) to the clipboard.


wxRichTextCtrl::Create

bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxRE_MULTILINE, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr)

Creates the underlying window.


wxRichTextCtrl::Cut

void Cut()

Copies the selected content (if any) to the clipboard and deletes the selection. This is undoable.


wxRichTextCtrl::Delete

bool Delete(const wxRichTextRange& range)

Deletes the content within the given range.


wxRichTextCtrl::DeleteSelectedContent

bool DeleteSelectedContent(long* newPos = NULL)

Deletes content if there is a selection, e.g. when pressing a key. Returns the new caret position in newPos, or leaves it if there was no action. This is undoable.


wxRichTextCtrl::DeleteSelection

void DeleteSelection()

Deletes the content in the selection, if any. This is undoable.


wxRichTextCtrl::DiscardEdits

void DiscardEdits()

Sets the buffer's modified status to false, and clears the buffer's command history.


wxRichTextCtrl::DoGetBestSize

wxSize DoGetBestSize() const

Currently this simply returns wxSize(10, 10).


wxRichTextCtrl::EndAlignment

bool EndAlignment()

Ends alignment.


wxRichTextCtrl::EndAllStyles

bool EndAllStyles()

Ends application of all styles in the current style stack.


wxRichTextCtrl::EndBatchUndo

bool EndBatchUndo()

Ends batching undo command history.


wxRichTextCtrl::EndBold

bool EndBold()

Ends using bold.


wxRichTextCtrl::EndCharacterStyle

bool EndCharacterStyle()

Ends application of a named character style.


wxRichTextCtrl::EndFont

bool EndFont()

Ends using a font.


wxRichTextCtrl::EndFontSize

bool EndFontSize()

Ends using a point size.


wxRichTextCtrl::EndItalic

bool EndItalic()

Ends using italic.


wxRichTextCtrl::EndLeftIndent

bool EndLeftIndent()

Ends left indent.


wxRichTextCtrl::EndLineSpacing

bool EndLineSpacing()

Ends line spacing.


wxRichTextCtrl::EndListStyle

bool EndListStyle()

Ends using a specified list style.


wxRichTextCtrl::EndNumberedBullet

bool EndNumberedBullet()

Ends application of a numbered bullet.


wxRichTextCtrl::EndParagraphSpacing

bool EndParagraphSpacing()

Ends paragraph spacing.


wxRichTextCtrl::EndParagraphStyle

bool EndParagraphStyle()

Ends application of a named character style.


wxRichTextCtrl::EndRightIndent

bool EndRightIndent()

Ends right indent.


wxRichTextCtrl::EndStyle

bool EndStyle()

Ends the current style.


wxRichTextCtrl::EndSuppressUndo

bool EndSuppressUndo()

Ends suppressing undo command history.


wxRichTextCtrl::EndSymbolBullet

bool EndSymbolBullet()

Ends applying a symbol bullet.


wxRichTextCtrl::EndTextColour

bool EndTextColour()

Ends applying a text colour.


wxRichTextCtrl::EndUnderline

bool EndUnderline()

End applying underlining.


wxRichTextCtrl::EndURL

bool EndURL()

Ends applying a URL.


wxRichTextCtrl::ExtendSelection

bool ExtendSelection(long oldPosition, long newPosition, int flags)

Helper function for extending the selection, returning true if the selection was changed. Selections are in caret positions.


wxRichTextCtrl::FindNextWordPosition

long FindNextWordPosition(int direction = 1) const

Helper function for finding the caret position for the next word. Direction is 1 (forward) or -1 (backwards).


wxRichTextCtrl::Freeze

void Freeze()

Call this function to prevent refresh and allow fast updates, and then Thaw to refresh the control.


wxRichTextCtrl::GetBasicStyle

const wxTextAttrEx& GetBasicStyle() const

Gets the basic (overall) style. This is the style of the whole buffer before further styles are applied, unlike the default style, which only affects the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold).


wxRichTextCtrl::GetBuffer

const wxRichTextBuffer& GetBuffer() const

wxRichTextBuffer& GetBuffer()

Returns the buffer associated with the control.


wxRichTextCtrl::GetCaretPosition

long GetCaretPosition() const

Returns the current caret position.


wxRichTextCtrl::GetCaretPositionForIndex

bool GetCaretPositionForIndex(long position, wxRect& rect)

Returns the caret height and position for the given character position


wxRichTextCtrl::GetCommandProcessor

wxCommandProcessor* GetCommandProcessor() const

Gets the command processor associated with the control's buffer.


wxRichTextCtrl::GetDefaultStyleEx

const wxTextAttrEx& GetDefaultStyleEx() const

Returns the current default style, which can be used to change how subsequently inserted text is displayed. When wxTextAttrEx is merged with wxTextAttr, this function will become GetDefaultStyle.


wxRichTextCtrl::GetDelayedLayoutThreshold

long GetDelayedLayoutThreshold() const

Gets the size of the buffer beyond which layout is delayed during resizing. This optimizes sizing for large buffers. The default is 20000.


wxRichTextCtrl::GetFilename

wxString GetFilename() const

Gets the current filename associated with the control.


wxRichTextCtrl::GetFirstVisiblePosition

long GetFirstVisiblePosition() const

Returns the first visible position in the current view.


wxRichTextCtrl::GetHandlerFlags

int GetHandlerFlags() const

Returns flags that change the behaviour of loading or saving. See the documentation for each handler class to see what flags are relevant for each handler.


wxRichTextCtrl::GetInsertionPoint

long GetInsertionPoint() const

Returns the current insertion point.


wxRichTextCtrl::GetLastPosition

wxTextPos GetLastPosition() const

Returns the last position in the buffer.


wxRichTextCtrl::GetLineLength

int GetLineLength(long lineNo) const

Returns the length of the specified line in characters.


wxRichTextCtrl::GetLineText

wxString GetLineText(long lineNo) const

Returns the text for the given line.


wxRichTextCtrl::GetLogicalPoint

wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const

Transforms physical window position to logical (unscrolled) position.


wxRichTextCtrl::GetNumberOfLines

int GetNumberOfLines() const

Returns the number of lines in the buffer.


wxRichTextCtrl::GetPhysicalPoint

wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const

Transforms logical (unscrolled) position to physical window position.


wxRichTextCtrl::GetRange

wxString GetRange(long from, long to) const

Gets the text for the given range.

The end point of range is specified as the last character position of the span of text, plus one.


wxRichTextCtrl::GetSelection

void GetSelection(long* from, long* to) const

Returns the range of the current selection.

The end point of range is specified as the last character position of the span of text, plus one.

If the return values from and to are the same, there is no selection.


wxRichTextCtrl::GetSelectionRange

const wxRichTextRange& GetSelectionRange() const

Returns the selection range in character positions. -1, -1 means no selection.


wxRichTextCtrl::GetStringSelection

wxString GetStringSelection() const

Returns the text within the current selection range, if any.


wxRichTextCtrl::GetStyle

bool GetStyle(long position, wxRichTextAttr& style)

bool GetStyle(long position, wxTextAttrEx& style)

bool GetStyle(long position, wxTextAttr& style)

Gets the attributes at the given position. The wxRichTextAttr version is generally more efficient because it does not use wxFont objects.

This function gets the combined style - that is, the style you see on the screen as a result of combining base style, paragraph style and character style attributes. To get the character or paragraph style alone, use GetUncombinedStyle.


wxRichTextCtrl::GetStyleForRange

bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style)

bool GetStyleForRange(const wxRichTextRange& range, wxTextAttrEx& style)

Gets the attributes common to the specified range. Attributes that differ in value within the range will not be included in style's flags.


wxRichTextCtrl::GetStyleSheet

wxRichTextStyleSheet* GetStyleSheet() const

Returns the style sheet associated with the control, if any. A style sheet allows named character and paragraph styles to be applied.


wxRichTextCtrl::GetUncombinedStyle

bool GetUncombinedStyle(long position, wxRichTextAttr& style)

bool GetUncombinedStyle(long position, wxTextAttrEx& style)

bool GetUncombinedStyle(long position, wxTextAttr& style)

Gets the attributes at the given position. The wxRichTextAttr version is generally more efficient because it does not use wxFont objects.

This function gets the uncombined style - that is, the attributes associated with the paragraph or character content, and not necessarily the combined attributes you see on the screen. To get the combined attributes, use GetStyle.

If you specify (any) paragraph attribute in style's flags, this function will fetch the paragraph attributes. Otherwise, it will return the character attributes.


wxRichTextCtrl::GetValue

wxString GetValue() const

Returns the content of the entire control as a string.


wxRichTextCtrl::GetVisibleLineForCaretPosition

wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const

Internal helper function returning the line for the visible caret position. If the caret is shown at the very end of the line, it means the next character is actually on the following line. So this function gets the line we're expecting to find if this is the case.


wxRichTextCtrl::HasCharacterAttributes

bool HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const

bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const

Test if this whole range has character attributes of the specified kind. If any of the attributes are different within the range, the test fails. You can use this to implement, for example, bold button updating. style must have flags indicating which attributes are of interest.


wxRichTextCtrl::HasParagraphAttributes

bool HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttrEx& style) const

bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const

Test if this whole range has paragraph attributes of the specified kind. If any of the attributes are different within the range, the test fails. You can use this to implement, for example, centering button updating. style must have flags indicating which attributes are of interest.


wxRichTextCtrl::HasSelection

bool HasSelection() const

Returns true if there is a selection.


wxRichTextCtrl::HitTest

wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long* pos) const

wxTextCtrlHitTestResult HitTest(const wxPoint& pt, wxTextCoord* col, wxTextCoord* row) const

Finds the character at the given position in pixels.

pt is in device coords (not adjusted for the client area origin nor for scrolling).


wxRichTextCtrl::Init

void Init()

Initialises the members of the control.


wxRichTextCtrl::InitCommandEvent

void InitCommandEvent(wxCommandEvent& event) const

Initialises the command event.


wxRichTextCtrl::IsDefaultStyleShowing

bool IsDefaultStyleShowing() const

Returns true if the user has recently set the default style without moving the caret, and therefore the UI needs to reflect the default style and not the style at the caret.

Below is an example of code that uses this function to determine whether the UI should show that the current style is bold.

/// Is all of the selection bold?
bool wxRichTextCtrl::IsSelectionBold()
{
    if (HasSelection())
    {
        wxRichTextAttr attr;
        wxRichTextRange range = GetInternalSelectionRange();
        attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
        attr.SetFontWeight(wxBOLD);

        return HasCharacterAttributes(range, attr);
    }
    else
    {
        // If no selection, then we need to combine current style with default style
        // to see what the effect would be if we started typing.
        wxRichTextAttr attr;
        attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);

        long pos = GetAdjustedCaretPosition(GetCaretPosition());
        if (GetStyle(pos, attr))
        {
            if (IsDefaultStyleShowing())
                wxRichTextApplyStyle(attr, GetDefaultStyleEx());
            return attr.GetFontWeight() == wxBOLD;
        }
    }
    return false;
}
See also SetAndShowDefaultStyle.


wxRichTextCtrl::IsEditable

bool IsEditable() const

Returns true if the control is editable.


wxRichTextCtrl::IsFrozen

bool IsFrozen() const

Returns true if Freeze has been called without a Thaw.


wxRichTextCtrl::IsModified

bool IsModified() const

Returns true if the buffer has been modified.


wxRichTextCtrl::IsMultiLine

bool IsMultiLine() const

Returns true if the control is multiline.


wxRichTextCtrl::IsPositionVisible

bool IsPositionVisible(long pos) const

Returns true if the given position is visible on the screen.


wxRichTextCtrl::IsSelectionAligned

bool IsSelectionAligned(wxTextAttrAlignment alignment) const

Returns true if all of the selection is aligned according to the specified flag.


wxRichTextCtrl::IsSelectionBold

bool IsSelectionBold() const

Returns true if all of the selection is bold.


wxRichTextCtrl::IsSelectionItalics

bool IsSelectionItalics() const

Returns true if all of the selection is italic.


wxRichTextCtrl::IsSelectionUnderlined

bool IsSelectionUnderlined() const

Returns true if all of the selection is underlined.


wxRichTextCtrl::IsSingleLine

bool IsSingleLine() const

Returns true if the control is single-line. Currently wxRichTextCtrl does not support single-line editing.


wxRichTextCtrl::KeyboardNavigate

bool KeyboardNavigate(int keyCode, int flags)

Helper function implementing keyboard navigation.


wxRichTextCtrl::LayoutContent

bool LayoutContent(bool onlyVisibleRect = false)

Lays out the buffer, which must be done before certain operations, such as setting the caret position. This function should not normally be required by the application.


wxRichTextCtrl::LineBreak

bool LineBreak()

Inserts a line break at the current insertion point. A line break forces wrapping within a paragraph, and can be introduced by using this function, by appending the wxChar value wxRichTextLineBreakChar to text content, or by typing Shift-Return.


wxRichTextCtrl::LoadFile

bool LoadFile(const wxString& file, int type = wxRICHTEXT_TYPE_ANY)

Loads content into the control's buffer using the given type. If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from the filename extension.

This function looks for a suitable wxRichTextFileHandler object.


wxRichTextCtrl::MarkDirty

void MarkDirty()

Marks the buffer as modified.


wxRichTextCtrl::MoveCaret

bool MoveCaret(long pos, bool showAtLineStart = false)

Move the caret to the given character position.


wxRichTextCtrl::MoveCaretBack

void MoveCaretBack(long oldPosition)

Move the caret one visual step forward: this may mean setting a flag and keeping the same position if we're going from the end of one line to the start of the next, which may be the exact same caret position.


wxRichTextCtrl::MoveCaretForward

void MoveCaretForward(long oldPosition)

Move the caret one visual step forward: this may mean setting a flag and keeping the same position if we're going from the end of one line to the start of the next, which may be the exact same caret position.


wxRichTextCtrl::MoveDown

bool MoveDown(int noLines = 1, int flags = 0)

Moves the caret down.


wxRichTextCtrl::MoveEnd

bool MoveEnd(int flags = 0)

Moves to the end of the buffer.


wxRichTextCtrl::MoveHome

bool MoveHome(int flags = 0)

Moves to the start of the buffer.


wxRichTextCtrl::MoveLeft

bool MoveLeft(int noPositions = 1, int flags = 0)

Moves left.


wxRichTextCtrl::MoveRight

bool MoveRight(int noPositions = 1, int flags = 0)

Moves right.


wxRichTextCtrl::MoveToLineEnd

bool MoveToLineEnd(int flags = 0)

Moves to the end of the line.


wxRichTextCtrl::MoveToLineStart

bool MoveToLineStart(int flags = 0)

Moves to the start of the line.


wxRichTextCtrl::MoveToParagraphEnd

bool MoveToParagraphEnd(int flags = 0)

Moves to the end of the paragraph.


wxRichTextCtrl::MoveToParagraphStart

bool MoveToParagraphStart(int flags = 0)

Moves to the start of the paragraph.


wxRichTextCtrl::MoveUp

bool MoveUp(int noLines = 1, int flags = 0)

Moves up.


wxRichTextCtrl::Newline

bool Newline()

Inserts a new paragraph at the current insertion point. See also wxRichTextCtrl::LineBreak.


wxRichTextCtrl::NumberList

bool NumberList(const wxRichTextRange& range, const wxRichTextListStyleDefinition* style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = -1, int listLevel = -1)

bool Number(const wxRichTextRange& range, const wxString& styleName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = -1, int listLevel = -1)

Numbers the paragraphs in the given range. Pass flags to determine how the attributes are set. Either the style definition or the name of the style definition (in the current sheet) can be passed.

flags is a bit list of the following:

See also wxRichTextCtrl::SetListStyle, wxRichTextCtrl::PromoteList, wxRichTextCtrl::ClearListStyle.


wxRichTextCtrl::OnClear

void OnClear(wxCommandEvent& event)

Standard handler for the wxID_CLEAR command.


wxRichTextCtrl::OnContextMenu

void OnContextMenu(wxContextMenuEvent& event)

Shows a standard context menu with undo, redo, cut, copy, paste, clear, and select all commands.


wxRichTextCtrl::OnCopy

void OnCopy(wxCommandEvent& event)

Standard handler for the wxID_COPY command.


wxRichTextCtrl::OnCut

void OnCut(wxCommandEvent& event)

Standard handler for the wxID_CUT command.


wxRichTextCtrl::OnDropFiles

void OnDropFiles(wxDropFilesEvent& event)

Loads the first dropped file.


wxRichTextCtrl::OnPaste

void OnPaste(wxCommandEvent& event)

Standard handler for the wxID_PASTE command.


wxRichTextCtrl::OnRedo

void OnRedo(wxCommandEvent& event)

Standard handler for the wxID_REDO command.


wxRichTextCtrl::OnSelectAll

void OnSelectAll(wxCommandEvent& event)

Standard handler for the wxID_SELECTALL command.


wxRichTextCtrl::OnUndo

void OnUndo(wxCommandEvent& event)

Standard handler for the wxID_PASTE command.


wxRichTextCtrl::OnUpdateClear

void OnUpdateClear(wxUpdateUIEvent& event)

Standard update handler for the wxID_CLEAR command.


wxRichTextCtrl::OnUpdateCopy

void OnUpdateCopy(wxUpdateUIEvent& event)

Standard update handler for the wxID_COPY command.


wxRichTextCtrl::OnUpdateCut

void OnUpdateCut(wxUpdateUIEvent& event)

Standard update handler for the wxID_CUT command.


wxRichTextCtrl::OnUpdatePaste

void OnUpdatePaste(wxUpdateUIEvent& event)

Standard update handler for the wxID_PASTE command.


wxRichTextCtrl::OnUpdateRedo

void OnUpdateRedo(wxUpdateUIEvent& event)

Standard update handler for the wxID_REDO command.


wxRichTextCtrl::OnUpdateSelectAll

void OnUpdateSelectAll(wxUpdateUIEvent& event)

Standard update handler for the wxID_SELECTALL command.


wxRichTextCtrl::OnUpdateUndo

void OnUpdateUndo(wxUpdateUIEvent& event)

Standard update handler for the wxID_UNDO command.


wxRichTextCtrl::PageDown

bool PageDown(int noPages = 1, int flags = 0)

Moves one or more pages down.


wxRichTextCtrl::PageUp

bool PageUp(int noPages = 1, int flags = 0)

Moves one or more pages up.


wxRichTextCtrl::PaintBackground

void PaintBackground(wxDC& dc)

Paints the background.


wxRichTextCtrl::Paste

void Paste()

Pastes content from the clipboard to the buffer.


wxRichTextCtrl::PositionCaret

void PositionCaret()

Internal function to position the visible caret according to the current caret position.


wxRichTextCtrl::PositionToXY

bool PositionToXY(long pos, long* x, long* y) const

Converts a text position to zero-based column and line numbers.


wxRichTextCtrl::PromoteList

bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxRichTextListStyleDefinition* style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int listLevel = -1)

bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& styleName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int listLevel = -1)

Promotes or demotes the paragraphs in the given range. A positive promoteBy produces a smaller indent, and a negative number produces a larger indent. Pass flags to determine how the attributes are set. Either the style definition or the name of the style definition (in the current sheet) can be passed.

flags is a bit list of the following:

See also wxRichTextCtrl::SetListStyle, See also wxRichTextCtrl::SetListStyle, wxRichTextCtrl::ClearListStyle.


wxRichTextCtrl::Redo

void Redo()

Redoes the current command.


wxRichTextCtrl::Remove

void Remove(long from, long to)

Removes the content in the specified range.


wxRichTextCtrl::Replace

void Replace(long from, long to, const wxString& value)

Replaces the content in the specified range with the string specified by value.


wxRichTextCtrl::SaveFile

bool SaveFile(const wxString& file = wxEmptyString, int type = wxRICHTEXT_TYPE_ANY)

Saves the buffer content using the given type. If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from the filename extension.

This function looks for a suitable wxRichTextFileHandler object.


wxRichTextCtrl::ScrollIntoView

bool ScrollIntoView(long position, int keyCode)

Scrolls position into view. This function takes a caret position.


wxRichTextCtrl::SelectAll

void SelectAll()

Selects all the text in the buffer.


wxRichTextCtrl::SelectNone

void SelectNone()

Cancels any selection.


wxRichTextCtrl::SetAndShowDefaultStyle

void SetAndShowDefaultStyle(const wxRichTextAttr& attr)

Sets attr as the default style and tells the control that the UI should reflect this attribute until the user moves the caret.

See also IsDefaultStyleShowing.


wxRichTextCtrl::SetBasicStyle

void SetBasicStyle(const wxRichTextAttr& style)

void SetBasicStyle(const wxTextAttrEx& style)

Sets the basic (overall) style. This is the style of the whole buffer before further styles are applied, unlike the default style, which only affects the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold).


wxRichTextCtrl::SetCaretPosition

void SetCaretPosition(long position, bool showAtLineStart = false)

The caret position is the character position just before the caret. A value of -1 means the caret is at the start of the buffer.


wxRichTextCtrl::SetDefaultStyle

bool SetDefaultStyle(const wxTextAttrEx& style)

Sets the current default style, which can be used to change how subsequently inserted text is displayed.


wxRichTextCtrl::SetDefaultStyleToCursorStyle

bool SetDefaultStyleToCursorStyle()

Sets the default style to the style under the cursor.


wxRichTextCtrl::SetDelayedLayoutThreshold

void SetDelayedLayoutThreshold(long threshold)

Sets the size of the buffer beyond which layout is delayed during resizing. This optimizes sizing for large buffers. The default is 20000.


wxRichTextCtrl::SetEditable

void SetEditable(bool editable)

Makes the control editable, or not.


wxRichTextCtrl::SetFilename

void SetFilename(const wxString& filename)

Sets the current filename.


wxRichTextCtrl::SetFont

bool SetFont(const wxFont& font)

Sets the font, and also the basic and default attributes (see SetDefaultStyle).


wxRichTextCtrl::SetHandlerFlags

void SetHandlerFlags(int flags)

Sets flags that change the behaviour of loading or saving. See the documentation for each handler class to see what flags are relevant for each handler.


wxRichTextCtrl::SetInsertionPoint

void SetInsertionPoint(long pos)

Sets the insertion point.


wxRichTextCtrl::SetInsertionPointEnd

void SetInsertionPointEnd()

Sets the insertion point to the end of the text control.


wxRichTextCtrl::SetListStyle

bool SetListStyle(const wxRichTextRange& range, const wxRichTextListStyleDefinition* style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = -1, int listLevel = -1)

bool SetListStyle(const wxRichTextRange& range, const wxString& styleName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = -1, int listLevel = -1)

Sets the list attributes for the given range, passing flags to determine how the attributes are set. Either the style definition or the name of the style definition (in the current sheet) can be passed.

flags is a bit list of the following:

See also wxRichTextCtrl::NumberList, wxRichTextCtrl::PromoteList, wxRichTextCtrl::ClearListStyle.


wxRichTextCtrl::SetSelection

void SetSelection(long from, long to)

Sets the selection to the given range.

The end point of range is specified as the last character position of the span of text, plus one. So, for example, to set the style for a character at position 5, use the range (5,6).


wxRichTextCtrl::SetSelectionRange

void SetSelectionRange(const wxRichTextRange& range)

Sets the selection to the given range.

The end point of range is specified as the last character position of the span of text, plus one. So, for example, to set the style for a character at position 5, use the range (5,6).


wxRichTextCtrl::SetStyle

bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style)

bool SetStyle(long start, long end, const wxTextAttrEx& style)

bool SetStyle(long start, long end, const wxTextAttr& style)

Sets the attributes for the given range. The wxRichTextAttr version is more efficient because it does not use wxFont objects.

The end point of range is specified as the last character position of the span of text, plus one. So, for example, to set the style for a character at position 5, use the range (5,6).


wxRichTextCtrl::SetStyleEx

bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO)

bool SetStyleEx(const wxRichTextRange& range, const wxTextAttrEx& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO)

bool SetStyleEx(long start, long end, const wxTextAttrEx& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO)

Sets the attributes for the given range, passing flags to determine how the attributes are set. The wxRichTextAttr version is more efficient because it does not use wxFont objects.

The end point of range is specified as the last character position of the span of text, plus one. So, for example, to set the style for a character at position 5, use the range (5,6).

flags may contain a bit list of the following values:


wxRichTextCtrl::SetStyleSheet

void SetStyleSheet(wxRichTextStyleSheet* styleSheet)

Sets the style sheet associated with the control. A style sheet allows named character and paragraph styles to be applied.


wxRichTextCtrl::SetValue

void SetValue(const wxString& value)

Replaces existing content with the given text.


wxRichTextCtrl::SetupScrollbars

void SetupScrollbars(bool atTop = false)

A helper function setting up scrollbars, for example after a resize.


wxRichTextCtrl::ShowPosition

void ShowPosition(long pos)

Scrolls the buffer so that the given position is in view.


wxRichTextCtrl::SuppressingUndo

bool SuppressingUndo() const

Returns true if undo history suppression is on.


wxRichTextCtrl::Thaw

void Thaw()

Call this function to end a Freeze and refresh the display.


wxRichTextCtrl::Undo

void Undo()

Undoes the command at the top of the command history, if there is one.


wxRichTextCtrl::WordLeft

bool WordLeft(int noWords = 1, int flags = 0)

Moves a number of words to the left.


wxRichTextCtrl::WordRight

bool WordRight(int noWords = 1, int flags = 0)

Move a nuber of words to the right.


wxRichTextCtrl::WriteImage

bool WriteImage(const wxString& filename, int bitmapType)

Loads an image from a file and writes it at the current insertion point.

bool WriteImage(const wxRichTextImageBlock& imageBlock)

Writes an image block at the current insertion point.

bool WriteImage(const wxBitmap& bitmap, int bitmapType = wxBITMAP_TYPE_PNG)

bool WriteImage(const wxImage& image, int bitmapType = wxBITMAP_TYPE_PNG)

Write a bitmap or image at the current insertion point. Supply an optional type to use for internal and file storage of the raw data.


wxRichTextCtrl::WriteText

void WriteText(const wxString& text)

Writes text at the current position.


wxRichTextCtrl::XYToPosition

long XYToPosition(long x, long y) const

Translates from column and line number to position.