diff --git a/include/wx/utils.h b/include/wx/utils.h index b522ec1f51..54d06f2fbd 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -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 m_winDisabled; + wxVector m_windowsToSkip; bool m_disabled; wxDECLARE_NO_COPY_CLASS(wxWindowDisabler); diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 4294dbb115..6dcc445618 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -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 } }