]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/evtloop.cpp
freeze whole window for TLW
[wxWidgets.git] / src / osx / carbon / evtloop.cpp
index abaafd3181f7d4a72946575c58c656aee273ef54..68695943bb582338a3bbdec6dc47e7e9bdc7dc4a 100644 (file)
     #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,62 @@ int wxGUIEventLoop::DoDispatchTimeout(unsigned long timeout)
             return 1;
     }
 }
+
+void wxGUIEventLoop::DoRun()
+{
+    wxMacAutoreleasePool autoreleasepool;
+    RunApplicationEventLoop();
+}
+
+void wxGUIEventLoop::DoStop()
+{
+    QuitApplicationEventLoop();
+}
+
+wxModalEventLoop::wxModalEventLoop(wxWindow *winModal)
+{
+    m_modalWindow = dynamic_cast<wxNonOwnedWindow*> (winModal);
+    wxASSERT_MSG( m_modalWindow != NULL, "must pass in a toplevel window for modal event loop" );
+}
+
+void wxModalEventLoop::DoRun()
+{
+    wxMacAutoreleasePool autoreleasepool;
+    WindowRef windowRef = m_modalWindow->GetWXWindow();
+
+    WindowGroupRef windowGroup = NULL;
+    WindowGroupRef formerParentGroup = NULL;
+    bool resetGroupParent = false;
+    
+    // make sure modal dialogs are in the right layer so that they are not covered
+    
+    if ( m_modalWindow->GetParent() == NULL )
+    {
+        windowGroup = GetWindowGroup(windowRef) ;
+        if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) )
+        {
+            formerParentGroup = GetWindowGroupParent( windowGroup );
+            SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) );
+            resetGroupParent = true;
+        }
+    }
+
+    m_modalWindow->SetFocus();
+    
+    RunAppModalLoopForWindow(windowRef);
+
+    if ( resetGroupParent )
+    {
+        SetWindowGroupParent( windowGroup , formerParentGroup );
+    }
+
+}
+
+void wxModalEventLoop::DoStop()
+{
+    wxMacAutoreleasePool autoreleasepool;
+    WindowRef theWindow = m_modalWindow->GetWXWindow();
+    QuitAppModalLoopForWindow(theWindow);
+}
+
+