- wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
-
- 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)
- {
- if (child->data == selection->data) return count;
- count++;
- child = child->next;
- }
- }
-
- return -1;
-}
-
-wxString wxComboBox::GetString( int n ) const
-{
- wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid combobox") );
-
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- wxString str;
- GList *child = g_list_nth( GTK_LIST(list)->children, n );
- if (child)
- {
- GtkBin *bin = GTK_BIN( child->data );
- GtkLabel *label = GTK_LABEL( bin->child );
-#ifdef __WXGTK20__
- str = wxGTK_CONV_BACK( gtk_label_get_text(label) );
-#else
- str = wxString( label->label );
-#endif
- }
- else
- {
- wxFAIL_MSG( wxT("wxComboBox: wrong index") );
- }
-
- return str;
-}
-
-wxString wxComboBox::GetStringSelection() const
-{
- wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid combobox") );
-
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *selection = GTK_LIST(list)->selection;
- if (selection)
- {
- GtkBin *bin = GTK_BIN( selection->data );
- GtkLabel *label = GTK_LABEL( bin->child );
-#ifdef __WXGTK20__
- wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
-#else
- wxString tmp( label->label );
-#endif
- return tmp;
- }
-
- wxFAIL_MSG( wxT("wxComboBox: no selection") );
-
- return wxT("");
-}
-
-int wxComboBox::GetCount() const
-{
- wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") );
-
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *child = GTK_LIST(list)->children;
- int count = 0;
- while (child) { count++; child = child->next; }
- return count;
-}
-
-void wxComboBox::SetSelection( int n )
-{
- wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
-
- DisableEvents();
-
- GtkWidget *list = GTK_COMBO(m_widget)->list;
- gtk_list_unselect_item( GTK_LIST(list), m_prevSelection );
- gtk_list_select_item( GTK_LIST(list), n );
- m_prevSelection = n;