]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/evtloop.mm
modeling subclassing along msw, unsubclassing filedialog at end of ShowModal, fixes...
[wxWidgets.git] / src / osx / cocoa / evtloop.mm
index 97a3b763300e8c36850c5d190db2773fce21b97c..11e9d211296b72c4fbe181d032fd90410ddfb787 100644 (file)
@@ -28,6 +28,7 @@
 
 #ifndef WX_PRECOMP
     #include "wx/app.h"
 
 #ifndef WX_PRECOMP
     #include "wx/app.h"
+    #include "wx/nonownedwnd.h"
 #endif // WX_PRECOMP
 
 #include "wx/log.h"
 #endif // WX_PRECOMP
 
 #include "wx/log.h"
@@ -117,10 +118,16 @@ bool wxGUIEventLoop::Dispatch()
                 inMode:NSDefaultRunLoopMode
                 dequeue: YES])
     {
                 inMode:NSDefaultRunLoopMode
                 dequeue: YES])
     {
+        WXEVENTREF formerEvent = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEvent();
+        WXEVENTHANDLERCALLREF formerHandler = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEventHandlerCallRef();
+
         if (wxTheApp)
             wxTheApp->MacSetCurrentEvent(event, NULL);
         m_sleepTime = 0.0;
         [NSApp sendEvent: event];
         if (wxTheApp)
             wxTheApp->MacSetCurrentEvent(event, NULL);
         m_sleepTime = 0.0;
         [NSApp sendEvent: event];
+
+        if (wxTheApp)
+            wxTheApp->MacSetCurrentEvent(formerEvent , formerHandler);
     }
     else
     {
     }
     else
     {
@@ -174,6 +181,31 @@ void wxGUIEventLoop::DoStop()
     [NSApp stop:0];
 }
 
     [NSApp stop:0];
 }
 
+CFRunLoopRef wxGUIEventLoop::CFGetCurrentRunLoop() const
+{
+    NSRunLoop* nsloop = [NSRunLoop currentRunLoop];
+    return [nsloop getCFRunLoop];
+}
+
+
+// TODO move into a evtloop_osx.cpp
+
+wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow)
+{
+    m_modalWindow = dynamic_cast<wxNonOwnedWindow*> (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 pool;
 void wxModalEventLoop::DoRun()
 {
     wxMacAutoreleasePool pool;
@@ -190,8 +222,7 @@ void wxModalEventLoop::DoRun()
         }
     }
     
         }
     }
     
-    NSWindow* theWindow = m_modalWindow->GetWXWindow();
-    [NSApp runModalForWindow:theWindow];
+    [NSApp runModalForWindow:m_modalNativeWindow];
 }
 
 void wxModalEventLoop::DoStop()
 }
 
 void wxModalEventLoop::DoStop()