small refactoring to avoid code duplication; renamed wxProgressDialog::UpdatePulse() to just Pulse(); added test for it in the dialogs sample (part of the patch 1551409 which somehow wasn't applied before)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42253 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -70,6 +70,7 @@ All (GUI):
|
||||
calling SelectObject itself if a valid bitmap is passed.
|
||||
- Reverted wxBuffered[Paint]DC to pre 2.7.1 state, added
|
||||
wxAutoBufferedPaintDC and wxAutoBufferedPaintDCFactory.
|
||||
- Renamed wxProgressDialog::UpdatePulse() to just Pulse()
|
||||
|
||||
Unix Ports:
|
||||
|
||||
|
@@ -56,7 +56,7 @@ public:
|
||||
|
||||
/* Switches the dialog to use a gauge in indeterminate mode and calls
|
||||
wxGauge::Pulse() to show to the user a bit of progress */
|
||||
virtual bool UpdatePulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
|
||||
virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
|
||||
|
||||
// Must provide overload to avoid hiding it (and warnings about it)
|
||||
virtual void Update() { wxDialog::Update(); }
|
||||
@@ -91,6 +91,9 @@ private:
|
||||
// updates the label message
|
||||
void UpdateMessage(const wxString &newmsg);
|
||||
|
||||
// common part of Update() and Pulse(), returns true if not cancelled
|
||||
bool DoAfterUpdate(bool *skip);
|
||||
|
||||
// shortcuts for enabling buttons
|
||||
void EnableClose();
|
||||
void EnableSkip(bool enable=true);
|
||||
|
@@ -1108,8 +1108,9 @@ void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
|
||||
// wxPD_AUTO_HIDE | -- try this as well
|
||||
wxPD_ELAPSED_TIME |
|
||||
wxPD_ESTIMATED_TIME |
|
||||
wxPD_REMAINING_TIME |
|
||||
wxPD_SMOOTH);
|
||||
wxPD_REMAINING_TIME
|
||||
//wxPD_SMOOTH - makes indeterminate mode bar on WinXP very small
|
||||
);
|
||||
|
||||
bool cont = true;
|
||||
bool skip = false;
|
||||
@@ -1138,15 +1139,29 @@ void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
|
||||
|
||||
wxString msg;
|
||||
|
||||
// test both behaviours of wxProgressDialog:
|
||||
// determinate mode for first 33% and last 33% of the time
|
||||
// indeterminate mode from 33% to 66% of the progress
|
||||
const int firstpart = max /3,
|
||||
secondpart = 2 * max /3;
|
||||
bool determinate = i < firstpart || i > secondpart;
|
||||
bool indeterminate = !determinate;
|
||||
|
||||
if ( i == max )
|
||||
{
|
||||
msg = _T("That's all, folks!");
|
||||
}
|
||||
else if ( i > max / 2 )
|
||||
else if ( indeterminate )
|
||||
{
|
||||
msg = _T("Only a half left (very long message)!");
|
||||
msg = _T("Now test indeterminate mode");
|
||||
}
|
||||
else if ( i > secondpart )
|
||||
{
|
||||
msg = _T("Back to determinate mode");
|
||||
}
|
||||
|
||||
if (determinate)
|
||||
{
|
||||
#if wxUSE_STOPWATCH && wxUSE_LONGLONG
|
||||
if ( (i % (max/100)) == 0 ) // // only 100 updates, this makes it much faster
|
||||
{
|
||||
@@ -1155,6 +1170,18 @@ void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) )
|
||||
#else
|
||||
cont = dialog.Update(i, msg, &skip);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if wxUSE_STOPWATCH && wxUSE_LONGLONG
|
||||
if ( (i % (max/100)) == 0 ) // // only 100 updates, this makes it much faster
|
||||
{
|
||||
cont = dialog.Pulse(msg, &skip);
|
||||
}
|
||||
#else
|
||||
cont = dialog.Pulse(msg, &skip);
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( !cont )
|
||||
{
|
||||
|
@@ -438,18 +438,9 @@ wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
else // not at maximum yet
|
||||
{
|
||||
// we have to yield because not only we want to update the display but
|
||||
// also to process the clicks on the cancel and skip buttons
|
||||
wxYieldIfNeeded() ;
|
||||
|
||||
if ( (m_skip) && (skip != NULL) && (*skip == false) )
|
||||
{
|
||||
*skip = true;
|
||||
m_skip = false;
|
||||
EnableSkip();
|
||||
}
|
||||
return DoAfterUpdate(skip);
|
||||
}
|
||||
|
||||
// update the display in case yielding above didn't do it
|
||||
@@ -458,8 +449,7 @@ wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip)
|
||||
return m_state != Canceled;
|
||||
}
|
||||
|
||||
bool
|
||||
wxProgressDialog::UpdatePulse(const wxString& newmsg, bool *skip)
|
||||
bool wxProgressDialog::Pulse(const wxString& newmsg, bool *skip)
|
||||
{
|
||||
wxASSERT_MSG( m_gauge, wxT("cannot update non existent dialog") );
|
||||
|
||||
@@ -477,11 +467,18 @@ wxProgressDialog::UpdatePulse(const wxString& newmsg, bool *skip)
|
||||
SetTimeLabel((unsigned long)-1, m_remaining);
|
||||
}
|
||||
|
||||
return DoAfterUpdate(skip);
|
||||
}
|
||||
|
||||
bool wxProgressDialog::DoAfterUpdate(bool *skip)
|
||||
{
|
||||
// we have to yield because not only we want to update the display but
|
||||
// also to process the clicks on the cancel and skip buttons
|
||||
wxYieldIfNeeded() ;
|
||||
wxYieldIfNeeded();
|
||||
|
||||
if ( (m_skip) && (skip != NULL) && (*skip == false) )
|
||||
Update();
|
||||
|
||||
if ( m_skip && skip && !*skip )
|
||||
{
|
||||
*skip = true;
|
||||
m_skip = false;
|
||||
|
Reference in New Issue
Block a user