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 wxCheckBoxBase::wxCheckBoxBase()
31 // Single check box item
32 bool wxCheckBox::Create(wxWindow
*parent
, wxWindowID id
, const wxString
& label
,
34 const wxSize
& size
, long style
,
35 const wxValidator
& validator
,
38 if ( !wxCheckBoxBase::Create(parent
, id
, pos
, size
, style
, validator
, name
) )
44 MacPreControlCreate( parent
, id
, label
, pos
, size
,style
, validator
, name
, &bounds
, title
) ;
46 SInt16 maxValue
= 1 /* kControlCheckboxCheckedValue */;
47 if (style
& wxCHK_3STATE
)
49 maxValue
= 2 /* kControlCheckboxMixedValue */;
52 m_macControl
= ::NewControl( MAC_WXHWND(parent
->MacGetRootWindow()) , &bounds
, title
, false , 0 , 0 , maxValue
,
53 kControlCheckBoxProc
, (long) this ) ;
55 MacPostControlCreate() ;
60 void wxCheckBox::SetValue(bool val
)
64 Set3StateValue(wxCHK_CHECKED
);
68 Set3StateValue(wxCHK_UNCHECKED
);
72 bool wxCheckBox::GetValue() const
74 return (DoGet3StateValue() != 0);
77 void wxCheckBox::Command (wxCommandEvent
& event
)
79 int state
= event
.GetInt();
81 wxCHECK_RET( (state
== wxCHK_UNCHECKED
) || (state
== wxCHK_CHECKED
)
82 || (state
== wxCHK_UNDETERMINED
),
83 wxT("event.GetInt() returned an invalid checkbox state") );
85 Set3StateValue((wxCheckBoxState
) state
);
87 ProcessCommand(event
);
90 wxCheckBoxState
wxCheckBox::DoGet3StateValue() const
92 return (wxCheckBoxState
) ::GetControl32BitValue( (ControlHandle
) m_macControl
);
95 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val
)
97 ::SetControl32BitValue( (ControlHandle
) m_macControl
, (int) val
) ;
101 void wxCheckBox::MacHandleControlClick( WXWidget
WXUNUSED(control
), wxInt16
WXUNUSED(controlpart
) , bool WXUNUSED(mouseStillDown
) )
103 wxCommandEvent
event(wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
104 wxCheckBoxState state
= Get3StateValue();
106 if (state
== wxCHK_UNCHECKED
)
108 state
= wxCHK_CHECKED
;
110 else if (state
== wxCHK_CHECKED
)
112 // If the style flag to allow the user setting the undetermined state
113 // is set, then set the state to undetermined. Otherwise set state to
115 if ( Is3rdStateAllowedForUser() )
117 state
= wxCHK_UNDETERMINED
;
121 state
= wxCHK_UNCHECKED
;
124 else if (state
== wxCHK_UNDETERMINED
)
126 state
= wxCHK_UNCHECKED
;
128 Set3StateValue(state
);
131 event
.SetEventObject(this);
132 ProcessCommand(event
);
136 bool wxBitmapCheckBox::Create(wxWindow
*parent
, wxWindowID id
,
137 const wxBitmap
*label
,
139 const wxSize
& size
, long style
,
140 const wxValidator
& validator
,
141 const wxString
& name
)
144 SetValidator(validator
);
145 m_windowStyle
= style
;
147 if (parent
) parent
->AddChild(this);
150 m_windowId
= NewControlId();
154 // TODO: Create the bitmap checkbox
159 void wxBitmapCheckBox::SetLabel(const wxBitmap
*bitmap
)
162 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
165 void wxBitmapCheckBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
167 wxControl::SetSize( x
, y
, width
, height
, sizeFlags
) ;
170 void wxBitmapCheckBox::SetValue(bool val
)
173 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
176 bool wxBitmapCheckBox::GetValue() const
179 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));