X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c801d85f158c4cba50b588807daabdcbd0ed3853..275bf4c13ab7f4b041b0d5c78cfdece709800d14:/src/gtk1/choice.cpp diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index a7c5ff028b..ef374c13ad 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -15,41 +15,49 @@ #include "wx/choice.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxChoice //----------------------------------------------------------------------------- -void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), gpointer data ) +static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) { - wxChoice *choice = (wxChoice*)data; - wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId()); + if (!choice->HasVMT()) return; + if (g_blockEventsOnDrag) return; + + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() ); event.SetInt( choice->GetSelection() ); wxString tmp( choice->GetStringSelection() ); event.SetString( WXSTRINGCAST(tmp) ); event.SetEventObject(choice); - choice->ProcessEvent(event); + choice->GetEventHandler()->ProcessEvent(event); }; //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxWindow) +IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl) wxChoice::wxChoice(void) { }; -wxChoice::wxChoice( wxWindow *parent, const wxWindowID id, - const wxPoint &pos, const wxSize &size, - const int n, const wxString choices[], - const long style, const wxString &name ) +wxChoice::wxChoice( wxWindow *parent, wxWindowID id, + const wxPoint &pos, const wxSize &size, + int n, const wxString choices[], + long style, const wxString &name ) { Create( parent, id, pos, size, n, choices, style, name ); }; -bool wxChoice::Create( wxWindow *parent, const wxWindowID id, - const wxPoint &pos, const wxSize &size, - const int n, const wxString choices[], - const long style, const wxString &name ) +bool wxChoice::Create( wxWindow *parent, wxWindowID id, + const wxPoint &pos, const wxSize &size, + int n, const wxString choices[], + long style, const wxString &name ) { m_needParent = TRUE; @@ -103,8 +111,8 @@ void wxChoice::Clear(void) int wxChoice::FindString( const wxString &string ) const { - // If you read this code once and you think you undestand - // it, then you are very wrong. RR + // 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; @@ -112,7 +120,8 @@ int wxChoice::FindString( const wxString &string ) const while (child) { GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = GTK_LABEL(bin->child); + GtkLabel *label = NULL; + if (bin->child) label = GTK_LABEL(bin->child); if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); if (string == label->label) return count; child = child->next; @@ -141,7 +150,7 @@ int wxChoice::GetSelection(void) return -1; }; -wxString wxChoice::GetString( const int n ) const +wxString wxChoice::GetString( int n ) const { GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); int count = 0; @@ -151,7 +160,8 @@ wxString wxChoice::GetString( const int n ) const GtkBin *bin = GTK_BIN( child->data ); if (count == n) { - GtkLabel *label = GTK_LABEL(bin->child); + GtkLabel *label = NULL; + if (bin->child) label = GTK_LABEL(bin->child); if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); return label->label; }; @@ -180,14 +190,16 @@ int wxChoice::Number(void) const return count; }; -void wxChoice::SetColumns( const int WXUNUSED(n) ) +void wxChoice::SetColumns( int WXUNUSED(n) ) { }; -void wxChoice::SetSelection( const int n ) +void wxChoice::SetSelection( int n ) { int tmp = n; gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); + + gtk_choice_clicked_callback( NULL, this ); }; void wxChoice::SetStringSelection( const wxString &string )