]> git.saurik.com Git - wxWidgets.git/blob - src/osx/iphone/gauge.mm
wxMessageBox off the main thread lost result 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 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #if wxUSE_GAUGE
14
15 #include "wx/gauge.h"
16
17 #include "wx/osx/private.h"
18
19 @interface wxUIProgressView : UIProgressView
20 {
21 }
22
23 @end
24
25 @implementation wxUIProgressView
26
27 + (void)initialize
28 {
29 static BOOL initialized = NO;
30 if (!initialized)
31 {
32 initialized = YES;
33 wxOSXIPhoneClassAddWXMethods( self );
34 }
35 }
36
37 @end
38
39 class wxOSXGaugeIPhoneImpl : public wxWidgetIPhoneImpl
40 {
41 public :
42 wxOSXGaugeIPhoneImpl( wxWindowMac* peer, WXWidget w) : wxWidgetIPhoneImpl( peer, w )
43 {
44 }
45
46 void SetMaximum(wxInt32 m)
47 {
48 wxUIProgressView* v = (wxUIProgressView*)GetWXWidget();
49 wxGauge* wxpeer = (wxGauge*) GetWXPeer();
50 SetDeterminateMode();
51 [v setProgress:(float) wxpeer->GetValue() / m];
52 [v setNeedsLayout];
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 [v setNeedsLayout];
62 }
63
64 void PulseGauge()
65 {
66 }
67 protected:
68 void SetDeterminateMode()
69 {
70 // switch back to determinate mode if necessary
71 }
72 };
73
74
75 wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
76 wxWindowMac* WXUNUSED(parent),
77 wxWindowID WXUNUSED(id),
78 wxInt32 value,
79 wxInt32 minimum,
80 wxInt32 maximum,
81 const wxPoint& pos,
82 const wxSize& size,
83 long WXUNUSED(style),
84 long WXUNUSED(extraStyle))
85 {
86 CGRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
87 wxUIProgressView* v = [[wxUIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleBar];
88 [v setFrame:r];
89 [v setProgressTintColor: [UIColor blackColor]];
90 [v setProgress:(float) value/maximum];
91
92 wxWidgetIPhoneImpl* c = new wxOSXGaugeIPhoneImpl( wxpeer, v );
93 return c;
94 }
95
96 #endif // wxUSE_GAUGE
97