-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 )
-{
- m_alreadySent = FALSE;
- m_needParent = TRUE;
-
- PreCreation( parent, id, pos, size, style, name );
-
- SetValidator( validator );
-
- 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_container_add( GTK_CONTAINER(list), list_item );
-
- m_clientData.Append( (wxObject*)NULL );
-
- gtk_widget_show( list_item );
-
- gtk_signal_connect( GTK_OBJECT(list_item), "select",
- GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
- }
-
- PostCreation();
-
-/*
- gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
- GTK_SIGNAL_FUNC(gtk_combo_size_callback), (gpointer)this );
-*/
-
- 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() );
-
- m_clientData.Clear();
-}
-
-void wxComboBox::Append( const wxString &item )
-{
- Append( item, (char*)NULL );
-}
-
-void wxComboBox::Append( const wxString &item, char *clientData )
-{
- 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 );
-
- m_clientData.Append( (wxObject*)clientData );
-}
-
-void wxComboBox::Delete( int n )
-{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- gtk_list_clear_items( GTK_LIST(list), n, n );
-
- wxNode *node = m_clientData.Nth( n );
- if (!node)
- {
- wxFAIL_MSG( "wxComboBox: wrong index" );
- }
- else
- m_clientData.DeleteNode( node );
-}
-
-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;
- }
-
- wxFAIL_MSG( "wxComboBox: string not found" );
-
- return -1;
-}
-
-char* wxComboBox::GetClientData( int n )
-{
- wxNode *node = m_clientData.Nth( n );
- if (node) return (char*)node->Data();
-
- wxFAIL_MSG( "wxComboBox: wrong index" );
-
- return (char *) NULL;
-}
-
-void wxComboBox::SetClientData( int n, char * clientData )
-{
- wxNode *node = m_clientData.Nth( n );
- if (node) node->SetData( (wxObject*) clientData );
-
- wxFAIL_MSG( "wxComboBox: wrong index" );
-}
-
-int wxComboBox::GetSelection(void) const
+ SetInitialSize(size); // need this too because this is a wxControlWithItems
+
+ return true;
+}
+
+GtkEntry *wxComboBox::GetEntry() const
+{
+ return GTK_ENTRY(GTK_BIN(m_widget)->child);
+}
+
+GtkEditable *wxComboBox::GetEditable() const
+{
+ return GTK_EDITABLE( GTK_BIN(m_widget)->child );
+}
+
+wxComboBox::~wxComboBox()
+{
+ Clear();
+
+ delete m_strings;
+}
+
+void wxComboBox::SetFocus()
+{
+ if ( m_hasFocus )
+ {
+ // don't do anything if we already have focus
+ return;
+ }
+
+ gtk_widget_grab_focus( m_focusWidget );
+}
+
+int wxComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
+ unsigned int pos,
+ void **clientData, wxClientDataType type)
+{
+ wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
+
+ wxASSERT_MSG( !IsSorted() || (pos == GetCount()),
+ _T("In a sorted combobox data could only be appended"));
+
+ const int count = items.GetCount();
+
+ int n = wxNOT_FOUND;
+
+ GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
+ for( int i = 0; i < count; ++i )
+ {
+ n = pos + i;
+ // If sorted, use this wxSortedArrayStrings to determine
+ // the right insertion point
+ if(m_strings)
+ n = m_strings->Add(items[i]);
+
+ gtk_combo_box_insert_text( combobox, n, wxGTK_CONV( items[i] ) );
+
+ m_clientData.Insert( NULL, n );
+ AssignNewItemClientData(n, clientData, i, type);
+ }
+
+ InvalidateBestSize();
+
+ return n;
+}
+
+void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
+{
+ m_clientData[n] = clientData;
+}
+
+void* wxComboBox::DoGetItemClientData(unsigned int n) const