#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
*/
class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet;
class WXDLLIMPEXP_RICHTEXT wxTextAttrEx;
class WXDLLIMPEXP_RICHTEXT wxRichTextListStyleDefinition;
+class WXDLLIMPEXP_RICHTEXT wxRichTextEvent;
+class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer;
+class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer;
/*!
* Flags determining the available space, passed to Layout
// the rect passed to Layout.
#define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10
+/*!
+ * Flags to pass to Draw
+ */
+
+// Ignore paragraph cache optimization, e.g. for printing purposes
+// where one line may be drawn higher (on the next page) compared
+// with the previous line
+#define wxRICHTEXT_DRAW_IGNORE_CACHE 0x01
+
/*!
* Flags returned from hit-testing
*/
// the current indentation will be used
#define wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL 0x20
+// Resets the existing style before applying the new style
+#define wxRICHTEXT_SETSTYLE_RESET 0x40
+
/*!
* Flags for text insertion
*/
#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_TEXT 0x00080000
#define wxTEXT_ATTR_BULLET_NAME 0x00100000
+#define wxTEXT_ATTR_URL 0x00200000
+#define wxTEXT_ATTR_PAGE_BREAK 0x00400000
+#define wxTEXT_ATTR_EFFECTS 0x00800000
+#define wxTEXT_ATTR_OUTLINE_LEVEL 0x01000000
/*!
* Styles for wxTextAttrEx::SetBulletStyle
*/
-#define wxTEXT_ATTR_BULLET_STYLE_NONE 0x0000
-#define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x0001
-#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x0002
-#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x0004
-#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x0008
-#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x0010
-#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x0020
-#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
+#define wxTEXT_ATTR_BULLET_STYLE_NONE 0x00000000
+#define wxTEXT_ATTR_BULLET_STYLE_ARABIC 0x00000001
+#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0x00000002
+#define wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0x00000004
+#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0x00000008
+#define wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0x00000010
+#define wxTEXT_ATTR_BULLET_STYLE_SYMBOL 0x00000020
+#define wxTEXT_ATTR_BULLET_STYLE_BITMAP 0x00000040
+#define wxTEXT_ATTR_BULLET_STYLE_PARENTHESES 0x00000080
+#define wxTEXT_ATTR_BULLET_STYLE_PERIOD 0x00000100
+#define wxTEXT_ATTR_BULLET_STYLE_STANDARD 0x00000200
+#define wxTEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0x00000400
+#define wxTEXT_ATTR_BULLET_STYLE_OUTLINE 0x00000800
+
+#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0x00000000
+#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0x00001000
+#define wxTEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0x00002000
+
+/*!
+ * Styles for wxTextAttrEx::SetTextEffects
+ */
+
+#define wxTEXT_ATTR_EFFECT_NONE 0x00000000
+#define wxTEXT_ATTR_EFFECT_CAPITALS 0x00000001
+#define wxTEXT_ATTR_EFFECT_SMALL_CAPITALS 0x00000002
+#define wxTEXT_ATTR_EFFECT_STRIKETHROUGH 0x00000004
+#define wxTEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH 0x00000008
+#define wxTEXT_ATTR_EFFECT_SHADOW 0x00000010
+#define wxTEXT_ATTR_EFFECT_EMBOSS 0x00000020
+#define wxTEXT_ATTR_EFFECT_OUTLINE 0x00000040
+#define wxTEXT_ATTR_EFFECT_ENGRAVE 0x00000080
+#define wxTEXT_ATTR_EFFECT_SUPERSCRIPT 0x00000100
+#define wxTEXT_ATTR_EFFECT_SUBSCRIPT 0x00000200
/*!
* Line spacing values
#define wxTEXT_ATTR_LINE_SPACING_HALF 15
#define wxTEXT_ATTR_LINE_SPACING_TWICE 20
+/*!
+ * Character and paragraph combined styles
+ */
+
+#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT|wxTEXT_ATTR_EFFECTS|wxTEXT_ATTR_BACKGROUND_COLOUR|wxTEXT_ATTR_TEXT_COLOUR|wxTEXT_ATTR_CHARACTER_STYLE_NAME|wxTEXT_ATTR_URL)
+
+#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_TEXT|wxTEXT_ATTR_BULLET_NAME|\
+ wxTEXT_ATTR_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL)
+
+#define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH)
+
/*!
* wxRichTextRange class declaration
* This stores beginning and end positions for a range of data.
// Initialise this object
void Init();
+ // Copy
+ void Copy(const wxTextAttrEx& attr);
+
// Assignment from a wxTextAttrEx object
void operator= (const wxTextAttrEx& attr);
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 SetBulletText(const wxString& text) { m_bulletText = text; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_TEXT); }
void SetBulletName(const wxString& name) { m_bulletName = name; SetFlags(GetFlags() | wxTEXT_ATTR_BULLET_NAME); }
void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; }
+ void SetURL(const wxString& url) { m_urlTarget = url; SetFlags(GetFlags() | wxTEXT_ATTR_URL); }
+ void SetPageBreak(bool pageBreak = true) { SetFlags(pageBreak ? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK)); }
+ void SetTextEffects(int effects) { m_textEffects = effects; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS); }
+ void SetTextEffectFlags(int effects) { m_textEffectFlags = effects; }
+ void SetOutlineLevel(int level) { m_outlineLevel = level; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL); }
const wxString& GetCharacterStyleName() const { return m_characterStyleName; }
const wxString& GetParagraphStyleName() const { return m_paragraphStyleName; }
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& GetBulletText() const { return m_bulletText; }
const wxString& GetBulletName() const { return m_bulletName; }
const wxString& GetBulletFont() const { return m_bulletFont; }
+ const wxString& GetURL() const { return m_urlTarget; }
+ int GetTextEffects() const { return m_textEffects; }
+ int GetTextEffectFlags() const { return m_textEffectFlags; }
+ int GetOutlineLevel() const { return m_outlineLevel; }
bool HasWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; }
bool HasSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; }
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 HasBulletText() const { return HasFlag(wxTEXT_ATTR_BULLET_TEXT); }
bool HasBulletName() const { return HasFlag(wxTEXT_ATTR_BULLET_NAME); }
+ bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL); }
+ bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK); }
+ bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS); }
+ bool HasTextEffect(int effect) const { return HasFlag(wxTEXT_ATTR_EFFECTS) && ((GetTextEffectFlags() & effect) != 0); }
+ bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); }
// 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_NAME))); }
+ bool IsCharacterStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_CHARACTER)); }
+ bool IsParagraphStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_PARAGRAPH)); }
// returns false if we have any attributes set, true otherwise
bool IsDefault() const
{
- return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() &&
- !HasTabs() && !HasLeftIndent() && !HasRightIndent() &&
- !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() &&
- !HasCharacterStyleName() && !HasParagraphStyleName() && !HasListStyleName() &&
- !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol() && !HasBulletName();
+ return (GetFlags() == 0);
}
// return the attribute having the valid font and colours: it uses the
int m_lineSpacing;
int m_bulletStyle;
int m_bulletNumber;
- wxChar m_bulletSymbol;
+ int m_textEffects;
+ int m_textEffectFlags;
+ int m_outlineLevel;
+ wxString m_bulletText;
wxString m_bulletFont;
wxString m_bulletName;
+ wxString m_urlTarget;
// Character style
wxString m_characterStyleName;
public:
// ctors
wxRichTextAttr(const wxTextAttrEx& attr);
+ wxRichTextAttr(const wxRichTextAttr& attr);
wxRichTextAttr() { Init(); }
wxRichTextAttr(const wxColour& colText,
const wxColour& colBack = wxNullColour,
// Initialise this object.
void Init();
+ // Copy
+ void Copy(const wxRichTextAttr& attr);
+
// Assignment from a wxRichTextAttr object.
void operator= (const wxRichTextAttr& attr);
// Making a wxTextAttrEx object.
operator wxTextAttrEx () const ;
- // Copy to a wxTextAttr
- void CopyTo(wxTextAttrEx& attr) const;
-
// Create font from font attributes.
wxFont CreateFont() const;
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 SetBulletText(const wxString& text) { m_bulletText = text; m_flags |= wxTEXT_ATTR_BULLET_TEXT; }
void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; }
- void SetBulletName(const wxString& name) { m_bulletName = name; }
+ void SetBulletName(const wxString& name) { m_bulletName = name; m_flags |= wxTEXT_ATTR_BULLET_NAME; }
+ void SetURL(const wxString& url) { m_urlTarget = url; m_flags |= wxTEXT_ATTR_URL; }
+ void SetPageBreak(bool pageBreak = true) { SetFlags(pageBreak ? (GetFlags() | wxTEXT_ATTR_PAGE_BREAK) : (GetFlags() & ~wxTEXT_ATTR_PAGE_BREAK)); }
+ void SetTextEffects(int effects) { m_textEffects = effects; SetFlags(GetFlags() | wxTEXT_ATTR_EFFECTS); }
+ void SetTextEffectFlags(int effects) { m_textEffectFlags = effects; }
+ void SetOutlineLevel(int level) { m_outlineLevel = level; SetFlags(GetFlags() | wxTEXT_ATTR_OUTLINE_LEVEL); }
const wxColour& GetTextColour() const { return m_colText; }
const wxColour& GetBackgroundColour() const { return m_colBack; }
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& GetBulletText() const { return m_bulletText; }
const wxString& GetBulletFont() const { return m_bulletFont; }
const wxString& GetBulletName() const { return m_bulletName; }
+ const wxString& GetURL() const { return m_urlTarget; }
+ int GetTextEffects() const { return m_textEffects; }
+ int GetTextEffectFlags() const { return m_textEffectFlags; }
+ int GetOutlineLevel() const { return m_outlineLevel; }
// accessors
bool HasTextColour() const { return m_colText.Ok() && HasFlag(wxTEXT_ATTR_TEXT_COLOUR) ; }
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 HasBulletText() const { return (m_flags & wxTEXT_ATTR_BULLET_TEXT) != 0; }
bool HasBulletName() const { return (m_flags & wxTEXT_ATTR_BULLET_NAME) != 0; }
+ bool HasURL() const { return HasFlag(wxTEXT_ATTR_URL); }
+ bool HasPageBreak() const { return HasFlag(wxTEXT_ATTR_PAGE_BREAK); }
+ bool HasTextEffects() const { return HasFlag(wxTEXT_ATTR_EFFECTS); }
+ bool HasTextEffect(int effect) const { return HasFlag(wxTEXT_ATTR_EFFECTS) && ((GetTextEffectFlags() & effect) != 0); }
+ bool HasOutlineLevel() const { return HasFlag(wxTEXT_ATTR_OUTLINE_LEVEL); }
bool HasFlag(long flag) const { return (m_flags & flag) != 0; }
// 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_NAME))); }
+ bool IsCharacterStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_CHARACTER)); }
+ bool IsParagraphStyle() const { return (0 != (GetFlags() & wxTEXT_ATTR_PARAGRAPH)); }
// returns false if we have any attributes set, true otherwise
bool IsDefault() const
{
- return !HasTextColour() && !HasBackgroundColour() && !HasFont() && !HasAlignment() &&
- !HasTabs() && !HasLeftIndent() && !HasRightIndent() &&
- !HasParagraphSpacingAfter() && !HasParagraphSpacingBefore() && !HasLineSpacing() &&
- !HasCharacterStyleName() && !HasParagraphStyleName() && !HasListStyleName() &&
- !HasBulletNumber() && !HasBulletStyle() && !HasBulletSymbol() && !HasBulletName();
+ return GetFlags() == 0;
}
// return the attribute having the valid font and colours: it uses the
int m_lineSpacing;
int m_bulletStyle;
int m_bulletNumber;
- wxChar m_bulletSymbol;
+ int m_textEffects;
+ int m_textEffectFlags;
+ int m_outlineLevel;
+ wxString m_bulletText;
wxString m_bulletFont;
wxString m_bulletName;
+ wxString m_urlTarget;
// Character styles
wxColour m_colText,
wxString m_listStyleName;
};
-#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|\
- 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)
-
/*!
* wxRichTextObject class declaration
* This is the base for drawable objects.
void SetDescent(int descent) { m_descent = descent; }
int GetDescent() const { return m_descent; }
+ /// Gets the containing buffer
+ wxRichTextBuffer* GetBuffer() const;
+
// Operations
/// Clone the object
void Reference() { m_refCount ++; }
void Dereference();
- /// Convert units in tends of a millimetre to device units
+ /// Convert units in tenths of a millimetre to device units
int ConvertTenthsMMToPixels(wxDC& dc, int units);
+ static int ConvertTenthsMMToPixels(int ppi, int units);
protected:
wxSize m_size;
/// 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);
+ bool CollectStyle(wxTextAttrEx& currentStyle, const wxTextAttrEx& style, long& multipleStyleAttributes, int& multipleTextEffectAttributes);
/// Set list style
virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
/// 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);
+ /// Fills in the attributes for numbering a paragraph after previousParagraph.
+ 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
/// Set basic (overall) style
virtual void SetBasicStyle(const wxTextAttrEx& style) { m_attributes = style; }
- virtual void SetBasicStyle(const wxRichTextAttr& style) { style.CopyTo(m_attributes); }
+ virtual void SetBasicStyle(const wxRichTextAttr& style) { m_attributes = style; }
/// Get basic (overall) style
virtual const wxTextAttrEx& GetBasicStyle() const { return m_attributes; }
// Constructors
wxRichTextParagraph(wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
- wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* style = NULL);
+ wxRichTextParagraph(const wxString& text, wxRichTextObject* parent = NULL, wxTextAttrEx* paraStyle = NULL, wxTextAttrEx* charStyle = NULL);
virtual ~wxRichTextParagraph();
wxRichTextParagraph(const wxRichTextParagraph& obj): wxRichTextBox() { Copy(obj); }
bool Ok() const { return IsOk(); }
bool IsOk() const { return GetData() != NULL; }
+ // Gets the extension for the block's type
+ wxString GetExtension() const;
+
/// Implementation
- /// Allocate and read from stream as a block of memory
+ // Allocate and read from stream as a block of memory
static unsigned char* ReadBlock(wxInputStream& stream, size_t size);
static unsigned char* ReadBlock(const wxString& filename, size_t size);
// Constructors
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, wxTextAttrEx* charStyle = NULL);
+ wxRichTextImage(const wxRichTextImageBlock& imageBlock, wxRichTextObject* parent = NULL, wxTextAttrEx* charStyle = NULL);
wxRichTextImage(const wxRichTextImage& obj): wxRichTextObject() { Copy(obj); }
// Overrideables
void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { m_styleSheet = styleSheet; }
virtual wxRichTextStyleSheet* GetStyleSheet() const { return m_styleSheet; }
+ /// Set style sheet and notify of the change
+ bool SetStyleSheetAndNotify(wxRichTextStyleSheet* sheet);
+
/// Push style sheet to top of stack
bool PushStyleSheet(wxRichTextStyleSheet* styleSheet);
/// Initialisation
void Init();
- /// Clears the buffer and resets the command processor
- virtual void Clear();
-
- /// The same as Clear, and adds an empty paragraph.
- virtual void Reset();
+ /// Clears the buffer, adds an empty paragraph, and clears the command processor.
+ virtual void ResetAndClearCommands();
/// Load a file
virtual bool LoadFile(const wxString& filename, int type = wxRICHTEXT_TYPE_ANY);
/// Save to a stream
virtual bool SaveFile(wxOutputStream& stream, int type = wxRICHTEXT_TYPE_ANY);
+ /// Set the handler flags, controlling loading and saving
+ void SetHandlerFlags(int flags) { m_handlerFlags = flags; }
+
+ /// Get the handler flags, controlling loading and saving
+ int GetHandlerFlags() const { return m_handlerFlags; }
+
/// Convenience function to add a paragraph of text
virtual wxRichTextRange AddParagraph(const wxString& text, wxTextAttrEx* paraStyle = NULL) { Modify(); return wxRichTextParagraphLayoutBox::AddParagraph(text, paraStyle); }
bool EndNumberedBullet() { return EndStyle(); }
/// Begin symbol bullet
- bool BeginSymbolBullet(wxChar symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL);
+ bool BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL);
/// End symbol bullet
bool EndSymbolBullet() { return EndStyle(); }
/// End named character style
bool EndListStyle() { return EndStyle(); }
+ /// Begin URL
+ bool BeginURL(const wxString& url, const wxString& characterStyle = wxEmptyString);
+
+ /// End URL
+ bool EndURL() { return EndStyle(); }
+
+// Event handling
+
+ /// Add an event handler
+ bool AddEventHandler(wxEvtHandler* handler);
+
+ /// Remove an event handler
+ bool RemoveEventHandler(wxEvtHandler* handler, bool deleteHandler = false);
+
+ /// Clear event handlers
+ void ClearEventHandlers();
+
+ /// Send event to event handlers. If sendToAll is true, will send to all event handlers,
+ /// otherwise will stop at the first successful one.
+ bool SendEvent(wxEvent& event, bool sendToAll = true);
+
// Implementation
/// Copy
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);
+ bool DeleteRangeWithUndo(const wxRichTextRange& range, wxRichTextCtrl* ctrl);
/// Mark modified
void Modify(bool modify = true) { m_modified = modify; }
/// Initialise the standard handlers
static void InitStandardHandlers();
+ /// Get renderer
+ static wxRichTextRenderer* GetRenderer() { return sm_renderer; }
+
+ /// Set renderer, deleting old one
+ static void SetRenderer(wxRichTextRenderer* renderer);
+
+ /// Minimum margin between bullet and paragraph in 10ths of a mm
+ static int GetBulletRightMargin() { return sm_bulletRightMargin; }
+ static void SetBulletRightMargin(int margin) { sm_bulletRightMargin = margin; }
+
+ /// Factor to multiply by character height to get a reasonable bullet size
+ static float GetBulletProportion() { return sm_bulletProportion; }
+ static void SetBulletProportion(float prop) { sm_bulletProportion = prop; }
+
+ /// Scale factor for calculating dimensions
+ double GetScale() const { return m_scale; }
+ void SetScale(double scale) { m_scale = scale; }
+
protected:
/// Command processor
/// Style sheet, if any
wxRichTextStyleSheet* m_styleSheet;
+ /// List of event handlers that will be notified of events
+ wxList m_eventHandlers;
+
/// Stack of attributes for convenience functions
wxList m_attributeStack;
+ /// Flags to be passed to handlers
+ int m_handlerFlags;
+
/// File handlers
static wxList sm_handlers;
+
+ /// Renderer
+ static wxRichTextRenderer* sm_renderer;
+
+ /// Minimum margin between bullet and paragraph in 10ths of a mm
+ static int sm_bulletRightMargin;
+
+ /// Factor to multiply by character height to get a reasonable bullet size
+ static float sm_bulletProportion;
+
+ /// Scaling factor in use: needed to calculate correct dimensions when printing
+ double m_scale;
};
/*!
bool Undo();
/// Update the control appearance
- void UpdateAppearance(long caretPosition, bool sendUpdateEvent = false);
+ void UpdateAppearance(long caretPosition, bool sendUpdateEvent = false,
+ wxArrayInt* optimizationLineCharPositions = NULL, wxArrayInt* optimizationLineYPositions = NULL);
/// Replace the buffer paragraphs with the given fragment.
void ApplyParagraphs(const wxRichTextParagraphLayoutBox& fragment);
wxRichTextCommandId m_cmdId;
};
+/*!
+ * Handler flags
+ */
+
+// Include style sheet when loading and saving
+#define wxRICHTEXT_HANDLER_INCLUDE_STYLESHEET 0x0001
+
+// Save images to memory file system in HTML handler
+#define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY 0x0010
+
+// Save images to files in HTML handler
+#define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES 0x0020
+
+// Save images as inline base64 data in HTML handler
+#define wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 0x0040
+
+// Don't write header and footer (or BODY), so we can include the fragment
+// in a larger document
+#define wxRICHTEXT_HANDLER_NO_HEADER_FOOTER 0x0080
+
/*!
* wxRichTextFileHandler
* Base class for file handlers
DECLARE_CLASS(wxRichTextFileHandler)
public:
wxRichTextFileHandler(const wxString& name = wxEmptyString, const wxString& ext = wxEmptyString, int type = 0)
- : m_name(name), m_extension(ext), m_type(type), m_visible(true)
+ : m_name(name), m_extension(ext), m_type(type), m_flags(0), m_visible(true)
{ }
#if wxUSE_STREAMS
void SetType(int type) { m_type = type; }
int GetType() const { return m_type; }
+ /// Flags controlling how loading and saving is done
+ void SetFlags(int flags) { m_flags = flags; }
+ int GetFlags() const { return m_flags; }
+
/// Encoding to use when saving a file. If empty, a suitable encoding is chosen
void SetEncoding(const wxString& encoding) { m_encoding = encoding; }
const wxString& GetEncoding() const { return m_encoding; }
wxString m_encoding;
wxString m_extension;
int m_type;
+ int m_flags;
bool m_visible;
};
* The data object for a wxRichTextBuffer
*/
-class wxRichTextBufferDataObject: public wxDataObjectSimple
+class WXDLLIMPEXP_RICHTEXT wxRichTextBufferDataObject: public wxDataObjectSimple
{
public:
// ctor doesn't copy the pointer, so it shouldn't go away while this object
#endif
+/*!
+ * wxRichTextRenderer isolates common drawing functionality
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer: public wxObject
+{
+public:
+ wxRichTextRenderer() {}
+ virtual ~wxRichTextRenderer() {}
+
+ /// Draw a standard bullet, as specified by the value of GetBulletName
+ virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& 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 wxTextAttrEx& 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 wxTextAttrEx& attr, const wxRect& rect) = 0;
+
+ /// Enumerate the standard bullet names currently supported
+ virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames) = 0;
+};
+
+/*!
+ * wxRichTextStdRenderer: standard renderer
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextStdRenderer: public wxRichTextRenderer
+{
+public:
+ wxRichTextStdRenderer() {}
+
+ /// Draw a standard bullet, as specified by the value of GetBulletName
+ virtual bool DrawStandardBullet(wxRichTextParagraph* paragraph, wxDC& dc, const wxTextAttrEx& 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 wxTextAttrEx& 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 wxTextAttrEx& attr, const wxRect& rect);
+
+ /// Enumerate the standard bullet names currently supported
+ virtual bool EnumerateStandardBulletNames(wxArrayString& bulletNames);
+};
+
/*!
* Utilities
*
}
/// Compare two attribute objects
-bool wxTextAttrEq(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2);
-bool wxTextAttrEq(const wxTextAttr& attr1, const wxRichTextAttr& attr2);
+WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2);
+WXDLLIMPEXP_RICHTEXT bool wxTextAttrEq(const wxTextAttr& attr1, const wxRichTextAttr& attr2);
/// Compare two attribute objects, but take into account the flags
/// specifying attributes of interest.
-bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2, int flags);
-bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxRichTextAttr& attr2, int flags);
+WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxTextAttrEx& attr2, int flags);
+WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const wxRichTextAttr& attr2, int flags);
/// 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, wxRichTextAttr* compareWith = NULL);
+WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxTextAttrEx& style);
+WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxTextAttrEx& style);
+WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
+WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
+
+/// Combine two bitlists
+WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB);
+
+/// Compare two bitlists
+WXDLLIMPEXP_RICHTEXT bool wxRichTextBitlistsEqPartial(int valueA, int valueB, int flags);
+
+/// Split into paragraph and character styles
+WXDLLIMPEXP_RICHTEXT bool wxRichTextSplitParaCharStyles(const wxTextAttrEx& style, wxTextAttrEx& parStyle, wxTextAttrEx& charStyle);
/// Compare tabs
-bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2);
+WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2);
/// Set the font without changing the font attributes
-void wxSetFontPreservingStyles(wxTextAttr& attr, const wxFont& font);
+WXDLLIMPEXP_RICHTEXT void wxSetFontPreservingStyles(wxTextAttr& attr, const wxFont& font);
/// Convert a decimal to Roman numerals
-wxString wxRichTextDecimalToRoman(long n);
-
+WXDLLIMPEXP_RICHTEXT wxString wxRichTextDecimalToRoman(long n);
WXDLLIMPEXP_RICHTEXT void wxRichTextModuleInit();
#endif
// _WX_RICHTEXTBUFFER_H_
+