m_needParent = TRUE;
m_acceptsFocus = TRUE;
- wxSize newSize( size );
- if (newSize.x == -1)
- newSize.x = 80;
- if (newSize.y == -1)
- newSize.y = 26;
- if (newSize.y > 30)
- newSize.y = 30;
-
- if (!PreCreation( parent, pos, newSize ) ||
+ if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
{
wxFAIL_MSG( wxT("wxComboBox creation failed") );
- return FALSE;
+ return FALSE;
}
m_widget = gtk_combo_new();
for (int i = 0; i < n; i++)
{
/* don't send first event, which GTK sends aways when
- inserting the first item */
+ inserting the first item */
m_alreadySent = TRUE;
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() );
gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ wxSize size_best( DoGetBestSize() );
+ wxSize new_size( size );
+ if (new_size.x == -1)
+ new_size.x = size_best.x;
+ if (new_size.y == -1)
+ new_size.y = size_best.y;
+ if (new_size.y > size_best.y)
+ new_size.y = size_best.y;
+ if ((new_size.x != size.x) || (new_size.y != size.y))
+ SetSize( new_size.x, new_size.y );
+
SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOW ) );
SetForegroundColour( parent->GetForegroundColour() );
- SetFont( parent->GetFont() );
Show( TRUE );
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
-#if (GTK_MINOR_VERSION > 0)
+#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
-#if (GTK_MINOR_VERSION > 0)
+#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
-#if (GTK_MINOR_VERSION > 0)
+#if defined(__WXGTK13__) || (GTK_MINOR_VERSION > 0)
gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
#else
gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
wxSize wxComboBox::DoGetBestSize() const
{
- return wxSize(100, 26);
+ wxSize ret( wxControl::DoGetBestSize() );
+
+ // 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;
}
#endif