]>
Commit | Line | Data |
---|---|---|
dbeddfb9 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: gauge.mm | |
3 | // Purpose: wxGauge class | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id: gauge.cpp 54820 2008-07-29 20:04:11Z SC $ | |
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 wxNSProgressIndicator : NSProgressIndicator | |
21 | { | |
dbeddfb9 SC |
22 | } |
23 | ||
dbeddfb9 SC |
24 | @end |
25 | ||
26 | @implementation wxNSProgressIndicator | |
27 | ||
4dd9fdf8 | 28 | + (void)initialize |
dbeddfb9 | 29 | { |
4dd9fdf8 SC |
30 | static BOOL initialized = NO; |
31 | if (!initialized) | |
32 | { | |
33 | initialized = YES; | |
34 | wxOSXCocoaClassAddWXMethods( self ); | |
35 | } | |
dbeddfb9 SC |
36 | } |
37 | ||
dbeddfb9 SC |
38 | @end |
39 | ||
40 | class wxOSXGaugeCocoaImpl : public wxWidgetCocoaImpl | |
41 | { | |
42 | public : | |
43 | wxOSXGaugeCocoaImpl( wxWindowMac* peer, WXWidget w) : wxWidgetCocoaImpl( peer, w ) | |
44 | { | |
45 | } | |
46 | ||
47 | void SetMaximum(wxInt32 v) | |
48 | { | |
49 | SetDeterminateMode(); | |
50 | wxWidgetCocoaImpl::SetMaximum( v ) ; | |
51 | } | |
52 | ||
53 | void SetValue(wxInt32 v) | |
54 | { | |
55 | SetDeterminateMode(); | |
56 | wxWidgetCocoaImpl::SetValue( v ) ; | |
57 | } | |
58 | ||
59 | void PulseGauge() | |
60 | { | |
61 | if ( ![(wxNSProgressIndicator*)m_osxView isIndeterminate] ) | |
62 | { | |
63 | [(wxNSProgressIndicator*)m_osxView setIndeterminate:YES]; | |
64 | [(wxNSProgressIndicator*)m_osxView startAnimation:nil]; | |
65 | } | |
66 | } | |
67 | protected: | |
68 | void SetDeterminateMode() | |
69 | { | |
70 | // switch back to determinate mode if necessary | |
71 | if ( [(wxNSProgressIndicator*)m_osxView isIndeterminate] ) | |
72 | { | |
73 | [(wxNSProgressIndicator*)m_osxView stopAnimation:nil]; | |
74 | [(wxNSProgressIndicator*)m_osxView setIndeterminate:NO]; | |
75 | } | |
76 | } | |
77 | }; | |
78 | ||
79 | ||
80 | wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer, | |
81 | wxWindowMac* parent, | |
82 | wxWindowID id, | |
83 | wxInt32 value, | |
84 | wxInt32 minimum, | |
85 | wxInt32 maximum, | |
86 | const wxPoint& pos, | |
87 | const wxSize& size, | |
88 | long style, | |
89 | long extraStyle) | |
90 | { | |
dbeddfb9 SC |
91 | NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; |
92 | wxNSProgressIndicator* v = [[wxNSProgressIndicator alloc] initWithFrame:r]; | |
93 | ||
94 | [v setMinValue: minimum]; | |
95 | [v setMaxValue: maximum]; | |
96 | [v setIndeterminate:FALSE]; | |
97 | [v setDoubleValue: (double) value]; | |
dbeddfb9 | 98 | wxWidgetCocoaImpl* c = new wxOSXGaugeCocoaImpl( wxpeer, v ); |
dbeddfb9 SC |
99 | return c; |
100 | } | |
101 | ||
102 | #endif // wxUSE_GAUGE | |
103 |