Mac(Carbon) impl of wxGauge::Pulse, also added sample code for Pulse to the widgets sample.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41103 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -115,7 +115,8 @@ protected:
|
|||||||
|
|
||||||
// the checkboxes for styles
|
// the checkboxes for styles
|
||||||
wxCheckBox *m_chkVert,
|
wxCheckBox *m_chkVert,
|
||||||
*m_chkSmooth;
|
*m_chkSmooth,
|
||||||
|
*m_chkIndeterminate;
|
||||||
|
|
||||||
// the gauge itself and the sizer it is in
|
// the gauge itself and the sizer it is in
|
||||||
wxGauge *m_gauge;
|
wxGauge *m_gauge;
|
||||||
@@ -178,7 +179,8 @@ GaugeWidgetsPage::GaugeWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
m_timer = (wxTimer *)NULL;
|
m_timer = (wxTimer *)NULL;
|
||||||
|
|
||||||
m_chkVert =
|
m_chkVert =
|
||||||
m_chkSmooth = (wxCheckBox *)NULL;
|
m_chkSmooth =
|
||||||
|
m_chkIndeterminate = (wxCheckBox *)NULL;
|
||||||
|
|
||||||
m_gauge = (wxGauge *)NULL;
|
m_gauge = (wxGauge *)NULL;
|
||||||
m_sizerGauge = (wxSizer *)NULL;
|
m_sizerGauge = (wxSizer *)NULL;
|
||||||
@@ -195,6 +197,7 @@ void GaugeWidgetsPage::CreateContent()
|
|||||||
|
|
||||||
m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Vertical"));
|
m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Vertical"));
|
||||||
m_chkSmooth = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Smooth"));
|
m_chkSmooth = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Smooth"));
|
||||||
|
m_chkIndeterminate = CreateCheckBoxAndAddToSizer(sizerLeft, _T("&Indeterminate"));
|
||||||
|
|
||||||
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
|
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
|
||||||
|
|
||||||
@@ -266,6 +269,7 @@ void GaugeWidgetsPage::Reset()
|
|||||||
{
|
{
|
||||||
m_chkVert->SetValue(false);
|
m_chkVert->SetValue(false);
|
||||||
m_chkSmooth->SetValue(false);
|
m_chkSmooth->SetValue(false);
|
||||||
|
m_chkIndeterminate->SetValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GaugeWidgetsPage::CreateGauge()
|
void GaugeWidgetsPage::CreateGauge()
|
||||||
@@ -293,6 +297,10 @@ void GaugeWidgetsPage::CreateGauge()
|
|||||||
wxDefaultPosition, wxDefaultSize,
|
wxDefaultPosition, wxDefaultSize,
|
||||||
flags);
|
flags);
|
||||||
m_gauge->SetValue(val);
|
m_gauge->SetValue(val);
|
||||||
|
|
||||||
|
if ( m_chkIndeterminate->GetValue() ){
|
||||||
|
m_gauge->Pulse();
|
||||||
|
}
|
||||||
|
|
||||||
if ( flags & wxGA_VERTICAL )
|
if ( flags & wxGA_VERTICAL )
|
||||||
m_sizerGauge->Add(m_gauge, 0, wxGROW | wxALL, 5);
|
m_sizerGauge->Add(m_gauge, 0, wxGROW | wxALL, 5);
|
||||||
@@ -348,6 +356,7 @@ void GaugeWidgetsPage::OnButtonSetRange(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
m_range = val;
|
m_range = val;
|
||||||
m_gauge->SetRange(val);
|
m_gauge->SetRange(val);
|
||||||
|
m_chkIndeterminate->SetValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GaugeWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
|
void GaugeWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
|
||||||
@@ -357,6 +366,7 @@ void GaugeWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_gauge->SetValue(val);
|
m_gauge->SetValue(val);
|
||||||
|
m_chkIndeterminate->SetValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GaugeWidgetsPage::OnUpdateUIValueButton(wxUpdateUIEvent& event)
|
void GaugeWidgetsPage::OnUpdateUIValueButton(wxUpdateUIEvent& event)
|
||||||
|
@@ -60,8 +60,15 @@ void wxGauge::SetRange(int r)
|
|||||||
// we are going via the base class in case there is
|
// we are going via the base class in case there is
|
||||||
// some change behind the values by it
|
// some change behind the values by it
|
||||||
wxGaugeBase::SetRange( r ) ;
|
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() ) ;
|
m_peer->SetMaximum( GetRange() ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGauge::SetValue(int pos)
|
void wxGauge::SetValue(int pos)
|
||||||
@@ -72,6 +79,12 @@ void wxGauge::SetValue(int pos)
|
|||||||
|
|
||||||
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->SetValue( GetValue() ) ;
|
m_peer->SetValue( GetValue() ) ;
|
||||||
|
|
||||||
// turn off animation in the unnecessary situations as this is consuming a lot of CPU otherwise
|
// 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() )
|
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 ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user