From d1b190d4354c3a14378e50d27bb98043d62a8cd3 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 18 Apr 2008 07:57:03 +0000 Subject: [PATCH] Improve default size calc of wxComboBox git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53253 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/combobox.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 0ad836e685..6a7c62a604 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -431,25 +431,27 @@ GdkWindow *wxComboBox::GTKGetWindow(wxArrayGdkWindows& windows) const wxSize wxComboBox::DoGetBestSize() const { + // strangely, this returns a width of 188 pixels from GTK+ (?) wxSize ret( wxControl::DoGetBestSize() ); // we know better our horizontal extent: it depends on the longest string // in the combobox if ( m_widget ) { + ret.x = 60; // start with something "sensible" int width; unsigned int count = GetCount(); for ( unsigned int n = 0; n < count; n++ ) { GetTextExtent(GetString(n), &width, NULL, NULL, NULL ); - if ( width > ret.x ) - ret.x = width; + if ( width + 40 > ret.x ) // 40 for drop down arrow and space around text + ret.x = width + 40; } } // empty combobox should have some reasonable default size too - if ( ret.x < 100 ) - ret.x = 100; + if ((GetCount() == 0) && (ret.x < 80)) + ret.x = 80; CacheBestSize(ret); return ret; -- 2.45.2