wxRuby Documentation Home

Wx::RichTextBuffer

This class represents the whole buffer associated with a RichTextCtrl.

Derived from

RichTextParagraphLayoutBox

Data structures

See also

TextAttr, RichTextAttr, RichTextCtrl

Methods

RichTextBuffer.new

RichTextBuffer.new(RichTextBuffer obj)

Copy constructor.

destructor()

Destructor.

RichTextBuffer#add_event_handler

Boolean add_event_handler(EvtHandler 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 RichTextBuffer#remove_event_handler is called with as the second argument.

RichTextBuffer#add_handler

add_handler(RichTextFileHandler handler)

Adds a file handler.

RichTextBuffer#add_paragraph

Range add_paragraph(String text)

Adds a paragraph of text.

RichTextBuffer#batching_undo

Boolean batching_undo()

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

RichTextBuffer#begin_alignment

Boolean begin_alignment(TextAttrAlignment alignment)

Begins using alignment.

RichTextBuffer#begin_batch_undo

Boolean begin_batch_undo(String 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.

RichTextBuffer#begin_bold

Boolean begin_bold()

Begin applying bold.

RichTextBuffer#begin_character_style

Boolean begin_character_style(String characterStyle)

Begins applying the named character style.

RichTextBuffer#begin_font

Boolean begin_font(Font font)

Begins using this font.

RichTextBuffer#begin_font_size

Boolean begin_font_size(Integer pointSize)

Begins using the given point size.

RichTextBuffer#begin_italic

Boolean begin_italic()

Begins using italic.

RichTextBuffer#begin_left_indent

Boolean begin_left_indent(Integer leftIndent,  Integer 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.

RichTextBuffer#begin_line_spacing

Boolean begin_line_spacing(Integer 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 TEXT_ATTR_LINE_SPACING_NORMAL         10
#define TEXT_ATTR_LINE_SPACING_HALF           15
#define TEXT_ATTR_LINE_SPACING_TWICE          20

RichTextBuffer#begin_list_style

Boolean begin_list_style(String listStyle,  Integer level=1, 
                         Integer number=1)

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

RichTextBuffer#begin_numbered_bullet

Boolean begin_numbered_bullet(Integer bulletNumber,  Integer leftIndent, 
                              Integer leftSubIndent, 
                              Integer bulletStyle = TEXT_ATTR_BULLET_STYLE_ARABIC|TEXT_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 TEXT_ATTR_BULLET_STYLE_NONE               0x00000000
#define TEXT_ATTR_BULLET_STYLE_ARABIC             0x00000001
#define TEXT_ATTR_BULLET_STYLE_LETTERS_UPPER      0x00000002
#define TEXT_ATTR_BULLET_STYLE_LETTERS_LOWER      0x00000004
#define TEXT_ATTR_BULLET_STYLE_ROMAN_UPPER        0x00000008
#define TEXT_ATTR_BULLET_STYLE_ROMAN_LOWER        0x00000010
#define TEXT_ATTR_BULLET_STYLE_SYMBOL             0x00000020
#define TEXT_ATTR_BULLET_STYLE_BITMAP             0x00000040
#define TEXT_ATTR_BULLET_STYLE_PARENTHESES        0x00000080
#define TEXT_ATTR_BULLET_STYLE_PERIOD             0x00000100
#define TEXT_ATTR_BULLET_STYLE_STANDARD           0x00000200
#define TEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS  0x00000400
#define TEXT_ATTR_BULLET_STYLE_OUTLINE            0x00000800
#define TEXT_ATTR_BULLET_STYLE_ALIGN_LEFT         0x00000000
#define TEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT        0x00001000
#define TEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE       0x00002000

RichTextBuffer 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.

RichTextBuffer#begin_paragraph_spacing

Boolean begin_paragraph_spacing(Integer before,  Integer after)

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

RichTextBuffer#begin_paragraph_style

Boolean begin_paragraph_style(String paragraphStyle)

Begins applying the named paragraph style.

RichTextBuffer#begin_right_indent

Boolean begin_right_indent(Integer rightIndent)

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

RichTextBuffer#begin_style

Boolean begin_style(RichTextAttr style)

Begins using a specified style.

RichTextBuffer#begin_suppress_undo

Boolean begin_suppress_undo()

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.

RichTextBuffer#begin_standard_bullet

Boolean begin_standard_bullet(String bulletName,  Integer leftIndent, 
                              Integer leftSubIndent, 
                              Integer bulletStyle = TEXT_ATTR_BULLET_STYLE_STANDARD)

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

RichTextBuffer#begin_symbol_bullet

Boolean begin_symbol_bullet(Char symbol,  Integer leftIndent, 
                            Integer leftSubIndent, 
                            Integer bulletStyle = TEXT_ATTR_BULLET_STYLE_SYMBOL)

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

RichTextBuffer#begin_text_colour

Boolean begin_text_colour(Colour colour)

Begins using the specified text foreground colour.

RichTextBuffer#begin_underline

Boolean begin_underline()

Begins using underline.

RichTextBuffer#begin_url

Boolean begin_url(String url,  String characterStyle = '')

Begins applying TEXT_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.

RichTextBuffer#can_paste_from_clipboard

Boolean can_paste_from_clipboard()

Returns if content can be pasted from the clipboard.

RichTextBuffer#clean_up_handlers

clean_up_handlers()

Cleans up the file handlers.

RichTextBuffer#clear

clear()

Clears the buffer.

RichTextBuffer#clear_list_style

Boolean clear_list_style(Range range, 
                         Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO)
Boolean clear_list_style(Range range, 
                         Integer flags $=$ RICHTEXT_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 RichTextBuffer#set_list_style, RichTextBuffer#promote_list, RichTextBuffer#number_list.

RichTextBuffer#clear_style_stack

clear_style_stack()

Clears the style stack.

RichTextBuffer#clone

RichTextObject clone()

Clones the object.

RichTextBuffer#copy

copy(RichTextBuffer obj)

Copies the given buffer.

RichTextBuffer#copy_to_clipboard

Boolean copy_to_clipboard(Range range)

Copy the given range to the clipboard.

RichTextBuffer#delete_range_with_undo

Boolean delete_range_with_undo(Range range, 
                               RichTextCtrl ctrl)

Submits a command to delete the given range.

RichTextBuffer#dump

dump()
dump(TextOutputStream stream)

Dumps the contents of the buffer for debugging purposes.

RichTextBuffer#end_alignment

Boolean end_alignment()

Ends alignment.

RichTextBuffer#end_all_styles

Boolean end_all_styles()

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

RichTextBuffer#end_batch_undo

Boolean end_batch_undo()

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

RichTextBuffer#end_bold

Boolean end_bold()

Ends using bold.

RichTextBuffer#end_character_style

Boolean end_character_style()

Ends using the named character style.

RichTextBuffer#end_font

Boolean end_font()

Ends using a font.

RichTextBuffer#end_font_size

Boolean end_font_size()

Ends using a point size.

RichTextBuffer#end_italic

Boolean end_italic()

Ends using italic.

RichTextBuffer#end_left_indent

Boolean end_left_indent()

Ends using a left indent.

RichTextBuffer#end_line_spacing

Boolean end_line_spacing()

Ends using a line spacing.

RichTextBuffer#end_list_style

Boolean end_list_style()

Ends using a specified list style.

RichTextBuffer#end_numbered_bullet

Boolean end_numbered_bullet()

Ends a numbered bullet.

RichTextBuffer#end_paragraph_spacing

Boolean end_paragraph_spacing()

Ends paragraph spacing.

RichTextBuffer#end_paragraph_style

Boolean end_paragraph_style()

Ends applying a named character style.

RichTextBuffer#end_right_indent

Boolean end_right_indent()

Ends using a right indent.

RichTextBuffer#end_style

Boolean end_style()

Ends the current style.

RichTextBuffer#end_suppress_undo

Boolean end_suppress_undo()

Ends suppressing undo/redo commands.

RichTextBuffer#end_symbol_bullet

Boolean end_symbol_bullet()

Ends using a symbol bullet.

RichTextBuffer#end_standard_bullet

Boolean end_standard_bullet()

Ends using a standard bullet.

RichTextBuffer#end_text_colour

Boolean end_text_colour()

Ends using a text foreground colour.

RichTextBuffer#end_underline

Boolean end_underline()

Ends using underline.

RichTextBuffer#end_url

Boolean end_url()

Ends applying a URL.

RichTextBuffer#find_handler

RichTextFileHandler find_handler(Integer imageType)

Finds a handler by type.

RichTextFileHandler find_handler(String extension, 
                                   Integer imageType)

Finds a handler by extension and type.

RichTextFileHandler find_handler(String name)

Finds a handler by name.

RichTextBuffer#find_handler_filename_or_type

RichTextFileHandler find_handler_filename_or_type(String filename, 
                                                    Integer imageType)

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

RichTextBuffer#get_basic_style

RichTextAttr get_basic_style()

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).

RichTextBuffer#get_batched_command

RichTextCommand get_batched_command()

Gets the collapsed command.

RichTextBuffer#get_command_processor

CommandProcessor get_command_processor()

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

RichTextBuffer#get_default_style

RichTextAttr get_default_style()

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).

RichTextBuffer#get_ext_wildcard

String get_ext_wildcard(Boolean combine = false,  Boolean save = false, 
                        ArrayInt types = nil)

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 load_file given a selected filter.

RichTextBuffer#get_handlers

List get_handlers()

Returns the list of file handlers.

RichTextBuffer#get_renderer

RichTextRenderer get_renderer()

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

RichTextBuffer#get_style

RichTextAttr get_style(Integer position)

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 get_uncombined_style.

RichTextBuffer#get_style_for_range

RichTextAttr get_style_for_range(Range range)

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 set_style specifying the RICHTEXT_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.

RichTextBuffer#get_style_sheet

RichTextStyleSheet get_style_sheet()

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

RichTextBuffer#get_style_stack_size

size_t get_style_stack_size()

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

RichTextBuffer#get_uncombined_style

RichTextAttr  get_uncombined_style(Integer position)

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 get_style.

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

RichTextBuffer#hit_test

Integer hit_test(DC dc,      Point pt, 
                 Integer 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 RICHTEXT_HITTEST_NONE     0x01
// The point was before the position returned from HitTest
#define RICHTEXT_HITTEST_BEFORE   0x02
// The point was after the position returned from HitTest
#define RICHTEXT_HITTEST_AFTER    0x04
// The point was on the position returned from HitTest
#define RICHTEXT_HITTEST_ON       0x08
// The point was on space outside content
#define RICHTEXT_HITTEST_OUTSIDE  0x10

RichTextBuffer#init

init()

Initialisation.

RichTextBuffer#init_standard_handlers

init_standard_handlers()

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

RichTextBuffer#insert_handler

insert_handler(RichTextFileHandler handler)

Inserts a handler at the front of the list.

RichTextBuffer#insert_image_with_undo

Boolean insert_image_with_undo(Integer pos, 
                               RichTextImageBlock imageBlock, 
                               RichTextCtrl ctrl)

Submits a command to insert the given image.

RichTextBuffer#insert_newline_with_undo

Boolean insert_newline_with_undo(Integer pos, 
                                 RichTextCtrl ctrl)

Submits a command to insert a newline.

RichTextBuffer#insert_text_with_undo

Boolean insert_text_with_undo(Integer pos,  String text, 
                              RichTextCtrl ctrl)

Submits a command to insert the given text.

RichTextBuffer#is_modified

Boolean is_modified()

Returns if the buffer has been modified.

RichTextBuffer#load_file

Boolean load_file(InputStream stream, 
                  Integer type = RICHTEXT_TYPE_ANY)

Loads content from a stream.

Boolean load_file(String filename,  Integer type = RICHTEXT_TYPE_ANY)

Loads content from a file.

RichTextBuffer#modify

modify(Boolean modify = true)

Marks the buffer as modified or unmodified.

RichTextBuffer#number_list

Boolean number_list(Range range, 
                    RichTextListStyleDefinition style, 
                    Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO,  Integer startFrom = -1,  Integer listLevel = -1)
Boolean number(Range range,  String styleName, 
               Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, 
               Integer startFrom = -1, 
               Integer 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 RichTextBuffer#set_list_style, RichTextBuffer#promote_list, RichTextBuffer#clear_list_style.

RichTextBuffer#paste_from_clipboard

Boolean paste_from_clipboard(Integer position)

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

RichTextBuffer#promote_list

Boolean promote_list(Integer promoteBy,  Range range, 
                     RichTextListStyleDefinition style, 
                     Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, 
                     Integer listLevel = -1)
Boolean promote_list(Integer promoteBy,  Range range, 
                     String styleName, 
                     Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, 
                     Integer 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 RichTextBuffer#set_list_style, See also RichTextBuffer#set_list_style, RichTextBuffer#clear_list_style.

RichTextBuffer#remove_event_handler

Boolean remove_event_handler(EvtHandler handler, 
                             Boolean deleteHandler = false)

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

RichTextBuffer#remove_handler

Boolean remove_handler(String name)

Removes a handler.

RichTextBuffer#reset_and_clear_commands

reset_and_clear_commands()

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

RichTextBuffer#save_file

Boolean save_file(OutputStream stream, 
                  Integer type = RICHTEXT_TYPE_ANY)

Saves content to a stream.

Boolean save_file(String filename,  Integer type = RICHTEXT_TYPE_ANY)

Saves content to a file.

RichTextBuffer#set_basic_style

set_basic_style(RichTextAttr 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).

RichTextBuffer#set_default_style

set_default_style(RichTextAttr 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.

RichTextBuffer#set_list_style

Boolean set_list_style(Range range, 
                       RichTextListStyleDefinition style, 
                       Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO,  Integer startFrom = -1,  Integer listLevel = -1)
Boolean set_list_style(Range range,  String styleName, 
                       Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, 
                       Integer startFrom = -1, 
                       Integer 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 RichTextBuffer#number_list, RichTextBuffer#promote_list, RichTextBuffer#clear_list_style.

RichTextBuffer#set_renderer

set_renderer(RichTextRenderer 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 RichTextRenderer or RichTextStdRenderer, overriding one or more virtual functions, and setting an instance of the class using this function.

RichTextBuffer#set_style

Boolean set_style(Range range,  RichTextAttr style, 
                  Integer flags = RICHTEXT_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 RichTextCtrl API, where you would specify (5,6).

flags may contain a bit list of the following values:

RichTextBuffer#set_style_sheet

set_style_sheet(RichTextStyleSheet 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.

RichTextBuffer#submit_action

Boolean submit_action(RichTextAction action)

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

RichTextBuffer#suppressing_undo

Boolean suppressing_undo()

Returns if undo suppression is currently on.

[This page automatically generated from the Textile source at Wed Sep 09 02:21:20 +0100 2009]