]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/richtext/richtextbuffer.h
use wxBitmap object as m_buffer and not a pointer to it (replaces patch 1582878)
[wxWidgets.git] / include / wx / richtext / richtextbuffer.h
index 0e90377f236e9e298e56ac3c65ec7afa9b63e969..d299f6be2a9d3a097cf5e0f91b8d8c757d4f069d 100644 (file)
@@ -22,9 +22,9 @@
 
   The top of the hierarchy is the buffer, a kind of wxRichTextParagraphLayoutBox.
   These boxes will allow flexible placement of text boxes on a page, but
 
   The top of the hierarchy is the buffer, a kind of wxRichTextParagraphLayoutBox.
   These boxes will allow flexible placement of text boxes on a page, but
-  for now there will be a single box representing the document,
-  and this box will a wxRichTextParagraphLayoutBox which contains further
-  wxRichTextParagraph objects, each of which can include text and images.
+  for now there is a single box representing the document, and this box is
+  a wxRichTextParagraphLayoutBox which contains further wxRichTextParagraph
+  objects, each of which can include text and images.
 
   Each object maintains a range (start and end position) measured
   from the start of the main parent box.
 
   Each object maintains a range (start and end position) measured
   from the start of the main parent box.
   a position relative to that text box. For now, we will not be dealing with
   embedded objects but it's something to bear in mind for later.
 
   a position relative to that text box. For now, we will not be dealing with
   embedded objects but it's something to bear in mind for later.
 
+  Note that internally, a range (5,5) represents a range of one character.
+  In the public wx[Rich]TextCtrl API, this would be passed to e.g. SetSelection
+  as (5,6). A paragraph with one character might have an internal range of (0, 1)
+  since the end of the paragraph takes up one position.
+
   Layout
   ======
 
   Layout
   ======
 
   in the vertical direction. The implementation of Layout can then
   cache the calculated size and position within the parent.
 
   in the vertical direction. The implementation of Layout can then
   cache the calculated size and position within the parent.
 
-  Note that position and size should be calculated separately, because
-  for example inserting a paragraph may result in the following paragraphs
-  moving down, but not changing in size.
-
-  Need to determine how objects specify their position. Absolute coordinates,
-  or relative to last object? May be hard to determine that. So should probably
-  be in absolute coordinates, in which case we'll need a Move virtual function
-  that allows quick movement of all elements without layout.
-
-  Let's work through a simple example of layout. Say we're laying out
-  a document with the buffer as the top box, with a wxRichTextParagraphLayoutBox
-  inside that that consists of wxRichTextParagraph objects.
-
-  We're in a mode whereby changes of window size change the width of the
-  page (useful for text editors, as opposed to word processors). The
-  window width is 600.
-
-  We pass (600, -1) to the top-level Layout (i.e. restrict size in horizontal
-  direction only). The wxRichTextBuffer box doesn't currently have
-  well-defined layout behaviour so we simply assume it has one child
-  that fills its parent (later we can define sizer-like box layout behaviour).
-  So it passes the same dimensions to the child, which is a wxRichTextParagraphLayoutBox.
-  This then looks at each child in turn (wxRichTextParagraph) and determines
-  the size the paragraph will take up, setting the cached size, and
-  splitting the paragraph into lines.
-
-  When the layout for one paragraph returns, the next paragraph is
-  fed the position of the previous, so it can position itself.
-
-  Each time Layout is called, the cached list of lines for each paragraph
-  is recreated, since it can change for example if the parent object width
-  changes.
-
-  Reporting size
-  ==============
-
-  Each object can report its size for a given range. It's important that
-  it can report a partial size, so that wrapping can be implemented,
-  hit test calculations performed, etc. So GetRangeSize must be implemented
-  for each object.
-
  */
 
 /*!
  */
 
 /*!
 #include "wx/cmdproc.h"
 #include "wx/txtstrm.h"
 
 #include "wx/cmdproc.h"
 #include "wx/txtstrm.h"
 
+#if wxUSE_DATAOBJ
+#include "wx/dataobj.h"
+#endif
+
+// Experimental dynamic styles to avoid user-specific character styles from being
+// overwritten by paragraph styles.
+#define wxRICHTEXT_USE_DYNAMIC_STYLES 1
+
 /*!
  * File types
  */
 /*!
  * File types
  */
@@ -123,10 +95,10 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextCacheObject;
 class WXDLLIMPEXP_RICHTEXT wxRichTextObjectList;
 class WXDLLIMPEXP_RICHTEXT wxRichTextLine;
 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph;
 class WXDLLIMPEXP_RICHTEXT wxRichTextObjectList;
 class WXDLLIMPEXP_RICHTEXT wxRichTextLine;
 class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph;
-class WXDLLIMPEXP_RICHTEXT wxRichTextFragment;
 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler;
 class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet;
 class WXDLLIMPEXP_RICHTEXT wxTextAttrEx;
 class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler;
 class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet;
 class WXDLLIMPEXP_RICHTEXT wxTextAttrEx;
+class WXDLLIMPEXP_RICHTEXT wxRichTextListStyleDefinition;
 
 /*!
  * Flags determining the available space, passed to Layout
 
 /*!
  * Flags determining the available space, passed to Layout
@@ -161,6 +133,44 @@ class WXDLLIMPEXP_RICHTEXT wxTextAttrEx;
 #define wxRICHTEXT_FORMATTED        0x01
 #define wxRICHTEXT_UNFORMATTED      0x02
 
 #define wxRICHTEXT_FORMATTED        0x01
 #define wxRICHTEXT_UNFORMATTED      0x02
 
+/*!
+ * Flags for SetStyle/SetListStyle
+ */
+
+#define wxRICHTEXT_SETSTYLE_NONE            0x00
+
+// Specifies that this operation should be undoable
+#define wxRICHTEXT_SETSTYLE_WITH_UNDO       0x01
+
+// Specifies that the style should not be applied if the
+// combined style at this point is already the style in question.
+#define wxRICHTEXT_SETSTYLE_OPTIMIZE        0x02
+
+// Specifies that the style should only be applied to paragraphs,
+// and not the content. This allows content styling to be
+// preserved independently from that of e.g. a named paragraph style.
+#define wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY 0x04
+
+// Specifies that the style should only be applied to characters,
+// and not the paragraph. This allows content styling to be
+// preserved independently from that of e.g. a named paragraph style.
+#define wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY 0x08
+
+// For SetListStyle only: specifies starting from the given number, otherwise
+// deduces number from existing attributes
+#define wxRICHTEXT_SETSTYLE_RENUMBER        0x10
+
+// For SetListStyle only: specifies the list level for all paragraphs, otherwise
+// the current indentation will be used
+#define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL   0x20
+
+/*!
+ * Flags for text insertion
+ */
+
+#define wxRICHTEXT_INSERT_NONE                              0x00
+#define wxRICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE     0x01
+
 /*!
  * Extra formatting flags not in wxTextAttr
  */
 /*!
  * Extra formatting flags not in wxTextAttr
  */
@@ -170,9 +180,11 @@ class WXDLLIMPEXP_RICHTEXT wxTextAttrEx;
 #define wxTEXT_ATTR_LINE_SPACING            0x00002000
 #define wxTEXT_ATTR_CHARACTER_STYLE_NAME    0x00004000
 #define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME    0x00008000
 #define wxTEXT_ATTR_LINE_SPACING            0x00002000
 #define wxTEXT_ATTR_CHARACTER_STYLE_NAME    0x00004000
 #define wxTEXT_ATTR_PARAGRAPH_STYLE_NAME    0x00008000
-#define wxTEXT_ATTR_BULLET_STYLE            0x00010000
-#define wxTEXT_ATTR_BULLET_NUMBER           0x00020000
-#define wxTEXT_ATTR_BULLET_SYMBOL           0x00040000
+#define wxTEXT_ATTR_LIST_STYLE_NAME         0x00010000
+#define wxTEXT_ATTR_BULLET_STYLE            0x00020000
+#define wxTEXT_ATTR_BULLET_NUMBER           0x00040000
+#define wxTEXT_ATTR_BULLET_SYMBOL           0x00080000
+#define wxTEXT_ATTR_BULLET_NAME             0x00100000
 
 /*!
  * Styles for wxTextAttrEx::SetBulletStyle
 
 /*!
  * Styles for wxTextAttrEx::SetBulletStyle
@@ -188,6 +200,7 @@ class WXDLLIMPEXP_RICHTEXT wxTextAttrEx;
 #define wxTEXT_ATTR_BULLET_STYLE_BITMAP         0x0040
 #define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES    0x0080
 #define wxTEXT_ATTR_BULLET_STYLE_PERIOD         0x0100
 #define wxTEXT_ATTR_BULLET_STYLE_BITMAP         0x0040
 #define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES    0x0080
 #define wxTEXT_ATTR_BULLET_STYLE_PERIOD         0x0100
+#define wxTEXT_ATTR_BULLET_STYLE_STANDARD       0x0200
 
 /*!
  * Line spacing values
 
 /*!
  * Line spacing values
@@ -214,6 +227,7 @@ public:
 
     void operator =(const wxRichTextRange& range) { m_start = range.m_start; m_end = range.m_end; }
     bool operator ==(const wxRichTextRange& range) const { return (m_start == range.m_start && m_end == range.m_end); }
 
     void operator =(const wxRichTextRange& range) { m_start = range.m_start; m_end = range.m_end; }
     bool operator ==(const wxRichTextRange& range) const { return (m_start == range.m_start && m_end == range.m_end); }
+    bool operator !=(const wxRichTextRange& range) const { return (m_start != range.m_start && m_end != range.m_end); }
     wxRichTextRange operator -(const wxRichTextRange& range) const { return wxRichTextRange(m_start - range.m_start, m_end - range.m_end); }
     wxRichTextRange operator +(const wxRichTextRange& range) const { return wxRichTextRange(m_start + range.m_start, m_end + range.m_end); }
 
     wxRichTextRange operator -(const wxRichTextRange& range) const { return wxRichTextRange(m_start - range.m_start, m_end - range.m_end); }
     wxRichTextRange operator +(const wxRichTextRange& range) const { return wxRichTextRange(m_start + range.m_start, m_end + range.m_end); }
 
@@ -246,6 +260,12 @@ public:
     /// Swaps the start and end
     void Swap() { long tmp = m_start; m_start = m_end; m_end = tmp; }
 
     /// Swaps the start and end
     void Swap() { long tmp = m_start; m_start = m_end; m_end = tmp; }
 
+    /// Convert to internal form: (n, n) is the range of a single character.
+    wxRichTextRange ToInternal() const { return wxRichTextRange(m_start, m_end-1); }
+
+    /// Convert from internal to public API form: (n, n+1) is the range of a single character.
+    wxRichTextRange FromInternal() const { return wxRichTextRange(m_start, m_end+1); }
+
 protected:
     long m_start;
     long m_end;
 protected:
     long m_start;
     long m_end;
@@ -266,33 +286,42 @@ public:
     wxTextAttrEx(const wxTextAttr& attr) { Init(); (*this) = attr; }
     wxTextAttrEx() { Init(); }
 
     wxTextAttrEx(const wxTextAttr& attr) { Init(); (*this) = attr; }
     wxTextAttrEx() { Init(); }
 
-    // Initialise this object.
+    // Initialise this object
     void Init();
 
     // Assignment from a wxTextAttrEx object
     void operator= (const wxTextAttrEx& attr);
 
     void Init();
 
     // Assignment from a wxTextAttrEx object
     void operator= (const wxTextAttrEx& attr);
 
-    // Assignment from a wxTextAttr object.
+    // Assignment from a wxTextAttr object
     void operator= (const wxTextAttr& attr);
 
     void operator= (const wxTextAttr& attr);
 
+    // Equality test
+    bool operator== (const wxTextAttrEx& attr) const;
+
     // setters
     void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_CHARACTER_STYLE_NAME); }
     void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_PARAGRAPH_STYLE_NAME); }
     // setters
     void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_CHARACTER_STYLE_NAME); }
     void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_PARAGRAPH_STYLE_NAME); }
+    void SetListStyleName(const wxString& name) { m_listStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_STYLE_NAME); }
     void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_AFTER); }
     void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_BEFORE); }
     void SetLineSpacing(int spacing) { m_lineSpacing = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_LINE_SPACING); }
     void SetBulletStyle(int style) { m_bulletStyle = style; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_STYLE); }
     void SetBulletNumber(int n) { m_bulletNumber = n; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NUMBER); }
     void SetBulletSymbol(wxChar symbol) { m_bulletSymbol = symbol; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_SYMBOL); }
     void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_AFTER); }
     void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_PARA_SPACING_BEFORE); }
     void SetLineSpacing(int spacing) { m_lineSpacing = spacing; SetFlags(GetFlags() | wxTEXT_ATTR_LINE_SPACING); }
     void SetBulletStyle(int style) { m_bulletStyle = style; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_STYLE); }
     void SetBulletNumber(int n) { m_bulletNumber = n; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NUMBER); }
     void SetBulletSymbol(wxChar symbol) { m_bulletSymbol = symbol; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_SYMBOL); }
+    void SetBulletName(const wxString& name) { m_bulletName = name; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NAME); }
+    void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; }
 
     const wxString& GetCharacterStyleName() const { return m_characterStyleName; }
     const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; }
 
     const wxString& GetCharacterStyleName() const { return m_characterStyleName; }
     const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; }
+    const wxString& GetListStyleName() const { return m_listStyleName; }
     int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; }
     int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; }
     int GetLineSpacing() const { return m_lineSpacing; }
     int GetBulletStyle() const { return m_bulletStyle; }
     int GetBulletNumber() const { return m_bulletNumber; }
     wxChar GetBulletSymbol() const { return m_bulletSymbol; }
     int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; }
     int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; }
     int GetLineSpacing() const { return m_lineSpacing; }
     int GetBulletStyle() const { return m_bulletStyle; }
     int GetBulletNumber() const { return m_bulletNumber; }
     wxChar GetBulletSymbol() const { return m_bulletSymbol; }
+    const wxString& GetBulletName() const { return m_bulletName; }
+    const wxString& GetBulletFont() const { return m_bulletFont; }
 
     bool HasWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
     bool HasSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; }
 
     bool HasWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
     bool HasSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; }
@@ -305,15 +334,17 @@ public:
     bool HasLineSpacing() const { return HasFlag(wxTEXT_ATTR_LINE_SPACING); }
     bool HasCharacterStyleName() const { return HasFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME) || !m_characterStyleName.IsEmpty(); }
     bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) || !m_paragraphStyleName.IsEmpty(); }
     bool HasLineSpacing() const { return HasFlag(wxTEXT_ATTR_LINE_SPACING); }
     bool HasCharacterStyleName() const { return HasFlag(wxTEXT_ATTR_CHARACTER_STYLE_NAME) || !m_characterStyleName.IsEmpty(); }
     bool HasParagraphStyleName() const { return HasFlag(wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) || !m_paragraphStyleName.IsEmpty(); }
+    bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME) || !m_listStyleName.IsEmpty(); }
     bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE); }
     bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER); }
     bool HasBulletSymbol() const { return HasFlag(wxTEXT_ATTR_BULLET_SYMBOL); }
     bool HasBulletStyle() const { return HasFlag(wxTEXT_ATTR_BULLET_STYLE); }
     bool HasBulletNumber() const { return HasFlag(wxTEXT_ATTR_BULLET_NUMBER); }
     bool HasBulletSymbol() const { return HasFlag(wxTEXT_ATTR_BULLET_SYMBOL); }
+    bool HasBulletName() const { return HasFlag(wxTEXT_ATTR_BULLET_NAME); }
 
     // Is this a character style?
     bool IsCharacterStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR))); }
     bool IsParagraphStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|
                             wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|
 
     // Is this a character style?
     bool IsCharacterStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR))); }
     bool IsParagraphStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|
                             wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|
-                            wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER))); }
+                            wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_NAME))); }
 
     // returns false if we have any attributes set, true otherwise
     bool IsDefault() const
 
     // returns false if we have any attributes set, true otherwise
     bool IsDefault() const
@@ -321,7 +352,8 @@ public:
         return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() &&
                !HasTabs() && !HasLeftIndent() && !HasRightIndent() &&
                !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() &&
         return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() &&
                !HasTabs() && !HasLeftIndent() && !HasRightIndent() &&
                !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() &&
-               !HasCharacterStyleName() && !HasParagraphStyleName() && !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol();
+               !HasCharacterStyleName() && !HasParagraphStyleName() && !HasListStyleName() &&
+               !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol() && !HasBulletName();
     }
 
     // return the attribute having the valid font and colours: it uses the
     }
 
     // return the attribute having the valid font and colours: it uses the
@@ -339,12 +371,17 @@ private:
     int                 m_bulletStyle;
     int                 m_bulletNumber;
     wxChar              m_bulletSymbol;
     int                 m_bulletStyle;
     int                 m_bulletNumber;
     wxChar              m_bulletSymbol;
+    wxString            m_bulletFont;
+    wxString            m_bulletName;
 
     // Character style
     wxString            m_characterStyleName;
 
     // Paragraph style
     wxString            m_paragraphStyleName;
 
     // Character style
     wxString            m_characterStyleName;
 
     // Paragraph style
     wxString            m_paragraphStyleName;
+
+    // List style
+    wxString            m_listStyleName;
 };
 
 /*!
 };
 
 /*!
@@ -371,6 +408,9 @@ public:
     // Assignment from a wxTextAttrEx object.
     void operator= (const wxTextAttrEx& attr);
 
     // Assignment from a wxTextAttrEx object.
     void operator= (const wxTextAttrEx& attr);
 
+    // Equality test
+    bool operator== (const wxRichTextAttr& attr) const;
+
     // Making a wxTextAttrEx object.
     operator wxTextAttrEx () const ;
 
     // Making a wxTextAttrEx object.
     operator wxTextAttrEx () const ;
 
@@ -401,12 +441,15 @@ public:
 
     void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; m_flags |= wxTEXT_ATTR_CHARACTER_STYLE_NAME; }
     void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; m_flags |= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME; }
 
     void SetCharacterStyleName(const wxString& name) { m_characterStyleName = name; m_flags |= wxTEXT_ATTR_CHARACTER_STYLE_NAME; }
     void SetParagraphStyleName(const wxString& name) { m_paragraphStyleName = name; m_flags |= wxTEXT_ATTR_PARAGRAPH_STYLE_NAME; }
+    void SetListStyleName(const wxString& name) { m_listStyleName = name; SetFlags(GetFlags() | wxTEXT_ATTR_LIST_STYLE_NAME); }
     void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_AFTER; }
     void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_BEFORE; }
     void SetLineSpacing(int spacing) { m_lineSpacing = spacing; m_flags |= wxTEXT_ATTR_LINE_SPACING; }
     void SetBulletStyle(int style) { m_bulletStyle = style; m_flags |= wxTEXT_ATTR_BULLET_STYLE; }
     void SetBulletNumber(int n) { m_bulletNumber = n; m_flags |= wxTEXT_ATTR_BULLET_NUMBER; }
     void SetBulletSymbol(wxChar symbol) { m_bulletSymbol = symbol; m_flags |= wxTEXT_ATTR_BULLET_NUMBER; }
     void SetParagraphSpacingAfter(int spacing) { m_paragraphSpacingAfter = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_AFTER; }
     void SetParagraphSpacingBefore(int spacing) { m_paragraphSpacingBefore = spacing; m_flags |= wxTEXT_ATTR_PARA_SPACING_BEFORE; }
     void SetLineSpacing(int spacing) { m_lineSpacing = spacing; m_flags |= wxTEXT_ATTR_LINE_SPACING; }
     void SetBulletStyle(int style) { m_bulletStyle = style; m_flags |= wxTEXT_ATTR_BULLET_STYLE; }
     void SetBulletNumber(int n) { m_bulletNumber = n; m_flags |= wxTEXT_ATTR_BULLET_NUMBER; }
     void SetBulletSymbol(wxChar symbol) { m_bulletSymbol = symbol; m_flags |= wxTEXT_ATTR_BULLET_NUMBER; }
+    void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; }
+    void SetBulletName(const wxString& name) { m_bulletName = name; }
 
     const wxColour& GetTextColour() const { return m_colText; }
     const wxColour& GetBackgroundColour() const { return m_colBack; }
 
     const wxColour& GetTextColour() const { return m_colText; }
     const wxColour& GetBackgroundColour() const { return m_colBack; }
@@ -425,12 +468,15 @@ public:
 
     const wxString& GetCharacterStyleName() const { return m_characterStyleName; }
     const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; }
 
     const wxString& GetCharacterStyleName() const { return m_characterStyleName; }
     const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; }
+    const wxString& GetListStyleName() const { return m_listStyleName; }
     int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; }
     int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; }
     int GetLineSpacing() const { return m_lineSpacing; }
     int GetBulletStyle() const { return m_bulletStyle; }
     int GetBulletNumber() const { return m_bulletNumber; }
     wxChar GetBulletSymbol() const { return m_bulletSymbol; }
     int GetParagraphSpacingAfter() const { return m_paragraphSpacingAfter; }
     int GetParagraphSpacingBefore() const { return m_paragraphSpacingBefore; }
     int GetLineSpacing() const { return m_lineSpacing; }
     int GetBulletStyle() const { return m_bulletStyle; }
     int GetBulletNumber() const { return m_bulletNumber; }
     wxChar GetBulletSymbol() const { return m_bulletSymbol; }
+    const wxString& GetBulletFont() const { return m_bulletFont; }
+    const wxString& GetBulletName() const { return m_bulletName; }
 
     // accessors
     bool HasTextColour() const { return m_colText.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; }
 
     // accessors
     bool HasTextColour() const { return m_colText.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; }
@@ -451,9 +497,11 @@ public:
     bool HasLineSpacing() const { return (m_flags & wxTEXT_ATTR_LINE_SPACING) != 0; }
     bool HasCharacterStyleName() const { return (m_flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) != 0 || !m_characterStyleName.IsEmpty(); }
     bool HasParagraphStyleName() const { return (m_flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) != 0 || !m_paragraphStyleName.IsEmpty(); }
     bool HasLineSpacing() const { return (m_flags & wxTEXT_ATTR_LINE_SPACING) != 0; }
     bool HasCharacterStyleName() const { return (m_flags & wxTEXT_ATTR_CHARACTER_STYLE_NAME) != 0 || !m_characterStyleName.IsEmpty(); }
     bool HasParagraphStyleName() const { return (m_flags & wxTEXT_ATTR_PARAGRAPH_STYLE_NAME) != 0 || !m_paragraphStyleName.IsEmpty(); }
+    bool HasListStyleName() const { return HasFlag(wxTEXT_ATTR_LIST_STYLE_NAME) || !m_listStyleName.IsEmpty(); }
     bool HasBulletStyle() const { return (m_flags & wxTEXT_ATTR_BULLET_STYLE) != 0; }
     bool HasBulletNumber() const { return (m_flags & wxTEXT_ATTR_BULLET_NUMBER) != 0; }
     bool HasBulletSymbol() const { return (m_flags & wxTEXT_ATTR_BULLET_SYMBOL) != 0; }
     bool HasBulletStyle() const { return (m_flags & wxTEXT_ATTR_BULLET_STYLE) != 0; }
     bool HasBulletNumber() const { return (m_flags & wxTEXT_ATTR_BULLET_NUMBER) != 0; }
     bool HasBulletSymbol() const { return (m_flags & wxTEXT_ATTR_BULLET_SYMBOL) != 0; }
+    bool HasBulletName() const { return (m_flags & wxTEXT_ATTR_BULLET_NAME) != 0; }
 
     bool HasFlag(long flag) const { return (m_flags & flag) != 0; }
 
 
     bool HasFlag(long flag) const { return (m_flags & flag) != 0; }
 
@@ -461,7 +509,7 @@ public:
     bool IsCharacterStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR))); }
     bool IsParagraphStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|
                             wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|
     bool IsCharacterStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR))); }
     bool IsParagraphStyle() const { return (0 != (GetFlags() & (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|
                             wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|
-                            wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER))); }
+                            wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_NAME))); }
 
     // returns false if we have any attributes set, true otherwise
     bool IsDefault() const
 
     // returns false if we have any attributes set, true otherwise
     bool IsDefault() const
@@ -469,7 +517,8 @@ public:
         return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() &&
                !HasTabs() && !HasLeftIndent() && !HasRightIndent() &&
                !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() &&
         return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() &&
                !HasTabs() && !HasLeftIndent() && !HasRightIndent() &&
                !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() &&
-               !HasCharacterStyleName() && !HasParagraphStyleName() && !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol();
+               !HasCharacterStyleName() && !HasParagraphStyleName() && !HasListStyleName() &&
+               !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol() && !HasBulletName();
     }
 
     // return the attribute having the valid font and colours: it uses the
     }
 
     // return the attribute having the valid font and colours: it uses the
@@ -496,6 +545,8 @@ private:
     int                 m_bulletStyle;
     int                 m_bulletNumber;
     wxChar              m_bulletSymbol;
     int                 m_bulletStyle;
     int                 m_bulletNumber;
     wxChar              m_bulletSymbol;
+    wxString            m_bulletFont;
+    wxString            m_bulletName;
 
     // Character styles
     wxColour            m_colText,
 
     // Character styles
     wxColour            m_colText,
@@ -511,13 +562,17 @@ private:
 
     // Paragraph style
     wxString            m_paragraphStyleName;
 
     // Paragraph style
     wxString            m_paragraphStyleName;
+
+    // List style
+    wxString            m_listStyleName;
 };
 
 };
 
-#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR)
+#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR | wxTEXT_ATTR_CHARACTER_STYLE_NAME)
 
 #define wxTEXT_ATTR_PARAGRAPH (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\
     wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\
 
 #define wxTEXT_ATTR_PARAGRAPH (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\
     wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|wxTEXT_ATTR_LINE_SPACING|\
-    wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_SYMBOL)
+    wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_SYMBOL|wxTEXT_ATTR_BULLET_NAME|\
+    wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME)
 
 #define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
 
 
 #define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
 
@@ -736,6 +791,9 @@ public:
     /// Copy
     void Copy(const wxRichTextCompositeObject& obj);
 
     /// Copy
     void Copy(const wxRichTextCompositeObject& obj);
 
+    /// Assignment
+    void operator= (const wxRichTextCompositeObject& obj) { Copy(obj); }
+
     /// Append a child, returning the position
     size_t AppendChild(wxRichTextObject* child) ;
 
     /// Append a child, returning the position
     size_t AppendChild(wxRichTextObject* child) ;
 
@@ -806,7 +864,7 @@ public:
 // Constructors
 
     wxRichTextParagraphLayoutBox(wxRichTextObject* parent = NULL);
 // Constructors
 
     wxRichTextParagraphLayoutBox(wxRichTextObject* parent = NULL);
-    wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox& obj):wxRichTextBox() { Init(); Copy(obj); }
+    wxRichTextParagraphLayoutBox(const wxRichTextParagraphLayoutBox& obj): wxRichTextBox() { Init(); Copy(obj); }
 
 // Overrideables
 
 
 // Overrideables
 
@@ -834,6 +892,14 @@ public:
     /// Get the associated control.
     wxRichTextCtrl* GetRichTextCtrl() const { return m_ctrl; }
 
     /// Get the associated control.
     wxRichTextCtrl* GetRichTextCtrl() const { return m_ctrl; }
 
+    /// Get/set whether the last paragraph is partial or complete
+    void SetPartialParagraph(bool partialPara) { m_partialParagraph = partialPara; }
+    bool GetPartialParagraph() const { return m_partialParagraph; }
+
+    /// If this is a buffer, returns the current style sheet. The base layout box
+    /// class doesn't have an associated style sheet.
+    virtual wxRichTextStyleSheet* GetStyleSheet() const { return NULL; }
+
 // Operations
 
     /// Initialize the object.
 // Operations
 
     /// Initialize the object.
@@ -846,13 +912,13 @@ public:
     virtual void Reset();
 
     /// Convenience function to add a paragraph of text
     virtual void Reset();
 
     /// Convenience function to add a paragraph of text
-    virtual wxRichTextRange AddParagraph(const wxString& text);
+    virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttrEx* paraStyle = NULL);
 
     /// Convenience function to add an image
 
     /// Convenience function to add an image
-    virtual wxRichTextRange AddImage(const wxImage& image);
+    virtual wxRichTextRange AddImage(const wxImage& image, wxTextAttrEx* paraStyle = NULL);
 
     /// Adds multiple paragraphs, based on newlines.
 
     /// Adds multiple paragraphs, based on newlines.
-    virtual wxRichTextRange AddParagraphs(const wxString& text);
+    virtual wxRichTextRange AddParagraphs(const wxString& text, wxTextAttrEx* 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.
 
     /// Get the line at the given position. If caretPosition is true, the position is
     /// a caret position, which is normally a smaller number.
@@ -906,12 +972,49 @@ public:
     virtual bool PositionToXY(long pos, long* x, long* y) const;
 
     /// Set text attributes: character and/or paragraph styles.
     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 wxRichTextAttr& style, bool withUndo = true);
-    virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttrEx& style, bool withUndo = true);
+    virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+    virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttrEx& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+
+    /// Get the conbined text attributes for this position.
+    virtual bool GetStyle(long position, wxTextAttrEx& style);
+    virtual bool GetStyle(long position, wxRichTextAttr& style);
+
+    /// Get the content (uncombined) attributes for this position.
+    virtual bool GetUncombinedStyle(long position, wxTextAttrEx& 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, wxTextAttrEx& 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, wxTextAttrEx& style);
 
 
-    /// Get the text attributes for this position.
-    virtual bool GetStyle(long position, wxTextAttrEx& style) const;
-    virtual bool GetStyle(long position, wxRichTextAttr& style) const;
+    /// Combines 'style' with 'currentStyle' for the purpose of summarising the attributes of a range of
+    /// content.
+    bool CollectStyle(wxTextAttrEx& currentStyle, const wxTextAttrEx& style, long& multipleStyleAttributes);
+
+    /// Set list style
+    virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+    virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+
+    /// Clear list for given range
+    virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+
+    /// Number/renumber any list elements in the given range.
+    /// def/defName can be NULL/empty to indicate that the existing list style should be used.
+    virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+    virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+
+    /// Promote the list items within the given range. promoteBy can be a positive or negative number, e.g. 1 or -1
+    /// def/defName can be NULL/empty to indicate that the existing list style should be used.
+    virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
+    virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
+
+    /// Helper for NumberList and PromoteList, that does renumbering and promotion simultaneously
+    /// def/defName can be NULL/empty to indicate that the existing list style should be used.
+    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);
 
     /// 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
 
     /// 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
@@ -933,14 +1036,20 @@ public:
     /// Insert fragment into this box at the given position. If partialParagraph is true,
     /// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
     /// marker.
     /// Insert fragment into this box at the given position. If partialParagraph is true,
     /// it is assumed that the last (or only) paragraph is just a piece of data with no paragraph
     /// marker.
-    virtual bool InsertFragment(long position, wxRichTextFragment& fragment);
+    virtual bool InsertFragment(long position, wxRichTextParagraphLayoutBox& fragment);
 
     /// Make a copy of the fragment corresponding to the given range, putting it in 'fragment'.
 
     /// Make a copy of the fragment corresponding to the given range, putting it in 'fragment'.
-    virtual bool CopyFragment(const wxRichTextRange& range, wxRichTextFragment& fragment);
+    virtual bool CopyFragment(const wxRichTextRange& range, wxRichTextParagraphLayoutBox& fragment);
+
+    /// Apply the style sheet to the buffer, for example if the styles have changed.
+    virtual bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet);
 
     /// Copy
     void Copy(const wxRichTextParagraphLayoutBox& obj);
 
 
     /// Copy
     void Copy(const wxRichTextParagraphLayoutBox& obj);
 
+    /// Assignment
+    void operator= (const wxRichTextParagraphLayoutBox& obj) { Copy(obj); }
+
     /// Calculate ranges
     virtual void UpdateRanges() { long end; CalculateRange(0, end); }
 
     /// Calculate ranges
     virtual void UpdateRanges() { long end; CalculateRange(0, end); }
 
@@ -972,47 +1081,10 @@ protected:
     wxTextAttrEx    m_defaultAttributes;
 
     /// The invalidated range that will need full layout
     wxTextAttrEx    m_defaultAttributes;
 
     /// The invalidated range that will need full layout
-    wxRichTextRange         m_invalidRange;
-};
-
-/*!
- * wxRichTextFragment class declaration
- * This is a lind of paragraph layout box used for storing
- * paragraphs for Undo/Redo, for example.
- */
-
-class WXDLLIMPEXP_RICHTEXT wxRichTextFragment: public wxRichTextParagraphLayoutBox
-{
-    DECLARE_DYNAMIC_CLASS(wxRichTextFragment)
-public:
-// Constructors
-
-    wxRichTextFragment() { Init(); }
-    wxRichTextFragment(const wxRichTextFragment& obj):wxRichTextParagraphLayoutBox() { Init(); Copy(obj); }
-
-// Accessors
-
-    /// Get/set whether the last paragraph is partial or complete
-    void SetPartialParagraph(bool partialPara) { m_partialParagraph = partialPara; }
-    bool GetPartialParagraph() const { return m_partialParagraph; }
-
-// Overrideables
-
-// Operations
-
-    /// Initialise
-    void Init();
-
-    /// Copy
-    void Copy(const wxRichTextFragment& obj);
-
-    /// Clone
-    virtual wxRichTextObject* Clone() const { return new wxRichTextFragment(*this); }
-
-protected:
+    wxRichTextRange m_invalidRange;
 
     // Is the last paragraph partial or complete?
 
     // Is the last paragraph partial or complete?
-    bool        m_partialParagraph;
+    bool            m_partialParagraph;
 };
 
 /*!
 };
 
 /*!
@@ -1111,7 +1183,7 @@ public:
     wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
     wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
     virtual ~wxRichTextParagraph();
     wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
     wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
     virtual ~wxRichTextParagraph();
-    wxRichTextParagraph(const wxRichTextParagraph& obj):wxRichTextBox() { Copy(obj); }
+    wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { Copy(obj); }
 
 // Overrideables
 
 
 // Overrideables
 
@@ -1154,7 +1226,7 @@ public:
 // Implementation
 
     /// Apply paragraph styles such as centering to the wrapped lines
 // Implementation
 
     /// Apply paragraph styles such as centering to the wrapped lines
-    virtual void ApplyParagraphStyle(const wxRect& rect);
+    virtual void ApplyParagraphStyle(const wxTextAttrEx& attr, const wxRect& rect);
 
     /// Insert text at the given position
     virtual bool InsertText(long pos, const wxString& text);
 
     /// Insert text at the given position
     virtual bool InsertText(long pos, const wxString& text);
@@ -1189,9 +1261,28 @@ public:
     /// Clear remaining unused line objects, if any
     bool ClearUnusedLines(int lineCount);
 
     /// Clear remaining unused line objects, if any
     bool ClearUnusedLines(int lineCount);
 
+    /// Get combined attributes of the base style, paragraph style and character style. We use this to dynamically
+    /// retrieve the actual style.
+    wxTextAttrEx GetCombinedAttributes(const wxTextAttrEx& contentStyle) const;
+
+    /// Get combined attributes of the base style and paragraph style.
+    wxTextAttrEx GetCombinedAttributes() const;
+
+    /// Create default tabstop array
+    static void InitDefaultTabs();
+
+    /// Clear default tabstop array
+    static void ClearDefaultTabs();
+
+    /// Get default tabstop array
+    static const wxArrayInt& GetDefaultTabs() { return sm_defaultTabs; }
+
 protected:
     /// The lines that make up the wrapped paragraph
     wxRichTextLineList m_cachedLines;
 protected:
     /// The lines that make up the wrapped paragraph
     wxRichTextLineList m_cachedLines;
+
+    /// Default tabstops
+    static wxArrayInt  sm_defaultTabs;
 };
 
 /*!
 };
 
 /*!
@@ -1206,7 +1297,7 @@ public:
 // Constructors
 
     wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
 // Constructors
 
     wxRichTextPlainText(const wxString& text = wxEmptyString, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
-    wxRichTextPlainText(const wxRichTextPlainText& obj):wxRichTextObject() { Copy(obj); }
+    wxRichTextPlainText(const wxRichTextPlainText& obj): wxRichTextObject() { Copy(obj); }
 
 // Overrideables
 
 
 // Overrideables
 
@@ -1262,7 +1353,7 @@ public:
     /// Clone
     virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); }
 private:
     /// Clone
     virtual wxRichTextObject* Clone() const { return new wxRichTextPlainText(*this); }
 private:
-    bool DrawTabbedString(wxDC& dc,const wxRect& rect,wxString& str, wxCoord& x, wxCoord& y, bool selected);
+    bool DrawTabbedString(wxDC& dc, const wxTextAttrEx& attr, const wxRect& rect, wxString& str, wxCoord& x, wxCoord& y, bool selected);
 
 protected:
     wxString    m_text;
 
 protected:
     wxString    m_text;
@@ -1324,7 +1415,8 @@ public:
     void SetDataSize(size_t size) { m_dataSize = size; }
     void SetImageType(int imageType) { m_imageType = imageType; }
 
     void SetDataSize(size_t size) { m_dataSize = size; }
     void SetImageType(int imageType) { m_imageType = imageType; }
 
-    bool Ok() const { return GetData() != NULL; }
+    bool Ok() const { return IsOk(); }
+    bool IsOk() const { return GetData() != NULL; }
 
 /// Implementation
 
 
 /// Implementation
 
@@ -1358,10 +1450,10 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextImage: public wxRichTextObject
 public:
 // Constructors
 
 public:
 // Constructors
 
-    wxRichTextImage(wxRichTextObject* parent = NULL):wxRichTextObject(parent) { }
+    wxRichTextImage(wxRichTextObject* parent = NULL): wxRichTextObject(parent) { }
     wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL);
     wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL);
     wxRichTextImage(const wxImage& image, wxRichTextObject* parent = NULL);
     wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL);
-    wxRichTextImage(const wxRichTextImage& obj):wxRichTextObject() { Copy(obj); }
+    wxRichTextImage(const wxRichTextImage& obj): wxRichTextObject() { Copy(obj); }
 
 // Overrideables
 
 
 // Overrideables
 
@@ -1426,7 +1518,7 @@ public:
 // Constructors
 
     wxRichTextBuffer() { Init(); }
 // Constructors
 
     wxRichTextBuffer() { Init(); }
-    wxRichTextBuffer(const wxRichTextBuffer& obj):wxRichTextParagraphLayoutBox() { Init(); Copy(obj); }
+    wxRichTextBuffer(const wxRichTextBuffer& obj): wxRichTextParagraphLayoutBox() { Init(); Copy(obj); }
     virtual ~wxRichTextBuffer() ;
 
 // Accessors
     virtual ~wxRichTextBuffer() ;
 
 // Accessors
@@ -1436,7 +1528,13 @@ public:
 
     /// Set style sheet, if any.
     void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { m_styleSheet = styleSheet; }
 
     /// Set style sheet, if any.
     void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { m_styleSheet = styleSheet; }
-    wxRichTextStyleSheet* GetStyleSheet() const { return m_styleSheet; }
+    virtual wxRichTextStyleSheet* GetStyleSheet() const { return m_styleSheet; }
+
+    /// Push style sheet to top of stack
+    bool PushStyleSheet(wxRichTextStyleSheet* styleSheet);
+
+    /// Pop style sheet from top of stack
+    wxRichTextStyleSheet* PopStyleSheet();
 
 // Operations
 
 
 // Operations
 
@@ -1462,7 +1560,7 @@ public:
     virtual bool SaveFile(wxOutputStream& stream, int type = wxRICHTEXT_TYPE_ANY);
 
     /// Convenience function to add a paragraph of text
     virtual bool SaveFile(wxOutputStream& stream, int type = wxRICHTEXT_TYPE_ANY);
 
     /// Convenience function to add a paragraph of text
-    virtual wxRichTextRange AddParagraph(const wxString& text) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text); }
+    virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttrEx* 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
 
     /// Begin collapsing undo/redo commands. Note that this may not work properly
     /// if combining commands that delete or insert content, changing ranges for
@@ -1595,6 +1693,12 @@ public:
     /// End symbol bullet
     bool EndSymbolBullet() { return EndStyle(); }
 
     /// End symbol bullet
     bool EndSymbolBullet() { return EndStyle(); }
 
+    /// Begin standard bullet
+    bool BeginStandardBullet(const wxString& bulletName, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_STANDARD);
+
+    /// End standard bullet
+    bool EndStandardBullet() { return EndStyle(); }
+
     /// Begin named character style
     bool BeginCharacterStyle(const wxString& characterStyle);
 
     /// Begin named character style
     bool BeginCharacterStyle(const wxString& characterStyle);
 
@@ -1607,22 +1711,31 @@ public:
     /// End named character style
     bool EndParagraphStyle() { return EndStyle(); }
 
     /// End named character style
     bool EndParagraphStyle() { return EndStyle(); }
 
+    /// Begin named list style
+    bool BeginListStyle(const wxString& listStyle, int level = 1, int number = 1);
+
+    /// End named character style
+    bool EndListStyle() { return EndStyle(); }
+
 // Implementation
 
     /// Copy
 // Implementation
 
     /// Copy
-    void Copy(const wxRichTextBuffer& obj) { wxRichTextBox::Copy(obj); }
+    void Copy(const wxRichTextBuffer& obj);
 
     /// Clone
     virtual wxRichTextObject* Clone() const { return new wxRichTextBuffer(*this); }
 
 
     /// Clone
     virtual wxRichTextObject* Clone() const { return new wxRichTextBuffer(*this); }
 
+    /// Submit command to insert paragraphs
+    bool InsertParagraphsWithUndo(long pos, const wxRichTextParagraphLayoutBox& paragraphs, wxRichTextCtrl* ctrl, int flags = 0);
+
     /// Submit command to insert the given text
     /// Submit command to insert the given text
-    bool InsertTextWithUndo(long pos, const wxString& text, wxRichTextCtrl* ctrl);
+    bool InsertTextWithUndo(long pos, const wxString& text, wxRichTextCtrl* ctrl, int flags = 0);
 
     /// Submit command to insert a newline
 
     /// Submit command to insert a newline
-    bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl);
+    bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int flags = 0);
 
     /// Submit command to insert the given image
 
     /// Submit command to insert the given image
-    bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl);
+    bool InsertImageWithUndo(long pos, const wxRichTextImageBlock& imageBlock, wxRichTextCtrl* ctrl, int flags = 0);
 
     /// Submit command to delete this range
     bool DeleteRangeWithUndo(const wxRichTextRange& range, long initialCaretPosition, long newCaretPositon, wxRichTextCtrl* ctrl);
 
     /// Submit command to delete this range
     bool DeleteRangeWithUndo(const wxRichTextRange& range, long initialCaretPosition, long newCaretPositon, wxRichTextCtrl* ctrl);
@@ -1631,6 +1744,11 @@ public:
     void Modify(bool modify = true) { m_modified = modify; }
     bool IsModified() const { return m_modified; }
 
     void Modify(bool modify = true) { m_modified = modify; }
     bool IsModified() const { return m_modified; }
 
+    /// 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.
+    wxRichTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false) const;
+
     /// Dumps contents of buffer for debugging purposes
     virtual void Dump();
     virtual void Dump(wxTextOutputStream& stream) { wxRichTextParagraphLayoutBox::Dump(stream); }
     /// Dumps contents of buffer for debugging purposes
     virtual void Dump();
     virtual void Dump(wxTextOutputStream& stream) { wxRichTextParagraphLayoutBox::Dump(stream); }
@@ -1763,11 +1881,11 @@ public:
     void UpdateAppearance(long caretPosition, bool sendUpdateEvent = false);
 
     /// Replace the buffer paragraphs with the given fragment.
     void UpdateAppearance(long caretPosition, bool sendUpdateEvent = false);
 
     /// Replace the buffer paragraphs with the given fragment.
-    void ApplyParagraphs(const wxRichTextFragment& fragment);
+    void ApplyParagraphs(const wxRichTextParagraphLayoutBox& fragment);
 
     /// Get the fragments
 
     /// Get the fragments
-    wxRichTextFragment& GetNewParagraphs() { return m_newParagraphs; }
-    wxRichTextFragment& GetOldParagraphs() { return m_oldParagraphs; }
+    wxRichTextParagraphLayoutBox& GetNewParagraphs() { return m_newParagraphs; }
+    wxRichTextParagraphLayoutBox& GetOldParagraphs() { return m_oldParagraphs; }
 
     /// Set/get the position used for e.g. insertion
     void SetPosition(long pos) { m_position = pos; }
 
     /// Set/get the position used for e.g. insertion
     void SetPosition(long pos) { m_position = pos; }
@@ -1791,10 +1909,10 @@ protected:
     wxRichTextCtrl*                 m_ctrl;
 
     // Stores the new paragraphs
     wxRichTextCtrl*                 m_ctrl;
 
     // Stores the new paragraphs
-    wxRichTextFragment              m_newParagraphs;
+    wxRichTextParagraphLayoutBox    m_newParagraphs;
 
     // Stores the old paragraphs
 
     // Stores the old paragraphs
-    wxRichTextFragment              m_oldParagraphs;
+    wxRichTextParagraphLayoutBox    m_oldParagraphs;
 
     // The affected range
     wxRichTextRange                 m_range;
 
     // The affected range
     wxRichTextRange                 m_range;
@@ -1903,6 +2021,48 @@ protected:
 
 };
 
 
 };
 
+#if wxUSE_DATAOBJ
+
+/*!
+ * The data object for a wxRichTextBuffer
+ */
+
+class wxRichTextBufferDataObject: public wxDataObjectSimple
+{
+public:
+    // ctor doesn't copy the pointer, so it shouldn't go away while this object
+    // is alive
+    wxRichTextBufferDataObject(wxRichTextBuffer* richTextBuffer = (wxRichTextBuffer*) NULL);
+    virtual ~wxRichTextBufferDataObject();
+
+    // after a call to this function, the buffer is owned by the caller and it
+    // is responsible for deleting it
+    wxRichTextBuffer* GetRichTextBuffer();
+
+    // Returns the id for the new data format
+    static const wxChar* GetRichTextBufferFormatId() { return ms_richTextBufferFormatId; }
+
+    // base class pure virtuals
+
+    virtual wxDataFormat GetPreferredFormat(Direction dir) const;
+    virtual size_t GetDataSize() const;
+    virtual bool GetDataHere(void *pBuf) const;
+    virtual bool SetData(size_t len, const void *buf);
+
+    // prevent warnings
+
+    virtual size_t GetDataSize(const wxDataFormat&) const { return GetDataSize(); }
+    virtual bool GetDataHere(const wxDataFormat&, void *buf) const { return GetDataHere(buf); }
+    virtual bool SetData(const wxDataFormat&, size_t len, const void *buf) { return SetData(len, buf); }
+
+private:
+    wxDataFormat            m_formatRichTextBuffer;     // our custom format
+    wxRichTextBuffer*       m_richTextBuffer;           // our data
+    static const wxChar*    ms_richTextBufferFormatId;  // our format id
+};
+
+#endif
+
 /*!
  * Utilities
  *
 /*!
  * Utilities
  *
@@ -1925,7 +2085,19 @@ bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxRichTextAttr& attr2,
 /// Apply one style to another
 bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxTextAttrEx& style);
 bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxTextAttrEx& style);
 /// Apply one style to another
 bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxTextAttrEx& style);
 bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxTextAttrEx& style);
-bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style);
+bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
+
+/// Compare tabs
+bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2);
+
+/// Set the font without changing the font attributes
+void wxSetFontPreservingStyles(wxTextAttr& attr, const wxFont& font);
+
+/// Convert a decimal to Roman numerals
+wxString wxRichTextDecimalToRoman(long n);
+
+
+WXDLLIMPEXP_RICHTEXT void wxRichTextModuleInit();
 
 #endif
     // wxUSE_RICHTEXT
 
 #endif
     // wxUSE_RICHTEXT