]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/gauge.cpp
readability cleanup
[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
e9576ca5
SC
22bool wxGauge::Create(wxWindow *parent, wxWindowID id,
23 int range,
24 const wxPoint& pos,
519cb848 25 const wxSize& s,
e9576ca5
SC
26 long style,
27 const wxValidator& validator,
28 const wxString& name)
29{
facd6764 30 m_macIsUserPane = FALSE ;
21fd5529 31
facd6764 32 if ( !wxGaugeBase::Create(parent, id, range, pos, s, style & 0xE0FFFFFF, validator, name) )
b45ed7a2
VZ
33 return false;
34
e40298d5 35 wxSize size = s ;
f4e8ff28 36 /*
422d0ff0 37 if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord)
e40298d5
JS
38 {
39 size = wxSize( 200 , 16 ) ;
40 }
f4e8ff28 41 */
facd6764 42 Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
b905d6cc 43 m_peer = new wxMacControl(this) ;
4c37f124 44 verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
5ca0d812 45 GetValue() , 0 , GetRange() , false /* not indeterminate */ , m_peer->GetControlRefAddr() ) );
2b1fe32e
SC
46
47 if ( GetValue() == 0 )
48 m_peer->SetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag , (Boolean) false ) ;
49
facd6764 50 MacPostControlCreate(pos,size) ;
e40298d5
JS
51
52 return TRUE;
e9576ca5
SC
53}
54
e9576ca5
SC
55void wxGauge::SetRange(int r)
56{
21fd5529
SC
57 // we are going via the base class in case there is
58 // some change behind the values by it
59 wxGaugeBase::SetRange(r) ;
60 if ( m_peer && m_peer->Ok() )
61 m_peer->SetMaximum( GetRange() ) ;
e9576ca5
SC
62}
63
64void wxGauge::SetValue(int pos)
65{
21fd5529
SC
66 // we are going via the base class in case there is
67 // some change behind the values by it
68 wxGaugeBase::SetValue(pos) ;
69 if ( m_peer && m_peer->Ok() )
2b1fe32e 70 {
21fd5529 71 m_peer->SetValue( GetValue() ) ;
456fd7b6 72 // we turn off animation in the unnecessary situations as this is eating a lot of CPU otherwise
2b1fe32e
SC
73 Boolean shouldAnimate = ( GetValue() > 0 && GetValue() < GetRange() ) ;
74 if ( m_peer->GetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag ) != shouldAnimate )
75 {
76 m_peer->SetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag , shouldAnimate ) ;
77 if ( !shouldAnimate )
78 {
79 Refresh() ;
80 }
81 }
82 }
e9576ca5
SC
83}
84
85int wxGauge::GetValue() const
86{
21fd5529
SC
87/*
88 if ( m_peer && m_peer->Ok() )
89 return m_peer->GetValue() ;
90*/
91 return m_gaugePos ;
e9576ca5
SC
92}
93
e3e817d4
RN
94#endif // wxUSE_GAUGE
95