Merge branch '18189-progdlg-modality'

See https://github.com/wxWidgets/wxWidgets/pull/886
This commit is contained in:
Vadim Zeitlin
2018-08-18 15:06:27 +02:00
2 changed files with 16 additions and 4 deletions

View File

@@ -55,8 +55,9 @@
@beginStyleTable @beginStyleTable
@style{wxPD_APP_MODAL} @style{wxPD_APP_MODAL}
Make the progress dialog modal. If this flag is not given, it is Make the progress dialog application-modal, i.e. disable all
only "locally" modal - that is the input to the parent window is application windows while it is shown. If this flag is not given, it
is only "locally" modal -- that is the input to the parent window is
disabled, but not to the other ones. disabled, but not to the other ones.
@style{wxPD_AUTO_HIDE} @style{wxPD_AUTO_HIDE}
Causes the progress dialog to disappear from screen as soon as the Causes the progress dialog to disappear from screen as soon as the
@@ -104,7 +105,11 @@ public:
In the generic implementation the progress bar is constructed In the generic implementation the progress bar is constructed
only if this value is greater than zero. only if this value is greater than zero.
@param parent @param parent
Parent window. Parent window. It will be disabled while this dialog is shown if
non-null (whether @c wxPD_APP_MODAL is specified or not). Note that
if you specify null parent and don't use @c wxPD_APP_MODAL, you
need to take care to avoid reentrancies, i.e. avoiding showing the
progress dialog again while this one is shown.
@param style @param style
The dialog style. See wxProgressDialog. The dialog style. See wxProgressDialog.
*/ */

View File

@@ -134,7 +134,14 @@ wxGenericProgressDialog::wxGenericProgressDialog(const wxString& title,
void wxGenericProgressDialog::SetTopParent(wxWindow* parent) void wxGenericProgressDialog::SetTopParent(wxWindow* parent)
{ {
m_parent = parent; m_parent = parent;
m_parentTop = GetParentForModalDialog(parent, GetWindowStyle());
// Notice that we intentionally do not use GetParentForModalDialog() here
// as we don't want to disable the main application window if null parent
// was given (and GetParentForModalDialog() would fall back to it in this
// case). This allows creating modeless progress dialog, which can be
// useful even though it is also dangerous because it can easily result in
// unwanted reentrancies.
m_parentTop = parent;
} }
bool wxGenericProgressDialog::Create( const wxString& title, bool wxGenericProgressDialog::Create( const wxString& title,