+ SetTimeLabel(elapsed, m_elapsed);
+ SetTimeLabel((unsigned long)-1, m_estimated);
+ SetTimeLabel((unsigned long)-1, m_remaining);
+ }
+
+ DoAfterUpdate();
+
+ return m_state != Canceled;
+}
+
+bool wxGenericProgressDialog::DoBeforeUpdate(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
+ // NOTE: using YieldFor() this call shouldn't give re-entrancy problems
+ // for event handlers not interested to UI/user-input events.
+ wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI|wxEVT_CATEGORY_USER_INPUT);
+
+ Update();
+
+ if ( m_skip && skip && !*skip )
+ {
+ *skip = true;
+ m_skip = false;
+ EnableSkip();
+ }
+
+ return m_state != Canceled;
+}
+
+void wxGenericProgressDialog::DoAfterUpdate()
+{
+ // allow the window to repaint:
+ // NOTE: since we yield only for UI events with this call, there
+ // should be no side-effects
+ wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
+}
+
+void wxGenericProgressDialog::Resume()
+{
+ m_state = Continue;
+ m_ctdelay = m_delay; // force an update of the elapsed/estimated/remaining time
+ m_break += wxGetCurrentTime()-m_timeStop;
+
+ EnableAbort();
+ EnableSkip();
+ m_skip = false;
+}
+
+bool wxGenericProgressDialog::Show( bool show )
+{
+ // reenable other windows before hiding this one because otherwise
+ // Windows wouldn't give the focus back to the window which had
+ // been previously focused because it would still be disabled
+ if(!show)
+ ReenableOtherWindows();
+
+ return wxDialog::Show(show);
+}
+
+int wxGenericProgressDialog::GetValue() const
+{
+ wxCHECK_MSG( m_gauge, -1, "dialog should be fully created" );
+
+ return m_gauge->GetValue();
+}
+
+int wxGenericProgressDialog::GetRange() const
+{
+ return m_maximum;
+}
+
+wxString wxGenericProgressDialog::GetMessage() const
+{
+ return m_msg->GetLabel();
+}
+
+void wxGenericProgressDialog::SetRange(int maximum)
+{
+ wxCHECK_RET( m_gauge, "dialog should be fully created" );
+
+ wxCHECK_RET( maximum > 0, "Invalid range" );
+
+ m_gauge->SetRange(maximum);
+
+ SetMaximum(maximum);
+}
+
+void wxGenericProgressDialog::SetMaximum(int maximum)
+{
+ m_maximum = maximum;
+
+#if defined(__WXMSW__) || defined(__WXPM__)
+ // we can't have values > 65,536 in the progress control under Windows, so
+ // scale everything down
+ m_factor = m_maximum / 65536 + 1;
+#endif // __WXMSW__
+}
+
+
+bool wxGenericProgressDialog::WasCancelled() const
+{
+ return HasPDFlag(wxPD_CAN_ABORT) && m_state == Canceled;
+}
+
+bool wxGenericProgressDialog::WasSkipped() const
+{
+ return HasPDFlag(wxPD_CAN_SKIP) && m_skip;
+}
+
+// static
+void wxGenericProgressDialog::SetTimeLabel(unsigned long val,
+ wxStaticText *label)
+{
+ if ( label )
+ {
+ wxString s;
+
+ if (val != (unsigned long)-1)
+ {
+ s = GetFormattedTime(val);
+ }
+ else
+ {
+ s = _("Unknown");
+ }
+
+ if ( s != label->GetLabel() )
+ label->SetLabel(s);
+ }