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 SInt16 maxValue
= 1 /* kControlCheckboxCheckedValue */;
42 if (style
& wxCHK_3STATE
)
44 maxValue
= 2 /* kControlCheckboxMixedValue */;
48 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
49 m_macControl
= (WXWidget
) ::NewControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()) , &bounds
, "\p" , true , 0 , 0 , maxValue
,
50 kControlCheckBoxProc
, (long) this ) ;
52 MacPostControlCreate(pos
,size
) ;
57 void wxCheckBox::SetValue(bool val
)
61 Set3StateValue(wxCHK_CHECKED
);
65 Set3StateValue(wxCHK_UNCHECKED
);
69 bool wxCheckBox::GetValue() const
71 return (DoGet3StateValue() != 0);
74 void wxCheckBox::Command (wxCommandEvent
& event
)
76 int state
= event
.GetInt();
78 wxCHECK_RET( (state
== wxCHK_UNCHECKED
) || (state
== wxCHK_CHECKED
)
79 || (state
== wxCHK_UNDETERMINED
),
80 wxT("event.GetInt() returned an invalid checkbox state") );
82 Set3StateValue((wxCheckBoxState
) state
);
84 ProcessCommand(event
);
87 wxCheckBoxState
wxCheckBox::DoGet3StateValue() const
89 return (wxCheckBoxState
) ::GetControl32BitValue( (ControlRef
) m_macControl
);
92 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val
)
94 ::SetControl32BitValue( (ControlRef
) m_macControl
, (int) val
) ;
98 void wxCheckBox::MacHandleControlClick( WXWidget
WXUNUSED(control
), wxInt16
WXUNUSED(controlpart
) , bool WXUNUSED(mouseStillDown
) )
100 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
101 wxCheckBoxState state
= Get3StateValue();
103 if (state
== wxCHK_UNCHECKED
)
105 state
= wxCHK_CHECKED
;
107 else if (state
== wxCHK_CHECKED
)
109 // If the style flag to allow the user setting the undetermined state
110 // is set, then set the state to undetermined. Otherwise set state to
112 if ( Is3rdStateAllowedForUser() )
114 state
= wxCHK_UNDETERMINED
;
118 state
= wxCHK_UNCHECKED
;
121 else if (state
== wxCHK_UNDETERMINED
)
123 state
= wxCHK_UNCHECKED
;
125 Set3StateValue(state
);
128 event
.SetEventObject(this);
129 ProcessCommand(event
);
133 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
,
134 const wxBitmap
*label
,
136 const wxSize
& size
, long style
,
137 const wxValidator
& validator
,
138 const wxString
& name
)
141 SetValidator(validator
);
142 m_windowStyle
= style
;
144 if (parent
) parent
->AddChild(this);
147 m_windowId
= NewControlId();
151 // TODO: Create the bitmap checkbox
156 void wxBitmapCheckBox::SetLabel(const wxBitmap
*bitmap
)
159 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
162 void wxBitmapCheckBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
164 wxControl::SetSize( x
, y
, width
, height
, sizeFlags
) ;
167 void wxBitmapCheckBox::SetValue(bool val
)
170 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
173 bool wxBitmapCheckBox::GetValue() const
176 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));