Commit | Line | Data |
---|---|---|
7c798d00 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/osx/iphone/checkbox.mm | |
3 | // Purpose: wxCheckBox | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 2008-08-20 | |
7c798d00 SC |
7 | // Copyright: (c) Stefan Csomor |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | #include "wx/wxprec.h" | |
12 | ||
13 | #if wxUSE_CHECKBOX | |
14 | ||
15 | #include "wx/checkbox.h" | |
16 | #include "wx/osx/private.h" | |
17 | ||
18 | @interface wxUISwitch : UISwitch | |
19 | { | |
20 | } | |
21 | ||
22 | @end | |
23 | ||
24 | @implementation wxUISwitch | |
25 | ||
26 | + (void)initialize | |
27 | { | |
28 | static BOOL initialized = NO; | |
03647350 | 29 | if (!initialized) |
7c798d00 SC |
30 | { |
31 | initialized = YES; | |
32 | wxOSXIPhoneClassAddWXMethods( self ); | |
33 | } | |
34 | } | |
35 | ||
ffb317d4 | 36 | @end |
7c798d00 | 37 | |
ffb317d4 | 38 | class wxCheckBoxIPhoneImpl : public wxWidgetIPhoneImpl |
7c798d00 | 39 | { |
ffb317d4 SC |
40 | public: |
41 | wxCheckBoxIPhoneImpl(wxWindowMac *wxpeer, UISwitch *v) | |
42 | : wxWidgetIPhoneImpl(wxpeer, v) | |
43 | { | |
44 | m_control = v; | |
45 | } | |
46 | ||
47 | wxInt32 GetValue() const | |
48 | { | |
49 | return [m_control isOn] ? 1 : 0; | |
50 | } | |
51 | ||
52 | void SetValue( wxInt32 v ) | |
53 | { | |
54 | [m_control setOn:v != 0 animated:NO]; | |
55 | } | |
56 | private: | |
57 | UISwitch* m_control; | |
58 | }; | |
7c798d00 | 59 | |
03647350 VZ |
60 | wxWidgetImplType* wxWidgetImpl::CreateCheckBox( wxWindowMac* wxpeer, |
61 | wxWindowMac* WXUNUSED(parent), | |
62 | wxWindowID WXUNUSED(id), | |
7c798d00 | 63 | const wxString& WXUNUSED(label), |
03647350 | 64 | const wxPoint& pos, |
7c798d00 | 65 | const wxSize& size, |
03647350 VZ |
66 | long style, |
67 | long WXUNUSED(extraStyle)) | |
7c798d00 SC |
68 | { |
69 | CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; | |
70 | wxUISwitch* v = [[wxUISwitch alloc] initWithFrame:r]; | |
71 | ||
72 | // if (style & wxCHK_3STATE) | |
73 | // [v setAllowsMixedState:YES]; | |
03647350 | 74 | |
ffb317d4 | 75 | wxCheckBoxIPhoneImpl* c = new wxCheckBoxIPhoneImpl( wxpeer, v ); |
7c798d00 SC |
76 | return c; |
77 | } | |
78 | ||
79 | #endif |