X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0056673c672ab444863c57344936c9a322124df6..ad05cdb74c4a1e632b6e9c5e56f463c6d798457b:/src/osx/carbon/evtloop.cpp diff --git a/src/osx/carbon/evtloop.cpp b/src/osx/carbon/evtloop.cpp index abaafd3181..4ca136ca90 100644 --- a/src/osx/carbon/evtloop.cpp +++ b/src/osx/carbon/evtloop.cpp @@ -31,6 +31,10 @@ #include "wx/log.h" #endif // WX_PRECOMP +#if wxUSE_GUI +#include "wx/nonownedwnd.h" +#endif + #include "wx/osx/private.h" // ============================================================================ @@ -55,6 +59,8 @@ static void DispatchAndReleaseEvent(EventRef theEvent) int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout) { + wxMacAutoreleasePool autoreleasepool; + EventRef event; OSStatus status = ReceiveNextEvent(0, NULL, timeout/1000, true, &event); switch ( status ) @@ -76,3 +82,75 @@ int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout) return 1; } } + +void wxGUIEventLoop::DoRun() +{ + wxMacAutoreleasePool autoreleasepool; + RunApplicationEventLoop(); +} + +void wxGUIEventLoop::DoStop() +{ + QuitApplicationEventLoop(); +} + +// TODO move into a evtloop_osx.cpp + +wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow) +{ + m_modalWindow = dynamic_cast (modalWindow); + wxASSERT_MSG( m_modalWindow != NULL, "must pass in a toplevel window for modal event loop" ); + m_modalNativeWindow = m_modalWindow->GetWXWindow(); +} + +wxModalEventLoop::wxModalEventLoop(WXWindow modalNativeWindow) +{ + m_modalWindow = NULL; + wxASSERT_MSG( modalNativeWindow != NULL, "must pass in a toplevel window for modal event loop" ); + m_modalNativeWindow = modalNativeWindow; +} + +// END move into a evtloop_osx.cpp + +void wxModalEventLoop::DoRun() +{ + wxMacAutoreleasePool autoreleasepool; + + bool resetGroupParent = false; + + WindowGroupRef windowGroup = NULL; + WindowGroupRef formerParentGroup = NULL; + + // make sure modal dialogs are in the right layer so that they are not covered + if ( m_modalWindow != NULL ) + { + if ( m_modalWindow->GetParent() == NULL ) + { + windowGroup = GetWindowGroup(m_modalNativeWindow) ; + if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) ) + { + formerParentGroup = GetWindowGroupParent( windowGroup ); + SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) ); + resetGroupParent = true; + } + } + } + + m_modalWindow->SetFocus(); + + RunAppModalLoopForWindow(m_modalNativeWindow); + + if ( resetGroupParent ) + { + SetWindowGroupParent( windowGroup , formerParentGroup ); + } + +} + +void wxModalEventLoop::DoStop() +{ + wxMacAutoreleasePool autoreleasepool; + QuitAppModalLoopForWindow(m_modalNativeWindow); +} + +