From 316bbd2189976c34699da69740e8ca2e82903d2b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 28 May 2020 02:02:12 +0200 Subject: [PATCH] Use the same code in generic wxSpinCtrl in all ports Use Mac version for the other ports too, instead of the weird hardcoded numbers introduced back in 40aa1a7e60 (Implement GetSizeFromTextSize() for wxSpinCtrl., 2012-11-20) which don't make much sense, as they use vertical text control size to determine the horizontal size of the spin control. Do not use the max of spin button height and text control height, however, as we really want to have the same height as just a normal text control. --- src/generic/spinctlg.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index 3b3ccf64d2..9e8e11bd2d 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -278,26 +278,12 @@ wxSize wxSpinCtrlGenericBase::DoGetBestSize() const wxSize wxSpinCtrlGenericBase::DoGetSizeFromTextSize(int xlen, int ylen) const { -#ifdef __WXOSX__ - wxSize sizeBtn = m_spinButton->GetBestSize(), sizeText = m_textCtrl->GetSizeFromTextSize(xlen, ylen); - return wxSize(sizeBtn.GetWidth() + sizeText.GetWidth() + MARGIN, wxMax(sizeBtn.GetHeight(), sizeText.GetHeight())); -#else - wxSize sizeBtn = m_spinButton->GetBestSize(); - wxSize totalS( m_textCtrl->GetBestSize() ); + const wxSize sizeBtn = m_spinButton->GetBestSize(); + const wxSize sizeText = m_textCtrl->GetSizeFromTextSize(xlen, ylen); - wxSize tsize(xlen + sizeBtn.x + MARGIN, totalS.y); -#if defined(__WXMSW__) - tsize.IncBy(4*totalS.y/10 + 4, 0); -#elif defined(__WXGTK__) - tsize.IncBy(totalS.y + 10, 0); -#endif // MSW GTK - - // Check if the user requested a non-standard height. - if ( ylen > 0 ) - tsize.IncBy(0, ylen - GetCharHeight()); - - return tsize; -#endif + // Note that we don't use the button height here, as it can be + // much greater than that of a text control that we want to resemble. + return wxSize(sizeText.x + sizeBtn.x + MARGIN, sizeText.y); } void wxSpinCtrlGenericBase::DoMoveWindow(int x, int y, int width, int height)