// Created: 08.02.01
// RCS-ID: $Id$
// Copyright: (c) 2000 Johnny C. Norris II
-// License: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
if (!cb->m_hasVMT || g_blockEventsOnDrag)
return;
- if (cb->m_blockEvent) return;
-
// Generate a wx event.
wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, cb->GetId());
event.SetInt(cb->GetValue());
}
}
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
+wxDEFINE_EVENT( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEvent );
// ------------------------------------------------------------------------
// wxBitmapToggleButton
const wxValidator& validator,
const wxString &name)
{
- m_blockEvent = false;
-
if (!PreCreation(parent, pos, size) ||
!CreateBase(parent, id, pos, size, style, validator, name ))
{
return true;
}
+void wxBitmapToggleButton::GTKDisableEvents()
+{
+ g_signal_handlers_block_by_func(m_widget,
+ (gpointer) gtk_togglebutton_clicked_callback, this);
+}
+
+void wxBitmapToggleButton::GTKEnableEvents()
+{
+ g_signal_handlers_unblock_by_func(m_widget,
+ (gpointer) gtk_togglebutton_clicked_callback, this);
+}
+
// void SetValue(bool state)
// Set the value of the toggle button.
void wxBitmapToggleButton::SetValue(bool state)
if (state == GetValue())
return;
- m_blockEvent = true;
+ GTKDisableEvents();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_widget), state);
- m_blockEvent = false;
+ GTKEnableEvents();
}
// bool GetValue() const
bool wxBitmapToggleButton::Enable(bool enable /*=true*/)
{
+ bool isEnabled = IsEnabled();
+
if (!wxControl::Enable(enable))
return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ if (!isEnabled && enable)
+ {
+ GTKFixSensitivity();
+ }
+
return true;
}
const wxValidator& validator,
const wxString &name)
{
- m_blockEvent = false;
-
if (!PreCreation(parent, pos, size) ||
!CreateBase(parent, id, pos, size, style, validator, name ))
{
return true;
}
+void wxToggleButton::GTKDisableEvents()
+{
+ g_signal_handlers_block_by_func(m_widget,
+ (gpointer) gtk_togglebutton_clicked_callback, this);
+}
+
+void wxToggleButton::GTKEnableEvents()
+{
+ g_signal_handlers_unblock_by_func(m_widget,
+ (gpointer) gtk_togglebutton_clicked_callback, this);
+}
+
// void SetValue(bool state)
// Set the value of the toggle button.
void wxToggleButton::SetValue(bool state)
if (state == GetValue())
return;
- m_blockEvent = true;
+ GTKDisableEvents();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_widget), state);
- m_blockEvent = false;
+ GTKEnableEvents();
}
// bool GetValue() const
gtk_button_set_label(GTK_BUTTON(m_widget), wxGTK_CONV(labelGTK));
- ApplyWidgetStyle( false );
+ GTKApplyWidgetStyle( false );
}
bool wxToggleButton::Enable(bool enable /*=true*/)
{
- if (!wxControl::Enable(enable))
+ if (!base_type::Enable(enable))
return false;
gtk_widget_set_sensitive(GTK_BIN(m_widget)->child, enable);
+ if (enable)
+ GTKFixSensitivity();
+
return true;
}