]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/gauge.cpp
cleanup - fixed warnings, reformatting
[wxWidgets.git] / src / mac / carbon / gauge.cpp
CommitLineData
e9576ca5
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: gauge.cpp
3// Purpose: wxGauge class
a31a5f85 4// Author: Stefan Csomor
e9576ca5 5// Modified by:
a31a5f85 6// Created: 1998-01-01
e9576ca5 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878 12#include "wx/wxprec.h"
e9576ca5 13
e3e817d4
RN
14#if wxUSE_GAUGE
15
3d1a4878
SC
16#include "wx/gauge.h"
17
e9576ca5 18IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
e9576ca5 19
d497dca4 20#include "wx/mac/uma.h"
519cb848 21
172da31f
DS
22bool wxGauge::Create( wxWindow *parent,
23 wxWindowID id,
24 int range,
25 const wxPoint& pos,
26 const wxSize& s,
27 long style,
28 const wxValidator& validator,
29 const wxString& name )
e9576ca5 30{
172da31f 31 m_macIsUserPane = false;
21fd5529 32
172da31f 33 if ( !wxGaugeBase::Create( parent, id, range, pos, s, style & 0xE0FFFFFF, validator, name ) )
b45ed7a2
VZ
34 return false;
35
172da31f
DS
36 wxSize size = s;
37
38#if 0
39 if (size.x == wxDefaultCoord && size.y == wxDefaultCoord)
40 size = wxSize( 200 , 16 );
41#endif
42
43 Rect bounds = wxMacGetBoundsForControl( this, pos, size );
44 m_peer = new wxMacControl( this );
45 OSStatus err = CreateProgressBarControl(
46 MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds,
47 GetValue(), 0, GetRange(), false /* not indeterminate */, m_peer->GetControlRefAddr() );
48 verify_noerr( err );
2b1fe32e
SC
49
50 if ( GetValue() == 0 )
172da31f 51 m_peer->SetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag, (Boolean)false );
2b1fe32e 52
172da31f 53 MacPostControlCreate( pos, size );
e40298d5 54
172da31f 55 return true;
e9576ca5
SC
56}
57
e9576ca5
SC
58void wxGauge::SetRange(int r)
59{
21fd5529
SC
60 // we are going via the base class in case there is
61 // some change behind the values by it
172da31f 62 wxGaugeBase::SetRange( r ) ;
21fd5529
SC
63 if ( m_peer && m_peer->Ok() )
64 m_peer->SetMaximum( GetRange() ) ;
e9576ca5
SC
65}
66
67void wxGauge::SetValue(int pos)
68{
21fd5529
SC
69 // we are going via the base class in case there is
70 // some change behind the values by it
172da31f
DS
71 wxGaugeBase::SetValue( pos ) ;
72
21fd5529 73 if ( m_peer && m_peer->Ok() )
2b1fe32e 74 {
21fd5529 75 m_peer->SetValue( GetValue() ) ;
172da31f
DS
76
77 // turn off animation in the unnecessary situations as this is consuming a lot of CPU otherwise
2b1fe32e 78 Boolean shouldAnimate = ( GetValue() > 0 && GetValue() < GetRange() ) ;
172da31f 79 if ( m_peer->GetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag ) != shouldAnimate )
2b1fe32e 80 {
172da31f 81 m_peer->SetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag, shouldAnimate ) ;
2b1fe32e 82 if ( !shouldAnimate )
2b1fe32e 83 Refresh() ;
2b1fe32e
SC
84 }
85 }
e9576ca5
SC
86}
87
88int wxGauge::GetValue() const
89{
172da31f 90#if 0
21fd5529
SC
91 if ( m_peer && m_peer->Ok() )
92 return m_peer->GetValue() ;
172da31f
DS
93#endif
94
21fd5529 95 return m_gaugePos ;
e9576ca5
SC
96}
97
172da31f 98#endif // wxUSE_GAUGE
e3e817d4 99