#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;
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;
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;
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;
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;
};
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 )