// Purpose: Definition of the wxToggleButton class, which implements a
// toggle button under wxGTK.
// Author: John Norris, minor changes by Axel Schlueter
// Purpose: Definition of the wxToggleButton class, which implements a
// toggle button under wxGTK.
// Author: John Norris, minor changes by Axel Schlueter
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
- if (g_isIdle)
- wxapp_install_idle_handler();
-
- 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());
- event.SetEventObject(cb);
- cb->GetEventHandler()->ProcessEvent(event);
+ if (g_isIdle)
+ wxapp_install_idle_handler();
+
+ 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());
+ event.SetEventObject(cb);
+ cb->GetEventHandler()->ProcessEvent(event);
+}
if (!PreCreation(parent, pos, size) ||
!CreateBase(parent, id, pos, size, style, validator, name ))
{
wxFAIL_MSG(wxT("wxToggleBitmapButton creation failed"));
if (!PreCreation(parent, pos, size) ||
!CreateBase(parent, id, pos, size, style, validator, name ))
{
wxFAIL_MSG(wxT("wxToggleBitmapButton creation failed"));
}
// void SetValue(bool state)
// Set the value of the toggle button.
void wxToggleBitmapButton::SetValue(bool state)
{
}
// void SetValue(bool state)
// Set the value of the toggle button.
void wxToggleBitmapButton::SetValue(bool state)
{
- SetWidgetStyle();
- gtk_widget_set_style(m_widget, m_widgetStyle);
- gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
+ gtk_widget_modify_style(m_widget, style);
+ gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
if (m_bitmap.Ok())
{
int border = HasFlag(wxNO_BORDER) ? 4 : 10;
best.x = m_bitmap.GetWidth()+border;
best.y = m_bitmap.GetHeight()+border;
}
if (m_bitmap.Ok())
{
int border = HasFlag(wxNO_BORDER) ? 4 : 10;
best.x = m_bitmap.GetWidth()+border;
best.y = m_bitmap.GetHeight()+border;
}
// ------------------------------------------------------------------------
// wxToggleButton
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// wxToggleButton
// ------------------------------------------------------------------------
- if (!PreCreation(parent, pos, size) ||
- !CreateBase(parent, id, pos, size, style, validator, name )) {
- wxFAIL_MSG(wxT("wxToggleButton creation failed"));
- return FALSE;
- }
- wxControl::SetLabel(label);
+ if (!PreCreation(parent, pos, size) ||
+ !CreateBase(parent, id, pos, size, style, validator, name )) {
+ wxFAIL_MSG(wxT("wxToggleButton creation failed"));
+ return false;
+ }
- gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
- GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
- (gpointer *)this);
+ // Create the gtk widget.
+ m_widget = gtk_toggle_button_new_with_label( wxGTK_CONV( m_label ) );
- m_parent->DoAddChild(this);
+ gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
+ GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
+ (gpointer *)this);
}
// void SetValue(bool state)
// Set the value of the toggle button.
void wxToggleButton::SetValue(bool state)
{
}
// void SetValue(bool state)
// Set the value of the toggle button.
void wxToggleButton::SetValue(bool state)
{
- SetWidgetStyle();
- gtk_widget_set_style(m_widget, m_widgetStyle);
- gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle);
+ gtk_widget_modify_style(m_widget, style);
+ gtk_widget_modify_style(BUTTON_CHILD(m_widget), style);
// Get the "best" size for this control.
wxSize wxToggleButton::DoGetBestSize() const
{
wxSize ret(wxControl::DoGetBestSize());
// Get the "best" size for this control.
wxSize wxToggleButton::DoGetBestSize() const
{
wxSize ret(wxControl::DoGetBestSize());