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::AddHandler
wxRichTextBuffer::AddParagraph
wxRichTextBuffer::BatchingUndo
wxRichTextBuffer::BeginAlignment
wxRichTextBuffer::BeginBatchUndo
wxRichTextBuffer::BeginBold
wxRichTextBuffer::BeginCharacterStyle
wxRichTextBuffer::BeginFont
wxRichTextBuffer::BeginFontSize
wxRichTextBuffer::BeginItalic
wxRichTextBuffer::BeginLeftIndent
wxRichTextBuffer::BeginLineSpacing
wxRichTextBuffer::BeginNumberedBullet
wxRichTextBuffer::BeginParagraphSpacing
wxRichTextBuffer::BeginParagraphStyle
wxRichTextBuffer::BeginRightIndent
wxRichTextBuffer::BeginStyle
wxRichTextBuffer::BeginSuppressUndo
wxRichTextBuffer::BeginSymbolBullet
wxRichTextBuffer::BeginTextColour
wxRichTextBuffer::BeginUnderline
wxRichTextBuffer::CanPasteFromClipboard
wxRichTextBuffer::CleanUpHandlers
wxRichTextBuffer::Clear
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::EndNumberedBullet
wxRichTextBuffer::EndParagraphSpacing
wxRichTextBuffer::EndParagraphStyle
wxRichTextBuffer::EndRightIndent
wxRichTextBuffer::EndStyle
wxRichTextBuffer::EndSuppressUndo
wxRichTextBuffer::EndSymbolBullet
wxRichTextBuffer::EndTextColour
wxRichTextBuffer::EndUnderline
wxRichTextBuffer::FindHandler
wxRichTextBuffer::FindHandlerFilenameOrType
wxRichTextBuffer::GetBatchedCommand
wxRichTextBuffer::GetCommandProcessor
wxRichTextBuffer::GetExtWildcard
wxRichTextBuffer::GetHandlers
wxRichTextBuffer::GetStyleSheet
wxRichTextBuffer::GetStyleStackSize
wxRichTextBuffer::HitTest
wxRichTextBuffer::Init
wxRichTextBuffer::InitStandardHandlers
wxRichTextBuffer::InsertHandler
wxRichTextBuffer::InsertImageWithUndo
wxRichTextBuffer::InsertNewlineWithUndo
wxRichTextBuffer::InsertTextWithUndo
wxRichTextBuffer::IsModified
wxRichTextBuffer::LoadFile
wxRichTextBuffer::Modify
wxRichTextBuffer::PasteFromClipboard
wxRichTextBuffer::RemoveHandler
wxRichTextBuffer::Reset
wxRichTextBuffer::SaveFile
wxRichTextBuffer::SetStyleSheet
wxRichTextBuffer::SubmitAction
wxRichTextBuffer::SuppressingUndo
wxRichTextBuffer(const wxRichTextBuffer& obj)
Copy constructor.
wxRichTextBuffer()
Default constructors.
~wxRichTextBuffer()
Destructor.
void AddHandler(wxRichTextFileHandler* handler)
Adds a file handler.
wxRichTextRange AddParagraph(const wxString& text)
Adds a paragraph of text.
bool BatchingUndo() const
Returns true if the buffer is currently collapsing commands into a single notional command.
bool BeginAlignment(wxTextAttrAlignment alignment)
Begins using alignment.
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.
bool BeginBold()
Begin applying bold.
bool BeginCharacterStyle(const wxString& characterStyle)
Begins applying the named character style.
bool BeginFont(const wxFont& font)
Begins using this font.
bool BeginFontSize(int pointSize)
Begins using the given point size.
bool BeginItalic()
Begins using italic.
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.
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
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 0x0000
#define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x0001
#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x0002
#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x0004
#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x0008
#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x0010
#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x0020
#define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x0040
#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x0080
#define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x0100
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.
bool BeginParagraphSpacing(int before, int after)
Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing in tenths of a millimetre.
bool BeginParagraphStyle(const wxString& paragraphStyle)
Begins applying the named paragraph style.
bool BeginRightIndent(int rightIndent)
Begins a right indent, specified in tenths of a millimetre.
bool BeginStyle(const wxTextAttrEx& style)
Begins using a specified style.
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.
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.
bool BeginTextColour(const wxColour& colour)
Begins using the specified text foreground colour.
bool BeginUnderline()
Begins using underline.
bool CanPasteFromClipboard() const
Returns true if content can be pasted from the clipboard.
void CleanUpHandlers()
Cleans up the file handlers.
void Clear()
Clears the buffer and resets the command processor.
void ClearStyleStack()
Clears the style stack.
wxRichTextObject* Clone() const
Clones the object.
void Copy(const wxRichTextBuffer& obj)
Copies the given buffer.
bool CopyToClipboard(const wxRichTextRange& range)
Copy the given range to the clipboard.
bool DeleteRangeWithUndo(const wxRichTextRange& range, long initialCaretPosition, long newCaretPositon, wxRichTextCtrl* ctrl)
Submits a command to delete the given range.
void Dump()
void Dump(wxTextOutputStream& stream)
Dumps the contents of the buffer for debugging purposes.
bool EndAlignment()
Ends alignment.
bool EndAllStyles()
Ends all styles that have been started with a Begin... command.
bool EndBatchUndo()
Ends collapsing undo/redo commands, and submits the combined command.
bool EndBold()
Ends using bold.
bool EndCharacterStyle()
Ends using the named character style.
bool EndFont()
Ends using a font.
bool EndFontSize()
Ends using a point size.
bool EndItalic()
Ends using italic.
bool EndLeftIndent()
Ends using a left indent.
bool EndLineSpacing()
Ends using a line spacing.
bool EndNumberedBullet()
Ends a numbered bullet.
bool EndParagraphSpacing()
Ends paragraph spacing.
bool EndParagraphStyle()
Ends applying a named character style.
bool EndRightIndent()
Ends using a right indent.
bool EndStyle()
Ends the current style.
bool EndSuppressUndo()
Ends suppressing undo/redo commands.
bool EndSymbolBullet()
Ends using a symbol bullet.
bool EndTextColour()
Ends using a text foreground colour.
bool EndUnderline()
Ends using underline.
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.
wxRichTextFileHandler* FindHandlerFilenameOrType(const wxString& filename, int imageType)
Finds a handler by filename or, if supplied, type.
wxRichTextCommand* GetBatchedCommand() const
Gets the collapsed command.
wxCommandProcessor* GetCommandProcessor() const
Gets the command processor. A text buffer always creates its own command processor when it is initialized.
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.
wxList& GetHandlers()
Returns the list of file handlers.
wxRichTextStyleSheet* GetStyleSheet() const
Returns the current style sheet associated with the buffer, if any.
size_t GetStyleStackSize() const
Get the size of the style stack, for example to check correct nesting.
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
void Init()
Initialisation.
void InitStandardHandlers()
Initialises the standard handlers. Currently, only the plain text loading/saving handler is initialised by default.
void InsertHandler(wxRichTextFileHandler* handler)
Inserts a handler at the front of the list.
bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl)
Submits a command to insert the given image.
bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl)
Submits a command to insert a newline.
bool InsertTextWithUndo(long pos, const wxString& text, wxRichTextCtrl* ctrl)
Submits a command to insert the given text.
bool IsModified() const
Returns true if the buffer has been modified.
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.
void Modify(bool modify = true)
Marks the buffer as modified or unmodified.
bool PasteFromClipboard(long position)
Pastes the clipboard content to the buffer at the given position.
bool RemoveHandler(const wxString& name)
Removes a handler.
void Reset()
The same as Clear, plus an empty paragraph is added.
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.
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.
bool SubmitAction(wxRichTextAction* action)
Submit an action immediately, or delay it according to whether collapsing is on.
bool SuppressingUndo() const
Returns true if undo suppression is currently on.