Refactor wxButton and wxToggleButton to derive from wxAnyButton.
[wxWidgets.git] / src / osx / iphone / button.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        src/osx/iphone/button.mm
3 // Purpose:     wxButton
4 // Author:      Stefan Csomor
5 // Modified by:
6 // Created:     1998-01-01
7 // RCS-ID:      $Id$
8 // Copyright:   (c) Stefan Csomor
9 // Licence:     wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #include "wx/button.h"
15
16 #ifndef WX_PRECOMP
17     #include "wx/panel.h"
18     #include "wx/toplevel.h"
19     #include "wx/dcclient.h"
20 #endif
21
22 #include "wx/stockitem.h"
23
24 #include "wx/osx/private.h"
25
26 @implementation wxUIButton
27
28 + (void)initialize
29 {
30     static BOOL initialized = NO;
31     if (!initialized)
32     {
33         initialized = YES;
34         wxOSXIPhoneClassAddWXMethods( self );
35     }
36 }
37
38 - (int) intValue
39 {
40     return 0;
41 }
42
43 - (void) setIntValue: (int) v
44 {
45 }
46
47 @end
48
49
50 wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
51                                     wxWindowMac* WXUNUSED(parent),
52                                     wxWindowID id,
53                                     const wxString& WXUNUSED(label),
54                                     const wxPoint& pos,
55                                     const wxSize& size,
56                                     long WXUNUSED(style),
57                                     long WXUNUSED(extraStyle))
58 {
59     CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
60     UIButtonType buttonType = UIButtonTypeRoundedRect;
61
62     if ( id == wxID_HELP )
63     {
64         buttonType = UIButtonTypeInfoDark;
65     }
66
67     UIButton* v = [[UIButton buttonWithType:buttonType] retain];
68     v.frame = r;
69     wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v );
70     return c;
71 }
72
73 void wxWidgetIPhoneImpl::SetDefaultButton( bool isDefault )
74 {
75 }
76
77 void wxWidgetIPhoneImpl::PerformClick()
78 {
79 }
80
81 wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer,
82                                     wxWindowMac* WXUNUSED(parent),
83                                     wxWindowID WXUNUSED(id),
84                                     const wxString& label,
85                                     const wxPoint& pos,
86                                     const wxSize& size,
87                                     long WXUNUSED(style),
88                                     long WXUNUSED(extraStyle))
89 {
90     CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
91     wxUIButton* v = [[wxUIButton alloc] initWithFrame:r];
92     [v setTitle:wxCFStringRef( label).AsNSString() forState:UIControlStateNormal];
93     wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v );
94     return c;
95 }