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