## wxRichTextBuffer

This class represents the whole buffer associated with a wxRichTextCtrl.

Derived from

wxRichTextParagraphLayoutBox

Include files

<wx/richtext/richtextbuffer.h>

Data structures

See also

wxTextAttr, wxTextAttrEx, wxRichTextAttr, wxRichTextCtrl

Members

wxRichTextBuffer::wxRichTextBuffer
wxRichTextBuffer::~wxRichTextBuffer
wxRichTextBuffer::AddEventHandler
wxRichTextBuffer::AddHandler
wxRichTextBuffer::AddParagraph
wxRichTextBuffer::BatchingUndo
wxRichTextBuffer::BeginAlignment
wxRichTextBuffer::BeginBatchUndo
wxRichTextBuffer::BeginBold
wxRichTextBuffer::BeginCharacterStyle
wxRichTextBuffer::BeginFont
wxRichTextBuffer::BeginFontSize
wxRichTextBuffer::BeginItalic
wxRichTextBuffer::BeginLeftIndent
wxRichTextBuffer::BeginLineSpacing
wxRichTextBuffer::BeginListStyle
wxRichTextBuffer::BeginNumberedBullet
wxRichTextBuffer::BeginParagraphSpacing
wxRichTextBuffer::BeginParagraphStyle
wxRichTextBuffer::BeginRightIndent
wxRichTextBuffer::BeginStyle
wxRichTextBuffer::BeginSuppressUndo
wxRichTextBuffer::BeginStandardBullet
wxRichTextBuffer::BeginSymbolBullet
wxRichTextBuffer::BeginTextColour
wxRichTextBuffer::BeginUnderline
wxRichTextBuffer::BeginURL
wxRichTextBuffer::CanPasteFromClipboard
wxRichTextBuffer::CleanUpHandlers
wxRichTextBuffer::Clear
wxRichTextBuffer::ClearListStyle
wxRichTextBuffer::ClearStyleStack
wxRichTextBuffer::Clone
wxRichTextBuffer::Copy
wxRichTextBuffer::CopyToClipboard
wxRichTextBuffer::DeleteRangeWithUndo
wxRichTextBuffer::Dump
wxRichTextBuffer::EndAlignment
wxRichTextBuffer::EndAllStyles
wxRichTextBuffer::EndBatchUndo
wxRichTextBuffer::EndBold
wxRichTextBuffer::EndCharacterStyle
wxRichTextBuffer::EndFont
wxRichTextBuffer::EndFontSize
wxRichTextBuffer::EndItalic
wxRichTextBuffer::EndLeftIndent
wxRichTextBuffer::EndLineSpacing
wxRichTextBuffer::EndListStyle
wxRichTextBuffer::EndNumberedBullet
wxRichTextBuffer::EndParagraphSpacing
wxRichTextBuffer::EndParagraphStyle
wxRichTextBuffer::EndRightIndent
wxRichTextBuffer::EndStyle
wxRichTextBuffer::EndSuppressUndo
wxRichTextBuffer::EndSymbolBullet
wxRichTextBuffer::EndStandardBullet
wxRichTextBuffer::EndTextColour
wxRichTextBuffer::EndUnderline
wxRichTextBuffer::EndURL
wxRichTextBuffer::FindHandler
wxRichTextBuffer::FindHandlerFilenameOrType
wxRichTextBuffer::GetBasicStyle
wxRichTextBuffer::GetBatchedCommand
wxRichTextBuffer::GetCommandProcessor
wxRichTextBuffer::GetDefaultStyle
wxRichTextBuffer::GetExtWildcard
wxRichTextBuffer::GetHandlers
wxRichTextBuffer::GetRenderer
wxRichTextBuffer::GetStyle
wxRichTextBuffer::GetStyleForRange
wxRichTextBuffer::GetStyleSheet
wxRichTextBuffer::GetStyleStackSize
wxRichTextBuffer::GetUncombinedStyle
wxRichTextBuffer::HitTest
wxRichTextBuffer::Init
wxRichTextBuffer::InitStandardHandlers
wxRichTextBuffer::InsertHandler
wxRichTextBuffer::InsertImageWithUndo
wxRichTextBuffer::InsertNewlineWithUndo
wxRichTextBuffer::InsertTextWithUndo
wxRichTextBuffer::IsModified
wxRichTextBuffer::LoadFile
wxRichTextBuffer::Modify
wxRichTextBuffer::NumberList
wxRichTextBuffer::PasteFromClipboard
wxRichTextBuffer::PromoteList
wxRichTextBuffer::RemoveEventHandler
wxRichTextBuffer::RemoveHandler
wxRichTextBuffer::ResetAndClearCommands
wxRichTextBuffer::SaveFile
wxRichTextBuffer::SetBasicStyle
wxRichTextBuffer::SetDefaultStyle
wxRichTextBuffer::SetListStyle
wxRichTextBuffer::SetRenderer
wxRichTextBuffer::SetStyle
wxRichTextBuffer::SetStyleSheet
wxRichTextBuffer::SubmitAction
wxRichTextBuffer::SuppressingUndo

### wxRichTextBuffer::wxRichTextBuffer

wxRichTextBuffer(const wxRichTextBuffer& obj)

Copy constructor.

wxRichTextBuffer()

Default constructors.

### wxRichTextBuffer::~wxRichTextBuffer

~wxRichTextBuffer()

Destructor.

### wxRichTextBuffer::AddEventHandler

bool AddEventHandler(wxEvtHandler* handler)

Adds an event handler to the buffer's list of handlers. A buffer associated with a contol has the control as the only event handler, but the application is free to add more if further notification is required. All handlers are notified of an event originating from the buffer, such as the replacement of a style sheet during loading. The buffer never deletes any of the event handlers, unless wxRichTextBuffer::RemoveEventHandler is called with `true` as the second argument.

### wxRichTextBuffer::AddHandler

void AddHandler(wxRichTextFileHandler* handler)

Adds a file handler.

### wxRichTextBuffer::AddParagraph

wxRichTextRange AddParagraph(const wxString& text)

Adds a paragraph of text.

### wxRichTextBuffer::BatchingUndo

bool BatchingUndo() const

Returns `true` if the buffer is currently collapsing commands into a single notional command.

### wxRichTextBuffer::BeginAlignment

bool BeginAlignment(wxTextAttrAlignment alignment)

Begins using alignment.

### wxRichTextBuffer::BeginBatchUndo

bool BeginBatchUndo(const wxString& cmdName)

Begins collapsing undo/redo commands. Note that this may not work properly if combining commands that delete or insert content, changing ranges for subsequent actions.

cmdName should be the name of the combined command that will appear next to Undo and Redo in the edit menu.

### wxRichTextBuffer::BeginBold

bool BeginBold()

Begin applying bold.

### wxRichTextBuffer::BeginCharacterStyle

bool BeginCharacterStyle(const wxString& characterStyle)

Begins applying the named character style.

### wxRichTextBuffer::BeginFont

bool BeginFont(const wxFont& font)

Begins using this font.

### wxRichTextBuffer::BeginFontSize

bool BeginFontSize(int pointSize)

Begins using the given point size.

### wxRichTextBuffer::BeginItalic

bool BeginItalic()

Begins using italic.

### wxRichTextBuffer::BeginLeftIndent

bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0)

Begin using leftIndent for the left indent, and optionally leftSubIndent for the sub-indent. Both are expressed 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::BeginLineSpacing

bool BeginLineSpacing(int lineSpacing)

Begins line spacing using the specified value. 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

### wxRichTextBuffer::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.

### wxRichTextBuffer::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.

### wxRichTextBuffer::BeginParagraphSpacing

bool BeginParagraphSpacing(int before, int after)

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

### wxRichTextBuffer::BeginParagraphStyle

bool BeginParagraphStyle(const wxString& paragraphStyle)

Begins applying the named paragraph style.

### wxRichTextBuffer::BeginRightIndent

bool BeginRightIndent(int rightIndent)

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

### wxRichTextBuffer::BeginStyle

bool BeginStyle(const wxTextAttrEx& style)

Begins using a specified style.

### wxRichTextBuffer::BeginSuppressUndo

bool BeginSuppressUndo()

Begins suppressing undo/redo commands. The way undo is suppressed may be implemented differently by each command. If not dealt with by a command implementation, then it will be implemented automatically by not storing the command in the undo history when the action is submitted to the command processor.

### wxRichTextBuffer::BeginStandardBullet

bool BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD)

Begins applying a standard bullet, using one of the standard bullet names (currently `standard/circle` or `standard/square`. See BeginNumberedBullet for an explanation of how indentation is used to render the bulleted paragraph.

### wxRichTextBuffer::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.

### wxRichTextBuffer::BeginTextColour

bool BeginTextColour(const wxColour& colour)

Begins using the specified text foreground colour.

### wxRichTextBuffer::BeginUnderline

bool BeginUnderline()

Begins using underline.

### wxRichTextBuffer::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.

### wxRichTextBuffer::CanPasteFromClipboard

bool CanPasteFromClipboard() const

Returns `true` if content can be pasted from the clipboard.

### wxRichTextBuffer::CleanUpHandlers

void CleanUpHandlers()

Cleans up the file handlers.

### wxRichTextBuffer::Clear

void Clear()

Clears the buffer.

### wxRichTextBuffer::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:

- wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.

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

### wxRichTextBuffer::ClearStyleStack

void ClearStyleStack()

Clears the style stack.

### wxRichTextBuffer::Clone

wxRichTextObject* Clone() const

Clones the object.

### wxRichTextBuffer::Copy

void Copy(const wxRichTextBuffer& obj)

Copies the given buffer.

### wxRichTextBuffer::CopyToClipboard

bool CopyToClipboard(const wxRichTextRange& range)

Copy the given range to the clipboard.

### wxRichTextBuffer::DeleteRangeWithUndo

bool DeleteRangeWithUndo(const wxRichTextRange& range, wxRichTextCtrl* ctrl)

Submits a command to delete the given range.

### wxRichTextBuffer::Dump

void Dump()

void Dump(wxTextOutputStream& stream)

Dumps the contents of the buffer for debugging purposes.

### wxRichTextBuffer::EndAlignment

bool EndAlignment()

Ends alignment.

### wxRichTextBuffer::EndAllStyles

bool EndAllStyles()

Ends all styles that have been started with a Begin... command.

### wxRichTextBuffer::EndBatchUndo

bool EndBatchUndo()

Ends collapsing undo/redo commands, and submits the combined command.

### wxRichTextBuffer::EndBold

bool EndBold()

Ends using bold.

### wxRichTextBuffer::EndCharacterStyle

bool EndCharacterStyle()

Ends using the named character style.

### wxRichTextBuffer::EndFont

bool EndFont()

Ends using a font.

### wxRichTextBuffer::EndFontSize

bool EndFontSize()

Ends using a point size.

### wxRichTextBuffer::EndItalic

bool EndItalic()

Ends using italic.

### wxRichTextBuffer::EndLeftIndent

bool EndLeftIndent()

Ends using a left indent.

### wxRichTextBuffer::EndLineSpacing

bool EndLineSpacing()

Ends using a line spacing.

### wxRichTextBuffer::EndListStyle

bool EndListStyle()

Ends using a specified list style.

### wxRichTextBuffer::EndNumberedBullet

bool EndNumberedBullet()

Ends a numbered bullet.

### wxRichTextBuffer::EndParagraphSpacing

bool EndParagraphSpacing()

Ends paragraph spacing.

### wxRichTextBuffer::EndParagraphStyle

bool EndParagraphStyle()

Ends applying a named character style.

### wxRichTextBuffer::EndRightIndent

bool EndRightIndent()

Ends using a right indent.

### wxRichTextBuffer::EndStyle

bool EndStyle()

Ends the current style.

### wxRichTextBuffer::EndSuppressUndo

bool EndSuppressUndo()

Ends suppressing undo/redo commands.

### wxRichTextBuffer::EndSymbolBullet

bool EndSymbolBullet()

Ends using a symbol bullet.

### wxRichTextBuffer::EndStandardBullet

bool EndStandardBullet()

Ends using a standard bullet.

### wxRichTextBuffer::EndTextColour

bool EndTextColour()

Ends using a text foreground colour.

### wxRichTextBuffer::EndUnderline

bool EndUnderline()

Ends using underline.

### wxRichTextBuffer::EndURL

bool EndURL()

Ends applying a URL.

### wxRichTextBuffer::FindHandler

wxRichTextFileHandler* FindHandler(int imageType)

Finds a handler by type.

wxRichTextFileHandler* FindHandler(const wxString& extension, int imageType)

Finds a handler by extension and type.

wxRichTextFileHandler* FindHandler(const wxString& name)

Finds a handler by name.

### wxRichTextBuffer::FindHandlerFilenameOrType

wxRichTextFileHandler* FindHandlerFilenameOrType(const wxString& filename, int imageType)

Finds a handler by filename or, if supplied, type.

### wxRichTextBuffer::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).

### wxRichTextBuffer::GetBatchedCommand

wxRichTextCommand* GetBatchedCommand() const

Gets the collapsed command.

### wxRichTextBuffer::GetCommandProcessor

wxCommandProcessor* GetCommandProcessor() const

Gets the command processor. A text buffer always creates its own command processor when it is initialized.

### wxRichTextBuffer::GetDefaultStyle

const wxTextAttrEx& GetDefaultStyle() const

Returns the current default style, affecting the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold).

### wxRichTextBuffer::GetExtWildcard

wxString GetExtWildcard(bool combine = false, bool save = false, wxArrayInt* types = NULL)

Gets a wildcard incorporating all visible handlers. If types is present, it will be filled with the file type corresponding to each filter. This can be used to determine the type to pass to LoadFile given a selected filter.

### wxRichTextBuffer::GetHandlers

wxList& GetHandlers()

Returns the list of file handlers.

### wxRichTextBuffer::GetRenderer

static wxRichTextRenderer* GetRenderer()

Returns the object to be used to render certain aspects of the content, such as bullets.

### wxRichTextBuffer::GetStyle

bool GetStyle(long position, wxRichTextAttr& style)

bool GetStyle(long position, wxTextAttrEx& style)

Gets the attributes at the given position.

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.

### wxRichTextBuffer::GetStyleForRange

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

This function gets a style representing the common, combined attributes in the given range. Attributes which have different values within the specified range will not be included the style flags.

The function is used to get the attributes to display in the formatting dialog: the user can edit the attributes common to the selection, and optionally specify the values of further attributes to be applied uniformly.

To apply the edited attributes, you can use SetStyle specifying the wxRICHTEXT_SETSTYLE_OPTIMIZE flag, which will only apply attributes that are different from the combined attributes within the range. So, the user edits the effective, displayed attributes for the range, but his choice won't be applied unnecessarily to content. As an example, say the style for a paragraph specifies bold, but the paragraph text doesn't specify a weight. The combined style is bold, and this is what the user will see on-screen and in the formatting dialog. The user now specifies red text, in addition to bold. When applying with SetStyle, the content font weight attributes won't be changed to bold because this is already specified by the paragraph. However the text colour attributes will be changed to show red.

### wxRichTextBuffer::GetStyleSheet

wxRichTextStyleSheet* GetStyleSheet() const

Returns the current style sheet associated with the buffer, if any.

### wxRichTextBuffer::GetStyleStackSize

size_t GetStyleStackSize() const

Get the size of the style stack, for example to check correct nesting.

### wxRichTextBuffer::GetUncombinedStyle

bool GetUncombinedStyle(long position, wxRichTextAttr& style)

bool GetUncombinedStyle(long position, wxTextAttrEx& style)

Gets the attributes at the given position.

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.

### wxRichTextBuffer::HitTest

int HitTest(wxDC& dc, const wxPoint& pt, long& textPosition)

Finds the text position for the given position, putting the position in textPosition if one is found. pt is in logical units (a zero y position is at the beginning of the buffer).

The function returns one of the following values:

    // The point was not on this object
    #define wxRICHTEXT_HITTEST_NONE     0x01
    // The point was before the position returned from HitTest
    #define wxRICHTEXT_HITTEST_BEFORE   0x02
    // The point was after the position returned from HitTest
    #define wxRICHTEXT_HITTEST_AFTER    0x04
    // The point was on the position returned from HitTest
    #define wxRICHTEXT_HITTEST_ON       0x08
    // The point was on space outside content
    #define wxRICHTEXT_HITTEST_OUTSIDE  0x10

### wxRichTextBuffer::Init

void Init()

Initialisation.

### wxRichTextBuffer::InitStandardHandlers

void InitStandardHandlers()

Initialises the standard handlers. Currently, only the plain text loading/saving handler is initialised by default.

### wxRichTextBuffer::InsertHandler

void InsertHandler(wxRichTextFileHandler* handler)

Inserts a handler at the front of the list.

### wxRichTextBuffer::InsertImageWithUndo

bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl)

Submits a command to insert the given image.

### wxRichTextBuffer::InsertNewlineWithUndo

bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl)

Submits a command to insert a newline.

### wxRichTextBuffer::InsertTextWithUndo

bool InsertTextWithUndo(long pos, const wxString& text, wxRichTextCtrl* ctrl)

Submits a command to insert the given text.

### wxRichTextBuffer::IsModified

bool IsModified() const

Returns `true` if the buffer has been modified.

### wxRichTextBuffer::LoadFile

bool LoadFile(wxInputStream& stream, int type = wxRICHTEXT_TYPE_ANY)

Loads content from a stream.

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

Loads content from a file.

### wxRichTextBuffer::Modify

void Modify(bool modify = true)

Marks the buffer as modified or unmodified.

### wxRichTextBuffer::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:

- wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
- wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from startFrom, otherwise existing attributes are used.
- wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.

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

### wxRichTextBuffer::PasteFromClipboard

bool PasteFromClipboard(long position)

Pastes the clipboard content to the buffer at the given position.

### wxRichTextBuffer::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:

- wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
- wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from startFrom, otherwise existing attributes are used.
- wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.

See also wxRichTextBuffer::SetListStyle, See also wxRichTextBuffer::SetListStyle, wxRichTextBuffer::ClearListStyle.

### wxRichTextBuffer::RemoveEventHandler

bool RemoveEventHandler(wxEvtHandler* handler, bool deleteHandler = false)

Removes an event handler from the buffer's list of handlers, deleting the object if deleteHandler is `true`.

### wxRichTextBuffer::RemoveHandler

bool RemoveHandler(const wxString& name)

Removes a handler.

### wxRichTextBuffer::ResetAndClearCommands

void ResetAndClearCommands()

Clears the buffer, adds a new blank paragraph, and clears the command history.

### wxRichTextBuffer::SaveFile

bool SaveFile(wxOutputStream& stream, int type = wxRICHTEXT_TYPE_ANY)

Saves content to a stream.

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

Saves content to a file.

### wxRichTextBuffer::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).

### wxRichTextBuffer::SetDefaultStyle

void SetDefaultStyle(const wxTextAttrEx& style)

Sets the default style, affecting the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold).

This is not cumulative - setting the default style will replace the previous default style.

### wxRichTextBuffer::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:

- wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
- wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from startFrom, otherwise existing attributes are used.
- wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.

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

### wxRichTextBuffer::SetRenderer

static void SetRenderer(wxRichTextRenderer* renderer)

Sets renderer as the object to be used to render certain aspects of the content, such as bullets. You can override default rendering by deriving a new class from wxRichTextRenderer or wxRichTextStdRenderer, overriding one or more virtual functions, and setting an instance of the class using this function.

### wxRichTextBuffer::SetStyle

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

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

Sets the attributes for the given range. Pass flags to determine how the attributes are set.

The end point of range is specified as the last character position of the span of text. So, for example, to set the style for a character at position 5, use the range (5,5). This differs from the wxRichTextCtrl API, where you would specify (5,6).

flags may contain a bit list of the following values:

- wxRICHTEXT_SETSTYLE_NONE: no style flag.
- wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be undoable.
- wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied if the combined style at this point is already the style in question.
- wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be applied to paragraphs, and not the content. This allows content styling to be preserved independently from that of e.g. a named paragraph style.
- wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be applied to characters, and not the paragraph. This allows content styling to be preserved independently from that of e.g. a named paragraph style.
- wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying the new style.
- wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags are used in this operation.

### wxRichTextBuffer::SetStyleSheet

void SetStyleSheet(wxRichTextStyleSheet* styleSheet)

Sets the current style sheet, if any. This will allow the application to use named character and paragraph styles found in the style sheet.

### wxRichTextBuffer::SubmitAction

bool SubmitAction(wxRichTextAction* action)

Submit an action immediately, or delay it according to whether collapsing is on.

### wxRichTextBuffer::SuppressingUndo

bool SuppressingUndo() const

Returns `true` if undo suppression is currently on.