]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/gauge.cpp
Set missing Language: headers in PO files.
[wxWidgets.git] / src / osx / carbon / gauge.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/osx/carbon/gauge.cpp
489468fe
SC
3// Purpose: wxGauge class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
489468fe
SC
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
524c47aa 17#include "wx/osx/private.h"
489468fe 18
524c47aa 19class wxMacGaugeCarbonControl : public wxMacControl
489468fe 20{
524c47aa
SC
21public :
22 wxMacGaugeCarbonControl( wxWindowMac* peer ) : wxMacControl( peer )
23 {
24 }
03647350 25
524c47aa
SC
26 void SetMaximum(wxInt32 v)
27 {
489468fe 28 // switch back to determinate mode if not there already
524c47aa 29 if ( GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != false )
489468fe 30 {
524c47aa 31 SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, (Boolean)false );
489468fe
SC
32 }
33
524c47aa 34 wxMacControl::SetMaximum( v ) ;
489468fe 35 }
03647350 36
524c47aa 37 void SetValue(wxInt32 v)
489468fe
SC
38 {
39 // switch back to determinate mode if not there already
524c47aa 40 if ( GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != false )
489468fe 41 {
524c47aa 42 SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, (Boolean)false );
489468fe
SC
43 }
44
524c47aa 45 wxMacControl::SetValue( v ) ;
489468fe
SC
46
47 // turn off animation in the unnecessary situations as this is consuming a lot of CPU otherwise
524c47aa
SC
48 Boolean shouldAnimate = ( v > 0 && v < GetMaximum() ) ;
49 if ( GetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag ) != shouldAnimate )
489468fe 50 {
524c47aa 51 SetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag, shouldAnimate ) ;
489468fe 52 if ( !shouldAnimate )
524c47aa 53 SetNeedsDisplay(NULL) ;
489468fe
SC
54 }
55 }
03647350 56
524c47aa 57 void PulseGauge()
489468fe 58 {
524c47aa 59 if ( GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != true )
489468fe 60 {
524c47aa 61 SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, true);
489468fe
SC
62 }
63
524c47aa 64 if ( GetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag ) != true )
489468fe 65 {
524c47aa 66 SetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag, true ) ;
489468fe
SC
67 }
68 }
524c47aa
SC
69};
70
71
03647350
VZ
72wxWidgetImplType* wxWidgetImpl::CreateGauge( wxWindowMac* wxpeer,
73 wxWindowMac* parent,
74 wxWindowID WXUNUSED(id),
524c47aa
SC
75 wxInt32 value,
76 wxInt32 minimum,
77 wxInt32 maximum,
03647350 78 const wxPoint& pos,
524c47aa 79 const wxSize& size,
03647350 80 long WXUNUSED(style),
a4fec5b4 81 long WXUNUSED(extraStyle))
524c47aa
SC
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;
489468fe
SC
92}
93
94#endif // wxUSE_GAUGE
95