- wxASSERT_MSG( value == -1 || m_gauge, _T("cannot update non existent dialog") );
- wxASSERT_MSG( value <= m_maximum, _T("invalid progress value") );
-
-
- if( m_gauge )
- m_gauge->SetValue(value + 1);
-
- if( !newmsg.IsEmpty() )
- m_msg->SetLabel(newmsg);
-
- if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
- {
- unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
- unsigned long estimated = elapsed * m_maximum / value;
- unsigned long remaining = estimated - elapsed;
-
- SetTimeLabel(elapsed, m_elapsed);
- SetTimeLabel(estimated, m_estimated);
- SetTimeLabel(remaining, m_remaining);
- }
-
- if ( (value == m_maximum ) && !m_AutoHide )
- {
- if ( m_btnAbort )
- {
- // tell the user what he should do...
- m_btnAbort->SetLabel(_("Close"));
- }
-
- if ( !newmsg )
- {
- // also provide the finishing message if the application didn't
- m_msg->SetLabel(_("Done."));
- }
-
- // so that we return TRUE below and that out [Cancel] handler knew what
- // to do
- m_state = Finished;
-
- wxYield();
-
- (void)ShowModal();
- }
- else
- {
- // update the display
- wxYield();
- }
-
- return m_state != Canceled;
+ wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );
+
+#ifdef __WXMSW__
+ value /= m_factor;
+#endif // __WXMSW__
+
+ wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") );
+
+ if ( m_gauge && value < m_maximum )
+ {
+ m_gauge->SetValue(value + 1);
+ }
+
+ if ( !newmsg.IsEmpty() )
+ {
+ m_msg->SetLabel(newmsg);
+
+ wxYield();
+ }
+
+ if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) )
+ {
+ unsigned long elapsed = wxGetCurrentTime() - m_timeStart;
+ unsigned long estimated = (unsigned long)(( (double) elapsed * m_maximum ) / ((double)value)) ;
+ unsigned long remaining = estimated - elapsed;
+
+ SetTimeLabel(elapsed, m_elapsed);
+ SetTimeLabel(estimated, m_estimated);
+ SetTimeLabel(remaining, m_remaining);
+ }
+
+ if ( value == m_maximum )
+ {
+ // so that we return TRUE below and that out [Cancel] handler knew what
+ // to do
+ m_state = Finished;
+ if( !(GetWindowStyle() & wxPD_AUTO_HIDE) )
+ {
+ if ( m_btnAbort )
+ {
+ // tell the user what he should do...
+ m_btnAbort->SetLabel(_("Close"));
+ }
+#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
+ else // enable the button to give the user a way to close the dlg
+ {
+ EnableCloseButton(TRUE);
+ }
+#endif // __WXMSW__
+
+ if ( !newmsg )
+ {
+ // also provide the finishing message if the application didn't
+ m_msg->SetLabel(_("Done."));
+ }
+
+ wxYield();
+
+ (void)ShowModal();
+ }
+ else // auto hide
+ {
+ // 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
+ ReenableOtherWindows();
+
+ Hide();
+ }
+ }
+ else
+ {
+ // update the display
+ wxYield();
+ }
+
+#ifdef __WXMAC__
+ MacUpdateImmediately();
+#endif
+
+ return m_state != Canceled;
+}
+
+void wxProgressDialog::Resume()
+{
+ m_state = Continue;
+
+ // it may have been disabled by OnCancel(), so enable it back to let the
+ // user interrupt us again if needed
+ m_btnAbort->Enable();
+}
+
+bool wxProgressDialog::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);