X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f03fc89fff2d6e823e7d4d14fbe14822ad6777b1..866592d872daa1f4e3d44948d7d3a6c90b0af9d0:/src/gtk/checkbox.cpp diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index 258f26ac1a..af1d2592c3 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -14,6 +14,8 @@ #include "wx/checkbox.h" +#if wxUSE_CHECKBOX + #include "gdk/gdk.h" #include "gtk/gtk.h" @@ -38,13 +40,7 @@ static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckB { if (g_isIdle) wxapp_install_idle_handler(); - if (!cb->HasVMT()) return; - - if (cb->m_blockFirstEvent) - { - cb->m_blockFirstEvent = FALSE; - return; - } + if (!cb->m_hasVMT) return; if (g_blockEventsOnDrag) return; @@ -76,11 +72,13 @@ bool wxCheckBox::Create(wxWindow *parent, m_needParent = TRUE; m_acceptsFocus = TRUE; - PreCreation( parent, id, pos, size, style, name ); - - m_blockFirstEvent = FALSE; + if (!PreCreation( parent, pos, size ) || + !CreateBase( parent, id, pos, size, style, validator, name )) + { + wxFAIL_MSG( _T("wxCheckBox creation failed") ); + return FALSE; + } - SetValidator( validator ); wxControl::SetLabel( label ); if ( style & wxALIGN_RIGHT ) @@ -97,7 +95,6 @@ bool wxCheckBox::Create(wxWindow *parent, gtk_box_pack_start(GTK_BOX(m_widget), m_widgetLabel, FALSE, FALSE, 3); gtk_box_pack_start(GTK_BOX(m_widget), m_widgetCheckbox, FALSE, FALSE, 3); - // VZ: why do I have to do this to make them appear? gtk_widget_show( m_widgetLabel ); gtk_widget_show( m_widgetCheckbox ); } @@ -141,14 +138,19 @@ void wxCheckBox::SetValue( bool state ) { wxCHECK_RET( m_widgetCheckbox != NULL, _T("invalid checkbox") ); - if ( state == GetValue() ) + if (state == GetValue()) return; - // for compatibility with wxMSW don't send notification when the check box - // state is changed programmatically - m_blockFirstEvent = TRUE; + gtk_signal_disconnect_by_func( GTK_OBJECT(m_widgetCheckbox), + GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), + (gpointer *)this ); gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widgetCheckbox), state ); + + gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox), + "clicked", + GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), + (gpointer *)this ); } bool wxCheckBox::GetValue() const @@ -184,3 +186,4 @@ void wxCheckBox::ApplyWidgetStyle() gtk_widget_set_style( m_widgetLabel, m_widgetStyle ); } +#endif