X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e7ad1cab887c2f1cd1a624ec0aec60d20b4d6e2..5405bfb439dcb552bd79e6f35c347498811f85ef:/interface/wx/richtext/richtextbuffer.h?ds=sidebyside diff --git a/interface/wx/richtext/richtextbuffer.h b/interface/wx/richtext/richtextbuffer.h index 0b63bdfd7d..e572433a3c 100644 --- a/interface/wx/richtext/richtextbuffer.h +++ b/interface/wx/richtext/richtextbuffer.h @@ -179,7 +179,8 @@ public: /** Adds a paragraph of text. */ - wxRichTextRange AddParagraph(const wxString& text); + virtual wxRichTextRange AddParagraph(const wxString& text, + wxTextAttr* paraStyle = 0); /** Returns @true if the buffer is currently collapsing commands into a single @@ -322,7 +323,7 @@ public: See BeginNumberedBullet() for an explanation of how indentation is used to render the bulleted paragraph. */ - bool BeginSymbolBullet(wxChar symbol, int leftIndent, + bool BeginSymbolBullet(const wxString& symbol, int leftIndent, int leftSubIndent, int bulletStyle = wxTEXT_ATTR_BULLET_STYLE_SYMBOL); @@ -358,9 +359,8 @@ public: /** Clears the buffer. */ - void Clear(); + virtual void Clear(); - //@{ /** Clears the list style from the given range, clearing list-related attributes and applying any named paragraph style associated with each paragraph. @@ -370,11 +370,8 @@ public: @see SetListStyle(), PromoteList(), NumberList() */ - bool ClearListStyle(const wxRichTextRange& range, - int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); - bool ClearListStyle(const wxRichTextRange& range, + virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); - //@} /** Clears the style stack. @@ -523,24 +520,22 @@ public: /** Finds a handler by type. */ - wxRichTextFileHandler* FindHandler(int imageType); + static wxRichTextFileHandler* FindHandler(wxRichTextFileType imageType); /** Finds a handler by extension and type. */ - wxRichTextFileHandler* FindHandler(const wxString& extension, - int imageType); + static wxRichTextFileHandler* FindHandler(const wxString& extension, wxRichTextFileType imageType); /** Finds a handler by name. */ - wxRichTextFileHandler* FindHandler(const wxString& name); + static wxRichTextFileHandler* FindHandler(const wxString& name); /** Finds a handler by filename or, if supplied, type. */ - wxRichTextFileHandler* FindHandlerFilenameOrType(const wxString& filename, - int imageType); + static wxRichTextFileHandler* FindHandlerFilenameOrType(const wxString& filename, wxRichTextFileType imageType); /** Gets the basic (overall) style. @@ -550,7 +545,7 @@ public: applied (for example, setting the default style to bold will cause subsequently inserted text to be bold). */ - const wxTextAttr GetBasicStyle() const; + virtual const wxTextAttr& GetBasicStyle() const; /** Gets the collapsed command. @@ -568,7 +563,7 @@ public: (for example, setting the default style to bold will cause subsequently inserted text to be bold). */ - const wxTextAttr GetDefaultStyle() const; + virtual const wxTextAttr& GetDefaultStyle() const; /** Gets a wildcard incorporating all visible handlers. @@ -576,13 +571,13 @@ public: to each filter. This can be used to determine the type to pass to LoadFile() given a selected filter. */ - wxString GetExtWildcard(bool combine = false, bool save = false, - wxArrayInt* types = NULL); + static wxString GetExtWildcard(bool combine = false, bool save = false, + wxArrayInt* types = NULL); /** Returns the list of file handlers. */ - wxList GetHandlers(); + static wxList& GetHandlers(); /** Returns the object to be used to render certain aspects of the content, such as @@ -598,7 +593,7 @@ public: style attributes. To get the character or paragraph style alone, use GetUncombinedStyle(). */ - bool GetStyle(long position, wxTextAttr& style); + virtual bool GetStyle(long position, wxTextAttr& style); /** This function gets a style representing the common, combined attributes in the @@ -623,8 +618,8 @@ public: changed to bold because this is already specified by the paragraph. However the text colour attributes @e will be changed to show red. */ - bool GetStyleForRange(const wxRichTextRange& range, - wxTextAttr& style); + virtual bool GetStyleForRange(const wxRichTextRange& range, + wxTextAttr& style); /** Returns the current style sheet associated with the buffer, if any. @@ -646,7 +641,7 @@ public: will fetch the paragraph attributes. Otherwise, it will return the character attributes. */ - bool GetUncombinedStyle(long position, wxTextAttr& style); + virtual bool GetUncombinedStyle(long position, wxTextAttr& style); /** Finds the text position for the given position, putting the position in @@ -655,7 +650,7 @@ public: @return One of the ::wxRichTextHitTestFlags values. */ - int HitTest(wxDC& dc, const wxPoint& pt, long& textPosition); + virtual int HitTest(wxDC& dc, const wxPoint& pt, long& textPosition); /** Initialisation. @@ -676,20 +671,19 @@ public: /** Submits a 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); /** Submits a command to insert a newline. */ - bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl); + bool InsertNewlineWithUndo(long pos, wxRichTextCtrl* ctrl, int flags = 0); /** Submits a command to insert the given text. */ bool InsertTextWithUndo(long pos, const wxString& text, - wxRichTextCtrl* ctrl); + wxRichTextCtrl* ctrl, int flags = 0); /** Returns @true if the buffer has been modified. @@ -699,14 +693,14 @@ public: /** Loads content from a stream. */ - bool LoadFile(wxInputStream& stream, - int type = wxRICHTEXT_TYPE_ANY); + virtual bool LoadFile(wxInputStream& stream, + wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); /** Loads content from a file. */ - bool LoadFile(const wxString& filename, - int type = wxRICHTEXT_TYPE_ANY); + virtual bool LoadFile(const wxString& filename, + wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); /** Marks the buffer as modified or unmodified. @@ -795,14 +789,14 @@ public: /** Saves content to a stream. */ - bool SaveFile(wxOutputStream& stream, - int type = wxRICHTEXT_TYPE_ANY); + virtual bool SaveFile(wxOutputStream& stream, + wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); /** Saves content to a file. */ - bool SaveFile(const wxString& filename, - int type = wxRICHTEXT_TYPE_ANY); + virtual bool SaveFile(const wxString& filename, + wxRichTextFileType type = wxRICHTEXT_TYPE_ANY); /** Sets the basic (overall) style. This is the style of the whole @@ -810,7 +804,7 @@ public: only affects the style currently being applied (for example, setting the default style to bold will cause subsequently inserted text to be bold). */ - void SetBasicStyle(const wxTextAttr& style); + virtual void SetBasicStyle(const wxTextAttr& style); /** Sets the default style, affecting the style currently being applied @@ -820,7 +814,7 @@ public: This is not cumulative - setting the default style will replace the previous default style. */ - void SetDefaultStyle(const wxTextAttr& style); + virtual bool SetDefaultStyle(const wxTextAttr& style); //@{ /** @@ -888,9 +882,8 @@ public: - wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags are used in this operation. */ - bool SetStyle(const wxRichTextRange& range, - const wxTextAttr& style, - int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); + virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style, + int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); /** Sets the current style sheet, if any. @@ -950,20 +943,10 @@ public: */ virtual bool CanSave() const; - /** - Override to load content from @a stream into @a buffer. - */ - bool DoLoadFile(wxRichTextBuffer* buffer, wxInputStream& stream); - - /** - Override to save content to @a stream from @a buffer. - */ - bool DoSaveFile(wxRichTextBuffer* buffer, wxOutputStream& stream); - /** Returns the encoding associated with the handler (if any). */ - const wxString GetEncoding() const; + const wxString& GetEncoding() const; /** Returns the extension associated with the handler. @@ -1049,6 +1032,19 @@ public: load and save dialogs). */ virtual void SetVisible(bool visible); + +protected: + /** + Override to load content from @a stream into @a buffer. + */ + virtual bool DoLoadFile(wxRichTextBuffer* buffer, + wxInputStream& stream) = 0; + + /** + Override to save content to @a stream from @a buffer. + */ + virtual bool DoSaveFile(wxRichTextBuffer* buffer, + wxOutputStream& stream) = 0; };