#endif
// Compatibility
-#define wxRichTextAttr wxTextAttr
+//#define wxRichTextAttr wxTextAttr
#define wxTextAttrEx wxTextAttr
// Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a
#define wxSCRIPT_MUL_FACTOR 1.5
-// Image align/floating
-#define wxRICHTEXT_LEFT 0x00
-#define wxRICHTEXT_CENTRE 0x01
-#define wxRICHTEXT_RIGHT 0x02
+typedef unsigned short wxTextAttrDimensionFlags;
-#define wxRICHTEXT_FLOAT_NONE 0x00
-#define wxRICHTEXT_FLOAT_LEFT 0x01
-#define wxRICHTEXT_FLOAT_RIGHT 0x02
+// Miscelaneous text box flags
+enum wxTextBoxAttrFlags
+{
+ wxTEXT_BOX_ATTR_FLOAT = 0x00000001,
+ wxTEXT_BOX_ATTR_CLEAR = 0x00000002,
+ wxTEXT_BOX_ATTR_COLLAPSE_BORDERS = 0x00000004
+};
-// Image width/height scale
-#define wxRICHTEXT_PX 0x00
-#define wxRICHTEXT_MM 0x01
+// Whether a value is present, used in dimension flags
+enum wxTextAttrValueFlags
+{
+ wxTEXT_ATTR_VALUE_PRESENT = 0x1000,
+ wxTEXT_ATTR_VALUE_PRESENT_MASK = 0x1000
+};
-/*!
- * wxRichTextAnchoredObjectAttr class declaration
- */
-class WXDLLIMPEXP_RICHTEXT wxRichTextAnchoredObjectAttr
+// 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_CORE wxTextAttrDimension
{
public:
- wxRichTextAnchoredObjectAttr() { Init(); }
- wxRichTextAnchoredObjectAttr(const wxRichTextAnchoredObjectAttr& attr) { Copy(attr); }
+ 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;
+};
- void Init();
+class WXDLLIMPEXP_CORE 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_CORE 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;
- void operator= (const wxRichTextAnchoredObjectAttr& attr) { Copy(attr); }
- void Copy(const wxRichTextAnchoredObjectAttr& attr);
+ // 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_CORE wxTextBoxAttrBorders
+{
+public:
+ wxTextBoxAttrBorders() { }
- /// Is this anchored? TODO: difference between anchored and floating?
- bool IsAnchored() const { return m_floating != wxRICHTEXT_FLOAT_NONE; }
+ 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;
+ }
- /// Is this floating?
- bool IsFloating() const { return m_floating != wxRICHTEXT_FLOAT_NONE; }
- void SetFloatingMode(int floating) { m_floating = floating; }
+ // Set style of all borders
+ void SetStyle(int style);
- int GetAlignment() const { return m_align; }
- void SetAlignment(int align) { m_align = align; }
+ // Set colour of all borders
+ void SetColour(unsigned long colour);
+ void SetColour(const wxColour& colour);
- int GetOffset() const { return m_offset; }
- void SetOffset(int offset) { m_offset = offset; }
+ // 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(); }
- int GetUnitsOffset() const { return m_unitsOffset; }
- void SetUnitsOffset(int offset) { m_unitsOffset = offset; }
+ // Partial equality test
+ bool EqPartial(const wxTextBoxAttrBorders& borders) const;
- int GetUnitsW() const { return m_unitsW; }
- void SetUnitsW(int u) { m_unitsW = u; }
+ // Apply border to 'this', but not if the same as compareWith
+ bool Apply(const wxTextBoxAttrBorders& borders, const wxTextBoxAttrBorders* compareWith = NULL);
- int GetUnitsH() const { return m_unitsH; }
- void SetUnitsH(int u) { m_unitsH = u; }
+ // Remove specified attributes from this object
+ bool RemoveStyle(const wxTextBoxAttrBorders& attr);
- int GetWidth() const { return m_width; }
- void SetWidth(int w) { m_width = w; }
+ // 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);
- int GetHeight() const { return m_height; }
- void SetHeight(int h) { m_height = h; }
+ wxTextBoxAttrBorder m_left, m_right, m_top, m_bottom;
- int m_align;
- int m_floating;
- int m_offset;
- int m_unitsOffset;
- int m_unitsW, m_unitsH;
- int m_width, m_height;
+};
+
+// ----------------------------------------------------------------------------
+// wxTextBoxAttr: a structure containing box attributes
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE 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;
};
/*!
bool IsOk() const { return m_refData != NULL; }
- wxFont FindFont(const wxTextAttr& fontSpec);
+ wxFont FindFont(const wxRichTextAttr& fontSpec);
void Clear();
void operator= (const wxRichTextFontTable& table);
// virtual bool IsPlaceHolding() const { return false; }
/// Floating direction
- virtual int GetFloatDirection() const { return wxRICHTEXT_FLOAT_NONE; }
+ virtual int GetFloatDirection() const { return wxTEXT_BOX_ATTR_FLOAT_NONE; }
/// Get any text in this object for the given range
virtual wxString GetTextForRange(const wxRichTextRange& WXUNUSED(range)) const { return wxEmptyString; }
virtual int GetBottomMargin() const { return m_bottomMargin; }
/// Set attributes object
- void SetAttributes(const wxTextAttr& attr) { m_attributes = attr; }
- const wxTextAttr& GetAttributes() const { return m_attributes; }
- wxTextAttr& GetAttributes() { return m_attributes; }
+ void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; }
+ const wxRichTextAttr& GetAttributes() const { return m_attributes; }
+ wxRichTextAttr& GetAttributes() { return m_attributes; }
/// Set/get stored descent
void SetDescent(int descent) { m_descent = descent; }
int ConvertTenthsMMToPixels(wxDC& dc, int units) const;
static int ConvertTenthsMMToPixels(int ppi, int units);
+ /// Convert units in pixels to tenths of a millimetre
+ int ConvertPixelsToTenthsMM(wxDC& dc, int pixels) const;
+ static int ConvertPixelsToTenthsMM(int ppi, int pixels);
+
protected:
wxSize m_size;
wxPoint m_pos;
int m_bottomMargin;
/// Attributes
- wxTextAttr m_attributes;
+ wxRichTextAttr m_attributes;
};
WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_RICHTEXT );
virtual void Reset();
/// Convenience function to add a paragraph of text
- virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttr* paraStyle = NULL);
+ virtual wxRichTextRange AddParagraph(const wxString& text, wxRichTextAttr* paraStyle = NULL);
/// Convenience function to add an image
- virtual wxRichTextRange AddImage(const wxImage& image, wxTextAttr* paraStyle = NULL);
+ virtual wxRichTextRange AddImage(const wxImage& image, wxRichTextAttr* paraStyle = NULL);
/// Adds multiple paragraphs, based on newlines.
- virtual wxRichTextRange AddParagraphs(const wxString& text, wxTextAttr* paraStyle = NULL);
+ virtual wxRichTextRange AddParagraphs(const wxString& text, wxRichTextAttr* paraStyle = NULL);
/// Get the line at the given position. If caretPosition is true, the position is
/// a caret position, which is normally a smaller number.
virtual bool PositionToXY(long pos, long* x, long* y) const;
/// Set text attributes: character and/or paragraph styles.
- virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+ virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
/// Set image attribute
- void SetImageStyle(wxRichTextImage *image, const wxRichTextAnchoredObjectAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+ void SetImageStyle(wxRichTextImage *image, const wxRichTextAttr& textAttr, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
/// Get the conbined text attributes for this position.
- virtual bool GetStyle(long position, wxTextAttr& style);
+ virtual bool GetStyle(long position, wxRichTextAttr& style);
/// Get the content (uncombined) attributes for this position.
- virtual bool GetUncombinedStyle(long position, wxTextAttr& style);
+ 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, wxTextAttr& style, bool combineStyles = true);
+ virtual bool DoGetStyle(long position, wxRichTextAttr& style, bool combineStyles = true);
/// Get the combined style for a range - if any attribute is different within the range,
/// that attribute is not present within the flags
- virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style);
+ virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
/// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
/// content.
- bool CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes, int& absentStyleAttributes, int& absentTextEffectAttributes);
+ bool CollectStyle(wxRichTextAttr& currentStyle, const wxRichTextAttr& style, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr);
/// Set list style
virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
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, wxTextAttr& attr) const;
+ virtual bool FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const;
/// 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 wxTextAttr& style) const;
+ 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 wxTextAttr& style) const;
+ virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const;
/// Clone
virtual wxRichTextObject* Clone() const { return new wxRichTextParagraphLayoutBox(*this); }
/// Set default style for new content. Setting it to a default attribute
/// makes new content take on the 'basic' style.
- virtual bool SetDefaultStyle(const wxTextAttr& style);
+ virtual bool SetDefaultStyle(const wxRichTextAttr& style);
/// Get default style
- virtual const wxTextAttr& GetDefaultStyle() const { return m_defaultAttributes; }
+ virtual const wxRichTextAttr& GetDefaultStyle() const { return m_defaultAttributes; }
/// Set basic (overall) style
- virtual void SetBasicStyle(const wxTextAttr& style) { m_attributes = style; }
+ virtual void SetBasicStyle(const wxRichTextAttr& style) { m_attributes = style; }
/// Get basic (overall) style
- virtual const wxTextAttr& GetBasicStyle() const { return m_attributes; }
+ virtual const wxRichTextAttr& GetBasicStyle() const { return m_attributes; }
/// Invalidate the buffer. With no argument, invalidates whole buffer.
void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL);
protected:
wxRichTextCtrl* m_ctrl;
- wxTextAttr m_defaultAttributes;
+ wxRichTextAttr m_defaultAttributes;
/// The invalidated range that will need full layout
wxRichTextRange m_invalidRange;
public:
// Constructors
- wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttr* style = NULL);
- wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttr* paraStyle = NULL, wxTextAttr* charStyle = NULL);
+ wxRichTextParagraph(wxRichTextObject* parent = NULL, wxRichTextAttr* style = NULL);
+ wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxRichTextAttr* paraStyle = NULL, wxRichTextAttr* charStyle = NULL);
virtual ~wxRichTextParagraph();
wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { Copy(obj); }
// Implementation
/// Apply paragraph styles such as centering to the wrapped lines
- virtual void ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect, wxDC& dc);
+ virtual void ApplyParagraphStyle(const wxRichTextAttr& attr, const wxRect& rect, wxDC& dc);
/// Insert text at the given position
virtual bool InsertText(long pos, const wxString& text);
/// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically
/// retrieve the actual style.
- wxTextAttr GetCombinedAttributes(const wxTextAttr& contentStyle) const;
+ wxRichTextAttr GetCombinedAttributes(const wxRichTextAttr& contentStyle) const;
/// Get combined attributes of the base style and paragraph style.
- wxTextAttr GetCombinedAttributes() const;
+ wxRichTextAttr GetCombinedAttributes() const;
/// Get the first position from pos that has a line break character.
long GetFirstLineBreakPosition(long pos);
public:
// Constructors
- wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxTextAttr* style = NULL);
+ wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxRichTextAttr* style = NULL);
wxRichTextPlainText(const wxRichTextPlainText& obj): wxRichTextObject() { Copy(obj); }
// Overrideables
/// Clone
virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); }
private:
- bool DrawTabbedString(wxDC& dc, const wxTextAttr& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected);
+ bool DrawTabbedString(wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected);
protected:
wxString m_text;
DECLARE_CLASS(wxRichTextAnchoredObject)
public:
// Constructors
- wxRichTextAnchoredObject(wxRichTextObject* parent = NULL, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
+ wxRichTextAnchoredObject(wxRichTextObject* parent = NULL, const wxRichTextAttr& attr = wxRichTextAttr());
wxRichTextAnchoredObject(const wxRichTextAnchoredObject& obj) : wxRichTextObject(obj) /* , m_ph(NULL) */ { Copy(obj); }
~wxRichTextAnchoredObject();
virtual bool IsFloatable() const { return true; }
/// Whether this object is currently floating
- virtual bool IsFloating() const { return m_anchoredAttr.m_floating != wxRICHTEXT_FLOAT_NONE; }
+ virtual bool IsFloating() const { return GetAttributes().GetTextBoxAttr().IsFloating(); }
virtual void SetParent(wxRichTextObject* parent);
// Accessors
- const wxRichTextAnchoredObjectAttr& GetAnchoredAttr() const { return m_anchoredAttr; }
- void SetAnchoredAttr(const wxRichTextAnchoredObjectAttr& attr);
/// The floating direction
- virtual int GetFloatDirection() const { return m_anchoredAttr.m_floating; }
+ virtual int GetFloatDirection() const { return GetAttributes().GetTextBoxAttr().GetFloatMode(); }
void operator=(const wxRichTextAnchoredObject&) { wxASSERT("Nobody can reset this object using ="); }
void Copy(const wxRichTextAnchoredObject& obj);
protected:
- wxRichTextAnchoredObjectAttr m_anchoredAttr;
+
};
/*!
// Constructors
wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextAnchoredObject(parent) { }
- wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxTextAttr* charStyle = NULL);
- wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxTextAttr* charStyle = NULL);
+ wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL, wxRichTextAttr* charStyle = NULL);
+ wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxRichTextAttr* charStyle = NULL);
wxRichTextImage(const wxRichTextImage& obj): wxRichTextAnchoredObject(obj) { Copy(obj); }
// Overrideables
int GetHandlerFlags() const { return m_handlerFlags; }
/// Convenience function to add a paragraph of text
- virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttr* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); }
+ virtual wxRichTextRange AddParagraph(const wxString& text, wxRichTextAttr* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); }
/// Begin collapsing undo/redo commands. Note that this may not work properly
/// if combining commands that delete or insert content, changing ranges for
virtual bool CanPasteFromClipboard() const;
/// Begin using a style
- virtual bool BeginStyle(const wxTextAttr& style);
+ virtual bool BeginStyle(const wxRichTextAttr& style);
/// End the style
virtual bool EndStyle();
bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int flags = 0);
/// Submit command to insert the given image
- bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags = 0, const wxRichTextAnchoredObjectAttr& floatAttr = wxRichTextAnchoredObjectAttr());
+ bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags = 0,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Submit command to insert an object
bool InsertObjectWithUndo(long pos, wxRichTextObject *object, wxRichTextCtrl* ctrl, int flags);
/// Get the style that is appropriate for a new paragraph at this position.
/// If the previous paragraph has a paragraph style name, look up the next-paragraph
/// style.
- wxTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const;
+ wxRichTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const;
/// Dumps contents of buffer for debugging purposes
virtual void Dump();
virtual ~wxRichTextRenderer() {}
/// Draw a standard bullet, as specified by the value of GetBulletName
- virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect) = 0;
+ virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect) = 0;
/// Draw a bullet that can be described by text, such as numbered or symbol bullets
- virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text) = 0;
+ virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, const wxString& text) = 0;
/// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
- virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect) = 0;
+ virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect) = 0;
/// Enumerate the standard bullet names currently supported
virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0;
wxRichTextStdRenderer() {}
/// Draw a standard bullet, as specified by the value of GetBulletName
- virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect);
+ virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect);
/// Draw a bullet that can be described by text, such as numbered or symbol bullets
- virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text);
+ virtual bool DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, const wxString& text);
/// Draw a bitmap bullet, where the bullet bitmap is specified by the value of GetBulletName
- virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect);
+ virtual bool DrawBitmapBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect);
/// Enumerate the standard bullet names currently supported
virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames);
}
/// Compare two attribute objects
-WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2);
-WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2);
+WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2);
+WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2);
/// Compare two attribute objects, but take into account the flags
/// specifying attributes of interest.
-WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttr& attr1, const wxTextAttr& attr2, int flags);
+WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2);
/// Apply one style to another
-WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttr& destStyle, const wxTextAttr& style, wxTextAttr* compareWith = NULL);
+WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
// Remove attributes
-WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style);
+WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style);
/// Combine two bitlists
WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB);
WXDLLIMPEXP_RICHTEXT bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags);
/// Split into paragraph and character styles
-WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle);
+WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxRichTextAttr& style, wxRichTextAttr& parStyle, wxRichTextAttr& charStyle);
/// Compare tabs
WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2);
/// Convert a decimal to Roman numerals
WXDLLIMPEXP_RICHTEXT wxString wxRichTextDecimalToRoman(long n);
+// 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.
+WXDLLIMPEXP_RICHTEXT void wxTextAttrCollectCommonAttributes(wxTextAttr& currentStyle, const wxTextAttr& attr, wxTextAttr& clashingAttr, wxTextAttr& absentAttr);
+
WXDLLIMPEXP_RICHTEXT void wxRichTextModuleInit();
#endif
virtual bool TransferDataToWindow();
/// Gets the attributes associated with the main formatting dialog
- wxTextAttr* GetAttributes();
+ wxRichTextAttr* GetAttributes();
/// Update for symbol-related controls
void OnSymbolUpdate( wxUpdateUIEvent& event );
* wxRichTextCtrl class declaration
*/
-class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxTextCtrlBase,
+class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxControl,
+ public wxTextCtrlIface,
public wxScrollHelper
{
DECLARE_CLASS( wxRichTextCtrl )
virtual bool DoSaveFile(const wxString& file = wxEmptyString,
int fileType = wxRICHTEXT_TYPE_ANY);
+ // implement the wxTextEntry pure virtual method
+ virtual wxWindow *GetEditableWindow() { return this; }
+
/// Set the handler flags, controlling loading and saving
void SetHandlerFlags(int flags) { GetBuffer().SetHandlerFlags(flags); }
// methods allow to apply the given text style to the given selection or to
// set/get the style which will be used for all appended text
virtual bool SetStyle(long start, long end, const wxTextAttr& style);
+ virtual bool SetStyle(long start, long end, const wxRichTextAttr& style);
virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style);
+ virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style);
virtual bool GetStyle(long position, wxTextAttr& style);
+ virtual bool GetStyle(long position, wxRichTextAttr& style);
// Set an image style
- void SetImageStyle(wxRichTextImage *image, const wxRichTextAnchoredObjectAttr& style);
+ void SetImageStyle(wxRichTextImage *image, const wxRichTextAttr& textAttr);
// get the common set of styles for the range
virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style);
+ virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
// extended style setting operation with flags including:
// wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY, wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY
// see richtextbuffer.h for more details.
- virtual bool SetStyleEx(const wxRichTextRange& range, const wxTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+ virtual bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
/// Get the content (uncombined) attributes for this position.
- virtual bool GetUncombinedStyle(long position, wxTextAttr& style);
+ virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style);
virtual bool SetDefaultStyle(const wxTextAttr& style);
+ virtual bool SetDefaultStyle(const wxRichTextAttr& style);
- virtual const wxTextAttr& GetDefaultStyleEx() const { return GetDefaultStyle(); }
+ virtual const wxRichTextAttr& GetDefaultStyleEx() const;
- virtual const wxTextAttr& GetDefaultStyle() const;
+ //virtual const wxTextAttr& GetDefaultStyle() const;
/// Set list style
virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
/// Write an image at the current insertion point. Supply optional type to use
/// for internal and file storage of the raw data.
- virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
+ virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Write a bitmap at the current insertion point. Supply optional type to use
/// for internal and file storage of the raw data.
- virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
+ virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Load an image from file and write at the current insertion point.
- virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
+ virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Write an image block at the current insertion point.
- virtual bool WriteImage(const wxRichTextImageBlock& imageBlock, const wxRichTextAnchoredObjectAttr& attr = wxRichTextAnchoredObjectAttr());
+ virtual bool WriteImage(const wxRichTextImageBlock& imageBlock,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
/// Insert a newline (actually paragraph) at the current insertion point.
virtual bool Newline();
virtual bool LineBreak();
/// Set basic (overall) style
- virtual void SetBasicStyle(const wxTextAttr& style) { GetBuffer().SetBasicStyle(style); }
+ virtual void SetBasicStyle(const wxRichTextAttr& style) { GetBuffer().SetBasicStyle(style); }
/// Get basic (overall) style
- virtual const wxTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); }
+ virtual const wxRichTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); }
- virtual bool BeginStyle(const wxTextAttr& style) { return GetBuffer().BeginStyle(style); }
+ virtual bool BeginStyle(const wxRichTextAttr& style) { return GetBuffer().BeginStyle(style); }
/// End the style
virtual bool EndStyle() { return GetBuffer().EndStyle(); }
/// 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 wxTextAttr& style) const
+ virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const
{
return GetBuffer().HasCharacterAttributes(range.ToInternal(), style);
}
/// 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 wxTextAttr& style) const
+ virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const
{
return GetBuffer().HasParagraphAttributes(range.ToInternal(), style);
}
/// Convenience function that tells the control to start reflecting the default
/// style, since the user is changing it.
- void SetAndShowDefaultStyle(const wxTextAttr& attr)
+ void SetAndShowDefaultStyle(const wxRichTextAttr& attr)
{
SetDefaultStyle(attr);
SetCaretPositionForDefaultStyle(GetCaretPosition());
void OnColourClicked( wxCommandEvent& event );
/// Gets the attributes associated with the main formatting dialog
- wxTextAttr* GetAttributes();
+ wxRichTextAttr* GetAttributes();
////@begin wxRichTextFontPage event handler declarations
virtual bool GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range);
/// Set the attributes and optionally update the display
- virtual bool SetStyle(const wxTextAttr& style, bool update = true);
+ virtual bool SetStyle(const wxRichTextAttr& style, bool update = true);
/// Set the style definition and optionally update the display
virtual bool SetStyleDefinition(const wxRichTextStyleDefinition& styleDef, wxRichTextStyleSheet* sheet, bool update = true);
virtual bool ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE);
/// Gets and sets the attributes
- const wxTextAttr& GetAttributes() const { return m_attributes; }
- wxTextAttr& GetAttributes() { return m_attributes; }
- void SetAttributes(const wxTextAttr& attr) { m_attributes = attr; }
+ const wxRichTextAttr& GetAttributes() const { return m_attributes; }
+ wxRichTextAttr& GetAttributes() { return m_attributes; }
+ void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; }
/// Transfers the data and from to the window
virtual bool TransferDataToWindow();
static wxRichTextFormattingDialog* GetDialog(wxWindow* win);
/// Helper for pages to get the attributes
- static wxTextAttr* GetDialogAttributes(wxWindow* win);
+ static wxRichTextAttr* GetDialogAttributes(wxWindow* win);
/// Helper for pages to get the style
static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win);
protected:
wxImageList* m_imageList;
- wxTextAttr m_attributes;
+ wxRichTextAttr m_attributes;
wxRichTextStyleDefinition* m_styleDefinition;
wxRichTextStyleSheet* m_styleSheet;
wxArrayInt m_pageIds; // mapping of book control indexes to page ids
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
/// Output character formatting
- void BeginCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& paraStyle, wxTextOutputStream& stream );
- void EndCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& paraStyle, wxTextOutputStream& stream );
+ void BeginCharacterFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, const wxRichTextAttr& paraStyle, wxTextOutputStream& stream );
+ void EndCharacterFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, const wxRichTextAttr& paraStyle, wxTextOutputStream& stream );
/// Output paragraph formatting
- void BeginParagraphFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, wxTextOutputStream& stream);
- void EndParagraphFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, wxTextOutputStream& stream);
+ void BeginParagraphFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, wxTextOutputStream& stream);
+ void EndParagraphFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, wxTextOutputStream& stream);
/// Output font tag
- void OutputFont(const wxTextAttr& style, wxTextOutputStream& stream);
+ void OutputFont(const wxRichTextAttr& style, wxTextOutputStream& stream);
/// Closes lists to level (-1 means close all)
void CloseLists(int level, wxTextOutputStream& str);
const wxChar* GetMimeType(int imageType);
/// Gets the html equivalent of the specified value
- wxString GetAlignment(const wxTextAttr& thisStyle);
+ wxString GetAlignment(const wxRichTextAttr& thisStyle);
/// Generates array for indentations
wxString SymbolicIndent(long indent);
/// Finds the html equivalent of the specified bullet
- int TypeOfList(const wxTextAttr& thisStyle, wxString& tag);
+ int TypeOfList(const wxRichTextAttr& thisStyle, wxString& tag);
#endif
// Data members
/// Creates the controls and sizers
void CreateControls();
+ /// Set the dimension into the value and units controls
+ void SetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl);
+
+ /// Get the dimension from the value and units controls
+ void GetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl);
+
////@begin wxRichTextImageDialog event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTIMAGEDIALOG_PARA_UP
static bool ShowToolTips();
/// Set the image attribute
- void SetImageAttr(const wxRichTextAnchoredObjectAttr& attr);
+ void SetImageAttr(const wxRichTextAttr& textAttr);
wxRichTextImage* ApplyImageAttr();
/// Set the anchored object
/// Convert CM to MM
bool ConvertFromString(const wxString& string, int& ret, int scale);
private:
- wxRichTextAnchoredObjectAttr m_attr;
+ wxRichTextAttr m_textAttr;
+
////@begin wxRichTextImageDialog member variables
- wxComboBox* m_alignment;
wxComboBox* m_float;
wxTextCtrl* m_width;
wxComboBox* m_unitsW;
/// Control identifiers
enum {
ID_WXRICHTEXTIMAGEPAGE = 10015,
- ID_COMBOBOX_ALIGN = 10016,
ID_RICHTEXTIMAGEDIALOG_FLOATING_MODE = 10017,
ID_RICHTEXTIMAGEDIALOG_WIDTH = 10018,
ID_RICHTEXTIMAGEDIALOG_UNITS_W = 10019,
void UpdatePreview();
/// Gets the attributes associated with the main formatting dialog
- wxTextAttr* GetAttributes();
+ wxRichTextAttr* GetAttributes();
////@begin wxRichTextIndentsSpacingPage event handler declarations
virtual bool TransferDataToWindow();
/// Get attributes for selected level
- wxTextAttr* GetAttributesForSelection();
+ wxRichTextAttr* GetAttributesForSelection();
/// Update for symbol-related controls
void OnSymbolUpdate( wxUpdateUIEvent& event );
virtual bool TransferDataToWindow();
/// Gets the attributes associated with the main formatting dialog
- wxTextAttr* GetAttributes();
+ wxRichTextAttr* GetAttributes();
////@begin wxRichTextStylePage event handler declarations
const wxString& GetBaseStyle() const { return m_baseStyle; }
/// Sets and gets the style
- void SetStyle(const wxTextAttr& style) { m_style = style; }
- const wxTextAttr& GetStyle() const { return m_style; }
- wxTextAttr& GetStyle() { return m_style; }
+ void SetStyle(const wxRichTextAttr& style) { m_style = style; }
+ const wxRichTextAttr& GetStyle() const { return m_style; }
+ wxRichTextAttr& GetStyle() { return m_style; }
/// Gets the style combined with the base style
- virtual wxTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
+ virtual wxRichTextAttr GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const;
protected:
wxString m_name;
wxString m_baseStyle;
wxString m_description;
- wxTextAttr m_style;
+ wxRichTextAttr m_style;
};
/*!
virtual wxRichTextStyleDefinition* Clone() const { return new wxRichTextListStyleDefinition(*this); }
/// Sets/gets the attributes for the given level
- void SetLevelAttributes(int i, const wxTextAttr& attr);
- wxTextAttr* GetLevelAttributes(int i);
- const wxTextAttr* GetLevelAttributes(int i) const;
+ void SetLevelAttributes(int i, const wxRichTextAttr& attr);
+ wxRichTextAttr* GetLevelAttributes(int i);
+ const wxRichTextAttr* GetLevelAttributes(int i) const;
/// Convenience function for setting the major attributes for a list level specification
void SetAttributes(int i, int leftIndent, int leftSubIndent, int bulletStyle, const wxString& bulletSymbol = wxEmptyString);
/// Combine the base and list style with a paragraph style, using the given indent (from which
/// an appropriate level is found)
- wxTextAttr CombineWithParagraphStyle(int indent, const wxTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet = NULL);
+ wxRichTextAttr CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet = NULL);
/// Combine the base and list style, using the given indent (from which
/// an appropriate level is found)
- wxTextAttr GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet = NULL);
+ wxRichTextAttr GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet = NULL);
/// Combine the base and list style, using the given level from which
/// an appropriate level is found)
- wxTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL);
+ wxRichTextAttr GetCombinedStyleForLevel(int level, wxRichTextStyleSheet* styleSheet = NULL);
/// Gets the number of available levels
int GetLevelCount() const { return 10; }
protected:
/// The styles for each level (up to 10)
- wxTextAttr m_levelStyles[10];
+ wxRichTextAttr m_levelStyles[10];
};
/*!
virtual void SortTabs();
/// Gets the attributes associated with the main formatting dialog
- wxTextAttr* GetAttributes();
+ wxRichTextAttr* GetAttributes();
////@begin wxRichTextTabsPage event handler declarations
bool ImportStyleDefinition(wxRichTextStyleSheet* sheet, wxXmlNode* node);
/// Create style parameters
- wxString CreateStyle(const wxTextAttr& attr, bool isPara = false);
+ wxString CreateStyle(const wxRichTextAttr& attr, bool isPara = false);
/// Get style parameters
- bool GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara = false);
+ bool GetStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara = false);
#endif
/// Can we save using this handler?
// Equality test
bool operator== (const wxTextAttr& attr) const;
- // Partial equality test taking flags into account
- bool EqPartial(const wxTextAttr& attr, int flags) const;
+ // Partial equality test
+ bool EqPartial(const wxTextAttr& attr) const;
// Get attributes from font.
bool GetFontAttributes(const wxFont& font, int flags = wxTEXT_ATTR_FONT);
bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); }
bool HasFlag(long flag) const { return (m_flags & flag) != 0; }
+ void RemoveFlag(long flag) { m_flags &= ~flag; }
+ void AddFlag(long flag) { m_flags |= flag; }
// Is this a character style?
bool IsCharacterStyle() const { return HasFlag(wxTEXT_ATTR_CHARACTER); }
return GetFlags() == 0;
}
- // Merges the given attributes. Does not affect 'this'. If compareWith
+ // 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 wxTextAttr& style, const wxTextAttr* compareWith = NULL);
-
+
// merges the attributes of the base and the overlay objects and returns
// the result; the parameter attributes take precedence
//
r.EndAlignment();
r.BeginAlignment(wxTEXT_ALIGNMENT_LEFT);
- wxRichTextAnchoredObjectAttr anchoredAttr;
- anchoredAttr.m_floating = wxRICHTEXT_FLOAT_LEFT;
+ wxRichTextAttr imageAttr;
+ imageAttr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_LEFT);
r.WriteText(wxString(wxT("This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side.")));
- r.WriteImage(wxBitmap(zebra_xpm), wxBITMAP_TYPE_PNG, anchoredAttr);
- anchoredAttr.m_floating = wxRICHTEXT_FLOAT_RIGHT;
- anchoredAttr.m_offset = 200;
- r.WriteImage(wxBitmap(zebra_xpm), wxBITMAP_TYPE_PNG, anchoredAttr);
+ r.WriteImage(wxBitmap(zebra_xpm), wxBITMAP_TYPE_PNG, imageAttr);
+ imageAttr.GetTextBoxAttr().GetTop().SetValue(200);
+ imageAttr.GetTextBoxAttr().GetTop().SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
+ imageAttr.GetTextBoxAttr().SetFloatMode(wxTEXT_BOX_ATTR_FLOAT_RIGHT);
+ r.WriteImage(wxBitmap(zebra_xpm), wxBITMAP_TYPE_PNG, imageAttr);
r.WriteText(wxString(wxT("This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side.")));
r.EndAlignment();
r.Newline();
tabs.Add(600);
tabs.Add(800);
tabs.Add(1000);
- wxTextAttrEx attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_TABS);
attr.SetTabs(tabs);
r.SetDefaultStyle(attr);
wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
wxFontData fontData;
- wxTextAttrEx attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT);
if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr))
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
{
- wxGetApp().GetPrinting()->PageSetup();
+ wxDialog dialog(this, wxID_ANY, wxT("Testing"), wxPoint(10, 10), wxSize(400, 300), wxDEFAULT_DIALOG_STYLE);
+
+ wxNotebook* nb = new wxNotebook(& dialog, wxID_ANY, wxPoint(5, 5), wxSize(300, 250));
+ wxPanel* panel = new wxPanel(nb, wxID_ANY, wxDefaultPosition, wxDefaultSize);
+ wxPanel* panel2 = new wxPanel(nb, wxID_ANY, wxDefaultPosition, wxDefaultSize);
+
+ wxRichTextCtrl* richTextCtrl = new wxRichTextCtrl(panel, wxID_ANY, wxEmptyString, wxPoint(5, 5), wxSize(200, 150), wxVSCROLL|wxTE_READONLY);
+ nb->AddPage(panel, wxT("Page 1"));
+
+ wxRichTextCtrl* richTextCtrl2 = new wxRichTextCtrl(panel2, wxID_ANY, wxEmptyString, wxPoint(5, 5), wxSize(200, 150), wxVSCROLL|wxTE_READONLY);
+ nb->AddPage(panel2, wxT("Page 2"));
+
+ wxButton* button = new wxButton(& dialog, wxID_OK, wxT("OK"), wxPoint(5, 180));
+
+ dialog.ShowModal();
+
+// wxGetApp().GetPrinting()->PageSetup();
}
GetURL() == attr.GetURL();
}
-// Partial equality test taking flags into account
-bool wxTextAttr::EqPartial(const wxTextAttr& attr, int flags) const
+// Partial equality test. Only returns false if an attribute doesn't match.
+bool wxTextAttr::EqPartial(const wxTextAttr& attr) const
{
+ int flags = attr.GetFlags();
+
if ((flags & wxTEXT_ATTR_TEXT_COLOUR) && GetTextColour() != attr.GetTextColour())
return false;
int wxRichTextFloatCollector::GetFitPosition(int direction, int start, int height) const
{
- if (direction == wxRICHTEXT_FLOAT_LEFT)
+ if (direction == wxTEXT_BOX_ATTR_FLOAT_LEFT)
return GetFitPosition(m_left, start, height);
- else if (direction == wxRICHTEXT_FLOAT_RIGHT)
+ else if (direction == wxTEXT_BOX_ATTR_FLOAT_RIGHT)
return GetFitPosition(m_right, start, height);
else
{
void wxRichTextFloatCollector::CollectFloat(wxRichTextParagraph* para, wxRichTextObject* floating)
{
int direction = floating->GetFloatDirection();
+
wxPoint pos = floating->GetPosition();
wxSize size = floating->GetCachedSize();
wxRichTextFloatRectMap *map = new wxRichTextFloatRectMap(pos.y, pos.y + size.y, size.x, floating);
-
switch (direction)
{
- case wxRICHTEXT_FLOAT_NONE:
+ case wxTEXT_BOX_ATTR_FLOAT_NONE:
delete map;
break;
- case wxRICHTEXT_FLOAT_LEFT:
+ case wxTEXT_BOX_ATTR_FLOAT_LEFT:
// Just a not-enough simple assertion
wxASSERT (m_left.Index(map) == wxNOT_FOUND);
m_left.Add(map);
break;
- case wxRICHTEXT_FLOAT_RIGHT:
+ case wxTEXT_BOX_ATTR_FLOAT_RIGHT:
wxASSERT (m_right.Index(map) == wxNOT_FOUND);
m_right.Add(map);
break;
if (floating->IsFloating())
{
wxRichTextAnchoredObject* anchor = wxDynamicCast(floating, wxRichTextAnchoredObject);
- if (anchor && anchor->GetAnchoredAttr().IsAnchored())
+ if (anchor)
{
CollectFloat(para, floating);
}
dc.SetBrush(brush);
}
-void wxRichTextAnchoredObjectAttr::Init()
-{
- m_align = wxRICHTEXT_CENTRE;
- m_floating = wxRICHTEXT_FLOAT_NONE;
- m_offset = 0;
- m_unitsOffset = wxRICHTEXT_PX;
-
- m_unitsW = wxRICHTEXT_PX;
- m_unitsH = wxRICHTEXT_PX;
-
- // Unspecified to begin with (use actual image size)
- m_width = -1;
- m_height = -1;
-}
-
-void wxRichTextAnchoredObjectAttr::Copy(const wxRichTextAnchoredObjectAttr& attr)
-{
- m_align = attr.m_align;
- m_floating = attr.m_floating;
- m_offset = attr.m_offset;
- m_unitsOffset = attr.m_unitsOffset;
-
- m_unitsW = attr.m_unitsW;
- m_unitsH = attr.m_unitsH;
- m_width = attr.m_width;
- m_height = attr.m_height;
-}
-
/*!
* wxRichTextObject
* This is the base for drawable objects.
return (int) pixels;
}
+// Convert units in pixels to tenths of a millimetre
+int wxRichTextObject::ConvertPixelsToTenthsMM(wxDC& dc, int pixels) const
+{
+ int p = pixels;
+ if (GetBuffer() && GetBuffer()->GetScale() != 1.0)
+ p = (int) (double(p) * GetBuffer()->GetScale());
+ return ConvertPixelsToTenthsMM(dc.GetPPI().x, p);
+}
+
+int wxRichTextObject::ConvertPixelsToTenthsMM(int ppi, int pixels)
+{
+ // There are ppi pixels in 254.1 "1/10 mm"
+
+ int units = int( double(pixels) * 254.1 / (double) ppi );
+ return units;
+}
+
/// Dump to output stream for debugging
void wxRichTextObject::Dump(wxTextOutputStream& stream)
{
/// Convenience function to add a paragraph of text
-wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text, wxTextAttr* paraStyle)
+wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text, wxRichTextAttr* paraStyle)
{
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
- wxTextAttr defaultCharStyle;
- wxTextAttr defaultParaStyle;
+ wxRichTextAttr defaultCharStyle;
+ wxRichTextAttr defaultParaStyle;
// If the default style is a named paragraph style, don't apply any character formatting
// to the initial text string.
else
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
- wxTextAttr* pStyle = paraStyle ? paraStyle : (wxTextAttr*) & defaultParaStyle;
- wxTextAttr* cStyle = & defaultCharStyle;
+ wxRichTextAttr* pStyle = paraStyle ? paraStyle : (wxRichTextAttr*) & defaultParaStyle;
+ wxRichTextAttr* cStyle = & defaultCharStyle;
wxRichTextParagraph* para = new wxRichTextParagraph(text, this, pStyle, cStyle);
}
/// Adds multiple paragraphs, based on newlines.
-wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text, wxTextAttr* paraStyle)
+wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text, wxRichTextAttr* paraStyle)
{
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
- wxTextAttr defaultCharStyle;
- wxTextAttr defaultParaStyle;
+ wxRichTextAttr defaultCharStyle;
+ wxRichTextAttr defaultParaStyle;
// If the default style is a named paragraph style, don't apply any character formatting
// to the initial text string.
else
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
- wxTextAttr* pStyle = paraStyle ? paraStyle : (wxTextAttr*) & defaultParaStyle;
- wxTextAttr* cStyle = & defaultCharStyle;
+ wxRichTextAttr* pStyle = paraStyle ? paraStyle : (wxRichTextAttr*) & defaultParaStyle;
+ wxRichTextAttr* cStyle = & defaultCharStyle;
wxRichTextParagraph* firstPara = NULL;
wxRichTextParagraph* lastPara = NULL;
}
/// Convenience function to add an image
-wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxTextAttr* paraStyle)
+wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxRichTextAttr* paraStyle)
{
// Don't use the base style, just the default style, and the base style will
// be combined at display time.
// Divide into paragraph and character styles.
- wxTextAttr defaultCharStyle;
- wxTextAttr defaultParaStyle;
+ wxRichTextAttr defaultCharStyle;
+ wxRichTextAttr defaultParaStyle;
// If the default style is a named paragraph style, don't apply any character formatting
// to the initial text string.
else
wxRichTextSplitParaCharStyles(GetDefaultStyle(), defaultParaStyle, defaultCharStyle);
- wxTextAttr* pStyle = paraStyle ? paraStyle : (wxTextAttr*) & defaultParaStyle;
- wxTextAttr* cStyle = & defaultCharStyle;
+ wxRichTextAttr* pStyle = paraStyle ? paraStyle : (wxRichTextAttr*) & defaultParaStyle;
+ wxRichTextAttr* cStyle = & defaultCharStyle;
wxRichTextParagraph* para = new wxRichTextParagraph(this, pStyle);
AppendChild(para);
wxRichTextParagraph* para = GetParagraphAtPosition(position);
if (para)
{
- wxTextAttrEx originalAttr = para->GetAttributes();
+ wxRichTextAttr originalAttr = para->GetAttributes();
wxRichTextObjectList::compatibility_iterator node = m_children.Find(para);
// Save empty paragraph attributes for appending later
// These are character attributes deliberately set for a new paragraph. Without this,
// we couldn't pass default attributes when appending a new paragraph.
- wxTextAttrEx emptyParagraphAttributes;
+ wxRichTextAttr emptyParagraphAttributes;
wxRichTextObjectList::compatibility_iterator objectNode = firstPara->GetChildren().GetFirst();
obj->DeleteRange(range);
wxRichTextRange thisRange = obj->GetRange();
- wxTextAttrEx thisAttr = obj->GetAttributes();
+ wxRichTextAttr thisAttr = obj->GetAttributes();
// If the whole paragraph is within the range to delete,
// delete the whole thing.
bool applyFinalParagraphStyle = firstPara && nextParagraph && nextParagraph != firstPara;
- wxTextAttrEx nextParaAttr;
+ wxRichTextAttr nextParaAttr;
if (applyFinalParagraphStyle)
{
// Special case when deleting the end of a paragraph - use _this_ paragraph's style,
}
/// Set character or paragraph text attributes: apply character styles only to immediate text nodes
-bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const wxTextAttr& style, int flags)
+bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style, int flags)
{
bool characterStyle = false;
bool paragraphStyle = false;
bool removeStyle = ((flags & wxRICHTEXT_SETSTYLE_REMOVE) != 0);
// Apply paragraph style first, if any
- wxTextAttr wholeStyle(style);
+ wxRichTextAttr wholeStyle(style);
if (!removeStyle && wholeStyle.HasParagraphStyleName() && GetStyleSheet())
{
}
// Limit the attributes to be set to the content to only character attributes.
- wxTextAttr characterAttributes(wholeStyle);
+ wxRichTextAttr characterAttributes(wholeStyle);
characterAttributes.SetFlags(characterAttributes.GetFlags() & (wxTEXT_ATTR_CHARACTER));
if (!removeStyle && characterAttributes.HasCharacterStyleName() && GetStyleSheet())
{
// Only apply attributes that will make a difference to the combined
// style as seen on the display
- wxTextAttr combinedAttr(para->GetCombinedAttributes());
+ wxRichTextAttr combinedAttr(para->GetCombinedAttributes());
wxRichTextApplyStyle(newPara->GetAttributes(), wholeStyle, & combinedAttr);
}
else
{
// Only apply attributes that will make a difference to the combined
// style as seen on the display
- wxTextAttr combinedAttr(newPara->GetCombinedAttributes(child->GetAttributes()));
+ wxRichTextAttr combinedAttr(newPara->GetCombinedAttributes(child->GetAttributes()));
wxRichTextApplyStyle(child->GetAttributes(), characterAttributes, & combinedAttr);
}
else
return true;
}
-void wxRichTextParagraphLayoutBox::SetImageStyle(wxRichTextImage *image, const wxRichTextAnchoredObjectAttr& attr, int flags)
+void wxRichTextParagraphLayoutBox::SetImageStyle(wxRichTextImage *image, const wxRichTextAttr& textAttr, int flags)
{
bool withUndo = flags & wxRICHTEXT_SETSTYLE_WITH_UNDO;
bool haveControl = (GetRichTextCtrl() != NULL);
wxRichTextParagraph* newPara wxDUMMY_INITIALIZE(NULL);
wxRichTextParagraph* para = GetParagraphAtPosition(image->GetRange().GetStart());
wxRichTextAction *action = NULL;
- wxRichTextAnchoredObjectAttr oldAttr = image->GetAnchoredAttr();
+ wxRichTextAttr oldTextAttr = image->GetAttributes();
if (haveControl && withUndo)
{
action = new wxRichTextAction(NULL, _("Change Image Style"), wxRICHTEXT_CHANGE_STYLE, & GetRichTextCtrl()->GetBuffer(), GetRichTextCtrl());
action->SetRange(image->GetRange().FromInternal());
action->SetPosition(GetRichTextCtrl()->GetCaretPosition());
- image->SetAnchoredAttr(attr);
+ image->SetAttributes(textAttr);
+
// Set the new attribute
newPara = new wxRichTextParagraph(*para);
action->GetNewParagraphs().AppendChild(newPara);
// Change back to the old one
- image->SetAnchoredAttr(oldAttr);
+ image->SetAttributes(oldTextAttr);
action->GetOldParagraphs().AppendChild(new wxRichTextParagraph(*para));
}
else
}
/// Get the text attributes for this position.
-bool wxRichTextParagraphLayoutBox::GetStyle(long position, wxTextAttr& style)
+bool wxRichTextParagraphLayoutBox::GetStyle(long position, wxRichTextAttr& style)
{
return DoGetStyle(position, style, true);
}
-bool wxRichTextParagraphLayoutBox::GetUncombinedStyle(long position, wxTextAttr& style)
+bool wxRichTextParagraphLayoutBox::GetUncombinedStyle(long position, wxRichTextAttr& style)
{
return DoGetStyle(position, style, false);
}
/// Implementation helper for GetStyle. If combineStyles is true, combine base, paragraph and
/// context attributes.
-bool wxRichTextParagraphLayoutBox::DoGetStyle(long position, wxTextAttr& style, bool combineStyles)
+bool wxRichTextParagraphLayoutBox::DoGetStyle(long position, wxRichTextAttr& style, bool combineStyles)
{
wxRichTextObject* obj wxDUMMY_INITIALIZE(NULL);
/// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
/// content.
-bool wxRichTextParagraphLayoutBox::CollectStyle(wxTextAttr& currentStyle, const wxTextAttr& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes, int& absentStyleAttributes, int& absentTextEffectAttributes)
+bool wxRichTextParagraphLayoutBox::CollectStyle(wxRichTextAttr& currentStyle, const wxRichTextAttr& style, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr)
+{
+ currentStyle.CollectCommonAttributes(style, clashingAttr, absentAttr);
+
+ return true;
+}
+
+/// Get the combined style for a range - if any attribute is different within the range,
+/// that attribute is not present within the flags.
+/// *** Note that this is not recursive, and so assumes that content inside a paragraph is not itself
+/// nested.
+bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style)
{
- absentStyleAttributes |= (~style.GetFlags() & wxTEXT_ATTR_ALL);
- absentTextEffectAttributes |= (~style.GetTextEffectFlags() & 0xFFFF);
+ style = wxRichTextAttr();
+
+ wxRichTextAttr clashingAttr;
+ wxRichTextAttr absentAttrPara, absentAttrChar;
- if (style.HasFont())
+ wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst();
+ while (node)
{
- if (style.HasFontSize() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_SIZE))
+ wxRichTextParagraph* para = (wxRichTextParagraph*) node->GetData();
+ if (!(para->GetRange().GetStart() > range.GetEnd() || para->GetRange().GetEnd() < range.GetStart()))
{
- if (currentStyle.HasFontSize())
- {
- if (currentStyle.GetFontSize() != style.GetFontSize())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_FONT_SIZE;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_FONT_SIZE);
- }
- }
- else
+ if (para->GetChildren().GetCount() == 0)
{
- currentStyle.SetFontSize(style.GetFontSize());
- }
- }
+ wxRichTextAttr paraStyle = para->GetCombinedAttributes();
- if (style.HasFontItalic() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_ITALIC))
- {
- if (currentStyle.HasFontItalic())
- {
- if (currentStyle.GetFontStyle() != style.GetFontStyle())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_FONT_ITALIC;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_FONT_ITALIC);
- }
+ CollectStyle(style, paraStyle, clashingAttr, absentAttrPara);
}
else
{
- currentStyle.SetFontStyle(style.GetFontStyle());
- }
- }
+ wxRichTextRange paraRange(para->GetRange());
+ paraRange.LimitTo(range);
- if (style.HasFontFamily() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_FAMILY))
- {
- if (currentStyle.HasFontFamily())
- {
- if (currentStyle.GetFontFamily() != style.GetFontFamily())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_FONT_FAMILY;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_FONT_FAMILY);
- }
- }
- else
- {
- currentStyle.SetFontFamily(style.GetFontFamily());
- }
- }
+ // First collect paragraph attributes only
+ wxRichTextAttr paraStyle = para->GetCombinedAttributes();
+ paraStyle.SetFlags(paraStyle.GetFlags() & wxTEXT_ATTR_PARAGRAPH);
+ CollectStyle(style, paraStyle, clashingAttr, absentAttrPara);
- if (style.HasFontWeight() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_WEIGHT))
- {
- if (currentStyle.HasFontWeight())
- {
- if (currentStyle.GetFontWeight() != style.GetFontWeight())
+ wxRichTextObjectList::compatibility_iterator childNode = para->GetChildren().GetFirst();
+
+ while (childNode)
{
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_FONT_WEIGHT;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_FONT_WEIGHT);
- }
- }
- else
- {
- currentStyle.SetFontWeight(style.GetFontWeight());
- }
- }
+ wxRichTextObject* child = childNode->GetData();
+ if (!(child->GetRange().GetStart() > range.GetEnd() || child->GetRange().GetEnd() < range.GetStart()))
+ {
+ wxRichTextAttr childStyle = para->GetCombinedAttributes(child->GetAttributes());
- if (style.HasFontFaceName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_FACE))
- {
- if (currentStyle.HasFontFaceName())
- {
- wxString faceName1(currentStyle.GetFontFaceName());
- wxString faceName2(style.GetFontFaceName());
+ // Now collect character attributes only
+ childStyle.SetFlags(childStyle.GetFlags() & wxTEXT_ATTR_CHARACTER);
- if (faceName1 != faceName2)
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_FONT_FACE;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_FONT_FACE);
- }
- }
- else
- {
- currentStyle.SetFontFaceName(style.GetFontFaceName());
- }
- }
+ CollectStyle(style, childStyle, clashingAttr, absentAttrChar);
+ }
- if (style.HasFontUnderlined() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_FONT_UNDERLINE))
- {
- if (currentStyle.HasFontUnderlined())
- {
- if (currentStyle.GetFontUnderlined() != style.GetFontUnderlined())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_FONT_UNDERLINE;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_FONT_UNDERLINE);
+ childNode = childNode->GetNext();
}
}
- else
- {
- currentStyle.SetFontUnderlined(style.GetFontUnderlined());
- }
}
+ node = node->GetNext();
}
+ return true;
+}
- if (style.HasTextColour() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_TEXT_COLOUR))
- {
- if (currentStyle.HasTextColour())
- {
- if (currentStyle.GetTextColour() != style.GetTextColour())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_TEXT_COLOUR;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_TEXT_COLOUR);
- }
- }
- else
- currentStyle.SetTextColour(style.GetTextColour());
- }
+/// Set default style
+bool wxRichTextParagraphLayoutBox::SetDefaultStyle(const wxRichTextAttr& style)
+{
+ m_defaultAttributes = style;
+ return true;
+}
- if (style.HasBackgroundColour() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BACKGROUND_COLOUR))
- {
- if (currentStyle.HasBackgroundColour())
- {
- if (currentStyle.GetBackgroundColour() != style.GetBackgroundColour())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_BACKGROUND_COLOUR;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_BACKGROUND_COLOUR);
- }
- }
- else
- currentStyle.SetBackgroundColour(style.GetBackgroundColour());
- }
+/// 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.
+bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const
+{
+ int foundCount = 0;
+ int matchingCount = 0;
- if (style.HasAlignment() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_ALIGNMENT))
+ wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst();
+ while (node)
{
- if (currentStyle.HasAlignment())
- {
- if (currentStyle.GetAlignment() != style.GetAlignment())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_ALIGNMENT;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_ALIGNMENT);
- }
- }
- else
- currentStyle.SetAlignment(style.GetAlignment());
- }
+ wxRichTextParagraph* para = wxDynamicCast(node->GetData(), wxRichTextParagraph);
+ wxASSERT (para != NULL);
- if (style.HasTabs() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_TABS))
- {
- if (currentStyle.HasTabs())
+ if (para)
{
- if (!wxRichTextTabsEq(currentStyle.GetTabs(), style.GetTabs()))
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_TABS;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_TABS);
- }
- }
- else
- currentStyle.SetTabs(style.GetTabs());
- }
+ // Stop searching if we're beyond the range of interest
+ if (para->GetRange().GetStart() > range.GetEnd())
+ return foundCount == matchingCount && foundCount != 0;
- if (style.HasLeftIndent() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LEFT_INDENT))
- {
- if (currentStyle.HasLeftIndent())
- {
- if (currentStyle.GetLeftIndent() != style.GetLeftIndent() || currentStyle.GetLeftSubIndent() != style.GetLeftSubIndent())
+ if (!para->GetRange().IsOutside(range))
{
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_LEFT_INDENT;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_LEFT_INDENT);
- }
- }
- else
- currentStyle.SetLeftIndent(style.GetLeftIndent(), style.GetLeftSubIndent());
- }
+ wxRichTextObjectList::compatibility_iterator node2 = para->GetChildren().GetFirst();
- if (style.HasRightIndent() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_RIGHT_INDENT))
- {
- if (currentStyle.HasRightIndent())
- {
- if (currentStyle.GetRightIndent() != style.GetRightIndent())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_RIGHT_INDENT;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_RIGHT_INDENT);
- }
- }
- else
- currentStyle.SetRightIndent(style.GetRightIndent());
- }
+ while (node2)
+ {
+ wxRichTextObject* child = node2->GetData();
+ // Allow for empty string if no buffer
+ wxRichTextRange childRange = child->GetRange();
+ if (childRange.GetLength() == 0 && GetRange().GetLength() == 1)
+ childRange.SetEnd(childRange.GetEnd()+1);
- if (style.HasParagraphSpacingAfter() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARA_SPACING_AFTER))
- {
- if (currentStyle.HasParagraphSpacingAfter())
- {
- if (currentStyle.GetParagraphSpacingAfter() != style.GetParagraphSpacingAfter())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_PARA_SPACING_AFTER;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_PARA_SPACING_AFTER);
- }
- }
- else
- currentStyle.SetParagraphSpacingAfter(style.GetParagraphSpacingAfter());
- }
+ if (!childRange.IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText)))
+ {
+ foundCount ++;
+ wxRichTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes());
- if (style.HasParagraphSpacingBefore() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARA_SPACING_BEFORE))
- {
- if (currentStyle.HasParagraphSpacingBefore())
- {
- if (currentStyle.GetParagraphSpacingBefore() != style.GetParagraphSpacingBefore())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_PARA_SPACING_BEFORE;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_PARA_SPACING_BEFORE);
- }
- }
- else
- currentStyle.SetParagraphSpacingBefore(style.GetParagraphSpacingBefore());
- }
+ if (wxTextAttrEqPartial(textAttr, style))
+ matchingCount ++;
+ }
- if (style.HasLineSpacing() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LINE_SPACING))
- {
- if (currentStyle.HasLineSpacing())
- {
- if (currentStyle.GetLineSpacing() != style.GetLineSpacing())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_LINE_SPACING;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_LINE_SPACING);
+ node2 = node2->GetNext();
+ }
}
}
- else
- currentStyle.SetLineSpacing(style.GetLineSpacing());
- }
- if (style.HasCharacterStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_CHARACTER_STYLE_NAME))
- {
- if (currentStyle.HasCharacterStyleName())
- {
- if (currentStyle.GetCharacterStyleName() != style.GetCharacterStyleName())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_CHARACTER_STYLE_NAME;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_CHARACTER_STYLE_NAME);
- }
- }
- else
- currentStyle.SetCharacterStyleName(style.GetCharacterStyleName());
+ node = node->GetNext();
}
- if (style.HasParagraphStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_PARAGRAPH_STYLE_NAME))
- {
- if (currentStyle.HasParagraphStyleName())
- {
- if (currentStyle.GetParagraphStyleName() != style.GetParagraphStyleName())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_PARAGRAPH_STYLE_NAME);
- }
- }
- else
- currentStyle.SetParagraphStyleName(style.GetParagraphStyleName());
- }
+ return foundCount == matchingCount && foundCount != 0;
+}
- if (style.HasListStyleName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_LIST_STYLE_NAME))
+/// 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.
+bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const
+{
+ int foundCount = 0;
+ int matchingCount = 0;
+
+ wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst();
+ while (node)
{
- if (currentStyle.HasListStyleName())
+ wxRichTextParagraph* para = wxDynamicCast(node->GetData(), wxRichTextParagraph);
+ wxASSERT (para != NULL);
+
+ if (para)
{
- if (currentStyle.GetListStyleName() != style.GetListStyleName())
+ // Stop searching if we're beyond the range of interest
+ if (para->GetRange().GetStart() > range.GetEnd())
+ return foundCount == matchingCount && foundCount != 0;
+
+ if (!para->GetRange().IsOutside(range))
{
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_LIST_STYLE_NAME;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_LIST_STYLE_NAME);
+ wxRichTextAttr textAttr = GetAttributes();
+ // Apply the paragraph style
+ wxRichTextApplyStyle(textAttr, para->GetAttributes());
+
+ foundCount ++;
+ if (wxTextAttrEqPartial(textAttr, style))
+ matchingCount ++;
}
}
- else
- currentStyle.SetListStyleName(style.GetListStyleName());
+
+ node = node->GetNext();
}
-
- if (style.HasBulletStyle() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_STYLE))
- {
- if (currentStyle.HasBulletStyle())
- {
- if (currentStyle.GetBulletStyle() != style.GetBulletStyle())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_BULLET_STYLE;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_BULLET_STYLE);
- }
- }
- else
- currentStyle.SetBulletStyle(style.GetBulletStyle());
- }
-
- if (style.HasBulletNumber() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_NUMBER))
- {
- if (currentStyle.HasBulletNumber())
- {
- if (currentStyle.GetBulletNumber() != style.GetBulletNumber())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_BULLET_NUMBER;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_BULLET_NUMBER);
- }
- }
- else
- currentStyle.SetBulletNumber(style.GetBulletNumber());
- }
-
- if (style.HasBulletText() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_TEXT))
- {
- if (currentStyle.HasBulletText())
- {
- if (currentStyle.GetBulletText() != style.GetBulletText())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_BULLET_TEXT;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_BULLET_TEXT);
- }
- }
- else
- {
- currentStyle.SetBulletText(style.GetBulletText());
- currentStyle.SetBulletFont(style.GetBulletFont());
- }
- }
-
- if (style.HasBulletName() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_BULLET_NAME))
- {
- if (currentStyle.HasBulletName())
- {
- if (currentStyle.GetBulletName() != style.GetBulletName())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_BULLET_NAME;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_BULLET_NAME);
- }
- }
- else
- {
- currentStyle.SetBulletName(style.GetBulletName());
- }
- }
-
- if (style.HasURL() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_URL))
- {
- if (currentStyle.HasURL())
- {
- if (currentStyle.GetURL() != style.GetURL())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_URL;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_URL);
- }
- }
- else
- {
- currentStyle.SetURL(style.GetURL());
- }
- }
-
- if (style.HasTextEffects() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_EFFECTS))
- {
- if (currentStyle.HasTextEffects())
- {
- // We need to find the bits in the new style that are different:
- // just look at those bits that are specified by the new style.
-
- // We need to remove the bits and flags that are not common between current style
- // and new style. In so doing we need to take account of the styles absent from one or more of the
- // previous styles.
-
- int currentRelevantTextEffects = currentStyle.GetTextEffects() & style.GetTextEffectFlags();
- int newRelevantTextEffects = style.GetTextEffects() & style.GetTextEffectFlags();
-
- if (currentRelevantTextEffects != newRelevantTextEffects)
- {
- // Find the text effects that were different, using XOR
- int differentEffects = currentRelevantTextEffects ^ newRelevantTextEffects;
-
- // Clash of style - mark as such
- multipleTextEffectAttributes |= differentEffects;
- currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~differentEffects);
- }
- }
- else
- {
- currentStyle.SetTextEffects(style.GetTextEffects());
- currentStyle.SetTextEffectFlags(style.GetTextEffectFlags());
- }
-
- // Mask out the flags and values that cannot be common because they were absent in one or more objecrs
- // that we've looked at so far
- currentStyle.SetTextEffects(currentStyle.GetTextEffects() & ~absentTextEffectAttributes);
- currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~absentTextEffectAttributes);
-
- if (currentStyle.GetTextEffectFlags() == 0)
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_EFFECTS);
- }
-
- if (style.HasOutlineLevel() && !wxHasStyle(multipleStyleAttributes|absentStyleAttributes, wxTEXT_ATTR_OUTLINE_LEVEL))
- {
- if (currentStyle.HasOutlineLevel())
- {
- if (currentStyle.GetOutlineLevel() != style.GetOutlineLevel())
- {
- // Clash of style - mark as such
- multipleStyleAttributes |= wxTEXT_ATTR_OUTLINE_LEVEL;
- currentStyle.SetFlags(currentStyle.GetFlags() & ~wxTEXT_ATTR_OUTLINE_LEVEL);
- }
- }
- else
- currentStyle.SetOutlineLevel(style.GetOutlineLevel());
- }
-
- return true;
-}
-
-/// Get the combined style for a range - if any attribute is different within the range,
-/// that attribute is not present within the flags.
-/// *** Note that this is not recursive, and so assumes that content inside a paragraph is not itself
-/// nested.
-bool wxRichTextParagraphLayoutBox::GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style)
-{
- style = wxTextAttr();
-
- // The attributes that aren't valid because of multiple styles within the range
- long multipleStyleAttributes = 0;
- int multipleTextEffectAttributes = 0;
-
- int absentStyleAttributesPara = 0;
- int absentStyleAttributesChar = 0;
- int absentTextEffectAttributesPara = 0;
- int absentTextEffectAttributesChar = 0;
-
- wxRichTextObjectList::compatibility_iterator node = GetChildren().GetFirst();
- while (node)
- {
- wxRichTextParagraph* para = (wxRichTextParagraph*) node->GetData();
- if (!(para->GetRange().GetStart() > range.GetEnd() || para->GetRange().GetEnd() < range.GetStart()))
- {
- if (para->GetChildren().GetCount() == 0)
- {
- wxTextAttr paraStyle = para->GetCombinedAttributes();
-
- CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesPara, absentTextEffectAttributesPara);
- }
- else
- {
- wxRichTextRange paraRange(para->GetRange());
- paraRange.LimitTo(range);
-
- // First collect paragraph attributes only
- wxTextAttr paraStyle = para->GetCombinedAttributes();
- paraStyle.SetFlags(paraStyle.GetFlags() & wxTEXT_ATTR_PARAGRAPH);
- CollectStyle(style, paraStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesPara, absentTextEffectAttributesPara);
-
- wxRichTextObjectList::compatibility_iterator childNode = para->GetChildren().GetFirst();
-
- while (childNode)
- {
- wxRichTextObject* child = childNode->GetData();
- if (!(child->GetRange().GetStart() > range.GetEnd() || child->GetRange().GetEnd() < range.GetStart()))
- {
- wxTextAttr childStyle = para->GetCombinedAttributes(child->GetAttributes());
-
- // Now collect character attributes only
- childStyle.SetFlags(childStyle.GetFlags() & wxTEXT_ATTR_CHARACTER);
-
- CollectStyle(style, childStyle, multipleStyleAttributes, multipleTextEffectAttributes, absentStyleAttributesChar, absentTextEffectAttributesChar);
- }
-
- childNode = childNode->GetNext();
- }
- }
- }
- node = node->GetNext();
- }
- return true;
-}
-
-/// Set default style
-bool wxRichTextParagraphLayoutBox::SetDefaultStyle(const wxTextAttr& style)
-{
- m_defaultAttributes = style;
- return true;
-}
-
-/// 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.
-bool wxRichTextParagraphLayoutBox::HasCharacterAttributes(const wxRichTextRange& range, const wxTextAttr& style) const
-{
- int foundCount = 0;
- int matchingCount = 0;
-
- wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst();
- while (node)
- {
- wxRichTextParagraph* para = wxDynamicCast(node->GetData(), wxRichTextParagraph);
- wxASSERT (para != NULL);
-
- if (para)
- {
- // Stop searching if we're beyond the range of interest
- if (para->GetRange().GetStart() > range.GetEnd())
- return foundCount == matchingCount && foundCount != 0;
-
- if (!para->GetRange().IsOutside(range))
- {
- wxRichTextObjectList::compatibility_iterator node2 = para->GetChildren().GetFirst();
-
- while (node2)
- {
- wxRichTextObject* child = node2->GetData();
- // Allow for empty string if no buffer
- wxRichTextRange childRange = child->GetRange();
- if (childRange.GetLength() == 0 && GetRange().GetLength() == 1)
- childRange.SetEnd(childRange.GetEnd()+1);
-
- if (!childRange.IsOutside(range) && child->IsKindOf(CLASSINFO(wxRichTextPlainText)))
- {
- foundCount ++;
- wxTextAttr textAttr = para->GetCombinedAttributes(child->GetAttributes());
-
- if (wxTextAttrEqPartial(textAttr, style, style.GetFlags()))
- matchingCount ++;
- }
-
- node2 = node2->GetNext();
- }
- }
- }
-
- node = node->GetNext();
- }
-
- return foundCount == matchingCount && foundCount != 0;
-}
-
-/// 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.
-bool wxRichTextParagraphLayoutBox::HasParagraphAttributes(const wxRichTextRange& range, const wxTextAttr& style) const
-{
- int foundCount = 0;
- int matchingCount = 0;
-
- wxRichTextObjectList::compatibility_iterator node = m_children.GetFirst();
- while (node)
- {
- wxRichTextParagraph* para = wxDynamicCast(node->GetData(), wxRichTextParagraph);
- wxASSERT (para != NULL);
-
- if (para)
- {
- // Stop searching if we're beyond the range of interest
- if (para->GetRange().GetStart() > range.GetEnd())
- return foundCount == matchingCount && foundCount != 0;
-
- if (!para->GetRange().IsOutside(range))
- {
- wxTextAttr textAttr = GetAttributes();
- // Apply the paragraph style
- wxRichTextApplyStyle(textAttr, para->GetAttributes());
-
- foundCount ++;
- if (wxTextAttrEqPartial(textAttr, style, style.GetFlags()))
- matchingCount ++;
- }
- }
-
- node = node->GetNext();
- }
- return foundCount == matchingCount && foundCount != 0;
-}
+ return foundCount == matchingCount && foundCount != 0;
+}
void wxRichTextParagraphLayoutBox::Clear()
{
// Renumbering will need to be done when we promote/demote a paragraph.
// Apply the overall list style, and item style for this level
- wxTextAttr listStyle(def->GetCombinedStyleForLevel(thisLevel, styleSheet));
+ wxRichTextAttr listStyle(def->GetCombinedStyleForLevel(thisLevel, styleSheet));
wxRichTextApplyStyle(newPara->GetAttributes(), listStyle);
// Now we need to do numbering
}
// Apply the overall list style, and item style for this level
- wxTextAttr listStyle(defToUse->GetCombinedStyleForLevel(thisLevel, styleSheet));
+ wxRichTextAttr listStyle(defToUse->GetCombinedStyleForLevel(thisLevel, styleSheet));
wxRichTextApplyStyle(newPara->GetAttributes(), listStyle);
// OK, we've (re)applied the style, now let's get the numbering right.
/// Fills in the attributes for numbering a paragraph after previousParagraph. It also finds the
/// position of the paragraph that it had to start looking from.
-bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxTextAttr& attr) const
+bool wxRichTextParagraphLayoutBox::FindNextParagraphNumber(wxRichTextParagraph* previousParagraph, wxRichTextAttr& attr) const
{
if (!previousParagraph->GetAttributes().HasFlag(wxTEXT_ATTR_BULLET_STYLE) || previousParagraph->GetAttributes().GetBulletStyle() == wxTEXT_ATTR_BULLET_STYLE_NONE)
return false;
wxArrayInt wxRichTextParagraph::sm_defaultTabs;
-wxRichTextParagraph::wxRichTextParagraph(wxRichTextObject* parent, wxTextAttr* style):
+wxRichTextParagraph::wxRichTextParagraph(wxRichTextObject* parent, wxRichTextAttr* style):
wxRichTextBox(parent)
{
if (style)
SetAttributes(*style);
}
-wxRichTextParagraph::wxRichTextParagraph(const wxString& text, wxRichTextObject* parent, wxTextAttr* paraStyle, wxTextAttr* charStyle):
+wxRichTextParagraph::wxRichTextParagraph(const wxString& text, wxRichTextObject* parent, wxRichTextAttr* paraStyle, wxRichTextAttr* charStyle):
wxRichTextBox(parent)
{
if (paraStyle)
/// Draw the item
bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxRichTextRange& selectionRange, const wxRect& rect, int WXUNUSED(descent), int style)
{
- wxTextAttr attr = GetCombinedAttributes();
+ wxRichTextAttr attr = GetCombinedAttributes();
// Draw the bullet, if any
if (attr.GetBulletStyle() != wxTEXT_ATTR_BULLET_STYLE_NONE)
int spaceBeforePara = ConvertTenthsMMToPixels(dc, attr.GetParagraphSpacingBefore());
int leftIndent = ConvertTenthsMMToPixels(dc, attr.GetLeftIndent());
- wxTextAttr bulletAttr(GetCombinedAttributes());
+ wxRichTextAttr bulletAttr(GetCombinedAttributes());
// Combine with the font of the first piece of content, if one is specified
if (GetChildren().GetCount() > 0)
wxASSERT(collector);
LayoutFloat(dc, rect, style, collector);
- wxTextAttr attr = GetCombinedAttributes();
+ wxRichTextAttr attr = GetCombinedAttributes();
// ClearLines();
}
/// Apply paragraph styles, such as centering, to wrapped lines
-void wxRichTextParagraph::ApplyParagraphStyle(const wxTextAttr& attr, const wxRect& rect, wxDC& dc)
+void wxRichTextParagraph::ApplyParagraphStyle(const wxRichTextAttr& attr, const wxRect& rect, wxDC& dc)
{
if (!attr.HasAlignment())
return;
/// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically
/// retrieve the actual style.
-wxTextAttr wxRichTextParagraph::GetCombinedAttributes(const wxTextAttr& contentStyle) const
+wxRichTextAttr wxRichTextParagraph::GetCombinedAttributes(const wxRichTextAttr& contentStyle) const
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
wxRichTextBuffer* buf = wxDynamicCast(GetParent(), wxRichTextBuffer);
if (buf)
{
}
/// Get combined attributes of the base style and paragraph style.
-wxTextAttr wxRichTextParagraph::GetCombinedAttributes() const
+wxRichTextAttr wxRichTextParagraph::GetCombinedAttributes() const
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
wxRichTextBuffer* buf = wxDynamicCast(GetParent(), wxRichTextBuffer);
if (buf)
{
wxSize size;
int descent, x = 0;
anchored->GetRangeSize(anchored->GetRange(), size, descent, dc, style);
- wxRichTextAnchoredObjectAttr attr = anchored->GetAnchoredAttr();
- int pos = floatCollector->GetFitPosition(attr.m_floating, rect.y + attr.m_offset, size.y);
+
+ int offsetY = 0;
+ if (anchored->GetAttributes().GetTextBoxAttr().GetTop().IsPresent())
+ {
+ offsetY = anchored->GetAttributes().GetTextBoxAttr().GetTop().GetValue();
+ if (anchored->GetAttributes().GetTextBoxAttr().GetTop().GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM)
+ {
+ offsetY = ConvertTenthsMMToPixels(dc, offsetY);
+ }
+ }
+
+ int pos = floatCollector->GetFitPosition(anchored->GetAttributes().GetTextBoxAttr().GetFloatMode(), rect.y + offsetY, size.y);
/* Update the offset */
- attr.m_offset = pos - rect.y;
- anchored->SetAnchoredAttr(attr);
+ int newOffsetY = pos - rect.y;
+ if (newOffsetY != offsetY)
+ {
+ if (anchored->GetAttributes().GetTextBoxAttr().GetTop().GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM)
+ newOffsetY = ConvertPixelsToTenthsMM(dc, newOffsetY);
+ anchored->GetAttributes().GetTextBoxAttr().GetTop().SetValue(newOffsetY);
+ }
+
+ // attr.m_offset = pos - rect.y;
+ //anchored->SetAnchoredAttr(attr);
- if (attr.m_floating == wxRICHTEXT_FLOAT_LEFT)
+ if (anchored->GetAttributes().GetTextBoxAttr().GetFloatMode() == wxTEXT_BOX_ATTR_FLOAT_LEFT)
x = 0;
- else if (attr.m_floating == wxRICHTEXT_FLOAT_RIGHT)
+ else if (anchored->GetAttributes().GetTextBoxAttr().GetFloatMode() == wxTEXT_BOX_ATTR_FLOAT_RIGHT)
x = rect.width - size.x;
+
anchored->SetPosition(wxPoint(x, pos));
anchored->SetCachedSize(size);
floatCollector->CollectFloat(this, anchored);
IMPLEMENT_DYNAMIC_CLASS(wxRichTextPlainText, wxRichTextObject)
-wxRichTextPlainText::wxRichTextPlainText(const wxString& text, wxRichTextObject* parent, wxTextAttr* style):
+wxRichTextPlainText::wxRichTextPlainText(const wxString& text, wxRichTextObject* parent, wxRichTextAttr* style):
wxRichTextObject(parent)
{
if (style)
wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph);
wxASSERT (para != NULL);
- wxTextAttr textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes());
+ wxRichTextAttr textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes());
int offset = GetRange().GetStart();
return true;
}
-bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxTextAttr& attr, const wxRect& rect,wxString& str, wxCoord& x, wxCoord& y, bool selected)
+bool wxRichTextPlainText::DrawTabbedString(wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect,wxString& str, wxCoord& x, wxCoord& y, bool selected)
{
bool hasTabs = (str.Find(wxT('\t')) != wxNOT_FOUND);
wxRichTextParagraph* para = wxDynamicCast(GetParent(), wxRichTextParagraph);
wxASSERT (para != NULL);
- wxTextAttr textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes());
+ wxRichTextAttr textAttr(para ? para->GetCombinedAttributes(GetAttributes()) : GetAttributes());
// Always assume unformatted text, since at this level we have no knowledge
// of line breaks - and we don't need it, since we'll calculate size within
{
wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false);
- wxTextAttr attr(GetDefaultStyle());
+ wxRichTextAttr attr(GetDefaultStyle());
- wxTextAttr* p = NULL;
- wxTextAttr paraAttr;
+ wxRichTextAttr* p = NULL;
+ wxRichTextAttr paraAttr;
if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
{
paraAttr = GetStyleForNewParagraph(pos);
{
wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false);
- wxTextAttr* p = NULL;
- wxTextAttr paraAttr;
+ wxRichTextAttr* p = NULL;
+ wxRichTextAttr paraAttr;
if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
{
// Get appropriate paragraph style
{
wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Text"), wxRICHTEXT_INSERT, this, ctrl, false);
- wxTextAttr* p = NULL;
- wxTextAttr paraAttr;
+ wxRichTextAttr* p = NULL;
+ wxRichTextAttr paraAttr;
if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
{
paraAttr = GetStyleForNewParagraph(pos, false, true /* look for next paragraph style */);
p = & paraAttr;
}
- wxTextAttr attr(GetDefaultStyle());
+ wxRichTextAttr attr(GetDefaultStyle());
wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr);
action->GetNewParagraphs().AppendChild(newPara);
{
// Check whether the default style merely reflects the paragraph/basic style,
// in which case don't apply it.
- wxTextAttrEx defaultStyle(GetDefaultStyle());
- wxTextAttrEx toApply;
+ wxRichTextAttr defaultStyle(GetDefaultStyle());
+ wxRichTextAttr toApply;
if (para)
{
wxRichTextAttr combinedAttr = para->GetCombinedAttributes();
- wxTextAttrEx newAttr;
+ wxRichTextAttr newAttr;
// This filters out attributes that are accounted for by the current
// paragraph/basic style
wxRichTextApplyStyle(toApply, defaultStyle, & combinedAttr);
}
/// Submit command to insert the given image
-bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags, const wxRichTextAnchoredObjectAttr& floatAttr)
+bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags,
+ const wxRichTextAttr& textAttr)
{
wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert Image"), wxRICHTEXT_INSERT, this, ctrl, false);
- wxTextAttr* p = NULL;
- wxTextAttr paraAttr;
+ wxRichTextAttr* p = NULL;
+ wxRichTextAttr paraAttr;
if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
{
paraAttr = GetStyleForNewParagraph(pos);
p = & paraAttr;
}
- wxTextAttr attr(GetDefaultStyle());
+ wxRichTextAttr attr(GetDefaultStyle());
wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr);
if (p)
wxRichTextImage* imageObject = new wxRichTextImage(imageBlock, newPara);
newPara->AppendChild(imageObject);
- imageObject->SetAnchoredAttr(floatAttr);
+ imageObject->SetAttributes(textAttr);
+ //imageObject->SetAnchoredAttr(floatAttr);
action->GetNewParagraphs().AppendChild(newPara);
action->GetNewParagraphs().UpdateRanges();
{
wxRichTextAction* action = new wxRichTextAction(NULL, _("Insert object"), wxRICHTEXT_INSERT, this, ctrl, false);
- wxTextAttr* p = NULL;
- wxTextAttr paraAttr;
+ wxRichTextAttr* p = NULL;
+ wxRichTextAttr paraAttr;
if (flags & wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE)
{
paraAttr = GetStyleForNewParagraph(pos);
p = & paraAttr;
}
- wxTextAttr attr(GetDefaultStyle());
+ wxRichTextAttr attr(GetDefaultStyle());
wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr);
if (p)
/// Get the style that is appropriate for a new paragraph at this position.
/// If the previous paragraph has a paragraph style name, look up the next-paragraph
/// style.
-wxTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPosition, bool lookUpNewParaStyle) const
+wxRichTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPosition, bool lookUpNewParaStyle) const
{
wxRichTextParagraph* para = GetParagraphAtPosition(pos, caretPosition);
if (para)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
bool foundAttributes = false;
// Look for a matching paragraph style
return attr;
}
else
- return wxTextAttr();
+ return wxRichTextAttr();
}
/// Submit command to delete this range
}
/// Begin using a style
-bool wxRichTextBuffer::BeginStyle(const wxTextAttr& style)
+bool wxRichTextBuffer::BeginStyle(const wxRichTextAttr& style)
{
- wxTextAttr newStyle(GetDefaultStyle());
+ wxRichTextAttr newStyle(GetDefaultStyle());
// Save the old default style
- m_attributeStack.Append((wxObject*) new wxTextAttr(GetDefaultStyle()));
+ m_attributeStack.Append((wxObject*) new wxRichTextAttr(GetDefaultStyle()));
wxRichTextApplyStyle(newStyle, style);
newStyle.SetFlags(style.GetFlags()|newStyle.GetFlags());
}
wxList::compatibility_iterator node = m_attributeStack.GetLast();
- wxTextAttr* attr = (wxTextAttr*)node->GetData();
+ wxRichTextAttr* attr = (wxRichTextAttr*)node->GetData();
m_attributeStack.Erase(node);
SetDefaultStyle(*attr);
void wxRichTextBuffer::ClearStyleStack()
{
for (wxList::compatibility_iterator node = m_attributeStack.GetFirst(); node; node = node->GetNext())
- delete (wxTextAttr*) node->GetData();
+ delete (wxRichTextAttr*) node->GetData();
m_attributeStack.Clear();
}
/// Begin using bold
bool wxRichTextBuffer::BeginBold()
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFontWeight(wxFONTWEIGHT_BOLD);
return BeginStyle(attr);
/// Begin using italic
bool wxRichTextBuffer::BeginItalic()
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFontStyle(wxFONTSTYLE_ITALIC);
return BeginStyle(attr);
/// Begin using underline
bool wxRichTextBuffer::BeginUnderline()
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFontUnderlined(true);
return BeginStyle(attr);
/// Begin using point size
bool wxRichTextBuffer::BeginFontSize(int pointSize)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFontSize(pointSize);
return BeginStyle(attr);
/// Begin using this font
bool wxRichTextBuffer::BeginFont(const wxFont& font)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFont(font);
return BeginStyle(attr);
/// Begin using this colour
bool wxRichTextBuffer::BeginTextColour(const wxColour& colour)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_TEXT_COLOUR);
attr.SetTextColour(colour);
/// Begin using alignment
bool wxRichTextBuffer::BeginAlignment(wxTextAttrAlignment alignment)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_ALIGNMENT);
attr.SetAlignment(alignment);
/// Begin left indent
bool wxRichTextBuffer::BeginLeftIndent(int leftIndent, int leftSubIndent)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_LEFT_INDENT);
attr.SetLeftIndent(leftIndent, leftSubIndent);
/// Begin right indent
bool wxRichTextBuffer::BeginRightIndent(int rightIndent)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_RIGHT_INDENT);
attr.SetRightIndent(rightIndent);
if (after != 0)
flags |= wxTEXT_ATTR_PARA_SPACING_AFTER;
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(flags);
attr.SetParagraphSpacingBefore(before);
attr.SetParagraphSpacingAfter(after);
/// Begin line spacing
bool wxRichTextBuffer::BeginLineSpacing(int lineSpacing)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_LINE_SPACING);
attr.SetLineSpacing(lineSpacing);
/// Begin numbered bullet
bool wxRichTextBuffer::BeginNumberedBullet(int bulletNumber, int leftIndent, int leftSubIndent, int bulletStyle)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT);
attr.SetBulletStyle(bulletStyle);
attr.SetBulletNumber(bulletNumber);
/// Begin symbol bullet
bool wxRichTextBuffer::BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT);
attr.SetBulletStyle(bulletStyle);
attr.SetLeftIndent(leftIndent, leftSubIndent);
/// Begin standard bullet
bool wxRichTextBuffer::BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_LEFT_INDENT);
attr.SetBulletStyle(bulletStyle);
attr.SetLeftIndent(leftIndent, leftSubIndent);
wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterStyle);
if (def)
{
- wxTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet());
+ wxRichTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet());
return BeginStyle(attr);
}
}
wxRichTextParagraphStyleDefinition* def = GetStyleSheet()->FindParagraphStyle(paragraphStyle);
if (def)
{
- wxTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet());
+ wxRichTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet());
return BeginStyle(attr);
}
}
wxRichTextListStyleDefinition* def = GetStyleSheet()->FindListStyle(listStyle);
if (def)
{
- wxTextAttr attr(def->GetCombinedStyleForLevel(level));
+ wxRichTextAttr attr(def->GetCombinedStyleForLevel(level));
attr.SetBulletNumber(number);
/// Begin URL
bool wxRichTextBuffer::BeginURL(const wxString& url, const wxString& characterStyle)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
if (!characterStyle.IsEmpty() && GetStyleSheet())
{
wxRichTextFileHandler* handler = FindHandlerFilenameOrType(filename, type);
if (handler)
{
- SetDefaultStyle(wxTextAttr());
+ SetDefaultStyle(wxRichTextAttr());
handler->SetFlags(GetHandlerFlags());
bool success = handler->LoadFile(this, filename);
Invalidate(wxRICHTEXT_ALL);
wxRichTextFileHandler* handler = FindHandler(type);
if (handler)
{
- SetDefaultStyle(wxTextAttr());
+ SetDefaultStyle(wxRichTextAttr());
handler->SetFlags(GetHandlerFlags());
bool success = handler->LoadFile(this, stream);
Invalidate(wxRICHTEXT_ALL);
sm_renderer = renderer;
}
-bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& bulletAttr, const wxRect& rect)
+bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& bulletAttr, const wxRect& rect)
{
if (bulletAttr.GetTextColour().Ok())
{
return true;
}
-bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttr& attr, const wxRect& rect, const wxString& text)
+bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxRichTextAttr& attr, const wxRect& rect, const wxString& text)
{
if (!text.empty())
{
wxFont font;
if ((attr.GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL) && !attr.GetBulletFont().IsEmpty() && attr.HasFont())
{
- wxTextAttr fontAttr;
+ wxRichTextAttr fontAttr;
fontAttr.SetFontSize(attr.GetFontSize());
fontAttr.SetFontStyle(attr.GetFontStyle());
fontAttr.SetFontWeight(attr.GetFontWeight());
return false;
}
-bool wxRichTextStdRenderer::DrawBitmapBullet(wxRichTextParagraph* WXUNUSED(paragraph), wxDC& WXUNUSED(dc), const wxTextAttr& WXUNUSED(attr), const wxRect& WXUNUSED(rect))
+bool wxRichTextStdRenderer::DrawBitmapBullet(wxRichTextParagraph* WXUNUSED(paragraph), wxDC& WXUNUSED(dc), const wxRichTextAttr& WXUNUSED(attr), const wxRect& WXUNUSED(rect))
{
// Currently unimplemented. The intention is to store bitmaps by name in a media store associated
// with the buffer. The store will allow retrieval from memory, disk or other means.
return true;
}
-#if 0
/*!
- * wxRichTextPlaceHoldingObject implementation
+ * wxRichTextAnchoredObject implementation
*/
+IMPLEMENT_CLASS(wxRichTextAnchoredObject, wxRichTextObject)
-IMPLEMENT_DYNAMIC_CLASS(wxRichTextPlaceHoldingObject, wxRichTextObject)
-
-wxRichTextPlaceHoldingObject::wxRichTextPlaceHoldingObject(wxRichTextObject *parent, wxRichTextAnchoredObject *real)
- : wxRichTextObject(parent), m_real(real)
-{
-}
-
-wxRichTextPlaceHoldingObject::~wxRichTextPlaceHoldingObject()
-{
-}
-
-bool wxRichTextPlaceHoldingObject::Draw(wxDC& WXUNUSED(dc), const wxRichTextRange& WXUNUSED(range), const wxRichTextRange& WXUNUSED(selectionrange), const wxRect& WXUNUSED(rect), int WXUNUSED(descent), int WXUNUSED(style))
-{
- return true;
-}
-
-bool wxRichTextPlaceHoldingObject::Layout(wxDC& WXUNUSED(dc), const wxRect& WXUNUSED(rect), int WXUNUSED(style))
+wxRichTextAnchoredObject::wxRichTextAnchoredObject(wxRichTextObject* parent, const wxRichTextAttr& attr):
+ wxRichTextObject(parent)
{
- SetCachedSize(wxSize(0, 0));
- return true;
+ SetAttributes(attr);
}
-bool wxRichTextPlaceHoldingObject::GetRangeSize(const wxRichTextRange& WXUNUSED(range), wxSize& size, int& WXUNUSED(descent), wxDC& WXUNUSED(dc), int WXUNUSED(flags), wxPoint WXUNUSED(position), wxArrayInt* partialExtents) const
+wxRichTextAnchoredObject::~wxRichTextAnchoredObject()
{
- size.x = size.y = 0;
- if (partialExtents)
- partialExtents->Add(0);
- return true;
}
-void wxRichTextPlaceHoldingObject::Copy(const wxRichTextPlaceHoldingObject& obj)
+void wxRichTextAnchoredObject::Copy(const wxRichTextAnchoredObject& obj)
{
wxRichTextObject::Copy(obj);
- wxASSERT (obj.m_real);
- wxRichTextObject* o = obj.m_real->Clone();
- wxASSERT (o->IsFloatable());
- wxRichTextAnchoredObject* anchor = wxDynamicCast(o, wxRichTextAnchoredObject);
- wxASSERT (anchor);
- anchor->SetPlaceHoldingObject(this);
- m_real = anchor;
}
-void wxRichTextPlaceHoldingObject::SetParent(wxRichTextObject* parent)
-{
- wxRichTextObject::SetParent(parent);
- if (m_real)
- {
- m_real->wxRichTextObject::SetParent(parent);
- }
-
-}
-
-#endif
-
-/*!
- * wxRichTextAnchoredObject implementation
- */
-IMPLEMENT_CLASS(wxRichTextAnchoredObject, wxRichTextObject)
-
-wxRichTextAnchoredObject::wxRichTextAnchoredObject(wxRichTextObject* parent, const wxRichTextAnchoredObjectAttr& attr):
- wxRichTextObject(parent), m_anchoredAttr(attr)
-{
-}
-
-wxRichTextAnchoredObject::~wxRichTextAnchoredObject()
-{
-}
-
-void wxRichTextAnchoredObject::SetAnchoredAttr(const wxRichTextAnchoredObjectAttr& attr)
-{
- m_anchoredAttr = attr;
-}
-
-void wxRichTextAnchoredObject::Copy(const wxRichTextAnchoredObject& obj)
-{
- wxRichTextObject::Copy(obj);
- m_anchoredAttr = obj.m_anchoredAttr;
-}
-
-void wxRichTextAnchoredObject::SetParent(wxRichTextObject* parent)
+void wxRichTextAnchoredObject::SetParent(wxRichTextObject* parent)
{
wxRichTextObject::SetParent(parent);
}
IMPLEMENT_DYNAMIC_CLASS(wxRichTextImage, wxRichTextAnchoredObject)
-wxRichTextImage::wxRichTextImage(const wxImage& image, wxRichTextObject* parent, wxTextAttr* charStyle):
+wxRichTextImage::wxRichTextImage(const wxImage& image, wxRichTextObject* parent, wxRichTextAttr* charStyle):
wxRichTextAnchoredObject(parent)
{
m_imageBlock.MakeImageBlockDefaultQuality(image, wxBITMAP_TYPE_PNG);
SetAttributes(*charStyle);
}
-wxRichTextImage::wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent, wxTextAttr* charStyle):
+wxRichTextImage::wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent, wxRichTextAttr* charStyle):
wxRichTextAnchoredObject(parent)
{
m_imageBlock = imageBlock;
int width = image.GetWidth();
int height = image.GetHeight();
-
- if (m_anchoredAttr.m_width != -1)
+
+ if (GetAttributes().GetTextBoxAttr().GetWidth().IsPresent() && GetAttributes().GetTextBoxAttr().GetWidth().GetValue() > 0)
{
- // Calculate the user specified length
- if (m_anchoredAttr.m_unitsW == wxRICHTEXT_MM)
- {
- width = ConvertTenthsMMToPixels(dc, m_anchoredAttr.m_width);
- }
+ if (GetAttributes().GetTextBoxAttr().GetWidth().GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM)
+ width = ConvertTenthsMMToPixels(dc, GetAttributes().GetTextBoxAttr().GetWidth().GetValue());
else
- {
- width = m_anchoredAttr.m_width;
- }
+ width = GetAttributes().GetTextBoxAttr().GetWidth().GetValue();
}
-
- if (m_anchoredAttr.m_height != -1)
+ if (GetAttributes().GetTextBoxAttr().GetHeight().IsPresent() && GetAttributes().GetTextBoxAttr().GetHeight().GetValue() > 0)
{
- if (m_anchoredAttr.m_unitsH == wxRICHTEXT_MM)
- {
- height = ConvertTenthsMMToPixels(dc, m_anchoredAttr.m_height);
- }
+ if (GetAttributes().GetTextBoxAttr().GetHeight().GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM)
+ height = ConvertTenthsMMToPixels(dc, GetAttributes().GetTextBoxAttr().GetHeight().GetValue());
else
- {
- height = m_anchoredAttr.m_height;
- }
+ height = GetAttributes().GetTextBoxAttr().GetHeight().GetValue();
}
if (image.GetWidth() == width && image.GetHeight() == height)
*/
/// Compare two attribute objects
-bool wxTextAttrEq(const wxTextAttr& attr1, const wxTextAttr& attr2)
+bool wxTextAttrEq(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2)
{
return (attr1 == attr2);
}
// Partial equality test taking flags into account
-bool wxTextAttrEqPartial(const wxTextAttr& attr1, const wxTextAttr& attr2, int flags)
+bool wxTextAttrEqPartial(const wxRichTextAttr& attr1, const wxRichTextAttr& attr2)
{
- return attr1.EqPartial(attr2, flags);
+ return attr1.EqPartial(attr2);
}
/// Compare tabs
return true;
}
-bool wxRichTextApplyStyle(wxTextAttr& destStyle, const wxTextAttr& style, wxTextAttr* compareWith)
+bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith)
{
return destStyle.Apply(style, compareWith);
}
// Remove attributes
-bool wxRichTextRemoveStyle(wxTextAttr& destStyle, const wxTextAttr& style)
+bool wxRichTextRemoveStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style)
{
- return wxTextAttr::RemoveStyle(destStyle, style);
+ return destStyle.RemoveStyle(style);
}
/// Combine two bitlists, specifying the bits of interest with separate flags.
bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB)
{
- return wxTextAttr::CombineBitlists(valueA, valueB, flagsA, flagsB);
+ return wxRichTextAttr::CombineBitlists(valueA, valueB, flagsA, flagsB);
}
/// Compare two bitlists
bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags)
{
- return wxTextAttr::BitlistsEqPartial(valueA, valueB, flags);
+ return wxRichTextAttr::BitlistsEqPartial(valueA, valueB, flags);
}
/// Split into paragraph and character styles
-bool wxRichTextSplitParaCharStyles(const wxTextAttr& style, wxTextAttr& parStyle, wxTextAttr& charStyle)
+bool wxRichTextSplitParaCharStyles(const wxRichTextAttr& style, wxRichTextAttr& parStyle, wxRichTextAttr& charStyle)
{
- return wxTextAttr::SplitParaCharStyles(style, parStyle, charStyle);
+ return wxRichTextAttr::SplitParaCharStyles(style, parStyle, charStyle);
}
/// Convert a decimal to Roman numerals
public:
wxRichTextFontTableData() {}
- wxFont FindFont(const wxTextAttr& fontSpec);
+ wxFont FindFont(const wxRichTextAttr& fontSpec);
wxRichTextFontTableHashMap m_hashMap;
};
-wxFont wxRichTextFontTableData::FindFont(const wxTextAttr& fontSpec)
+wxFont wxRichTextFontTableData::FindFont(const wxRichTextAttr& fontSpec)
{
wxString facename(fontSpec.GetFontFaceName());
wxString spec(wxString::Format(wxT("%d-%d-%d-%d-%s-%d"), fontSpec.GetFontSize(), fontSpec.GetFontStyle(), fontSpec.GetFontWeight(), (int) fontSpec.GetFontUnderlined(), facename.c_str(), (int) fontSpec.GetFontEncoding()));
Ref(table);
}
-wxFont wxRichTextFontTable::FindFont(const wxTextAttr& fontSpec)
+wxFont wxRichTextFontTable::FindFont(const wxRichTextAttr& fontSpec)
{
wxRichTextFontTableData* data = (wxRichTextFontTableData*) m_refData;
if (data)
data->m_hashMap.clear();
}
+// wxTextBoxAttr
+
+
+void wxTextBoxAttr::Reset()
+{
+ m_flags = 0;
+ m_floatMode = 0;
+ m_clearMode = 0;
+ m_collapseMode = 0;
+
+ m_margins.Reset();
+ m_padding.Reset();
+ m_position.Reset();
+
+ m_width.Reset();
+ m_height.Reset();
+
+ m_border.Reset();
+ m_outline.Reset();
+}
+
+// Equality test
+bool wxTextBoxAttr::operator== (const wxTextBoxAttr& attr) const
+{
+ return (
+ m_flags == attr.m_flags &&
+ m_floatMode == attr.m_floatMode &&
+ m_clearMode == attr.m_clearMode &&
+ m_collapseMode == attr.m_collapseMode &&
+
+ m_margins == attr.m_margins &&
+ m_padding == attr.m_padding &&
+ m_position == attr.m_position &&
+
+ m_width == attr.m_width &&
+ m_height == attr.m_height &&
+
+ m_border == attr.m_border &&
+ m_outline == attr.m_outline
+ );
+}
+
+// Partial equality test
+bool wxTextBoxAttr::EqPartial(const wxTextBoxAttr& attr) const
+{
+ if (attr.HasFloatMode() && HasFloatMode() && (GetFloatMode() != attr.GetFloatMode()))
+ return false;
+
+ if (attr.HasClearMode() && HasClearMode() && (GetClearMode() != attr.GetClearMode()))
+ return false;
+
+ if (attr.HasCollapseBorders() && HasCollapseBorders() && (attr.GetCollapseBorders() != GetCollapseBorders()))
+ return false;
+
+ // Position
+
+ if (!m_position.EqPartial(attr.m_position))
+ return false;
+
+ // Margins
+
+ if (!m_margins.EqPartial(attr.m_margins))
+ return false;
+
+ // Padding
+
+ if (!m_padding.EqPartial(attr.m_padding))
+ return false;
+
+ // Border
+
+ if (!GetBorder().EqPartial(attr.GetBorder()))
+ return false;
+
+ // Outline
+
+ if (!GetOutline().EqPartial(attr.GetOutline()))
+ return false;
+
+ return true;
+}
+
+// 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 wxTextBoxAttr::Apply(const wxTextBoxAttr& attr, const wxTextBoxAttr* compareWith)
+{
+ if (attr.HasFloatMode())
+ {
+ if (!(compareWith && compareWith->HasFloatMode() && compareWith->GetFloatMode() == attr.GetFloatMode()))
+ SetFloatMode(attr.GetFloatMode());
+ }
+
+ if (attr.HasClearMode())
+ {
+ if (!(compareWith && compareWith->HasClearMode() && compareWith->GetClearMode() == attr.GetClearMode()))
+ SetClearMode(attr.GetClearMode());
+ }
+
+ if (attr.HasCollapseBorders())
+ {
+ if (!(compareWith && compareWith->HasCollapseBorders() && compareWith->GetCollapseBorders() == attr.GetCollapseBorders()))
+ SetCollapseBorders(true);
+ }
+
+ m_margins.Apply(attr.m_margins, compareWith ? (& attr.m_margins) : (const wxTextBoxAttrDimensions*) NULL);
+ m_padding.Apply(attr.m_padding, compareWith ? (& attr.m_padding) : (const wxTextBoxAttrDimensions*) NULL);
+ m_position.Apply(attr.m_position, compareWith ? (& attr.m_position) : (const wxTextBoxAttrDimensions*) NULL);
+
+ m_width.Apply(attr.m_width, compareWith ? (& attr.m_width) : (const wxTextAttrDimension*) NULL);
+ m_height.Apply(attr.m_height, compareWith ? (& attr.m_height) : (const wxTextAttrDimension*) NULL);
+
+ m_border.Apply(attr.m_border, compareWith ? (& attr.m_border) : (const wxTextBoxAttrBorders*) NULL);
+ m_outline.Apply(attr.m_outline, compareWith ? (& attr.m_outline) : (const wxTextBoxAttrBorders*) NULL);
+
+ return true;
+}
+
+// Remove specified attributes from this object
+bool wxTextBoxAttr::RemoveStyle(const wxTextBoxAttr& attr)
+{
+ if (attr.HasFloatMode())
+ RemoveFlag(wxTEXT_BOX_ATTR_FLOAT);
+
+ if (attr.HasClearMode())
+ RemoveFlag(wxTEXT_BOX_ATTR_CLEAR);
+
+ if (attr.HasCollapseBorders())
+ RemoveFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS);
+
+ m_margins.RemoveStyle(attr.m_margins);
+ m_padding.RemoveStyle(attr.m_padding);
+ m_position.RemoveStyle(attr.m_position);
+
+ if (attr.m_width.IsPresent())
+ m_width.Reset();
+ if (attr.m_height.IsPresent())
+ m_height.Reset();
+
+ m_border.RemoveStyle(attr.m_border);
+ m_outline.RemoveStyle(attr.m_outline);
+
+ return true;
+}
+
+// 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 wxTextBoxAttr::CollectCommonAttributes(const wxTextBoxAttr& attr, wxTextBoxAttr& clashingAttr, wxTextBoxAttr& absentAttr)
+{
+ if (attr.HasFloatMode())
+ {
+ if (!clashingAttr.HasFloatMode() && !absentAttr.HasFloatMode())
+ {
+ if (HasFloatMode())
+ {
+ if (GetFloatMode() != attr.GetFloatMode())
+ {
+ clashingAttr.AddFlag(wxTEXT_BOX_ATTR_FLOAT);
+ RemoveFlag(wxTEXT_BOX_ATTR_FLOAT);
+ }
+ }
+ else
+ SetFloatMode(attr.GetFloatMode());
+ }
+ }
+ else
+ absentAttr.AddFlag(wxTEXT_BOX_ATTR_FLOAT);
+
+ if (attr.HasClearMode())
+ {
+ if (!clashingAttr.HasClearMode() && !absentAttr.HasClearMode())
+ {
+ if (HasClearMode())
+ {
+ if (GetClearMode() != attr.GetClearMode())
+ {
+ clashingAttr.AddFlag(wxTEXT_BOX_ATTR_CLEAR);
+ RemoveFlag(wxTEXT_BOX_ATTR_CLEAR);
+ }
+ }
+ else
+ SetClearMode(attr.GetClearMode());
+ }
+ }
+ else
+ absentAttr.AddFlag(wxTEXT_BOX_ATTR_CLEAR);
+
+ if (attr.HasCollapseBorders())
+ {
+ if (!clashingAttr.HasCollapseBorders() && !absentAttr.HasCollapseBorders())
+ {
+ if (HasCollapseBorders())
+ {
+ if (GetCollapseBorders() != attr.GetCollapseBorders())
+ {
+ clashingAttr.AddFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS);
+ RemoveFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS);
+ }
+ }
+ else
+ SetCollapseBorders(attr.GetCollapseBorders());
+ }
+ }
+ else
+ absentAttr.AddFlag(wxTEXT_BOX_ATTR_COLLAPSE_BORDERS);
+
+ m_margins.CollectCommonAttributes(attr.m_margins, clashingAttr.m_margins, absentAttr.m_margins);
+ m_padding.CollectCommonAttributes(attr.m_padding, clashingAttr.m_padding, absentAttr.m_padding);
+ m_position.CollectCommonAttributes(attr.m_position, clashingAttr.m_position, absentAttr.m_position);
+
+ m_width.CollectCommonAttributes(attr.m_width, clashingAttr.m_width, absentAttr.m_width);
+ m_height.CollectCommonAttributes(attr.m_height, clashingAttr.m_height, absentAttr.m_height);
+
+ m_border.CollectCommonAttributes(attr.m_border, clashingAttr.m_border, absentAttr.m_border);
+ m_outline.CollectCommonAttributes(attr.m_outline, clashingAttr.m_outline, absentAttr.m_outline);
+}
+
+// wxRichTextAttr
+
+void wxRichTextAttr::Copy(const wxRichTextAttr& attr)
+{
+ wxTextAttr::Copy(attr);
+
+ m_textBoxAttr = attr.m_textBoxAttr;
+}
+
+bool wxRichTextAttr::operator==(const wxRichTextAttr& attr) const
+{
+ if (!(wxTextAttr::operator==(attr)))
+ return false;
+
+ return (m_textBoxAttr == attr.m_textBoxAttr);
+}
+
+// Partial equality test taking comparison object into account
+bool wxRichTextAttr::EqPartial(const wxRichTextAttr& attr) const
+{
+ if (!(wxTextAttr::EqPartial(attr)))
+ return false;
+
+ return m_textBoxAttr.EqPartial(attr.m_textBoxAttr);
+}
+
+// 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 wxRichTextAttr::Apply(const wxRichTextAttr& style, const wxRichTextAttr* compareWith)
+{
+ wxTextAttr::Apply(style, compareWith);
+
+ return m_textBoxAttr.Apply(style.m_textBoxAttr, compareWith ? (& compareWith->m_textBoxAttr) : (const wxTextBoxAttr*) NULL);
+}
+
+// Remove specified attributes from this object
+bool wxRichTextAttr::RemoveStyle(const wxRichTextAttr& attr)
+{
+ wxTextAttr::RemoveStyle(*this, attr);
+
+ return m_textBoxAttr.RemoveStyle(attr.m_textBoxAttr);
+}
+
+// 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 wxRichTextAttr::CollectCommonAttributes(const wxRichTextAttr& attr, wxRichTextAttr& clashingAttr, wxRichTextAttr& absentAttr)
+{
+ wxTextAttrCollectCommonAttributes(*this, attr, clashingAttr, absentAttr);
+
+ m_textBoxAttr.CollectCommonAttributes(attr.m_textBoxAttr, clashingAttr.m_textBoxAttr, absentAttr.m_textBoxAttr);
+}
+
+// Partial equality test
+bool wxTextBoxAttrBorder::EqPartial(const wxTextBoxAttrBorder& border) const
+{
+ if (border.HasStyle() && !HasStyle() && (border.GetStyle() != GetStyle()))
+ return false;
+
+ if (border.HasColour() && !HasColour() && (border.GetColourLong() != GetColourLong()))
+ return false;
+
+ if (border.HasWidth() && !HasWidth() && !(border.GetWidth() == GetWidth()))
+ return false;
+
+ return true;
+}
+
+// Apply border to 'this', but not if the same as compareWith
+bool wxTextBoxAttrBorder::Apply(const wxTextBoxAttrBorder& border, const wxTextBoxAttrBorder* compareWith)
+{
+ if (border.HasStyle())
+ {
+ if (!(compareWith && (border.GetStyle() == compareWith->GetStyle())))
+ SetStyle(border.GetStyle());
+ }
+ if (border.HasColour())
+ {
+ if (!(compareWith && (border.GetColourLong() == compareWith->GetColourLong())))
+ SetColour(border.GetColourLong());
+ }
+ if (border.HasWidth())
+ {
+ if (!(compareWith && (border.GetWidth() == compareWith->GetWidth())))
+ SetWidth(border.GetWidth());
+ }
+
+ return true;
+}
+
+// Remove specified attributes from this object
+bool wxTextBoxAttrBorder::RemoveStyle(const wxTextBoxAttrBorder& attr)
+{
+ if (attr.HasStyle() && HasStyle())
+ SetFlags(GetFlags() & ~wxTEXT_BOX_ATTR_BORDER_STYLE);
+ if (attr.HasColour() && HasColour())
+ SetFlags(GetFlags() & ~wxTEXT_BOX_ATTR_BORDER_COLOUR);
+ if (attr.HasWidth() && HasWidth())
+ m_borderWidth.Reset();
+
+ return true;
+}
+
+// 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 wxTextBoxAttrBorder::CollectCommonAttributes(const wxTextBoxAttrBorder& attr, wxTextBoxAttrBorder& clashingAttr, wxTextBoxAttrBorder& absentAttr)
+{
+ if (attr.HasStyle())
+ {
+ if (!clashingAttr.HasStyle() && !absentAttr.HasStyle())
+ {
+ if (HasStyle())
+ {
+ if (GetStyle() != attr.GetStyle())
+ {
+ clashingAttr.AddFlag(wxTEXT_BOX_ATTR_BORDER_STYLE);
+ RemoveFlag(wxTEXT_BOX_ATTR_BORDER_STYLE);
+ }
+ }
+ else
+ SetStyle(attr.GetStyle());
+ }
+ }
+ else
+ absentAttr.AddFlag(wxTEXT_BOX_ATTR_BORDER_STYLE);
+
+ if (attr.HasColour())
+ {
+ if (!clashingAttr.HasColour() && !absentAttr.HasColour())
+ {
+ if (HasColour())
+ {
+ if (GetColour() != attr.GetColour())
+ {
+ clashingAttr.AddFlag(wxTEXT_BOX_ATTR_BORDER_COLOUR);
+ RemoveFlag(wxTEXT_BOX_ATTR_BORDER_COLOUR);
+ }
+ }
+ else
+ SetColour(attr.GetColourLong());
+ }
+ }
+ else
+ absentAttr.AddFlag(wxTEXT_BOX_ATTR_BORDER_COLOUR);
+
+ m_borderWidth.CollectCommonAttributes(attr.m_borderWidth, clashingAttr.m_borderWidth, absentAttr.m_borderWidth);
+}
+
+// Partial equality test
+bool wxTextBoxAttrBorders::EqPartial(const wxTextBoxAttrBorders& borders) const
+{
+ return m_left.EqPartial(borders.m_left) && m_right.EqPartial(borders.m_right) &&
+ m_top.EqPartial(borders.m_top) && m_bottom.EqPartial(borders.m_bottom);
+}
+
+// Apply border to 'this', but not if the same as compareWith
+bool wxTextBoxAttrBorders::Apply(const wxTextBoxAttrBorders& borders, const wxTextBoxAttrBorders* compareWith)
+{
+ m_left.Apply(borders.m_left, compareWith ? (& compareWith->m_left) : (const wxTextBoxAttrBorder*) NULL);
+ m_right.Apply(borders.m_right, compareWith ? (& compareWith->m_right) : (const wxTextBoxAttrBorder*) NULL);
+ m_top.Apply(borders.m_top, compareWith ? (& compareWith->m_top) : (const wxTextBoxAttrBorder*) NULL);
+ m_bottom.Apply(borders.m_bottom, compareWith ? (& compareWith->m_bottom) : (const wxTextBoxAttrBorder*) NULL);
+ return true;
+}
+
+// Remove specified attributes from this object
+bool wxTextBoxAttrBorders::RemoveStyle(const wxTextBoxAttrBorders& attr)
+{
+ m_left.RemoveStyle(attr.m_left);
+ m_right.RemoveStyle(attr.m_right);
+ m_top.RemoveStyle(attr.m_top);
+ m_bottom.RemoveStyle(attr.m_bottom);
+ return true;
+}
+
+// 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 wxTextBoxAttrBorders::CollectCommonAttributes(const wxTextBoxAttrBorders& attr, wxTextBoxAttrBorders& clashingAttr, wxTextBoxAttrBorders& absentAttr)
+{
+ m_left.CollectCommonAttributes(attr.m_left, clashingAttr.m_left, absentAttr.m_left);
+ m_right.CollectCommonAttributes(attr.m_right, clashingAttr.m_right, absentAttr.m_right);
+ m_top.CollectCommonAttributes(attr.m_top, clashingAttr.m_top, absentAttr.m_top);
+ m_bottom.CollectCommonAttributes(attr.m_bottom, clashingAttr.m_bottom, absentAttr.m_bottom);
+}
+
+// Set style of all borders
+void wxTextBoxAttrBorders::SetStyle(int style)
+{
+ m_left.SetStyle(style);
+ m_right.SetStyle(style);
+ m_top.SetStyle(style);
+ m_bottom.SetStyle(style);
+}
+
+// Set colour of all borders
+void wxTextBoxAttrBorders::SetColour(unsigned long colour)
+{
+ m_left.SetColour(colour);
+ m_right.SetColour(colour);
+ m_top.SetColour(colour);
+ m_bottom.SetColour(colour);
+}
+
+void wxTextBoxAttrBorders::SetColour(const wxColour& colour)
+{
+ m_left.SetColour(colour);
+ m_right.SetColour(colour);
+ m_top.SetColour(colour);
+ m_bottom.SetColour(colour);
+}
+
+// Set width of all borders
+void wxTextBoxAttrBorders::SetWidth(const wxTextAttrDimension& width)
+{
+ m_left.SetWidth(width);
+ m_right.SetWidth(width);
+ m_top.SetWidth(width);
+ m_bottom.SetWidth(width);
+}
+
+// Partial equality test
+bool wxTextAttrDimension::EqPartial(const wxTextAttrDimension& dim) const
+{
+ if (dim.IsPresent() && IsPresent() && !((*this) == dim))
+ return false;
+ else
+ return true;
+}
+
+bool wxTextAttrDimension::Apply(const wxTextAttrDimension& dim, const wxTextAttrDimension* compareWith)
+{
+ if (dim.IsPresent())
+ {
+ if (!(compareWith && dim == (*compareWith)))
+ (*this) = dim;
+ }
+
+ return true;
+}
+
+// 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 wxTextAttrDimension::CollectCommonAttributes(const wxTextAttrDimension& attr, wxTextAttrDimension& clashingAttr, wxTextAttrDimension& absentAttr)
+{
+ if (attr.IsPresent())
+ {
+ if (!clashingAttr.IsPresent() && !absentAttr.IsPresent())
+ {
+ if (IsPresent())
+ {
+ if (!((*this) == attr))
+ {
+ clashingAttr.SetPresent(true);
+ SetPresent(false);
+ }
+ }
+ else
+ (*this) = attr;
+ }
+ }
+ else
+ absentAttr.SetPresent(true);
+}
+
+// Partial equality test
+bool wxTextBoxAttrDimensions::EqPartial(const wxTextBoxAttrDimensions& dims) const
+{
+ if (!m_left.EqPartial(dims.m_left))
+ return false;
+
+ if (!m_right.EqPartial(dims.m_right))
+ return false;
+
+ if (!m_top.EqPartial(dims.m_top))
+ return false;
+
+ if (!m_bottom.EqPartial(dims.m_bottom))
+ return false;
+
+ return true;
+}
+
+// Apply border to 'this', but not if the same as compareWith
+bool wxTextBoxAttrDimensions::Apply(const wxTextBoxAttrDimensions& dims, const wxTextBoxAttrDimensions* compareWith)
+{
+ m_left.Apply(dims.m_left, compareWith ? (& compareWith->m_left) : (const wxTextAttrDimension*) NULL);
+ m_right.Apply(dims.m_right, compareWith ? (& compareWith->m_right): (const wxTextAttrDimension*) NULL);
+ m_top.Apply(dims.m_top, compareWith ? (& compareWith->m_top): (const wxTextAttrDimension*) NULL);
+ m_bottom.Apply(dims.m_bottom, compareWith ? (& compareWith->m_bottom): (const wxTextAttrDimension*) NULL);
+
+ return true;
+}
+
+// Remove specified attributes from this object
+bool wxTextBoxAttrDimensions::RemoveStyle(const wxTextBoxAttrDimensions& attr)
+{
+ if (attr.m_left.IsPresent())
+ m_left.Reset();
+ if (attr.m_right.IsPresent())
+ m_right.Reset();
+ if (attr.m_top.IsPresent())
+ m_top.Reset();
+ if (attr.m_bottom.IsPresent())
+ m_bottom.Reset();
+
+ return true;
+}
+
+// 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 wxTextBoxAttrDimensions::CollectCommonAttributes(const wxTextBoxAttrDimensions& attr, wxTextBoxAttrDimensions& clashingAttr, wxTextBoxAttrDimensions& absentAttr)
+{
+ m_left.CollectCommonAttributes(attr.m_left, clashingAttr.m_left, absentAttr.m_left);
+ m_right.CollectCommonAttributes(attr.m_right, clashingAttr.m_right, absentAttr.m_right);
+ m_top.CollectCommonAttributes(attr.m_top, clashingAttr.m_top, absentAttr.m_top);
+ m_bottom.CollectCommonAttributes(attr.m_bottom, clashingAttr.m_bottom, absentAttr.m_bottom);
+}
+
+// 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 wxTextAttrCollectCommonAttributes(wxTextAttr& currentStyle, const wxTextAttr& attr, wxTextAttr& clashingAttr, wxTextAttr& absentAttr)
+{
+ absentAttr.SetFlags(absentAttr.GetFlags() | (~attr.GetFlags() & wxTEXT_ATTR_ALL));
+ absentAttr.SetTextEffectFlags(absentAttr.GetTextEffectFlags() | (~attr.GetTextEffectFlags() & 0xFFFF));
+
+ long forbiddenFlags = clashingAttr.GetFlags()|absentAttr.GetFlags();
+
+ if (attr.HasFont())
+ {
+ if (attr.HasFontSize() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_SIZE))
+ {
+ if (currentStyle.HasFontSize())
+ {
+ if (currentStyle.GetFontSize() != attr.GetFontSize())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_FONT_SIZE);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_SIZE);
+ }
+ }
+ else
+ currentStyle.SetFontSize(attr.GetFontSize());
+ }
+
+ if (attr.HasFontItalic() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_ITALIC))
+ {
+ if (currentStyle.HasFontItalic())
+ {
+ if (currentStyle.GetFontStyle() != attr.GetFontStyle())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_FONT_ITALIC);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_ITALIC);
+ }
+ }
+ else
+ currentStyle.SetFontStyle(attr.GetFontStyle());
+ }
+
+ if (attr.HasFontFamily() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_FAMILY))
+ {
+ if (currentStyle.HasFontFamily())
+ {
+ if (currentStyle.GetFontFamily() != attr.GetFontFamily())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_FONT_FAMILY);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_FAMILY);
+ }
+ }
+ else
+ currentStyle.SetFontFamily(attr.GetFontFamily());
+ }
+
+ if (attr.HasFontWeight() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_WEIGHT))
+ {
+ if (currentStyle.HasFontWeight())
+ {
+ if (currentStyle.GetFontWeight() != attr.GetFontWeight())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_FONT_WEIGHT);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_WEIGHT);
+ }
+ }
+ else
+ currentStyle.SetFontWeight(attr.GetFontWeight());
+ }
+
+ if (attr.HasFontFaceName() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_FACE))
+ {
+ if (currentStyle.HasFontFaceName())
+ {
+ wxString faceName1(currentStyle.GetFontFaceName());
+ wxString faceName2(attr.GetFontFaceName());
+
+ if (faceName1 != faceName2)
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_FONT_FACE);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_FACE);
+ }
+ }
+ else
+ currentStyle.SetFontFaceName(attr.GetFontFaceName());
+ }
+
+ if (attr.HasFontUnderlined() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_FONT_UNDERLINE))
+ {
+ if (currentStyle.HasFontUnderlined())
+ {
+ if (currentStyle.GetFontUnderlined() != attr.GetFontUnderlined())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_FONT_UNDERLINE);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_FONT_UNDERLINE);
+ }
+ }
+ else
+ currentStyle.SetFontUnderlined(attr.GetFontUnderlined());
+ }
+ }
+
+ if (attr.HasTextColour() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_TEXT_COLOUR))
+ {
+ if (currentStyle.HasTextColour())
+ {
+ if (currentStyle.GetTextColour() != attr.GetTextColour())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_TEXT_COLOUR);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_TEXT_COLOUR);
+ }
+ }
+ else
+ currentStyle.SetTextColour(attr.GetTextColour());
+ }
+
+ if (attr.HasBackgroundColour() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_BACKGROUND_COLOUR))
+ {
+ if (currentStyle.HasBackgroundColour())
+ {
+ if (currentStyle.GetBackgroundColour() != attr.GetBackgroundColour())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_BACKGROUND_COLOUR);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_BACKGROUND_COLOUR);
+ }
+ }
+ else
+ currentStyle.SetBackgroundColour(attr.GetBackgroundColour());
+ }
+
+ if (attr.HasAlignment() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_ALIGNMENT))
+ {
+ if (currentStyle.HasAlignment())
+ {
+ if (currentStyle.GetAlignment() != attr.GetAlignment())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_ALIGNMENT);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_ALIGNMENT);
+ }
+ }
+ else
+ currentStyle.SetAlignment(attr.GetAlignment());
+ }
+
+ if (attr.HasTabs() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_TABS))
+ {
+ if (currentStyle.HasTabs())
+ {
+ if (!wxRichTextTabsEq(currentStyle.GetTabs(), attr.GetTabs()))
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_TABS);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_TABS);
+ }
+ }
+ else
+ currentStyle.SetTabs(attr.GetTabs());
+ }
+
+ if (attr.HasLeftIndent() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_LEFT_INDENT))
+ {
+ if (currentStyle.HasLeftIndent())
+ {
+ if (currentStyle.GetLeftIndent() != attr.GetLeftIndent() || currentStyle.GetLeftSubIndent() != attr.GetLeftSubIndent())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_LEFT_INDENT);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_LEFT_INDENT);
+ }
+ }
+ else
+ currentStyle.SetLeftIndent(attr.GetLeftIndent(), attr.GetLeftSubIndent());
+ }
+
+ if (attr.HasRightIndent() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_RIGHT_INDENT))
+ {
+ if (currentStyle.HasRightIndent())
+ {
+ if (currentStyle.GetRightIndent() != attr.GetRightIndent())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_RIGHT_INDENT);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_RIGHT_INDENT);
+ }
+ }
+ else
+ currentStyle.SetRightIndent(attr.GetRightIndent());
+ }
+
+ if (attr.HasParagraphSpacingAfter() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_PARA_SPACING_AFTER))
+ {
+ if (currentStyle.HasParagraphSpacingAfter())
+ {
+ if (currentStyle.GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_PARA_SPACING_AFTER);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_PARA_SPACING_AFTER);
+ }
+ }
+ else
+ currentStyle.SetParagraphSpacingAfter(attr.GetParagraphSpacingAfter());
+ }
+
+ if (attr.HasParagraphSpacingBefore() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_PARA_SPACING_BEFORE))
+ {
+ if (currentStyle.HasParagraphSpacingBefore())
+ {
+ if (currentStyle.GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE);
+ }
+ }
+ else
+ currentStyle.SetParagraphSpacingBefore(attr.GetParagraphSpacingBefore());
+ }
+
+ if (attr.HasLineSpacing() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_LINE_SPACING))
+ {
+ if (currentStyle.HasLineSpacing())
+ {
+ if (currentStyle.GetLineSpacing() != attr.GetLineSpacing())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_LINE_SPACING);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_LINE_SPACING);
+ }
+ }
+ else
+ currentStyle.SetLineSpacing(attr.GetLineSpacing());
+ }
+
+ if (attr.HasCharacterStyleName() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_CHARACTER_STYLE_NAME))
+ {
+ if (currentStyle.HasCharacterStyleName())
+ {
+ if (currentStyle.GetCharacterStyleName() != attr.GetCharacterStyleName())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME);
+ }
+ }
+ else
+ currentStyle.SetCharacterStyleName(attr.GetCharacterStyleName());
+ }
+
+ if (attr.HasParagraphStyleName() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_PARAGRAPH_STYLE_NAME))
+ {
+ if (currentStyle.HasParagraphStyleName())
+ {
+ if (currentStyle.GetParagraphStyleName() != attr.GetParagraphStyleName())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME);
+ }
+ }
+ else
+ currentStyle.SetParagraphStyleName(attr.GetParagraphStyleName());
+ }
+
+ if (attr.HasListStyleName() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_LIST_STYLE_NAME))
+ {
+ if (currentStyle.HasListStyleName())
+ {
+ if (currentStyle.GetListStyleName() != attr.GetListStyleName())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_LIST_STYLE_NAME);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_LIST_STYLE_NAME);
+ }
+ }
+ else
+ currentStyle.SetListStyleName(attr.GetListStyleName());
+ }
+
+ if (attr.HasBulletStyle() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_BULLET_STYLE))
+ {
+ if (currentStyle.HasBulletStyle())
+ {
+ if (currentStyle.GetBulletStyle() != attr.GetBulletStyle())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_BULLET_STYLE);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_BULLET_STYLE);
+ }
+ }
+ else
+ currentStyle.SetBulletStyle(attr.GetBulletStyle());
+ }
+
+ if (attr.HasBulletNumber() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_BULLET_NUMBER))
+ {
+ if (currentStyle.HasBulletNumber())
+ {
+ if (currentStyle.GetBulletNumber() != attr.GetBulletNumber())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_BULLET_NUMBER);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_BULLET_NUMBER);
+ }
+ }
+ else
+ currentStyle.SetBulletNumber(attr.GetBulletNumber());
+ }
+
+ if (attr.HasBulletText() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_BULLET_TEXT))
+ {
+ if (currentStyle.HasBulletText())
+ {
+ if (currentStyle.GetBulletText() != attr.GetBulletText())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_BULLET_TEXT);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_BULLET_TEXT);
+ }
+ }
+ else
+ {
+ currentStyle.SetBulletText(attr.GetBulletText());
+ currentStyle.SetBulletFont(attr.GetBulletFont());
+ }
+ }
+
+ if (attr.HasBulletName() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_BULLET_NAME))
+ {
+ if (currentStyle.HasBulletName())
+ {
+ if (currentStyle.GetBulletName() != attr.GetBulletName())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_BULLET_NAME);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_BULLET_NAME);
+ }
+ }
+ else
+ {
+ currentStyle.SetBulletName(attr.GetBulletName());
+ }
+ }
+
+ if (attr.HasURL() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_URL))
+ {
+ if (currentStyle.HasURL())
+ {
+ if (currentStyle.GetURL() != attr.GetURL())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_URL);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_URL);
+ }
+ }
+ else
+ {
+ currentStyle.SetURL(attr.GetURL());
+ }
+ }
+
+ if (attr.HasTextEffects() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_EFFECTS))
+ {
+ if (currentStyle.HasTextEffects())
+ {
+ // We need to find the bits in the new attr that are different:
+ // just look at those bits that are specified by the new attr.
+
+ // We need to remove the bits and flags that are not common between current attr
+ // and new attr. In so doing we need to take account of the styles absent from one or more of the
+ // previous styles.
+
+ int currentRelevantTextEffects = currentStyle.GetTextEffects() & attr.GetTextEffectFlags();
+ int newRelevantTextEffects = attr.GetTextEffects() & attr.GetTextEffectFlags();
+
+ if (currentRelevantTextEffects != newRelevantTextEffects)
+ {
+ // Find the text effects that were different, using XOR
+ int differentEffects = currentRelevantTextEffects ^ newRelevantTextEffects;
+
+ // Clash of attr - mark as such
+ clashingAttr.SetTextEffectFlags(clashingAttr.GetTextEffectFlags() | differentEffects);
+ currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~differentEffects);
+ }
+ }
+ else
+ {
+ currentStyle.SetTextEffects(attr.GetTextEffects());
+ currentStyle.SetTextEffectFlags(attr.GetTextEffectFlags());
+ }
+
+ // Mask out the flags and values that cannot be common because they were absent in one or more objecrs
+ // that we've looked at so far
+ currentStyle.SetTextEffects(currentStyle.GetTextEffects() & ~absentAttr.GetTextEffectFlags());
+ currentStyle.SetTextEffectFlags(currentStyle.GetTextEffectFlags() & ~absentAttr.GetTextEffectFlags());
+
+ if (currentStyle.GetTextEffectFlags() == 0)
+ currentStyle.RemoveFlag(wxTEXT_ATTR_EFFECTS);
+ }
+
+ if (attr.HasOutlineLevel() && !wxHasStyle(forbiddenFlags, wxTEXT_ATTR_OUTLINE_LEVEL))
+ {
+ if (currentStyle.HasOutlineLevel())
+ {
+ if (currentStyle.GetOutlineLevel() != attr.GetOutlineLevel())
+ {
+ // Clash of attr - mark as such
+ clashingAttr.AddFlag(wxTEXT_ATTR_OUTLINE_LEVEL);
+ currentStyle.RemoveFlag(wxTEXT_ATTR_OUTLINE_LEVEL);
+ }
+ }
+ else
+ currentStyle.SetOutlineLevel(attr.GetOutlineLevel());
+ }
+}
+
+
#endif
// wxUSE_RICHTEXT
{
wxPanel::TransferDataFromWindow();
- wxTextAttr* attr = GetAttributes();
+ wxRichTextAttr* attr = GetAttributes();
if (m_hasBulletStyle)
{
wxPanel::TransferDataToWindow();
- wxTextAttr* attr = GetAttributes();
+ wxRichTextAttr* attr = GetAttributes();
if (attr->HasBulletStyle())
{
iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
TransferDataFromWindow();
- wxTextAttr attr(*GetAttributes());
+ wxRichTextAttr attr(*GetAttributes());
attr.SetFlags(attr.GetFlags() &
(wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_TEXT|wxTEXT_ATTR_BULLET_NAME|
wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
font.SetPointSize(9);
m_previewCtrl->SetFont(font);
- wxTextAttr normalParaAttr;
+ wxRichTextAttr normalParaAttr;
normalParaAttr.SetFont(font);
normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
m_previewCtrl->Thaw();
}
-wxTextAttr* wxRichTextBulletsPage::GetAttributes()
+wxRichTextAttr* wxRichTextBulletsPage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}
};
#endif
-IMPLEMENT_DYNAMIC_CLASS( wxRichTextCtrl, wxTextCtrlBase )
+IMPLEMENT_DYNAMIC_CLASS( wxRichTextCtrl, wxControl )
IMPLEMENT_DYNAMIC_CLASS( wxRichTextEvent, wxNotifyEvent )
-BEGIN_EVENT_TABLE( wxRichTextCtrl, wxTextCtrlBase )
+BEGIN_EVENT_TABLE( wxRichTextCtrl, wxControl )
EVT_PAINT(wxRichTextCtrl::OnPaint)
EVT_ERASE_BACKGROUND(wxRichTextCtrl::OnEraseBackground)
EVT_IDLE(wxRichTextCtrl::OnIdle)
{
style |= wxVSCROLL;
- if (!wxTextCtrlBase::Create(parent, id, pos, size,
+ if (!wxControl::Create(parent, id, pos, size,
style|wxFULL_REPAINT_ON_RESIZE,
validator, name))
return false;
SetEditable(false);
// The base attributes must all have default values
- wxTextAttr attributes;
+ wxRichTextAttr attributes;
attributes.SetFont(GetFont());
attributes.SetTextColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
attributes.SetAlignment(wxTEXT_ALIGNMENT_LEFT);
// The default attributes will be merged with base attributes, so
// can be empty to begin with
- wxTextAttr defaultAttributes;
+ wxRichTextAttr defaultAttributes;
SetDefaultStyle(defaultAttributes);
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
if (!GetEventHandler()->ProcessEvent(cmdEvent))
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
if (GetStyle(position, attr))
{
if (attr.HasFlag(wxTEXT_ATTR_URL))
{
if (hit != wxRICHTEXT_HITTEST_NONE && !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
if (GetStyle(position, attr))
{
if (attr.HasFlag(wxTEXT_ATTR_URL))
}
/// Write an image at the current insertion point
-bool wxRichTextCtrl::WriteImage(const wxImage& image, wxBitmapType bitmapType, const wxRichTextAnchoredObjectAttr& attr)
+bool wxRichTextCtrl::WriteImage(const wxImage& image, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
{
wxRichTextImageBlock imageBlock;
wxImage image2 = image;
if (imageBlock.MakeImageBlock(image2, bitmapType))
- return WriteImage(imageBlock, attr);
+ return WriteImage(imageBlock, textAttr);
return false;
}
-bool wxRichTextCtrl::WriteImage(const wxString& filename, wxBitmapType bitmapType, const wxRichTextAnchoredObjectAttr& attr)
+bool wxRichTextCtrl::WriteImage(const wxString& filename, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
{
wxRichTextImageBlock imageBlock;
wxImage image;
if (imageBlock.MakeImageBlock(filename, bitmapType, image, false))
- return WriteImage(imageBlock, attr);
+ return WriteImage(imageBlock, textAttr);
return false;
}
-bool wxRichTextCtrl::WriteImage(const wxRichTextImageBlock& imageBlock, const wxRichTextAnchoredObjectAttr& attr)
+bool wxRichTextCtrl::WriteImage(const wxRichTextImageBlock& imageBlock, const wxRichTextAttr& textAttr)
{
- return GetBuffer().InsertImageWithUndo(m_caretPosition+1, imageBlock, this, NULL, attr);
+ return GetBuffer().InsertImageWithUndo(m_caretPosition+1, imageBlock, this, NULL, textAttr);
}
-bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType, const wxRichTextAnchoredObjectAttr& attr)
+bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType, const wxRichTextAttr& textAttr)
{
if (bitmap.Ok())
{
wxImage image = bitmap.ConvertToImage();
if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType))
- return WriteImage(imageBlock, attr);
+ return WriteImage(imageBlock, textAttr);
}
return false;
bool wxRichTextCtrl::SetStyle(long start, long end, const wxTextAttr& style)
{
- return GetBuffer().SetStyle(wxRichTextRange(start, end-1), wxTextAttr(style));
+ return GetBuffer().SetStyle(wxRichTextRange(start, end-1), wxRichTextAttr(style));
+}
+
+bool wxRichTextCtrl::SetStyle(long start, long end, const wxRichTextAttr& style)
+{
+ return GetBuffer().SetStyle(wxRichTextRange(start, end-1), style);
}
bool wxRichTextCtrl::SetStyle(const wxRichTextRange& range, const wxTextAttr& style)
+{
+ return GetBuffer().SetStyle(range.ToInternal(), wxRichTextAttr(style));
+}
+
+bool wxRichTextCtrl::SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style)
{
return GetBuffer().SetStyle(range.ToInternal(), style);
}
-void wxRichTextCtrl::SetImageStyle(wxRichTextImage *image, const wxRichTextAnchoredObjectAttr& attr)
+void wxRichTextCtrl::SetImageStyle(wxRichTextImage *image, const wxRichTextAttr& textAttr)
{
- GetBuffer().SetImageStyle(image, attr);
+ GetBuffer().SetImageStyle(image, textAttr);
}
// extended style setting operation with flags including:
// wxRICHTEXT_SETSTYLE_WITH_UNDO, wxRICHTEXT_SETSTYLE_OPTIMIZE, wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY.
// see richtextbuffer.h for more details.
-bool wxRichTextCtrl::SetStyleEx(const wxRichTextRange& range, const wxTextAttr& style, int flags)
+bool wxRichTextCtrl::SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags)
{
return GetBuffer().SetStyle(range.ToInternal(), style, flags);
}
bool wxRichTextCtrl::SetDefaultStyle(const wxTextAttr& style)
{
- return GetBuffer().SetDefaultStyle(wxTextAttr(style));
+ return GetBuffer().SetDefaultStyle(style);
}
-const wxTextAttr& wxRichTextCtrl::GetDefaultStyle() const
+bool wxRichTextCtrl::SetDefaultStyle(const wxRichTextAttr& style)
+{
+ return GetBuffer().SetDefaultStyle(style);
+}
+
+const wxRichTextAttr& wxRichTextCtrl::GetDefaultStyleEx() const
{
return GetBuffer().GetDefaultStyle();
}
bool wxRichTextCtrl::GetStyle(long position, wxTextAttr& style)
+{
+ wxRichTextAttr attr;
+ if (GetBuffer().GetStyle(position, attr))
+ {
+ style = attr;
+ return true;
+ }
+ else
+ return false;
+}
+
+bool wxRichTextCtrl::GetStyle(long position, wxRichTextAttr& style)
{
return GetBuffer().GetStyle(position, style);
}
// get the common set of styles for the range
bool wxRichTextCtrl::GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style)
+{
+ wxRichTextAttr attr;
+ if (GetBuffer().GetStyleForRange(range.ToInternal(), attr))
+ {
+ style = attr;
+ return true;
+ }
+ else
+ return false;
+}
+
+bool wxRichTextCtrl::GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style)
{
return GetBuffer().GetStyleForRange(range.ToInternal(), style);
}
/// Get the content (uncombined) attributes for this position.
-bool wxRichTextCtrl::GetUncombinedStyle(long position, wxTextAttr& style)
+bool wxRichTextCtrl::GetUncombinedStyle(long position, wxRichTextAttr& style)
{
return GetBuffer().GetUncombinedStyle(position, style);
}
/// Set font, and also the buffer attributes
bool wxRichTextCtrl::SetFont(const wxFont& font)
{
- wxTextCtrlBase::SetFont(font);
+ wxControl::SetFont(font);
- wxTextAttr attr = GetBuffer().GetAttributes();
+ wxRichTextAttr attr = GetBuffer().GetAttributes();
attr.SetFont(font);
GetBuffer().SetBasicStyle(attr);
{
if (HasSelection())
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
wxRichTextRange range = GetSelectionRange();
attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
attr.SetFontWeight(wxFONTWEIGHT_BOLD);
{
// If no selection, then we need to combine current style with default style
// to see what the effect would be if we started typing.
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
long pos = GetAdjustedCaretPosition(GetCaretPosition());
if (HasSelection())
{
wxRichTextRange range = GetSelectionRange();
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC);
attr.SetFontStyle(wxFONTSTYLE_ITALIC);
{
// If no selection, then we need to combine current style with default style
// to see what the effect would be if we started typing.
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC);
long pos = GetAdjustedCaretPosition(GetCaretPosition());
if (HasSelection())
{
wxRichTextRange range = GetSelectionRange();
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
attr.SetFontUnderlined(true);
{
// If no selection, then we need to combine current style with default style
// to see what the effect would be if we started typing.
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
long pos = GetAdjustedCaretPosition(GetCaretPosition());
/// Apply bold to the selection
bool wxRichTextCtrl::ApplyBoldToSelection()
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
attr.SetFontWeight(IsSelectionBold() ? wxFONTWEIGHT_NORMAL : wxFONTWEIGHT_BOLD);
/// Apply italic to the selection
bool wxRichTextCtrl::ApplyItalicToSelection()
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC);
attr.SetFontStyle(IsSelectionItalics() ? wxFONTSTYLE_NORMAL : wxFONTSTYLE_ITALIC);
/// Apply underline to the selection
bool wxRichTextCtrl::ApplyUnderlineToSelection()
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
attr.SetFontUnderlined(!IsSelectionUnderlined());
else
range = wxRichTextRange(GetCaretPosition()+1, GetCaretPosition()+2);
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetAlignment(alignment);
return HasParagraphAttributes(range, attr);
/// Apply alignment to the selection
bool wxRichTextCtrl::ApplyAlignmentToSelection(wxTextAttrAlignment alignment)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetAlignment(alignment);
if (HasSelection())
return SetStyle(GetSelectionRange(), attr);
{
// Flags are defined within each definition, so only certain
// attributes are applied.
- wxTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle());
+ wxRichTextAttr attr(GetStyleSheet() ? def->GetStyleMergedWithBase(GetStyleSheet()) : def->GetStyle());
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE|wxRICHTEXT_SETSTYLE_RESET;
return SetStyleEx(GetSelectionRange(), attr, flags);
else
{
- wxTextAttr current = GetDefaultStyleEx();
- wxTextAttr defaultStyle(attr);
+ wxRichTextAttr current = GetDefaultStyleEx();
+ wxRichTextAttr defaultStyle(attr);
if (isPara)
{
// Don't apply extra character styles since they are already implied
/// Sets the default style to the style under the cursor
bool wxRichTextCtrl::SetDefaultStyleToCursorStyle()
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetFlags(wxTEXT_ATTR_CHARACTER);
// If at the start of a paragraph, use the next position.
<bool name="proxy-wxSHAPED">0</bool>
<bool name="proxy-wxADJUST_MINSIZE">0</bool>
<bool name="proxy-wxFIXED_MINSIZE">0</bool>
- <document>
- <string name="title">"wxStaticText: wxID_STATIC"</string>
- <string name="type">"dialog-control-document"</string>
- <string name="filename">""</string>
- <string name="icon-name">"statictext"</string>
- <long name="is-transient">0</long>
- <long name="owns-file">1</long>
- <long name="title-mode">0</long>
- <long name="locked">0</long>
- <string name="proxy-type">"wbStaticTextProxy"</string>
- <string name="proxy-Id name">"wxID_STATIC"</string>
- <long name="proxy-Id value">5105</long>
- <string name="proxy-Name">""</string>
- <string name="proxy-Class">"wxStaticText"</string>
- <string name="proxy-Base class">"wxStaticText"</string>
- <bool name="proxy-External implementation">1</bool>
- <bool name="proxy-Separate files">0</bool>
- <string name="proxy-Implementation filename">""</string>
- <string name="proxy-Header filename">""</string>
- <string name="proxy-Member variable name">""</string>
- <string name="proxy-Label">"Alignment:"</string>
- <long name="proxy-Wrapping width">-1</long>
- <string name="proxy-Help text">""</string>
- <string name="proxy-Tooltip text">""</string>
- <string name="proxy-Background colour">""</string>
- <string name="proxy-Foreground colour">""</string>
- <string name="proxy-Font">""</string>
- <bool name="proxy-Hidden">1</bool>
- <bool name="proxy-Enabled">1</bool>
- <string name="proxy-Platform">"<Any platform>"</string>
- <string name="proxy-Data variable">""</string>
- <string name="proxy-Data validator">""</string>
- <string name="proxy-Data source">""</string>
- <string name="proxy-Data class name">""</string>
- <string name="proxy-Data class implementation filename">""</string>
- <string name="proxy-Data class header filename">""</string>
- <string name="proxy-Data class manager window">""</string>
- <bool name="proxy-wxALIGN_LEFT">0</bool>
- <bool name="proxy-wxALIGN_RIGHT">0</bool>
- <bool name="proxy-wxALIGN_CENTRE">0</bool>
- <bool name="proxy-wxST_NO_AUTORESIZE">0</bool>
- <bool name="proxy-wxNO_BORDER">0</bool>
- <bool name="proxy-wxSIMPLE_BORDER">0</bool>
- <bool name="proxy-wxDOUBLE_BORDER">0</bool>
- <bool name="proxy-wxBORDER_THEME">0</bool>
- <bool name="proxy-wxSUNKEN_BORDER">0</bool>
- <bool name="proxy-wxRAISED_BORDER">0</bool>
- <bool name="proxy-wxSTATIC_BORDER">0</bool>
- <bool name="proxy-wxWANTS_CHARS">0</bool>
- <bool name="proxy-wxNO_FULL_REPAINT_ON_RESIZE">0</bool>
- <bool name="proxy-wxFULL_REPAINT_ON_RESIZE">0</bool>
- <string name="proxy-Custom styles">""</string>
- <long name="proxy-X">-1</long>
- <long name="proxy-Y">-1</long>
- <long name="proxy-Width">-1</long>
- <long name="proxy-Height">-1</long>
- <string name="proxy-AlignH">"Centre"</string>
- <string name="proxy-AlignV">"Centre"</string>
- <long name="proxy-Stretch factor">0</long>
- <long name="proxy-Border">5</long>
- <bool name="proxy-wxLEFT">1</bool>
- <bool name="proxy-wxRIGHT">1</bool>
- <bool name="proxy-wxTOP">1</bool>
- <bool name="proxy-wxBOTTOM">1</bool>
- <bool name="proxy-wxSHAPED">0</bool>
- <bool name="proxy-wxADJUST_MINSIZE">0</bool>
- <bool name="proxy-wxFIXED_MINSIZE">0</bool>
- <string name="proxy-Custom arguments">""</string>
- <string name="proxy-Custom ctor arguments">""</string>
- </document>
- <document>
- <string name="title">"wxComboBox: ID_COMBOBOX_ALIGN"</string>
- <string name="type">"dialog-control-document"</string>
- <string name="filename">""</string>
- <string name="icon-name">"combobox"</string>
- <long name="is-transient">0</long>
- <long name="owns-file">1</long>
- <long name="title-mode">0</long>
- <long name="locked">0</long>
- <string name="proxy-type">"wbComboBoxProxy"</string>
- <string name="proxy-Id name">"ID_COMBOBOX_ALIGN"</string>
- <long name="proxy-Id value">10016</long>
- <string name="proxy-Name">""</string>
- <string name="proxy-Class">"wxComboBox"</string>
- <string name="proxy-Base class">"wxComboBox"</string>
- <bool name="proxy-External implementation">1</bool>
- <bool name="proxy-Separate files">0</bool>
- <string name="proxy-Implementation filename">""</string>
- <string name="proxy-Header filename">""</string>
- <string name="proxy-Member variable name">"m_alignment"</string>
- <string name="proxy-Strings">"Left|Centre|Right"</string>
- <string name="proxy-Initial value">"Left"</string>
- <string name="proxy-Help text">""</string>
- <string name="proxy-Tooltip text">""</string>
- <string name="proxy-Background colour">""</string>
- <string name="proxy-Foreground colour">""</string>
- <string name="proxy-Font">""</string>
- <bool name="proxy-Hidden">1</bool>
- <bool name="proxy-Enabled">1</bool>
- <string name="proxy-Platform">"<Any platform>"</string>
- <string name="proxy-Data variable">""</string>
- <string name="proxy-Data validator">""</string>
- <string name="proxy-Data source">""</string>
- <string name="proxy-Data class name">""</string>
- <string name="proxy-Data class implementation filename">""</string>
- <string name="proxy-Data class header filename">""</string>
- <string name="proxy-Data class manager window">""</string>
- <bool name="proxy-wxCB_SIMPLE">0</bool>
- <bool name="proxy-wxCB_DROPDOWN">0</bool>
- <bool name="proxy-wxCB_READONLY">1</bool>
- <bool name="proxy-wxCB_SORT">0</bool>
- <bool name="proxy-wxTE_PROCESS_ENTER">0</bool>
- <bool name="proxy-wxWANTS_CHARS">0</bool>
- <bool name="proxy-wxNO_FULL_REPAINT_ON_RESIZE">0</bool>
- <bool name="proxy-wxFULL_REPAINT_ON_RESIZE">0</bool>
- <string name="proxy-Custom styles">""</string>
- <long name="proxy-X">-1</long>
- <long name="proxy-Y">-1</long>
- <long name="proxy-Width">80</long>
- <long name="proxy-Height">-1</long>
- <string name="proxy-AlignH">"Centre"</string>
- <string name="proxy-AlignV">"Centre"</string>
- <long name="proxy-Stretch factor">0</long>
- <long name="proxy-Border">5</long>
- <bool name="proxy-wxLEFT">1</bool>
- <bool name="proxy-wxRIGHT">1</bool>
- <bool name="proxy-wxTOP">1</bool>
- <bool name="proxy-wxBOTTOM">1</bool>
- <bool name="proxy-wxSHAPED">0</bool>
- <bool name="proxy-wxADJUST_MINSIZE">0</bool>
- <bool name="proxy-wxFIXED_MINSIZE">0</bool>
- <string name="proxy-Custom arguments">""</string>
- <string name="proxy-Custom ctor arguments">""</string>
- </document>
<document>
<string name="title">"wxStaticText: wxID_STATIC"</string>
<string name="type">"dialog-control-document"</string>
{
wxPanel::TransferDataFromWindow();
- wxTextAttr* attr = GetAttributes();
+ wxRichTextAttr* attr = GetAttributes();
if (m_faceListBox->GetSelection() != wxNOT_FOUND)
{
wxPanel::TransferDataToWindow();
m_dontUpdate = true;
- wxTextAttr* attr = GetAttributes();
+ wxRichTextAttr* attr = GetAttributes();
if (attr->HasFontFaceName())
{
return true;
}
-wxTextAttr* wxRichTextFontPage::GetAttributes()
+wxRichTextAttr* wxRichTextFontPage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}
/// Updates the font preview
void wxRichTextFontPage::UpdatePreview()
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
if (m_colourPresent)
m_previewCtrl->SetForegroundColour(m_colourCtrl->GetBackgroundColour());
}
/// Set the attributes and optionally update the display
-bool wxRichTextFormattingDialog::SetStyle(const wxTextAttr& style, bool update)
+bool wxRichTextFormattingDialog::SetStyle(const wxRichTextAttr& style, bool update)
{
m_attributes = style;
if (update)
// Helper for pages to get the attributes
-wxTextAttr* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win)
+wxRichTextAttr* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win)
{
wxRichTextFormattingDialog* dialog = GetDialog(win);
if (dialog)
wxTextOutputStream str(stream, wxEOL_NATIVE);
#endif
- wxTextAttr currentParaStyle = buffer->GetAttributes();
- wxTextAttr currentCharStyle = buffer->GetAttributes();
+ wxRichTextAttr currentParaStyle = buffer->GetAttributes();
+ wxRichTextAttr currentCharStyle = buffer->GetAttributes();
if ((GetFlags() & wxRICHTEXT_HANDLER_NO_HEADER_FOOTER) == 0)
str << wxT("<html><head></head><body>\n");
if (para)
{
- wxTextAttr paraStyle(para->GetCombinedAttributes());
+ wxRichTextAttr paraStyle(para->GetCombinedAttributes());
BeginParagraphFormatting(currentParaStyle, paraStyle, str);
wxRichTextPlainText* textObj = wxDynamicCast(obj, wxRichTextPlainText);
if (textObj && !textObj->IsEmpty())
{
- wxTextAttr charStyle(para->GetCombinedAttributes(obj->GetAttributes()));
+ wxRichTextAttr charStyle(para->GetCombinedAttributes(obj->GetAttributes()));
BeginCharacterFormatting(currentCharStyle, charStyle, paraStyle, str);
wxString text = textObj->GetText();
return true;
}
-void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxTextAttr& currentStyle, const wxTextAttr& thisStyle, const wxTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& str)
+void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, const wxRichTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& str)
{
wxString style;
str << wxT("<a href=\"") << thisStyle.GetURL() << wxT("\">");
}
-void wxRichTextHTMLHandler::EndCharacterFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, const wxTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& stream)
+void wxRichTextHTMLHandler::EndCharacterFormatting(const wxRichTextAttr& WXUNUSED(currentStyle), const wxRichTextAttr& thisStyle, const wxRichTextAttr& WXUNUSED(paraStyle), wxTextOutputStream& stream)
{
if (thisStyle.HasURL())
stream << wxT("</a>");
}
/// Begin paragraph formatting
-void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, wxTextOutputStream& str)
+void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxRichTextAttr& WXUNUSED(currentStyle), const wxRichTextAttr& thisStyle, wxTextOutputStream& str)
{
if (thisStyle.HasPageBreak())
{
}
/// End paragraph formatting
-void wxRichTextHTMLHandler::EndParagraphFormatting(const wxTextAttr& WXUNUSED(currentStyle), const wxTextAttr& thisStyle, wxTextOutputStream& stream)
+void wxRichTextHTMLHandler::EndParagraphFormatting(const wxRichTextAttr& WXUNUSED(currentStyle), const wxRichTextAttr& thisStyle, wxTextOutputStream& stream)
{
if (thisStyle.HasFont())
stream << wxT("</font>");
}
/// Output font tag
-void wxRichTextHTMLHandler::OutputFont(const wxTextAttr& style, wxTextOutputStream& stream)
+void wxRichTextHTMLHandler::OutputFont(const wxRichTextAttr& style, wxTextOutputStream& stream)
{
if (style.HasFont())
{
}
}
-int wxRichTextHTMLHandler::TypeOfList( const wxTextAttr& thisStyle, wxString& tag )
+int wxRichTextHTMLHandler::TypeOfList( const wxRichTextAttr& thisStyle, wxString& tag )
{
// We can use number attribute of li tag but not all the browsers support it.
// also wxHtmlWindow doesn't support type attribute.
return 0;
}
-wxString wxRichTextHTMLHandler::GetAlignment( const wxTextAttr& thisStyle )
+wxString wxRichTextHTMLHandler::GetAlignment( const wxRichTextAttr& thisStyle )
{
switch( thisStyle.GetAlignment() )
{
void wxRichTextImageDialog::Init()
{
////@begin wxRichTextImageDialog member initialisation
- m_alignment = NULL;
m_float = NULL;
m_width = NULL;
m_unitsW = NULL;
wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(0, 2, 0, 0);
itemBoxSizer3->Add(itemFlexGridSizer4, 0, wxALIGN_TOP|wxRIGHT, 5);
- wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Alignment:"), wxDefaultPosition, wxDefaultSize, 0 );
- itemStaticText5->Show(false);
- itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
-
- wxArrayString m_alignmentStrings;
- m_alignmentStrings.Add(_("Left"));
- m_alignmentStrings.Add(_("Centre"));
- m_alignmentStrings.Add(_("Right"));
- m_alignment = new wxComboBox( itemDialog1, ID_COMBOBOX_ALIGN, _("Left"), wxDefaultPosition, wxSize(80, -1), m_alignmentStrings, wxCB_READONLY );
- m_alignment->SetStringSelection(_("Left"));
- m_alignment->Show(false);
- itemFlexGridSizer4->Add(m_alignment, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
-
- wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Floating mode:"), wxDefaultPosition, wxDefaultSize, 0 );
- itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Floating mode:"), wxDefaultPosition, wxDefaultSize, 0 );
+ itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_floatStrings;
m_floatStrings.Add(_("None"));
m_float->SetToolTip(_("How the image will float relative to the text."));
itemFlexGridSizer4->Add(m_float, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
- itemFlexGridSizer4->Add(itemStaticText9, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Width:"), wxDefaultPosition, wxDefaultSize, 0 );
+ itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
- itemFlexGridSizer4->Add(itemBoxSizer10, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
+ wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
+ itemFlexGridSizer4->Add(itemBoxSizer8, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
m_width = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_WIDTH, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
m_width->SetHelpText(_("The image width to be shown - does not change the source image width."));
if (wxRichTextImageDialog::ShowToolTips())
m_width->SetToolTip(_("The image width to be shown - does not change the source image width."));
- itemBoxSizer10->Add(m_width, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ itemBoxSizer8->Add(m_width, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_unitsWStrings;
m_unitsWStrings.Add(_("px"));
m_unitsW->SetHelpText(_("Units for the image width."));
if (wxRichTextImageDialog::ShowToolTips())
m_unitsW->SetToolTip(_("Units for the image width."));
- itemBoxSizer10->Add(m_unitsW, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ itemBoxSizer8->Add(m_unitsW, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Height:"), wxDefaultPosition, wxDefaultSize, 0 );
- itemFlexGridSizer4->Add(itemStaticText13, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ wxStaticText* itemStaticText11 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Height:"), wxDefaultPosition, wxDefaultSize, 0 );
+ itemFlexGridSizer4->Add(itemStaticText11, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL);
- itemFlexGridSizer4->Add(itemBoxSizer14, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
+ wxBoxSizer* itemBoxSizer12 = new wxBoxSizer(wxHORIZONTAL);
+ itemFlexGridSizer4->Add(itemBoxSizer12, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
m_height = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_HEIGHT, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
m_height->SetHelpText(_("The image height to be shown - does not change the source image height."));
if (wxRichTextImageDialog::ShowToolTips())
m_height->SetToolTip(_("The image height to be shown - does not change the source image height."));
- itemBoxSizer14->Add(m_height, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ itemBoxSizer12->Add(m_height, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_unitsHStrings;
m_unitsHStrings.Add(_("px"));
m_unitsH->SetHelpText(_("Units for the image height."));
if (wxRichTextImageDialog::ShowToolTips())
m_unitsH->SetToolTip(_("Units for the image height."));
- itemBoxSizer14->Add(m_unitsH, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ itemBoxSizer12->Add(m_unitsH, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxStaticText* itemStaticText17 = new wxStaticText( itemDialog1, wxID_STATIC, _("Image Vertical &Offset:"), wxDefaultPosition, wxDefaultSize, 0 );
- itemFlexGridSizer4->Add(itemStaticText17, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ wxStaticText* itemStaticText15 = new wxStaticText( itemDialog1, wxID_STATIC, _("Image Vertical &Offset:"), wxDefaultPosition, wxDefaultSize, 0 );
+ itemFlexGridSizer4->Add(itemStaticText15, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxHORIZONTAL);
- itemFlexGridSizer4->Add(itemBoxSizer18, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
+ wxBoxSizer* itemBoxSizer16 = new wxBoxSizer(wxHORIZONTAL);
+ itemFlexGridSizer4->Add(itemBoxSizer16, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
m_offset = new wxTextCtrl( itemDialog1, ID_RICHTEXTIMAGEDIALOG_OFFSET, wxEmptyString, wxDefaultPosition, wxSize(65, -1), 0 );
m_offset->SetMaxLength(10);
m_offset->SetHelpText(_("The vertical offset relative to the paragraph."));
if (wxRichTextImageDialog::ShowToolTips())
m_offset->SetToolTip(_("The vertical offset relative to the paragraph."));
- itemBoxSizer18->Add(m_offset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ itemBoxSizer16->Add(m_offset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxArrayString m_unitsOffsetStrings;
m_unitsOffsetStrings.Add(_("px"));
m_unitsOffset->SetHelpText(_("Units for the image offset."));
if (wxRichTextImageDialog::ShowToolTips())
m_unitsOffset->SetToolTip(_("Units for the image offset."));
- itemBoxSizer18->Add(m_unitsOffset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ itemBoxSizer16->Add(m_unitsOffset, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxStaticText* itemStaticText21 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Move the image to:"), wxDefaultPosition, wxDefaultSize, 0 );
- itemFlexGridSizer4->Add(itemStaticText21, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ wxStaticText* itemStaticText19 = new wxStaticText( itemDialog1, wxID_STATIC, _("&Move the image to:"), wxDefaultPosition, wxDefaultSize, 0 );
+ itemFlexGridSizer4->Add(itemStaticText19, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxHORIZONTAL);
- itemFlexGridSizer4->Add(itemBoxSizer22, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
+ wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
+ itemFlexGridSizer4->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
- wxButton* itemButton23 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_PARA_UP, _("&Previous Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
- itemButton23->SetHelpText(_("Moves the image to the previous paragraph."));
+ wxButton* itemButton21 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_PARA_UP, _("&Previous Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
+ itemButton21->SetHelpText(_("Moves the image to the previous paragraph."));
if (wxRichTextImageDialog::ShowToolTips())
- itemButton23->SetToolTip(_("Moves the image to the previous paragraph."));
- itemBoxSizer22->Add(itemButton23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+ itemButton21->SetToolTip(_("Moves the image to the previous paragraph."));
+ itemBoxSizer20->Add(itemButton21, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
- wxButton* itemButton24 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_DOWN, _("&Next Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
- itemButton24->SetHelpText(_("Moves the image to the next paragraph."));
+ wxButton* itemButton22 = new wxButton( itemDialog1, ID_RICHTEXTIMAGEDIALOG_DOWN, _("&Next Paragraph"), wxDefaultPosition, wxDefaultSize, 0 );
+ itemButton22->SetHelpText(_("Moves the image to the next paragraph."));
if (wxRichTextImageDialog::ShowToolTips())
- itemButton24->SetToolTip(_("Moves the image to the next paragraph."));
- itemBoxSizer22->Add(itemButton24, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
+ itemButton22->SetToolTip(_("Moves the image to the next paragraph."));
+ itemBoxSizer20->Add(itemButton22, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
- wxStaticLine* itemStaticLine25 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
- itemBoxSizer2->Add(itemStaticLine25, 0, wxGROW|wxALL, 5);
+ wxStaticLine* itemStaticLine23 = new wxStaticLine( itemDialog1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
+ itemBoxSizer2->Add(itemStaticLine23, 0, wxGROW|wxALL, 5);
- wxStdDialogButtonSizer* itemStdDialogButtonSizer26 = new wxStdDialogButtonSizer;
+ wxStdDialogButtonSizer* itemStdDialogButtonSizer24 = new wxStdDialogButtonSizer;
- itemBoxSizer2->Add(itemStdDialogButtonSizer26, 0, wxGROW|wxALL, 5);
+ itemBoxSizer2->Add(itemStdDialogButtonSizer24, 0, wxGROW|wxALL, 5);
m_saveButton = new wxButton( itemDialog1, wxID_OK, _("OK"), wxDefaultPosition, wxDefaultSize, 0 );
m_saveButton->SetHelpText(_("Click to confirm your changes."));
if (wxRichTextImageDialog::ShowToolTips())
m_saveButton->SetToolTip(_("Click to confirm your changes."));
- itemStdDialogButtonSizer26->AddButton(m_saveButton);
+ itemStdDialogButtonSizer24->AddButton(m_saveButton);
m_cancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
m_cancelButton->SetHelpText(_("Click to discard your changes."));
if (wxRichTextImageDialog::ShowToolTips())
m_cancelButton->SetToolTip(_("Click to discard your changes."));
- itemStdDialogButtonSizer26->AddButton(m_cancelButton);
+ itemStdDialogButtonSizer24->AddButton(m_cancelButton);
- itemStdDialogButtonSizer26->Realize();
+ itemStdDialogButtonSizer24->Realize();
////@end wxRichTextImageDialog content construction
}
/*!
* Set the image attribute
*/
-void wxRichTextImageDialog::SetImageAttr(const wxRichTextAnchoredObjectAttr& attr)
+void wxRichTextImageDialog::SetImageAttr(const wxRichTextAttr& textAttr)
{
- m_attr = attr;
+ m_textAttr = textAttr;
+
TransferDataToWindow();
}
TransferDataFromWindow();
if (m_buffer->GetRichTextCtrl())
{
- m_buffer->GetRichTextCtrl()->SetImageStyle(image, m_attr);
+ m_buffer->GetRichTextCtrl()->SetImageStyle(image, m_textAttr);
}
return image;
}
m_buffer = buffer;
m_image = image;
m_parent = parent;
- SetImageAttr(image->GetAnchoredAttr());
+ SetImageAttr(image->GetAttributes());
if (image->GetImageCache().IsOk())
{
- if (m_attr.m_width == -1)
+ if (!m_textAttr.GetTextBoxAttr().GetWidth().IsPresent() || m_textAttr.GetTextBoxAttr().GetWidth().GetValue() <= 0)
{
- m_attr.m_width = image->GetImageCache().GetWidth();
- wxASSERT(m_attr.m_unitsW == wxRICHTEXT_PX);
-
- m_attr.m_unitsW = wxRICHTEXT_PX;
+ m_textAttr.GetTextBoxAttr().GetWidth().SetValue(image->GetImageCache().GetWidth());
+ m_textAttr.GetTextBoxAttr().GetWidth().SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
}
- if (m_attr.m_height == -1)
+ if (!m_textAttr.GetTextBoxAttr().GetHeight().IsPresent() || m_textAttr.GetTextBoxAttr().GetHeight().GetValue() <= 0)
{
- m_attr.m_height = image->GetImageCache().GetHeight();
- wxASSERT(m_attr.m_unitsH == wxRICHTEXT_PX);
-
- m_attr.m_unitsH = wxRICHTEXT_PX;
+ m_textAttr.GetTextBoxAttr().GetHeight().SetValue(image->GetImageCache().GetHeight());
+ m_textAttr.GetTextBoxAttr().GetHeight().SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
}
}
}
-bool wxRichTextImageDialog::TransferDataToWindow()
+void wxRichTextImageDialog::SetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl)
{
- int remain = 100;
-
- m_alignment->SetSelection(m_attr.m_align);
- m_float->SetSelection(m_attr.m_floating);
-
- // Update scale
- m_unitsW->SetSelection(m_attr.m_unitsW);
- m_unitsH->SetSelection(m_attr.m_unitsH);
- m_unitsOffset->SetSelection(m_attr.m_unitsOffset);
-
- // Update metric
- m_width->Clear();
- if (m_attr.m_unitsW == wxRICHTEXT_MM)
+ int unitsIdx = 0;
+
+ if (!dim.IsPresent())
{
- int remainder = m_attr.m_width % remain;
- *m_width << m_attr.m_width / remain;
- if (remainder)
- {
- *m_width << '.' << remainder;
- }
- }
- else
- {
- *m_width << m_attr.m_width;
+ dim.SetValue(0);
+ dim.SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
}
- m_height->Clear();
- if (m_attr.m_unitsH == wxRICHTEXT_MM)
+ if (dim.GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM)
{
- int remainder = m_attr.m_height % remain;
- *m_height << m_attr.m_height / remain;
- if (remainder)
- {
- *m_height << '.' << remainder;
- }
+ unitsIdx = 1;
+ float value = float(dim.GetValue()) / 10.0;
+ valueCtrl->SetValue(wxString::Format(wxT("%.2f"), value));
}
else
{
- *m_height << m_attr.m_height;
+ unitsIdx = 0;
+ valueCtrl->SetValue(wxString::Format(wxT("%d"), (int) dim.GetValue()));
}
- m_offset->Clear();
- if (m_attr.m_unitsOffset == wxRICHTEXT_MM)
- {
- int remainder = m_attr.m_offset % remain;
- *m_offset << m_attr.m_offset / remain;
- if (remainder)
- {
- *m_offset << '.' << remainder;
- }
- }
+ unitsCtrl->SetSelection(unitsIdx);
+}
+
+void wxRichTextImageDialog::GetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl)
+{
+ if (unitsCtrl->GetSelection() == 1)
+ dim.SetUnits(wxTEXT_ATTR_UNITS_TENTHS_MM);
else
- {
- *m_offset << m_attr.m_offset;
- }
+ dim.SetUnits(wxTEXT_ATTR_UNITS_PIXELS);
- return true;
+ int value = 0;
+ if (ConvertFromString(valueCtrl->GetValue(), value, dim.GetUnits()))
+ dim.SetValue(value);
}
-bool wxRichTextImageDialog::TransferDataFromWindow()
+bool wxRichTextImageDialog::TransferDataToWindow()
{
- wxString width = m_width->GetValue();
- wxString height = m_height->GetValue();
- wxString offset = m_offset->GetValue();
- int w, h, o;
+ m_float->SetSelection(m_textAttr.GetTextBoxAttr().GetFloatMode());
+
+ SetDimensionValue(m_textAttr.GetTextBoxAttr().GetWidth(), m_width, m_unitsW);
+ SetDimensionValue(m_textAttr.GetTextBoxAttr().GetHeight(), m_height, m_unitsH);
+ SetDimensionValue(m_textAttr.GetTextBoxAttr().GetTop(), m_offset, m_unitsOffset);
- m_attr.m_align = m_alignment->GetSelection();
- m_attr.m_floating = m_float->GetSelection();
+ return true;
+}
- m_attr.m_unitsW = m_unitsW->GetSelection();
- m_attr.m_unitsH = m_unitsH->GetSelection();
- m_attr.m_unitsOffset = m_unitsOffset->GetSelection();
+bool wxRichTextImageDialog::TransferDataFromWindow()
+{
+ m_textAttr.GetTextBoxAttr().SetFloatMode(m_float->GetSelection());
- if (ConvertFromString(width, w, m_attr.m_unitsW))
- m_attr.m_width = w;
- if (ConvertFromString(height, h, m_attr.m_unitsH))
- m_attr.m_height = h;
- if (ConvertFromString(offset, o, m_attr.m_unitsOffset))
- m_attr.m_offset = o;
+ GetDimensionValue(m_textAttr.GetTextBoxAttr().GetWidth(), m_width, m_unitsW);
+ GetDimensionValue(m_textAttr.GetTextBoxAttr().GetHeight(), m_height, m_unitsH);
+ GetDimensionValue(m_textAttr.GetTextBoxAttr().GetTop(), m_offset, m_unitsOffset);
return true;
}
for (unsigned int i = 0; i < string.Len() && remain; i++)
{
- if (!(chars[i] >= '0' && chars[i] <= '9') && !(scale == wxRICHTEXT_MM && chars[i] == '.'))
+ if (!(chars[i] >= '0' && chars[i] <= '9') && !(scale == wxTEXT_ATTR_UNITS_TENTHS_MM && chars[i] == '.'))
return false;
if (chars[i] == '.')
ret = ret * 10 + chars[i] - '0';
}
- while (remain-- > 0 && scale == wxRICHTEXT_MM)
+ while (remain-- > 0 && scale == wxTEXT_ATTR_UNITS_TENTHS_MM)
ret *= 10;
return true;
////@end wxRichTextIndentsSpacingPage content construction
}
-wxTextAttr* wxRichTextIndentsSpacingPage::GetAttributes()
+wxRichTextAttr* wxRichTextIndentsSpacingPage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}
iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
TransferDataFromWindow();
- wxTextAttr attr(*GetAttributes());
+ wxRichTextAttr attr(*GetAttributes());
attr.SetFlags(attr.GetFlags() &
(wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
wxTEXT_ATTR_LINE_SPACING|
font.SetPointSize(9);
m_previewCtrl->SetFont(font);
- wxTextAttr normalParaAttr;
+ wxRichTextAttr normalParaAttr;
normalParaAttr.SetFont(font);
normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
{
wxPanel::TransferDataFromWindow();
- wxTextAttr* attr = GetAttributes();
+ wxRichTextAttr* attr = GetAttributes();
if (m_alignmentLeft->GetValue())
attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
wxPanel::TransferDataToWindow();
- wxTextAttr* attr = GetAttributes();
+ wxRichTextAttr* attr = GetAttributes();
if (attr->HasAlignment())
{
wxRichTextStyleSheet* styleSheet = wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet();
- wxTextAttr attr((const wxTextAttr &)(styleSheet ? def->GetStyle() : def->GetStyleMergedWithBase(styleSheet)));
+ wxRichTextAttr attr((const wxRichTextAttr &)(styleSheet ? def->GetStyle() : def->GetStyleMergedWithBase(styleSheet)));
attr.SetFlags(attr.GetFlags() &
(wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
font.SetPointSize(9);
m_previewCtrl->SetFont(font);
- wxTextAttr normalParaAttr;
+ wxRichTextAttr normalParaAttr;
normalParaAttr.SetFont(font);
normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
int i;
for (i = 0; i < 10; i++)
{
- wxTextAttr levelAttr = * def->GetLevelAttributes(i);
+ wxRichTextAttr levelAttr = * def->GetLevelAttributes(i);
levelAttr.SetBulletNumber(1);
m_previewCtrl->BeginStyle(levelAttr);
m_previewCtrl->WriteText(wxString::Format(wxT("List level %d. "), i+1) + s_para2);
m_currentLevel = m_levelCtrl->GetValue();
- wxTextAttr* attr = GetAttributesForSelection();
+ wxRichTextAttr* attr = GetAttributesForSelection();
if (m_alignmentLeft->GetValue())
attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
wxPanel::TransferDataToWindow();
- wxTextAttr* attr = GetAttributesForSelection();
+ wxRichTextAttr* attr = GetAttributesForSelection();
if (attr->HasAlignment())
{
}
/// Get attributes for selected level
-wxTextAttr* wxRichTextListStylePage::GetAttributesForSelection()
+wxRichTextAttr* wxRichTextListStylePage::GetAttributesForSelection()
{
wxRichTextListStyleDefinition* def = wxDynamicCast(wxRichTextFormattingDialog::GetDialogStyleDefinition(this),
wxRichTextListStyleDefinition);
void wxRichTextListStylePage::OnChooseFontClick( wxCommandEvent& WXUNUSED(event) )
{
- wxTextAttr* attr = GetAttributesForSelection();
+ wxRichTextAttr* attr = GetAttributesForSelection();
int pages = wxRICHTEXT_FORMAT_FONT;
wxRichTextFormattingDialog formatDlg;
if (labelCtrl)
labelCtrl->SetLabel(def->GetName() + wxT(":"));
- wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
+ wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
wxFont font(m_previewCtrl->GetFont());
font.SetPointSize(9);
m_previewCtrl->SetFont(font);
- wxTextAttr normalParaAttr;
+ wxRichTextAttr normalParaAttr;
normalParaAttr.SetFont(font);
normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
int i;
for (i = 0; i < 10; i++)
{
- wxTextAttr levelAttr = * listDef->GetLevelAttributes(i);
+ wxRichTextAttr levelAttr = * listDef->GetLevelAttributes(i);
levelAttr.SetBulletNumber(1);
m_previewCtrl->BeginStyle(levelAttr);
m_previewCtrl->WriteText(wxString::Format(wxT("List level %d. "), i+1) + s_para2List);
return true;
}
-wxTextAttr* wxRichTextStylePage::GetAttributes()
+wxRichTextAttr* wxRichTextStylePage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}
}
/// Gets the style combined with the base style
-wxTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const
+wxRichTextAttr wxRichTextStyleDefinition::GetStyleMergedWithBase(const wxRichTextStyleSheet* sheet) const
{
if (m_baseStyle.IsEmpty())
return m_style;
}
/// Sets/gets the attributes for the given level
-void wxRichTextListStyleDefinition::SetLevelAttributes(int i, const wxTextAttr& attr)
+void wxRichTextListStyleDefinition::SetLevelAttributes(int i, const wxRichTextAttr& attr)
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
m_levelStyles[i] = attr;
}
-const wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
+const wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
return NULL;
}
-wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
+wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
{
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
wxASSERT( (i >= 0 && i < 10) );
if (i >= 0 && i < 10)
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
attr.SetBulletStyle(bulletStyle);
attr.SetLeftIndent(leftIndent, leftSubIndent);
/// Combine the list style with a paragraph style, using the given indent (from which
/// an appropriate level is found)
-wxTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet)
+wxRichTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent, const wxRichTextAttr& paraStyle, wxRichTextStyleSheet* styleSheet)
{
int listLevel = FindLevelForIndent(indent);
- wxTextAttr attr(*GetLevelAttributes(listLevel));
+ wxRichTextAttr attr(*GetLevelAttributes(listLevel));
int oldLeftIndent = attr.GetLeftIndent();
int oldLeftSubIndent = attr.GetLeftSubIndent();
/// Combine the base and list style, using the given indent (from which
/// an appropriate level is found)
-wxTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet)
+wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTextStyleSheet* styleSheet)
{
int listLevel = FindLevelForIndent(indent);
return GetCombinedStyleForLevel(listLevel, styleSheet);
/// Combine the base and list style, using the given indent (from which
/// an appropriate level is found)
-wxTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel, wxRichTextStyleSheet* styleSheet)
+wxRichTextAttr wxRichTextListStyleDefinition::GetCombinedStyleForLevel(int listLevel, wxRichTextStyleSheet* styleSheet)
{
- wxTextAttr attr(*GetLevelAttributes(listLevel));
+ wxRichTextAttr attr(*GetLevelAttributes(listLevel));
int oldLeftIndent = attr.GetLeftIndent();
int oldLeftSubIndent = attr.GetLeftSubIndent();
bool isCentred = false;
- wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
+ wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
if (attr.HasAlignment() && attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
isCentred = true;
wxString styleName;
- wxTextAttr attr;
+ wxRichTextAttr attr;
ctrl->GetStyle(adjustedCaretPos, attr);
// Take into account current default style just chosen by user
{
wxPanel::TransferDataFromWindow();
- wxTextAttr* attr = GetAttributes();
+ wxRichTextAttr* attr = GetAttributes();
if (m_tabsPresent)
{
{
wxPanel::TransferDataToWindow();
- wxTextAttr* attr = GetAttributes();
+ wxRichTextAttr* attr = GetAttributes();
m_tabListCtrl->Clear();
m_tabEditCtrl->SetValue(wxEmptyString);
}
}
-wxTextAttr* wxRichTextTabsPage::GetAttributes()
+wxRichTextAttr* wxRichTextTabsPage::GetAttributes()
{
return wxRichTextFormattingDialog::GetDialogAttributes(this);
}
{
if (child->GetName() == wxT("style"))
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
GetStyle(attr, child, false);
def->SetStyle(attr);
}
{
if (child->GetName() == wxT("style"))
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
GetStyle(attr, child, false);
def->SetStyle(attr);
}
{
if (child->GetName() == wxT("style"))
{
- wxTextAttr attr;
+ wxRichTextAttr attr;
GetStyle(attr, child, false);
wxString styleLevel = child->GetAttribute(wxT("level"), wxEmptyString);
int i;
for (i = 0; i < 10; i ++)
{
- wxTextAttr* levelAttr = listDef->GetLevelAttributes(i);
+ wxRichTextAttr* levelAttr = listDef->GetLevelAttributes(i);
if (levelAttr)
{
wxString style = CreateStyle(def->GetStyle(), false);
}
/// Create style parameters
-wxString wxRichTextXMLHandler::CreateStyle(const wxTextAttr& attr, bool isPara)
+wxString wxRichTextXMLHandler::CreateStyle(const wxRichTextAttr& attr, bool isPara)
{
wxString str;
if (attr.HasTextColour() && attr.GetTextColour().Ok())
}
/// Get style parameters
-bool wxRichTextXMLHandler::GetStyle(wxTextAttr& attr, wxXmlNode* node, bool isPara)
+bool wxRichTextXMLHandler::GetStyle(wxRichTextAttr& attr, wxXmlNode* node, bool isPara)
{
wxString fontFacename;
int fontSize = 12;