1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/checkbox.cpp
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: checkbox.cpp 54129 2008-06-11 19:30:52Z SC $
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(wxCheckBox
, wxControl
)
20 IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox
, wxCheckBox
)
22 // Single check box item
23 bool wxCheckBox::Create(wxWindow
*parent
,
25 const wxString
& label
,
29 const wxValidator
& validator
,
32 m_macIsUserPane
= false ;
34 if ( !wxCheckBoxBase::Create(parent
, id
, pos
, size
, style
, validator
, name
) )
37 m_labelOrig
= m_label
= label
;
39 m_peer
= 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
)m_peer
->GetValue() ;
78 void wxCheckBox::DoSet3StateValue(wxCheckBoxState val
)
80 m_peer
->SetValue( val
) ;
83 bool wxCheckBox::OSXHandleClicked( double timestampsec
)
85 bool sendEvent
= true;
86 wxCheckBoxState newState
= Get3StateValue();
88 if ( !m_peer
->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"));