]> git.saurik.com Git - wxWidgets.git/blame - src/osx/iphone/button.mm
'Set to Unspecified' -> 'Set Value to Unspecified'
[wxWidgets.git] / src / osx / iphone / button.mm
CommitLineData
0c2dc57d
SC
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: button.cpp 54845 2008-07-30 14:52:41Z SC $
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
26wxSize wxButton::DoGetBestSize() const
27{
28 if ( GetId() == wxID_HELP )
29 return wxSize( 18 , 18 ) ;
30
31 wxSize sz = GetDefaultSize() ;
32
33 wxRect r ;
03647350 34
0c2dc57d
SC
35 m_peer->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;
03647350 44
0c2dc57d
SC
45 if ((wBtn > sz.x) || ( GetWindowStyle() & wxBU_EXACTFIT))
46 sz.x = wBtn;
47
48 return sz ;
49}
50
51wxSize 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;
03647350 64 if (!initialized)
0c2dc57d
SC
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
03647350
VZ
83wxWidgetImplType* wxWidgetImpl::CreateButton( wxWindowMac* wxpeer,
84 wxWindowMac* WXUNUSED(parent),
85 wxWindowID id,
0c2dc57d 86 const wxString& WXUNUSED(label),
03647350 87 const wxPoint& pos,
0c2dc57d 88 const wxSize& size,
03647350
VZ
89 long WXUNUSED(style),
90 long WXUNUSED(extraStyle))
0c2dc57d
SC
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 OSStatus err;
106 Rect bounds = wxMacGetBoundsForControl( wxpeer , pos , size ) ;
107 wxMacControl* peer = new wxMacControl(wxpeer) ;
108 if ( id == wxID_HELP )
109 {
110 ControlButtonContentInfo info ;
111 info.contentType = kControlContentIconRef ;
112 GetIconRef(kOnSystemDisk, kSystemIconsCreator, kHelpIcon, &info.u.iconRef);
113 err = CreateRoundButtonControl(
114 MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
115 &bounds, kControlRoundButtonNormalSize,
116 &info, peer->GetControlRefAddr() );
117 }
118 else if ( label.Find('\n' ) == wxNOT_FOUND && label.Find('\r' ) == wxNOT_FOUND)
119 {
120 // Button height is static in Mac, can't be changed, so we need to force it here
121 int maxHeight;
03647350 122 switch (wxpeer->GetWindowVariant() )
0c2dc57d
SC
123 {
124 case wxWINDOW_VARIANT_NORMAL:
125 case wxWINDOW_VARIANT_LARGE:
126 maxHeight = 20 ;
127 break;
128 case wxWINDOW_VARIANT_SMALL:
129 maxHeight = 17;
130 case wxWINDOW_VARIANT_MINI:
131 maxHeight = 15;
132 default:
133 break;
134 }
135 bounds.bottom = bounds.top + maxHeight ;
136 wxpeer->SetMaxSize( wxSize( wxpeer->GetMaxWidth() , maxHeight ));
137 err = CreatePushButtonControl(
138 MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
139 &bounds, CFSTR(""), peer->GetControlRefAddr() );
140 }
141 else
142 {
143 ControlButtonContentInfo info ;
144 info.contentType = kControlNoContent ;
145 err = CreateBevelButtonControl(
146 MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds, CFSTR(""),
147 kControlBevelButtonLargeBevel, kControlBehaviorPushbutton,
148 &info, 0, 0, 0, peer->GetControlRefAddr() );
149 }
150 verify_noerr( err );
151 return peer;
152 */
153}
154
155void wxWidgetIPhoneImpl::SetDefaultButton( bool isDefault )
03647350 156{
0c2dc57d
SC
157}
158
03647350 159void wxWidgetIPhoneImpl::PerformClick()
0c2dc57d
SC
160{
161}
162
03647350
VZ
163wxWidgetImplType* wxWidgetImpl::CreateDisclosureTriangle( wxWindowMac* wxpeer,
164 wxWindowMac* WXUNUSED(parent),
165 wxWindowID WXUNUSED(id),
0c2dc57d 166 const wxString& label,
03647350 167 const wxPoint& pos,
0c2dc57d 168 const wxSize& size,
03647350
VZ
169 long WXUNUSED(style),
170 long WXUNUSED(extraStyle))
0c2dc57d
SC
171{
172 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
173 wxUIButton* v = [[wxUIButton alloc] initWithFrame:r];
174 [v setTitle:wxCFStringRef( label).AsNSString() forState:UIControlStateNormal];
175 wxWidgetIPhoneImpl* c = new wxWidgetIPhoneImpl( wxpeer, v );
176 return c;
177}