+ /**
+ Get the size of the field, given the label, font size, and so on.
+ */
+ wxSize GetSize(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, int style) const;
+
+ /**
+ Returns @true if the display type is wxRICHTEXT_FIELD_STYLE_COMPOSITE, @false otherwise.
+ */
+ virtual bool IsTopLevel(wxRichTextField* WXUNUSED(obj)) const { return (GetDisplayStyle() & wxRICHTEXT_FIELD_STYLE_COMPOSITE) != 0; }
+
+ /**
+ Sets the text label for fields of this type.
+ */
+ void SetLabel(const wxString& label) { m_label = label; }
+
+ /**
+ Returns the text label for fields of this type.
+ */
+ const wxString& GetLabel() const { return m_label; }
+
+ /**
+ Sets the bitmap label for fields of this type.
+ */
+ void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
+
+ /**
+ Gets the bitmap label for fields of this type.
+ */
+ const wxBitmap& GetBitmap() const { return m_bitmap; }
+
+ /**
+ Gets the display style for fields of this type.
+ */
+ int GetDisplayStyle() const { return m_displayStyle; }
+
+ /**
+ Sets the display style for fields of this type.
+ */
+ void SetDisplayStyle(int displayStyle) { m_displayStyle = displayStyle; }
+
+ /**
+ Gets the font used for drawing the text label.
+ */
+ const wxFont& GetFont() const { return m_font; }
+
+ /**
+ Sets the font used for drawing the text label.
+ */
+ void SetFont(const wxFont& font) { m_font = font; }
+
+ /**
+ Gets the colour used for drawing the text label.
+ */
+ const wxColour& GetTextColour() const { return m_textColour; }
+
+ /**
+ Sets the colour used for drawing the text label.
+ */
+ void SetTextColour(const wxColour& colour) { m_textColour = colour; }
+
+ /**
+ Gets the colour used for drawing the field border.
+ */
+ const wxColour& GetBorderColour() const { return m_borderColour; }
+
+ /**
+ Sets the colour used for drawing the field border.
+ */
+ void SetBorderColour(const wxColour& colour) { m_borderColour = colour; }
+
+ /**
+ Gets the colour used for drawing the field background.
+ */
+ const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
+
+ /**
+ Sets the colour used for drawing the field background.
+ */
+ void SetBackgroundColour(const wxColour& colour) { m_backgroundColour = colour; }
+
+ /**
+ Sets the vertical padding (the distance between the border and the text).
+ */
+ void SetVerticalPadding(int padding) { m_verticalPadding = padding; }
+
+ /**
+ Gets the vertical padding (the distance between the border and the text).
+ */
+ int GetVerticalPadding() const { return m_verticalPadding; }
+
+ /**
+ Sets the horizontal padding (the distance between the border and the text).
+ */
+ void SetHorizontalPadding(int padding) { m_horizontalPadding = padding; }
+
+ /**
+ Sets the horizontal padding (the distance between the border and the text).
+ */
+ int GetHorizontalPadding() const { return m_horizontalPadding; }
+
+ /**
+ Sets the horizontal margin surrounding the field object.
+ */
+ void SetHorizontalMargin(int margin) { m_horizontalMargin = margin; }
+
+ /**
+ Gets the horizontal margin surrounding the field object.
+ */
+ int GetHorizontalMargin() const { return m_horizontalMargin; }
+
+ /**
+ Sets the vertical margin surrounding the field object.
+ */
+ void SetVerticalMargin(int margin) { m_verticalMargin = margin; }
+
+ /**
+ Gets the vertical margin surrounding the field object.
+ */
+ int GetVerticalMargin() const { return m_verticalMargin; }
+
+protected:
+
+ wxString m_label;
+ int m_displayStyle;
+ wxFont m_font;
+ wxColour m_textColour;
+ wxColour m_borderColour;
+ wxColour m_backgroundColour;
+ int m_verticalPadding;
+ int m_horizontalPadding;
+ int m_horizontalMargin;
+ int m_verticalMargin;
+ wxBitmap m_bitmap;
+};
+
+/**
+ @class wxRichTextLine
+
+ This object represents a line in a paragraph, and stores
+ offsets from the start of the paragraph representing the
+ start and end positions of the line.
+
+ @library{wxrichtext}
+ @category{richtext}
+
+ @see wxRichTextBuffer, wxRichTextCtrl
+*/
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextLine
+{
+public:
+// Constructors
+
+ wxRichTextLine(wxRichTextParagraph* parent);
+ wxRichTextLine(const wxRichTextLine& obj) { Init( NULL); Copy(obj); }
+ virtual ~wxRichTextLine() {}
+
+// Overridables
+
+// Accessors
+
+ /**
+ Sets the range associated with this line.
+ */
+ void SetRange(const wxRichTextRange& range) { m_range = range; }
+ /**
+ Sets the range associated with this line.
+ */
+ void SetRange(long from, long to) { m_range = wxRichTextRange(from, to); }
+
+ /**
+ Returns the parent paragraph.
+ */
+ wxRichTextParagraph* GetParent() { return m_parent; }
+
+ /**
+ Returns the range.
+ */
+ const wxRichTextRange& GetRange() const { return m_range; }
+ /**
+ Returns the range.
+ */
+ wxRichTextRange& GetRange() { return m_range; }
+
+ /**
+ Returns the absolute range.
+ */
+ wxRichTextRange GetAbsoluteRange() const;
+
+ /**
+ Returns the line size as calculated by Layout.
+ */
+ virtual wxSize GetSize() const { return m_size; }
+
+ /**
+ Sets the line size as calculated by Layout.
+ */
+ virtual void SetSize(const wxSize& sz) { m_size = sz; }
+
+ /**
+ Returns the object position relative to the parent.
+ */
+ virtual wxPoint GetPosition() const { return m_pos; }
+
+ /**
+ Sets the object position relative to the parent.
+ */
+ virtual void SetPosition(const wxPoint& pos) { m_pos = pos; }
+
+ /**
+ Returns the absolute object position.
+ */
+ virtual wxPoint GetAbsolutePosition() const;
+
+ /**
+ Returns the rectangle enclosing the line.
+ */
+ virtual wxRect GetRect() const { return wxRect(GetAbsolutePosition(), GetSize()); }
+
+ /**
+ Sets the stored descent.
+ */
+ void SetDescent(int descent) { m_descent = descent; }
+
+ /**
+ Returns the stored descent.
+ */
+ int GetDescent() const { return m_descent; }
+
+#if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING
+ wxArrayInt& GetObjectSizes() { return m_objectSizes; }
+ const wxArrayInt& GetObjectSizes() const { return m_objectSizes; }
+#endif
+
+// Operations
+
+ /**
+ Initialises the object.
+ */
+ void Init(wxRichTextParagraph* parent);
+
+ /**
+ Copies from @a obj.
+ */
+ void Copy(const wxRichTextLine& obj);
+
+ virtual wxRichTextLine* Clone() const { return new wxRichTextLine(*this); }
+
+protected:
+
+ // The range of the line (start position to end position)
+ // This is relative to the parent paragraph.
+ wxRichTextRange m_range;
+
+ // Size and position measured relative to top of paragraph
+ wxPoint m_pos;
+ wxSize m_size;
+
+ // Maximum descent for this line (location of text baseline)
+ int m_descent;
+
+ // The parent object
+ wxRichTextParagraph* m_parent;
+
+#if wxRICHTEXT_USE_OPTIMIZED_LINE_DRAWING
+ wxArrayInt m_objectSizes;
+#endif
+};
+
+WX_DECLARE_LIST_WITH_DECL( wxRichTextLine, wxRichTextLineList , class WXDLLIMPEXP_RICHTEXT );
+
+/**
+ @class wxRichTextParagraph
+
+ This object represents a single paragraph containing various objects such as text content, images, and further paragraph layout objects.
+
+ @library{wxrichtext}
+ @category{richtext}
+
+ @see wxRichTextBuffer, wxRichTextCtrl
+*/
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph: public wxRichTextCompositeObject
+{
+ DECLARE_DYNAMIC_CLASS(wxRichTextParagraph)
+public:
+// Constructors
+
+ /**
+ Constructor taking a parent and style.
+ */
+ wxRichTextParagraph(wxRichTextObject* parent = NULL, wxRichTextAttr* style = NULL);
+ /**
+ Constructor taking a text string, a parent and paragraph and character attributes.
+ */
+ wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxRichTextAttr* paraStyle = NULL, wxRichTextAttr* charStyle = NULL);
+ virtual ~wxRichTextParagraph();
+ wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextCompositeObject() { Copy(obj); }
+
+// Overridables
+
+ virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
+
+ virtual bool Layout(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style);
+
+ virtual bool GetRangeSize(const wxRichTextRange& range, wxSize& size, int& descent, wxDC& dc, wxRichTextDrawingContext& context, int flags, const wxPoint& position = wxPoint(0,0), const wxSize& parentSize = wxDefaultSize, wxArrayInt* partialExtents = NULL) const;
+
+ virtual bool FindPosition(wxDC& dc, wxRichTextDrawingContext& context, long index, wxPoint& pt, int* height, bool forceLineStart);
+
+ virtual int HitTest(wxDC& dc, wxRichTextDrawingContext& context, const wxPoint& pt, long& textPosition, wxRichTextObject** obj, wxRichTextObject** contextObj, int flags = 0);
+
+ virtual void CalculateRange(long start, long& end);
+
+ virtual wxString GetXMLNodeName() const { return wxT("paragraph"); }
+
+// Accessors
+
+ /**
+ Returns the cached lines.
+ */
+ wxRichTextLineList& GetLines() { return m_cachedLines; }
+
+// Operations
+
+ /**
+ Copies the object.
+ */
+ void Copy(const wxRichTextParagraph& obj);
+
+ virtual wxRichTextObject* Clone() const { return new wxRichTextParagraph(*this); }
+
+ /**
+ Clears the cached lines.
+ */
+ void ClearLines();
+
+// Implementation
+
+ /**
+ Applies paragraph styles such as centering to the wrapped lines.
+ */
+ virtual void ApplyParagraphStyle(wxRichTextLine* line, const wxRichTextAttr& attr, const wxRect& rect, wxDC& dc);
+
+ /**
+ Inserts text at the given position.
+ */
+ virtual bool InsertText(long pos, const wxString& text);
+
+ /**
+ Splits an object at this position if necessary, and returns
+ the previous object, or NULL if inserting at the beginning.
+ */
+ virtual wxRichTextObject* SplitAt(long pos, wxRichTextObject** previousObject = NULL);
+
+ /**
+ Moves content to a list from this point.
+ */
+ virtual void MoveToList(wxRichTextObject* obj, wxList& list);
+
+ /**
+ Adds content back from a list.
+ */
+ virtual void MoveFromList(wxList& list);
+
+ /**
+ Returns the plain text searching from the start or end of the range.
+ The resulting string may be shorter than the range given.
+ */
+ bool GetContiguousPlainText(wxString& text, const wxRichTextRange& range, bool fromStart = true);
+
+ /**
+ Finds a suitable wrap position. @a wrapPosition is the last position in the line to the left
+ of the split.
+ */
+ bool FindWrapPosition(const wxRichTextRange& range, wxDC& dc, wxRichTextDrawingContext& context, int availableSpace, long& wrapPosition, wxArrayInt* partialExtents);
+
+ /**
+ Finds the object at the given position.
+ */
+ wxRichTextObject* FindObjectAtPosition(long position);
+
+ /**
+ Returns the bullet text for this paragraph.
+ */
+ wxString GetBulletText();
+
+ /**
+ Allocates or reuses a line object.
+ */
+ wxRichTextLine* AllocateLine(int pos);
+
+ /**
+ Clears remaining unused line objects, if any.
+ */
+ bool ClearUnusedLines(int lineCount);
+
+ /**
+ Returns combined attributes of the base style, paragraph style and character style. We use this to dynamically
+ retrieve the actual style.
+ */
+ wxRichTextAttr GetCombinedAttributes(const wxRichTextAttr& contentStyle, bool includingBoxAttr = false) const;
+
+ /**
+ Returns the combined attributes of the base style and paragraph style.
+ */
+ wxRichTextAttr GetCombinedAttributes(bool includingBoxAttr = false) const;
+
+ /**
+ Returns the first position from pos that has a line break character.
+ */
+ long GetFirstLineBreakPosition(long pos);
+
+ /**
+ Creates a default tabstop array.
+ */
+ static void InitDefaultTabs();
+
+ /**
+ Clears the default tabstop array.
+ */
+ static void ClearDefaultTabs();
+
+ /**
+ Returns the default tabstop array.
+ */
+ static const wxArrayInt& GetDefaultTabs() { return sm_defaultTabs; }
+
+ /**
+ Lays out the floating objects.
+ */
+ void LayoutFloat(wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style, wxRichTextFloatCollector* floatCollector);
+
+protected:
+
+ // The lines that make up the wrapped paragraph
+ wxRichTextLineList m_cachedLines;
+
+ // Default tabstops
+ static wxArrayInt sm_defaultTabs;
+
+friend class wxRichTextFloatCollector;