]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/gauge.cpp
ATSU Support in font extended
[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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "gauge.h"
14 #endif
15
16 #include "wx/wxprec.h"
17
18 #if wxUSE_GAUGE
19
20 #include "wx/gauge.h"
21
22 #if !USE_SHARED_LIBRARY
23 IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
24 #endif
25
26 #include "wx/mac/uma.h"
27
28 bool wxGauge::Create(wxWindow *parent, wxWindowID id,
29 int range,
30 const wxPoint& pos,
31 const wxSize& s,
32 long style,
33 const wxValidator& validator,
34 const wxString& name)
35 {
36 m_macIsUserPane = FALSE ;
37
38 if ( !wxGaugeBase::Create(parent, id, range, pos, s, style & 0xE0FFFFFF, validator, name) )
39 return false;
40
41 wxSize size = s ;
42 /*
43 if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord)
44 {
45 size = wxSize( 200 , 16 ) ;
46 }
47 */
48 Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
49 m_peer = new wxMacControl() ;
50 verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
51 GetValue() , 0 , GetRange() , false /* not indeterminate */ , m_peer->GetControlRefAddr() ) );
52
53 if ( GetValue() == 0 )
54 m_peer->SetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag , (Boolean) false ) ;
55
56 MacPostControlCreate(pos,size) ;
57
58 return TRUE;
59 }
60
61 void wxGauge::SetRange(int r)
62 {
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() ) ;
68 }
69
70 void wxGauge::SetValue(int pos)
71 {
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() )
76 {
77 m_peer->SetValue( GetValue() ) ;
78 // we turn off animation in the unnecessary situations as this is eating a lot of CPU otherwise
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 }
89 }
90
91 int wxGauge::GetValue() const
92 {
93 /*
94 if ( m_peer && m_peer->Ok() )
95 return m_peer->GetValue() ;
96 */
97 return m_gaugePos ;
98 }
99
100 #endif // wxUSE_GAUGE
101