+ virtual void Remove(long from, long to);
+
+#ifdef DOXYGEN
+ /**
+ Loads content into the control's buffer using the given type.
+
+ If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
+ the filename extension.
+
+ This function looks for a suitable wxRichTextFileHandler object.
+ */
+ bool LoadFile(const wxString& file,
+ int type = wxRICHTEXT_TYPE_ANY);
+#endif
+
+ /**
+ Helper function for LoadFile(). Loads content into the control's buffer using the given type.
+
+ If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
+ the filename extension.
+
+ This function looks for a suitable wxRichTextFileHandler object.
+ */
+ virtual bool DoLoadFile(const wxString& file, int fileType);
+
+#ifdef DOXYGEN
+ /**
+ Saves the buffer content using the given type.
+
+ If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
+ the filename extension.
+
+ This function looks for a suitable wxRichTextFileHandler object.
+ */
+ bool SaveFile(const wxString& file = wxEmptyString,
+ int type = wxRICHTEXT_TYPE_ANY);
+#endif
+
+ /**
+ Helper function for SaveFile(). Saves the buffer content using the given type.
+
+ If the specified type is wxRICHTEXT_TYPE_ANY, the type is deduced from
+ the filename extension.
+
+ This function looks for a suitable wxRichTextFileHandler object.
+ */
+ virtual bool DoSaveFile(const wxString& file = wxEmptyString,
+ int fileType = wxRICHTEXT_TYPE_ANY);
+
+ /**
+ Sets flags that change the behaviour of loading or saving.
+
+ See the documentation for each handler class to see what flags are
+ relevant for each handler.
+ */
+ void SetHandlerFlags(int flags) { GetBuffer().SetHandlerFlags(flags); }
+
+ /**
+ Returns flags that change the behaviour of loading or saving.
+ See the documentation for each handler class to see what flags are
+ relevant for each handler.
+ */
+ int GetHandlerFlags() const { return GetBuffer().GetHandlerFlags(); }
+
+ /**
+ Marks the buffer as modified.
+ */
+ virtual void MarkDirty();
+
+ /**
+ Sets the buffer's modified status to @false, and clears the buffer's command
+ history.
+ */
+ virtual void DiscardEdits();
+
+ /**
+ Sets the maximum number of characters that may be entered in a single line
+ text control. For compatibility only; currently does nothing.
+ */
+ virtual void SetMaxLength(unsigned long WXUNUSED(len)) { }
+
+ /**
+ Writes text at the current position.
+ */
+ virtual void WriteText(const wxString& text);
+
+ /**
+ Sets the insertion point to the end of the buffer and writes the text.
+ */
+ virtual void AppendText(const wxString& text);
+
+ //@{
+ /**
+ Gets the attributes at the given position.
+ This function gets the combined style - that is, the style you see on the
+ screen as a result of combining base style, paragraph style and character
+ style attributes.
+
+ To get the character or paragraph style alone, use GetUncombinedStyle().
+
+ @beginWxPerlOnly
+ In wxPerl this method is implemented as GetStyle(@a position)
+ returning a 2-element list (ok, attr).
+ @endWxPerlOnly
+ */
+ virtual bool GetStyle(long position, wxTextAttr& style);
+ virtual bool GetStyle(long position, wxRichTextAttr& style);
+ virtual bool GetStyle(long position, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container);
+ //@}
+
+ //@{
+ /**
+ Sets the attributes for the given range.
+ The end point of range is specified as the last character position of the span
+ of text, plus one.
+
+ So, for example, to set the style for a character at position 5, use the range
+ (5,6).
+ */
+ virtual bool SetStyle(long start, long end, const wxTextAttr& style);
+ virtual bool SetStyle(long start, long end, const wxRichTextAttr& style);
+ virtual bool SetStyle(const wxRichTextRange& range, const wxTextAttr& style);
+ virtual bool SetStyle(const wxRichTextRange& range, const wxRichTextAttr& style);
+ //@}
+
+ /**
+ Sets the attributes for a single object
+ */
+ virtual void SetStyle(wxRichTextObject *obj, const wxRichTextAttr& textAttr);
+
+ //@{
+ /**
+ Gets the attributes common to the specified range.
+ Attributes that differ in value within the range will not be included
+ in @a style flags.
+
+ @beginWxPerlOnly
+ In wxPerl this method is implemented as GetStyleForRange(@a position)
+ returning a 2-element list (ok, attr).
+ @endWxPerlOnly
+ */
+ virtual bool GetStyleForRange(const wxRichTextRange& range, wxTextAttr& style);
+ virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style);
+ virtual bool GetStyleForRange(const wxRichTextRange& range, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container);
+ //@}
+
+ /**
+ Sets the attributes for the given range, passing flags to determine how the
+ attributes are set.
+
+ The end point of range is specified as the last character position of the span
+ of text, plus one. So, for example, to set the style for a character at
+ position 5, use the range (5,6).
+
+ @a flags may contain a bit list of the following values:
+ - wxRICHTEXT_SETSTYLE_NONE: no style flag.
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be
+ undoable.
+ - wxRICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied
+ if the combined style at this point is already the style in question.
+ - wxRICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be
+ applied to paragraphs, and not the content.
+ This allows content styling to be preserved independently from that
+ of e.g. a named paragraph style.
+ - wxRICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be
+ applied to characters, and not the paragraph.
+ This allows content styling to be preserved independently from that
+ of e.g. a named paragraph style.
+ - wxRICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying
+ the new style.
+ - wxRICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags
+ are used in this operation.
+ */
+ virtual bool SetStyleEx(const wxRichTextRange& range, const wxRichTextAttr& style, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+
+ //@{
+ /**
+ Gets the attributes at the given position.
+ This function gets the @e uncombined style - that is, the attributes associated
+ with the paragraph or character content, and not necessarily the combined
+ attributes you see on the screen.
+ To get the combined attributes, use GetStyle().
+
+ If you specify (any) paragraph attribute in @e style's flags, this function
+ will fetch the paragraph attributes.
+ Otherwise, it will return the character attributes.
+
+ @beginWxPerlOnly
+ In wxPerl this method is implemented as GetUncombinedStyle(@a position)
+ returning a 2-element list (ok, attr).
+ @endWxPerlOnly
+ */
+ virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style);
+ virtual bool GetUncombinedStyle(long position, wxRichTextAttr& style, wxRichTextParagraphLayoutBox* container);
+ //@}
+
+ //@{
+ /**
+ Sets the current default style, which can be used to change how subsequently
+ inserted text is displayed.
+ */
+ virtual bool SetDefaultStyle(const wxTextAttr& style);
+ virtual bool SetDefaultStyle(const wxRichTextAttr& style);
+ //@}
+
+ /**
+ Returns the current default style, which can be used to change how subsequently
+ inserted text is displayed.
+ */
+ virtual const wxRichTextAttr& GetDefaultStyleEx() const;
+
+ //virtual const wxTextAttr& GetDefaultStyle() const;
+
+ //@{
+ /**
+ Sets the list attributes for the given range, passing flags to determine how
+ the attributes are set.
+
+ Either the style definition or the name of the style definition (in the current
+ sheet) can be passed.
+ @a flags is a bit list of the following:
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
+ - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
+ @a startFrom, otherwise existing attributes are used.
+ - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
+ as the level for all paragraphs, otherwise the current indentation will be used.
+
+ @see NumberList(), PromoteList(), ClearListStyle().
+ */
+ virtual bool SetListStyle(const wxRichTextRange& range, wxRichTextListStyleDefinition* def, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+ virtual bool SetListStyle(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+ //@}
+
+ /**
+ Clears the list style from the given range, clearing list-related attributes
+ and applying any named paragraph style associated with each paragraph.
+
+ @a flags is a bit list of the following:
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
+
+ @see SetListStyle(), PromoteList(), NumberList().
+ */
+ virtual bool ClearListStyle(const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO);
+
+ //@{
+ /**
+ Numbers the paragraphs in the given range.
+ Pass flags to determine how the attributes are set.
+
+ Either the style definition or the name of the style definition (in the current
+ sheet) can be passed.
+
+ @a flags is a bit list of the following:
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
+ - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
+ @a startFrom, otherwise existing attributes are used.
+ - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
+ as the level for all paragraphs, otherwise the current indentation will be used.
+
+ @see SetListStyle(), PromoteList(), ClearListStyle().
+ */
+ virtual bool NumberList(const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+ virtual bool NumberList(const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int startFrom = 1, int specifiedLevel = -1);
+ //@}
+
+ //@{
+ /**
+ Promotes or demotes the paragraphs in the given range.
+ A positive @a promoteBy produces a smaller indent, and a negative number
+ produces a larger indent. Pass flags to determine how the attributes are set.
+ Either the style definition or the name of the style definition (in the current
+ sheet) can be passed.
+
+ @a flags is a bit list of the following:
+ - wxRICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
+ - wxRICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from
+ @a startFrom, otherwise existing attributes are used.
+ - wxRICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that @a listLevel should be used
+ as the level for all paragraphs, otherwise the current indentation will be used.
+
+ @see SetListStyle(), @see SetListStyle(), ClearListStyle().
+ */
+ virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, wxRichTextListStyleDefinition* def = NULL, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
+ virtual bool PromoteList(int promoteBy, const wxRichTextRange& range, const wxString& defName, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO, int specifiedLevel = -1);
+ //@}
+
+ /**
+ Sets the properties for the given range, passing flags to determine how the
+ attributes are set. You can merge properties or replace them.
+
+ The end point of range is specified as the last character position of the span
+ of text, plus one. So, for example, to set the properties for a character at
+ position 5, use the range (5,6).
+
+ @a flags may contain a bit list of the following values:
+ - wxRICHTEXT_SETSPROPERTIES_NONE: no flag.
+ - wxRICHTEXT_SETPROPERTIES_WITH_UNDO: specifies that this operation should be
+ undoable.
+ - wxRICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY: specifies that the properties should only be
+ applied to paragraphs, and not the content.
+ - wxRICHTEXT_SETPROPERTIES_CHARACTERS_ONLY: specifies that the properties should only be
+ applied to characters, and not the paragraph.
+ - wxRICHTEXT_SETPROPERTIES_RESET: resets (clears) the existing properties before applying
+ the new properties.
+ - wxRICHTEXT_SETPROPERTIES_REMOVE: removes the specified properties.
+ */
+ virtual bool SetProperties(const wxRichTextRange& range, const wxRichTextProperties& properties, int flags = wxRICHTEXT_SETPROPERTIES_WITH_UNDO);
+
+ /**
+ Deletes the content within the given range.
+ */
+ virtual bool Delete(const wxRichTextRange& range);
+
+ /**
+ Translates from column and line number to position.
+ */
+ virtual long XYToPosition(long x, long y) const;
+
+ /**
+ Converts a text position to zero-based column and line numbers.
+ */
+ virtual bool PositionToXY(long pos, long *x, long *y) const;
+
+ /**
+ Scrolls the buffer so that the given position is in view.
+ */
+ virtual void ShowPosition(long pos);
+
+ //@{
+ /**
+ Finds the character at the given position in pixels.
+ @a pt is in device coords (not adjusted for the client area origin nor for
+ scrolling).
+ */
+ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
+ virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
+ wxTextCoord *col,
+ wxTextCoord *row) const;
+
+ /**
+ Finds the container at the given point, which is assumed to be in client coordinates.
+ */
+ wxRichTextParagraphLayoutBox* FindContainerAtPoint(const wxPoint pt, long& position, int& hit, wxRichTextObject* hitObj, int flags = 0);
+ //@}
+
+// Clipboard operations
+
+ /**
+ Copies the selected content (if any) to the clipboard.
+ */
+ virtual void Copy();
+
+ /**
+ Copies the selected content (if any) to the clipboard and deletes the selection.
+ This is undoable.
+ */
+ virtual void Cut();
+
+ /**
+ Pastes content from the clipboard to the buffer.
+ */
+ virtual void Paste();
+
+ /**
+ Deletes the content in the selection, if any. This is undoable.
+ */
+ virtual void DeleteSelection();
+
+ /**
+ Returns @true if selected content can be copied to the clipboard.
+ */
+ virtual bool CanCopy() const;
+
+ /**
+ Returns @true if selected content can be copied to the clipboard and deleted.
+ */
+ virtual bool CanCut() const;
+
+ /**
+ Returns @true if the clipboard content can be pasted to the buffer.
+ */
+ virtual bool CanPaste() const;
+
+ /**
+ Returns @true if selected content can be deleted.
+ */
+ virtual bool CanDeleteSelection() const;
+
+ /**
+ Undoes the command at the top of the command history, if there is one.
+ */
+ virtual void Undo();
+
+ /**
+ Redoes the current command.
+ */
+ virtual void Redo();
+
+ /**
+ Returns @true if there is a command in the command history that can be undone.
+ */
+ virtual bool CanUndo() const;
+
+ /**
+ Returns @true if there is a command in the command history that can be redone.
+ */
+ virtual bool CanRedo() const;
+
+ /**
+ Sets the insertion point and causes the current editing style to be taken from
+ the new position (unlike wxRichTextCtrl::SetCaretPosition).
+ */
+ virtual void SetInsertionPoint(long pos);
+
+ /**
+ Sets the insertion point to the end of the text control.
+ */
+ virtual void SetInsertionPointEnd();
+
+ /**
+ Returns the current insertion point.
+ */
+ virtual long GetInsertionPoint() const;
+
+ /**
+ Returns the last position in the buffer.
+ */
+ virtual wxTextPos GetLastPosition() const;
+
+ //@{
+ /**
+ Sets the selection to the given range.
+ The end point of range is specified as the last character position of the span
+ of text, plus one.
+
+ So, for example, to set the selection for a character at position 5, use the
+ range (5,6).
+ */
+ virtual void SetSelection(long from, long to);
+ void SetSelection(const wxRichTextSelection& sel) { m_selection = sel; }
+ //@}
+
+
+ /**
+ Selects all the text in the buffer.
+ */
+ virtual void SelectAll();
+
+ /**
+ Makes the control editable, or not.
+ */
+ virtual void SetEditable(bool editable);
+
+ /**
+ Returns @true if there is a selection and the object containing the selection
+ was the same as the current focus object.
+ */
+ virtual bool HasSelection() const;
+
+ /**
+ Returns @true if there was a selection, whether or not the current focus object
+ is the same as the selection's container object.
+ */
+ virtual bool HasUnfocusedSelection() const;
+
+ //@{
+ /**
+ Write a bitmap or image at the current insertion point.
+ Supply an optional type to use for internal and file storage of the raw data.
+ */
+ virtual bool WriteImage(const wxImage& image, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
+
+ virtual bool WriteImage(const wxBitmap& bitmap, wxBitmapType bitmapType = wxBITMAP_TYPE_PNG,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
+ //@}
+
+ /**
+ Loads an image from a file and writes it at the current insertion point.
+ */
+ virtual bool WriteImage(const wxString& filename, wxBitmapType bitmapType,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
+
+ /**
+ Writes an image block at the current insertion point.
+ */
+ virtual bool WriteImage(const wxRichTextImageBlock& imageBlock,
+ const wxRichTextAttr& textAttr = wxRichTextAttr());
+
+ /**
+ Write a text box at the current insertion point, returning the text box.
+ You can then call SetFocusObject() to set the focus to the new object.
+ */
+ virtual wxRichTextBox* WriteTextBox(const wxRichTextAttr& textAttr = wxRichTextAttr());
+
+ /**
+ Write a table at the current insertion point, returning the table.
+ You can then call SetFocusObject() to set the focus to the new object.
+ */
+ virtual wxRichTextTable* WriteTable(int rows, int cols, const wxRichTextAttr& tableAttr = wxRichTextAttr(), const wxRichTextAttr& cellAttr = wxRichTextAttr());
+
+ /**
+ Inserts a new paragraph at the current insertion point. @see LineBreak().
+ */
+ virtual bool Newline();
+
+ /**
+ Inserts a line break at the current insertion point.
+
+ A line break forces wrapping within a paragraph, and can be introduced by
+ using this function, by appending the wxChar value @b wxRichTextLineBreakChar
+ to text content, or by typing Shift-Return.
+ */
+ virtual bool LineBreak();
+
+ /**
+ Sets the basic (overall) style.
+
+ This is the style of the whole buffer before further styles are applied,
+ unlike the default style, which only affects the style currently being
+ applied (for example, setting the default style to bold will cause
+ subsequently inserted text to be bold).
+ */
+ virtual void SetBasicStyle(const wxRichTextAttr& style) { GetBuffer().SetBasicStyle(style); }
+
+ /**
+ Gets the basic (overall) style.
+
+ This is the style of the whole buffer before further styles are applied,
+ unlike the default style, which only affects the style currently being
+ applied (for example, setting the default style to bold will cause
+ subsequently inserted text to be bold).
+ */
+ virtual const wxRichTextAttr& GetBasicStyle() const { return GetBuffer().GetBasicStyle(); }
+
+ /**
+ Begins applying a style.
+ */
+ virtual bool BeginStyle(const wxRichTextAttr& style) { return GetBuffer().BeginStyle(style); }
+
+ /**
+ Ends the current style.
+ */
+ virtual bool EndStyle() { return GetBuffer().EndStyle(); }
+
+ /**
+ Ends application of all styles in the current style stack.
+ */
+ virtual bool EndAllStyles() { return GetBuffer().EndAllStyles(); }
+
+ /**
+ Begins using bold.
+ */
+ bool BeginBold() { return GetBuffer().BeginBold(); }
+
+ /**
+ Ends using bold.
+ */
+ bool EndBold() { return GetBuffer().EndBold(); }
+
+ /**
+ Begins using italic.
+ */
+ bool BeginItalic() { return GetBuffer().BeginItalic(); }
+
+ /**
+ Ends using italic.
+ */
+ bool EndItalic() { return GetBuffer().EndItalic(); }
+
+ /**
+ Begins using underlining.
+ */
+ bool BeginUnderline() { return GetBuffer().BeginUnderline(); }
+
+ /**
+ End applying underlining.
+ */
+ bool EndUnderline() { return GetBuffer().EndUnderline(); }
+
+ /**
+ Begins using the given point size.
+ */
+ bool BeginFontSize(int pointSize) { return GetBuffer().BeginFontSize(pointSize); }
+
+ /**
+ Ends using a point size.
+ */
+ bool EndFontSize() { return GetBuffer().EndFontSize(); }
+
+ /**
+ Begins using this font.
+ */
+ bool BeginFont(const wxFont& font) { return GetBuffer().BeginFont(font); }
+
+ /**
+ Ends using a font.
+ */
+ bool EndFont() { return GetBuffer().EndFont(); }
+
+ /**
+ Begins using this colour.
+ */
+ bool BeginTextColour(const wxColour& colour) { return GetBuffer().BeginTextColour(colour); }
+
+ /**
+ Ends applying a text colour.
+ */
+ bool EndTextColour() { return GetBuffer().EndTextColour(); }
+
+ /**
+ Begins using alignment.
+ For alignment values, see wxTextAttr.
+ */
+ bool BeginAlignment(wxTextAttrAlignment alignment) { return GetBuffer().BeginAlignment(alignment); }
+
+ /**
+ Ends alignment.
+ */
+ bool EndAlignment() { return GetBuffer().EndAlignment(); }
+
+ /**
+ Begins applying a left indent and subindent in tenths of a millimetre.
+ The subindent is an offset from the left edge of the paragraph, and is
+ used for all but the first line in a paragraph. A positive value will
+ cause the first line to appear to the left of the subsequent lines, and
+ a negative value will cause the first line to be indented to the right
+ of the subsequent lines.
+
+ wxRichTextBuffer uses indentation to render a bulleted item. The
+ content of the paragraph, including the first line, starts at the
+ @a leftIndent plus the @a leftSubIndent.
+
+ @param leftIndent
+ The distance between the margin and the bullet.
+ @param leftSubIndent
+ The distance between the left edge of the bullet and the left edge
+ of the actual paragraph.
+ */
+ bool BeginLeftIndent(int leftIndent, int leftSubIndent = 0) { return GetBuffer().BeginLeftIndent(leftIndent, leftSubIndent); }