.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.richtext.RichTextParagraph:
==========================================================================================================================================
|phoenix_title| **wx.richtext.RichTextParagraph**
==========================================================================================================================================
This object represents a single paragraph containing various objects such as text content, images, and further paragraph layout objects.
.. seealso:: :ref:`wx.richtext.RichTextBuffer`, :ref:`wx.richtext.RichTextCtrl`
|
|class_hierarchy| Class Hierarchy
=================================
.. raw:: html

Inheritance diagram for class
RichTextParagraph:
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.richtext.RichTextParagraph.__init__` Constructor taking a parent and style.
:meth:`~wx.richtext.RichTextParagraph.AllocateLine` Allocates or reuses a line object.
:meth:`~wx.richtext.RichTextParagraph.ApplyParagraphStyle` Applies paragraph styles such as centering to the wrapped lines.
:meth:`~wx.richtext.RichTextParagraph.CalculateRange` Calculates the range of the object.
:meth:`~wx.richtext.RichTextParagraph.ClearDefaultTabs` Clears the default tabstop array.
:meth:`~wx.richtext.RichTextParagraph.ClearLines` Clears the cached lines.
:meth:`~wx.richtext.RichTextParagraph.ClearUnusedLines` Clears remaining unused line objects, if any.
:meth:`~wx.richtext.RichTextParagraph.Clone` Clones the object.
:meth:`~wx.richtext.RichTextParagraph.Copy` Copies the object.
:meth:`~wx.richtext.RichTextParagraph.Draw` Draw the item, within the given range.
:meth:`~wx.richtext.RichTextParagraph.FindObjectAtPosition` Finds the object at the given position.
:meth:`~wx.richtext.RichTextParagraph.FindPosition` Finds the absolute position and row height for the given character position.
:meth:`~wx.richtext.RichTextParagraph.FindWrapPosition` Finds a suitable wrap position.
:meth:`~wx.richtext.RichTextParagraph.GetBulletText` Returns the bullet text for this paragraph.
:meth:`~wx.richtext.RichTextParagraph.GetCombinedAttributes` Returns combined attributes of the base style, paragraph style and character style.
:meth:`~wx.richtext.RichTextParagraph.GetContiguousPlainText` Returns the plain text searching from the start or end of the range.
:meth:`~wx.richtext.RichTextParagraph.GetDefaultTabs` Returns the default tabstop array.
:meth:`~wx.richtext.RichTextParagraph.GetFirstLineBreakPosition` Returns the first position from pos that has a line break character.
:meth:`~wx.richtext.RichTextParagraph.GetImpactedByFloatingObjects` Whether the paragraph is impacted by floating objects from above.
:meth:`~wx.richtext.RichTextParagraph.GetLines` Returns the cached lines.
:meth:`~wx.richtext.RichTextParagraph.GetRangeSize` Returns the object size for the given range.
:meth:`~wx.richtext.RichTextParagraph.GetXMLNodeName` Returns the ``XML`` node name of this object.
:meth:`~wx.richtext.RichTextParagraph.HitTest` Hit-testing: returns a flag indicating hit test details, plus information about position.
:meth:`~wx.richtext.RichTextParagraph.Init`
:meth:`~wx.richtext.RichTextParagraph.InitDefaultTabs` Creates a default tabstop array.
:meth:`~wx.richtext.RichTextParagraph.InsertText` Inserts text at the given position.
:meth:`~wx.richtext.RichTextParagraph.Layout` Lay the item out at the specified position with the given size constraint.
:meth:`~wx.richtext.RichTextParagraph.LayoutFloat` Lays out the floating objects.
:meth:`~wx.richtext.RichTextParagraph.MoveFromList` Adds content back from a list.
:meth:`~wx.richtext.RichTextParagraph.MoveToList` Moves content to a list from this point.
:meth:`~wx.richtext.RichTextParagraph.SetImpactedByFloatingObjects` Sets whether the paragraph is impacted by floating objects from above.
:meth:`~wx.richtext.RichTextParagraph.SplitAt` Splits an object at this position if necessary, and returns the previous object, or ``None`` if inserting at the beginning.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.richtext.RichTextParagraph.BulletText` See :meth:`~wx.richtext.RichTextParagraph.GetBulletText`
:attr:`~wx.richtext.RichTextParagraph.CombinedAttributes` See :meth:`~wx.richtext.RichTextParagraph.GetCombinedAttributes`
:attr:`~wx.richtext.RichTextParagraph.ImpactedByFloatingObjects` See :meth:`~wx.richtext.RichTextParagraph.GetImpactedByFloatingObjects` and :meth:`~wx.richtext.RichTextParagraph.SetImpactedByFloatingObjects`
:attr:`~wx.richtext.RichTextParagraph.Lines` See :meth:`~wx.richtext.RichTextParagraph.GetLines`
:attr:`~wx.richtext.RichTextParagraph.XMLNodeName` See :meth:`~wx.richtext.RichTextParagraph.GetXMLNodeName`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.richtext.RichTextParagraph(RichTextCompositeObject)
**Possible constructors**::
RichTextParagraph(parent: Optional[RichTextObject]=None, style:
Optional[RichTextAttr]=None) -> None
RichTextParagraph(text : str, parent: Optional[RichTextObject]=None,
paraStyle: Optional[RichTextAttr]=None, charStyle:
Optional[RichTextAttr]=None) -> None
RichTextParagraph(obj : RichTextParagraph) -> None
This object represents a single paragraph containing various objects
such as text content, images, and further paragraph layout objects.
.. method:: __init__(self, *args, **kw)
|overload| **Overloaded Implementations:**
:html:`
`
**__init__** `(self, parent: Optional[RichTextObject]=None, style: Optional[RichTextAttr]=None)`
Constructor taking a parent and style.
:param `parent`:
:type `parent`: wx.richtext.RichTextObject
:param `style`:
:type `style`: wx.richtext.RichTextAttr
:rtype: `None`
:html:`
`
**__init__** `(self, text : str, parent: Optional[RichTextObject]=None, paraStyle: Optional[RichTextAttr]=None, charStyle: Optional[RichTextAttr]=None)`
Constructor taking a text string, a parent and paragraph and character attributes.
:param `text`:
:type `text`: string
:param `parent`:
:type `parent`: wx.richtext.RichTextObject
:param `paraStyle`:
:type `paraStyle`: wx.richtext.RichTextAttr
:param `charStyle`:
:type `charStyle`: wx.richtext.RichTextAttr
:rtype: `None`
:html:`
`
**__init__** `(self, obj : RichTextParagraph)`
:param `obj`:
:type `obj`: wx.richtext.RichTextParagraph
:rtype: `None`
:html:`
`
.. method:: AllocateLine(self, pos : int)
Allocates or reuses a line object.
:param `pos`:
:type `pos`: int
:rtype: :ref:`wx.richtext.RichTextLine`
.. method:: ApplyParagraphStyle(self, line : RichTextLine, attr : RichTextAttr, rect : Rect, dc : DC)
Applies paragraph styles such as centering to the wrapped lines.
:param `line`:
:type `line`: wx.richtext.RichTextLine
:param `attr`:
:type `attr`: wx.richtext.RichTextAttr
:param `rect`:
:type `rect`: wx.Rect
:param `dc`:
:type `dc`: wx.DC
:rtype: `None`
.. method:: CalculateRange(self, start : int)
Calculates the range of the object.
By default, guess that the object is 1 unit long.
:param `start`:
:type `start`: long
:rtype: `int`
.. staticmethod:: ClearDefaultTabs()
Clears the default tabstop array.
:rtype: `None`
.. method:: ClearLines(self)
Clears the cached lines.
:rtype: `None`
.. method:: ClearUnusedLines(self, lineCount : int)
Clears remaining unused line objects, if any.
:param `lineCount`:
:type `lineCount`: int
:rtype: `bool`
.. method:: Clone(self)
Clones the object.
:rtype: :ref:`wx.richtext.RichTextObject`
.. method:: Copy(self, obj : RichTextParagraph)
Copies the object.
:param `obj`:
:type `obj`: wx.richtext.RichTextParagraph
:rtype: `None`
.. method:: Draw(self, dc : DC, context : RichTextDrawingContext, range : RichTextRange, selection : RichTextSelection, rect : Rect, descent : int, style : int)
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)
:param `dc`:
:type `dc`: wx.DC
:param `context`:
:type `context`: wx.richtext.RichTextDrawingContext
:param `range`:
:type `range`: wx.richtext.RichTextRange
:param `selection`:
:type `selection`: wx.richtext.RichTextSelection
:param `rect`:
:type `rect`: wx.Rect
:param `descent`:
:type `descent`: int
:param `style`:
:type `style`: int
:rtype: `bool`
.. method:: FindObjectAtPosition(self, position : int)
Finds the object at the given position.
:param `position`:
:type `position`: long
:rtype: :ref:`wx.richtext.RichTextObject`
.. method:: FindPosition(self, dc : DC, context : RichTextDrawingContext, index : int, forceLineStart : bool)
Finds the absolute position and row height for the given character position.
:param `dc`:
:type `dc`: wx.DC
:param `context`:
:type `context`: wx.richtext.RichTextDrawingContext
:param `index`:
:type `index`: long
:param `forceLineStart`:
:type `forceLineStart`: bool
:rtype: :ref:`le[bool, wx.Point, int]`
.. method:: FindWrapPosition(self, range : RichTextRange, dc : DC, context : RichTextDrawingContext, availableSpace : int, wrapPosition : int, partialExtents : List[int])
Finds a suitable wrap position.
`wrapPosition` is the last position in the line to the left of the split.
:param `range`:
:type `range`: wx.richtext.RichTextRange
:param `dc`:
:type `dc`: wx.DC
:param `context`:
:type `context`: wx.richtext.RichTextDrawingContext
:param `availableSpace`:
:type `availableSpace`: int
:param `wrapPosition`:
:type `wrapPosition`: long
:param `partialExtents`:
:type `partialExtents`: list of integers
:rtype: `bool`
.. method:: GetBulletText(self)
Returns the bullet text for this paragraph.
:rtype: `str`
.. method:: GetCombinedAttributes(self, *args, **kw)
|overload| **Overloaded Implementations:**
:html:`
`
**GetCombinedAttributes** `(self, contentStyle : RichTextAttr, includingBoxAttr: bool=False)`
Returns combined attributes of the base style, paragraph style and character style.
We use this to dynamically retrieve the actual style.
:param `contentStyle`:
:type `contentStyle`: wx.richtext.RichTextAttr
:param `includingBoxAttr`:
:type `includingBoxAttr`: bool
:rtype: :ref:`wx.richtext.RichTextAttr`
:html:`
`
**GetCombinedAttributes** `(self, includingBoxAttr: bool=False)`
Returns the combined attributes of the base style and paragraph style.
:param `includingBoxAttr`:
:type `includingBoxAttr`: bool
:rtype: :ref:`wx.richtext.RichTextAttr`
:html:`
`
.. method:: GetContiguousPlainText(self, text : str, range : RichTextRange, fromStart: bool=True)
Returns the plain text searching from the start or end of the range.
The resulting string may be shorter than the range given.
:param `text`:
:type `text`: string
:param `range`:
:type `range`: wx.richtext.RichTextRange
:param `fromStart`:
:type `fromStart`: bool
:rtype: `bool`
.. staticmethod:: GetDefaultTabs()
Returns the default tabstop array.
:rtype: `List[int]`
.. method:: GetFirstLineBreakPosition(self, pos : int)
Returns the first position from pos that has a line break character.
:param `pos`:
:type `pos`: long
:rtype: `int`
.. method:: GetImpactedByFloatingObjects(self)
Whether the paragraph is impacted by floating objects from above.
:rtype: `int`
.. method:: GetLines(self)
Returns the cached lines.
:rtype: `Any`
.. method:: GetRangeSize(self, range : RichTextRange, size : Size, descent : int, dc : DC, context : RichTextDrawingContext, flags : int, position: Point=Point(0,0), parentSize: Size=DefaultSize, partialExtents: Optional[List[int]]=None)
Returns the object size for the given range.
Returns ``False`` if the range is invalid for this object.
:param `range`:
:type `range`: wx.richtext.RichTextRange
:param `size`:
:type `size`: wx.Size
:param `descent`:
:type `descent`: int
:param `dc`:
:type `dc`: wx.DC
:param `context`:
:type `context`: wx.richtext.RichTextDrawingContext
:param `flags`:
:type `flags`: int
:param `position`:
:type `position`: wx.Point
:param `parentSize`:
:type `parentSize`: wx.Size
:param `partialExtents`:
:type `partialExtents`: list of integers
:rtype: `bool`
.. method:: GetXMLNodeName(self)
Returns the ``XML`` node name of this object.
This must be overridden for XmlNode-base ``XML`` export to work.
:rtype: `str`
.. method:: HitTest(self, dc : DC, context : RichTextDrawingContext, pt : Point, flags: int=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).
:param `dc`:
:type `dc`: wx.DC
:param `context`:
:type `context`: wx.richtext.RichTextDrawingContext
:param `pt`:
:type `pt`: wx.Point
:param `flags`:
:type `flags`: int
:rtype: :ref:`Tuple[int, int, RichTextObject, RichTextObject]`
:returns:
One of the :ref:`wx.richtext.RichTextHitTestFlags` values.
.. method:: Init(self)
:rtype: `None`
.. staticmethod:: InitDefaultTabs()
Creates a default tabstop array.
:rtype: `None`
.. method:: InsertText(self, pos : int, text : str)
Inserts text at the given position.
:param `pos`:
:type `pos`: long
:param `text`:
:type `text`: string
:rtype: `bool`
.. method:: Layout(self, dc : DC, context : RichTextDrawingContext, rect : Rect, parentRect : Rect, style : int)
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).
:param `dc`:
:type `dc`: wx.DC
:param `context`:
:type `context`: wx.richtext.RichTextDrawingContext
:param `rect`:
:type `rect`: wx.Rect
:param `parentRect`:
:type `parentRect`: wx.Rect
:param `style`:
:type `style`: int
:rtype: `bool`
.. method:: LayoutFloat(self, dc : DC, context : RichTextDrawingContext, rect : Rect, parentRect : Rect, style : int, floatCollector : RichTextFloatCollector)
Lays out the floating objects.
:param `dc`:
:type `dc`: wx.DC
:param `context`:
:type `context`: wx.richtext.RichTextDrawingContext
:param `rect`:
:type `rect`: wx.Rect
:param `parentRect`:
:type `parentRect`: wx.Rect
:param `style`:
:type `style`: int
:param `floatCollector`:
:type `floatCollector`: RichTextFloatCollector
:rtype: `None`
.. method:: MoveFromList(self, list : RichTextObjectList_)
Adds content back from a list.
:param `list`:
:type `list`: :class:`RichTextObjectList_`
:rtype: `None`
.. method:: MoveToList(self, obj : RichTextObject, list : RichTextObjectList_)
Moves content to a list from this point.
:param `obj`:
:type `obj`: wx.richtext.RichTextObject
:param `list`:
:type `list`: :class:`RichTextObjectList_`
:rtype: `None`
.. method:: SetImpactedByFloatingObjects(self, i : int)
Sets whether the paragraph is impacted by floating objects from above.
:param `i`:
:type `i`: int
:rtype: `None`
.. method:: SplitAt(self, pos : int, previousObject: Optional[RichTextObject]=None)
Splits an object at this position if necessary, and returns the previous object, or ``None`` if inserting at the beginning.
:param `pos`:
:type `pos`: long
:param `previousObject`:
:type `previousObject`: RichTextObject
:rtype: :ref:`wx.richtext.RichTextObject`
.. attribute:: BulletText
See :meth:`~wx.richtext.RichTextParagraph.GetBulletText`
.. attribute:: CombinedAttributes
See :meth:`~wx.richtext.RichTextParagraph.GetCombinedAttributes`
.. attribute:: ImpactedByFloatingObjects
See :meth:`~wx.richtext.RichTextParagraph.GetImpactedByFloatingObjects` and :meth:`~wx.richtext.RichTextParagraph.SetImpactedByFloatingObjects`
.. attribute:: Lines
See :meth:`~wx.richtext.RichTextParagraph.GetLines`
.. attribute:: XMLNodeName
See :meth:`~wx.richtext.RichTextParagraph.GetXMLNodeName`