]>
Commit | Line | Data |
---|---|---|
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 | wxSize wxButton::DoGetBestSize() const | |
27 | { | |
28 | if ( GetId() == wxID_HELP ) | |
29 | return wxSize( 18 , 18 ) ; | |
30 | ||
31 | wxSize sz = GetDefaultSize() ; | |
32 | ||
33 | wxRect r ; | |
34 | ||
35 | GetPeer()->GetBestRect(&r); | |
36 | ||
37 | if ( r.GetWidth() == 0 && r.GetHeight() == 0 ) | |
38 | { | |
39 | } | |
40 | sz.x = r.GetWidth(); | |
41 | sz.y = r.GetHeight(); | |
42 | ||
43 | int wBtn = 72; | |
44 | ||
45 | if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT)) | |
46 | sz.x = wBtn; | |
47 | ||
48 | return sz ; | |
49 | } | |
50 | ||
51 | wxSize wxButton::GetDefaultSize() | |
52 | { | |
53 | int wBtn = 72 ; | |
54 | int hBtn = 35 ; | |
55 | ||
56 | return wxSize(wBtn, hBtn); | |
57 | } | |
58 | ||
59 | @implementation wxUIButton | |
60 | ||
61 | + (void)initialize | |
62 | { | |
63 | static BOOL initialized = NO; | |
64 | if (!initialized) | |
65 | { | |
66 | initialized = YES; | |
67 | wxOSXIPhoneClassAddWXMethods( self ); | |
68 | } | |
69 | } | |
70 | ||
71 | - (int) intValue | |
72 | { | |
73 | return 0; | |
74 | } | |
75 | ||
76 | - (void) setIntValue: (int) v | |
77 | { | |
78 | } | |
79 | ||
80 | @end | |
81 | ||
82 | ||
83 | wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer, | |
84 | wxWindowMac* WXUNUSED(parent), | |
85 | wxWindowID id, | |
86 | const wxString& WXUNUSED(label), | |
87 | const wxPoint& pos, | |
88 | const wxSize& size, | |
89 | long WXUNUSED(style), | |
90 | long WXUNUSED(extraStyle)) | |
91 | { | |
92 | CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; | |
93 | UIButtonType buttonType = UIButtonTypeRoundedRect; | |
94 | ||
95 | if ( id == wxID_HELP ) | |
96 | { | |
97 | buttonType = UIButtonTypeInfoDark; | |
98 | } | |
99 | ||
100 | UIButton* v = [[UIButton buttonWithType:buttonType] retain]; | |
101 | v.frame = r; | |
102 | wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v ); | |
103 | return c; | |
104 | } | |
105 | ||
106 | void wxWidgetIPhoneImpl::SetDefaultButton( bool isDefault ) | |
107 | { | |
108 | } | |
109 | ||
110 | void wxWidgetIPhoneImpl::PerformClick() | |
111 | { | |
112 | } | |
113 | ||
114 | wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer, | |
115 | wxWindowMac* WXUNUSED(parent), | |
116 | wxWindowID WXUNUSED(id), | |
117 | const wxString& label, | |
118 | const wxPoint& pos, | |
119 | const wxSize& size, | |
120 | long WXUNUSED(style), | |
121 | long WXUNUSED(extraStyle)) | |
122 | { | |
123 | CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; | |
124 | wxUIButton* v = [[wxUIButton alloc] initWithFrame:r]; | |
125 | [v setTitle:wxCFStringRef( label).AsNSString() forState:UIControlStateNormal]; | |
126 | wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v ); | |
127 | return c; | |
128 | } |