- m_needParent = TRUE;
-
- PreCreation( parent, id, pos, size, style, name );
-
- SetValidator( validator );
-
- m_widget = gtk_option_menu_new();
-
- wxSize newSize = size;
- if (newSize.x == -1) newSize.x = 80;
- if (newSize.y == -1) newSize.y = 26;
- SetSize( newSize.x, newSize.y );
-
- GtkWidget *menu = gtk_menu_new();
-
- for (int i = 0; i < n; i++)
- {
- GtkWidget *item = gtk_menu_item_new_with_label( choices[i] );
- gtk_signal_connect( GTK_OBJECT( item ), "activate",
- GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
-
- gtk_menu_append( GTK_MENU(menu), item );
-
- gtk_widget_show( item );
- gtk_widget_realize( item );
- gtk_widget_realize( GTK_BIN(item)->child );
- }
- gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
-
- PostCreation();
-
- SetBackgroundColour( parent->GetBackgroundColour() );
-
- Show( TRUE );
-
- return TRUE;
+ if (!PreCreation( parent, pos, size ) ||
+ !CreateBase( parent, id, pos, size, style, validator, name ))
+ {
+ wxFAIL_MSG( wxT("wxChoice creation failed") );
+ return false;
+ }
+
+ if ( IsSorted() )
+ {
+ // if our m_strings != NULL, Append() will check for it and insert
+ // items in the correct order
+ m_strings = new wxGtkCollatedArrayString;
+ }
+
+ m_widget = gtk_combo_box_new_text();
+ g_object_ref(m_widget);
+
+ Append(n, choices);
+
+ m_parent->DoAddChild( this );
+
+ PostCreation(size);
+
+ g_signal_connect_after (m_widget, "changed",
+ G_CALLBACK (gtk_choice_changed_callback), this);
+
+ return true;
+}
+
+wxChoice::~wxChoice()
+{
+ delete m_strings;
+}
+
+void wxChoice::SendSelectionChangedEvent(wxEventType evt_type)
+{
+ if (!m_hasVMT)
+ return;
+
+ if (GetSelection() == -1)
+ return;
+
+ wxCommandEvent event( evt_type, GetId() );
+
+ int n = GetSelection();
+ event.SetInt( n );
+ event.SetString( GetStringSelection() );
+ event.SetEventObject( this );
+ InitCommandEventWithItems( event, n );
+
+ HandleWindowEvent( event );