]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/checkbox.cpp
Fixed GetIcon to keep up with return type change on all other platforms.
[wxWidgets.git] / src / mac / carbon / checkbox.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: checkbox.cpp
3// Purpose: wxCheckBox
a31a5f85 4// Author: Stefan Csomor
e9576ca5
SC
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
a8e9860d 12#include "wx/wxprec.h"
d8c736e5 13
179e085f
RN
14#if wxUSE_CHECKBOX
15
e9576ca5
SC
16#include "wx/checkbox.h"
17
e9576ca5
SC
18IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
19IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
e9576ca5 20
d497dca4 21#include "wx/mac/uma.h"
519cb848 22
e9576ca5
SC
23// Single check box item
24bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
25 const wxPoint& pos,
26 const wxSize& size, long style,
27 const wxValidator& validator,
28 const wxString& name)
29{
facd6764
SC
30 m_macIsUserPane = FALSE ;
31
b45ed7a2
VZ
32 if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) )
33 return false;
34
facd6764 35 m_label = label ;
e9576ca5 36
4c37f124 37 SInt32 maxValue = 1 /* kControlCheckboxCheckedValue */;
9c9ceb48 38 if (style & wxCHK_3STATE)
8941fa88 39 maxValue = 2 /* kControlCheckboxMixedValue */;
facd6764
SC
40
41 Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
b905d6cc 42 m_peer = new wxMacControl(this) ;
4c37f124 43 verify_noerr( CreateCheckBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds ,
5ca0d812 44 CFSTR("") , 0 , false , m_peer->GetControlRefAddr() ) );
21fd5529
SC
45
46 m_peer->SetMaximum( maxValue ) ;
e40298d5 47
facd6764 48 MacPostControlCreate(pos,size) ;
e9576ca5 49
519cb848 50 return TRUE;
e9576ca5
SC
51}
52
53void wxCheckBox::SetValue(bool val)
54{
8941fa88
VZ
55 if (val)
56 {
57 Set3StateValue(wxCHK_CHECKED);
58 }
59 else
60 {
61 Set3StateValue(wxCHK_UNCHECKED);
62 }
e9576ca5
SC
63}
64
65bool wxCheckBox::GetValue() const
66{
8941fa88 67 return (DoGet3StateValue() != 0);
e9576ca5
SC
68}
69
70void wxCheckBox::Command (wxCommandEvent & event)
71{
8941fa88
VZ
72 int state = event.GetInt();
73
74 wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED)
75 || (state == wxCHK_UNDETERMINED),
76 wxT("event.GetInt() returned an invalid checkbox state") );
77
78 Set3StateValue((wxCheckBoxState) state);
79
80 ProcessCommand(event);
81}
82
83wxCheckBoxState wxCheckBox::DoGet3StateValue() const
84{
21fd5529 85 return (wxCheckBoxState) m_peer->GetValue() ;
8941fa88
VZ
86}
87
88void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
89{
21fd5529 90 m_peer->SetValue( val ) ;
e9576ca5
SC
91}
92
4c37f124 93wxInt32 wxCheckBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
519cb848 94{
8208e181 95 wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
8941fa88
VZ
96 wxCheckBoxState state = Get3StateValue();
97
98 if (state == wxCHK_UNCHECKED)
99 {
100 state = wxCHK_CHECKED;
101 }
102 else if (state == wxCHK_CHECKED)
103 {
104 // If the style flag to allow the user setting the undetermined state
105 // is set, then set the state to undetermined. Otherwise set state to
106 // unchecked.
107 if ( Is3rdStateAllowedForUser() )
108 {
109 state = wxCHK_UNDETERMINED;
110 }
111 else
112 {
113 state = wxCHK_UNCHECKED;
114 }
115 }
116 else if (state == wxCHK_UNDETERMINED)
117 {
118 state = wxCHK_UNCHECKED;
119 }
4c37f124 120 Set3StateValue(state);
8941fa88
VZ
121
122 event.SetInt(state);
8208e181
SC
123 event.SetEventObject(this);
124 ProcessCommand(event);
4c37f124
SC
125
126 return noErr ;
519cb848
SC
127}
128
e9576ca5 129// Bitmap checkbox
f2af4afb
GD
130bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id,
131 const wxBitmap *label,
132 const wxPoint& pos,
133 const wxSize& size, long style,
134 const wxValidator& validator,
135 const wxString& name)
e9576ca5
SC
136{
137 SetName(name);
138 SetValidator(validator);
139 m_windowStyle = style;
140
141 if (parent) parent->AddChild(this);
142
143 if ( id == -1 )
144 m_windowId = NewControlId();
145 else
146 m_windowId = id;
147
148 // TODO: Create the bitmap checkbox
149
150 return FALSE;
151}
152
153void wxBitmapCheckBox::SetLabel(const wxBitmap *bitmap)
154{
155 // TODO
0c32c930 156 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
e9576ca5
SC
157}
158
159void wxBitmapCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags)
160{
519cb848 161 wxControl::SetSize( x , y , width , height , sizeFlags ) ;
e9576ca5
SC
162}
163
164void wxBitmapCheckBox::SetValue(bool val)
165{
166 // TODO
0c32c930 167 wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
e9576ca5
SC
168}
169
170bool wxBitmapCheckBox::GetValue() const
171{
0c32c930
GD
172 // TODO
173 wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));
e9576ca5
SC
174 return FALSE;
175}
176
179e085f 177#endif