From 82735e86125c73a02807ba98f8080f6e2ded47e5 Mon Sep 17 00:00:00 2001 From: Scott Talbert Date: Wed, 1 Dec 2021 15:45:10 -0500 Subject: [PATCH] Use wxSpinCtrl best size in wxGenericCalendarCtrl::DoGetBestSize This fixes the wxGenericCalendarCtrl on wxGTK3 where the SpinCtrl is much wider than on other platforms and should also ensure that the control is always big enough in all locales under Mac. Closes https://github.com/wxWidgets/wxWidgets/pull/2604 Closes #11444. --- samples/calendar/calendar.cpp | 2 +- src/generic/calctrlg.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/calendar/calendar.cpp b/samples/calendar/calendar.cpp index b7ef65f823..a0904d4886 100644 --- a/samples/calendar/calendar.cpp +++ b/samples/calendar/calendar.cpp @@ -397,7 +397,7 @@ bool MyApp::OnInit() // Create the main application window MyFrame *frame = new MyFrame("Calendar wxWidgets sample" - ,wxPoint(50, 50), wxSize(450, 340) + ,wxPoint(50, 50), wxSize(460, 340) ); frame->Show(true); diff --git a/src/generic/calctrlg.cpp b/src/generic/calctrlg.cpp index 86410071b0..4432233091 100644 --- a/src/generic/calctrlg.cpp +++ b/src/generic/calctrlg.cpp @@ -690,11 +690,12 @@ wxSize wxGenericCalendarCtrl::DoGetBestSize() const if ( !HasFlag(wxCAL_SEQUENTIAL_MONTH_SELECTION) ) { const wxSize bestSizeCombo = m_comboMonth->GetBestSize(); + const wxSize bestSizeSpin = m_spinYear->GetBestSize(); - height += wxMax(bestSizeCombo.y, m_spinYear->GetBestSize().y) + height += wxMax(bestSizeCombo.y, bestSizeSpin.y) + VERT_MARGIN; - wxCoord w2 = bestSizeCombo.x + HORZ_MARGIN + GetCharWidth()*8; + wxCoord w2 = bestSizeCombo.x + HORZ_MARGIN + bestSizeSpin.x; if ( width < w2 ) width = w2; }