]> git.saurik.com Git - wxWidgets.git/commitdiff
wxRTC no longer derives from wxTextCtrlBase; added wxRichTextAttr deriving from wxTex...
authorJulian Smart <julian@anthemion.co.uk>
Mon, 4 Oct 2010 08:37:31 +0000 (08:37 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Mon, 4 Oct 2010 08:37:31 +0000 (08:37 +0000)
with CSS-like attributes for future developments; removed image-specific attributes object

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65756 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

31 files changed:
include/wx/richtext/richtextbuffer.h
include/wx/richtext/richtextbulletspage.h
include/wx/richtext/richtextctrl.h
include/wx/richtext/richtextfontpage.h
include/wx/richtext/richtextformatdlg.h
include/wx/richtext/richtexthtml.h
include/wx/richtext/richtextimagedlg.h
include/wx/richtext/richtextindentspage.h
include/wx/richtext/richtextliststylepage.h
include/wx/richtext/richtextstylepage.h
include/wx/richtext/richtextstyles.h
include/wx/richtext/richtexttabspage.h
include/wx/richtext/richtextxml.h
include/wx/textctrl.h
samples/richtext/richtext.cpp
src/common/textcmn.cpp
src/richtext/richtextbuffer.cpp
src/richtext/richtextbulletspage.cpp
src/richtext/richtextctrl.cpp
src/richtext/richtextdialogs.pjd
src/richtext/richtextfontpage.cpp
src/richtext/richtextformatdlg.cpp
src/richtext/richtexthtml.cpp
src/richtext/richtextimagedlg.cpp
src/richtext/richtextindentspage.cpp
src/richtext/richtextliststylepage.cpp
src/richtext/richtextstyledlg.cpp
src/richtext/richtextstylepage.cpp
src/richtext/richtextstyles.cpp
src/richtext/richtexttabspage.cpp
src/richtext/richtextxml.cpp

index 9e8d84db2b6014ea50d1cb2bade8f9032cc9ffa9..199adf6f37ef455b18c068f5749ed509feba039b 100644 (file)
@@ -71,7 +71,7 @@
 #endif
 
 // Compatibility
-#define wxRichTextAttr wxTextAttr
+//#define wxRichTextAttr wxTextAttr
 #define wxTextAttrEx wxTextAttr
 
 // Setting wxRICHTEXT_USE_OWN_CARET to 1 implements a
@@ -235,67 +235,471 @@ enum wxRichTextHitTestFlags
 
 #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;
 };
 
 /*!
@@ -313,7 +717,7 @@ public:
 
     bool IsOk() const { return m_refData != NULL; }
 
-    wxFont FindFont(const wxTextAttr& fontSpec);
+    wxFont FindFont(const wxRichTextAttr& fontSpec);
     void Clear();
 
     void operator= (const wxRichTextFontTable& table);
@@ -453,7 +857,7 @@ public:
     // 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; }
@@ -514,9 +918,9 @@ public:
     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; }
@@ -542,6 +946,10 @@ public:
     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;
@@ -560,7 +968,7 @@ protected:
     int                     m_bottomMargin;
 
     /// Attributes
-    wxTextAttr          m_attributes;
+    wxRichTextAttr          m_attributes;
 };
 
 WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_RICHTEXT );
@@ -758,13 +1166,13 @@ public:
     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.
@@ -818,28 +1226,28 @@ public:
     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);
@@ -863,19 +1271,19 @@ public:
     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); }
@@ -905,16 +1313,16 @@ public:
 
     /// 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);
@@ -932,7 +1340,7 @@ public:
 
 protected:
     wxRichTextCtrl* m_ctrl;
-    wxTextAttr  m_defaultAttributes;
+    wxRichTextAttr  m_defaultAttributes;
 
     /// The invalidated range that will need full layout
     wxRichTextRange m_invalidRange;
@@ -1046,8 +1454,8 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph: public wxRichTextBox
 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); }
 
@@ -1092,7 +1500,7 @@ public:
 // 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);
@@ -1129,10 +1537,10 @@ public:
 
     /// 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);
@@ -1170,7 +1578,7 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextPlainText: public wxRichTextObject
 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
@@ -1230,7 +1638,7 @@ public:
     /// 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;
@@ -1334,7 +1742,7 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextAnchoredObject: public wxRichTextObject
     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();
 
@@ -1342,16 +1750,14 @@ public:
     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 ="); }
 
@@ -1359,7 +1765,7 @@ public:
     void Copy(const wxRichTextAnchoredObject& obj);
 
 protected:
-    wxRichTextAnchoredObjectAttr m_anchoredAttr;
+
 };
 
 /*!
@@ -1374,8 +1780,8 @@ public:
 // 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
@@ -1498,7 +1904,7 @@ public:
     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
@@ -1539,7 +1945,7 @@ public:
     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();
@@ -1694,7 +2100,8 @@ public:
     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);
@@ -1709,7 +2116,7 @@ public:
     /// 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();
@@ -2113,13 +2520,13 @@ public:
     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;
@@ -2135,13 +2542,13 @@ public:
     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);
@@ -2158,18 +2565,18 @@ inline bool wxRichTextHasStyle(int flags, int style)
 }
 
 /// 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);
@@ -2178,7 +2585,7 @@ WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int
 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);
@@ -2186,6 +2593,10 @@ WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArra
 /// 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
index 36b4cc6eb67b83e5a45d1363df34eadf770a858d..beafe36a975168d6256f72e444dbef28b7de7593 100644 (file)
@@ -69,7 +69,7 @@ public:
     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 );
index abf7f449a979c0231f07ad40f8dd4c79d51ce092..bb34cdc9b7021c289a806ff7f5989bee49aa3b9d 100644 (file)
@@ -86,7 +86,8 @@ class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleDefinition;
  * wxRichTextCtrl class declaration
  */
 
-class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxTextCtrlBase,
+class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl : public wxControl,
+                                            public wxTextCtrlIface,
                                             public wxScrollHelper
 {
     DECLARE_CLASS( wxRichTextCtrl )
@@ -200,6 +201,9 @@ public:
     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); }
 
@@ -223,27 +227,32 @@ public:
     // 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);
@@ -316,17 +325,21 @@ public:
 
     /// 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();
@@ -335,12 +348,12 @@ public:
     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(); }
@@ -561,7 +574,7 @@ public:
     /// 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);
     }
@@ -570,7 +583,7 @@ public:
     /// 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);
     }
@@ -791,7 +804,7 @@ public:
 
     /// 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());
index 9027348fd0039652b1d16bdf1e1c157854d74895..b43f5f2caf427ce843473341621588aa1bb7c98f 100644 (file)
@@ -75,7 +75,7 @@ public:
     void OnColourClicked( wxCommandEvent& event );
 
     /// Gets the attributes associated with the main formatting dialog
-    wxTextAttr* GetAttributes();
+    wxRichTextAttr* GetAttributes();
 
 ////@begin wxRichTextFontPage event handler declarations
 
index 5a69bf5683619a8596ac94007c05561ca4ac21bb..ea3a34af24473ca56eb6f2ba36cc85ce7ed9551c 100644 (file)
@@ -138,7 +138,7 @@ public:
     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);
@@ -156,9 +156,9 @@ public:
     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();
@@ -183,7 +183,7 @@ public:
     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);
@@ -200,7 +200,7 @@ public:
 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
index 86cb17af6943a7a1d38772f5cf13229c043f12e7..d939489ac6cbd60f7d8833d2155d3451fd8b8d5d 100644 (file)
@@ -80,15 +80,15 @@ protected:
     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);
@@ -106,13 +106,13 @@ protected:
     const wxChar* GetMimeType(int imageType);
 
     /// Gets the html equivalent of the specified value
-    wxString GetAlignment(const wxTextAttr& thisStyle);
+    wxString GetAlignment(const wxRichTextAttr& thisStyle);
 
     /// Generates &nbsp; 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
index 968694eef896f28c861735c0ffe91459c7950623..10b0ddc1236d2b6445a0c473511352bed8dc9710 100644 (file)
@@ -66,6 +66,12 @@ public:
     /// 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
@@ -89,7 +95,7 @@ public:
     static bool ShowToolTips();
 
     /// Set the image attribute
-    void SetImageAttr(const wxRichTextAnchoredObjectAttr& attr);
+    void SetImageAttr(const wxRichTextAttr& textAttr);
     wxRichTextImage* ApplyImageAttr();
 
     /// Set the anchored object
@@ -101,9 +107,9 @@ private:
     /// 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;
@@ -116,7 +122,6 @@ private:
     /// Control identifiers
     enum {
         ID_WXRICHTEXTIMAGEPAGE = 10015,
-        ID_COMBOBOX_ALIGN = 10016,
         ID_RICHTEXTIMAGEDIALOG_FLOATING_MODE = 10017,
         ID_RICHTEXTIMAGEDIALOG_WIDTH = 10018,
         ID_RICHTEXTIMAGEDIALOG_UNITS_W = 10019,
index d70b0a7cacc373613dddeecad46bde8c0026a496..1d77ca7756bdf11218096f39a0582b5128d20d09 100644 (file)
@@ -71,7 +71,7 @@ public:
     void UpdatePreview();
 
     /// Gets the attributes associated with the main formatting dialog
-    wxTextAttr* GetAttributes();
+    wxRichTextAttr* GetAttributes();
 
 ////@begin wxRichTextIndentsSpacingPage event handler declarations
 
index 832b3f2d75c69a7efa7dcac6cac7aae077353cd6..92b7c67e521e579fca4725ca5841dfdf87eb76ec 100644 (file)
@@ -65,7 +65,7 @@ public:
     virtual bool TransferDataToWindow();
 
     /// Get attributes for selected level
-    wxTextAttr* GetAttributesForSelection();
+    wxRichTextAttr* GetAttributesForSelection();
 
     /// Update for symbol-related controls
     void OnSymbolUpdate( wxUpdateUIEvent& event );
index e80b0bbb66562d6b700404891ffb9f81a468efa9..f9478309b4940b5eadc79f2b79d7f902ee7eb63a 100644 (file)
@@ -52,7 +52,7 @@ public:
     virtual bool TransferDataToWindow();
 
     /// Gets the attributes associated with the main formatting dialog
-    wxTextAttr* GetAttributes();
+    wxRichTextAttr* GetAttributes();
 
 ////@begin wxRichTextStylePage event handler declarations
 
index fb5557b6fde6f2fbc97e12acd568a182073d7f45..022f81e33a5a149b1c3f767ad5b2501c3eac9f13 100644 (file)
@@ -94,18 +94,18 @@ public:
     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;
 };
 
 /*!
@@ -206,9 +206,9 @@ public:
     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);
@@ -218,15 +218,15 @@ public:
 
     /// 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; }
@@ -237,7 +237,7 @@ public:
 protected:
 
     /// The styles for each level (up to 10)
-    wxTextAttr m_levelStyles[10];
+    wxRichTextAttr m_levelStyles[10];
 };
 
 /*!
index 6f8a91cb4f1a7b53dc52d3a7b84f5b6a0c3da0a1..162601251f2cc608feabe5a3b0ba8ecb800ee2b6 100644 (file)
@@ -69,7 +69,7 @@ public:
     virtual void SortTabs();
 
     /// Gets the attributes associated with the main formatting dialog
-    wxTextAttr* GetAttributes();
+    wxRichTextAttr* GetAttributes();
 
 ////@begin wxRichTextTabsPage event handler declarations
 
index 493511f802cb1f5ae96ff7f3ffd2dd9621552df3..ca114c748cc1cecb6ccf3e529526509d9d308785 100644 (file)
@@ -45,10 +45,10 @@ public:
     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?
index 8638f13303181ea758c025eefd83f61a2575f99e..eb7c2140ceff0dd7c6113cbddf1c9a3b5656e7ef 100644 (file)
@@ -298,8 +298,8 @@ public:
     // 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);
@@ -411,6 +411,8 @@ public:
     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); }
@@ -422,11 +424,11 @@ public:
         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
     //
index 58367e0b957674eac77c565cd38fa972e2ab068a..ff29361e165ac200824c6dd3bf127be639138e55 100644 (file)
@@ -783,13 +783,14 @@ void MyFrame::WriteInitialText()
     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();
@@ -884,7 +885,7 @@ void MyFrame::WriteInitialText()
     tabs.Add(600);
     tabs.Add(800);
     tabs.Add(1000);
-    wxTextAttrEx attr;
+    wxRichTextAttr attr;
     attr.SetFlags(wxTEXT_ATTR_TABS);
     attr.SetTabs(tabs);
     r.SetDefaultStyle(attr);
@@ -1162,7 +1163,7 @@ void MyFrame::OnFont(wxCommandEvent& WXUNUSED(event))
     wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
     wxFontData fontData;
 
-    wxTextAttrEx attr;
+    wxRichTextAttr attr;
     attr.SetFlags(wxTEXT_ATTR_FONT);
 
     if (m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr))
@@ -1664,5 +1665,21 @@ void MyFrame::OnPreview(wxCommandEvent& WXUNUSED(event))
 
 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();
 }
index fa4d41ffbca30ccf3157da7522dd20d4ad566224..473de1178f8e8f18e756bff5c0fa9bb91ed9261e 100644 (file)
@@ -188,9 +188,11 @@ bool wxTextAttr::operator== (const wxTextAttr& attr) const
             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;
 
index ce200c47e9e544efdbed5ec308e24e9f73e01c7e..af17e754620a24f3f9b3ba47c6a6bc1bc6ce0546 100644 (file)
@@ -221,9 +221,9 @@ int wxRichTextFloatCollector::GetFitPosition(const wxRichTextFloatRectMapArray&
 
 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
     {
@@ -235,21 +235,21 @@ int wxRichTextFloatCollector::GetFitPosition(int direction, int start, int heigh
 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;
@@ -271,7 +271,7 @@ void wxRichTextFloatCollector::CollectFloat(wxRichTextParagraph* para)
         if (floating->IsFloating())
         {
             wxRichTextAnchoredObject* anchor = wxDynamicCast(floating, wxRichTextAnchoredObject);
-            if (anchor && anchor->GetAnchoredAttr().IsAnchored())
+            if (anchor)
             {
                 CollectFloat(para, floating);
             }
@@ -429,34 +429,6 @@ inline void wxCheckSetBrush(wxDC& dc, const wxBrush& brush)
     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.
@@ -533,6 +505,23 @@ int wxRichTextObject::ConvertTenthsMMToPixels(int ppi, int units)
     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)
 {
@@ -1385,14 +1374,14 @@ wxSize wxRichTextParagraphLayoutBox::GetLineSizeAtPosition(long pos, bool caretP
 
 
 /// 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.
@@ -1405,8 +1394,8 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text,
     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);
 
@@ -1419,14 +1408,14 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraph(const wxString& text,
 }
 
 /// 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.
@@ -1439,8 +1428,8 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
     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;
@@ -1495,14 +1484,14 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddParagraphs(const wxString& text
 }
 
 /// 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.
@@ -1515,8 +1504,8 @@ wxRichTextRange wxRichTextParagraphLayoutBox::AddImage(const wxImage& image, wxT
     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);
@@ -1541,7 +1530,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
     wxRichTextParagraph* para = GetParagraphAtPosition(position);
     if (para)
     {
-        wxTextAttrEx originalAttr = para->GetAttributes();
+        wxRichTextAttr originalAttr = para->GetAttributes();
 
         wxRichTextObjectList::compatibility_iterator node = m_children.Find(para);
 
@@ -1616,7 +1605,7 @@ bool wxRichTextParagraphLayoutBox::InsertFragment(long position, wxRichTextParag
             // 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();
 
@@ -1892,7 +1881,7 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range)
             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.
@@ -1924,7 +1913,7 @@ bool wxRichTextParagraphLayoutBox::DeleteRange(const wxRichTextRange& range)
 
                 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,
@@ -2102,7 +2091,7 @@ wxRichTextObject* wxRichTextParagraphLayoutBox::GetLeafObjectAtPosition(long pos
 }
 
 /// 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;
@@ -2120,7 +2109,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const
     bool removeStyle = ((flags & wxRICHTEXT_SETSTYLE_REMOVE) != 0);
 
     // Apply paragraph style first, if any
-    wxTextAttr wholeStyle(style);
+    wxRichTextAttr wholeStyle(style);
 
     if (!removeStyle && wholeStyle.HasParagraphStyleName() && GetStyleSheet())
     {
@@ -2130,7 +2119,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const
     }
 
     // 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())
@@ -2200,7 +2189,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const
                         {
                             // 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
@@ -2279,7 +2268,7 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const
                             {
                                 // 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
@@ -2305,26 +2294,27 @@ bool wxRichTextParagraphLayoutBox::SetStyle(const wxRichTextRange& range, const
     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
@@ -2335,19 +2325,19 @@ void wxRichTextParagraphLayoutBox::SetImageStyle(wxRichTextImage *image, const w
 }
 
 /// 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);
 
@@ -2396,598 +2386,167 @@ static bool wxHasStyle(long flags, long style)
 
 /// 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()
 {
@@ -3242,7 +2801,7 @@ bool wxRichTextParagraphLayoutBox::SetListStyle(const wxRichTextRange& range, wx
                     // 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
@@ -3417,7 +2976,7 @@ bool wxRichTextParagraphLayoutBox::DoNumberList(const wxRichTextRange& range, co
                     }
 
                     // 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.
@@ -3528,7 +3087,7 @@ bool wxRichTextParagraphLayoutBox::PromoteList(int promoteBy, const wxRichTextRa
 
 /// 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;
@@ -3590,14 +3149,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxRichTextParagraph, wxRichTextBox)
 
 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)
@@ -3614,7 +3173,7 @@ wxRichTextParagraph::~wxRichTextParagraph()
 /// 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)
@@ -3624,7 +3183,7 @@ bool wxRichTextParagraph::Draw(wxDC& dc, const wxRichTextRange& range, const wxR
             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)
@@ -3778,7 +3337,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
     wxASSERT(collector);
     LayoutFloat(dc, rect, style, collector);
 
-    wxTextAttr attr = GetCombinedAttributes();
+    wxRichTextAttr attr = GetCombinedAttributes();
 
     // ClearLines();
 
@@ -4104,7 +3663,7 @@ bool wxRichTextParagraph::Layout(wxDC& dc, const wxRect& rect, int style)
 }
 
 /// 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;
@@ -4941,9 +4500,9 @@ bool wxRichTextParagraph::ClearUnusedLines(int lineCount)
 
 /// 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)
     {
@@ -4958,9 +4517,9 @@ wxTextAttr wxRichTextParagraph::GetCombinedAttributes(const wxTextAttr& contentS
 }
 
 /// 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)
     {
@@ -5000,17 +4559,36 @@ void wxRichTextParagraph::LayoutFloat(wxDC& dc, const wxRect& rect, int style, w
             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);
@@ -5097,7 +4675,7 @@ wxRichTextRange wxRichTextLine::GetAbsoluteRange() const
 
 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)
@@ -5117,7 +4695,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR
     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();
 
@@ -5273,7 +4851,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, const wxRichTextRange& range, const wxR
     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);
 
@@ -5424,7 +5002,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
     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
@@ -5793,10 +5371,10 @@ bool wxRichTextBuffer::InsertParagraphsWithUndo(long pos, const wxRichTextParagr
 {
     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);
@@ -5836,8 +5414,8 @@ bool wxRichTextBuffer::InsertTextWithUndo(long pos, const wxString& text, wxRich
 {
     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
@@ -5874,8 +5452,8 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int
 {
     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 */);
@@ -5883,7 +5461,7 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int
             p = & paraAttr;
     }
 
-    wxTextAttr attr(GetDefaultStyle());
+    wxRichTextAttr attr(GetDefaultStyle());
 
     wxRichTextParagraph* newPara = new wxRichTextParagraph(wxEmptyString, this, & attr);
     action->GetNewParagraphs().AppendChild(newPara);
@@ -5917,12 +5495,12 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int
     {
         // 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);
@@ -5943,12 +5521,13 @@ bool wxRichTextBuffer::InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int
 }
 
 /// 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);
@@ -5956,7 +5535,7 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock&
             p = & paraAttr;
     }
 
-    wxTextAttr attr(GetDefaultStyle());
+    wxRichTextAttr attr(GetDefaultStyle());
 
     wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr);
     if (p)
@@ -5964,7 +5543,8 @@ bool wxRichTextBuffer::InsertImageWithUndo(long pos, const wxRichTextImageBlock&
 
     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();
 
@@ -5985,8 +5565,8 @@ bool wxRichTextBuffer::InsertObjectWithUndo(long pos, wxRichTextObject *object,
 {
     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);
@@ -5994,7 +5574,7 @@ bool wxRichTextBuffer::InsertObjectWithUndo(long pos, wxRichTextObject *object,
             p = & paraAttr;
     }
 
-    wxTextAttr attr(GetDefaultStyle());
+    wxRichTextAttr attr(GetDefaultStyle());
 
     wxRichTextParagraph* newPara = new wxRichTextParagraph(this, & attr);
     if (p)
@@ -6018,12 +5598,12 @@ bool wxRichTextBuffer::InsertObjectWithUndo(long pos, wxRichTextObject *object,
 /// 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
@@ -6085,7 +5665,7 @@ wxTextAttr wxRichTextBuffer::GetStyleForNewParagraph(long pos, bool caretPositio
         return attr;
     }
     else
-        return wxTextAttr();
+        return wxRichTextAttr();
 }
 
 /// Submit command to delete this range
@@ -6199,12 +5779,12 @@ bool wxRichTextBuffer::EndSuppressUndo()
 }
 
 /// 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());
@@ -6224,7 +5804,7 @@ bool wxRichTextBuffer::EndStyle()
     }
 
     wxList::compatibility_iterator node = m_attributeStack.GetLast();
-    wxTextAttr* attr = (wxTextAttr*)node->GetData();
+    wxRichTextAttr* attr = (wxRichTextAttr*)node->GetData();
     m_attributeStack.Erase(node);
 
     SetDefaultStyle(*attr);
@@ -6245,14 +5825,14 @@ bool wxRichTextBuffer::EndAllStyles()
 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);
@@ -6261,7 +5841,7 @@ bool wxRichTextBuffer::BeginBold()
 /// Begin using italic
 bool wxRichTextBuffer::BeginItalic()
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFontStyle(wxFONTSTYLE_ITALIC);
 
     return BeginStyle(attr);
@@ -6270,7 +5850,7 @@ bool wxRichTextBuffer::BeginItalic()
 /// Begin using underline
 bool wxRichTextBuffer::BeginUnderline()
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFontUnderlined(true);
 
     return BeginStyle(attr);
@@ -6279,7 +5859,7 @@ bool wxRichTextBuffer::BeginUnderline()
 /// Begin using point size
 bool wxRichTextBuffer::BeginFontSize(int pointSize)
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFontSize(pointSize);
 
     return BeginStyle(attr);
@@ -6288,7 +5868,7 @@ bool wxRichTextBuffer::BeginFontSize(int pointSize)
 /// Begin using this font
 bool wxRichTextBuffer::BeginFont(const wxFont& font)
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFont(font);
 
     return BeginStyle(attr);
@@ -6297,7 +5877,7 @@ bool wxRichTextBuffer::BeginFont(const wxFont& font)
 /// Begin using this colour
 bool wxRichTextBuffer::BeginTextColour(const wxColour& colour)
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFlags(wxTEXT_ATTR_TEXT_COLOUR);
     attr.SetTextColour(colour);
 
@@ -6307,7 +5887,7 @@ bool wxRichTextBuffer::BeginTextColour(const wxColour& colour)
 /// Begin using alignment
 bool wxRichTextBuffer::BeginAlignment(wxTextAttrAlignment alignment)
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFlags(wxTEXT_ATTR_ALIGNMENT);
     attr.SetAlignment(alignment);
 
@@ -6317,7 +5897,7 @@ bool wxRichTextBuffer::BeginAlignment(wxTextAttrAlignment 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);
 
@@ -6327,7 +5907,7 @@ bool wxRichTextBuffer::BeginLeftIndent(int leftIndent, int leftSubIndent)
 /// Begin right indent
 bool wxRichTextBuffer::BeginRightIndent(int rightIndent)
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFlags(wxTEXT_ATTR_RIGHT_INDENT);
     attr.SetRightIndent(rightIndent);
 
@@ -6343,7 +5923,7 @@ bool wxRichTextBuffer::BeginParagraphSpacing(int before, int after)
     if (after != 0)
         flags |= wxTEXT_ATTR_PARA_SPACING_AFTER;
 
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFlags(flags);
     attr.SetParagraphSpacingBefore(before);
     attr.SetParagraphSpacingAfter(after);
@@ -6354,7 +5934,7 @@ bool wxRichTextBuffer::BeginParagraphSpacing(int before, int after)
 /// Begin line spacing
 bool wxRichTextBuffer::BeginLineSpacing(int lineSpacing)
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFlags(wxTEXT_ATTR_LINE_SPACING);
     attr.SetLineSpacing(lineSpacing);
 
@@ -6364,7 +5944,7 @@ bool wxRichTextBuffer::BeginLineSpacing(int 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);
@@ -6376,7 +5956,7 @@ bool wxRichTextBuffer::BeginNumberedBullet(int bulletNumber, int leftIndent, int
 /// 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);
@@ -6388,7 +5968,7 @@ bool wxRichTextBuffer::BeginSymbolBullet(const wxString& symbol, int leftIndent,
 /// 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);
@@ -6405,7 +5985,7 @@ bool wxRichTextBuffer::BeginCharacterStyle(const wxString& characterStyle)
         wxRichTextCharacterStyleDefinition* def = GetStyleSheet()->FindCharacterStyle(characterStyle);
         if (def)
         {
-            wxTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet());
+            wxRichTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet());
             return BeginStyle(attr);
         }
     }
@@ -6420,7 +6000,7 @@ bool wxRichTextBuffer::BeginParagraphStyle(const wxString& paragraphStyle)
         wxRichTextParagraphStyleDefinition* def = GetStyleSheet()->FindParagraphStyle(paragraphStyle);
         if (def)
         {
-            wxTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet());
+            wxRichTextAttr attr = def->GetStyleMergedWithBase(GetStyleSheet());
             return BeginStyle(attr);
         }
     }
@@ -6435,7 +6015,7 @@ bool wxRichTextBuffer::BeginListStyle(const wxString& listStyle, int level, int
         wxRichTextListStyleDefinition* def = GetStyleSheet()->FindListStyle(listStyle);
         if (def)
         {
-            wxTextAttr attr(def->GetCombinedStyleForLevel(level));
+            wxRichTextAttr attr(def->GetCombinedStyleForLevel(level));
 
             attr.SetBulletNumber(number);
 
@@ -6448,7 +6028,7 @@ bool wxRichTextBuffer::BeginListStyle(const wxString& listStyle, int level, int
 /// Begin URL
 bool wxRichTextBuffer::BeginURL(const wxString& url, const wxString& characterStyle)
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
 
     if (!characterStyle.IsEmpty() && GetStyleSheet())
     {
@@ -6619,7 +6199,7 @@ bool wxRichTextBuffer::LoadFile(const wxString& filename, wxRichTextFileType typ
     wxRichTextFileHandler* handler = FindHandlerFilenameOrType(filename, type);
     if (handler)
     {
-        SetDefaultStyle(wxTextAttr());
+        SetDefaultStyle(wxRichTextAttr());
         handler->SetFlags(GetHandlerFlags());
         bool success = handler->LoadFile(this, filename);
         Invalidate(wxRICHTEXT_ALL);
@@ -6648,7 +6228,7 @@ bool wxRichTextBuffer::LoadFile(wxInputStream& stream, wxRichTextFileType type)
     wxRichTextFileHandler* handler = FindHandler(type);
     if (handler)
     {
-        SetDefaultStyle(wxTextAttr());
+        SetDefaultStyle(wxRichTextAttr());
         handler->SetFlags(GetHandlerFlags());
         bool success = handler->LoadFile(this, stream);
         Invalidate(wxRICHTEXT_ALL);
@@ -6918,7 +6498,7 @@ void wxRichTextBuffer::SetRenderer(wxRichTextRenderer* renderer)
     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())
     {
@@ -6993,14 +6573,14 @@ bool wxRichTextStdRenderer::DrawStandardBullet(wxRichTextParagraph* paragraph, w
     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());
@@ -7045,7 +6625,7 @@ bool wxRichTextStdRenderer::DrawTextBullet(wxRichTextParagraph* paragraph, wxDC&
         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.
@@ -7495,91 +7075,27 @@ bool wxRichTextRange::LimitTo(const wxRichTextRange& range)
     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);
 }
@@ -7591,7 +7107,7 @@ void wxRichTextAnchoredObject::SetParent(wxRichTextObject* 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);
@@ -7599,7 +7115,7 @@ wxRichTextImage::wxRichTextImage(const wxImage& image, wxRichTextObject* parent,
         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;
@@ -7622,30 +7138,20 @@ bool wxRichTextImage::LoadImageCache(wxDC& dc, bool resetCache)
 
         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)
@@ -7763,15 +7269,15 @@ bool wxRichTextImage::EditProperties(wxWindow* parent, wxRichTextBuffer* buffer)
  */
 
 /// 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
@@ -7789,33 +7295,33 @@ bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2)
     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
@@ -8382,12 +7888,12 @@ class wxRichTextFontTableData: public wxObjectRefData
 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()));
@@ -8433,7 +7939,7 @@ void wxRichTextFontTable::operator= (const wxRichTextFontTable& table)
     Ref(table);
 }
 
-wxFont wxRichTextFontTable::FindFont(const wxTextAttr& fontSpec)
+wxFont wxRichTextFontTable::FindFont(const wxRichTextAttr& fontSpec)
 {
     wxRichTextFontTableData* data = (wxRichTextFontTableData*) m_refData;
     if (data)
@@ -8449,5 +7955,963 @@ void wxRichTextFontTable::Clear()
         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
index 61cad9f528fb72017ffc387161f39e413aca7e6b..c62e3c3b53545059ccd68f45886484e88e4f0339 100644 (file)
@@ -316,7 +316,7 @@ bool wxRichTextBulletsPage::TransferDataFromWindow()
 {
     wxPanel::TransferDataFromWindow();
 
-    wxTextAttr* attr = GetAttributes();
+    wxRichTextAttr* attr = GetAttributes();
 
     if (m_hasBulletStyle)
     {
@@ -404,7 +404,7 @@ bool wxRichTextBulletsPage::TransferDataToWindow()
 
     wxPanel::TransferDataToWindow();
 
-    wxTextAttr* attr = GetAttributes();
+    wxRichTextAttr* attr = GetAttributes();
 
     if (attr->HasBulletStyle())
     {
@@ -522,7 +522,7 @@ et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id m
 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|
@@ -532,7 +532,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
     font.SetPointSize(9);
     m_previewCtrl->SetFont(font);
 
-    wxTextAttr normalParaAttr;
+    wxRichTextAttr normalParaAttr;
     normalParaAttr.SetFont(font);
     normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
 
@@ -556,7 +556,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
     m_previewCtrl->Thaw();
 }
 
-wxTextAttr* wxRichTextBulletsPage::GetAttributes()
+wxRichTextAttr* wxRichTextBulletsPage::GetAttributes()
 {
     return wxRichTextFormattingDialog::GetDialogAttributes(this);
 }
index 6d834135d1603d5ad7d7f6a337140a8ab230d440..2e3c42366e8abc6842bd34df74a4a0a474043551 100644 (file)
@@ -136,11 +136,11 @@ private:
 };
 #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)
@@ -214,7 +214,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
 {
     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;
@@ -231,7 +231,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
         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);
@@ -243,7 +243,7 @@ bool wxRichTextCtrl::Create( wxWindow* parent, wxWindowID id, const wxString& va
 
     // 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));
@@ -560,7 +560,7 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event)
 
             if (!GetEventHandler()->ProcessEvent(cmdEvent))
             {
-                wxTextAttr attr;
+                wxRichTextAttr attr;
                 if (GetStyle(position, attr))
                 {
                     if (attr.HasFlag(wxTEXT_ATTR_URL))
@@ -608,7 +608,7 @@ void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event)
     {
         if (hit != wxRICHTEXT_HITTEST_NONE && !(hit & wxRICHTEXT_HITTEST_OUTSIDE))
         {
-            wxTextAttr attr;
+            wxRichTextAttr attr;
             if (GetStyle(position, attr))
             {
                 if (attr.HasFlag(wxTEXT_ATTR_URL))
@@ -2397,34 +2397,34 @@ void wxRichTextCtrl::AppendText(const wxString& text)
 }
 
 /// 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())
     {
@@ -2432,7 +2432,7 @@ bool wxRichTextCtrl::WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType,
 
         wxImage image = bitmap.ConvertToImage();
         if (image.Ok() && imageBlock.MakeImageBlock(image, bitmapType))
-            return WriteImage(imageBlock, attr);
+            return WriteImage(imageBlock, textAttr);
     }
 
     return false;
@@ -2878,51 +2878,90 @@ void wxRichTextCtrl::OnContextMenu(wxContextMenuEvent& event)
 
 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);
 }
@@ -2930,9 +2969,9 @@ bool wxRichTextCtrl::GetUncombinedStyle(long position, wxTextAttr& 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);
 
@@ -3096,7 +3135,7 @@ bool wxRichTextCtrl::IsSelectionBold()
 {
     if (HasSelection())
     {
-        wxTextAttr attr;
+        wxRichTextAttr attr;
         wxRichTextRange range = GetSelectionRange();
         attr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT);
         attr.SetFontWeight(wxFONTWEIGHT_BOLD);
@@ -3107,7 +3146,7 @@ bool wxRichTextCtrl::IsSelectionBold()
     {
         // 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());
@@ -3127,7 +3166,7 @@ bool wxRichTextCtrl::IsSelectionItalics()
     if (HasSelection())
     {
         wxRichTextRange range = GetSelectionRange();
-        wxTextAttr attr;
+        wxRichTextAttr attr;
         attr.SetFlags(wxTEXT_ATTR_FONT_ITALIC);
         attr.SetFontStyle(wxFONTSTYLE_ITALIC);
 
@@ -3137,7 +3176,7 @@ bool wxRichTextCtrl::IsSelectionItalics()
     {
         // 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());
@@ -3157,7 +3196,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined()
     if (HasSelection())
     {
         wxRichTextRange range = GetSelectionRange();
-        wxTextAttr attr;
+        wxRichTextAttr attr;
         attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
         attr.SetFontUnderlined(true);
 
@@ -3167,7 +3206,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined()
     {
         // 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());
 
@@ -3184,7 +3223,7 @@ bool wxRichTextCtrl::IsSelectionUnderlined()
 /// 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);
 
@@ -3202,7 +3241,7 @@ bool wxRichTextCtrl::ApplyBoldToSelection()
 /// 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);
 
@@ -3220,7 +3259,7 @@ bool wxRichTextCtrl::ApplyItalicToSelection()
 /// Apply underline to the selection
 bool wxRichTextCtrl::ApplyUnderlineToSelection()
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetFlags(wxTEXT_ATTR_FONT_UNDERLINE);
     attr.SetFontUnderlined(!IsSelectionUnderlined());
 
@@ -3244,7 +3283,7 @@ bool wxRichTextCtrl::IsSelectionAligned(wxTextAttrAlignment alignment)
     else
         range = wxRichTextRange(GetCaretPosition()+1, GetCaretPosition()+2);
 
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetAlignment(alignment);
 
     return HasParagraphAttributes(range, attr);
@@ -3253,7 +3292,7 @@ bool wxRichTextCtrl::IsSelectionAligned(wxTextAttrAlignment alignment)
 /// Apply alignment to the selection
 bool wxRichTextCtrl::ApplyAlignmentToSelection(wxTextAttrAlignment alignment)
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     attr.SetAlignment(alignment);
     if (HasSelection())
         return SetStyle(GetSelectionRange(), attr);
@@ -3271,7 +3310,7 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
 {
     // 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;
 
@@ -3312,8 +3351,8 @@ bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
         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
@@ -3359,7 +3398,7 @@ bool wxRichTextCtrl::ApplyStyleSheet(wxRichTextStyleSheet* styleSheet)
 /// 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.
index 793bbc3a8a0c511c9943e038791db482390c1b40..0811abab63d630dc77f408cb842bee38fee907ab 100644 (file)
                 <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">"&lt;Any platform&gt;"</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">"&lt;Any platform&gt;"</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>
index a832f040e8030e43d48104bc33fe70b9f0b408fc..caf10cad363948fc2ab3837bdf731dd8d25c4fe9 100644 (file)
@@ -304,7 +304,7 @@ bool wxRichTextFontPage::TransferDataFromWindow()
 {
     wxPanel::TransferDataFromWindow();
 
-    wxTextAttr* attr = GetAttributes();
+    wxRichTextAttr* attr = GetAttributes();
 
     if (m_faceListBox->GetSelection() != wxNOT_FOUND)
     {
@@ -429,7 +429,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
     wxPanel::TransferDataToWindow();
 
     m_dontUpdate = true;
-    wxTextAttr* attr = GetAttributes();
+    wxRichTextAttr* attr = GetAttributes();
 
     if (attr->HasFontFaceName())
     {
@@ -564,7 +564,7 @@ bool wxRichTextFontPage::TransferDataToWindow()
     return true;
 }
 
-wxTextAttr* wxRichTextFontPage::GetAttributes()
+wxRichTextAttr* wxRichTextFontPage::GetAttributes()
 {
     return wxRichTextFormattingDialog::GetDialogAttributes(this);
 }
@@ -572,7 +572,7 @@ wxTextAttr* wxRichTextFontPage::GetAttributes()
 /// Updates the font preview
 void wxRichTextFontPage::UpdatePreview()
 {
-    wxTextAttr attr;
+    wxRichTextAttr attr;
 
     if (m_colourPresent)
         m_previewCtrl->SetForegroundColour(m_colourCtrl->GetBackgroundColour());
index 08c20f18d2b6d07967a4b5c92850bdc3aea6b355..6ae76714529e29db29db9b08d43974e7829f18d5 100644 (file)
@@ -130,7 +130,7 @@ bool wxRichTextFormattingDialog::ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTe
 }
 
 /// 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)
@@ -462,7 +462,7 @@ wxRichTextFormattingDialog* wxRichTextFormattingDialog::GetDialog(wxWindow* win)
 
 
 // Helper for pages to get the attributes
-wxTextAttr* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win)
+wxRichTextAttr* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win)
 {
     wxRichTextFormattingDialog* dialog = GetDialog(win);
     if (dialog)
index ec723334ca6ac893f3cc332ad6497d1666120b2c..e720fb449637807a62fbcd0cf65d91b6c814df09 100644 (file)
@@ -101,8 +101,8 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
         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");
@@ -123,7 +123,7 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
 
             if (para)
             {
-                wxTextAttr paraStyle(para->GetCombinedAttributes());
+                wxRichTextAttr paraStyle(para->GetCombinedAttributes());
 
                 BeginParagraphFormatting(currentParaStyle, paraStyle, str);
 
@@ -134,7 +134,7 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
                     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();
@@ -184,7 +184,7 @@ bool wxRichTextHTMLHandler::DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream&
     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;
 
@@ -219,7 +219,7 @@ void wxRichTextHTMLHandler::BeginCharacterFormatting(const wxTextAttr& currentSt
         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>");
@@ -239,7 +239,7 @@ void wxRichTextHTMLHandler::EndCharacterFormatting(const wxTextAttr& WXUNUSED(cu
 }
 
 /// 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())
     {
@@ -367,7 +367,7 @@ void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxTextAttr& WXUNUSED(
 }
 
 /// 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>");
@@ -405,7 +405,7 @@ void wxRichTextHTMLHandler::CloseLists(int level, wxTextOutputStream& str)
 }
 
 /// Output font tag
-void wxRichTextHTMLHandler::OutputFont(const wxTextAttr& style, wxTextOutputStream& stream)
+void wxRichTextHTMLHandler::OutputFont(const wxRichTextAttr& style, wxTextOutputStream& stream)
 {
     if (style.HasFont())
     {
@@ -416,7 +416,7 @@ void wxRichTextHTMLHandler::OutputFont(const wxTextAttr& style, wxTextOutputStre
     }
 }
 
-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.
@@ -444,7 +444,7 @@ int wxRichTextHTMLHandler::TypeOfList( const wxTextAttr& thisStyle, wxString& ta
         return 0;
 }
 
-wxString wxRichTextHTMLHandler::GetAlignment( const wxTextAttr& thisStyle )
+wxString wxRichTextHTMLHandler::GetAlignment( const wxRichTextAttr& thisStyle )
 {
     switch( thisStyle.GetAlignment() )
     {
index 7090ac5c4f4deb04d4e134e11c5c6aa6ab4eb263..4ca4a641be714c61111fc525533240cd83930827 100644 (file)
@@ -111,7 +111,6 @@ wxRichTextImageDialog::~wxRichTextImageDialog()
 void wxRichTextImageDialog::Init()
 {
 ////@begin wxRichTextImageDialog member initialisation
-    m_alignment = NULL;
     m_float = NULL;
     m_width = NULL;
     m_unitsW = NULL;
@@ -147,21 +146,8 @@ void wxRichTextImageDialog::CreateControls()
     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"));
@@ -174,17 +160,17 @@ void wxRichTextImageDialog::CreateControls()
         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"));
@@ -194,19 +180,19 @@ void wxRichTextImageDialog::CreateControls()
     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"));
@@ -216,20 +202,20 @@ void wxRichTextImageDialog::CreateControls()
     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"));
@@ -239,45 +225,45 @@ void wxRichTextImageDialog::CreateControls()
     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
 }
@@ -321,9 +307,10 @@ wxIcon wxRichTextImageDialog::GetIconResource( const wxString& name )
 /*!
  * Set the image attribute
  */
-void wxRichTextImageDialog::SetImageAttr(const wxRichTextAnchoredObjectAttr& attr)
+void wxRichTextImageDialog::SetImageAttr(const wxRichTextAttr& textAttr)
 {
-   m_attr = attr;
+   m_textAttr = textAttr;
+
    TransferDataToWindow();
 }
 
@@ -337,7 +324,7 @@ wxRichTextImage* wxRichTextImageDialog::ApplyImageAttr()
     TransferDataFromWindow();
     if (m_buffer->GetRichTextCtrl())
     {
-        m_buffer->GetRichTextCtrl()->SetImageStyle(image, m_attr);
+        m_buffer->GetRichTextCtrl()->SetImageStyle(image, m_textAttr);
     }
     return image;
 }
@@ -349,107 +336,77 @@ void wxRichTextImageDialog::SetImageObject(wxRichTextImage* image, wxRichTextBuf
     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;
 }
@@ -463,7 +420,7 @@ bool wxRichTextImageDialog::ConvertFromString(const wxString& string, int& ret,
 
     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] == '.')
@@ -478,7 +435,7 @@ bool wxRichTextImageDialog::ConvertFromString(const wxString& string, int& ret,
         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;
index 0d0eea7d8e1a87c487c94f9498cde25a6d5ee024..2605a9885baae4e3076cf51e18baf59bc05319ff 100644 (file)
@@ -340,7 +340,7 @@ void wxRichTextIndentsSpacingPage::CreateControls()
 ////@end wxRichTextIndentsSpacingPage content construction
 }
 
-wxTextAttr* wxRichTextIndentsSpacingPage::GetAttributes()
+wxRichTextAttr* wxRichTextIndentsSpacingPage::GetAttributes()
 {
     return wxRichTextFormattingDialog::GetDialogAttributes(this);
 }
@@ -358,7 +358,7 @@ et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id m
 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|
@@ -368,7 +368,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
     font.SetPointSize(9);
     m_previewCtrl->SetFont(font);
 
-    wxTextAttr normalParaAttr;
+    wxRichTextAttr normalParaAttr;
     normalParaAttr.SetFont(font);
     normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
 
@@ -395,7 +395,7 @@ bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
 {
     wxPanel::TransferDataFromWindow();
 
-    wxTextAttr* attr = GetAttributes();
+    wxRichTextAttr* attr = GetAttributes();
 
     if (m_alignmentLeft->GetValue())
         attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
@@ -466,7 +466,7 @@ bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
 
     wxPanel::TransferDataToWindow();
 
-    wxTextAttr* attr = GetAttributes();
+    wxRichTextAttr* attr = GetAttributes();
 
     if (attr->HasAlignment())
     {
index 374a352025ed64605387e2c4a6d0836764eb829f..ca89d6628acccbbc0e328a074ab04f172cefd3fd 100644 (file)
@@ -528,7 +528,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
 
     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|
@@ -539,7 +539,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
     font.SetPointSize(9);
     m_previewCtrl->SetFont(font);
 
-    wxTextAttr normalParaAttr;
+    wxRichTextAttr normalParaAttr;
     normalParaAttr.SetFont(font);
     normalParaAttr.SetTextColour(wxColour(wxT("LIGHT GREY")));
 
@@ -556,7 +556,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
     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);
@@ -581,7 +581,7 @@ bool wxRichTextListStylePage::TransferDataFromWindow()
 
     m_currentLevel = m_levelCtrl->GetValue();
 
-    wxTextAttr* attr = GetAttributesForSelection();
+    wxRichTextAttr* attr = GetAttributesForSelection();
 
     if (m_alignmentLeft->GetValue())
         attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
@@ -719,7 +719,7 @@ void wxRichTextListStylePage::DoTransferDataToWindow()
 
     wxPanel::TransferDataToWindow();
 
-    wxTextAttr* attr = GetAttributesForSelection();
+    wxRichTextAttr* attr = GetAttributesForSelection();
 
     if (attr->HasAlignment())
     {
@@ -875,7 +875,7 @@ void wxRichTextListStylePage::DoTransferDataToWindow()
 }
 
 /// Get attributes for selected level
-wxTextAttr* wxRichTextListStylePage::GetAttributesForSelection()
+wxRichTextAttr* wxRichTextListStylePage::GetAttributesForSelection()
 {
     wxRichTextListStyleDefinition* def = wxDynamicCast(wxRichTextFormattingDialog::GetDialogStyleDefinition(this),
         wxRichTextListStyleDefinition);
@@ -1280,7 +1280,7 @@ void wxRichTextListStylePage::OnStandardBulletUpdate( wxUpdateUIEvent& event )
 
 void wxRichTextListStylePage::OnChooseFontClick( wxCommandEvent& WXUNUSED(event) )
 {
-    wxTextAttr* attr = GetAttributesForSelection();
+    wxRichTextAttr* attr = GetAttributesForSelection();
 
     int pages = wxRICHTEXT_FORMAT_FONT;
     wxRichTextFormattingDialog formatDlg;
index 5c7c85af920c053907a0ba6ca0e610a7ee39fead..0c663345dca0eb30f4e43d3c0a6cb1ea22465ada 100644 (file)
@@ -430,13 +430,13 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
     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")));
 
@@ -455,7 +455,7 @@ iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
         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);
index c761fa60bf1d9a76fe3761d6652fdd5da12d9198..5dde2fe7ee7cda10640452511ad32ae28aded39e 100644 (file)
@@ -245,7 +245,7 @@ bool wxRichTextStylePage::TransferDataToWindow()
     return true;
 }
 
-wxTextAttr* wxRichTextStylePage::GetAttributes()
+wxRichTextAttr* wxRichTextStylePage::GetAttributes()
 {
     return wxRichTextFormattingDialog::GetDialogAttributes(this);
 }
index 420c8ede5fb55b0fc46866069e3e4025f8725691..649a2a11c30a9fd7c04ac5f45eadfe0e889e2dad 100644 (file)
@@ -54,7 +54,7 @@ bool wxRichTextStyleDefinition::Eq(const wxRichTextStyleDefinition& def) const
 }
 
 /// 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;
@@ -129,14 +129,14 @@ bool wxRichTextListStyleDefinition::operator ==(const wxRichTextListStyleDefinit
 }
 
 /// 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)
@@ -145,7 +145,7 @@ const wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i) const
         return NULL;
 }
 
-wxTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
+wxRichTextAttr* wxRichTextListStyleDefinition::GetLevelAttributes(int i)
 {
     wxASSERT( (i >= 0 && i < 10) );
     if (i >= 0 && i < 10)
@@ -160,7 +160,7 @@ void wxRichTextListStyleDefinition::SetAttributes(int i, int leftIndent, int lef
     wxASSERT( (i >= 0 && i < 10) );
     if (i >= 0 && i < 10)
     {
-        wxTextAttr attr;
+        wxRichTextAttr attr;
 
         attr.SetBulletStyle(bulletStyle);
         attr.SetLeftIndent(leftIndent, leftSubIndent);
@@ -196,11 +196,11 @@ int wxRichTextListStyleDefinition::FindLevelForIndent(int indent) const
 
 /// 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();
 
@@ -221,7 +221,7 @@ wxTextAttr wxRichTextListStyleDefinition::CombineWithParagraphStyle(int indent,
 
 /// 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);
@@ -229,9 +229,9 @@ wxTextAttr wxRichTextListStyleDefinition::GetCombinedStyle(int indent, wxRichTex
 
 /// 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();
 
@@ -616,7 +616,7 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
 
     bool isCentred = false;
 
-    wxTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
+    wxRichTextAttr attr(def->GetStyleMergedWithBase(GetStyleSheet()));
 
     if (attr.HasAlignment() && attr.GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
         isCentred = true;
@@ -800,7 +800,7 @@ wxString wxRichTextStyleListBox::GetStyleToShowInIdleTime(wxRichTextCtrl* ctrl,
 
     wxString styleName;
 
-    wxTextAttr attr;
+    wxRichTextAttr attr;
     ctrl->GetStyle(adjustedCaretPos, attr);
 
     // Take into account current default style just chosen by user
index 2285d3fa93c988d5596eaf79782a6ca9248709a0..78006682dfa7a3e2ffd90b63b30e651ae5c9cd53 100644 (file)
@@ -158,7 +158,7 @@ bool wxRichTextTabsPage::TransferDataFromWindow()
 {
     wxPanel::TransferDataFromWindow();
 
-    wxTextAttr* attr = GetAttributes();
+    wxRichTextAttr* attr = GetAttributes();
 
     if (m_tabsPresent)
     {
@@ -177,7 +177,7 @@ bool wxRichTextTabsPage::TransferDataToWindow()
 {
     wxPanel::TransferDataToWindow();
 
-    wxTextAttr* attr = GetAttributes();
+    wxRichTextAttr* attr = GetAttributes();
 
     m_tabListCtrl->Clear();
     m_tabEditCtrl->SetValue(wxEmptyString);
@@ -225,7 +225,7 @@ void wxRichTextTabsPage::SortTabs()
     }
 }
 
-wxTextAttr* wxRichTextTabsPage::GetAttributes()
+wxRichTextAttr* wxRichTextTabsPage::GetAttributes()
 {
     return wxRichTextFormattingDialog::GetDialogAttributes(this);
 }
index 8a51656f34186a1a6b9c12a76d65f67d757ff8f3..4c1d11568c313eaf82f25b96cd3b6ac72fd8e039 100644 (file)
@@ -284,7 +284,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
         {
             if (child->GetName() == wxT("style"))
             {
-                wxTextAttr attr;
+                wxRichTextAttr attr;
                 GetStyle(attr, child, false);
                 def->SetStyle(attr);
             }
@@ -306,7 +306,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
         {
             if (child->GetName() == wxT("style"))
             {
-                wxTextAttr attr;
+                wxRichTextAttr attr;
                 GetStyle(attr, child, false);
                 def->SetStyle(attr);
             }
@@ -328,7 +328,7 @@ bool wxRichTextXMLHandler::ImportStyleDefinition(wxRichTextStyleSheet* sheet, wx
         {
             if (child->GetName() == wxT("style"))
             {
-                wxTextAttr attr;
+                wxRichTextAttr attr;
                 GetStyle(attr, child, false);
 
                 wxString styleLevel = child->GetAttribute(wxT("level"), wxEmptyString);
@@ -927,7 +927,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon
         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);
@@ -975,7 +975,7 @@ bool wxRichTextXMLHandler::ExportStyleDefinition(wxOutputStream& stream, wxMBCon
 }
 
 /// 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())
@@ -1146,7 +1146,7 @@ bool wxRichTextFixFaceName(wxString& facename)
 }
 
 /// 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;