From 27d0e7804c0c4a3366e3c800a5475d05083fc290 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 24 Jul 2021 20:10:24 +0100 Subject: [PATCH] Replace DoGetBorderSize() with GetWindowBorderSize() We accidentally ended up with two functions doing the same thing, since DoGetBorderSize() was added in 743b426605 (Added DoGetClientBestSize() and use it for a couple of controls in wxMSW., 2009-06-22), as we already had GetWindowBorderSize() added even earlier in 333d70525c (added wxWindow::GetWindowBorderSize(), 2006-11-25), so remove the redundant non-public function and use GetWindowBorderSize() everywhere. This does change the behaviour of GetWindowBorderSize() in wxMSW, wxGTK and wxUniv, as it now does what DoGetBorderSize() used to do, but this should be an improvement, as DoGetBorderSize() implementation was more precise. --- docs/changes.txt | 3 +++ include/wx/gtk/window.h | 3 ++- include/wx/msw/window.h | 3 +-- include/wx/univ/window.h | 5 ++--- include/wx/window.h | 9 --------- src/common/wincmn.cpp | 18 +++--------------- src/gtk/window.cpp | 6 +++--- src/msw/listctrl.cpp | 2 +- src/msw/window.cpp | 2 +- src/propgrid/manager.cpp | 4 ++-- src/univ/winuniv.cpp | 2 +- 11 files changed, 19 insertions(+), 38 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index e92d92064d..b32ada7003 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -196,6 +196,9 @@ Changes in behaviour which may result in build errors - wxImage constructor from XPM data is now explicit, write "wxImage(xpmData)" instead of just "xpmData" if you really need to use it. +- wxWindow::DoGetBorderSize() was removed, if you used this non-public function + in your code, you can replace it with public GetWindowBorderSize(). + - Microsoft Visual Studio 2003 (a.k.a. MSVC 7) is not supported any longer, the minimum required version is now 2005. diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 1261931b22..53d2c88d57 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -76,6 +76,8 @@ public: virtual bool Reparent( wxWindowBase *newParent ) wxOVERRIDE; + virtual wxSize GetWindowBorderSize() const wxOVERRIDE; + virtual void WarpPointer(int x, int y) wxOVERRIDE; #ifdef __WXGTK3__ virtual bool EnableTouchEvents(int eventsMask) wxOVERRIDE; @@ -384,7 +386,6 @@ protected: int width, int height, int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; virtual void DoSetClientSize(int width, int height) wxOVERRIDE; - virtual wxSize DoGetBorderSize() const wxOVERRIDE; virtual void DoMoveWindow(int x, int y, int width, int height) wxOVERRIDE; virtual void DoEnable(bool enable) wxOVERRIDE; diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index 9e09786d9b..89218b5a67 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -102,6 +102,7 @@ public: virtual wxSize GetDPI() const wxOVERRIDE; virtual double GetDPIScaleFactor() const wxOVERRIDE; + virtual wxSize GetWindowBorderSize() const wxOVERRIDE; virtual void WarpPointer(int x, int y) wxOVERRIDE; virtual bool EnableTouchEvents(int eventsMask) wxOVERRIDE; @@ -654,8 +655,6 @@ protected: int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; virtual void DoSetClientSize(int width, int height) wxOVERRIDE; - virtual wxSize DoGetBorderSize() const wxOVERRIDE; - virtual void DoCaptureMouse() wxOVERRIDE; virtual void DoReleaseMouse() wxOVERRIDE; diff --git a/include/wx/univ/window.h b/include/wx/univ/window.h index b615c2a04f..5909cbcba6 100644 --- a/include/wx/univ/window.h +++ b/include/wx/univ/window.h @@ -197,6 +197,8 @@ public: return wxWindowNative::IsClientAreaChild(child); } + virtual wxSize GetWindowBorderSize() const wxOVERRIDE; + protected: // common part of all ctors void Init(); @@ -234,9 +236,6 @@ protected: // draw the controls contents virtual void DoDraw(wxControlRenderer *renderer); - // override the base class method to return the size of the window borders - virtual wxSize DoGetBorderSize() const wxOVERRIDE; - // adjust the size of the window to take into account its borders wxSize AdjustSize(const wxSize& size) const; diff --git a/include/wx/window.h b/include/wx/window.h index 393d71ba49..d8a00f199f 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -1909,15 +1909,6 @@ protected: int maxW, int maxH, int incW, int incH ); - // return the total size of the window borders, i.e. the sum of the widths - // of the left and the right border in the x component of the returned size - // and the sum of the heights of the top and bottom borders in the y one - // - // NB: this is currently only implemented properly for wxMSW, wxGTK and - // wxUniv and doesn't behave correctly in the presence of scrollbars in - // the other ports - virtual wxSize DoGetBorderSize() const; - // move the window to the specified location and resize it: this is called // from both DoSetSize() and DoSetClientSize() and would usually just // reposition this window except for composite controls which will want to diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index a851b371ce..880b0c1922 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -892,18 +892,6 @@ wxSize wxWindowBase::GetEffectiveMinSize() const return min; } -wxSize wxWindowBase::DoGetBorderSize() const -{ - // there is one case in which we can implement it for all ports easily - if ( GetBorder() == wxBORDER_NONE ) - return wxSize(0, 0); - - // otherwise use the difference between the real size and the client size - // as a fallback: notice that this is incorrect in general as client size - // also doesn't take the scrollbars into account - return GetSize() - GetClientSize(); -} - wxSize wxWindowBase::GetBestSize() const { if ( !m_windowSizer && m_bestSizeCache.IsFullySpecified() ) @@ -913,7 +901,7 @@ wxSize wxWindowBase::GetBestSize() const // it to be used wxSize size = DoGetBestClientSize(); if ( size != wxDefaultSize ) - size += DoGetBorderSize(); + size += GetWindowBorderSize(); else size = DoGetBestSize(); @@ -934,7 +922,7 @@ int wxWindowBase::GetBestHeight(int width) const return height == wxDefaultCoord ? GetBestSize().y - : height + DoGetBorderSize().y; + : height + GetWindowBorderSize().y; } int wxWindowBase::GetBestWidth(int height) const @@ -943,7 +931,7 @@ int wxWindowBase::GetBestWidth(int height) const return width == wxDefaultCoord ? GetBestSize().x - : width + DoGetBorderSize().x; + : width + GetWindowBorderSize().x; } void wxWindowBase::SetMinSize(const wxSize& minSize) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index d891c96423..ba59cb5cdd 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4021,7 +4021,7 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const } } - const wxSize sizeBorders = DoGetBorderSize(); + const wxSize sizeBorders = GetWindowBorderSize(); w -= sizeBorders.x; h -= sizeBorders.y; @@ -4035,10 +4035,10 @@ void wxWindowGTK::DoGetClientSize( int *width, int *height ) const if (height) *height = h; } -wxSize wxWindowGTK::DoGetBorderSize() const +wxSize wxWindowGTK::GetWindowBorderSize() const { if ( !m_wxwindow ) - return wxWindowBase::DoGetBorderSize(); + return wxWindowBase::GetWindowBorderSize(); GtkBorder border; WX_PIZZA(m_wxwindow)->get_border(border); diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index f48ad7e3e9..6b4be8208b 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1604,7 +1604,7 @@ wxSize wxListCtrl::MSWGetBestViewRect(int x, int y) const // OTOH we have to subtract the size of our borders because the base class // public method already adds them, but ListView_ApproximateViewRect() // already takes the borders into account, so this would be superfluous. - return size - DoGetBorderSize(); + return size - GetWindowBorderSize(); } // ---------------------------------------------------------------------------- diff --git a/src/msw/window.cpp b/src/msw/window.cpp index cba433d6be..4b96c2dec4 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2249,7 +2249,7 @@ void wxWindowMSW::DoSetClientSize(int width, int height) } } -wxSize wxWindowMSW::DoGetBorderSize() const +wxSize wxWindowMSW::GetWindowBorderSize() const { wxCoord border; switch ( GetBorder() ) diff --git a/src/propgrid/manager.cpp b/src/propgrid/manager.cpp index 82e5956088..2395c0b1d4 100644 --- a/src/propgrid/manager.cpp +++ b/src/propgrid/manager.cpp @@ -291,7 +291,7 @@ private: wxPropertyGrid* pg = m_manager->GetGrid(); // Internal border width - int borderWidth = pg->DoGetBorderSize().x / 2; + int borderWidth = pg->GetWindowBorderSize().x / 2; const unsigned int colCount = m_page->GetColumnCount(); for ( unsigned int i = 0; i < colCount; i++ ) @@ -327,7 +327,7 @@ private: wxPropertyGrid* pg = m_manager->GetGrid(); // Internal border width - int borderWidth = pg->DoGetBorderSize().x / 2; + int borderWidth = pg->GetWindowBorderSize().x / 2; // Compensate for the internal border int x = -borderWidth; diff --git a/src/univ/winuniv.cpp b/src/univ/winuniv.cpp index 83ba04057c..66fca70fc9 100644 --- a/src/univ/winuniv.cpp +++ b/src/univ/winuniv.cpp @@ -712,7 +712,7 @@ void wxWindow::OnSize(wxSizeEvent& event) #endif } -wxSize wxWindow::DoGetBorderSize() const +wxSize wxWindow::GetWindowBorderSize() const { return AdjustSize(wxSize(0, 0)); }