+ 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 is bold.
+ */
+ virtual bool IsSelectionBold();
+
+ /**
+ Returns @true if all of the selection is italic.
+ */
+ virtual bool IsSelectionItalics();
+
+ /**
+ Returns @true if all of the selection is underlined.
+ */
+ virtual bool IsSelectionUnderlined();
+
+ /**
+ Returns @true if all of the selection is aligned according to the specified flag.
+ */
+ virtual bool IsSelectionAligned(wxTextAttrAlignment alignment);
+
+ /**
+ Apples bold to the selection (undoable).
+ */
+ virtual bool ApplyBoldToSelection();
+
+ /**
+ Applies italic to the selection (undoable).
+ */
+ virtual bool ApplyItalicToSelection();
+
+ /**
+ Applies underline to the selection (undoable).
+ */
+ virtual bool ApplyUnderlineToSelection();
+
+ /**
+ Applies the given alignment to the selection (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);
+
+// 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.
+ */
+ virtual bool KeyboardNavigate(int keyCode, int flags);
+
+ /**
+ Paints the background.
+ */
+ virtual void PaintBackground(wxDC& dc);
+
+ /**
+ Other user defined painting after everything else (i.e. all text) is painted.
+
+ @since 2.9.1
+ */
+ virtual void PaintAboveContent(wxDC& WXUNUSED(dc)) {}
+
+#if wxRICHTEXT_BUFFERED_PAINTING
+ /**
+ Recreates the buffer bitmap if necessary.
+ */
+ virtual bool RecreateBuffer(const wxSize& size = wxDefaultSize);
+#endif
+
+ // Write text
+ virtual void DoWriteText(const wxString& value, int flags = 0);
+
+ // Should we inherit colours?
+ virtual bool ShouldInheritColours() const { return false; }
+
+ /**
+ Internal function to position the visible caret according to the current caret
+ position.
+ */
+ virtual void PositionCaret(wxRichTextParagraphLayoutBox* container = NULL);
+
+ /**
+ Helper function for extending the selection, returning @true if the selection
+ was changed. Selections are in caret positions.
+ */
+ virtual bool ExtendSelection(long oldPosition, long newPosition, int flags);
+
+ /**
+ Scrolls @a position into view. This function takes a caret position.
+ */
+ virtual bool ScrollIntoView(long position, int keyCode);
+
+ /**
+ Refreshes the area affected by a selection change.
+ */
+ bool RefreshForSelectionChange(const wxRichTextSelection& oldSelection, const wxRichTextSelection& newSelection);
+
+ /**
+ Sets the caret position.
+
+ The caret position is the character position just before the caret.
+ A value of -1 means the caret is at the start of the buffer.
+ Please note that this does not update the current editing style
+ from the new position or cause the actual caret to be refreshed; to do that,
+ call wxRichTextCtrl::SetInsertionPoint instead.
+ */
+ void SetCaretPosition(long position, bool showAtLineStart = false) ;
+
+ /**
+ Returns the current caret position.
+ */
+ long GetCaretPosition() const { return m_caretPosition; }
+
+ /**
+ The adjusted caret position is the character position adjusted to take
+ into account whether we're at the start of a paragraph, in which case
+ style information should be taken from the next position, not current one.
+ */
+ long GetAdjustedCaretPosition(long caretPos) const;
+
+ /**
+ Move the caret one visual step forward: this may mean setting a flag
+ and keeping the same position if we're going from the end of one line
+ to the start of the next, which may be the exact same caret position.
+ */
+ void MoveCaretForward(long oldPosition) ;
+
+ /**
+ Move the caret one visual step forward: this may mean setting a flag
+ and keeping the same position if we're going from the end of one line
+ to the start of the next, which may be the exact same caret position.
+ */
+ void MoveCaretBack(long oldPosition) ;
+
+ /**
+ Returns the caret height and position for the given character position.
+ If container is null, the current focus object will be used.
+
+ @beginWxPerlOnly
+ In wxPerl this method is implemented as
+ GetCaretPositionForIndex(@a position) returning a
+ 2-element list (ok, rect).
+ @endWxPerlOnly
+ */
+ bool GetCaretPositionForIndex(long position, wxRect& rect, wxRichTextParagraphLayoutBox* container = NULL);
+
+ /**
+ Internal helper function returning the line for the visible caret position.
+ If the caret is shown at the very end of the line, it means the next character
+ is actually on the following line.
+ So this function gets the line we're expecting to find if this is the case.
+ */
+ wxRichTextLine* GetVisibleLineForCaretPosition(long caretPosition) const;
+
+ /**
+ Gets the command processor associated with the control's buffer.
+ */
+ wxCommandProcessor* GetCommandProcessor() const { return GetBuffer().GetCommandProcessor(); }
+
+ /**
+ Deletes content if there is a selection, e.g. when pressing a key.
+ Returns the new caret position in @e newPos, or leaves it if there
+ was no action. This is undoable.
+
+ @beginWxPerlOnly
+ In wxPerl this method takes no arguments and returns a 2-element
+ list (ok, newPos).
+ @endWxPerlOnly
+ */
+ bool DeleteSelectedContent(long* newPos= NULL);
+
+ /**
+ Transforms logical (unscrolled) position to physical window position.
+ */
+ wxPoint GetPhysicalPoint(const wxPoint& ptLogical) const;
+
+ /**
+ Transforms physical window position to logical (unscrolled) position.
+ */
+ wxPoint GetLogicalPoint(const wxPoint& ptPhysical) const;
+
+ /**
+ Helper function for finding the caret position for the next word.
+ Direction is 1 (forward) or -1 (backwards).
+ */
+ virtual long FindNextWordPosition(int direction = 1) const;
+
+ /**
+ Returns @true if the given position is visible on the screen.
+ */
+ bool IsPositionVisible(long pos) const;
+
+ /**
+ Returns the first visible position in the current view.
+ */
+ long GetFirstVisiblePosition() const;
+
+ /**
+ Returns the caret position since the default formatting was changed. As
+ soon as this position changes, we no longer reflect the default style
+ in the UI. A value of -2 means that we should only reflect the style of the
+ content under the caret.
+ */
+ long GetCaretPositionForDefaultStyle() const { return m_caretPositionForDefaultStyle; }
+
+ /**
+ Set the caret position for the default style that the user is selecting.
+ */
+ void SetCaretPositionForDefaultStyle(long pos) { m_caretPositionForDefaultStyle = pos; }
+
+ /**
+ Returns @true if the user has recently set the default style without moving
+ the caret, and therefore the UI needs to reflect the default style and not
+ the style at the caret.
+
+ Below is an example of code that uses this function to determine whether the UI
+ should show that the current style is bold.
+
+ @see SetAndShowDefaultStyle().
+ */
+ bool IsDefaultStyleShowing() const { return m_caretPositionForDefaultStyle != -2; }
+
+ /**
+ Sets @a attr as the default style and tells the control that the UI should
+ reflect this attribute until the user moves the caret.
+
+ @see IsDefaultStyleShowing().
+ */
+ void SetAndShowDefaultStyle(const wxRichTextAttr& attr)
+ {
+ SetDefaultStyle(attr);
+ SetCaretPositionForDefaultStyle(GetCaretPosition());
+ }
+
+ /**
+ Returns the first visible point in the window.
+ */
+ wxPoint GetFirstVisiblePoint() const;
+
+#ifdef DOXYGEN
+ /**
+ Returns the content of the entire control as a string.
+ */
+ virtual wxString GetValue() const;
+
+ /**
+ Replaces existing content with the given text.
+ */
+ virtual void SetValue(const wxString& value);
+
+ /**
+ Call this function to prevent refresh and allow fast updates, and then Thaw() to
+ refresh the control.
+ */
+ void Freeze();