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
) )
40 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
42 SInt16 maxValue
= 1 /* kControlCheckboxCheckedValue */;
43 if (style
& wxCHK_3STATE
)
45 maxValue
= 2 /* kControlCheckboxMixedValue */;
48 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , maxValue
,
49 kControlCheckBoxProc
, (long) this ) ;
51 MacPostControlCreate() ;
56 void wxCheckBox::SetValue(bool val
)
60 Set3StateValue(wxCHK_CHECKED
);
64 Set3StateValue(wxCHK_UNCHECKED
);
68 bool wxCheckBox::GetValue() const
70 return (DoGet3StateValue() != 0);
73 void wxCheckBox::Command (wxCommandEvent
& event
)
75 int state
= event
.GetInt();
77 wxCHECK_RET( (state
== wxCHK_UNCHECKED
) || (state
== wxCHK_CHECKED
)
78 || (state
== wxCHK_UNDETERMINED
),
79 wxT("event.GetInt() returned an invalid checkbox state") );
81 Set3StateValue((wxCheckBoxState
) state
);
83 ProcessCommand(event
);
86 wxCheckBoxState
wxCheckBox::DoGet3StateValue() const
88 return (wxCheckBoxState
) ::GetControl32BitValue( (ControlHandle
) m_macControl
);
91 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val
)
93 ::SetControl32BitValue( (ControlHandle
) m_macControl
, (int) val
) ;
97 void wxCheckBox::MacHandleControlClick( WXWidget
WXUNUSED(control
), wxInt16
WXUNUSED(controlpart
) , bool WXUNUSED(mouseStillDown
) )
99 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
100 wxCheckBoxState state
= Get3StateValue();
102 if (state
== wxCHK_UNCHECKED
)
104 state
= wxCHK_CHECKED
;
106 else if (state
== wxCHK_CHECKED
)
108 // If the style flag to allow the user setting the undetermined state
109 // is set, then set the state to undetermined. Otherwise set state to
111 if ( Is3rdStateAllowedForUser() )
113 state
= wxCHK_UNDETERMINED
;
117 state
= wxCHK_UNCHECKED
;
120 else if (state
== wxCHK_UNDETERMINED
)
122 state
= wxCHK_UNCHECKED
;
124 Set3StateValue(state
);
127 event
.SetEventObject(this);
128 ProcessCommand(event
);
132 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
,
133 const wxBitmap
*label
,
135 const wxSize
& size
, long style
,
136 const wxValidator
& validator
,
137 const wxString
& name
)
140 SetValidator(validator
);
141 m_windowStyle
= style
;
143 if (parent
) parent
->AddChild(this);
146 m_windowId
= NewControlId();
150 // TODO: Create the bitmap checkbox
155 void wxBitmapCheckBox::SetLabel(const wxBitmap
*bitmap
)
158 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
161 void wxBitmapCheckBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
163 wxControl::SetSize( x
, y
, width
, height
, sizeFlags
) ;
166 void wxBitmapCheckBox::SetValue(bool val
)
169 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
172 bool wxBitmapCheckBox::GetValue() const
175 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));