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 IMPLEMENT_DYNAMIC_CLASS(wxGauge
, wxControl
)
24 #include "wx/mac/uma.h"
26 bool wxGauge::Create(wxWindow
*parent
, wxWindowID id
,
31 const wxValidator
& validator
,
34 m_macIsUserPane
= FALSE
;
36 if ( !wxGaugeBase::Create(parent
, id
, range
, pos
, s
, style
& 0xE0FFFFFF, validator
, name
) )
41 if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord)
43 size = wxSize( 200 , 16 ) ;
46 Rect bounds
= wxMacGetBoundsForControl( this , pos
, size
) ;
47 m_peer
= new wxMacControl(this) ;
48 verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent
->MacGetTopLevelWindowRef()) , &bounds
,
49 GetValue() , 0 , GetRange() , false /* not indeterminate */ , m_peer
->GetControlRefAddr() ) );
51 if ( GetValue() == 0 )
52 m_peer
->SetData
<Boolean
>( kControlEntireControl
, kControlProgressBarAnimatingTag
, (Boolean
) false ) ;
54 MacPostControlCreate(pos
,size
) ;
59 void wxGauge::SetRange(int r
)
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() ) ;
68 void wxGauge::SetValue(int pos
)
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() )
75 m_peer
->SetValue( GetValue() ) ;
76 // we turn off animation in the unnecessary situations as this is eating a lot of CPU otherwise
77 Boolean shouldAnimate
= ( GetValue() > 0 && GetValue() < GetRange() ) ;
78 if ( m_peer
->GetData
<Boolean
>( kControlEntireControl
, kControlProgressBarAnimatingTag
) != shouldAnimate
)
80 m_peer
->SetData
<Boolean
>( kControlEntireControl
, kControlProgressBarAnimatingTag
, shouldAnimate
) ;
89 int wxGauge::GetValue() const
92 if ( m_peer && m_peer->Ok() )
93 return m_peer->GetValue() ;