X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/38113684016c5ecbc65985bee3c6c7b318c012cf..696b38f7f5255a9aae92822efafc3de36e3390a5:/include/wx/richtext/richtextbuffer.h?ds=sidebyside diff --git a/include/wx/richtext/richtextbuffer.h b/include/wx/richtext/richtextbuffer.h index 2e6f9f3752..5916a2dfaa 100644 --- a/include/wx/richtext/richtextbuffer.h +++ b/include/wx/richtext/richtextbuffer.h @@ -9,6 +9,9 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +#ifndef _WX_RICHTEXTBUFFER_H_ +#define _WX_RICHTEXTBUFFER_H_ + /* Data structures @@ -84,17 +87,17 @@ */ -#ifndef _WX_RICHTEXTBUFFER_H_ -#define _WX_RICHTEXTBUFFER_H_ - /*! * Includes */ -#include "wx/list.h" +#include "wx/defs.h" #if wxUSE_RICHTEXT +#include "wx/list.h" +#include "wx/textctrl.h" +#include "wx/bitmap.h" #include "wx/image.h" #include "wx/cmdproc.h" #include "wx/txtstrm.h" @@ -134,6 +137,10 @@ class WXDLLIMPEXP_ADV wxTextAttrEx; #define wxRICHTEXT_VARIABLE_WIDTH 0x04 #define wxRICHTEXT_VARIABLE_HEIGHT 0x08 +// Only lay out the part of the buffer that lies within +// the rect passed to Layout. +#define wxRICHTEXT_LAYOUT_SPECIFIED_RECT 0x10 + /*! * Flags returned from hit-testing */ @@ -244,6 +251,9 @@ protected: long m_end; }; +#define wxRICHTEXT_ALL wxRichTextRange(-2, -2) +#define wxRICHTEXT_NONE wxRichTextRange(-1, -1) + /*! * wxTextAttrEx is an extended version of wxTextAttr with more paragraph attributes. */ @@ -482,13 +492,13 @@ private: wxString m_paragraphStyleName; }; -#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) -#define wxTEXT_ATTR_PARAGRAPH wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_TABS|\ +#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) -#define wxTEXT_ATTR_ALL wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH +#define wxTEXT_ATTR_ALL (wxTEXT_ATTR_CHARACTER|wxTEXT_ATTR_PARAGRAPH) /*! * wxRichTextObject class declaration @@ -641,7 +651,7 @@ protected: wxTextAttrEx m_attributes; }; -WX_DECLARE_EXPORTED_LIST( wxRichTextObject, wxRichTextObjectList ); +WX_DECLARE_LIST_WITH_DECL( wxRichTextObject, wxRichTextObjectList, class WXDLLIMPEXP_ADV ); /*! * wxRichTextCompositeObject class declaration @@ -931,7 +941,7 @@ public: virtual const wxTextAttrEx& GetBasicStyle() const { return m_attributes; } /// Invalidate the buffer. With no argument, invalidates whole buffer. - void Invalidate(const wxRichTextRange& invalidRange = wxRichTextRange(-1, -1)); + void Invalidate(const wxRichTextRange& invalidRange = wxRICHTEXT_ALL); /// Get invalid range, rounding to entire paragraphs if argument is true. wxRichTextRange GetInvalidRange(bool wholeParagraphs = false) const; @@ -997,7 +1007,7 @@ public: // Constructors wxRichTextLine(wxRichTextParagraph* parent); - wxRichTextLine(const wxRichTextLine& obj) { Init(); Copy(obj); } + wxRichTextLine(const wxRichTextLine& obj) { Init( NULL); Copy(obj); } virtual ~wxRichTextLine() {} // Overrideables @@ -1015,6 +1025,9 @@ public: const wxRichTextRange& GetRange() const { return m_range; } wxRichTextRange& GetRange() { return m_range; } + /// Get the absolute range + wxRichTextRange GetAbsoluteRange() const; + /// Get/set the line size as calculated by Layout. virtual wxSize GetSize() const { return m_size; } virtual void SetSize(const wxSize& sz) { m_size = sz; } @@ -1036,7 +1049,7 @@ public: // Operations /// Initialisation - void Init(); + void Init(wxRichTextParagraph* parent); /// Copy void Copy(const wxRichTextLine& obj); @@ -1047,6 +1060,7 @@ public: protected: /// The range of the line (start position to end position) + /// This is relative to the parent paragraph. wxRichTextRange m_range; /// Size and position measured relative to top of paragraph @@ -1060,7 +1074,7 @@ protected: wxRichTextParagraph* m_parent; }; -WX_DECLARE_EXPORTED_LIST( wxRichTextLine, wxRichTextLineList ); +WX_DECLARE_LIST_WITH_DECL( wxRichTextLine, wxRichTextLineList , class WXDLLIMPEXP_ADV ); /*! * wxRichTextParagraph class declaration @@ -1148,6 +1162,12 @@ public: /// Get the bullet text for this paragraph. wxString GetBulletText(); + /// Allocate or reuse a line object + wxRichTextLine* AllocateLine(int pos); + + /// Clear remaining unused line objects, if any + bool ClearUnusedLines(int lineCount); + protected: /// The lines that make up the wrapped paragraph wxRichTextLineList m_cachedLines; @@ -1616,8 +1636,10 @@ public: /// Finds a handler by type static wxRichTextFileHandler *FindHandler(int imageType); - /// Gets a wildcard incorporating all visible handlers - static wxString GetExtWildcard(bool combine = false, bool save = false); + /// Gets a wildcard incorporating all visible handlers. If 'types' is present, + /// will be filled with the file type corresponding to each filter. This can be + /// used to determine the type to pass to LoadFile given a selected filter. + static wxString GetExtWildcard(bool combine = false, bool save = false, wxArrayInt* types = NULL); /// Clean up handlers static void CleanUpHandlers(); @@ -1800,15 +1822,22 @@ public: virtual bool IsVisible() const { return m_visible; } virtual void SetVisible(bool visible) { m_visible = visible; } + /// The name of the nandler void SetName(const wxString& name) { m_name = name; } wxString GetName() const { return m_name; } + /// The default extension to recognise void SetExtension(const wxString& ext) { m_extension = ext; } wxString GetExtension() const { return m_extension; } + /// The handler type void SetType(int type) { m_type = type; } int GetType() const { return m_type; } + /// 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; } + protected: #if wxUSE_STREAMS @@ -1817,6 +1846,7 @@ protected: #endif wxString m_name; + wxString m_encoding; wxString m_extension; int m_type; bool m_visible;