+// A class for left, right, top and bottom dimensions
+class WXDLLIMPEXP_RICHTEXT wxTextAttrDimensions
+{
+public:
+ void Reset() { m_left.Reset(); m_top.Reset(); m_right.Reset(); m_bottom.Reset(); }
+
+ bool operator==(const wxTextAttrDimensions& dims) const { return m_left == dims.m_left && m_top == dims.m_top && m_right == dims.m_right && m_bottom == dims.m_bottom; }
+
+ // Partial equality test
+ bool EqPartial(const wxTextAttrDimensions& dims) const;
+
+ // Apply border to 'this', but not if the same as compareWith
+ bool Apply(const wxTextAttrDimensions& dims, const wxTextAttrDimensions* compareWith = NULL);
+
+ // Collects the attributes that are common to a range of content, building up a note of
+ // which attributes are absent in some objects and which clash in some objects.
+ void CollectCommonAttributes(const wxTextAttrDimensions& attr, wxTextAttrDimensions& clashingAttr, wxTextAttrDimensions& absentAttr);
+
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxTextAttrDimensions& attr);
+
+ const wxTextAttrDimension& GetLeft() const { return m_left; }
+ wxTextAttrDimension& GetLeft() { return m_left; }
+
+ const wxTextAttrDimension& GetRight() const { return m_right; }
+ wxTextAttrDimension& GetRight() { return m_right; }
+
+ const wxTextAttrDimension& GetTop() const { return m_top; }
+ wxTextAttrDimension& GetTop() { return m_top; }
+
+ const wxTextAttrDimension& GetBottom() const { return m_bottom; }
+ wxTextAttrDimension& GetBottom() { return m_bottom; }
+
+ wxTextAttrDimension m_left;
+ wxTextAttrDimension m_top;
+ wxTextAttrDimension m_right;
+ wxTextAttrDimension m_bottom;
+};
+
+// A class to make it easier to convert dimensions
+class WXDLLIMPEXP_RICHTEXT wxTextAttrDimensionConverter
+{
+public:
+ wxTextAttrDimensionConverter(wxDC& dc, double scale = 1.0, const wxSize& parentSize = wxDefaultSize);
+ wxTextAttrDimensionConverter(int ppi, double scale = 1.0, const wxSize& parentSize = wxDefaultSize);
+
+ int GetPixels(const wxTextAttrDimension& dim, int direction = wxHORIZONTAL) const;
+ int GetTenthsMM(const wxTextAttrDimension& dim) const;
+
+ int ConvertTenthsMMToPixels(int units) const;
+ int ConvertPixelsToTenthsMM(int pixels) const;
+
+ int m_ppi;
+ double m_scale;
+ wxSize m_parentSize;
+};
+
+// Border styles
+enum wxTextAttrBorderStyle
+{
+ wxTEXT_BOX_ATTR_BORDER_NONE = 0,
+ wxTEXT_BOX_ATTR_BORDER_SOLID = 1,
+ wxTEXT_BOX_ATTR_BORDER_DOTTED = 2,
+ wxTEXT_BOX_ATTR_BORDER_DASHED = 3,
+ wxTEXT_BOX_ATTR_BORDER_DOUBLE = 4,
+ wxTEXT_BOX_ATTR_BORDER_GROOVE = 5,
+ wxTEXT_BOX_ATTR_BORDER_RIDGE = 6,
+ wxTEXT_BOX_ATTR_BORDER_INSET = 7,
+ wxTEXT_BOX_ATTR_BORDER_OUTSET = 8
+};
+
+// Border style presence flags
+enum wxTextAttrBorderFlags
+{
+ wxTEXT_BOX_ATTR_BORDER_STYLE = 0x0001,
+ wxTEXT_BOX_ATTR_BORDER_COLOUR = 0x0002
+};
+
+// Border width symbols for qualitative widths
+enum wxTextAttrBorderWidth
+{
+ wxTEXT_BOX_ATTR_BORDER_THIN = -1,
+ wxTEXT_BOX_ATTR_BORDER_MEDIUM = -2,
+ wxTEXT_BOX_ATTR_BORDER_THICK = -3
+};
+
+// Float styles
+enum wxTextBoxAttrFloatStyle
+{
+ wxTEXT_BOX_ATTR_FLOAT_NONE = 0,
+ wxTEXT_BOX_ATTR_FLOAT_LEFT = 1,
+ wxTEXT_BOX_ATTR_FLOAT_RIGHT = 2
+};
+
+// Clear styles
+enum wxTextBoxAttrClearStyle
+{
+ wxTEXT_BOX_ATTR_CLEAR_NONE = 0,
+ wxTEXT_BOX_ATTR_CLEAR_LEFT = 1,
+ wxTEXT_BOX_ATTR_CLEAR_RIGHT = 2,
+ wxTEXT_BOX_ATTR_CLEAR_BOTH = 3
+};
+
+// Collapse mode styles. TODO: can they be switched on per side?
+enum wxTextBoxAttrCollapseMode
+{
+ wxTEXT_BOX_ATTR_COLLAPSE_NONE = 0,
+ wxTEXT_BOX_ATTR_COLLAPSE_FULL = 1
+};
+
+// Border
+class WXDLLIMPEXP_RICHTEXT wxTextAttrBorder
+{
+public:
+ wxTextAttrBorder() { Reset(); }
+
+ bool operator==(const wxTextAttrBorder& border) const
+ {
+ return m_flags == border.m_flags && m_borderStyle == border.m_borderStyle &&
+ m_borderColour == border.m_borderColour && m_borderWidth == border.m_borderWidth;
+ }
+
+ void Reset() { m_borderStyle = 0; m_borderColour = 0; m_flags = 0; m_borderWidth.Reset(); }
+
+ // Partial equality test
+ bool EqPartial(const wxTextAttrBorder& border) const;
+
+ // Apply border to 'this', but not if the same as compareWith
+ bool Apply(const wxTextAttrBorder& border, const wxTextAttrBorder* compareWith = NULL);
+
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxTextAttrBorder& attr);
+
+ // Collects the attributes that are common to a range of content, building up a note of
+ // which attributes are absent in some objects and which clash in some objects.
+ void CollectCommonAttributes(const wxTextAttrBorder& attr, wxTextAttrBorder& clashingAttr, wxTextAttrBorder& absentAttr);
+
+ void SetStyle(int style) { m_borderStyle = style; m_flags |= wxTEXT_BOX_ATTR_BORDER_STYLE; }
+ int GetStyle() const { return m_borderStyle; }
+
+ void SetColour(unsigned long colour) { m_borderColour = colour; m_flags |= wxTEXT_BOX_ATTR_BORDER_COLOUR; }
+ void SetColour(const wxColour& colour) { m_borderColour = colour.GetRGB(); m_flags |= wxTEXT_BOX_ATTR_BORDER_COLOUR; }
+ unsigned long GetColourLong() const { return m_borderColour; }
+ wxColour GetColour() const { return wxColour(m_borderColour); }
+
+ wxTextAttrDimension& GetWidth() { return m_borderWidth; }
+ const wxTextAttrDimension& GetWidth() const { return m_borderWidth; }
+ void SetWidth(const wxTextAttrDimension& width) { m_borderWidth = width; }
+
+ bool HasStyle() const { return (m_flags & wxTEXT_BOX_ATTR_BORDER_STYLE) != 0; }
+ bool HasColour() const { return (m_flags & wxTEXT_BOX_ATTR_BORDER_COLOUR) != 0; }
+ bool HasWidth() const { return m_borderWidth.IsPresent(); }
+
+ bool IsValid() const { return HasStyle() && HasColour() && HasWidth(); }
+
+ int GetFlags() const { return m_flags; }
+ void SetFlags(int flags) { m_flags = flags; }
+ void AddFlag(int flag) { m_flags |= flag; }
+ void RemoveFlag(int flag) { m_flags &= ~flag; }
+
+ int m_borderStyle;
+ unsigned long m_borderColour;
+ wxTextAttrDimension m_borderWidth;
+ int m_flags;
+};
+
+// Borders
+class WXDLLIMPEXP_RICHTEXT wxTextAttrBorders
+{
+public:
+ wxTextAttrBorders() { }
+
+ bool operator==(const wxTextAttrBorders& borders) const
+ {
+ return m_left == borders.m_left && m_right == borders.m_right &&
+ m_top == borders.m_top && m_bottom == borders.m_bottom;
+ }
+
+ // Set style of all borders
+ void SetStyle(int style);
+
+ // Set colour of all borders
+ void SetColour(unsigned long colour);
+ void SetColour(const wxColour& colour);
+
+ // Set width of all borders
+ void SetWidth(const wxTextAttrDimension& width);
+
+ // Reset
+ void Reset() { m_left.Reset(); m_right.Reset(); m_top.Reset(); m_bottom.Reset(); }
+
+ // Partial equality test
+ bool EqPartial(const wxTextAttrBorders& borders) const;
+
+ // Apply border to 'this', but not if the same as compareWith
+ bool Apply(const wxTextAttrBorders& borders, const wxTextAttrBorders* compareWith = NULL);
+
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxTextAttrBorders& attr);
+
+ // Collects the attributes that are common to a range of content, building up a note of
+ // which attributes are absent in some objects and which clash in some objects.
+ void CollectCommonAttributes(const wxTextAttrBorders& attr, wxTextAttrBorders& clashingAttr, wxTextAttrBorders& absentAttr);
+
+ bool HasBorder() const { return m_left.IsValid() || m_right.IsValid() || m_top.IsValid() || m_bottom.IsValid(); }
+
+ const wxTextAttrBorder& GetLeft() const { return m_left; }
+ wxTextAttrBorder& GetLeft() { return m_left; }
+
+ const wxTextAttrBorder& GetRight() const { return m_right; }
+ wxTextAttrBorder& GetRight() { return m_right; }
+
+ const wxTextAttrBorder& GetTop() const { return m_top; }
+ wxTextAttrBorder& GetTop() { return m_top; }
+
+ const wxTextAttrBorder& GetBottom() const { return m_bottom; }
+ wxTextAttrBorder& GetBottom() { return m_bottom; }
+
+ wxTextAttrBorder m_left, m_right, m_top, m_bottom;
+
+};
+
+// ----------------------------------------------------------------------------
+// wxTextBoxAttr: a structure containing box attributes
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_RICHTEXT wxTextBoxAttr
+{
+public:
+ // ctors
+ wxTextBoxAttr() { Init(); }
+ wxTextBoxAttr(const wxTextBoxAttr& attr) { Init(); (*this) = attr; }
+
+ // Initialise this object.
+ void Init() { Reset(); }
+
+ // Reset this object.
+ void Reset();
+
+ // Copy. Unnecessary since we let it do a binary copy
+ //void Copy(const wxTextBoxAttr& attr);
+
+ // Assignment
+ //void operator= (const wxTextBoxAttr& attr);
+
+ // Equality test
+ bool operator== (const wxTextBoxAttr& attr) const;
+
+ // Partial equality test
+ bool EqPartial(const wxTextBoxAttr& attr) const;
+
+ // Merges the given attributes. If compareWith
+ // is non-NULL, then it will be used to mask out those attributes that are the same in style
+ // and compareWith, for situations where we don't want to explicitly set inherited attributes.
+ bool Apply(const wxTextBoxAttr& style, const wxTextBoxAttr* compareWith = NULL);
+
+ // Collects the attributes that are common to a range of content, building up a note of
+ // which attributes are absent in some objects and which clash in some objects.
+ void CollectCommonAttributes(const wxTextBoxAttr& attr, wxTextBoxAttr& clashingAttr, wxTextBoxAttr& absentAttr);
+
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxTextBoxAttr& attr);
+
+ // Set flags
+ void SetFlags(int flags) { m_flags = flags; }
+
+ // Get flags
+ int GetFlags() const { return m_flags; }
+
+ // Is this flag present?
+ bool HasFlag(wxTextBoxAttrFlags flag) const { return (m_flags & flag) != 0; }
+
+ // Remove this flag
+ void RemoveFlag(wxTextBoxAttrFlags flag) { m_flags &= ~flag; }
+
+ // Add this flag
+ void AddFlag(wxTextBoxAttrFlags flag) { m_flags |= flag; }
+
+ // Is this default? I.e. no flags set
+ bool IsDefault() const;
+
+ // Float mode
+ short int GetFloatMode() const { return m_floatMode; }
+ void SetFloatMode(short int mode) { m_floatMode = mode; m_flags |= wxTEXT_BOX_ATTR_FLOAT; }
+ bool HasFloatMode() const { return HasFlag(wxTEXT_BOX_ATTR_FLOAT); }
+ bool IsFloating() const { return HasFloatMode() && GetFloatMode() != wxTEXT_BOX_ATTR_FLOAT_NONE; }
+
+ // Whether to wrap text after object
+ short int GetClearMode() const { return m_clearMode; }
+ void SetClearMode(short int mode) { m_clearMode = mode; m_flags |= wxTEXT_BOX_ATTR_CLEAR; }
+ bool HasClearMode() const { return HasFlag(wxTEXT_BOX_ATTR_CLEAR); }
+
+ // Whether to collapse borders
+ int GetCollapseBorders() const { return m_collapseMode ; }
+ void SetCollapseBorders(int collapse) { m_collapseMode = collapse; m_flags |= wxTEXT_BOX_ATTR_COLLAPSE_BORDERS; }
+ bool HasCollapseBorders() const { return HasFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS); }
+
+ // Margins
+
+ wxTextAttrDimensions& GetMargins() { return m_margins; }
+ const wxTextAttrDimensions& GetMargins() const { return m_margins; }
+
+ wxTextAttrDimension& GetLeftMargin() { return m_margins.m_left; }
+ const wxTextAttrDimension& GetLeftMargin() const { return m_margins.m_left; }
+
+ wxTextAttrDimension& GetRightMargin() { return m_margins.m_right; }
+ const wxTextAttrDimension& GetRightMargin() const { return m_margins.m_right; }
+
+ wxTextAttrDimension& GetTopMargin() { return m_margins.m_top; }
+ const wxTextAttrDimension& GetTopMargin() const { return m_margins.m_top; }
+
+ wxTextAttrDimension& GetBottomMargin() { return m_margins.m_bottom; }
+ const wxTextAttrDimension& GetBottomMargin() const { return m_margins.m_bottom; }
+
+ // Position
+
+ wxTextAttrDimensions& GetPosition() { return m_position; }
+ const wxTextAttrDimensions& GetPosition() const { return m_position; }