From adacb5c07e0f2fd1d54c87f30be38011d3460c06 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 20 Aug 2021 16:42:01 +0100 Subject: [PATCH] Move EmptyUndoBuffer() from wxTextEntry to wxTextCtrl It seems unlikely that we're ever going to need this function in any other classes inheriting from wxTextEntry (i.e. wxComboBox) and both existing implementations are for wxTextCtrl only, so define this function there. If really necessary, we can always lower it to wxTextEntry later, while moving it in the other direction wouldn't be easily possible due to compatibility concerns. This commit is best viewed with git --color-moved option. --- include/wx/osx/textctrl.h | 2 ++ include/wx/osx/textentry.h | 2 -- include/wx/textctrl.h | 2 ++ include/wx/textentry.h | 2 -- interface/wx/textctrl.h | 11 +++++++++++ interface/wx/textentry.h | 11 ----------- src/osx/textctrl_osx.cpp | 7 +++++++ src/osx/textentry_osx.cpp | 7 ------- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/wx/osx/textctrl.h b/include/wx/osx/textctrl.h index d3bb9ce057..a784e39ac6 100644 --- a/include/wx/osx/textctrl.h +++ b/include/wx/osx/textctrl.h @@ -74,6 +74,8 @@ public: virtual void MarkDirty() wxOVERRIDE; virtual void DiscardEdits() wxOVERRIDE; + virtual void EmptyUndoBuffer() wxOVERRIDE; + // text control under some platforms supports the text styles: these // methods apply the given text style to the given selection or to // set/get the style which will be used for all appended text diff --git a/include/wx/osx/textentry.h b/include/wx/osx/textentry.h index 14b795eed6..4a563a29db 100644 --- a/include/wx/osx/textentry.h +++ b/include/wx/osx/textentry.h @@ -72,8 +72,6 @@ public: virtual bool CanUndo() const wxOVERRIDE; virtual bool CanRedo() const wxOVERRIDE; - virtual void EmptyUndoBuffer() wxOVERRIDE; - // Insertion point virtual void SetInsertionPoint(long pos) wxOVERRIDE; virtual void SetInsertionPointEnd() wxOVERRIDE; diff --git a/include/wx/textctrl.h b/include/wx/textctrl.h index e386040404..ac18c183e9 100644 --- a/include/wx/textctrl.h +++ b/include/wx/textctrl.h @@ -574,6 +574,8 @@ public: DiscardEdits(); } + virtual void EmptyUndoBuffer() { } + // styles handling // --------------- diff --git a/include/wx/textentry.h b/include/wx/textentry.h index ed46d9b5ca..0f8a6bcbd9 100644 --- a/include/wx/textentry.h +++ b/include/wx/textentry.h @@ -81,8 +81,6 @@ public: virtual bool CanUndo() const = 0; virtual bool CanRedo() const = 0; - virtual void EmptyUndoBuffer() { } - // insertion point // --------------- diff --git a/interface/wx/textctrl.h b/interface/wx/textctrl.h index ec3cbba2ec..d296d05c72 100644 --- a/interface/wx/textctrl.h +++ b/interface/wx/textctrl.h @@ -1312,6 +1312,17 @@ public: */ virtual void DiscardEdits(); + /** + Delete the undo history. + + Currently only implemented in wxMSW (for controls using wxTE_RICH2 + style only) and wxOSX (for multiline text controls only), does nothing + in the other ports or for the controls not using the appropriate styles. + + @since 3.1.6 + */ + virtual void EmptyUndoBuffer(); + /** This function inserts into the control the character which would have been inserted if the given key event had occurred in the text control. diff --git a/interface/wx/textentry.h b/interface/wx/textentry.h index 0323eeaeb4..989f61ba3b 100644 --- a/interface/wx/textentry.h +++ b/interface/wx/textentry.h @@ -165,17 +165,6 @@ public: */ virtual bool CanUndo() const; - /** - Delete the undo history. - - Currently only implemented in wxMSW (for controls using wxTE_RICH2 - style only) and wxOSX (for multiline text controls only), does nothing - in the other ports or for the controls not using the appropriate styles. - - @since 3.1.6 - */ - virtual void EmptyUndoBuffer(); - /** Sets the new text control value. diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 3a47d55b45..31a3bcebcb 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -259,6 +259,13 @@ void wxTextCtrl::DiscardEdits() m_dirty = false; } +void wxTextCtrl::EmptyUndoBuffer() +{ + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + + GetTextPeer()->EmptyUndoBuffer() ; +} + int wxTextCtrl::GetNumberOfLines() const { return GetTextPeer()->GetNumberOfLines() ; diff --git a/src/osx/textentry_osx.cpp b/src/osx/textentry_osx.cpp index 4a971aadf0..f0b58ab524 100644 --- a/src/osx/textentry_osx.cpp +++ b/src/osx/textentry_osx.cpp @@ -293,13 +293,6 @@ bool wxTextEntry::CanRedo() const return GetTextPeer()->CanRedo() ; } -void wxTextEntry::EmptyUndoBuffer() -{ - wxCHECK_RET( GetTextPeer(), "Must create the control first" ); - - return GetTextPeer()->EmptyUndoBuffer() ; -} - wxTextWidgetImpl * wxTextEntry::GetTextPeer() const { wxWindow * const win = const_cast(this)->GetEditableWindow();