]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/gauge.cpp
Don't use DDEExec registry key in wxMSW wxExecute() if it's empty.
[wxWidgets.git] / src / osx / carbon / gauge.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/gauge.cpp
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 class wxMacGaugeCarbonControl : public wxMacControl
20 {
21 public :
22 wxMacGaugeCarbonControl( wxWindowMac* peer ) : wxMacControl( peer )
23 {
24 }
25
26 void SetMaximum(wxInt32 v)
27 {
28 // switch back to determinate mode if not there already
29 if ( GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != false )
30 {
31 SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, (Boolean)false );
32 }
33
34 wxMacControl::SetMaximum( v ) ;
35 }
36
37 void SetValue(wxInt32 v)
38 {
39 // switch back to determinate mode if not there already
40 if ( GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != false )
41 {
42 SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, (Boolean)false );
43 }
44
45 wxMacControl::SetValue( v ) ;
46
47 // turn off animation in the unnecessary situations as this is consuming a lot of CPU otherwise
48 Boolean shouldAnimate = ( v > 0 && v < GetMaximum() ) ;
49 if ( GetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag ) != shouldAnimate )
50 {
51 SetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag, shouldAnimate ) ;
52 if ( !shouldAnimate )
53 SetNeedsDisplay(NULL) ;
54 }
55 }
56
57 void PulseGauge()
58 {
59 if ( GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != true )
60 {
61 SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, true);
62 }
63
64 if ( GetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag ) != true )
65 {
66 SetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag, true ) ;
67 }
68 }
69 };
70
71
72 wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
73 wxWindowMac* parent,
74 wxWindowID WXUNUSED(id),
75 wxInt32 value,
76 wxInt32 minimum,
77 wxInt32 maximum,
78 const wxPoint& pos,
79 const wxSize& size,
80 long WXUNUSED(style),
81 long WXUNUSED(extraStyle))
82 {
83 Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );
84 wxMacGaugeCarbonControl* peer = new wxMacGaugeCarbonControl( wxpeer );
85 OSStatus err = CreateProgressBarControl(
86 MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds,
87 value, minimum, maximum, false /* not indeterminate */, peer->GetControlRefAddr() );
88 verify_noerr( err );
89 if ( value == 0 )
90 peer->SetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag, (Boolean)false );
91 return peer;
92 }
93
94 #endif // wxUSE_GAUGE
95