1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/checkbox.h"
16 IMPLEMENT_DYNAMIC_CLASS(wxCheckBox
, wxControl
)
17 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
19 #include "wx/mac/uma.h"
21 // Single check box item
22 bool wxCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxString
& label
,
24 const wxSize
& size
, long style
,
25 const wxValidator
& validator
,
28 if ( !wxCheckBoxBase::Create(parent
, id
, pos
, size
, style
, validator
, name
) )
34 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
36 SInt16 maxValue
= 1 /* kControlCheckboxCheckedValue */;
37 if (style
& wxCHK_3STATE
)
39 maxValue
= 2 /* kControlCheckboxMixedValue */;
42 m_macControl
= (WXWidget
) ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , maxValue
,
43 kControlCheckBoxProc
, (long) this ) ;
45 MacPostControlCreate() ;
50 void wxCheckBox::SetValue(bool val
)
54 Set3StateValue(wxCHK_CHECKED
);
58 Set3StateValue(wxCHK_UNCHECKED
);
62 bool wxCheckBox::GetValue() const
64 return (DoGet3StateValue() != 0);
67 void wxCheckBox::Command (wxCommandEvent
& event
)
69 int state
= event
.GetInt();
71 wxCHECK_RET( (state
== wxCHK_UNCHECKED
) || (state
== wxCHK_CHECKED
)
72 || (state
== wxCHK_UNDETERMINED
),
73 wxT("event.GetInt() returned an invalid checkbox state") );
75 Set3StateValue((wxCheckBoxState
) state
);
77 ProcessCommand(event
);
80 wxCheckBoxState
wxCheckBox::DoGet3StateValue() const
82 return (wxCheckBoxState
) ::GetControl32BitValue( (ControlHandle
) m_macControl
);
85 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val
)
87 ::SetControl32BitValue( (ControlHandle
) m_macControl
, (int) val
) ;
91 void wxCheckBox::MacHandleControlClick( WXWidget
WXUNUSED(control
), wxInt16
WXUNUSED(controlpart
) , bool WXUNUSED(mouseStillDown
) )
93 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
94 wxCheckBoxState state
= Get3StateValue();
96 if (state
== wxCHK_UNCHECKED
)
98 state
= wxCHK_CHECKED
;
100 else if (state
== wxCHK_CHECKED
)
102 // If the style flag to allow the user setting the undetermined state
103 // is set, then set the state to undetermined. Otherwise set state to
105 if ( Is3rdStateAllowedForUser() )
107 state
= wxCHK_UNDETERMINED
;
111 state
= wxCHK_UNCHECKED
;
114 else if (state
== wxCHK_UNDETERMINED
)
116 state
= wxCHK_UNCHECKED
;
118 Set3StateValue(state
);
121 event
.SetEventObject(this);
122 ProcessCommand(event
);
126 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
,
127 const wxBitmap
*label
,
129 const wxSize
& size
, long style
,
130 const wxValidator
& validator
,
131 const wxString
& name
)
134 SetValidator(validator
);
135 m_windowStyle
= style
;
137 if (parent
) parent
->AddChild(this);
140 m_windowId
= NewControlId();
144 // TODO: Create the bitmap checkbox
149 void wxBitmapCheckBox::SetLabel(const wxBitmap
*bitmap
)
152 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
155 void wxBitmapCheckBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
157 wxControl::SetSize( x
, y
, width
, height
, sizeFlags
) ;
160 void wxBitmapCheckBox::SetValue(bool val
)
163 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
166 bool wxBitmapCheckBox::GetValue() const
169 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));