]> git.saurik.com Git - wxWidgets.git/blob - src/osx/iphone/gauge.mm
Test for NULL associated frame in doc/view event handling code.
[wxWidgets.git] / src / osx / iphone / gauge.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/iphone/gauge.mm
3 // Purpose: wxGauge class
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 #if wxUSE_GAUGE
15
16 #include "wx/gauge.h"
17
18 #include "wx/osx/private.h"
19
20 @interface wxUIProgressView : UIProgressView
21 {
22 }
23
24 @end
25
26 @implementation wxUIProgressView
27
28 + (void)initialize
29 {
30 static BOOL initialized = NO;
31 if (!initialized)
32 {
33 initialized = YES;
34 wxOSXIPhoneClassAddWXMethods( self );
35 }
36 }
37
38 @end
39
40 class wxOSXGaugeIPhoneImpl : public wxWidgetIPhoneImpl
41 {
42 public :
43 wxOSXGaugeIPhoneImpl( wxWindowMac* peer, WXWidget w) : wxWidgetIPhoneImpl( peer, w )
44 {
45 }
46
47 void SetMaximum(wxInt32 m)
48 {
49 wxUIProgressView* v = (wxUIProgressView*)GetWXWidget();
50 wxGauge* wxpeer = (wxGauge*) GetWXPeer();
51 SetDeterminateMode();
52 [v setProgress:(float) wxpeer->GetValue() / m];
53 }
54
55 void SetValue(wxInt32 n)
56 {
57 wxUIProgressView* v = (wxUIProgressView*)GetWXWidget();
58 wxGauge* wxpeer = (wxGauge*) GetWXPeer();
59 SetDeterminateMode();
60 [v setProgress:(float) n / wxpeer->GetRange()];
61 }
62
63 void PulseGauge()
64 {
65 }
66 protected:
67 void SetDeterminateMode()
68 {
69 // switch back to determinate mode if necessary
70 }
71 };
72
73
74 wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
75 wxWindowMac* WXUNUSED(parent),
76 wxWindowID WXUNUSED(id),
77 wxInt32 value,
78 wxInt32 minimum,
79 wxInt32 maximum,
80 const wxPoint& pos,
81 const wxSize& size,
82 long WXUNUSED(style),
83 long WXUNUSED(extraStyle))
84 {
85 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
86 wxUIProgressView* v = [[wxUIProgressView alloc] initWithFrame:r];
87 [v setProgress:(float) value/maximum];
88
89 wxWidgetIPhoneImpl* c = new wxOSXGaugeIPhoneImpl( wxpeer, v );
90 return c;
91 }
92
93 #endif // wxUSE_GAUGE
94