1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/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::HandleClicked( double timestampsec
)
85 wxCheckBoxState origState
, newState
;
87 newState
= origState
= Get3StateValue();
92 newState
= wxCHK_CHECKED
;
96 // If the style flag to allow the user setting the undetermined state is set,
97 // then set the state to undetermined; otherwise set state to unchecked.
98 newState
= Is3rdStateAllowedForUser() ? wxCHK_UNDETERMINED
: wxCHK_UNCHECKED
;
101 case wxCHK_UNDETERMINED
:
102 newState
= wxCHK_UNCHECKED
;
109 if (newState
!= origState
)
111 Set3StateValue( newState
);
113 wxCommandEvent
event( wxEVT_COMMAND_CHECKBOX_CLICKED
, m_windowId
);
114 event
.SetInt( newState
);
115 event
.SetEventObject( this );
116 ProcessCommand( event
);
123 bool wxBitmapCheckBox::Create(wxWindow
*parent
,
125 const wxBitmap
*WXUNUSED(label
),
126 const wxPoint
& WXUNUSED(pos
),
127 const wxSize
& WXUNUSED(size
),
129 const wxValidator
& wxVALIDATOR_PARAM(validator
),
130 const wxString
& name
)
134 SetValidator(validator
);
136 m_windowStyle
= style
;
139 parent
->AddChild(this);
142 m_windowId
= NewControlId();
146 // TODO: Create the bitmap checkbox
151 void wxBitmapCheckBox::SetLabel(const wxBitmap
*WXUNUSED(bitmap
))
154 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
157 void wxBitmapCheckBox::SetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
159 wxControl::SetSize( x
, y
, width
, height
, sizeFlags
) ;
162 void wxBitmapCheckBox::SetValue(bool WXUNUSED(val
))
165 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
168 bool wxBitmapCheckBox::GetValue() const
171 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));