+ 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; }