]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/gauge.cpp
avoiding unkown namespace std
[wxWidgets.git] / src / mac / carbon / gauge.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: gauge.cpp
3 // Purpose: wxGauge class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_GAUGE
15
16 #include "wx/gauge.h"
17
18 IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
19
20 #include "wx/mac/uma.h"
21
22 bool wxGauge::Create(wxWindow *parent, wxWindowID id,
23 int range,
24 const wxPoint& pos,
25 const wxSize& s,
26 long style,
27 const wxValidator& validator,
28 const wxString& name)
29 {
30 m_macIsUserPane = FALSE ;
31
32 if ( !wxGaugeBase::Create(parent, id, range, pos, s, style & 0xE0FFFFFF, validator, name) )
33 return false;
34
35 wxSize size = s ;
36 /*
37 if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord)
38 {
39 size = wxSize( 200 , 16 ) ;
40 }
41 */
42 Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
43 m_peer = new wxMacControl(this) ;
44 verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
45 GetValue() , 0 , GetRange() , false /* not indeterminate */ , m_peer->GetControlRefAddr() ) );
46
47 if ( GetValue() == 0 )
48 m_peer->SetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag , (Boolean) false ) ;
49
50 MacPostControlCreate(pos,size) ;
51
52 return TRUE;
53 }
54
55 void wxGauge::SetRange(int r)
56 {
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() ) ;
62 }
63
64 void wxGauge::SetValue(int pos)
65 {
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() )
70 {
71 m_peer->SetValue( GetValue() ) ;
72 // we turn off animation in the unnecessary situations as this is eating a lot of CPU otherwise
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 }
83 }
84
85 int wxGauge::GetValue() const
86 {
87 /*
88 if ( m_peer && m_peer->Ok() )
89 return m_peer->GetValue() ;
90 */
91 return m_gaugePos ;
92 }
93
94 #endif // wxUSE_GAUGE
95