+#define wxSCRIPT_MUL_FACTOR 1.5
+
+typedef unsigned short wxTextAttrDimensionFlags;
+
+// Miscelaneous text box flags
+enum wxTextBoxAttrFlags
+{
+ wxTEXT_BOX_ATTR_FLOAT = 0x00000001,
+ wxTEXT_BOX_ATTR_CLEAR = 0x00000002,
+ wxTEXT_BOX_ATTR_COLLAPSE_BORDERS = 0x00000004
+};
+
+// Whether a value is present, used in dimension flags
+enum wxTextAttrValueFlags
+{
+ wxTEXT_ATTR_VALUE_PRESENT = 0x1000,
+ wxTEXT_ATTR_VALUE_PRESENT_MASK = 0x1000
+};
+
+// Units - included in the dimension value
+enum wxTextAttrUnits
+{
+ wxTEXT_ATTR_UNITS_TENTHS_MM = 0x0001,
+ wxTEXT_ATTR_UNITS_PIXELS = 0x0002,
+ wxTEXT_ATTR_UNITS_PERCENTAGE = 0x0004,
+ wxTEXT_ATTR_UNITS_POINTS = 0x0008,
+
+ wxTEXT_ATTR_UNITS_MASK = 0x000F
+};
+
+// Position - included in the dimension flags
+enum wxTextBoxAttrPosition
+{
+ wxTEXT_BOX_ATTR_POSITION_STATIC = 0x0000, // Default is static, i.e. as per normal layout
+ wxTEXT_BOX_ATTR_POSITION_RELATIVE = 0x0010,
+ wxTEXT_BOX_ATTR_POSITION_ABSOLUTE = 0x0020,
+
+ wxTEXT_BOX_ATTR_POSITION_MASK = 0x00F0
+};
+
+// Dimension, including units and position
+class WXDLLIMPEXP_RICHTEXT wxTextAttrDimension
+{
+public:
+ wxTextAttrDimension() { Reset(); }
+ wxTextAttrDimension(int value, wxTextAttrDimensionFlags flags = wxTEXT_ATTR_VALUE_PRESENT|wxTEXT_ATTR_UNITS_TENTHS_MM) { m_value = value; m_flags = flags; }
+
+ void Reset() { m_value = 0; m_flags = 0; }
+
+ // Partial equality test
+ bool EqPartial(const wxTextAttrDimension& dim) const;
+
+ // Apply
+ bool Apply(const wxTextAttrDimension& dim, const wxTextAttrDimension* 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 wxTextAttrDimension& attr, wxTextAttrDimension& clashingAttr, wxTextAttrDimension& absentAttr);
+
+ bool operator==(const wxTextAttrDimension& dim) const { return m_value == dim.m_value && m_flags == dim.m_flags; }
+
+ int GetValue() const { return m_value; }
+ float GetValueMM() const { return float(m_value) / 10.0; }
+ void SetValueMM(float value) { m_value = (int) ((value * 10.0) + 0.5); m_flags |= wxTEXT_ATTR_VALUE_PRESENT; }
+ void SetValue(int value) { m_value = value; m_flags |= wxTEXT_ATTR_VALUE_PRESENT; }
+ void SetValue(int value, wxTextAttrDimensionFlags flags) { m_value = value; m_flags = flags; }
+
+ wxTextAttrUnits GetUnits() const { return (wxTextAttrUnits) (m_flags & wxTEXT_ATTR_UNITS_MASK); }
+ void SetUnits(wxTextAttrUnits units) { m_flags &= ~wxTEXT_ATTR_UNITS_MASK; m_flags |= units; }
+
+ wxTextBoxAttrPosition GetPosition() const { return (wxTextBoxAttrPosition) (m_flags & wxTEXT_BOX_ATTR_POSITION_MASK); }
+ void SetPosition(wxTextBoxAttrPosition pos) { m_flags &= ~wxTEXT_BOX_ATTR_POSITION_MASK; m_flags |= pos; }
+
+ bool IsPresent() const { return (m_flags & wxTEXT_ATTR_VALUE_PRESENT) != 0; }
+ void SetPresent(bool b) { m_flags &= ~wxTEXT_ATTR_VALUE_PRESENT_MASK; m_flags |= (b ? wxTEXT_ATTR_VALUE_PRESENT : 0); }
+
+ int m_value;
+ wxTextAttrDimensionFlags m_flags;
+};
+
+class WXDLLIMPEXP_RICHTEXT wxTextBoxAttrDimensions
+{
+public:
+ void Reset() { m_left.Reset(); m_top.Reset(); m_right.Reset(); m_bottom.Reset(); }
+
+ bool operator==(const wxTextBoxAttrDimensions& 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 wxTextBoxAttrDimensions& dims) const;
+
+ // Apply border to 'this', but not if the same as compareWith
+ bool Apply(const wxTextBoxAttrDimensions& dims, const wxTextBoxAttrDimensions* 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 wxTextBoxAttrDimensions& attr, wxTextBoxAttrDimensions& clashingAttr, wxTextBoxAttrDimensions& absentAttr);
+
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxTextBoxAttrDimensions& attr);
+
+ wxTextAttrDimension m_left;
+ wxTextAttrDimension m_top;
+ wxTextAttrDimension m_right;
+ wxTextAttrDimension m_bottom;
+};
+
+// Border styles
+enum wxTextBoxAttrBorderStyle
+{
+ 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 wxTextBoxAttrBorderFlags
+{
+ wxTEXT_BOX_ATTR_BORDER_STYLE = 0x0001,
+ wxTEXT_BOX_ATTR_BORDER_COLOUR = 0x0002
+};
+
+// 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 wxTextBoxAttrBorder
+{
+public:
+ wxTextBoxAttrBorder() { Reset(); }
+
+ bool operator==(const wxTextBoxAttrBorder& 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 wxTextBoxAttrBorder& border) const;
+
+ // Apply border to 'this', but not if the same as compareWith
+ bool Apply(const wxTextBoxAttrBorder& border, const wxTextBoxAttrBorder* compareWith = NULL);
+
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxTextBoxAttrBorder& 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 wxTextBoxAttrBorder& attr, wxTextBoxAttrBorder& clashingAttr, wxTextBoxAttrBorder& 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(); }
+
+ 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 wxTextBoxAttrBorders
+{
+public:
+ wxTextBoxAttrBorders() { }
+
+ bool operator==(const wxTextBoxAttrBorders& 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 wxTextBoxAttrBorders& borders) const;
+
+ // Apply border to 'this', but not if the same as compareWith
+ bool Apply(const wxTextBoxAttrBorders& borders, const wxTextBoxAttrBorders* compareWith = NULL);
+
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxTextBoxAttrBorders& 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 wxTextBoxAttrBorders& attr, wxTextBoxAttrBorders& clashingAttr, wxTextBoxAttrBorders& absentAttr);
+
+ wxTextBoxAttrBorder 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. Unecessary 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
+
+ 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
+
+ wxTextAttrDimension& GetLeft() { return m_position.m_left; }
+ const wxTextAttrDimension& GetLeft() const { return m_position.m_left; }
+
+ wxTextAttrDimension& GetRight() { return m_position.m_right; }
+ const wxTextAttrDimension& GetRight() const { return m_position.m_right; }
+
+ wxTextAttrDimension& GetTop() { return m_position.m_top; }
+ const wxTextAttrDimension& GetTop() const { return m_position.m_top; }
+
+ wxTextAttrDimension& GetBottom() { return m_position.m_bottom; }
+ const wxTextAttrDimension& GetBottom() const { return m_position.m_bottom; }
+
+ // Padding
+
+ wxTextAttrDimension& GetLeftPadding() { return m_padding.m_left; }
+ const wxTextAttrDimension& GetLeftPadding() const { return m_padding.m_left; }
+
+ wxTextAttrDimension& GetRightPadding() { return m_padding.m_right; }
+ const wxTextAttrDimension& GetRightPadding() const { return m_padding.m_right; }
+
+ wxTextAttrDimension& GetTopPadding() { return m_padding.m_top; }
+ const wxTextAttrDimension& GetTopPadding() const { return m_padding.m_top; }
+
+ wxTextAttrDimension& GetBottomPadding() { return m_padding.m_bottom; }
+ const wxTextAttrDimension& GetBottomPadding() const { return m_padding.m_bottom; }
+
+ // Border
+
+ wxTextBoxAttrBorders& GetBorder() { return m_border; }
+ const wxTextBoxAttrBorders& GetBorder() const { return m_border; }
+
+ wxTextBoxAttrBorder& GetLeftBorder() { return m_border.m_left; }
+ const wxTextBoxAttrBorder& GetLeftBorder() const { return m_border.m_left; }
+
+ wxTextBoxAttrBorder& GetTopBorder() { return m_border.m_top; }
+ const wxTextBoxAttrBorder& GetTopBorder() const { return m_border.m_top; }
+
+ wxTextBoxAttrBorder& GetRightBorder() { return m_border.m_right; }
+ const wxTextBoxAttrBorder& GetRightBorder() const { return m_border.m_right; }
+
+ wxTextBoxAttrBorder& GetBottomBorder() { return m_border.m_bottom; }
+ const wxTextBoxAttrBorder& GetBottomBorder() const { return m_border.m_bottom; }
+
+ // Outline
+
+ wxTextBoxAttrBorders& GetOutline() { return m_outline; }
+ const wxTextBoxAttrBorders& GetOutline() const { return m_outline; }
+
+ wxTextBoxAttrBorder& GetLeftOutline() { return m_outline.m_left; }
+ const wxTextBoxAttrBorder& GetLeftOutline() const { return m_outline.m_left; }
+
+ wxTextBoxAttrBorder& GetTopOutline() { return m_outline.m_top; }
+ const wxTextBoxAttrBorder& GetTopOutline() const { return m_outline.m_top; }
+
+ wxTextBoxAttrBorder& GetRightOutline() { return m_outline.m_right; }
+ const wxTextBoxAttrBorder& GetRightOutline() const { return m_outline.m_right; }
+
+ wxTextBoxAttrBorder& GetBottomOutline() { return m_outline.m_bottom; }
+ const wxTextBoxAttrBorder& GetBottomOutline() const { return m_outline.m_bottom; }
+
+
+ // Width and height
+
+ wxTextAttrDimension& GetWidth() { return m_width; }
+ const wxTextAttrDimension& GetWidth() const { return m_width; }
+
+ wxTextAttrDimension& GetHeight() { return m_height; }
+ const wxTextAttrDimension& GetHeight() const { return m_height; }
+
+public:
+
+ int m_flags;
+
+ wxTextBoxAttrDimensions m_margins;
+ wxTextBoxAttrDimensions m_padding;
+ wxTextBoxAttrDimensions m_position;
+
+ wxTextAttrDimension m_width;
+ wxTextAttrDimension m_height;
+
+ wxTextBoxAttrBorders m_border;
+ wxTextBoxAttrBorders m_outline;
+
+ short int m_floatMode;
+ short int m_clearMode;
+ short int m_collapseMode;
+};
+
+// ----------------------------------------------------------------------------
+// wxRichTextAttr: an enhanced attribute
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextAttr: public wxTextAttr
+{
+public:
+ wxRichTextAttr(const wxTextAttr& attr) { wxTextAttr::Copy(attr); }
+ wxRichTextAttr(const wxRichTextAttr& attr) { Copy(attr); }
+ wxRichTextAttr() {}
+
+ // Copy
+ void Copy(const wxRichTextAttr& attr);
+
+ // Assignment
+ void operator=(const wxRichTextAttr& attr) { Copy(attr); }
+ void operator=(const wxTextAttr& attr) { wxTextAttr::Copy(attr); }
+
+ // Equality test
+ bool operator==(const wxRichTextAttr& attr) const;
+
+ // Partial equality test taking comparison object into account
+ bool EqPartial(const wxRichTextAttr& 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 wxRichTextAttr& style, const wxRichTextAttr* 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 wxRichTextAttr& attr, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr);
+
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxRichTextAttr& attr);
+
+ wxTextBoxAttr& GetTextBoxAttr() { return m_textBoxAttr; }
+ const wxTextBoxAttr& GetTextBoxAttr() const { return m_textBoxAttr; }
+ void SetTextBoxAttr(const wxTextBoxAttr& attr) { m_textBoxAttr = attr; }
+
+ wxTextBoxAttr m_textBoxAttr;
+};