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