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