]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/progdlgg.cpp
item with no image no longer crash when hit
[wxWidgets.git] / src / generic / progdlgg.cpp
index 801ef396eaa6d6bdb125e4532c3ff95239fa867e..542ffad1611044f8a836ce2189bb9174f8b83872 100644 (file)
@@ -81,8 +81,8 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
 
    m_msg = new wxStaticText(this, -1, message);
    c = new wxLayoutConstraints;
-   c->left.SameAs(this, wxLeft, 10);
-   c->top.SameAs(this, wxTop, 10);
+   c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
+   c->top.SameAs(this, wxTop, 2*LAYOUT_Y_MARGIN);
    c->width.AsIs();
    c->height.AsIs();
    m_msg->SetConstraints(c);
@@ -174,10 +174,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
       m_btnAbort = new wxButton(this, -1, _("Cancel"));
       c = new wxLayoutConstraints;
       c->centreX.SameAs(this, wxCentreX);
-      if(lastWindow)
-         c->top.Below(lastWindow, 2*LAYOUT_Y_MARGIN);
-      else
-         c->top.Below(m_btnAbort, 2*LAYOUT_Y_MARGIN);
+      c->top.Below(lastWindow, 2*LAYOUT_Y_MARGIN);
       c->width.AsIs();
       c->height.AsIs();
       m_btnAbort->SetConstraints(c);
@@ -194,9 +191,8 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
    // wide under Windows, so try to find a reasonable value for the width, not
    // too big and not too small
    wxSize size = GetClientSize();
-   size.x = 2*widthText;
-   if ( size.x < 2*size.y )
-      SetClientSize(2*size.y, size.y);
+   size.x = wxMax(3*widthText/2, 2*size.y);
+   SetClientSize(size);
 
    Show(TRUE);
    Centre(wxCENTER_FRAME | wxBOTH);
@@ -214,8 +210,8 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
 bool
 wxProgressDialog::Update(int value, const wxString& newmsg)
 {
-   wxASSERT_MSG( value == -1 || m_gauge, _T("can't update non existent dialog") );
-   wxASSERT_MSG( value < m_maximum, _T("invalid progress value") );
+   wxASSERT_MSG( value == -1 || m_gauge, _T("cannot update non existent dialog") );
+   wxASSERT_MSG( value <= m_maximum, _T("invalid progress value") );
 
 
    if( m_gauge )
@@ -235,18 +231,18 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
 
       if (m_elapsed) 
       {
-        s.Printf("%i:%02i:%02i", diff.GetHour(), diff.GetMinute(), diff.GetSecond());
-        if (s != m_elapsed->GetLabel()) m_elapsed->SetLabel(s);
+         s.Printf(_T("%i:%02i:%02i"), diff.GetHour(), diff.GetMinute(), diff.GetSecond());
+         if (s != m_elapsed->GetLabel()) m_elapsed->SetLabel(s);
       }
       if (m_estimated) 
       {
-        s.Printf("%i:%02i:%02i", estim / (60 * 60), (estim / 60) % 60, estim % 60);
-        if (s != m_estimated->GetLabel()) m_estimated->SetLabel(s);
+         s.Printf(_T("%i:%02i:%02i"), estim / (60 * 60), (estim / 60) % 60, estim % 60);
+         if (s != m_estimated->GetLabel()) m_estimated->SetLabel(s);
       }
       if (m_remaining) 
       {
-        s.Printf("%i:%02i:%02i", remai / (60 * 60), (remai / 60) % 60, remai % 60);
-        if (s != m_remaining->GetLabel()) m_remaining->SetLabel(s);
+         s.Printf(_T("%i:%02i:%02i"), remai / (60 * 60), (remai / 60) % 60, remai % 60);
+         if (s != m_remaining->GetLabel()) m_remaining->SetLabel(s);
       }
    }
 
@@ -258,18 +254,22 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
            m_btnAbort->SetLabel(_("Close"));
        }
 
-       if ( !newmsg )
+/*I think the default should be the other way round. If the
+  application wants to set a "Done." message at the end, it should
+  supply it. Any serious objections to this change? Makes the
+  application programmers' work a little easier.
+  if ( !newmsg )
        {
            // also provide the finishing message if the application didn't
            m_msg->SetLabel(_("Done."));
        }
-
+*/
        m_state = Finished;
 
        // so that we return TRUE below
        m_state = Finished;
    }
-
+   wxYield();
    return m_state != Canceled;
 }