From 7c349adb6e419aa8007e2c6c323e80ee39bcd4e2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 22 Dec 2001 02:14:38 +0000 Subject: [PATCH] fixed wxProgressDialog for ranges > 65535 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13159 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/generic/progdlgg.h | 6 ++++++ src/generic/progdlgg.cpp | 22 +++++++++++++++------- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index b35add0afe..77d35eaff7 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -73,6 +73,7 @@ wxMSW: - fixed flicker in wxTreeCtrl::SetItemXXX() - fixed redraw problems in dynamically resized wxStaticText +- fixed wxProgressDialog for ranges > 65535 2.3.2 ----- diff --git a/include/wx/generic/progdlgg.h b/include/wx/generic/progdlgg.h index 11437238a0..872bba1fe0 100644 --- a/include/wx/generic/progdlgg.h +++ b/include/wx/generic/progdlgg.h @@ -112,6 +112,12 @@ private: // the maximum value int m_maximum; +#ifdef __WXMSW__ + // the factor we use to always keep the value in 16 bit range as the native + // control only supports ranges from 0 to 65,535 + size_t m_factor; +#endif // __WXMSW__ + // for wxPD_APP_MODAL case class WXDLLEXPORT wxWindowDisabler *m_winDisabler; diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index 33a8d648fc..4b5dcd7e75 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -110,6 +110,13 @@ wxProgressDialog::wxProgressDialog(wxString const &title, m_state = hasAbortButton ? Continue : Uncancelable; m_maximum = maximum; +#ifdef __WXMSW__ + // 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__ + m_parentTop = parent; while ( m_parentTop && m_parentTop->GetParent() ) { @@ -142,7 +149,7 @@ wxProgressDialog::wxProgressDialog(wxString const &title, // 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, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL); @@ -305,19 +312,20 @@ bool wxProgressDialog::Update(int value, const wxString& newmsg) { 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 ) + { m_gauge->SetValue(value + 1); + } if ( !newmsg.IsEmpty() ) { -#ifdef __WXMSW__ - // this seems to be necessary or garbage is left when the new label is - // longer than the old one - m_msg->SetLabel(wxEmptyString); -#endif // MSW - m_msg->SetLabel(newmsg); wxYield(); -- 2.45.2