]> git.saurik.com Git - wxWidgets.git/blame - src/osx/cocoa/gauge.mm
Since wxDialog::Show(false) only calls wxWindow::Show, we must explicitly hide the...
[wxWidgets.git] / src / osx / cocoa / gauge.mm
CommitLineData
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 30 static BOOL initialized = NO;
03647350 31 if (!initialized)
4dd9fdf8
SC
32 {
33 initialized = YES;
34 wxOSXCocoaClassAddWXMethods( self );
35 }
dbeddfb9
SC
36}
37
dbeddfb9
SC
38@end
39
40class wxOSXGaugeCocoaImpl : public wxWidgetCocoaImpl
41{
42public :
43 wxOSXGaugeCocoaImpl( wxWindowMac* peer, WXWidget w) : wxWidgetCocoaImpl( peer, w )
44 {
45 }
03647350 46
dbeddfb9
SC
47 void SetMaximum(wxInt32 v)
48 {
49 SetDeterminateMode();
50 wxWidgetCocoaImpl::SetMaximum( v ) ;
51 }
03647350 52
dbeddfb9
SC
53 void SetValue(wxInt32 v)
54 {
55 SetDeterminateMode();
56 wxWidgetCocoaImpl::SetValue( v ) ;
57 }
03647350 58
dbeddfb9
SC
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 }
67protected:
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
03647350
VZ
80wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
81 wxWindowMac* WXUNUSED(parent),
82 wxWindowID WXUNUSED(id),
dbeddfb9
SC
83 wxInt32 value,
84 wxInt32 minimum,
85 wxInt32 maximum,
03647350 86 const wxPoint& pos,
dbeddfb9 87 const wxSize& size,
03647350 88 long WXUNUSED(style),
d8207702 89 long WXUNUSED(extraStyle))
dbeddfb9 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