1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGauge class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "gauge.h"
16 #include "wx/wxprec.h"
22 #if !USE_SHARED_LIBRARY
23 IMPLEMENT_DYNAMIC_CLASS(wxGauge
, wxControl
)
26 #include "wx/mac/uma.h"
28 bool wxGauge::Create(wxWindow
*parent
, wxWindowID id
,
33 const wxValidator
& validator
,
36 m_macIsUserPane
= FALSE
;
38 if ( !wxGaugeBase::Create(parent
, id
, range
, pos
, s
, style
& 0xE0FFFFFF, validator
, name
) )
43 if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord)
45 size = wxSize( 200 , 16 ) ;
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() ) );
53 if ( GetValue() == 0 )
54 m_peer
->SetData
<Boolean
>( kControlEntireControl
, kControlProgressBarAnimatingTag
, (Boolean
) false ) ;
56 MacPostControlCreate(pos
,size
) ;
61 void wxGauge::SetRange(int r
)
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() ) ;
70 void wxGauge::SetValue(int pos
)
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() )
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
)
82 m_peer
->SetData
<Boolean
>( kControlEntireControl
, kControlProgressBarAnimatingTag
, shouldAnimate
) ;
91 int wxGauge::GetValue() const
94 if ( m_peer && m_peer->Ok() )
95 return m_peer->GetValue() ;
100 #endif // wxUSE_GAUGE