X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d2d0adc7765dfe904f0f7e97d85a2638c934a7d6..f321ab7fb40525098cea6594ffbf2daf0186b1a3:/include/wx/richtext/richtextbuffer.h diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index a91ea90363..c414e1394f 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -70,9 +70,11 @@ #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 +/*! + * Special characters + */ + +extern WXDLLIMPEXP_RICHTEXT const wxChar wxRichTextLineBreakChar; /*! * File types @@ -101,6 +103,7 @@ 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 @@ -115,6 +118,15 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer; // 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 */ @@ -166,6 +178,9 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer; // 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 */ @@ -188,6 +203,9 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer; #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 @@ -211,6 +229,22 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer; #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 */ @@ -223,12 +257,12 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer; * Character and paragraph combined styles */ -#define wxTEXT_ATTR_CHARACTER (wxTEXT_ATTR_FONT | wxTEXT_ATTR_BACKGROUND_COLOUR | wxTEXT_ATTR_TEXT_COLOUR | wxTEXT_ATTR_CHARACTER_STYLE_NAME | wxTEXT_ATTR_URL) +#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_PARAGRAPH_STYLE_NAME|wxTEXT_ATTR_LIST_STYLE_NAME|wxTEXT_ATTR_OUTLINE_LEVEL) #define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) @@ -336,6 +370,10 @@ public: 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; } @@ -349,24 +387,31 @@ public: 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 HasItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC) != 0; } - bool HasUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } - bool HasFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE) != 0; } + bool HasFontWeight() const { return (GetFlags() & wxTEXT_ATTR_FONT_WEIGHT) != 0; } + bool HasFontSize() const { return (GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0; } + bool HasFontItalic() const { return (GetFlags() & wxTEXT_ATTR_FONT_ITALIC) != 0; } + bool HasFontUnderlined() const { return (GetFlags() & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } + bool HasFontFaceName() const { return (GetFlags() & wxTEXT_ATTR_FONT_FACE) != 0; } bool HasParagraphSpacingAfter() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_AFTER); } bool HasParagraphSpacingBefore() const { return HasFlag(wxTEXT_ATTR_PARA_SPACING_BEFORE); } 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 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 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_CHARACTER)); } @@ -375,11 +420,7 @@ public: // 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() && !HasBulletText() && !HasBulletName() && !HasURL(); + return (GetFlags() == 0); } // return the attribute having the valid font and colours: it uses the @@ -396,6 +437,9 @@ private: int m_lineSpacing; int m_bulletStyle; int m_bulletNumber; + int m_textEffects; + int m_textEffectFlags; + int m_outlineLevel; wxString m_bulletText; wxString m_bulletFont; wxString m_bulletName; @@ -445,9 +489,6 @@ public: // Making a wxTextAttrEx object. operator wxTextAttrEx () const ; - // Copy to a wxTextAttr - void CopyTo(wxTextAttrEx& attr) const; - // Create font from font attributes. wxFont CreateFont() const; @@ -482,6 +523,10 @@ public: void SetBulletFont(const wxString& bulletFont) { m_bulletFont = bulletFont; } 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; } @@ -510,6 +555,9 @@ public: 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) ; } @@ -518,24 +566,28 @@ public: bool HasTabs() const { return (m_flags & wxTEXT_ATTR_TABS) != 0 ; } bool HasLeftIndent() const { return (m_flags & wxTEXT_ATTR_LEFT_INDENT) != 0 ; } bool HasRightIndent() const { return (m_flags & wxTEXT_ATTR_RIGHT_INDENT) != 0 ; } - bool HasWeight() const { return (m_flags & wxTEXT_ATTR_FONT_WEIGHT) != 0; } - bool HasSize() const { return (m_flags & wxTEXT_ATTR_FONT_SIZE) != 0; } - bool HasItalic() const { return (m_flags & wxTEXT_ATTR_FONT_ITALIC) != 0; } - bool HasUnderlined() const { return (m_flags & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } - bool HasFaceName() const { return (m_flags & wxTEXT_ATTR_FONT_FACE) != 0; } + bool HasFontWeight() const { return (m_flags & wxTEXT_ATTR_FONT_WEIGHT) != 0; } + bool HasFontSize() const { return (m_flags & wxTEXT_ATTR_FONT_SIZE) != 0; } + bool HasFontItalic() const { return (m_flags & wxTEXT_ATTR_FONT_ITALIC) != 0; } + bool HasFontUnderlined() const { return (m_flags & wxTEXT_ATTR_FONT_UNDERLINE) != 0; } + bool HasFontFaceName() const { return (m_flags & wxTEXT_ATTR_FONT_FACE) != 0; } bool HasFont() const { return (m_flags & (wxTEXT_ATTR_FONT)) != 0; } bool HasParagraphSpacingAfter() const { return (m_flags & wxTEXT_ATTR_PARA_SPACING_AFTER) != 0; } bool HasParagraphSpacingBefore() const { return (m_flags & wxTEXT_ATTR_PARA_SPACING_BEFORE) != 0; } 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 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 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; } @@ -546,19 +598,19 @@ public: // 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() && !HasBulletText() && !HasBulletName() && !HasURL(); + return GetFlags() == 0; } - // return the attribute having the valid font and colours: it uses the - // attributes set in attr and falls back first to attrDefault and then to - // the text control font/colours for those attributes which are not set - static wxRichTextAttr Combine(const wxRichTextAttr& attr, - const wxRichTextAttr& attrDef, - const wxTextCtrlBase *text); + // Merges the given attributes. Does not affect 'this'. 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); + + // Merges the given attributes and returns the result. Does not affect 'this'. 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. + wxRichTextAttr Combine(const wxRichTextAttr& style, const wxRichTextAttr* compareWith = NULL) const; + private: long m_flags; @@ -576,6 +628,9 @@ private: int m_lineSpacing; int m_bulletStyle; int m_bulletNumber; + int m_textEffects; + int m_textEffectFlags; + int m_outlineLevel; wxString m_bulletText; wxString m_bulletFont; wxString m_bulletName; @@ -714,6 +769,9 @@ public: void SetDescent(int descent) { m_descent = descent; } int GetDescent() const { return m_descent; } + /// Gets the containing buffer + wxRichTextBuffer* GetBuffer() const; + // Operations /// Clone the object @@ -727,8 +785,9 @@ public: void Reference() { m_refCount ++; } void Dereference(); - /// Convert units in tends of a millimetre to device units - static int ConvertTenthsMMToPixels(wxDC& dc, int 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; @@ -1017,7 +1076,7 @@ public: /// 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); @@ -1092,7 +1151,7 @@ public: /// 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; } @@ -1208,7 +1267,7 @@ public: // 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); } @@ -1295,6 +1354,9 @@ public: /// Get combined attributes of the base style and paragraph style. wxTextAttrEx GetCombinedAttributes() const; + /// Get the first position from pos that has a line break character. + long GetFirstLineBreakPosition(long pos); + /// Create default tabstop array static void InitDefaultTabs(); @@ -1364,6 +1426,9 @@ public: /// Dump to output stream for debugging virtual void Dump(wxTextOutputStream& stream); + /// Get the first position from pos that has a line break character. + long GetFirstLineBreakPosition(long pos); + // Accessors /// Get the text @@ -1481,8 +1546,8 @@ public: // 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 @@ -1574,11 +1639,8 @@ public: /// 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); @@ -1798,7 +1860,7 @@ public: 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; } @@ -1807,7 +1869,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. - wxRichTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false) const; + wxRichTextAttr GetStyleForNewParagraph(long pos, bool caretPosition = false, bool lookUpNewParaStyle=false) const; /// Dumps contents of buffer for debugging purposes virtual void Dump(); @@ -1861,6 +1923,11 @@ public: /// 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 @@ -1904,6 +1971,9 @@ protected: /// 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; }; /*! @@ -1966,7 +2036,8 @@ public: 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); @@ -2031,6 +2102,10 @@ protected: // 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 @@ -2041,7 +2116,7 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler: public wxObject 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_flags(0) + : m_name(name), m_extension(ext), m_type(type), m_flags(0), m_visible(true) { } #if wxUSE_STREAMS @@ -2240,6 +2315,16 @@ WXDLLIMPEXP_RICHTEXT bool wxTextAttrEqPartial(const wxTextAttrEx& attr1, const w 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 WXDLLIMPEXP_RICHTEXT bool wxRichTextTabsEq(const wxArrayInt& tabs1, const wxArrayInt& tabs2);