This is the base for drawable rich text objects.
See also
wx.richtext.RichTextBuffer, wx.richtext.RichTextCtrl
wx.richtext.RichTextCompositeObject, wx.richtext.RichTextImage, wx.richtext.RichTextPlainText
Constructor, taking an optional parent pointer. |
|
Returns |
|
Adjusts the attributes for virtual attribute provision, collapsed borders, etc. |
|
Returns the rectangle which the child has available to it given restrictions specified in the child attribute, e.g. |
|
Calculates the range of the object. |
|
Returns |
|
Returns |
|
Returns |
|
Clones the object. |
|
Convert units in pixels to tenths of a millimetre. |
|
Converts units in tenths of a millimetre to device units. |
|
Copies the object. |
|
Deletes the given range. |
|
Reference-counting allows us to use the same object in multiple lists (not yet used). |
|
Do a split from pos, returning an object containing the second part, and setting the first part in ‘this’. |
|
Draw the item, within the given range. |
|
Draws a border. |
|
Draws the borders and background for the given rectangle and attributes. |
|
Edits the object’s properties via a GUI. |
|
Finds the absolute position and row height for the given character position. |
|
Returns the absolute object position, by traversing up the child/parent hierarchy. |
|
Returns the object’s attributes. |
|
Calculates the available content space in the given rectangle, given the margins, border and padding specified in the object’s attributes. |
|
Returns the best size, i.e. the ideal starting size for this object irrespective of available space. |
|
Returns the bottom margin of the object, in pixels. |
|
Returns the various rectangles of the box model in pixels. |
|
Returns the containing buffer. |
|
Gets the cached object size as calculated by Layout. |
|
Returns the top-level container of this object. |
|
Returns the stored descent value. |
|
Returns the floating direction. |
|
Returns the left margin of the object, in pixels. |
|
Gets the maximum object size as calculated by Layout. |
|
Gets the minimum object size as calculated by Layout. |
|
Returns the identifying name for this object from the properties, using the “name” key. |
|
Gets the ‘natural’ size for an object. |
|
Returns the object’s own range (valid if top-level). |
|
Returns the object’s own range only if a top-level object. |
|
Returns a pointer to the parent object. |
|
Returns the top-level container of this object. |
|
Returns the object position in pixels. |
|
Returns the object’s properties. |
|
Returns the label to be used for the properties context menu item. |
|
Returns the object’s range. |
|
Returns the object size for the given range. |
|
Returns the rectangle enclosing the object. |
|
Returns the right margin of the object, in pixels. |
|
Returns a selection object specifying the selections between start and end character positions. |
|
Returns any text in this object for the given range. |
|
Returns the top margin of the object, in pixels. |
|
Returns the total margin for the object in pixels, taking into account margin, padding and border size. |
|
Returns the |
|
Returns |
|
Hit-testing: returns a flag indicating hit test details, plus information about position. |
|
Imports this object from |
|
Invalidates the object at the given range. |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Lay the item out at the specified position with the given size constraint. |
|
Lays out the object first with a given amount of space, and then if no width was specified in attr, lays out the object again using the minimum size. |
|
Returns |
|
Moves the object recursively, by adding the offset from old to new. |
|
Reference-counting allows us to use the same object in multiple lists (not yet used). |
|
Sets the object’s attributes. |
|
Sets the cached object size as calculated by Layout. |
|
Sets the stored descent value. |
|
Set the margin around the object, in pixels. |
|
Sets the maximum object size as calculated by Layout. |
|
Sets the minimum object size as calculated by Layout. |
|
Sets the identifying name for this object as a property using the “name” key. |
|
Set the object’s own range, for a top-level object with its own position space. |
|
Sets the pointer to the parent object. |
|
Sets the object position in pixels. |
|
Sets the object’s properties. |
|
Sets the object’s range within its container. |
|
Call to show or hide this object. |
|
Returns the final object in the split objects if this object was split due to differences between sub-object virtual attributes. |
|
Returns |
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
wx.richtext.
RichTextObject
(Object)¶Possible constructors:
RichTextObject(parent=None)
This is the base for drawable rich text objects.
__init__
(self, parent=None)¶Constructor, taking an optional parent pointer.
parent (wx.richtext.RichTextObject) –
AcceptsFocus
(self)¶Returns True
if objects of this class can accept the focus, i.e. a call to SetFocusObject is possible.
For example, containers supporting text, such as a text box object, can accept the focus, but a table can’t (set the focus to individual cells instead).
bool
AdjustAttributes
(self, attr, context)¶Adjusts the attributes for virtual attribute provision, collapsed borders, etc.
attr (wx.richtext.RichTextAttr) –
context (wx.richtext.RichTextDrawingContext) –
bool
AdjustAvailableSpace
(dc, buffer, parentAttr, childAttr, availableParentSpace, availableContainerSpace)¶Returns the rectangle which the child has available to it given restrictions specified in the child attribute, e.g.
50% width of the parent, 400 pixels, x position 20% of the parent, etc. availableContainerSpace might be a parent that the cell has to compute its width relative to. E.g. a cell that’s 50% of its parent.
dc (wx.DC) –
buffer (wx.richtext.RichTextBuffer) –
parentAttr (wx.richtext.RichTextAttr) –
childAttr (wx.richtext.RichTextAttr) –
availableParentSpace (wx.Rect) –
availableContainerSpace (wx.Rect) –
CalculateRange
(self, start)¶Calculates the range of the object.
By default, guess that the object is 1 unit long.
start (long) –
end
CanEditProperties
(self)¶Returns True
if we can edit the object’s properties via a GUI.
bool
CanMerge
(self, object, context)¶Returns True
if this object can merge itself with the given one.
object (wx.richtext.RichTextObject) –
context (wx.richtext.RichTextDrawingContext) –
bool
CanSplit
(self, context)¶Returns True
if this object can potentially be split, by virtue of having different virtual attributes for individual sub-objects.
context (wx.richtext.RichTextDrawingContext) –
bool
Clone
(self)¶Clones the object.
ConvertPixelsToTenthsMM
(self, *args, **kw)¶Convert units in pixels to tenths of a millimetre.
ConvertPixelsToTenthsMM (self, dc, pixels)
dc (wx.DC) –
pixels (int) –
int
ConvertPixelsToTenthsMM (ppi, pixels, scale=1.0)
ppi (int) –
pixels (int) –
scale (float) –
int
ConvertTenthsMMToPixels
(self, *args, **kw)¶Converts units in tenths of a millimetre to device units.
ConvertTenthsMMToPixels (self, dc, units)
dc (wx.DC) –
units (int) –
int
ConvertTenthsMMToPixels (ppi, units, scale=1.0)
ppi (int) –
units (int) –
scale (float) –
int
Copy
(self, obj)¶Copies the object.
obj (wx.richtext.RichTextObject) –
DeleteRange
(self, range)¶Deletes the given range.
range (wx.richtext.RichTextRange) –
bool
Dereference
(self)¶Reference-counting allows us to use the same object in multiple lists (not yet used).
DoSplit
(self, pos)¶Do a split from pos, returning an object containing the second part, and setting the first part in ‘this’.
pos (long) –
Draw
(self, dc, context, range, selection, rect, descent, style)¶Draw the item, within the given range.
Some objects may ignore the range (for example paragraphs) while others must obey it (lines, to implement wrapping)
dc (wx.DC) –
context (wx.richtext.RichTextDrawingContext) –
range (wx.richtext.RichTextRange) –
selection (wx.richtext.RichTextSelection) –
rect (wx.Rect) –
descent (int) –
style (int) –
bool
DrawBorder
(dc, buffer, attr, borders, rect, flags=0)¶Draws a border.
dc (wx.DC) –
buffer (wx.richtext.RichTextBuffer) –
attr (wx.richtext.RichTextAttr) –
borders (wx.richtext.TextAttrBorders) –
rect (wx.Rect) –
flags (int) –
bool
DrawBoxAttributes
(dc, buffer, attr, boxRect, flags=0, obj=None)¶Draws the borders and background for the given rectangle and attributes.
boxRect is taken to be the outer margin box, not the box around the content.
dc (wx.DC) –
buffer (wx.richtext.RichTextBuffer) –
attr (wx.richtext.RichTextAttr) –
boxRect (wx.Rect) –
flags (int) –
obj (wx.richtext.RichTextObject) –
bool
EditProperties
(self, parent, buffer)¶Edits the object’s properties via a GUI.
parent (wx.Window) –
buffer (wx.richtext.RichTextBuffer) –
bool
FindPosition
(self, dc, context, index, forceLineStart)¶Finds the absolute position and row height for the given character position.
dc (wx.DC) –
context (wx.richtext.RichTextDrawingContext) –
index (long) –
forceLineStart (bool) –
tuple
( bool, pt, height )
GetAbsolutePosition
(self)¶Returns the absolute object position, by traversing up the child/parent hierarchy.
TODO
: may not be needed, if all object positions are in fact relative to the top of the coordinate space.
Point
GetAttributes
(self)¶Returns the object’s attributes.
GetAvailableContentArea
(self, dc, context, outerRect)¶Calculates the available content space in the given rectangle, given the margins, border and padding specified in the object’s attributes.
dc (wx.DC) –
context (wx.richtext.RichTextDrawingContext) –
outerRect (wx.Rect) –
GetBestSize
(self)¶Returns the best size, i.e. the ideal starting size for this object irrespective of available space.
For a short text string, it will be the size that exactly encloses the text. For a longer string, it might use the parent width for example.
Size
GetBottomMargin
(self)¶Returns the bottom margin of the object, in pixels.
int
GetBoxRects
(dc, buffer, attr)¶Returns the various rectangles of the box model in pixels.
You can either specify contentRect (inner) or marginRect (outer), and the other must be the default rectangle (no width or height). Note that the outline doesn’t affect the position of the rectangle, it’s drawn in whatever space is available.
dc (wx.DC) –
buffer (wx.richtext.RichTextBuffer) –
attr (wx.richtext.RichTextAttr) –
tuple
( bool, marginRect, borderRect, contentRect, paddingRect, outlineRect )
GetBuffer
(self)¶Returns the containing buffer.
GetCachedSize
(self)¶Gets the cached object size as calculated by Layout.
Size
GetContainer
(self)¶Returns the top-level container of this object.
May return itself if it’s a container; use GetParentContainer to return a different container.
GetDescent
(self)¶Returns the stored descent value.
int
GetFloatDirection
(self)¶Returns the floating direction.
int
GetLeftMargin
(self)¶Returns the left margin of the object, in pixels.
int
GetMaxSize
(self)¶Gets the maximum object size as calculated by Layout.
This allows us to fit an object to its contents or allocate extra space if required.
Size
GetMinSize
(self)¶Gets the minimum object size as calculated by Layout.
This allows us to constrain an object to its absolute minimum size if necessary.
Size
GetName
(self)¶Returns the identifying name for this object from the properties, using the “name” key.
string
GetNaturalSize
(self)¶Gets the ‘natural’ size for an object.
For an image, it would be the image size.
GetOwnRange
(self)¶Returns the object’s own range (valid if top-level).
GetOwnRangeIfTopLevel
(self)¶Returns the object’s own range only if a top-level object.
GetParent
(self)¶Returns a pointer to the parent object.
GetParentContainer
(self)¶Returns the top-level container of this object.
Returns a different container than itself, unless there’s no parent, in which case it will return None
.
GetPosition
(self)¶Returns the object position in pixels.
Point
GetProperties
(self)¶Returns the object’s properties.
GetPropertiesMenuLabel
(self)¶Returns the label to be used for the properties context menu item.
string
GetRange
(self)¶Returns the object’s range.
GetRangeSize
(self, range, size, descent, dc, context, flags, position=Point(0, 0), parentSize=DefaultSize, partialExtents=None)¶Returns the object size for the given range.
Returns False
if the range is invalid for this object.
range (wx.richtext.RichTextRange) –
size (wx.Size) –
descent (int) –
dc (wx.DC) –
context (wx.richtext.RichTextDrawingContext) –
flags (int) –
position (wx.Point) –
parentSize (wx.Size) –
partialExtents (list of integers) –
bool
GetRightMargin
(self)¶Returns the right margin of the object, in pixels.
int
GetSelection
(self, start, end)¶Returns a selection object specifying the selections between start and end character positions.
For example, a table would deduce what cells (of range length 1) are selected when dragging across the table.
start (long) –
end (long) –
GetTextForRange
(self, range)¶Returns any text in this object for the given range.
range (wx.richtext.RichTextRange) –
string
GetTopMargin
(self)¶Returns the top margin of the object, in pixels.
int
GetTotalMargin
(dc, buffer, attr)¶Returns the total margin for the object in pixels, taking into account margin, padding and border size.
dc (wx.DC) –
buffer (wx.richtext.RichTextBuffer) –
attr (wx.richtext.RichTextAttr) –
tuple
( bool, leftMargin, rightMargin, topMargin, bottomMargin )
GetXMLNodeName
(self)¶Returns the XML
node name of this object.
This must be overridden for XmlNode-base XML
export to work.
string
HandlesChildSelections
(self)¶Returns True
if this object can handle the selections of its children, fOr example a table.
Required for composite selection handling to work.
bool
HitTest
(self, dc, context, pt, flags=0)¶Hit-testing: returns a flag indicating hit test details, plus information about position.
contextObj is returned to specify what object position is relevant to, since otherwise there’s an ambiguity. @ obj might not be a child of contextObj, since we may be referring to the container itself if we have no hit on a child - for example if we click outside an object.
The function puts the position in textPosition if one is found. pt is in logical units (a zero y position is at the beginning of the buffer).
dc (wx.DC) –
context (wx.richtext.RichTextDrawingContext) –
pt (wx.Point) –
flags (int) –
tuple
( int, textPosition, obj, contextObj )
ImportFromXML
(self, buffer, node, handler, recurse)¶Imports this object from XML
.
buffer (wx.richtext.RichTextBuffer) –
node (wx.xml.XmlNode) –
handler (wx.richtext.RichTextXMLHandler) –
recurse (bool) –
bool
Invalidate
(self, invalidRange=RICHTEXT_ALL)¶Invalidates the object at the given range.
With no argument, invalidates the whole object.
invalidRange (wx.richtext.RichTextRange) –
IsAtomic
(self)¶Returns True
if no user editing can be done inside the object.
This returns True
for simple objects, False
for most composite objects, but True
for fields, which if composite, should not be user-edited.
bool
IsComposite
(self)¶Returns True
if this object is composite.
bool
IsEmpty
(self)¶Returns True
if the object is empty.
bool
IsFloatable
(self)¶Returns True
if this class of object is floatable.
bool
IsFloating
(self)¶Returns True
if this object is currently floating.
bool
IsShown
(self)¶Returns True
if the object will be shown, False
otherwise.
bool
IsTopLevel
(self)¶Returns True
if this object is top-level, i.e. contains its own paragraphs, such as a text box.
bool
Layout
(self, dc, context, rect, parentRect, style)¶Lay the item out at the specified position with the given size constraint.
Layout must set the cached size. rect is the available space for the object, and parentRect is the container that is used to determine a relative size or position (for example if a text box must be 50% of the parent text box).
dc (wx.DC) –
context (wx.richtext.RichTextDrawingContext) –
rect (wx.Rect) –
parentRect (wx.Rect) –
style (int) –
bool
LayoutToBestSize
(self, dc, context, buffer, parentAttr, attr, availableParentSpace, availableContainerSpace, style)¶Lays out the object first with a given amount of space, and then if no width was specified in attr, lays out the object again using the minimum size.
availableParentSpace is the maximum space for the object, whereas availableContainerSpace is the container with which relative positions and sizes should be computed. For example, a text box whose space has already been constrained in a previous layout pass to availableParentSpace, but should have a width of 50% of availableContainerSpace. (If these two rects were the same, a 2nd pass could see the object getting too small.)
dc (wx.DC) –
context (wx.richtext.RichTextDrawingContext) –
buffer (wx.richtext.RichTextBuffer) –
parentAttr (wx.richtext.RichTextAttr) –
attr (wx.richtext.RichTextAttr) –
availableParentSpace (wx.Rect) –
availableContainerSpace (wx.Rect) –
style (int) –
bool
Merge
(self, object, context)¶Returns True
if this object merged itself with the given one.
The calling code will then delete the given object.
object (wx.richtext.RichTextObject) –
context (wx.richtext.RichTextDrawingContext) –
bool
Move
(self, pt)¶Moves the object recursively, by adding the offset from old to new.
pt (wx.Point) –
Reference
(self)¶Reference-counting allows us to use the same object in multiple lists (not yet used).
SetAttributes
(self, attr)¶Sets the object’s attributes.
attr (wx.richtext.RichTextAttr) –
SetCachedSize
(self, sz)¶Sets the cached object size as calculated by Layout.
sz (wx.Size) –
SetDescent
(self, descent)¶Sets the stored descent value.
descent (int) –
SetMargins
(self, *args, **kw)¶Set the margin around the object, in pixels.
SetMargins (self, margin)
margin (int) –
SetMargins (self, leftMargin, rightMargin, topMargin, bottomMargin)
leftMargin (int) –
rightMargin (int) –
topMargin (int) –
bottomMargin (int) –
SetMaxSize
(self, sz)¶Sets the maximum object size as calculated by Layout.
This allows us to fit an object to its contents or allocate extra space if required.
sz (wx.Size) –
SetMinSize
(self, sz)¶Sets the minimum object size as calculated by Layout.
This allows us to constrain an object to its absolute minimum size if necessary.
sz (wx.Size) –
SetName
(self, name)¶Sets the identifying name for this object as a property using the “name” key.
name (string) –
SetOwnRange
(self, range)¶Set the object’s own range, for a top-level object with its own position space.
range (wx.richtext.RichTextRange) –
SetParent
(self, parent)¶Sets the pointer to the parent object.
parent (wx.richtext.RichTextObject) –
SetProperties
(self, props)¶Sets the object’s properties.
props (wx.richtext.RichTextProperties) –
SetRange
(self, range)¶Sets the object’s range within its container.
range (wx.richtext.RichTextRange) –
Show
(self, show)¶Call to show or hide this object.
This function does not cause the content to be laid out or redrawn.
show (bool) –
Split
(self, context)¶Returns the final object in the split objects if this object was split due to differences between sub-object virtual attributes.
Returns itself if it was not split.
context (wx.richtext.RichTextDrawingContext) –
UsesParagraphAttributes
(self)¶Returns True
if this object takes note of paragraph attributes (text and image objects don’t).
bool
AbsolutePosition
¶Attributes
¶See GetAttributes
and SetAttributes
BestSize
¶See GetBestSize
BottomMargin
¶See GetBottomMargin
CachedSize
¶See GetCachedSize
and SetCachedSize
Container
¶See GetContainer
Descent
¶See GetDescent
and SetDescent
FloatDirection
¶LeftMargin
¶See GetLeftMargin
MaxSize
¶See GetMaxSize
and SetMaxSize
MinSize
¶See GetMinSize
and SetMinSize
NaturalSize
¶See GetNaturalSize
OwnRange
¶See GetOwnRange
and SetOwnRange
OwnRangeIfTopLevel
¶ParentContainer
¶Position
¶See GetPosition
and SetPosition
Properties
¶See GetProperties
and SetProperties
PropertiesMenuLabel
¶RightMargin
¶See GetRightMargin
TopMargin
¶See GetTopMargin
XMLNodeName
¶See GetXMLNodeName