wx.richtext.RichTextBuffer

Inheritance diagram for wx.richtext.RichTextBuffer:



Description

This class represents the whole buffer associated with a wx.richtext.RichTextCtrl.

Methods Summary

Class API

Methods

__init__()

This is a kind of box, used to represent the whole buffer.


Returns:

wx.richtext.RichTextBuffer


AddEventHandler(handler)

Adds an event handler to the buffer’s list of handlers.

A buffer associated with a control 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 RemoveEventHandler is called with True as the second argument.

Parameters:


Returns:

bool


AddHandler(handler)

Adds a file handler.

Parameters:


BatchingUndo()

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


Returns:

bool


BeginAlignment(alignment)

Begins using alignment.

Parameters:

  • alignment (int)

Returns:

bool


BeginBatchUndo(cmdName)

Begins collapsing undo/redo commands.

Parameters:

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

Returns:

bool

Note

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


BeginBold()

Begin applying bold.


Returns:

bool


BeginCharacterStyle(characterStyle)

Begins applying the named character style.

Parameters:

  • characterStyle (string)

Returns:

bool


BeginFont(font)

Begins using this font.

Parameters:


Returns:

bool


BeginFontSize(pointSize)

Begins using the given point size.

Parameters:

  • pointSize (int)

Returns:

bool


BeginItalic()

Begins using italic.


Returns:

bool


BeginLeftIndent(leftIndent, 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.

Parameters:

  • leftIndent (int)
  • leftSubIndent (int)

Returns:

bool


BeginLineSpacing(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:

Line Spacing Flags Value
wx.richtext.TEXT_ATTR_LINE_SPACING_NORMAL 10
wx.richtext.TEXT_ATTR_LINE_SPACING_HALF 15
wx.richtext.TEXT_ATTR_LINE_SPACING_TWICE 20

Parameters:

  • lineSpacing (int)

Returns:

bool


BeginListStyle(listStyle, level=1, number=1)

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

Parameters:

  • listStyle (string)
  • level (int)
  • number (int)

Returns:

bool


BeginNumberedBullet(bulletNumber, leftIndent, leftSubIndent, bulletStyle=wx.richtext.TEXT_ATTR_BULLET_STYLE_ARABIC | wx.richtext.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.

Parameters:

  • bulletNumber (int): Is a number, usually starting with 1.

  • leftIndent (int): Value in tenths of a millimetre.

  • leftSubIndent (int): Value in tenths of a millimetre.

  • bulletStyle (int): A bitlist of the following values:

    Bullet Style Flags

    Value

    wx.richtext.TEXT_ATTR_BULLET_STYLE_NONE

    0x00000000

    wx.richtext.TEXT_ATTR_BULLET_STYLE_ARABIC

    0x00000001

    wx.richtext.TEXT_ATTR_BULLET_STYLE_LETTERS_UPPER

    0x00000002

    wx.richtext.TEXT_ATTR_BULLET_STYLE_LETTERS_LOWER

    0x00000004

    wx.richtext.TEXT_ATTR_BULLET_STYLE_ROMAN_UPPER

    0x00000008

    wx.richtext.TEXT_ATTR_BULLET_STYLE_ROMAN_LOWER

    0x00000010

    wx.richtext.TEXT_ATTR_BULLET_STYLE_SYMBOL

    0x00000020

    wx.richtext.TEXT_ATTR_BULLET_STYLE_BITMAP

    0x00000040

    wx.richtext.TEXT_ATTR_BULLET_STYLE_PARENTHESES

    0x00000080

    wx.richtext.TEXT_ATTR_BULLET_STYLE_PERIOD

    0x00000100

    wx.richtext.TEXT_ATTR_BULLET_STYLE_STANDARD

    0x00000200

    wx.richtext.TEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS

    0x00000400

    wx.richtext.TEXT_ATTR_BULLET_STYLE_OUTLINE

    0x00000800

    wx.richtext.TEXT_ATTR_BULLET_STYLE_ALIGN_LEFT

    0x00000000

    wx.richtext.TEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT

    0x00001000

    wx.richtext.TEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE

    0x00002000

    Of these, wx.richtext.TEXT_ATTR_BULLET_STYLE_BITMAP is unimplemented.

wx.richtext.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.


Returns:

bool


BeginParagraphSpacing(before, after)

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

Parameters:

  • before (int)
  • after (int)

Returns:

bool


BeginParagraphStyle(paragraphStyle)

Begins applying the named paragraph style.

Parameters:

  • paragraphStyle (string)

Returns:

bool


BeginRightIndent(rightIndent)

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

Parameters:

  • rightIndent (int)

Returns:

bool


BeginStandardBullet(bulletName, leftIndent, leftSubIndent, bulletStyle=wx.richtext.TEXT_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.

Parameters:

  • bulletName (string)
  • leftIndent (int)
  • leftSubIndent (int)
  • bulletStyle (int)

Returns:

bool


BeginStyle(style)

Begins using a specified style.

Parameters:


Returns:

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.


Returns:

bool


BeginSymbolBullet(symbol, leftIndent, leftSubIndent, bulletStyle=wx.richtext.TEXT_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.

Parameters:

  • symbol (string)
  • leftIndent (int)
  • leftSubIndent (int)
  • bulletStyle (int)

Returns:

bool


BeginTextColour(colour)

Begins using the specified text foreground colour.

Parameters:


Returns:

bool


BeginURL(url, characterStyle="")

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

Parameters:

  • url (string)
  • characterStyle (string)

Returns:

bool


BeginUnderline()

Begins using underline.


Returns:

bool


CanPasteFromClipboard()

Returns True if content can be pasted from the clipboard.


Returns:

bool


CleanUpHandlers()
Cleans up the file handlers.

ClearEventHandlers()
No docstrings available for this method.

ClearStyleStack()
Clears the style stack.

Copy(obj)

Clones the object.

Parameters:


CopyToClipboard(range)

Copy the given range to the clipboard.

Parameters:


Returns:

bool


DeleteRangeWithUndo(range, ctrl)

Submits a command to delete the given range.

Parameters:


Returns:

bool


EndAlignment()

Ends alignment.


Returns:

bool


EndAllStyles()

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


Returns:

bool


EndBatchUndo()

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


Returns:

bool


EndBold()

Ends using bold.


Returns:

bool


EndCharacterStyle()

Ends using the named character style.


Returns:

bool


EndFont()

Ends using a font.


Returns:

bool


EndFontSize()

Ends using a point size.


Returns:

bool


EndItalic()

Ends using italic.


Returns:

bool


EndLeftIndent()

Ends using a left indent.


Returns:

bool


EndLineSpacing()

Ends using a line spacing.


Returns:

bool


EndListStyle()

Ends using a specified list style.


Returns:

bool


EndNumberedBullet()

Ends a numbered bullet.


Returns:

bool


EndParagraphSpacing()

Ends paragraph spacing.


Returns:

bool


EndParagraphStyle()

Ends applying a named character style.


Returns:

bool


EndRightIndent()

Ends using a right indent.


Returns:

bool


EndStandardBullet()

Ends using a standard bullet.


Returns:

bool


EndStyle()

Ends the current style.


Returns:

bool


EndSuppressUndo()

Ends suppressing undo/redo commands.


Returns:

bool


EndSymbolBullet()

Ends using a symbol bullet.


Returns:

bool


EndTextColour()

Ends using a text foreground colour.


Returns:

bool


EndURL()

Ends applying a URL.


Returns:

bool


EndUnderline()

Ends using underline.


Returns:

bool


FindHandlerByExtension(extension, imageType)

Finds a handler by extension and type.

Parameters:

  • extension (string)
  • imageType (int)

Returns:

wx.richtext.RichTextFileHandler


FindHandlerByFilename(filename, imageType)

Finds a handler by name and type.

Parameters:

  • filename (string)
  • imageType (int)

Returns:

wx.richtext.RichTextFileHandler


FindHandlerByName(name)

Finds a handler by name.

Parameters:

  • name (string)

Returns:

wx.richtext.RichTextFileHandler


FindHandlerByType(imageType)

Finds a handler by type.

Parameters:

  • imageType (int)

Returns:

wx.richtext.RichTextFileHandler


GetBatchedCommand()

Gets the collapsed command.


Returns:

wxRichTextCommand


GetBulletProportion()
No docstrings available for this method.

GetBulletRightMargin()
No docstrings available for this method.

GetCommandProcessor()

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


Returns:

wx.CommandProcessor


GetExtWildcard(combine=False, save=False, types=None)

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.

Parameters:

  • combine (bool)
  • save (bool)
  • types (list of integers)

Returns:

string


GetHandlerFlags()
No docstrings available for this method.

GetHandlers()

Returns the list of file handlers.


Returns:

list of strings


GetRenderer()

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


Returns:

wx.richtext.RichTextRenderer


GetScale()
No docstrings available for this method.

GetStyleForNewParagraph(pos, caretPosition=False, lookUpNewParaStyle=False)

Parameters:

  • pos (long)
  • caretPosition (bool)
  • lookUpNewParaStyle (bool)

Returns:

wx.richtext.TextAttrEx


GetStyleStackSize()

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


Returns:

long


HitTest(dc, pt, 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:

HitTest Flags Value – Description
wx.richtext.RICHTEXT_HITTEST_NONE 0x01 – The point was not on this object
wx.richtext.RICHTEXT_HITTEST_BEFORE 0x02 – The point was before the position returned from HitTest
wx.richtext.RICHTEXT_HITTEST_AFTER 0x04 – The point was after the position returned from HitTest
wx.richtext.RICHTEXT_HITTEST_ON 0x08 – The point was on the position returned from HitTest
wx.richtext.RICHTEXT_HITTEST_OUTSIDE 0x10 – The point was on space outside content

Returns:

int


InitStandardHandlers()

Initialises the standard handlers.

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


InsertHandler(handler)

Inserts a handler at the front of the list.

Parameters:


InsertImageWithUndo(pos, imageBlock, ctrl)

Submits a command to insert the given image.

Parameters:


Returns:

bool


InsertNewlineWithUndo(pos, ctrl)

Submits a command to insert a newline.

Parameters:


Returns:

bool


InsertParagraphsWithUndo(pos, paragraphs, ctrl, flags=0)

Submits a command to insert a new paragraph.

Parameters:


Returns:

bool


InsertTextWithUndo(pos, text, ctrl)

Submits a command to insert the given text.

Parameters:


Returns:

bool


IsModified()

Returns True if the buffer has been modified.


Returns:

bool


LoadFile(filename, type=wx.richtext.RICHTEXT_TYPE_ANY)

Loads content from a file.

Parameters:

  • filename (string)
  • type (int)

Returns:

bool


LoadStream(stream, type=wx.richtext.RICHTEXT_TYPE_ANY)

Load content from a text stream.

Parameters:


Returns:

bool


Modify(modify=True)

Marks the buffer as modified or unmodified.

Parameters:

  • modify (bool)

PasteFromClipboard(position)

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

Parameters:

  • position (long)

Returns:

bool


PopStyleSheet()
No docstrings available for this method.

PushStyleSheet(styleSheet)

Parameters:


Returns:

bool


RemoveEventHandler(handler, deleteHandler=False)

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

Parameters:


Returns:

bool


RemoveHandler(name)

Removes a handler.

Parameters:

  • name (string)

Returns:

bool


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

SaveFile(filename, type=wx.richtext.RICHTEXT_TYPE_ANY)

Saves content to a file.

Parameters:

  • filename (string)
  • type (int)

Returns:

bool


SaveStream(stream, type=wx.richtext.RICHTEXT_TYPE_ANY)

Saves content to a string stream.

Parameters:


Returns:

bool


SendEvent(event, sendToAll=True)

Parameters:


Returns:

bool


SetBulletProportion(prop)

Parameters:

  • prop (float)

SetBulletRightMargin(margin)

Parameters:

  • margin (int)

SetHandlerFlags(flags)

Parameters:

  • flags (int)

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

Parameters:

  • renderer (wx.richtext.RichTextRenderer)

SetScale(scale)

Parameters:

  • scale (double)

SetStyleSheet(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.

Parameters:


SetStyleSheetAndNotify(sheet)

Parameters:


Returns:

bool


SubmitAction(action)

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

Parameters:

  • action (wx.richtext.RichTextAction)

Returns:

bool


SuppressingUndo()

Returns True if undo suppression is currently on.


Returns:

bool