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 m_macIsUserPane
= FALSE
;
36 if ( !wxCheckBoxBase::Create(parent
, id
, pos
, size
, style
, validator
, name
) )
41 SInt32 maxValue
= 1 /* kControlCheckboxCheckedValue */;
42 if (style
& wxCHK_3STATE
)
43 maxValue
= 2 /* kControlCheckboxMixedValue */;
45 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
46 verify_noerr( CreateCheckBoxControl(MAC_WXHWND(parent
->MacGetTopLevelWindowRef()), &bounds
,
47 CFSTR("") , 0 , false , (ControlRef
*) &m_macControl
) ) ;
49 SetControl32BitMaximum( (ControlRef
) m_macControl
, maxValue
) ;
51 MacPostControlCreate(pos
,size
) ;
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( (ControlRef
) m_macControl
);
91 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val
)
93 ::SetControl32BitValue( (ControlRef
) m_macControl
, (int) val
) ;
97 wxInt32
wxCheckBox::MacControlHit(WXEVENTHANDLERREF
WXUNUSED(handler
) , WXEVENTREF
WXUNUSED(event
) )
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
);
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"));