wxrichtextbufferthis 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::wxrichtextbufferwxrichtextbuffer(const wxrichtextbuffer& obj) copy constructor. wxrichtextbuffer() default constructors.
wxrichtextbuffer::~wxrichtextbuffer~wxrichtextbuffer() destructor.
wxrichtextbuffer::addeventhandlerbool 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::addhandlervoid addhandler(wxrichtextfilehandler* handler) adds a file handler.
wxrichtextbuffer::addparagraphwxrichtextrange addparagraph(const wxstring& text) adds a paragraph of text.
wxrichtextbuffer::batchingundobool batchingundo() const returns true if the buffer is currently collapsing commands into a single notional command.
wxrichtextbuffer::beginalignmentbool beginalignment(wxtextattralignment alignment) begins using alignment.
wxrichtextbuffer::beginbatchundobool 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::beginboldbool beginbold() begin applying bold.
wxrichtextbuffer::begincharacterstylebool begincharacterstyle(const wxstring& characterstyle) begins applying the named character style.
wxrichtextbuffer::beginfontbool beginfont(const wxfont& font) begins using this font.
wxrichtextbuffer::beginfontsizebool beginfontsize(int pointsize) begins using the given point size.
wxrichtextbuffer::beginitalicbool beginitalic() begins using italic.
wxrichtextbuffer::beginleftindentbool 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::beginlinespacingbool 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:
wxrichtextbuffer::beginliststylebool 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::beginnumberedbulletbool 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:
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::beginparagraphspacingbool beginparagraphspacing(int before, int after) begins paragraph spacing; pass the before-paragraph and after-paragraph spacing in tenths of a millimetre.
wxrichtextbuffer::beginparagraphstylebool beginparagraphstyle(const wxstring& paragraphstyle) begins applying the named paragraph style.
wxrichtextbuffer::beginrightindentbool beginrightindent(int rightindent) begins a right indent, specified in tenths of a millimetre.
wxrichtextbuffer::beginstylebool beginstyle(const wxtextattrex& style) begins using a specified style.
wxrichtextbuffer::beginsuppressundobool 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::beginstandardbulletbool 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::beginsymbolbulletbool 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::begintextcolourbool begintextcolour(const wxcolour& colour) begins using the specified text foreground colour.
wxrichtextbuffer::beginunderlinebool beginunderline() begins using underline.
wxrichtextbuffer::beginurlbool 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::canpastefromclipboardbool canpastefromclipboard() const returns true if content can be pasted from the clipboard.
wxrichtextbuffer::cleanuphandlersvoid cleanuphandlers() cleans up the file handlers.
wxrichtextbuffer::clearvoid clear() clears the buffer.
wxrichtextbuffer::clearliststylebool 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 wxrichtextbuffer::setliststyle, wxrichtextbuffer::promotelist, wxrichtextbuffer::numberlist.
wxrichtextbuffer::clearstylestackvoid clearstylestack() clears the style stack.
wxrichtextbuffer::clonewxrichtextobject* clone() const clones the object.
wxrichtextbuffer::copyvoid copy(const wxrichtextbuffer& obj) copies the given buffer.
wxrichtextbuffer::copytoclipboardbool copytoclipboard(const wxrichtextrange& range) copy the given range to the clipboard.
wxrichtextbuffer::deleterangewithundobool deleterangewithundo(const wxrichtextrange& range, wxrichtextctrl* ctrl) submits a command to delete the given range.
wxrichtextbuffer::dumpvoid dump() void dump(wxtextoutputstream& stream) dumps the contents of the buffer for debugging purposes.
wxrichtextbuffer::endalignmentbool endalignment() ends alignment.
wxrichtextbuffer::endallstylesbool endallstyles() ends all styles that have been started with a begin... command.
wxrichtextbuffer::endbatchundobool endbatchundo() ends collapsing undo/redo commands, and submits the combined command.
wxrichtextbuffer::endboldbool endbold() ends using bold.
wxrichtextbuffer::endcharacterstylebool endcharacterstyle() ends using the named character style.
wxrichtextbuffer::endfontbool endfont() ends using a font.
wxrichtextbuffer::endfontsizebool endfontsize() ends using a point size.
wxrichtextbuffer::enditalicbool enditalic() ends using italic.
wxrichtextbuffer::endleftindentbool endleftindent() ends using a left indent.
wxrichtextbuffer::endlinespacingbool endlinespacing() ends using a line spacing.
wxrichtextbuffer::endliststylebool endliststyle() ends using a specified list style.
wxrichtextbuffer::endnumberedbulletbool endnumberedbullet() ends a numbered bullet.
wxrichtextbuffer::endparagraphspacingbool endparagraphspacing() ends paragraph spacing.
wxrichtextbuffer::endparagraphstylebool endparagraphstyle() ends applying a named character style.
wxrichtextbuffer::endrightindentbool endrightindent() ends using a right indent.
wxrichtextbuffer::endstylebool endstyle() ends the current style.
wxrichtextbuffer::endsuppressundobool endsuppressundo() ends suppressing undo/redo commands.
wxrichtextbuffer::endsymbolbulletbool endsymbolbullet() ends using a symbol bullet.
wxrichtextbuffer::endstandardbulletbool endstandardbullet() ends using a standard bullet.
wxrichtextbuffer::endtextcolourbool endtextcolour() ends using a text foreground colour.
wxrichtextbuffer::endunderlinebool endunderline() ends using underline.
wxrichtextbuffer::endurlbool endurl() ends applying a url.
wxrichtextbuffer::findhandlerwxrichtextfilehandler* 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::findhandlerfilenameortypewxrichtextfilehandler* findhandlerfilenameortype(const wxstring& filename, int imagetype) finds a handler by filename or, if supplied, type.
wxrichtextbuffer::getbasicstyleconst 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::getbatchedcommandwxrichtextcommand* getbatchedcommand() const gets the collapsed command.
wxrichtextbuffer::getcommandprocessorwxcommandprocessor* getcommandprocessor() const gets the command processor. a text buffer always creates its own command processor when it is initialized.
wxrichtextbuffer::getdefaultstyleconst 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::getextwildcardwxstring 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::gethandlerswxlist& gethandlers() returns the list of file handlers.
wxrichtextbuffer::getrendererstatic wxrichtextrenderer* getrenderer() returns the object to be used to render certain aspects of the content, such as bullets.
wxrichtextbuffer::getstylebool 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::getstyleforrangebool 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::getstylesheetwxrichtextstylesheet* getstylesheet() const returns the current style sheet associated with the buffer, if any.
wxrichtextbuffer::getstylestacksizesize_t getstylestacksize() const get the size of the style stack, for example to check correct nesting.
wxrichtextbuffer::getuncombinedstylebool 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::hittestint 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:
wxrichtextbuffer::initvoid init() initialisation.
wxrichtextbuffer::initstandardhandlersvoid initstandardhandlers() initialises the standard handlers. currently, only the plain text loading/saving handler is initialised by default.
wxrichtextbuffer::inserthandlervoid inserthandler(wxrichtextfilehandler* handler) inserts a handler at the front of the list.
wxrichtextbuffer::insertimagewithundobool insertimagewithundo(long pos, const wxrichtextimageblock& imageblock, wxrichtextctrl* ctrl) submits a command to insert the given image.
wxrichtextbuffer::insertnewlinewithundobool insertnewlinewithundo(long pos, wxrichtextctrl* ctrl) submits a command to insert a newline.
wxrichtextbuffer::inserttextwithundobool inserttextwithundo(long pos, const wxstring& text, wxrichtextctrl* ctrl) submits a command to insert the given text.
wxrichtextbuffer::ismodifiedbool ismodified() const returns true if the buffer has been modified.
wxrichtextbuffer::loadfilebool 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::modifyvoid modify(bool modify = true) marks the buffer as modified or unmodified.
wxrichtextbuffer::numberlistbool 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 wxrichtextbuffer::setliststyle, wxrichtextbuffer::promotelist, wxrichtextbuffer::clearliststyle.
wxrichtextbuffer::pastefromclipboardbool pastefromclipboard(long position) pastes the clipboard content to the buffer at the given position.
wxrichtextbuffer::promotelistbool 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 wxrichtextbuffer::setliststyle, see also wxrichtextbuffer::setliststyle, wxrichtextbuffer::clearliststyle.
wxrichtextbuffer::removeeventhandlerbool 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::removehandlerbool removehandler(const wxstring& name) removes a handler.
wxrichtextbuffer::resetandclearcommandsvoid resetandclearcommands() clears the buffer, adds a new blank paragraph, and clears the command history.
wxrichtextbuffer::savefilebool 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::setbasicstylevoid 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::setdefaultstylevoid 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::setliststylebool 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 wxrichtextbuffer::numberlist, wxrichtextbuffer::promotelist, wxrichtextbuffer::clearliststyle.
wxrichtextbuffer::setrendererstatic 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::setstylebool 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:
wxrichtextbuffer::setstylesheetvoid 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::submitactionbool submitaction(wxrichtextaction* action) submit an action immediately, or delay it according to whether collapsing is on.
wxrichtextbuffer::suppressingundobool suppressingundo() const returns true if undo suppression is currently on.
|