From 34b5e560a9f6376c0da05e8b3b2f1d0870ff8639 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 6 Oct 2003 18:09:20 +0000 Subject: [PATCH] Implemented wxChoice::SetString() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24106 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/choice.cpp | 24 +++++++++++++++++++++++- src/gtk1/choice.cpp | 24 +++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 5874c0fd6a..6d72df1233 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -350,7 +350,29 @@ void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) ) { wxCHECK_RET( m_widget != NULL, wxT("invalid choice") ); - wxFAIL_MSG(wxT("not implemented")); + 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( BUTTON_CHILD(m_widget) ); + + wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); + + gtk_label_set_text( label, wxGTK_CONV( str ) ); + + return; + } + child = child->next; + count++; + } } wxString wxChoice::GetString( int n ) const diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index 5874c0fd6a..6d72df1233 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -350,7 +350,29 @@ void wxChoice::SetString( int WXUNUSED(n), const wxString& WXUNUSED(string) ) { wxCHECK_RET( m_widget != NULL, wxT("invalid choice") ); - wxFAIL_MSG(wxT("not implemented")); + 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( BUTTON_CHILD(m_widget) ); + + wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); + + gtk_label_set_text( label, wxGTK_CONV( str ) ); + + return; + } + child = child->next; + count++; + } } wxString wxChoice::GetString( int n ) const -- 2.45.2