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.
This commit is contained in:
Vadim Zeitlin
2020-05-28 02:02:12 +02:00
parent 8189ce89ed
commit 316bbd2189

View File

@@ -278,26 +278,12 @@ wxSize wxSpinCtrlGenericBase::DoGetBestSize() const
wxSize wxSpinCtrlGenericBase::DoGetSizeFromTextSize(int xlen, int ylen) const wxSize wxSpinCtrlGenericBase::DoGetSizeFromTextSize(int xlen, int ylen) const
{ {
#ifdef __WXOSX__ const wxSize sizeBtn = m_spinButton->GetBestSize();
wxSize sizeBtn = m_spinButton->GetBestSize(), sizeText = m_textCtrl->GetSizeFromTextSize(xlen, ylen); const wxSize 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() );
wxSize tsize(xlen + sizeBtn.x + MARGIN, totalS.y); // Note that we don't use the button height here, as it can be
#if defined(__WXMSW__) // much greater than that of a text control that we want to resemble.
tsize.IncBy(4*totalS.y/10 + 4, 0); return wxSize(sizeText.x + sizeBtn.x + MARGIN, sizeText.y);
#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
} }
void wxSpinCtrlGenericBase::DoMoveWindow(int x, int y, int width, int height) void wxSpinCtrlGenericBase::DoMoveWindow(int x, int y, int width, int height)