X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fe8635a7e78715344f0f4b6abc9d797931429333..3cd25cff50f35741c8f5327865068593e214e4ca:/src/generic/progdlgg.cpp?ds=sidebyside diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index cffe7fce24..e1b79f34a0 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -97,7 +97,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title, int maximum, wxWindow *parent, int style) - : wxDialog(parent, wxID_ANY, title), + : wxDialog(GetParentForModalDialog(parent), wxID_ANY, title), m_skip(false), m_delay(3), m_hasAbortButton(false), @@ -141,7 +141,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title, wxClientDC dc(this); dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - long widthText = 0; + wxCoord widthText = 0; dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL); wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL); @@ -176,7 +176,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title, m_display_estimated = m_last_timeupdate = m_break = 0; m_ctdelay = 0; - // if we are going to have at least one label, remmeber it in this var + // if we are going to have at least one label, remember it in this var wxStaticText *label = NULL; // also count how many labels we really have @@ -261,9 +261,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title, sizeDlg.y += 2*LAYOUT_MARGIN; // try to make the dialog not square but rectangular of reasonable width - sizeDlg.x = (wxCoord)wxMax(widthText, 4*sizeDlg.y/3); - sizeDlg.x *= 3; - sizeDlg.x /= 2; + sizeDlg.x = (wxCoord)wxMax(3*widthText/2, 4*sizeDlg.y/3); SetClientSize(sizeDlg); } @@ -338,12 +336,8 @@ wxProgressDialog::Update(int value, const wxString& newmsg, bool *skip) wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") ); - // fill up the gauge if value == maximum because this means that the dialog - // is going to close and the gauge shouldn't be partly empty in this case - if ( m_gauge && value <= m_maximum ) - { - m_gauge->SetValue(value == m_maximum ? value : value + 1); - } + if ( m_gauge ) + m_gauge->SetValue(value); UpdateMessage(newmsg); @@ -438,18 +432,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 +443,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 +461,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(); + + Update(); - if ( (m_skip) && (skip != NULL) && (*skip == false) ) + if ( m_skip && skip && !*skip ) { *skip = true; m_skip = false;