BEGIN_EVENT_TABLE(wxProgressDialog, wxDialog)
EVT_BUTTON(wxID_CANCEL, wxProgressDialog::OnCancel)
BEGIN_EVENT_TABLE(wxProgressDialog, wxDialog)
EVT_BUTTON(wxID_CANCEL, wxProgressDialog::OnCancel)
EVT_CLOSE(wxProgressDialog::OnClose)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
// ============================================================================
EVT_CLOSE(wxProgressDialog::OnClose)
END_EVENT_TABLE()
IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
// ============================================================================
// ============================================================================
// ----------------------------------------------------------------------------
// ============================================================================
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
wxProgressDialog::wxProgressDialog(wxString const &title,
// ----------------------------------------------------------------------------
wxProgressDialog::wxProgressDialog(wxString const &title,
// we have to remove the "Close" button from the title bar then as it is
// confusing to have it - it doesn't work anyhow
//
// we have to remove the "Close" button from the title bar then as it is
// confusing to have it - it doesn't work anyhow
//
+#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;
+ m_maximum /= m_factor;
+#endif // __WXMSW__
+
long widthText;
dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL);
long widthText;
dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL);
// note that we can't use wxGA_SMOOTH because it happens to also mean
// wxDIALOG_MODAL and will cause the dialog to be modal. Have an extra
// style argument to wxProgressDialog, perhaps.
// note that we can't use wxGA_SMOOTH because it happens to also mean
// wxDIALOG_MODAL and will cause the dialog to be modal. Have an extra
// style argument to wxProgressDialog, perhaps.
- m_gauge = new wxGauge(this, -1, maximum,
+ m_gauge = new wxGauge(this, -1, m_maximum,
// create the estimated/remaining/total time zones if requested
m_elapsed = m_estimated = m_remaining = (wxStaticText*)NULL;
// create the estimated/remaining/total time zones if requested
m_elapsed = m_estimated = m_remaining = (wxStaticText*)NULL;
+ // if we are going to have at least one label, remmeber it in this var
+ wxStaticText *label = NULL;
+
+ // also count how many labels we really have
+ size_t nTimeLabels = 0;
+
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
#else // !MSW
c->centreX.SameAs(this, wxCentreX);
#endif // MSW/!MSW
c->bottom.SameAs(this, wxBottom, 2*LAYOUT_Y_MARGIN);
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
#else // !MSW
c->centreX.SameAs(this, wxCentreX);
#endif // MSW/!MSW
c->bottom.SameAs(this, wxBottom, 2*LAYOUT_Y_MARGIN);
// VZ: I like the labels be centered - if the others don't mind, you may
// remove "#ifdef __WXMSW__" and use it for all ports
// VZ: I like the labels be centered - if the others don't mind, you may
// remove "#ifdef __WXMSW__" and use it for all ports
c->left.SameAs(this, wxCentreX, LAYOUT_X_MARGIN);
#else // !MSW
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
c->left.SameAs(this, wxCentreX, LAYOUT_X_MARGIN);
#else // !MSW
c->right.SameAs(this, wxRight, 2*LAYOUT_X_MARGIN);
bool
wxProgressDialog::Update(int value, const wxString& newmsg)
{
wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );
bool
wxProgressDialog::Update(int value, const wxString& newmsg)
{
wxASSERT_MSG( value == -1 || m_gauge, wxT("cannot update non existent dialog") );
- if ( m_btnAbort )
- {
- // tell the user what he should do...
- m_btnAbort->SetLabel(_("Close"));
- }
-#ifdef __WXMSW__
- else // enable the close button to give the user a way to close the dlg
+ // so that we return TRUE below and that out [Cancel] handler knew what
+ // to do
+ m_state = Finished;
+ if( !(GetWindowStyle() & wxPD_AUTO_HIDE) )
- EnableCloseButton(TRUE);
- }
+ 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);
+ }
+ (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();
// ----------------------------------------------------------------------------
// event handlers
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// event handlers
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// destruction
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// destruction
// ----------------------------------------------------------------------------