- if (child->data == selection->data) return count;
- count++;
- child = child->next;
- };
- };
- return -1;
-};
-
-wxString wxComboBox::GetString( const int n ) const
-{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *child = g_list_nth( GTK_LIST(list)->children, n );
- if (child)
- {
- GtkBin *bin = GTK_BIN( child->data );
- GtkLabel *label = GTK_LABEL( bin->child );
- return label->label;
- };
- return "";
-};
-
-wxString wxComboBox::GetStringSelection(void) const
-{
- GtkWidget *list = GTK_COMBO(m_widget)->list;
-
- GList *selection = GTK_LIST(list)->selection;
- if (selection)
- {
- GtkBin *bin = GTK_BIN( selection->data );
- wxString tmp = GTK_LABEL( bin->child )->label;
- return tmp;
- };
- return "";
-};
+ GtkBin *bin = GTK_BIN( child->data );
+ GtkLabel *label = GTK_LABEL( bin->child );
+#ifdef __WXGTK20__
+ wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) );
+#else
+ wxString str( label->label );
+#endif
+ if (item == str)
+ return count;
+
+ count++;
+ child = child->next;
+ }
+
+ return wxNOT_FOUND;
+}
+
+int wxComboBox::GetSelection() const
+{
+ 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::Number() 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;
+}