]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/gauge.cpp
define wxDateEvent static stuff here
[wxWidgets.git] / src / mac / carbon / gauge.cpp
index 6e9ed032f27f81b6f2784441c3447a22aa29341c..6f97b0357833caff02f5efdc843f58bca035c85f 100644 (file)
@@ -47,8 +47,10 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
     m_peer = new wxMacControl() ;
     verify_noerr ( CreateProgressBarControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 
      GetValue() , 0 , GetRange() , false /* not indeterminate */ , m_peer->GetControlRefAddr() ) );
-    
-       
+
+    if ( GetValue() == 0 )
+        m_peer->SetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag , (Boolean) false ) ;
+
     MacPostControlCreate(pos,size) ;
     
     return TRUE;
@@ -69,7 +71,19 @@ void wxGauge::SetValue(int pos)
     // some change behind the values by it
     wxGaugeBase::SetValue(pos) ;
     if ( m_peer && m_peer->Ok() )
+    {
         m_peer->SetValue( GetValue() ) ;
+        // we turn off animation in the unnecessary situations as this is eating a lot of CPU otherwise
+        Boolean shouldAnimate = ( GetValue() > 0 && GetValue() < GetRange() ) ;
+        if ( m_peer->GetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag ) != shouldAnimate )
+        {
+            m_peer->SetData<Boolean>( kControlEntireControl , kControlProgressBarAnimatingTag , shouldAnimate ) ;
+            if ( !shouldAnimate )
+            {
+                Refresh() ;
+            }
+        }
+    }
 }
 
 int wxGauge::GetValue() const