added wxWindowDisabler ctor for conditionally disabling all windows and use it in WaitForChild()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52671 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -649,16 +649,28 @@ WXDLLEXPORT bool wxCheckForInterrupt(wxWindow *wnd);
|
|||||||
// Consume all events until no more left
|
// Consume all events until no more left
|
||||||
WXDLLEXPORT void wxFlushEvents();
|
WXDLLEXPORT void wxFlushEvents();
|
||||||
|
|
||||||
// a class which disables all windows (except, may be, thegiven one) in its
|
// a class which disables all windows (except, may be, the given one) in its
|
||||||
// ctor and enables them back in its dtor
|
// ctor and enables them back in its dtor
|
||||||
class WXDLLEXPORT wxWindowDisabler
|
class WXDLLEXPORT wxWindowDisabler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxWindowDisabler(wxWindow *winToSkip = (wxWindow *)NULL);
|
// this ctor conditionally disables all windows: if the argument is false,
|
||||||
|
// it doesn't do anything
|
||||||
|
wxWindowDisabler(bool disable = true);
|
||||||
|
|
||||||
|
// ctor disables all windows except winToSkip
|
||||||
|
wxWindowDisabler(wxWindow *winToSkip);
|
||||||
|
|
||||||
|
// dtor enables back all windows disabled by the ctor
|
||||||
~wxWindowDisabler();
|
~wxWindowDisabler();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// disable all windows except the given one (used by both ctors)
|
||||||
|
void DoDisable(wxWindow *winToSkip = NULL);
|
||||||
|
|
||||||
|
|
||||||
wxWindowList *m_winDisabled;
|
wxWindowList *m_winDisabled;
|
||||||
|
bool m_disabled;
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(wxWindowDisabler)
|
DECLARE_NO_COPY_CLASS(wxWindowDisabler)
|
||||||
};
|
};
|
||||||
|
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
This class disables all windows of the application (may be with the exception
|
This class disables all windows of the application (may be with the exception
|
||||||
of one of them) in its constructor and enables them back in its destructor.
|
of one of them) in its constructor and enables them back in its destructor.
|
||||||
This comes in handy when you want to indicate to the user that the application
|
|
||||||
|
This is useful when you want to indicate to the user that the application
|
||||||
is currently busy and cannot respond to user input.
|
is currently busy and cannot respond to user input.
|
||||||
|
|
||||||
@library{wxcore}
|
@library{wxcore}
|
||||||
@@ -23,11 +24,21 @@
|
|||||||
class wxWindowDisabler
|
class wxWindowDisabler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
Disables all top level windows of the applications.
|
||||||
|
|
||||||
|
If @a disable is @c false nothing is done. This can be convenient if
|
||||||
|
the windows should be disabled depending on some condition.
|
||||||
|
|
||||||
|
@since 2.9.0
|
||||||
|
*/
|
||||||
|
wxWindowDisabler(bool disable = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Disables all top level windows of the applications with the exception of
|
Disables all top level windows of the applications with the exception of
|
||||||
@a winToSkip if it is not @NULL.
|
@a winToSkip if it is not @NULL.
|
||||||
*/
|
*/
|
||||||
wxWindowDisabler(wxWindow* winToSkip = NULL);
|
wxWindowDisabler(wxWindow* winToSkip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reenables back the windows disabled by the constructor.
|
Reenables back the windows disabled by the constructor.
|
||||||
|
@@ -1561,7 +1561,20 @@ void wxEnableTopLevelWindows(bool enable)
|
|||||||
node->GetData()->Enable(enable);
|
node->GetData()->Enable(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxWindowDisabler::wxWindowDisabler(bool disable)
|
||||||
|
{
|
||||||
|
m_disabled = disable;
|
||||||
|
if ( disable )
|
||||||
|
DoDisable();
|
||||||
|
}
|
||||||
|
|
||||||
wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip)
|
wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip)
|
||||||
|
{
|
||||||
|
m_disabled = true;
|
||||||
|
DoDisable(winToSkip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxWindowDisabler::DoDisable(wxWindow *winToSkip)
|
||||||
{
|
{
|
||||||
// remember the top level windows which were already disabled, so that we
|
// remember the top level windows which were already disabled, so that we
|
||||||
// don't reenable them later
|
// don't reenable them later
|
||||||
@@ -1593,6 +1606,9 @@ wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip)
|
|||||||
|
|
||||||
wxWindowDisabler::~wxWindowDisabler()
|
wxWindowDisabler::~wxWindowDisabler()
|
||||||
{
|
{
|
||||||
|
if ( !m_disabled )
|
||||||
|
return;
|
||||||
|
|
||||||
wxWindowList::compatibility_iterator node;
|
wxWindowList::compatibility_iterator node;
|
||||||
for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
|
for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
|
||||||
{
|
{
|
||||||
|
@@ -1447,8 +1447,7 @@ int wxGUIAppTraits::WaitForChild(wxExecuteData& execData)
|
|||||||
// prepare to wait for the child termination: show to the user that we're
|
// prepare to wait for the child termination: show to the user that we're
|
||||||
// busy and refuse all input unless explicitly told otherwise
|
// busy and refuse all input unless explicitly told otherwise
|
||||||
wxBusyCursor bc;
|
wxBusyCursor bc;
|
||||||
wxWindowDisabler *wd = flags & wxEXEC_NODISABLE ? NULL
|
wxWindowDisabler wd(!(flags & wxEXEC_NODISABLE));
|
||||||
: new wxWindowDisabler;
|
|
||||||
|
|
||||||
// endProcData.pid will be set to 0 from wxHandleProcessTermination() when
|
// endProcData.pid will be set to 0 from wxHandleProcessTermination() when
|
||||||
// the process terminates
|
// the process terminates
|
||||||
@@ -1480,8 +1479,6 @@ int wxGUIAppTraits::WaitForChild(wxExecuteData& execData)
|
|||||||
wxYield();
|
wxYield();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete wd;
|
|
||||||
|
|
||||||
return endProcData.exitcode;
|
return endProcData.exitcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user