1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxGauge class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
18 IMPLEMENT_DYNAMIC_CLASS(wxGauge
, wxControl
)
20 #include "wx/mac/uma.h"
22 bool wxGauge::Create(wxWindow
*parent
, wxWindowID id
,
27 const wxValidator
& validator
,
30 m_macIsUserPane
= FALSE
;
32 if ( !wxGaugeBase::Create(parent
, id
, range
, pos
, s
, style
& 0xE0FFFFFF, validator
, name
) )
37 if ( size.x == wxDefaultCoord && size.y == wxDefaultCoord)
39 size = wxSize( 200 , 16 ) ;
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() ) );
47 if ( GetValue() == 0 )
48 m_peer
->SetData
<Boolean
>( kControlEntireControl
, kControlProgressBarAnimatingTag
, (Boolean
) false ) ;
50 MacPostControlCreate(pos
,size
) ;
55 void wxGauge::SetRange(int r
)
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() ) ;
64 void wxGauge::SetValue(int pos
)
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() )
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
)
76 m_peer
->SetData
<Boolean
>( kControlEntireControl
, kControlProgressBarAnimatingTag
, shouldAnimate
) ;
85 int wxGauge::GetValue() const
88 if ( m_peer && m_peer->Ok() )
89 return m_peer->GetValue() ;