From c501fd0c0f96e09fa62e9c0d15c4f29c220bf75a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 Nov 2022 00:13:37 +0100 Subject: [PATCH] Derive generic wxSearchCtrl from only wxTextEntry too This is similar to the changes of 020b6ebcb8 (Derive from wxTextEntry instead of wxTextCtrlBase, 2019-12-29) for wxGTK and removes the methods that don't exist in the other ports from the generic wxSearchCtrl too. --- docs/changes.txt | 3 + include/wx/generic/srchctlg.h | 45 ------------- include/wx/srchctrl.h | 2 +- src/generic/srchctlg.cpp | 119 ---------------------------------- 4 files changed, 4 insertions(+), 165 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6418898b8f..6826adf924 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -46,6 +46,9 @@ Changes in behaviour which may result in build errors - wxMotif and wxGTK1 ports have been removed, please use wxWidgets 3.2 if you still need them. +- Generic wxSearchCtrl doesn't provide methods that make sense only for + multiline text controls any longer, for consistency with the other ports. + - wxOnAssert() overload taking wide character file name was removed. If you call it for any reason, please use one of the other overloads instead. diff --git a/include/wx/generic/srchctlg.h b/include/wx/generic/srchctlg.h index 3e5cfd2cff..b233962ecc 100644 --- a/include/wx/generic/srchctlg.h +++ b/include/wx/generic/srchctlg.h @@ -69,17 +69,8 @@ public: virtual wxString GetRange(long from, long to) const override; - virtual int GetLineLength(long lineNo) const override; - virtual wxString GetLineText(long lineNo) const override; - virtual int GetNumberOfLines() const override; - - virtual bool IsModified() const override; virtual bool IsEditable() const override; - // more readable flag testing methods - virtual bool IsSingleLine() const; - virtual bool IsMultiLine() const; - // If the return values from and to are the same, there is no selection. virtual void GetSelection(long* from, long* to) const override; @@ -95,14 +86,6 @@ public: virtual void Replace(long from, long to, const wxString& value) override; virtual void Remove(long from, long to) override; - // load/save the controls contents from/to the file - virtual bool LoadFile(const wxString& file); - virtual bool SaveFile(const wxString& file = wxEmptyString); - - // sets/clears the dirty flag - virtual void MarkDirty() override; - virtual void DiscardEdits() override; - // set the max number of characters which may be entered in a single line // text control virtual void SetMaxLength(unsigned long WXUNUSED(len)) override; @@ -116,31 +99,6 @@ public: // return true if anything has been inserted virtual bool EmulateKeyPress(const wxKeyEvent& event); - // text control under some platforms supports the text styles: these - // methods allow to apply the given text style to the given selection or to - // set/get the style which will be used for all appended text - virtual bool SetStyle(long start, long end, const wxTextAttr& style) override; - virtual bool GetStyle(long position, wxTextAttr& style) override; - virtual bool SetDefaultStyle(const wxTextAttr& style) override; - virtual const wxTextAttr& GetDefaultStyle() const override; - - // translate between the position (which is just an index in the text ctrl - // considering all its contents as a single strings) and (x, y) coordinates - // which represent column and line. - virtual long XYToPosition(long x, long y) const override; - virtual bool PositionToXY(long pos, long *x, long *y) const override; - - virtual void ShowPosition(long pos) override; - - // find the character at position given in pixels - // - // NB: pt is in device coords (not adjusted for the client area origin nor - // scrolling) - virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const override; - virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, - wxTextCoord *col, - wxTextCoord *row) const override; - // Clipboard operations virtual void Copy() override; virtual void Cut() override; @@ -189,9 +147,6 @@ protected: virtual void DoSetValue(const wxString& value, int flags) override; virtual wxString DoGetValue() const override; - virtual bool DoLoadFile(const wxString& file, int fileType) override; - virtual bool DoSaveFile(const wxString& file, int fileType) override; - // override the base class virtuals involved into geometry calculations virtual wxSize DoGetBestClientSize() const override; diff --git a/include/wx/srchctrl.h b/include/wx/srchctrl.h index 977057c0b2..25d3b58b69 100644 --- a/include/wx/srchctrl.h +++ b/include/wx/srchctrl.h @@ -25,7 +25,7 @@ class WXDLLIMPEXP_CORE wxSearchCtrlBaseBaseClass : public wxCompositeWindow< wxNavigationEnabled >, - public wxTextCtrlIface + public wxTextEntryBase { }; #elif defined(__WXMAC__) diff --git a/src/generic/srchctlg.cpp b/src/generic/srchctlg.cpp index 19cf47d5be..2211420444 100644 --- a/src/generic/srchctlg.cpp +++ b/src/generic/srchctlg.cpp @@ -71,16 +71,6 @@ public: wxTextCtrl::DoSetValue(value, flags); } - bool DoLoadFile(const wxString& file, int fileType) override - { - return wxTextCtrl::DoLoadFile(file, fileType); - } - - bool DoSaveFile(const wxString& file, int fileType) override - { - return wxTextCtrl::DoSaveFile(file, fileType); - } - protected: void OnText(wxCommandEvent& eventText) { @@ -561,38 +551,11 @@ wxString wxSearchCtrl::GetRange(long from, long to) const return m_text->GetRange(from, to); } -int wxSearchCtrl::GetLineLength(long lineNo) const -{ - return m_text->GetLineLength(lineNo); -} -wxString wxSearchCtrl::GetLineText(long lineNo) const -{ - return m_text->GetLineText(lineNo); -} -int wxSearchCtrl::GetNumberOfLines() const -{ - return m_text->GetNumberOfLines(); -} - -bool wxSearchCtrl::IsModified() const -{ - return m_text->IsModified(); -} bool wxSearchCtrl::IsEditable() const { return m_text->IsEditable(); } -// more readable flag testing methods -bool wxSearchCtrl::IsSingleLine() const -{ - return m_text->IsSingleLine(); -} -bool wxSearchCtrl::IsMultiLine() const -{ - return m_text->IsMultiLine(); -} - // If the return values from and to are the same, there is no selection. void wxSearchCtrl::GetSelection(long* from, long* to) const { @@ -621,26 +584,6 @@ void wxSearchCtrl::Remove(long from, long to) m_text->Remove(from, to); } -// load/save the controls contents from/to the file -bool wxSearchCtrl::LoadFile(const wxString& file) -{ - return m_text->LoadFile(file); -} -bool wxSearchCtrl::SaveFile(const wxString& file) -{ - return m_text->SaveFile(file); -} - -// sets/clears the dirty flag -void wxSearchCtrl::MarkDirty() -{ - m_text->MarkDirty(); -} -void wxSearchCtrl::DiscardEdits() -{ - m_text->DiscardEdits(); -} - // set the max number of characters which may be entered in a single line // text control void wxSearchCtrl::SetMaxLength(unsigned long len) @@ -666,58 +609,6 @@ bool wxSearchCtrl::EmulateKeyPress(const wxKeyEvent& event) return m_text->EmulateKeyPress(event); } -// text control under some platforms supports the text styles: these -// methods allow to apply the given text style to the given selection or to -// set/get the style which will be used for all appended text -bool wxSearchCtrl::SetStyle(long start, long end, const wxTextAttr& style) -{ - return m_text->SetStyle(start, end, style); -} -bool wxSearchCtrl::GetStyle(long position, wxTextAttr& style) -{ - return m_text->GetStyle(position, style); -} -bool wxSearchCtrl::SetDefaultStyle(const wxTextAttr& style) -{ - return m_text->SetDefaultStyle(style); -} -const wxTextAttr& wxSearchCtrl::GetDefaultStyle() const -{ - return m_text->GetDefaultStyle(); -} - -// translate between the position (which is just an index in the text ctrl -// considering all its contents as a single strings) and (x, y) coordinates -// which represent column and line. -long wxSearchCtrl::XYToPosition(long x, long y) const -{ - return m_text->XYToPosition(x, y); -} -bool wxSearchCtrl::PositionToXY(long pos, long *x, long *y) const -{ - return m_text->PositionToXY(pos, x, y); -} - -void wxSearchCtrl::ShowPosition(long pos) -{ - m_text->ShowPosition(pos); -} - -// find the character at position given in pixels -// -// NB: pt is in device coords (not adjusted for the client area origin nor -// scrolling) -wxTextCtrlHitTestResult wxSearchCtrl::HitTest(const wxPoint& pt, long *pos) const -{ - return m_text->HitTest(pt, pos); -} -wxTextCtrlHitTestResult wxSearchCtrl::HitTest(const wxPoint& pt, - wxTextCoord *col, - wxTextCoord *row) const -{ - return m_text->HitTest(pt, col, row); -} - // Clipboard operations void wxSearchCtrl::Copy() { @@ -909,16 +800,6 @@ void wxSearchCtrl::DoSetValue(const wxString& value, int flags) m_text->DoSetValue(value, flags); } -bool wxSearchCtrl::DoLoadFile(const wxString& file, int fileType) -{ - return m_text->DoLoadFile(file, fileType); -} - -bool wxSearchCtrl::DoSaveFile(const wxString& file, int fileType) -{ - return m_text->DoSaveFile(file, fileType); -} - bool wxSearchCtrl::ShouldInheritColours() const { return true;