From f994a8ac8daef7ba9908af3e56f4b4d78fcbf958 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 20 Apr 2010 11:10:33 +0000 Subject: [PATCH] Add wxProgressDialog::Was{Cancelled,Skipped}() convenience methods. Although the information about "Cancel" and "Skip" buttons presses is returned from Update(), sometimes it may be more convenient to ask the dialog about whether it was cancelled or skipped instead of storing it in the program itself. Add the methods which allow to check for this. Closes #10903. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64057 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/generic/progdlgg.h | 5 +++++ interface/wx/progdlg.h | 26 ++++++++++++++++++++++++++ src/generic/progdlgg.cpp | 12 ++++++++++++ 4 files changed, 44 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index ff8af76198..45f8609b99 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -509,6 +509,7 @@ All (GUI): - Added support for gradient stops in wxGraphicsContext (Kit Bishop). - Added wxTransparentColour. - Added wxToolBar::GetToolByPos(). +- Added wxProgressDialog::Was{Cancelled,Skipped}() (Julien Weinzorn). GTK: diff --git a/include/wx/generic/progdlgg.h b/include/wx/generic/progdlgg.h index 4a296b6af9..5a90d1f1f4 100644 --- a/include/wx/generic/progdlgg.h +++ b/include/wx/generic/progdlgg.h @@ -48,6 +48,11 @@ public: void SetRange(int maximum); + // Return whether "Cancel" or "Skip" button was pressed, always return + // false if the corresponding button is not shown. + bool WasCancelled() const; + bool WasSkipped() const; + // Must provide overload to avoid hiding it (and warnings about it) virtual void Update() { wxDialog::Update(); } diff --git a/interface/wx/progdlg.h b/interface/wx/progdlg.h index 7847a230c2..221f1edaf1 100644 --- a/interface/wx/progdlg.h +++ b/interface/wx/progdlg.h @@ -137,6 +137,32 @@ public: */ void SetRange(int maximum); + + /** + Returns true if the "Cancel" button was pressed. + + Normally a Cancel button press is indicated by Update() returning + @false but sometimes it may be more convenient to check if the dialog + was cancelled from elsewhere in the code and this function allows to + do it. + + It always returns @false if the Cancel button is not shown at all. + + @since 2.9.1 + */ + bool WasCancelled() const; + + /** + Returns true if the "Skip" button was pressed. + + This is similar to WasCancelled() but returns @true if the "Skip" + button was pressed, not the "Cancel" one. + + @since 2.9.1 + */ + bool WasSkipped() const; + + /** Updates the dialog, setting the progress bar to the new value and updating the message if new one is specified. diff --git a/src/generic/progdlgg.cpp b/src/generic/progdlgg.cpp index 443d354104..ef7b89b24e 100644 --- a/src/generic/progdlgg.cpp +++ b/src/generic/progdlgg.cpp @@ -538,6 +538,18 @@ void wxProgressDialog::SetRange(int maximum) #endif // __WXMSW__ } + +bool wxProgressDialog::WasCancelled() const +{ + return m_hasAbortButton && m_state == Canceled; +} + +bool wxProgressDialog::WasSkipped() const +{ + return m_hasSkipButton && m_skip; +} + + // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- -- 2.45.2