-IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl)
-
-bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value,
- const wxPoint& pos, const wxSize& size,
- int n, const wxString choices[],
- long style, const wxString& name )
-{
- m_needParent = TRUE;
-
- PreCreation( parent, id, pos, size, style, name );
-
- m_widget = gtk_combo_new();
-
- wxSize newSize = size;
- if (newSize.x == -1) newSize.x = 100;
- if (newSize.y == -1) newSize.y = 26;
- SetSize( newSize.x, newSize.y );
-
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- for (int i = 0; i < n; i++)
- {
- GtkWidget *list_item;
- list_item = gtk_list_item_new_with_label( choices[i] );
-
- gtk_signal_connect( GTK_OBJECT(list_item), "select",
- GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
-
- gtk_container_add( GTK_CONTAINER(list), list_item );
-
- gtk_widget_show( list_item );
- };
-
- PostCreation();
-
- if (!value.IsNull()) SetValue( value );
-
- Show( TRUE );
-
- return TRUE;
-};
-
-void wxComboBox::Clear(void)
-{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- gtk_list_clear_items( GTK_LIST(list), 0, Number() );
-};
-
-void wxComboBox::Append( const wxString &item )
-{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GtkWidget *list_item;
- list_item = gtk_list_item_new_with_label( item );
-
- gtk_signal_connect( GTK_OBJECT(list_item), "select",
- GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
-
- gtk_container_add( GTK_CONTAINER(list), list_item );
-
- gtk_widget_show( list_item );
-};
-
-void wxComboBox::Append( const wxString &WXUNUSED(item), char* WXUNUSED(clientData) )
-{
-};
-
-void wxComboBox::Delete( int n )
-{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- gtk_list_clear_items( GTK_LIST(list), n, n );
-};
-
-int wxComboBox::FindString( const wxString &item )
-{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *child = GTK_LIST(list)->children;
- int count = 0;
- while (child)
- {
- GtkBin *bin = GTK_BIN( child->data );
- GtkLabel *label = GTK_LABEL( bin->child );
- if (item == label->label) return count;
- count++;
- child = child->next;
- };
- return -1;
-};
-
-char* wxComboBox::GetClientData( int n )
-{
- wxNode *node = m_clientData.Nth( n );
- if (node) return (char*)node->Data();
- return NULL;
-};
-
-void wxComboBox::SetClientData( int n, char * clientData )
-{
- wxNode *node = m_clientData.Nth( n );
- if (node) node->SetData( (wxObject*) clientData );
-};
-
-int wxComboBox::GetSelection(void) const
-{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *selection = GTK_LIST(list)->selection;
- if (selection)
- {
- GList *child = GTK_LIST(list)->children;
- int count = 0;
- while (child)
+bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
+ const wxPoint& pos, const wxSize& size,
+ int n, const wxString choices[],
+ long style, const wxValidator& validator,
+ const wxString& name )
+{
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, validator, name ))
+ {
+ wxFAIL_MSG( wxT("wxComboBox creation failed") );
+ return false;
+ }
+
+ if (HasFlag(wxCB_SORT))
+ m_strings = new wxGtkCollatedArrayString();
+
+ GTKCreateComboBoxWidget();
+
+ if (HasFlag(wxBORDER_NONE))
+ {
+ // Doesn't seem to work
+ // g_object_set (m_widget, "has-frame", FALSE, NULL);
+ }
+
+ GtkEntry * const entry = GetEntry();
+
+ if ( entry )
+ {
+ // Set it up to trigger default item on enter key press
+ gtk_entry_set_activates_default( entry,
+ !HasFlag(wxTE_PROCESS_ENTER) );
+
+ gtk_editable_set_editable(GTK_EDITABLE(entry), true);
+ }
+
+ Append(n, choices);
+
+ m_parent->DoAddChild( this );
+
+ if ( entry )
+ m_focusWidget = GTK_WIDGET( entry );
+
+ PostCreation(size);
+
+ if ( entry )
+ {
+ if (style & wxCB_READONLY)
+ {
+ // this will assert and do nothing if the value is not in our list
+ // of strings which is the desired behaviour (for consistency with
+ // wxMSW and also because it doesn't make sense to have a string
+ // which is not a possible choice in a read-only combobox)
+ SetStringSelection(value);
+ gtk_editable_set_editable(GTK_EDITABLE(entry), false);
+ }
+ else // editable combobox
+ {
+ // any value is accepted, even if it's not in our list
+ gtk_entry_set_text( entry, wxGTK_CONV(value) );
+ }
+
+ g_signal_connect_after (entry, "changed",
+ G_CALLBACK (gtkcombobox_text_changed_callback), this);
+ }
+
+ g_signal_connect_after (m_widget, "changed",
+ G_CALLBACK (gtkcombobox_changed_callback), this);
+
+ if ( !gtk_check_version(2,10,0) )