+ /**
+ Returns the paragraph for a given line.
+ */
+ virtual wxRichTextParagraph* GetParagraphForLine(wxRichTextLine* line) const;
+
+ /**
+ Returns the length of the paragraph.
+ */
+ virtual int GetParagraphLength(long paragraphNumber) const;
+
+ /**
+ Returns the number of paragraphs.
+ */
+ virtual int GetParagraphCount() const { return static_cast<int>(GetChildCount()); }
+
+ /**
+ Returns the number of visible lines.
+ */
+ virtual int GetLineCount() const;
+
+ /**
+ Returns the text of the paragraph.
+ */
+ virtual wxString GetParagraphText(long paragraphNumber) const;
+
+ /**
+ Converts zero-based line column and paragraph number to a position.
+ */
+ virtual long XYToPosition(long x, long y) const;
+
+ /**
+ Converts a zero-based position to line column and paragraph number.
+ */
+ virtual bool PositionToXY(long pos, long* x, long* y) const;
+
+ /**
+ Sets the attributes for the given range. Pass flags to determine how the
+ attributes are set.
+
+ The end point of range is specified as the last character position of the span
+ of text. So, for example, to set the style for a character at position 5,
+ use the range (5,5).
+ This differs from the wxRichTextCtrl API, where you would specify (5,6).
+
+ @a flags may contain a bit list of the following values:
+ - wxRICHTEXT_SETSTYLE_NONE: no style flag.
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be
+ undoable.
+ - wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied
+ if the combined style at this point is already the style in question.
+ - wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be
+ applied to paragraphs, and not the content.
+ This allows content styling to be preserved independently from that
+ of e.g. a named paragraph style.
+ - wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be
+ applied to characters, and not the paragraph.
+ This allows content styling to be preserved independently from that
+ of e.g. a named paragraph style.
+ - wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying
+ the new style.
+ - wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style.
+ Only the style flags are used in this operation.
+ */
+ virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+
+ /**
+ Sets the attributes for the given object only, for example the box attributes for a text box.
+ */
+ virtual void SetStyle(wxRichTextObject *obj, const wxRichTextAttr& textAttr, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+
+ /**
+ Returns the combined text attributes for this position.
+
+ This function gets the @e uncombined style - that is, the attributes associated
+ with the paragraph or character content, and not necessarily the combined
+ attributes you see on the screen. To get the combined attributes, use GetStyle().
+ If you specify (any) paragraph attribute in @e style's flags, this function
+ will fetch the paragraph attributes.
+ Otherwise, it will return the character attributes.
+ */
+ virtual bool GetStyle(long position, wxRichTextAttr& style);
+
+ /**
+ Returns the content (uncombined) attributes for this position.
+ */
+ virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style);
+
+ /**
+ Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and
+ context attributes.
+ */
+ virtual bool DoGetStyle(long position, wxRichTextAttr& style, bool combineStyles = true);
+
+ /**
+ This function gets a style representing the common, combined attributes in the
+ given range.
+ Attributes which have different values within the specified range will not be
+ included the style flags.
+
+ The function is used to get the attributes to display in the formatting dialog:
+ the user can edit the attributes common to the selection, and optionally specify the
+ values of further attributes to be applied uniformly.
+
+ To apply the edited attributes, you can use SetStyle() specifying
+ the wxRICHTEXT_SETSTYLE_OPTIMIZE flag, which will only apply attributes that
+ are different from the @e combined attributes within the range.
+ So, the user edits the effective, displayed attributes for the range,
+ but his choice won't be applied unnecessarily to content. As an example,
+ say the style for a paragraph specifies bold, but the paragraph text doesn't
+ specify a weight.
+ The combined style is bold, and this is what the user will see on-screen and
+ in the formatting dialog. The user now specifies red text, in addition to bold.
+ When applying with SetStyle(), the content font weight attributes won't be
+ changed to bold because this is already specified by the paragraph.
+ However the text colour attributes @e will be changed to show red.
+ */
+ virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
+
+ /**
+ Combines @a style with @a currentStyle for the purpose of summarising the attributes of a range of
+ content.
+ */
+ bool CollectStyle(wxRichTextAttr& currentStyle, const wxRichTextAttr& style, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr);
+
+ //@{
+ /**
+ Sets the list attributes for the given range, passing flags to determine how
+ the attributes are set.
+ Either the style definition or the name of the style definition (in the current
+ sheet) can be passed.
+
+ @a flags is a bit list of the following:
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
+ - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
+ @a startFrom, otherwise existing attributes are used.
+ - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
+ as the level for all paragraphs, otherwise the current indentation will be used.
+
+ @see NumberList(), PromoteList(), ClearListStyle().
+ */
+ virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+ virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+ //@}
+
+ /**
+ Clears the list style from the given range, clearing list-related attributes
+ and applying any named paragraph style associated with each paragraph.
+
+ @a flags is a bit list of the following:
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
+
+ @see SetListStyle(), PromoteList(), NumberList()
+ */
+ virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+
+ //@{
+ /**
+ Numbers the paragraphs in the given range.
+
+ Pass flags to determine how the attributes are set.
+ Either the style definition or the name of the style definition (in the current
+ sheet) can be passed.
+
+ @a flags is a bit list of the following:
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
+ - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
+ @a startFrom, otherwise existing attributes are used.
+ - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
+ as the level for all paragraphs, otherwise the current indentation will be used.
+
+ @a def can be NULL to indicate that the existing list style should be used.
+
+ @see SetListStyle(), PromoteList(), ClearListStyle()
+ */
+ virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+ virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+ //@}
+
+ //@{
+ /**
+ Promotes the list items within the given range.
+ A positive @a promoteBy produces a smaller indent, and a negative number
+ produces a larger indent. Pass flags to determine how the attributes are set.
+ Either the style definition or the name of the style definition (in the current
+ sheet) can be passed.
+
+ @a flags is a bit list of the following:
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
+ - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
+ @a startFrom, otherwise existing attributes are used.
+ - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
+ as the level for all paragraphs, otherwise the current indentation will be used.
+
+ @see SetListStyle(), SetListStyle(), ClearListStyle()
+ */
+ virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
+ virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
+ //@}
+
+ /**
+ Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously
+ @a def can be NULL/empty to indicate that the existing list style should be used.
+ */
+ virtual bool DoNumberList(const wxRichTextRange& range, const wxRichTextRange& promotionRange, int promoteBy, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+
+ /**
+ Fills in the attributes for numbering a paragraph after previousParagraph.
+ */
+ virtual bool FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const;
+
+ /**
+ Sets the properties for the given range, passing flags to determine how the
+ attributes are set. You can merge properties or replace them.
+
+ The end point of range is specified as the last character position of the span
+ of text, plus one. So, for example, to set the properties for a character at
+ position 5, use the range (5,6).
+
+ @a flags may contain a bit list of the following values:
+ - wxRICHTEXT_SETPROPERTIES_NONE: no flag.
+ - wxRICHTEXT_SETPROPERTIES_WITH_UNDO: specifies that this operation should be
+ undoable.
+ - wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY: specifies that the properties should only be
+ applied to paragraphs, and not the content.
+ - wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY: specifies that the properties should only be
+ applied to characters, and not the paragraph.
+ - wxRICHTEXT_SETPROPERTIES_RESET: resets (clears) the existing properties before applying
+ the new properties.
+ - wxRICHTEXT_SETPROPERTIES_REMOVE: removes the specified properties.
+ */
+ virtual bool SetProperties(const wxRichTextRange& range, const wxRichTextProperties& properties, int flags = wxRICHTEXT_SETPROPERTIES_WITH_UNDO);
+
+ /**
+ Test if this whole range has character attributes of the specified kind. If any
+ of the attributes are different within the range, the test fails. You
+ can use this to implement, for example, bold button updating. style must have
+ flags indicating which attributes are of interest.
+ */
+ virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const;
+
+ /**
+ Test if this whole range has paragraph attributes of the specified kind. If any
+ of the attributes are different within the range, the test fails. You
+ can use this to implement, for example, centering button updating. style must have
+ flags indicating which attributes are of interest.
+ */
+ virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const;
+
+ virtual wxRichTextObject* Clone() const { return new wxRichTextParagraphLayoutBox(*this); }
+
+ /**
+ Prepares the content just before insertion (or after buffer reset).
+ Currently is only called if undo mode is on.
+ */
+ virtual void PrepareContent(wxRichTextParagraphLayoutBox& container);
+
+ /**
+ Insert fragment into this box at the given position. If partialParagraph is true,
+ it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
+ marker.
+ */
+ virtual bool InsertFragment(long position, wxRichTextParagraphLayoutBox& fragment);
+
+ /**
+ Make a copy of the fragment corresponding to the given range, putting it in @a fragment.
+ */
+ virtual bool CopyFragment(const wxRichTextRange& range, wxRichTextParagraphLayoutBox& fragment);
+
+ /**
+ Apply the style sheet to the buffer, for example if the styles have changed.
+ */
+ virtual bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet);
+
+ void Copy(const wxRichTextParagraphLayoutBox& obj);
+
+ void operator= (const wxRichTextParagraphLayoutBox& obj) { Copy(obj); }
+
+ /**
+ Calculate ranges.
+ */
+ virtual void UpdateRanges();
+
+ /**
+ Get all the text.
+ */
+ virtual wxString GetText() const;
+
+ /**
+ Sets the default style, affecting the style currently being applied
+ (for example, setting the default style to bold will cause subsequently
+ inserted text to be bold).
+
+ This is not cumulative - setting the default style will replace the previous
+ default style.
+
+ Setting it to a default attribute object makes new content take on the 'basic' style.
+ */
+ virtual bool SetDefaultStyle(const wxRichTextAttr& style);
+
+ /**
+ Returns the current default style, affecting the style currently being applied
+ (for example, setting the default style to bold will cause subsequently
+ inserted text to be bold).
+ */
+ virtual const wxRichTextAttr& GetDefaultStyle() const { return m_defaultAttributes; }
+
+ /**
+ Sets the basic (overall) style. This is the style of the whole
+ buffer before further styles are applied, unlike the default style, which
+ only affects the style currently being applied (for example, setting the default
+ style to bold will cause subsequently inserted text to be bold).
+ */
+ virtual void SetBasicStyle(const wxRichTextAttr& style) { m_attributes = style; }
+
+ /**
+ Returns the basic (overall) style.
+
+ This is the style of the whole buffer before further styles are applied,
+ unlike the default style, which only affects the style currently being
+ applied (for example, setting the default style to bold will cause
+ subsequently inserted text to be bold).
+ */
+ virtual const wxRichTextAttr& GetBasicStyle() const { return m_attributes; }
+
+ /**
+ Invalidates the buffer. With no argument, invalidates whole buffer.
+ */
+ virtual void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL);
+
+ /**
+ Do the (in)validation for this object only.
+ */
+ virtual void DoInvalidate(const wxRichTextRange& invalidRange);
+
+ /**
+ Do the (in)validation both up and down the hierarchy.
+ */
+ virtual void InvalidateHierarchy(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL);
+
+ /**
+ Gather information about floating objects. If untilObj is non-NULL,
+ will stop getting information if the current object is this, since we
+ will collect the rest later.
+ */
+ virtual bool UpdateFloatingObjects(const wxRect& availableRect, wxRichTextObject* untilObj = NULL);
+
+ /**
+ Get invalid range, rounding to entire paragraphs if argument is true.
+ */
+ wxRichTextRange GetInvalidRange(bool wholeParagraphs = false) const;
+
+ /**
+ Returns @true if this object needs layout.
+ */
+ bool IsDirty() const { return m_invalidRange != wxRICHTEXT_NONE; }
+
+ /**
+ Returns the wxRichTextFloatCollector of this object.
+ */
+ wxRichTextFloatCollector* GetFloatCollector() { return m_floatCollector; }
+
+ /**
+ Returns the number of floating objects at this level.
+ */
+ int GetFloatingObjectCount() const;
+
+ /**
+ Returns a list of floating objects.
+ */
+ bool GetFloatingObjects(wxRichTextObjectList& objects) const;
+
+protected:
+ wxRichTextCtrl* m_ctrl;
+ wxRichTextAttr m_defaultAttributes;
+
+ // The invalidated range that will need full layout
+ wxRichTextRange m_invalidRange;
+
+ // Is the last paragraph partial or complete?
+ bool m_partialParagraph;
+
+ // The floating layout state
+ wxRichTextFloatCollector* m_floatCollector;
+};
+
+/**
+ @class wxRichTextBox
+
+ This class implements a floating or inline text box, containing paragraphs.
+
+ @library{wxrichtext}
+ @category{richtext}
+
+ @see wxRichTextParagraphLayoutBox, wxRichTextObject, wxRichTextBuffer, wxRichTextCtrl
+*/
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextBox: public wxRichTextParagraphLayoutBox
+{
+ DECLARE_DYNAMIC_CLASS(wxRichTextBox)
+public:
+// Constructors
+
+ /**
+ Default constructor; optionally pass the parent object.
+ */
+
+ wxRichTextBox(wxRichTextObject* parent = NULL);
+
+ /**
+ Copy constructor.
+ */
+
+ wxRichTextBox(const wxRichTextBox& obj): wxRichTextParagraphLayoutBox() { Copy(obj); }
+
+// Overridables
+
+ virtual bool Draw(wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style);
+
+ virtual wxString GetXMLNodeName() const { return wxT("textbox"); }
+
+ virtual bool CanEditProperties() const { return true; }
+
+ virtual bool EditProperties(wxWindow* parent, wxRichTextBuffer* buffer);
+
+ virtual wxString GetPropertiesMenuLabel() const { return _("&Box"); }
+
+// Accessors
+
+// Operations
+
+ virtual wxRichTextObject* Clone() const { return new wxRichTextBox(*this); }
+
+ void Copy(const wxRichTextBox& obj);
+
+protected:
+};
+
+/**
+ @class wxRichTextField
+
+ This class implements the general concept of a field, an object that represents
+ additional functionality such as a footnote, a bookmark, a page number, a table
+ of contents, and so on. Extra information (such as a bookmark name) can be stored
+ in the object properties.
+
+ Drawing, layout, and property editing is delegated to classes derived
+ from wxRichTextFieldType, such as instances of wxRichTextFieldTypeStandard; this makes
+ the use of fields an efficient method of introducing extra functionality, since
+ most of the information required to draw a field (such as a bitmap) is kept centrally
+ in a single field type definition.
+
+ The FieldType property, accessed by SetFieldType/GetFieldType, is used to retrieve
+ the field type definition. So be careful not to overwrite this property.
+
+ wxRichTextField is derived from wxRichTextParagraphLayoutBox, which means that it
+ can contain its own read-only content, refreshed when the application calls the UpdateField
+ function. Whether a field is treated as a composite or a single graphic is determined
+ by the field type definition. If using wxRichTextFieldTypeStandard, passing the display
+ type wxRICHTEXT_FIELD_STYLE_COMPOSITE to the field type definition causes the field
+ to behave like a composite; the other display styles display a simple graphic.
+ When implementing a composite field, you will still need to derive from wxRichTextFieldTypeStandard
+ or wxRichTextFieldType, if only to implement UpdateField to refresh the field content
+ appropriately. wxRichTextFieldTypeStandard is only one possible implementation, but
+ covers common needs especially for simple, static fields using text or a bitmap.
+
+ Register field types on application initialisation with the static function
+ wxRichTextBuffer::AddFieldType. They will be deleted automatically on
+ application exit.
+
+ An application can write a field to a control with wxRichTextCtrl::WriteField,
+ taking a field type, the properties for the field, and optional attributes.
+
+ @library{wxrichtext}
+ @category{richtext}
+
+ @see wxRichTextFieldTypeStandard, wxRichTextFieldType, wxRichTextParagraphLayoutBox, wxRichTextProperties, wxRichTextCtrl
+*/
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextField: public wxRichTextParagraphLayoutBox
+{
+ DECLARE_DYNAMIC_CLASS(wxRichTextField)
+public:
+// Constructors
+
+ /**
+ Default constructor; optionally pass the parent object.
+ */
+
+ wxRichTextField(const wxString& fieldType = wxEmptyString, wxRichTextObject* parent = NULL);
+
+ /**
+ Copy constructor.
+ */
+
+ wxRichTextField(const wxRichTextField& obj): wxRichTextParagraphLayoutBox() { 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 wxString GetXMLNodeName() const { return wxT("field"); }
+
+ virtual bool CanEditProperties() const;
+
+ virtual bool EditProperties(wxWindow* parent, wxRichTextBuffer* buffer);
+
+ virtual wxString GetPropertiesMenuLabel() const;
+
+ virtual bool AcceptsFocus() const { return false; }
+
+ virtual void CalculateRange(long start, long& end);
+
+ /**
+ If a field has children, we don't want the user to be able to edit it.
+ */
+ virtual bool IsAtomic() const { return true; }
+
+ virtual bool IsEmpty() const { return false; }
+
+ virtual bool IsTopLevel() const;
+
+// Accessors
+
+ void SetFieldType(const wxString& fieldType) { GetProperties().SetProperty(wxT("FieldType"), fieldType); }
+ wxString GetFieldType() const { return GetProperties().GetPropertyString(wxT("FieldType")); }
+
+// Operations
+
+ /**
+ Update the field; delegated to the associated field type. This would typically expand the field to its value,
+ if this is a dynamically changing and/or composite field.
+ */
+ virtual bool UpdateField(wxRichTextBuffer* buffer);
+
+ virtual wxRichTextObject* Clone() const { return new wxRichTextField(*this); }
+
+ void Copy(const wxRichTextField& obj);
+
+protected:
+};
+
+/**
+ @class wxRichTextFieldType
+
+ The base class for custom field types. Each type definition handles one
+ field type. Override functions to provide drawing, layout, updating and
+ property editing functionality for a field.
+
+ Register field types on application initialisation with the static function
+ wxRichTextBuffer::AddFieldType. They will be deleted automatically on
+ application exit.
+
+ @library{wxrichtext}
+ @category{richtext}
+
+ @see wxRichTextFieldTypeStandard, wxRichTextField, wxRichTextCtrl
+*/
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextFieldType: public wxObject
+{
+ DECLARE_CLASS(wxRichTextFieldType)
+public:
+ /**
+ Creates a field type definition.
+ */
+ wxRichTextFieldType(const wxString& name = wxEmptyString)
+ : m_name(name)
+ { }
+
+ /**
+ Copy constructor.
+ */
+ wxRichTextFieldType(const wxRichTextFieldType& fieldType)
+ : wxObject(fieldType)
+ { Copy(fieldType); }
+
+ void Copy(const wxRichTextFieldType& fieldType) { m_name = fieldType.m_name; }
+
+ /**
+ 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)
+ */
+ virtual bool Draw(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int style) = 0;
+
+ /**
+ 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 @a 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).
+ */
+ virtual bool Layout(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style) = 0;
+
+ /**
+ Returns the object size for the given range. Returns @false if the range
+ is invalid for this object.
+ */
+ virtual bool GetRangeSize(wxRichTextField* obj, 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 = 0;
+
+ /**
+ Returns @true if we can edit the object's properties via a GUI.
+ */
+ virtual bool CanEditProperties(wxRichTextField* WXUNUSED(obj)) const { return false; }
+
+ /**
+ Edits the object's properties via a GUI.
+ */
+ virtual bool EditProperties(wxRichTextField* WXUNUSED(obj), wxWindow* WXUNUSED(parent), wxRichTextBuffer* WXUNUSED(buffer)) { return false; }
+
+ /**
+ Returns the label to be used for the properties context menu item.
+ */
+ virtual wxString GetPropertiesMenuLabel(wxRichTextField* WXUNUSED(obj)) const { return wxEmptyString; }
+
+ /**
+ Update the field. This would typically expand the field to its value,
+ if this is a dynamically changing and/or composite field.
+ */
+ virtual bool UpdateField(wxRichTextBuffer* WXUNUSED(buffer), wxRichTextField* WXUNUSED(obj)) { return false; }
+
+ /**
+ Returns @true if this object is top-level, i.e. contains its own paragraphs, such as a text box.
+ */
+ virtual bool IsTopLevel(wxRichTextField* WXUNUSED(obj)) const { return true; }
+
+ /**
+ Sets the field type name. There should be a unique name per field type object.
+ */
+ void SetName(const wxString& name) { m_name = name; }
+
+ /**
+ Returns the field type name. There should be a unique name per field type object.
+ */
+ wxString GetName() const { return m_name; }
+
+protected:
+
+ wxString m_name;
+};
+
+WX_DECLARE_STRING_HASH_MAP(wxRichTextFieldType*, wxRichTextFieldTypeHashMap);
+
+/**
+ @class wxRichTextFieldTypeStandard
+
+ A field type that can handle fields with text or bitmap labels, with a small range
+ of styles for implementing rectangular fields and fields that can be used for start
+ and end tags.
+
+ The border, text and background colours can be customised; the default is
+ white text on a black background.
+
+ The following display styles can be used.
+
+ @beginStyleTable
+ @style{wxRICHTEXT_FIELD_STYLE_COMPOSITE}
+ Creates a composite field; you will probably need to derive a new class to implement UpdateField.
+ @style{wxRICHTEXT_FIELD_STYLE_RECTANGLE}
+ Shows a rounded rectangle background.
+ @style{wxRICHTEXT_FIELD_STYLE_NO_BORDER}
+ Suppresses the background and border; mostly used with a bitmap label.
+ @style{wxRICHTEXT_FIELD_STYLE_START_TAG}
+ Shows a start tag background, with the pointy end facing right.
+ @style{wxRICHTEXT_FIELD_STYLE_END_TAG}
+ Shows an end tag background, with the pointy end facing left.
+ @endStyleTable
+
+ @library{wxrichtext}
+ @category{richtext}
+
+ @see wxRichTextFieldType, wxRichTextField, wxRichTextBuffer, wxRichTextCtrl
+*/
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextFieldTypeStandard: public wxRichTextFieldType
+{
+ DECLARE_CLASS(wxRichTextFieldTypeStandard)
+public:
+
+ // Display style types
+ enum { wxRICHTEXT_FIELD_STYLE_COMPOSITE = 0x01,
+ wxRICHTEXT_FIELD_STYLE_RECTANGLE = 0x02,
+ wxRICHTEXT_FIELD_STYLE_NO_BORDER = 0x04,
+ wxRICHTEXT_FIELD_STYLE_START_TAG = 0x08,
+ wxRICHTEXT_FIELD_STYLE_END_TAG = 0x10
+ };
+
+ /**
+ Constructor, creating a field type definition with a text label.
+
+ @param parent
+ The name of the type definition. This must be unique, and is the type
+ name used when adding a field to a control.
+ @param label
+ The text label to be shown on the field.
+ @param displayStyle
+ The display style: one of wxRICHTEXT_FIELD_STYLE_RECTANGLE,
+ wxRICHTEXT_FIELD_STYLE_NO_BORDER, wxRICHTEXT_FIELD_STYLE_START_TAG,
+ wxRICHTEXT_FIELD_STYLE_END_TAG.
+
+ */
+ wxRichTextFieldTypeStandard(const wxString& name, const wxString& label, int displayStyle = wxRICHTEXT_FIELD_STYLE_RECTANGLE);
+
+ /**
+ Constructor, creating a field type definition with a bitmap label.
+
+ @param parent
+ The name of the type definition. This must be unique, and is the type
+ name used when adding a field to a control.
+ @param label
+ The bitmap label to be shown on the field.
+ @param displayStyle
+ The display style: one of wxRICHTEXT_FIELD_STYLE_RECTANGLE,
+ wxRICHTEXT_FIELD_STYLE_NO_BORDER, wxRICHTEXT_FIELD_STYLE_START_TAG,
+ wxRICHTEXT_FIELD_STYLE_END_TAG.
+
+ */
+ wxRichTextFieldTypeStandard(const wxString& name, const wxBitmap& bitmap, int displayStyle = wxRICHTEXT_FIELD_STYLE_NO_BORDER);
+
+ /**
+ The default constructor.
+
+ */
+ wxRichTextFieldTypeStandard() { Init(); }
+
+ /**
+ The copy constructor.
+
+ */
+ wxRichTextFieldTypeStandard(const wxRichTextFieldTypeStandard& field)
+ : wxRichTextFieldType(field)
+ { Copy(field); }
+
+ /**
+ Initialises the object.
+ */
+ void Init();
+
+ /**
+ Copies the object.
+ */
+ void Copy(const wxRichTextFieldTypeStandard& field);
+
+ /**
+ The assignment operator.
+ */
+ void operator=(const wxRichTextFieldTypeStandard& field) { Copy(field); }
+
+ /**
+ 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)
+ */
+ virtual bool Draw(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, const wxRichTextRange& range, const wxRichTextSelection& selection, const wxRect& rect, int descent, int 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 @a 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).
+ */
+ virtual bool Layout(wxRichTextField* obj, wxDC& dc, wxRichTextDrawingContext& context, const wxRect& rect, const wxRect& parentRect, int style);
+
+ /**
+ Returns the object size for the given range. Returns @false if the range
+ is invalid for this object.
+ */
+ virtual bool GetRangeSize(wxRichTextField* obj, 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;
+
+ /**
+ 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;
+};
+
+/**
+ @class wxRichTextPlainText
+
+ This object represents a single piece of text.
+
+ @library{wxrichtext}
+ @category{richtext}
+
+ @see wxRichTextBuffer, wxRichTextCtrl
+*/
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText: public wxRichTextObject
+{
+ DECLARE_DYNAMIC_CLASS(wxRichTextPlainText)
+public:
+// Constructors
+
+ /**
+ Constructor.
+ */
+ wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxRichTextAttr* style = NULL);
+
+ /**
+ Copy constructor.
+ */
+ wxRichTextPlainText(const wxRichTextPlainText& obj): wxRichTextObject() { 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 wxString GetTextForRange(const wxRichTextRange& range) const;
+
+ virtual wxRichTextObject* DoSplit(long pos);
+
+ virtual void CalculateRange(long start, long& end);
+
+ virtual bool DeleteRange(const wxRichTextRange& range);
+
+ virtual bool IsEmpty() const { return m_text.empty(); }
+
+ virtual bool CanMerge(wxRichTextObject* object, wxRichTextDrawingContext& context) const;
+
+ virtual bool Merge(wxRichTextObject* object, wxRichTextDrawingContext& context);
+
+ virtual void Dump(wxTextOutputStream& stream);
+
+ virtual bool CanSplit(wxRichTextDrawingContext& context) const;
+
+ virtual wxRichTextObject* Split(wxRichTextDrawingContext& context);
+
+ /**
+ Get the first position from pos that has a line break character.
+ */
+ long GetFirstLineBreakPosition(long pos);
+
+ /// Does this object take note of paragraph attributes? Text and image objects don't.
+ virtual bool UsesParagraphAttributes() const { return false; }
+
+#if wxUSE_XML
+ virtual bool ImportFromXML(wxRichTextBuffer* buffer, wxXmlNode* node, wxRichTextXMLHandler* handler, bool* recurse);
+#endif
+
+#if wxRICHTEXT_HAVE_DIRECT_OUTPUT
+ virtual bool ExportXML(wxOutputStream& stream, int indent, wxRichTextXMLHandler* handler);
+#endif
+
+#if wxRICHTEXT_HAVE_XMLDOCUMENT_OUTPUT
+ virtual bool ExportXML(wxXmlNode* parent, wxRichTextXMLHandler* handler);
+#endif
+
+ virtual wxString GetXMLNodeName() const { return wxT("text"); }
+
+// Accessors
+
+ /**
+ Returns the text.
+ */
+ const wxString& GetText() const { return m_text; }
+
+ /**
+ Sets the text.
+ */
+ void SetText(const wxString& text) { m_text = text; }
+
+// Operations
+
+ // Copies the text object,
+ void Copy(const wxRichTextPlainText& obj);
+
+ // Clones the text object.
+ virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); }
+
+private:
+ bool DrawTabbedString(wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected);
+
+protected:
+ wxString m_text;
+};
+
+/**
+ @class wxRichTextImageBlock
+
+ This class stores information about an image, in binary in-memory form.
+
+ @library{wxrichtext}
+ @category{richtext}
+
+ @see wxRichTextBuffer, wxRichTextCtrl
+*/
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock: public wxObject
+{
+public:
+ /**
+ Constructor.
+ */
+ wxRichTextImageBlock();
+
+ /**
+ Copy constructor.
+ */
+ wxRichTextImageBlock(const wxRichTextImageBlock& block);
+ virtual ~wxRichTextImageBlock();
+
+ /**
+ Initialises the block.
+ */
+ void Init();
+
+ /**
+ Clears the block.
+ */
+
+ void Clear();
+
+ /**
+ Load the original image into a memory block.
+ If the image is not a JPEG, we must convert it into a JPEG
+ to conserve space.
+ If it's not a JPEG we can make use of @a image, already scaled, so we don't have to
+ load the image a second time.
+ */
+ virtual bool MakeImageBlock(const wxString& filename, wxBitmapType imageType,
+ wxImage& image, bool convertToJPEG = true);
+
+ /**
+ Make an image block from the wxImage in the given
+ format.
+ */
+ virtual bool MakeImageBlock(wxImage& image, wxBitmapType imageType, int quality = 80);
+
+ /**
+ Uses a const wxImage for efficiency, but can't set quality (only relevant for JPEG)
+ */
+ virtual bool MakeImageBlockDefaultQuality(const wxImage& image, wxBitmapType imageType);
+
+ /**
+ Makes the image block.
+ */
+ virtual bool DoMakeImageBlock(const wxImage& image, wxBitmapType imageType);
+
+ /**
+ Writes the block to a file.
+ */
+ bool Write(const wxString& filename);
+
+ /**
+ Writes the data in hex to a stream.
+ */
+ bool WriteHex(wxOutputStream& stream);
+
+ /**
+ Reads the data in hex from a stream.
+ */
+ bool ReadHex(wxInputStream& stream, int length, wxBitmapType imageType);
+
+ /**
+ Copy from @a block.
+ */
+ void Copy(const wxRichTextImageBlock& block);
+
+ // Load a wxImage from the block
+ /**
+ */
+ bool Load(wxImage& image);
+
+// Operators
+
+ /**
+ Assignment operation.
+ */
+ void operator=(const wxRichTextImageBlock& block);
+
+// Accessors
+
+ /**
+ Returns the raw data.
+ */
+ unsigned char* GetData() const { return m_data; }
+
+ /**
+ Returns the data size in bytes.
+ */
+ size_t GetDataSize() const { return m_dataSize; }
+
+ /**
+ Returns the image type.
+ */
+ wxBitmapType GetImageType() const { return m_imageType; }
+
+ /**
+ */