X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e72e3cc53f04cc79189ab5d0f6fecca3f68a2ee..7f2a8ba84486d549d655b095096127fb4014dd1c:/samples/dialogs/dialogs.cpp?ds=sidebyside diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index dc43589120..fecd4b0ec3 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -575,7 +575,7 @@ void MyFrame::PasswordEntry(wxCommandEvent& WXUNUSED(event)) _T("Password entry dialog"), wxEmptyString, this); - if ( !!pwd ) + if ( !pwd.empty() ) { wxMessageBox(wxString::Format(wxT("Your password is '%s'"), pwd.c_str()), _T("Got password"), wxOK | wxICON_INFORMATION, this); @@ -905,7 +905,14 @@ void MyFrame::ModelessDlg(wxCommandEvent& event) } else // hide { - m_dialog->Hide(); + // If m_dialog is NULL, then possibly the system + // didn't report the checked menu item status correctly. + // It should be true just after the menu item was selected, + // if there was no modeless dialog yet. + + wxASSERT( m_dialog != NULL ); + if (m_dialog) + m_dialog->Hide(); } } #endif // USE_MODAL_PRESENTATION @@ -990,14 +997,18 @@ void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) ) max, // range this, // parent wxPD_CAN_ABORT | + wxPD_CAN_SKIP | wxPD_APP_MODAL | // wxPD_AUTO_HIDE | -- try this as well wxPD_ELAPSED_TIME | wxPD_ESTIMATED_TIME | - wxPD_REMAINING_TIME); + wxPD_REMAINING_TIME | + wxPD_SMOOTH); bool cont = true; - for ( int i = 0; i <= max; i++ ) + bool skip = false; + // each skip will move progress about quarter forward + for ( int i = 0; i <= max; i = wxMin(i+(skip?int(max/4):1), max+1), skip = false ) { #if wxUSE_STOPWATCH && wxUSE_LONGLONG // do (almost) the same operations as we did for the performance test @@ -1018,25 +1029,27 @@ void MyFrame::ShowProgress( wxCommandEvent& WXUNUSED(event) ) #else wxSleep(1); #endif + + wxString msg; + if ( i == max ) { - cont = dialog.Update(i, _T("That's all, folks!")); + msg = _T("That's all, folks!"); } - else if ( i == max / 2 ) + else if ( i > max / 2 ) { - cont = dialog.Update(i, _T("Only a half left (very long message)!")); + msg = _T("Only a half left (very long message)!"); } - else + +#if wxUSE_STOPWATCH && wxUSE_LONGLONG + if ( (i % (max/100)) == 0 ) // // only 100 updates, this makes it much faster { - #if wxUSE_STOPWATCH && wxUSE_LONGLONG - if ( (i % (max/100)) == 0 ) // // only 100 updates, this makes it much faster - { - cont = dialog.Update(i); - } - #else - cont = dialog.Update(i); - #endif + cont = dialog.Update(i, msg, &skip); } +#else + cont = dialog.Update(i, msg, &skip); +#endif + if ( !cont ) { if ( wxMessageBox(_T("Do you really want to cancel?"),