]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/gauge.mm
Move body of SetMinSize and SetMaxSize from header to cpp file for easier debugging...
[wxWidgets.git] / src / osx / cocoa / gauge.mm
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 {
22 WXCOCOAIMPL_COMMON_MEMBERS
23 }
24
25 WXCOCOAIMPL_COMMON_INTERFACE
26
27 @end
28
29 @implementation wxNSProgressIndicator
30
31 - (id)initWithFrame:(NSRect)frame
32 {
33 [super initWithFrame:frame];
34 impl = NULL;
35 return self;
36 }
37
38 WXCOCOAIMPL_COMMON_IMPLEMENTATION
39
40 @end
41
42 class wxOSXGaugeCocoaImpl : public wxWidgetCocoaImpl
43 {
44 public :
45 wxOSXGaugeCocoaImpl( wxWindowMac* peer, WXWidget w) : wxWidgetCocoaImpl( peer, w )
46 {
47 }
48
49 void SetMaximum(wxInt32 v)
50 {
51 SetDeterminateMode();
52 wxWidgetCocoaImpl::SetMaximum( v ) ;
53 }
54
55 void SetValue(wxInt32 v)
56 {
57 SetDeterminateMode();
58 wxWidgetCocoaImpl::SetValue( v ) ;
59 }
60
61 void PulseGauge()
62 {
63 if ( ![(wxNSProgressIndicator*)m_osxView isIndeterminate] )
64 {
65 [(wxNSProgressIndicator*)m_osxView setIndeterminate:YES];
66 [(wxNSProgressIndicator*)m_osxView startAnimation:nil];
67 }
68 }
69 protected:
70 void SetDeterminateMode()
71 {
72 // switch back to determinate mode if necessary
73 if ( [(wxNSProgressIndicator*)m_osxView isIndeterminate] )
74 {
75 [(wxNSProgressIndicator*)m_osxView stopAnimation:nil];
76 [(wxNSProgressIndicator*)m_osxView setIndeterminate:NO];
77 }
78 }
79 };
80
81
82 wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
83 wxWindowMac* parent,
84 wxWindowID id,
85 wxInt32 value,
86 wxInt32 minimum,
87 wxInt32 maximum,
88 const wxPoint& pos,
89 const wxSize& size,
90 long style,
91 long extraStyle)
92 {
93 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
94 wxNSProgressIndicator* v = [[wxNSProgressIndicator alloc] initWithFrame:r];
95
96 [v setMinValue: minimum];
97 [v setMaxValue: maximum];
98 [v setIndeterminate:FALSE];
99 [v setDoubleValue: (double) value];
100 wxWidgetCocoaImpl* c = new wxOSXGaugeCocoaImpl( wxpeer, v );
101 [v setImplementation:c];
102 return c;
103 }
104
105 #endif // wxUSE_GAUGE
106