From f25d48fbd58367422145077a8c4efa069b254ecf Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 23 Feb 2021 23:12:43 -0800 Subject: [PATCH] Use a more accurate size for wxTimePickerCtrlGeneric See #19078 --- src/generic/timectrlg.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/generic/timectrlg.cpp b/src/generic/timectrlg.cpp index 2435eb9547..55eef40e8f 100644 --- a/src/generic/timectrlg.cpp +++ b/src/generic/timectrlg.cpp @@ -665,8 +665,14 @@ wxSize wxTimePickerCtrlGeneric::DoGetBestSize() const if ( !m_impl ) return Base::DoGetBestSize(); - wxSize size = m_impl->m_text->GetBestSize(); - size.x += m_impl->m_btn->GetBestSize().x + HMARGIN_TEXT_SPIN; + wxTextCtrl* const text = m_impl->m_text; + int w; + text->GetTextExtent(text->GetValue(), &w, NULL); + wxSize size(text->GetSizeFromTextSize(w + 1)); + + const wxSize sizeBtn(m_impl->m_btn->GetBestSize()); + size.y = wxMax(size.y, sizeBtn.y); + size.x += sizeBtn.x + HMARGIN_TEXT_SPIN; return size; }