]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/evtloop.cpp
Allow the renderer to also work with wxMemoryDCs
[wxWidgets.git] / src / osx / carbon / evtloop.cpp
index f208d9801cdc0e90a4a907d37b99bc004a00e459..adc340a7143b3fd8fda57b87f43a9bd916532b91 100644 (file)
 #ifndef WX_PRECOMP
     #include "wx/app.h"
     #include "wx/log.h"
-    #include "wx/nonownedwnd.h"
 #endif // WX_PRECOMP
 
+#if wxUSE_GUI
+#include "wx/nonownedwnd.h"
+#endif
+
 #include "wx/osx/private.h"
 
 // ============================================================================
@@ -91,31 +94,57 @@ void wxGUIEventLoop::DoStop()
     QuitApplicationEventLoop();
 }
 
+CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const
+{
+    return wxCFEventLoop::CFGetCurrentRunLoop();
+}
+
+// TODO move into a evtloop_osx.cpp
+
+wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow)
+{
+    m_modalWindow = wxDynamicCast(modalWindow, wxNonOwnedWindow);
+    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()
 {
+    wxWindowDisabler disabler(m_modalWindow);
     wxMacAutoreleasePool autoreleasepool;
-    WindowRef windowRef = m_modalWindow->GetWXWindow();
+
+    bool resetGroupParent = false;
 
     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 )
+    if ( m_modalWindow != NULL )
     {
-        windowGroup = GetWindowGroup(windowRef) ;
-        if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) )
+        if ( m_modalWindow->GetParent() == NULL )
         {
-            formerParentGroup = GetWindowGroupParent( windowGroup );
-            SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) );
-            resetGroupParent = true;
+            windowGroup = GetWindowGroup(m_modalNativeWindow) ;
+            if ( windowGroup != GetWindowGroupOfClass( kMovableModalWindowClass ) )
+            {
+                formerParentGroup = GetWindowGroupParent( windowGroup );
+                SetWindowGroupParent( windowGroup, GetWindowGroupOfClass( kMovableModalWindowClass ) );
+                resetGroupParent = true;
+            }
         }
     }
 
     m_modalWindow->SetFocus();
     
-    RunAppModalLoopForWindow(windowRef);
+    RunAppModalLoopForWindow(m_modalNativeWindow);
 
     if ( resetGroupParent )
     {
@@ -127,8 +156,7 @@ void wxModalEventLoop::DoRun()
 void wxModalEventLoop::DoStop()
 {
     wxMacAutoreleasePool autoreleasepool;
-    WindowRef theWindow = m_modalWindow->GetWXWindow();
-    QuitAppModalLoopForWindow(theWindow);
+    QuitAppModalLoopForWindow(m_modalNativeWindow);
 }