+ wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice") );
+
+ // If you read this code once and you think you understand
+ // it, then you are very wrong. Robert Roebling.
+
+ GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
+ int count = 0;
+ GList *child = menu_shell->children;
+ while (child)
+ {
+ GtkBin *bin = GTK_BIN( child->data );
+ GtkLabel *label = (GtkLabel *) NULL;
+ if (bin->child) label = GTK_LABEL(bin->child);
+ if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
+
+ wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
+
+ if (string == wxString(label->label,*wxConvCurrent))
+ return count;
+
+ child = child->next;
+ count++;
+ }
+
+ return -1;
+}
+
+int wxChoice::GetSelection() const
+{
+ wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice") );
+
+ GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
+ int count = 0;
+ GList *child = menu_shell->children;
+ while (child)
+ {
+ GtkBin *bin = GTK_BIN( child->data );
+ if (!bin->child) return count;
+ child = child->next;
+ count++;
+ }
+
+ return -1;
+}
+
+void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) )
+{
+ wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
+
+ wxFAIL_MSG(wxT("not implemented"));
+}
+
+wxString wxChoice::GetString( int n ) const
+{
+ wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid choice") );
+
+ GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
+ int count = 0;
+ GList *child = menu_shell->children;
+ while (child)
+ {
+ GtkBin *bin = GTK_BIN( child->data );
+ if (count == n)
+ {
+ GtkLabel *label = (GtkLabel *) NULL;
+ if (bin->child) label = GTK_LABEL(bin->child);
+ if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
+
+ wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
+
+ return wxString(label->label,*wxConvCurrent);
+ }
+ child = child->next;
+ count++;
+ }
+
+ wxFAIL_MSG( wxT("wxChoice: invalid index in GetString()") );
+
+ return wxT("");