+ 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).
+ */
+ void SetSelectionRange(const wxRichTextRange& range);
+
+ /**
+ Returns the selection range in character positions. -2, -2 means no selection
+ -1, -1 means select everything.
+ The range is in internal format, i.e. a single character selection is denoted
+ by (n, n)
+ */
+ wxRichTextRange GetInternalSelectionRange() const { return m_selection.GetRange(); }
+
+ /**
+ Sets the selection range in character positions. -2, -2 means no selection
+ -1, -1 means select everything.
+ The range is in internal format, i.e. a single character selection is denoted
+ by (n, n)
+ */
+ void SetInternalSelectionRange(const wxRichTextRange& range) { m_selection.Set(range, GetFocusObject()); }
+
+ /**
+ Adds a new paragraph of text to the end of the buffer.
+ */
+ virtual wxRichTextRange AddParagraph(const wxString& text);
+
+ /**
+ Adds an image to the control's buffer.
+ */
+ virtual wxRichTextRange AddImage(const wxImage& image);
+
+ /**
+ Lays out the buffer, which must be done before certain operations, such as
+ setting the caret position.
+ This function should not normally be required by the application.
+ */
+ virtual bool LayoutContent(bool onlyVisibleRect = false);
+
+ /**
+ Move the caret to the given character position.
+
+ Please note that this does not update the current editing style
+ from the new position; to do that, call wxRichTextCtrl::SetInsertionPoint instead.
+ */
+ virtual bool MoveCaret(long pos, bool showAtLineStart = false, wxRichTextParagraphLayoutBox* container = NULL);
+
+ /**
+ Moves right.
+ */
+ virtual bool MoveRight(int noPositions = 1, int flags = 0);
+
+ /**
+ Moves left.
+ */
+ virtual bool MoveLeft(int noPositions = 1, int flags = 0);
+
+ /**
+ Moves to the start of the paragraph.
+ */
+ virtual bool MoveUp(int noLines = 1, int flags = 0);
+
+ /**
+ Moves the caret down.
+ */
+ virtual bool MoveDown(int noLines = 1, int flags = 0);
+
+ /**
+ Moves to the end of the line.
+ */
+ virtual bool MoveToLineEnd(int flags = 0);
+
+ /**
+ Moves to the start of the line.
+ */
+ virtual bool MoveToLineStart(int flags = 0);
+
+ /**
+ Moves to the end of the paragraph.
+ */
+ virtual bool MoveToParagraphEnd(int flags = 0);
+
+ /**
+ Moves to the start of the paragraph.
+ */
+ virtual bool MoveToParagraphStart(int flags = 0);
+
+ /**
+ Moves to the start of the buffer.
+ */
+ virtual bool MoveHome(int flags = 0);
+
+ /**
+ Moves to the end of the buffer.
+ */
+ virtual bool MoveEnd(int flags = 0);
+
+ /**
+ Moves one or more pages up.
+ */
+ virtual bool PageUp(int noPages = 1, int flags = 0);
+
+ /**
+ Moves one or more pages down.
+ */
+ virtual bool PageDown(int noPages = 1, int flags = 0);
+
+ /**
+ Moves a number of words to the left.
+ */
+ virtual bool WordLeft(int noPages = 1, int flags = 0);
+
+ /**
+ Move a nuber of words to the right.
+ */
+ virtual bool WordRight(int noPages = 1, int flags = 0);
+
+ //@{
+ /**
+ Returns the buffer associated with the control.
+ */
+ wxRichTextBuffer& GetBuffer() { return m_buffer; }
+ const wxRichTextBuffer& GetBuffer() const { return m_buffer; }
+ //@}
+
+ /**
+ Starts batching undo history for commands.
+ */
+ virtual bool BeginBatchUndo(const wxString& cmdName) { return m_buffer.BeginBatchUndo(cmdName); }
+
+ /**
+ Ends batching undo command history.
+ */
+ virtual bool EndBatchUndo() { return m_buffer.EndBatchUndo(); }
+
+ /**
+ Returns @true if undo commands are being batched.
+ */
+ virtual bool BatchingUndo() const { return m_buffer.BatchingUndo(); }
+
+ /**
+ Starts suppressing undo history for commands.
+ */
+ virtual bool BeginSuppressUndo() { return m_buffer.BeginSuppressUndo(); }
+
+ /**
+ Ends suppressing undo command history.
+ */
+ virtual bool EndSuppressUndo() { return m_buffer.EndSuppressUndo(); }
+
+ /**
+ Returns @true if undo history suppression is on.
+ */
+ virtual bool SuppressingUndo() const { return m_buffer.SuppressingUndo(); }
+
+ /**
+ Test if this whole range has character attributes of the specified kind.
+ If any of the attributes are different within the range, the test fails.
+
+ You can use this to implement, for example, bold button updating.
+ @a style must have flags indicating which attributes are of interest.
+ */
+ virtual bool HasCharacterAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const
+ {
+ return GetBuffer().HasCharacterAttributes(range.ToInternal(), style);
+ }
+
+ /**
+ Test if this whole range has paragraph attributes of the specified kind.
+ If any of the attributes are different within the range, the test fails.
+ You can use this to implement, for example, centering button updating.
+ @a style must have flags indicating which attributes are of interest.
+ */
+ virtual bool HasParagraphAttributes(const wxRichTextRange& range, const wxRichTextAttr& style) const
+ {
+ return GetBuffer().HasParagraphAttributes(range.ToInternal(), style);
+ }
+
+ /**
+ Returns @true if all of the selection, or the content at the caret position, is bold.
+ */
+ virtual bool IsSelectionBold();
+
+ /**
+ Returns @true if all of the selection, or the content at the caret position, is italic.
+ */
+ virtual bool IsSelectionItalics();
+
+ /**
+ Returns @true if all of the selection, or the content at the caret position, is underlined.
+ */
+ virtual bool IsSelectionUnderlined();
+
+ /**
+ Returns @true if all of the selection, or the content at the current caret position, has the supplied wxTextAttrEffects flag(s).
+ */
+ virtual bool DoesSelectionHaveTextEffectFlag(int flag);
+
+ /**
+ Returns @true if all of the selection is aligned according to the specified flag.
+ */
+ virtual bool IsSelectionAligned(wxTextAttrAlignment alignment);
+
+ /**
+ Apples bold to the selection or the default style (undoable).
+ */
+ virtual bool ApplyBoldToSelection();
+
+ /**
+ Applies italic to the selection or the default style (undoable).
+ */
+ virtual bool ApplyItalicToSelection();
+
+ /**
+ Applies underline to the selection or the default style (undoable).
+ */
+ virtual bool ApplyUnderlineToSelection();
+
+ /**
+ Applies one or more wxTextAttrEffects flags to the selection (undoable).
+ If there is no selection, it is applied to the default style.
+ */
+ virtual bool ApplyTextEffectToSelection(int flags);
+
+ /**
+ Applies the given alignment to the selection or the default style (undoable).
+ For alignment values, see wxTextAttr.
+ */
+ virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment);
+
+ /**
+ Applies the style sheet to the buffer, matching paragraph styles in the sheet
+ against named styles in the buffer.
+
+ This might be useful if the styles have changed.
+ If @a sheet is @NULL, the sheet set with SetStyleSheet() is used.
+ Currently this applies paragraph styles only.
+ */
+ virtual bool ApplyStyle(wxRichTextStyleDefinition* def);
+
+ /**
+ Sets the style sheet associated with the control.
+ A style sheet allows named character and paragraph styles to be applied.
+ */
+ void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { GetBuffer().SetStyleSheet(styleSheet); }
+
+ /**
+ Returns the style sheet associated with the control, if any.
+ A style sheet allows named character and paragraph styles to be applied.
+ */
+ wxRichTextStyleSheet* GetStyleSheet() const { return GetBuffer().GetStyleSheet(); }
+
+ /**
+ Push the style sheet to top of stack.
+ */
+ bool PushStyleSheet(wxRichTextStyleSheet* styleSheet) { return GetBuffer().PushStyleSheet(styleSheet); }
+
+ /**
+ Pops the style sheet from top of stack.
+ */
+ wxRichTextStyleSheet* PopStyleSheet() { return GetBuffer().PopStyleSheet(); }
+
+ /**
+ Applies the style sheet to the buffer, for example if the styles have changed.
+ */
+ bool ApplyStyleSheet(wxRichTextStyleSheet* styleSheet = NULL);
+
+ /**
+ Shows the given context menu, optionally adding appropriate property-editing commands for the current position in the object hierarchy.
+ */
+ virtual bool ShowContextMenu(wxMenu* menu, const wxPoint& pt, bool addPropertyCommands);
+
+ /**
+ Prepares the context menu, optionally adding appropriate property-editing commands.
+ Returns the number of property commands added.
+ */
+ virtual int PrepareContextMenu(wxMenu* menu, const wxPoint& pt, bool addPropertyCommands);
+
+ /**
+ Returns @true if we can edit the object's properties via a GUI.
+ */
+ virtual bool CanEditProperties(wxRichTextObject* obj) const;
+
+ /**
+ Edits the object's properties via a GUI.
+ */
+ virtual bool EditProperties(wxRichTextObject* obj, wxWindow* parent);
+
+ /**
+ Gets the object's properties menu label.
+ */
+ virtual wxString GetPropertiesMenuLabel(wxRichTextObject* obj);
+
+ /**
+ Prepares the content just before insertion (or after buffer reset). Called by the same function in wxRichTextBuffer.
+ Currently is only called if undo mode is on.
+ */
+ virtual void PrepareContent(wxRichTextParagraphLayoutBox& WXUNUSED(container)) {}
+
+ /**
+ Can we delete this range?
+ Sends an event to the control.
+ */
+ virtual bool CanDeleteRange(wxRichTextParagraphLayoutBox& container, const wxRichTextRange& range) const;
+
+ /**
+ Can we insert content at this position?
+ Sends an event to the control.
+ */
+ virtual bool CanInsertContent(wxRichTextParagraphLayoutBox& container, long pos) const;
+
+// Command handlers
+
+ /**
+ Sends the event to the control.
+ */
+ void Command(wxCommandEvent& event);
+
+ /**
+ Loads the first dropped file.
+ */
+ void OnDropFiles(wxDropFilesEvent& event);
+
+ void OnCaptureLost(wxMouseCaptureLostEvent& event);
+ void OnSysColourChanged(wxSysColourChangedEvent& event);
+
+ /**
+ Standard handler for the wxID_CUT command.
+ */
+ void OnCut(wxCommandEvent& event);
+
+ /**
+ Standard handler for the wxID_COPY command.
+ */
+ void OnCopy(wxCommandEvent& event);
+
+ /**
+ Standard handler for the wxID_PASTE command.
+ */
+ void OnPaste(wxCommandEvent& event);
+
+ /**
+ Standard handler for the wxID_UNDO command.
+ */
+ void OnUndo(wxCommandEvent& event);
+
+ /**
+ Standard handler for the wxID_REDO command.
+ */
+ void OnRedo(wxCommandEvent& event);
+
+ /**
+ Standard handler for the wxID_SELECTALL command.
+ */
+ void OnSelectAll(wxCommandEvent& event);
+
+ /**
+ Standard handler for property commands.
+ */
+ void OnProperties(wxCommandEvent& event);
+
+ /**
+ Standard handler for the wxID_CLEAR command.
+ */
+ void OnClear(wxCommandEvent& event);
+
+ /**
+ Standard update handler for the wxID_CUT command.
+ */
+ void OnUpdateCut(wxUpdateUIEvent& event);
+
+ /**
+ Standard update handler for the wxID_COPY command.
+ */
+ void OnUpdateCopy(wxUpdateUIEvent& event);
+
+ /**
+ Standard update handler for the wxID_PASTE command.
+ */
+ void OnUpdatePaste(wxUpdateUIEvent& event);
+
+ /**
+ Standard update handler for the wxID_UNDO command.
+ */
+ void OnUpdateUndo(wxUpdateUIEvent& event);
+
+ /**
+ Standard update handler for the wxID_REDO command.
+ */
+ void OnUpdateRedo(wxUpdateUIEvent& event);
+
+ /**
+ Standard update handler for the wxID_SELECTALL command.
+ */
+ void OnUpdateSelectAll(wxUpdateUIEvent& event);
+
+ /**
+ Standard update handler for property commands.
+ */
+
+ void OnUpdateProperties(wxUpdateUIEvent& event);
+
+ /**
+ Standard update handler for the wxID_CLEAR command.
+ */
+ void OnUpdateClear(wxUpdateUIEvent& event);
+
+ /**
+ Shows a standard context menu with undo, redo, cut, copy, paste, clear, and
+ select all commands.
+ */
+ void OnContextMenu(wxContextMenuEvent& event);
+
+// Event handlers
+
+ // Painting
+ void OnPaint(wxPaintEvent& event);
+ void OnEraseBackground(wxEraseEvent& event);
+
+ // Left-click
+ void OnLeftClick(wxMouseEvent& event);
+
+ // Left-up
+ void OnLeftUp(wxMouseEvent& event);
+
+ // Motion
+ void OnMoveMouse(wxMouseEvent& event);
+
+ // Left-double-click
+ void OnLeftDClick(wxMouseEvent& event);
+
+ // Middle-click
+ void OnMiddleClick(wxMouseEvent& event);
+
+ // Right-click
+ void OnRightClick(wxMouseEvent& event);
+
+ // Key press
+ void OnChar(wxKeyEvent& event);
+
+ // Sizing
+ void OnSize(wxSizeEvent& event);
+
+ // Setting/losing focus
+ void OnSetFocus(wxFocusEvent& event);
+ void OnKillFocus(wxFocusEvent& event);
+
+ // Idle-time processing
+ void OnIdle(wxIdleEvent& event);
+
+ // Scrolling
+ void OnScroll(wxScrollWinEvent& event);
+
+ /**
+ Sets the font, and also the basic and default attributes
+ (see wxRichTextCtrl::SetDefaultStyle).
+ */
+ virtual bool SetFont(const wxFont& font);
+
+ /**
+ A helper function setting up scrollbars, for example after a resize.
+ */
+ virtual void SetupScrollbars(bool atTop = false);
+
+ /**
+ Helper function implementing keyboard navigation.