#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
* Forward declarations
*/
-class WXDLLIMPEXP_RICHTEXT wxRichTextCtrl;
-class WXDLLIMPEXP_RICHTEXT wxRichTextObject;
-class WXDLLIMPEXP_RICHTEXT wxRichTextCacheObject;
-class WXDLLIMPEXP_RICHTEXT wxRichTextObjectList;
-class WXDLLIMPEXP_RICHTEXT wxRichTextLine;
-class WXDLLIMPEXP_RICHTEXT wxRichTextParagraph;
-class WXDLLIMPEXP_RICHTEXT wxRichTextFileHandler;
-class WXDLLIMPEXP_RICHTEXT wxRichTextStyleSheet;
-class WXDLLIMPEXP_RICHTEXT wxTextAttrEx;
-class WXDLLIMPEXP_RICHTEXT wxRichTextListStyleDefinition;
-class WXDLLIMPEXP_RICHTEXT wxRichTextEvent;
-class WXDLLIMPEXP_RICHTEXT wxRichTextRenderer;
-class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCtrl;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObject;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCacheObject;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextObjectList;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextLine;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextParagraph;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFileHandler;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextStyleSheet;
+class WXDLLIMPEXP_FWD_RICHTEXT wxTextAttrEx;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextListStyleDefinition;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextEvent;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextRenderer;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextBuffer;
/*!
* Flags determining the available space, passed to Layout
#define wxRICHTEXT_HITTEST_AFTER 0x04
// The point was on the position returned from HitTest
#define wxRICHTEXT_HITTEST_ON 0x08
+// The point was on space outside content
+#define wxRICHTEXT_HITTEST_OUTSIDE 0x10
/*!
* Flags for GetRangeSize
// 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
+
+// Removes the given style instead of applying it
+#define wxRICHTEXT_SETSTYLE_REMOVE 0x80
+
/*!
* Flags for text insertion
*/
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 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; }
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;
/// 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();
/// 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
* wxRichTextImageBlock stores information about an image, in binary in-memory form
*/
-class WXDLLIMPEXP_BASE wxDataInputStream;
-class WXDLLIMPEXP_BASE wxDataOutputStream;
+class WXDLLIMPEXP_FWD_BASE wxDataInputStream;
+class WXDLLIMPEXP_FWD_BASE wxDataOutputStream;
class WXDLLIMPEXP_RICHTEXT wxRichTextImageBlock: public wxObject
{
* This is a kind of box, used to represent the whole buffer
*/
-class WXDLLIMPEXP_RICHTEXT wxRichTextCommand;
-class WXDLLIMPEXP_RICHTEXT wxRichTextAction;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextCommand;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction;
class WXDLLIMPEXP_RICHTEXT wxRichTextBuffer: public wxRichTextParagraphLayoutBox
{
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; }
/// 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();
*
*/
-class WXDLLIMPEXP_RICHTEXT wxRichTextAction;
+class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextAction;
class WXDLLIMPEXP_RICHTEXT wxRichTextCommand: public wxCommand
{
public:
// 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
{ return DoSaveFile(buffer, stream); }
#endif
+#if wxUSE_FFILE && wxUSE_STREAMS
bool LoadFile(wxRichTextBuffer *buffer, const wxString& filename);
bool SaveFile(wxRichTextBuffer *buffer, const wxString& filename);
+#endif // wxUSE_STREAMS && wxUSE_STREAMS
/// Can we handle this filename (if using files)? By default, checks the extension.
virtual bool CanHandle(const wxString& filename) const;
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
WXDLLIMPEXP_RICHTEXT bool wxRichTextApplyStyle(wxRichTextAttr& destStyle, const wxRichTextAttr& style, wxRichTextAttr* compareWith = NULL);
+// Remove attributes
+WXDLLIMPEXP_RICHTEXT bool wxRichTextRemoveStyle(wxTextAttrEx& destStyle, const wxRichTextAttr& style);
+
/// Combine two bitlists
WXDLLIMPEXP_RICHTEXT bool wxRichTextCombineBitlists(int& valueA, int valueB, int& flagsA, int flagsB);