]> git.saurik.com Git - wxWidgets.git/blame - src/osx/checkbox_osx.cpp
removed superfluous ;
[wxWidgets.git] / src / osx / checkbox_osx.cpp
CommitLineData
e53b3d16 1/////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/carbon/checkbox.cpp
e53b3d16
SC
3// Purpose: wxCheckBox
4// Author: Stefan Csomor
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id: checkbox.cpp 54129 2008-06-11 19:30:52Z SC $
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_CHECKBOX
15
16#include "wx/checkbox.h"
17#include "wx/osx/private.h"
18
19IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
20IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
21
22// Single check box item
23bool wxCheckBox::Create(wxWindow *parent,
24 wxWindowID id,
25 const wxString& label,
26 const wxPoint& pos,
27 const wxSize& size,
28 long style,
29 const wxValidator& validator,
30 const wxString& name)
31{
32 m_macIsUserPane = false ;
33
34 if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) )
35 return false;
36
37 m_labelOrig = m_label = label ;
38
39 m_peer = wxWidgetImpl::CreateCheckBox( this, parent, id, label, pos, size, style, GetExtraStyle() ) ;
40
41 MacPostControlCreate(pos, size) ;
42
43 return true;
44}
45
46
47void wxCheckBox::SetValue(bool val)
48{
49 if (val)
50 Set3StateValue(wxCHK_CHECKED);
51 else
52 Set3StateValue(wxCHK_UNCHECKED);
53}
54
55bool wxCheckBox::GetValue() const
56{
57 return (DoGet3StateValue() != 0);
58}
59
60void wxCheckBox::Command(wxCommandEvent & event)
61{
62 int state = event.GetInt();
63
64 wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED)
65 || (state == wxCHK_UNDETERMINED),
66 wxT("event.GetInt() returned an invalid checkbox state") );
67
68 Set3StateValue((wxCheckBoxState)state);
69
70 ProcessCommand(event);
71}
72
73wxCheckBoxState wxCheckBox::DoGet3StateValue() const
74{
75 return (wxCheckBoxState)m_peer->GetValue() ;
76}
77
78void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
79{
80 m_peer->SetValue( val ) ;
81}
82
03647350 83bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) )
e53b3d16 84{
524c47aa
SC
85 bool sendEvent = true;
86 wxCheckBoxState newState = Get3StateValue();
03647350 87
524c47aa 88 if ( !m_peer->ButtonClickDidStateChange() )
e53b3d16 89 {
524c47aa
SC
90 wxCheckBoxState origState ;
91
92 newState = origState = Get3StateValue();
93
94 switch (origState)
95 {
96 case wxCHK_UNCHECKED:
97 newState = wxCHK_CHECKED;
98 break;
99
100 case 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;
104 break;
105
106 case wxCHK_UNDETERMINED:
107 newState = wxCHK_UNCHECKED;
108 break;
109
110 default:
111 break;
112 }
113 if (newState == origState)
114 sendEvent = false;
e53b3d16
SC
115 }
116
524c47aa 117 if (sendEvent)
e53b3d16
SC
118 {
119 Set3StateValue( newState );
120
121 wxCommandEvent event( wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
122 event.SetInt( newState );
123 event.SetEventObject( this );
124 ProcessCommand( event );
125 }
126
127 return true;
128}
129
130// Bitmap checkbox
131bool wxBitmapCheckBox::Create(wxWindow *parent,
132 wxWindowID id,
133 const wxBitmap *WXUNUSED(label),
134 const wxPoint& WXUNUSED(pos),
135 const wxSize& WXUNUSED(size),
136 long style,
137 const wxValidator& wxVALIDATOR_PARAM(validator),
138 const wxString& name)
139{
140 SetName(name);
141#if wxUSE_VALIDATORS
142 SetValidator(validator);
143#endif
144 m_windowStyle = style;
145
146 if (parent)
147 parent->AddChild(this);
148
149 if ( id == -1 )
150 m_windowId = NewControlId();
151 else
152 m_windowId = id;
153
154 // TODO: Create the bitmap checkbox
155
156 return false;
157}
158
159void wxBitmapCheckBox::SetLabel(const wxBitmap *WXUNUSED(bitmap))
160{
161 // TODO
162 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
163}
164
165void wxBitmapCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags)
166{
167 wxControl::SetSize( x , y , width , height , sizeFlags ) ;
168}
169
170void wxBitmapCheckBox::SetValue(bool WXUNUSED(val))
171{
172 // TODO
173 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
174}
175
176bool wxBitmapCheckBox::GetValue() const
177{
178 // TODO
179 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));
180
181 return false;
182}
183
184#endif