1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "checkbox.h"
18 #include "wx/checkbox.h"
20 #if !USE_SHARED_LIBRARY
21 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
22 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
25 #include "wx/mac/uma.h"
27 // Single check box item
28 bool wxCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxString
& label
,
30 const wxSize
& size
, long style
,
31 const wxValidator
& validator
,
34 if ( !wxCheckBoxBase::Create(parent
, id
, pos
, size
, style
, validator
, name
) )
42 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
44 SInt16 maxValue
= 1 /* kControlCheckboxCheckedValue */;
45 if (style
& wxCHK_3STATE
)
47 maxValue
= 2 /* kControlCheckboxMixedValue */;
50 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , maxValue
,
51 kControlCheckBoxProc
, (long) this ) ;
53 MacPostControlCreate() ;
58 void wxCheckBox::SetValue(bool val
)
62 Set3StateValue(wxCHK_CHECKED
);
66 Set3StateValue(wxCHK_UNCHECKED
);
70 bool wxCheckBox::GetValue() const
72 return (DoGet3StateValue() != 0);
75 void wxCheckBox::Command (wxCommandEvent
& event
)
77 int state
= event
.GetInt();
79 wxCHECK_RET( (state
== wxCHK_UNCHECKED
) || (state
== wxCHK_CHECKED
)
80 || (state
== wxCHK_UNDETERMINED
),
81 wxT("event.GetInt() returned an invalid checkbox state") );
83 Set3StateValue((wxCheckBoxState
) state
);
85 ProcessCommand(event
);
88 wxCheckBoxState
wxCheckBox::DoGet3StateValue() const
90 return (wxCheckBoxState
) ::GetControl32BitValue( (ControlHandle
) m_macControl
);
93 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val
)
95 ::SetControl32BitValue( (ControlHandle
) m_macControl
, (int) val
) ;
99 void wxCheckBox::MacHandleControlClick( WXWidget
WXUNUSED(control
), wxInt16
WXUNUSED(controlpart
) , bool WXUNUSED(mouseStillDown
) )
101 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
102 wxCheckBoxState state
= Get3StateValue();
104 if (state
== wxCHK_UNCHECKED
)
106 state
= wxCHK_CHECKED
;
108 else if (state
== wxCHK_CHECKED
)
110 // If the style flag to allow the user setting the undetermined state
111 // is set, then set the state to undetermined. Otherwise set state to
113 if ( Is3rdStateAllowedForUser() )
115 state
= wxCHK_UNDETERMINED
;
119 state
= wxCHK_UNCHECKED
;
122 else if (state
== wxCHK_UNDETERMINED
)
124 state
= wxCHK_UNCHECKED
;
126 Set3StateValue(state
);
129 event
.SetEventObject(this);
130 ProcessCommand(event
);
134 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
,
135 const wxBitmap
*label
,
137 const wxSize
& size
, long style
,
138 const wxValidator
& validator
,
139 const wxString
& name
)
142 SetValidator(validator
);
143 m_windowStyle
= style
;
145 if (parent
) parent
->AddChild(this);
148 m_windowId
= NewControlId();
152 // TODO: Create the bitmap checkbox
157 void wxBitmapCheckBox::SetLabel(const wxBitmap
*bitmap
)
160 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
163 void wxBitmapCheckBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
165 wxControl::SetSize( x
, y
, width
, height
, sizeFlags
) ;
168 void wxBitmapCheckBox::SetValue(bool val
)
171 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
174 bool wxBitmapCheckBox::GetValue() const
177 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));