From b5c9627778e8ba6e1a1358dbc6a737b6163cfbc0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 May 2013 14:43:06 +0000 Subject: [PATCH] Add wxPreferencesEditor::ShownModally(). While this is not necessary to use wxPreferencesEditor in normal scenario, it can be useful if the program needs to handle modal dialogs in some special way. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74009 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/preferences.h | 14 ++++++++++++++ include/wx/private/preferences.h | 4 ---- interface/wx/preferences.h | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/include/wx/preferences.h b/include/wx/preferences.h index 935c7b1875..ab1e0a2c99 100644 --- a/include/wx/preferences.h +++ b/include/wx/preferences.h @@ -24,9 +24,13 @@ class wxPreferencesEditorImpl; #define wxHAS_PREF_EDITOR_ICONS // Changes should be applied immediately #define wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY + // The dialog is shown non-modally. + #define wxHAS_PREF_EDITOR_MODELESS #elif defined(__WXGTK__) // Changes should be applied immediately #define wxHAS_PREF_EDITOR_APPLY_IMMEDIATELY + // The dialog is shown non-modally. + #define wxHAS_PREF_EDITOR_MODELESS #endif // ---------------------------------------------------------------------------- @@ -117,6 +121,16 @@ public: #endif } + // Whether the dialog is shown modally, i.e. Show() blocks, or not. + static bool ShownModally() + { +#ifdef wxHAS_PREF_EDITOR_MODELESS + return false; +#else + return true; +#endif + } + private: wxPreferencesEditorImpl* m_impl; diff --git a/include/wx/private/preferences.h b/include/wx/private/preferences.h index f68893a99d..7d0cb292fc 100644 --- a/include/wx/private/preferences.h +++ b/include/wx/private/preferences.h @@ -17,10 +17,6 @@ #define wxHAS_PREF_EDITOR_NATIVE #endif -#if defined(__WXOSX__) || defined(__WXGTK__) - #define wxHAS_PREF_EDITOR_MODELESS -#endif - // ---------------------------------------------------------------------------- // wxPreferencesEditorImpl: defines wxPreferencesEditor implementation. // ---------------------------------------------------------------------------- diff --git a/interface/wx/preferences.h b/interface/wx/preferences.h index 656ce907c1..161d78755c 100644 --- a/interface/wx/preferences.h +++ b/interface/wx/preferences.h @@ -98,6 +98,23 @@ public: in this case as well. */ static bool ShouldApplyChangesImmediately() + + /** + Returns whether the preferences dialog is shown modally. + + If this method returns false, as it currently does in wxGTK and wxOSX, + Show() simply makes the dialog visible and returns immediately. If it + returns true, as it does in wxMSW and under the other platforms, then + the dialog is shown modally, i.e. Show() blocks until the user + dismisses it. + + Notice that it isn't necessary to test the return value of this method + to use this class normally, its interface is designed to work in both + cases. However it can sometimes be necessary to call it if the program + needs to handle modal dialogs specially, e.g. perhaps to block some + periodic background update operation while a modal dialog is shown. + */ + static bool ShownModally(); }; -- 2.45.2