1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "checkbox.h"
16 #include "wx/checkbox.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 void gtk_checkbox_clicked_callback( GtkWidget
*WXUNUSED(widget
), gpointer data
)
24 wxCheckBox
*cb
= (wxCheckBox
*)data
;
25 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, cb
->GetId());
26 event
.SetInt( cb
->GetValue() );
27 event
.SetEventObject(cb
);
28 cb
->ProcessEvent(event
);
31 //-----------------------------------------------------------------------------
33 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
,wxControl
)
35 wxCheckBox::wxCheckBox(void)
39 wxCheckBox::wxCheckBox( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
40 const wxPoint
&pos
, const wxSize
&size
,
41 long style
, const wxString
&name
)
43 Create( parent
, id
, label
, pos
, size
, style
, name
);
46 bool wxCheckBox::Create( wxWindow
*parent
, wxWindowID id
, const wxString
&label
,
47 const wxPoint
&pos
, const wxSize
&size
,
48 long style
, const wxString
&name
)
52 PreCreation( parent
, id
, pos
, size
, style
, name
);
54 m_widget
= gtk_check_button_new_with_label( label
);
56 wxSize newSize
= size
;
57 if (newSize
.x
== -1) newSize
.x
= 25+gdk_string_measure( m_widget
->style
->font
, label
);
58 if (newSize
.y
== -1) newSize
.y
= 26;
59 SetSize( newSize
.x
, newSize
.y
);
61 gtk_signal_connect( GTK_OBJECT(m_widget
), "clicked",
62 GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback
), (gpointer
*)this );
71 void wxCheckBox::SetValue( bool state
)
74 gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget
), GTK_STATE_ACTIVE
);
76 gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widget
), GTK_STATE_NORMAL
);
79 bool wxCheckBox::GetValue(void) const
81 GtkToggleButton
*tb
= GTK_TOGGLE_BUTTON(m_widget
);