]> git.saurik.com Git - wxWidgets.git/blob - src/osx/iphone/checkbox.mm
Update version to 2.9.4 in version.bkl too and rebake everything.
[wxWidgets.git] / src / osx / iphone / checkbox.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/checkbox.mm
3 // Purpose: wxCheckBox
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 2008-08-20
7 // RCS-ID: $Id$
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
19 @interface wxUISwitch : UISwitch
20 {
21 }
22
23 @end
24
25 @implementation wxUISwitch
26
27 + (void)initialize
28 {
29 static BOOL initialized = NO;
30 if (!initialized)
31 {
32 initialized = YES;
33 wxOSXIPhoneClassAddWXMethods( self );
34 }
35 }
36
37 @end
38
39 class wxCheckBoxIPhoneImpl : public wxWidgetIPhoneImpl
40 {
41 public:
42 wxCheckBoxIPhoneImpl(wxWindowMac *wxpeer, UISwitch *v)
43 : wxWidgetIPhoneImpl(wxpeer, v)
44 {
45 m_control = v;
46 }
47
48 wxInt32 GetValue() const
49 {
50 return [m_control isOn] ? 1 : 0;
51 }
52
53 void SetValue( wxInt32 v )
54 {
55 [m_control setOn:v != 0 animated:NO];
56 }
57 private:
58 UISwitch* m_control;
59 };
60
61 wxWidgetImplType* wxWidgetImpl::CreateCheckBox( wxWindowMac* wxpeer,
62 wxWindowMac* WXUNUSED(parent),
63 wxWindowID WXUNUSED(id),
64 const wxString& WXUNUSED(label),
65 const wxPoint& pos,
66 const wxSize& size,
67 long style,
68 long WXUNUSED(extraStyle))
69 {
70 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
71 wxUISwitch* v = [[wxUISwitch alloc] initWithFrame:r];
72
73 // if (style & wxCHK_3STATE)
74 // [v setAllowsMixedState:YES];
75
76 wxCheckBoxIPhoneImpl* c = new wxCheckBoxIPhoneImpl( wxpeer, v );
77 return c;
78 }
79
80 #endif