X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/db434467a143a2c847c4bcfe987f0202c2d02bf2..3d2b9c202d215ec220a7b2d62b28768ec7f40e44:/src/gtk1/combobox.cpp diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index eb10d33e38..40e9370a10 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -138,8 +138,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, PostCreation(); - ApplyWidgetStyle(); - ConnectWidget( GTK_COMBO(m_widget)->button ); if (!value.IsNull()) SetValue( value ); @@ -668,7 +666,27 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) wxSize wxComboBox::DoGetBestSize() const { wxSize ret( wxControl::DoGetBestSize() ); - if (ret.x < 100) ret.x = 100; + + // we know better our horizontal extent: it depends on the longest string + // in the combobox + ret.x = 0; + if ( m_widget ) + { + GdkFont *font = m_font.GetInternalFont(); + + wxCoord width; + size_t count = Number(); + for ( size_t n = 0; n < count; n++ ) + { + width = (wxCoord)gdk_string_width(font, GetString(n).mbc_str()); + if ( width > ret.x ) + ret.x = width; + } + } + + // empty combobox should have some reasonable default size too + if ( ret.x < 100 ) + ret.x = 100; return ret; }