1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/checkbox_osx.cpp
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/checkbox.h"
17 #include "wx/osx/private.h"
19 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
21 // Single check box item
22 bool wxCheckBox::Create(wxWindow
*parent
,
24 const wxString
& label
,
28 const wxValidator
& validator
,
33 if ( !wxCheckBoxBase::Create(parent
, id
, pos
, size
, style
, validator
, name
) )
36 m_labelOrig
= m_label
= label
;
38 WXValidateStyle( &style
);
39 SetPeer(wxWidgetImpl::CreateCheckBox( this, parent
, id
, label
, pos
, size
, style
, GetExtraStyle() )) ;
41 MacPostControlCreate(pos
, size
) ;
47 void wxCheckBox::SetValue(bool val
)
50 Set3StateValue(wxCHK_CHECKED
);
52 Set3StateValue(wxCHK_UNCHECKED
);
55 bool wxCheckBox::GetValue() const
57 return (DoGet3StateValue() != 0);
60 void wxCheckBox::Command(wxCommandEvent
& event
)
62 int state
= event
.GetInt();
64 wxCHECK_RET( (state
== wxCHK_UNCHECKED
) || (state
== wxCHK_CHECKED
)
65 || (state
== wxCHK_UNDETERMINED
),
66 wxT("event.GetInt() returned an invalid checkbox state") );
68 Set3StateValue((wxCheckBoxState
)state
);
70 ProcessCommand(event
);
73 wxCheckBoxState
wxCheckBox::DoGet3StateValue() const
75 return (wxCheckBoxState
)GetPeer()->GetValue() ;
78 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val
)
80 GetPeer()->SetValue( val
) ;
83 bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec
) )
85 bool sendEvent
= true;
86 wxCheckBoxState newState
= Get3StateValue();
88 if ( !GetPeer()->ButtonClickDidStateChange() )
90 wxCheckBoxState origState
;
92 newState
= origState
= Get3StateValue();
97 newState
= wxCHK_CHECKED
;
101 // If the style flag to allow the user setting the undetermined state is set,
102 // then set the state to undetermined; otherwise set state to unchecked.
103 newState
= Is3rdStateAllowedForUser() ? wxCHK_UNDETERMINED
: wxCHK_UNCHECKED
;
106 case wxCHK_UNDETERMINED
:
107 newState
= wxCHK_UNCHECKED
;
113 if (newState
== origState
)
119 Set3StateValue( newState
);
121 wxCommandEvent
event( wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
122 event
.SetInt( newState
);
123 event
.SetEventObject( this );
124 ProcessCommand( event
);
131 bool wxBitmapCheckBox::Create(wxWindow
*parent
,
133 const wxBitmap
*WXUNUSED(label
),
134 const wxPoint
& WXUNUSED(pos
),
135 const wxSize
& WXUNUSED(size
),
137 const wxValidator
& wxVALIDATOR_PARAM(validator
),
138 const wxString
& name
)
142 SetValidator(validator
);
144 m_windowStyle
= style
;
147 parent
->AddChild(this);
150 m_windowId
= NewControlId();
154 // TODO: Create the bitmap checkbox
159 void wxBitmapCheckBox::SetLabel(const wxBitmap
*WXUNUSED(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 WXUNUSED(val
))
173 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
176 bool wxBitmapCheckBox::GetValue() const
179 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));