From d7d943a71cff6dda4888e7c5aa6a084d787ac843 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 8 Dec 2009 15:56:14 +0000 Subject: [PATCH] Implement wxWindow::DoGetBorderSize() in the trivial case of wxBORDER_NONE. This fixes an assert in wxGenericStaticText which overrode DoGetBestClientSize() but not DoGetBorderSize(). It would still be useful to implement DoGetBorderSize() in wxGTK (and other ports) in general too as using wxGenericStaticText with non-default border still doesn't work. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62820 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/window.h | 11 +++-------- src/common/wincmn.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/include/wx/window.h b/include/wx/window.h index 83660b0cf8..2e1eee3839 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -1671,14 +1671,9 @@ protected: // 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 new/temporary API only implemented by wxMSW and wxUniv so - // far and subject to change, don't use - virtual wxSize DoGetBorderSize() const - { - wxFAIL_MSG( "must be overridden if called" ); - - return wxDefaultSize; - } + // NB: this is currently only implemented by wxMSW and wxUniv so far and + // simply asserts 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 diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 5fbba53392..8cbef77168 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -722,6 +722,21 @@ wxSize wxWindowBase::GetEffectiveMinSize() const return min; } +wxSize wxWindowBase::DoGetBorderSize() const +{ + // there is one case in which we can implement it for all ports easily: + // do it as some classes used by both wxUniv and native ports (e.g. + // wxGenericStaticText) do override DoGetBestClientSize() and so this + // method must work for them and that ensures that it does, at least in + // the default case) + if ( GetBorder() == wxBORDER_NONE ) + return wxSize(0, 0); + + wxFAIL_MSG( "must be overridden if called" ); + + return wxDefaultSize; +} + wxSize wxWindowBase::GetBestSize() const { if ( !m_windowSizer && m_bestSizeCache.IsFullySpecified() ) -- 2.47.2