-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();
-
- ConnectWidget( GTK_COMBO(m_widget)->button );
-
- 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 = gtk_list_item_new_with_label( item );
-
- if (m_hasOwnStyle)
- {
- GtkBin *bin = GTK_BIN( list_item );
- gtk_widget_set_style( bin->child,
- gtk_style_ref(
- gtk_widget_get_style( m_widget ) ) );
- }
-
- gtk_signal_connect( GTK_OBJECT(list_item), "select",
- GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
-
- m_clientData.Append( (wxObject*)clientData );
-
- gtk_container_add( GTK_CONTAINER(list), list_item );
-
- gtk_widget_show( list_item );
-}
-
-void wxComboBox::Delete( int n )
-{
- GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
-
- GList *child = g_list_nth( listbox->children, n );
-
- if (!child)
- {
- wxFAIL_MSG("wrong index");
- return;
- }
-
- GList *list = g_list_append( NULL, child->data );
- gtk_list_remove_items( listbox, list );
- g_list_free( list );
-
- wxNode *node = m_clientData.Nth( n );
- if (!node)
- {
- wxFAIL_MSG( "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
-{
- 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)
+wxComboBox::~wxComboBox()
+{
+ if (m_entry)
+ GTKDisconnect(m_entry);
+}
+
+void wxComboBox::Init()
+{
+ m_entry = NULL;
+}
+
+bool wxComboBox::Create( wxWindow *parent, wxWindowID id,
+ const wxString& value,
+ const wxPoint& pos, const wxSize& size,
+ const wxArrayString& choices,
+ long style, const wxValidator& validator,
+ const wxString& name )
+{
+ wxCArrayString chs(choices);
+
+ return Create( parent, id, value, pos, size, chs.GetCount(),
+ chs.GetStrings(), style, validator, name );
+}
+
+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);
+
+ GTKConnectInsertTextSignal(entry);
+ GTKConnectClipboardSignals(GTK_WIDGET(entry));
+ }
+
+ g_signal_connect_after (m_widget, "changed",
+ G_CALLBACK (gtkcombobox_changed_callback), this);
+
+#ifndef __WXGTK3__
+ if ( !gtk_check_version(2,10,0) )
+#endif