X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/db434467a143a2c847c4bcfe987f0202c2d02bf2..84c5b38d579e140df28cfbb649587e8862148c89:/src/gtk1/combobox.cpp diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index eb10d33e38..023caa971e 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -111,7 +111,11 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, m_widget = gtk_combo_new(); // make it more useable - gtk_combo_set_use_arrows_always(GTK_COMBO(m_widget), TRUE); + gtk_combo_set_use_arrows_always( GTK_COMBO(m_widget), TRUE ); + + // and case-sensitive + gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE ); + GtkWidget *list = GTK_COMBO(m_widget)->list; @@ -138,8 +142,6 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, PostCreation(); - ApplyWidgetStyle(); - ConnectWidget( GTK_COMBO(m_widget)->button ); if (!value.IsNull()) SetValue( value ); @@ -579,6 +581,7 @@ void wxComboBox::OnChar( wxKeyEvent &event ) if ( FindString(value) == wxNOT_FOUND ) { Append(value); + SetStringSelection(value); // and generate the selected event for it wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, GetId() ); @@ -668,7 +671,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; }