fixed wxProgressDialog for ranges > 65535

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13159 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2001-12-22 02:14:38 +00:00
parent 1ccabb813a
commit 7c349adb6e
3 changed files with 22 additions and 7 deletions

View File

@ -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
-----

View File

@ -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;

View File

@ -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();