]> git.saurik.com Git - wxWidgets.git/commitdiff
Mac(Carbon) impl of wxGauge::Pulse, also added sample code for Pulse to the widgets...
authorKevin Ollivier <kevino@theolliviers.com>
Sat, 9 Sep 2006 18:11:48 +0000 (18:11 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Sat, 9 Sep 2006 18:11:48 +0000 (18:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41103 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/widgets/gauge.cpp
src/mac/carbon/gauge.cpp

index 7093f874c40e6a06e1e9190f8229479540cfa585..3f80544e5f8b19014809bdb02b7d860cc20a9e45 100644 (file)
@@ -115,7 +115,8 @@ protected:
 
     // the checkboxes for styles
     wxCheckBox *m_chkVert,
-               *m_chkSmooth;
+               *m_chkSmooth,
+               *m_chkIndeterminate;
 
     // the gauge itself and the sizer it is in
     wxGauge *m_gauge;
@@ -178,7 +179,8 @@ GaugeWidgetsPage::GaugeWidgetsPage(WidgetsBookCtrl *book,
     m_timer = (wxTimer *)NULL;
 
     m_chkVert =
-    m_chkSmooth = (wxCheckBox *)NULL;
+    m_chkSmooth =
+    m_chkIndeterminate = (wxCheckBox *)NULL;
 
     m_gauge = (wxGauge *)NULL;
     m_sizerGauge = (wxSizer *)NULL;
@@ -195,6 +197,7 @@ void GaugeWidgetsPage::CreateContent()
 
     m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Vertical"));
     m_chkSmooth = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Smooth"));
+    m_chkIndeterminate = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Indeterminate"));
 
     sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
 
@@ -266,6 +269,7 @@ void GaugeWidgetsPage::Reset()
 {
     m_chkVert->SetValue(false);
     m_chkSmooth->SetValue(false);
+    m_chkIndeterminate->SetValue(false);
 }
 
 void GaugeWidgetsPage::CreateGauge()
@@ -293,6 +297,10 @@ void GaugeWidgetsPage::CreateGauge()
                           wxDefaultPosition, wxDefaultSize,
                           flags);
     m_gauge->SetValue(val);
+    
+    if ( m_chkIndeterminate->GetValue() ){
+        m_gauge->Pulse();
+    }
 
     if ( flags & wxGA_VERTICAL )
         m_sizerGauge->Add(m_gauge, 0, wxGROW | wxALL, 5);
@@ -348,6 +356,7 @@ void GaugeWidgetsPage::OnButtonSetRange(wxCommandEvent& WXUNUSED(event))
 
     m_range = val;
     m_gauge->SetRange(val);
+    m_chkIndeterminate->SetValue(0);
 }
 
 void GaugeWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
@@ -357,6 +366,7 @@ void GaugeWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
         return;
 
     m_gauge->SetValue(val);
+    m_chkIndeterminate->SetValue(0);
 }
 
 void GaugeWidgetsPage::OnUpdateUIValueButton(wxUpdateUIEvent& event)
index 531cf003f3b92f0b1bdaf5eddddcd259e4cff730..3793d8ed604195d7d9853c474c8bab829f0bcf81 100644 (file)
@@ -60,8 +60,15 @@ void wxGauge::SetRange(int r)
     // we are going via the base class in case there is 
     // some change behind the values by it
     wxGaugeBase::SetRange( r ) ;
-    if ( m_peer && m_peer->Ok() )
+    if ( m_peer && m_peer->Ok() ){
+        // switch back to determinate mode if not there already 
+        if ( m_peer->GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != false )
+        {
+             m_peer->SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, (Boolean)false );
+        }
+    
         m_peer->SetMaximum( GetRange() ) ;
+    }
 }
 
 void wxGauge::SetValue(int pos)
@@ -72,6 +79,12 @@ void wxGauge::SetValue(int pos)
 
     if ( m_peer && m_peer->Ok() )
     {
+        // switch back to determinate mode if not there already 
+        if ( m_peer->GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != false )
+        {
+            m_peer->SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, (Boolean)false );
+        }
+    
         m_peer->SetValue( GetValue() ) ;
 
         // turn off animation in the unnecessary situations as this is consuming a lot of CPU otherwise
@@ -99,7 +112,15 @@ void wxGauge::Pulse()
 {
     if ( m_peer && m_peer->Ok() )
     {
-        // need to use the animate() method of NSProgressIndicator Class here
+        if ( m_peer->GetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag ) != true )
+        {
+        m_peer->SetData<Boolean>( kControlNoPart, kControlProgressBarIndeterminateTag, true); 
+        }
+        
+        if ( m_peer->GetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag ) != true )
+        {
+            m_peer->SetData<Boolean>( kControlEntireControl, kControlProgressBarAnimatingTag, true ) ;
+        }
     }
 }