Refactor wxWindowDisabler to allow skipping more than one window
This is not implemented yet, but this commit changes DoDisable() to disable all windows except those in the list of the windows not to be disabled instead of explicitly checking for just a single window to skip. Rename m_winDisabled to m_windowsToSkip to better describe its purpose and also because it's a vector, and so should use plural form in its name. Finally note that AfterDisable() is called with NULL argument from the ctor not taking the window to skip for compatibility with the old code, but it's not clear if it's really the right thing to do and perhaps this shouldn't be done. No real changes yet.
This commit is contained in:
parent
53844108dd
commit
bc81682e7f
@ -739,8 +739,8 @@ public:
|
||||
~wxWindowDisabler();
|
||||
|
||||
private:
|
||||
// disable all windows except the given one (used by both ctors)
|
||||
void DoDisable(wxWindow *winToSkip = NULL);
|
||||
// disable all windows not in m_windowsToSkip
|
||||
void DoDisable();
|
||||
|
||||
#if defined(__WXOSX__) && wxOSX_USE_COCOA
|
||||
void AfterDisable(wxWindow* winToSkip);
|
||||
@ -748,7 +748,7 @@ private:
|
||||
|
||||
wxEventLoop* m_modalEventLoop = NULL;
|
||||
#endif
|
||||
wxVector<wxWindow*> m_winDisabled;
|
||||
wxVector<wxWindow*> m_windowsToSkip;
|
||||
bool m_disabled;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxWindowDisabler);
|
||||
|
@ -1517,16 +1517,30 @@ wxWindowDisabler::wxWindowDisabler(bool disable)
|
||||
{
|
||||
m_disabled = disable;
|
||||
if ( disable )
|
||||
{
|
||||
DoDisable();
|
||||
|
||||
#if defined(__WXOSX__) && wxOSX_USE_COCOA
|
||||
AfterDisable(NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
wxWindowDisabler::wxWindowDisabler(wxWindow *winToSkip)
|
||||
{
|
||||
m_disabled = true;
|
||||
DoDisable(winToSkip);
|
||||
|
||||
if ( winToSkip )
|
||||
m_windowsToSkip.push_back(winToSkip);
|
||||
|
||||
DoDisable();
|
||||
|
||||
#if defined(__WXOSX__) && wxOSX_USE_COCOA
|
||||
AfterDisable(winToSkip);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowDisabler::DoDisable(wxWindow *winToSkip)
|
||||
void wxWindowDisabler::DoDisable()
|
||||
{
|
||||
// remember the top level windows which were already disabled, so that we
|
||||
// don't reenable them later
|
||||
@ -1534,7 +1548,7 @@ void wxWindowDisabler::DoDisable(wxWindow *winToSkip)
|
||||
for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
|
||||
{
|
||||
wxWindow *winTop = node->GetData();
|
||||
if ( winTop == winToSkip )
|
||||
if ( wxVectorContains(m_windowsToSkip, winTop) )
|
||||
continue;
|
||||
|
||||
// we don't need to disable the hidden or already disabled windows
|
||||
@ -1544,13 +1558,9 @@ void wxWindowDisabler::DoDisable(wxWindow *winToSkip)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_winDisabled.push_back(winTop);
|
||||
m_windowsToSkip.push_back(winTop);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__WXOSX__) && wxOSX_USE_COCOA
|
||||
AfterDisable(winToSkip);
|
||||
#endif
|
||||
}
|
||||
|
||||
wxWindowDisabler::~wxWindowDisabler()
|
||||
@ -1566,11 +1576,11 @@ wxWindowDisabler::~wxWindowDisabler()
|
||||
for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
|
||||
{
|
||||
wxWindow *winTop = node->GetData();
|
||||
if ( !wxVectorContains(m_winDisabled, winTop) )
|
||||
if ( !wxVectorContains(m_windowsToSkip, winTop) )
|
||||
{
|
||||
winTop->Enable();
|
||||
}
|
||||
//else: had been already disabled, don't reenable
|
||||
//else: we didn't disable this window, so don't reenable it neither
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user