# wxRichTextParagraph Class Reference
[Rich Text]

`#include <wx/richtext/richtextbuffer.h>`

Inheritance diagram for wxRichTextParagraph:
[legend]

## Detailed Description

This object represents a single paragraph containing various objects such as text content, images, and further paragraph layout objects.

##

Library: wxRichText

Category: Rich Text

See also:
  wxRichTextBuffer, wxRichTextCtrl

## Public Member Functions
| wxRichTextParagraph (wxRichTextObject *parent=NULL, wxRichTextAttr *style=NULL)
| Constructor taking a parent and style.
| wxRichTextParagraph (const wxString &text, wxRichTextObject *parent=NULL, wxRichTextAttr *paraStyle=NULL, wxRichTextAttr *charStyle=NULL)
| Constructor taking a text string, a parent and paragraph and character attributes.
virtual | ~wxRichTextParagraph ()
| wxRichTextParagraph (const wxRichTextParagraph &obj)
virtual bool | Draw (wxDC &dc, const wxRichTextRange &range, const wxRichTextSelection &selection, const wxRect &rect, int descent, int style)
| Draw the item, within the given range.
virtual bool | Layout (wxDC &dc, const wxRect &rect, int style)
| Lay the item out at the specified position with the given size constraint.
virtual bool | GetRangeSize (const wxRichTextRange &range, wxSize &size, int &descent, wxDC &dc, int flags, wxPoint position=wxPoint(0, 0), wxArrayInt *partialExtents=NULL) const
| Returns the object size for the given range.
virtual bool | FindPosition (wxDC &dc, long index, wxPoint &pt, int *height, bool forceLineStart)
virtual int | HitTest (wxDC &dc, const wxPoint &pt, long &textPosition, wxRichTextObject **obj, wxRichTextObject **contextObj, int flags=0)
| Hit-testing: returns a flag indicating hit test details, plus information about position.
virtual void | CalculateRange (long start, long &end)
| Calculates the range of the object.
virtual wxString | GetXMLNodeName () const
| Returns the XML node name of this object.
wxRichTextLineList & | GetLines ()
| Returns the cached lines.
void | Copy (const wxRichTextParagraph &obj)
| Copies the object.
virtual wxRichTextObject * | Clone () const
| Clones the object.
void | ClearLines ()
| Clears the cached lines.
virtual void | ApplyParagraphStyle (wxRichTextLine *line, const wxRichTextAttr &attr, const wxRect &rect, wxDC &dc)
| Applies paragraph styles such as centering to the wrapped lines.
virtual bool | InsertText (long pos, const wxString &text)
| Inserts text at the given position.
virtual wxRichTextObject * | SplitAt (long pos, wxRichTextObject **previousObject=NULL)
| Splits an object at this position if necessary, and returns the previous object, or NULL if inserting at the beginning.
virtual void | MoveToList (wxRichTextObject *obj, wxList &list)
| Moves content to a list from this point.
virtual void | MoveFromList (wxList &list)
| Adds content back from a list.
bool | GetContiguousPlainText (wxString &text, const wxRichTextRange &range, bool fromStart=true)
| Returns the plain text searching from the start or end of the range.
bool | FindWrapPosition (const wxRichTextRange &range, wxDC &dc, int availableSpace, long &wrapPosition, wxArrayInt *partialExtents)
| Finds a suitable wrap position.
wxRichTextObject * | FindObjectAtPosition (long position)
| Finds the object at the given position.
wxString | GetBulletText ()
| Returns the bullet text for this paragraph.
wxRichTextLine * | AllocateLine (int pos)
| Allocates or reuses a line object.
bool | ClearUnusedLines (int lineCount)
| Clears remaining unused line objects, if any.
wxRichTextAttr | GetCombinedAttributes (const wxRichTextAttr &contentStyle, bool includingBoxAttr=false) const
| Returns combined attributes of the base style, paragraph style and character style.
wxRichTextAttr | GetCombinedAttributes (bool includingBoxAttr=false) const
| Returns the combined attributes of the base style and paragraph style.
long | GetFirstLineBreakPosition (long pos)
| Returns the first position from pos that has a line break character.
void | LayoutFloat (wxDC &dc, const wxRect &rect, int style, wxRichTextFloatCollector *floatCollector)
| Lays out the floating objects.
## Static Public Member Functions
static void | InitDefaultTabs ()
| Creates a default tabstop array.
static void | ClearDefaultTabs ()
| Clears the default tabstop array.
static const wxArrayInt & | GetDefaultTabs ()
| Returns the default tabstop array.
## Protected Attributes
wxRichTextLineList | m_cachedLines
## Static Protected Attributes
static wxArrayInt | sm_defaultTabs
## Friends
class | wxRichTextFloatCollector

List of all members.

## Constructor & Destructor Documentation

wxRichTextParagraph::wxRichTextParagraph | ( | wxRichTextObject * | parent = `NULL`,
|  | wxRichTextAttr * | style = `NULL` |
| ) |  |  |

Constructor taking a parent and style.

wxRichTextParagraph::wxRichTextParagraph | ( | const wxString & | text,
|  | wxRichTextObject * | parent = `NULL`,
|  | wxRichTextAttr * | paraStyle = `NULL`,
|  | wxRichTextAttr * | charStyle = `NULL` |
| ) |  |  |

Constructor taking a text string, a parent and paragraph and character attributes.

virtual wxRichTextParagraph::~wxRichTextParagraph | ( |  | ) | `[virtual]`

wxRichTextParagraph::wxRichTextParagraph | ( | const wxRichTextParagraph & | obj | ) | `[inline]`

## Member Function Documentation

wxRichTextLine* wxRichTextParagraph::AllocateLine | ( | int | pos | ) |

Allocates or reuses a line object.

virtual void wxRichTextParagraph::ApplyParagraphStyle | ( | wxRichTextLine * | line,
|  | const wxRichTextAttr & | attr,
|  | const wxRect & | rect,
|  | wxDC & | dc |
| ) |  |  | `[virtual]`

Applies paragraph styles such as centering to the wrapped lines.

virtual void wxRichTextParagraph::CalculateRange | ( | long | start,
|  | long & | end |
| ) |  |  | `[virtual]`

Calculates the range of the object.

By default, guess that the object is 1 unit long.

Reimplemented from wxRichTextCompositeObject.

static void wxRichTextParagraph::ClearDefaultTabs | ( |  | ) | `[static]`

Clears the default tabstop array.

void wxRichTextParagraph::ClearLines | ( |  | ) |

Clears the cached lines.

bool wxRichTextParagraph::ClearUnusedLines | ( | int | lineCount | ) |

Clears remaining unused line objects, if any.

virtual wxRichTextObject* wxRichTextParagraph::Clone | ( |  | ) | const`[inline, virtual]`

Clones the object.

Reimplemented from wxRichTextObject.

void wxRichTextParagraph::Copy | ( | const wxRichTextParagraph & | obj | ) |

Copies the object.

virtual bool wxRichTextParagraph::Draw | ( | wxDC & | dc,
|  | const wxRichTextRange & | range,
|  | const wxRichTextSelection & | selection,
|  | const wxRect & | rect,
|  | int | descent,
|  | int | style |
| ) |  |  | `[virtual]`

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)

Implements wxRichTextObject.

wxRichTextObject* wxRichTextParagraph::FindObjectAtPosition | ( | long | position | ) |

Finds the object at the given position.

virtual bool wxRichTextParagraph::FindPosition | ( | wxDC & | dc,
|  | long | index,
|  | wxPoint & | pt,
|  | int * | height,
|  | bool | forceLineStart |
| ) |  |  | `[virtual]`

Reimplemented from wxRichTextCompositeObject.

bool wxRichTextParagraph::FindWrapPosition | ( | const wxRichTextRange & | range,
|  | wxDC & | dc,
|  | int | availableSpace,
|  | long & | wrapPosition,
|  | wxArrayInt * | partialExtents |
| ) |  |  |

Finds a suitable wrap position.

wrapPosition is the last position in the line to the left of the split.

wxString wxRichTextParagraph::GetBulletText | ( |  | ) |

Returns the bullet text for this paragraph.

wxRichTextAttr wxRichTextParagraph::GetCombinedAttributes | ( | bool | includingBoxAttr = `false` | ) | const

Returns the combined attributes of the base style and paragraph style.

wxRichTextAttr wxRichTextParagraph::GetCombinedAttributes | ( | const wxRichTextAttr & | contentStyle,
|  | bool | includingBoxAttr = `false` |
| ) |  |  | const

Returns combined attributes of the base style, paragraph style and character style.

We use this to dynamically retrieve the actual style.

bool wxRichTextParagraph::GetContiguousPlainText | ( | wxString & | text,
|  | const wxRichTextRange & | range,
|  | bool | fromStart = `true` |
| ) |  |  |

Returns the plain text searching from the start or end of the range.

The resulting string may be shorter than the range given.

static const wxArrayInt& wxRichTextParagraph::GetDefaultTabs | ( |  | ) | `[inline, static]`

Returns the default tabstop array.

long wxRichTextParagraph::GetFirstLineBreakPosition | ( | long | pos | ) |

Returns the first position from pos that has a line break character.

wxRichTextLineList& wxRichTextParagraph::GetLines | ( |  | ) | `[inline]`

Returns the cached lines.

virtual bool wxRichTextParagraph::GetRangeSize | ( | const wxRichTextRange & | range,
|  | wxSize & | size,
|  | int & | descent,
|  | wxDC & | dc,
|  | int | flags,
|  | wxPoint | position = `wxPoint(0, 0)`,
|  | wxArrayInt * | partialExtents = `NULL` |
| ) |  |  | const`[virtual]`

Returns the object size for the given range.

Returns false if the range is invalid for this object.

Reimplemented from wxRichTextCompositeObject.

virtual wxString wxRichTextParagraph::GetXMLNodeName | ( |  | ) | const`[inline, virtual]`

Returns the XML node name of this object.

This must be overridden for wxXmlNode-base XML export to work.

Reimplemented from wxRichTextObject.

virtual int wxRichTextParagraph::HitTest | ( | wxDC & | dc,
|  | const wxPoint & | pt,
|  | long & | textPosition,
|  | wxRichTextObject ** | obj,
|  | wxRichTextObject ** | contextObj,
|  | int | flags = `0` |
| ) |  |  | `[virtual]`

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

Returns:
  One of the wxRichTextHitTestFlags values.

Reimplemented from wxRichTextCompositeObject.

static void wxRichTextParagraph::InitDefaultTabs | ( |  | ) | `[static]`

Creates a default tabstop array.

virtual bool wxRichTextParagraph::InsertText | ( | long | pos,
|  | const wxString & | text |
| ) |  |  | `[virtual]`

Inserts text at the given position.

virtual bool wxRichTextParagraph::Layout | ( | wxDC & | dc,
|  | const wxRect & | rect,
|  | int | style |
| ) |  |  | `[virtual]`

Lay the item out at the specified position with the given size constraint.

Layout must set the cached size.

Implements wxRichTextObject.

void wxRichTextParagraph::LayoutFloat | ( | wxDC & | dc,
|  | const wxRect & | rect,
|  | int | style,
|  | wxRichTextFloatCollector * | floatCollector |
| ) |  |  |

Lays out the floating objects.

virtual void wxRichTextParagraph::MoveFromList | ( | wxList & | list | ) | `[virtual]`

Adds content back from a list.

virtual void wxRichTextParagraph::MoveToList | ( | wxRichTextObject * | obj,
|  | wxList & | list |
| ) |  |  | `[virtual]`

Moves content to a list from this point.

virtual wxRichTextObject* wxRichTextParagraph::SplitAt | ( | long | pos,
|  | wxRichTextObject ** | previousObject = `NULL` |
| ) |  |  | `[virtual]`

Splits an object at this position if necessary, and returns the previous object, or NULL if inserting at the beginning.

## Friends And Related Function Documentation

friend class wxRichTextFloatCollector`[friend]`

## Member Data Documentation

wxRichTextLineList wxRichTextParagraph::m_cachedLines`[protected]`

wxArrayInt wxRichTextParagraph::sm_defaultTabs`[static, protected]`

|  | [ top ]