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