]> git.saurik.com Git - wxWidgets.git/commitdiff
allowing direct native tlw modal loops
authorStefan Csomor <csomor@advancedconcepts.ch>
Thu, 8 Apr 2010 09:46:36 +0000 (09:46 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Thu, 8 Apr 2010 09:46:36 +0000 (09:46 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63912 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/evtloop.h
src/osx/carbon/evtloop.cpp
src/osx/cocoa/evtloop.mm
src/osx/iphone/evtloop.mm

index b86cfeecf3c74c8aa4f179aa24804ea08367d8f1..45b411e9031084ff919f70840f7131bfd6160faf 100644 (file)
@@ -98,7 +98,8 @@ class WXDLLIMPEXP_FWD_CORE wxNonOwnedWindow;
 class WXDLLIMPEXP_CORE wxModalEventLoop : public wxGUIEventLoop
 {
 public:
-    wxModalEventLoop(wxWindow *winModal);
+    wxModalEventLoop(wxWindow *modalWindow);
+    wxModalEventLoop(WXWindow modalNativeWindow);
     
 protected:
     virtual void DoRun();
@@ -107,6 +108,7 @@ protected:
     
     // (in case) the modal window for this event loop
     wxNonOwnedWindow* m_modalWindow;
+    WXWindow m_modalNativeWindow;
 };
 
 #endif // wxUSE_GUI
index 68695943bb582338a3bbdec6dc47e7e9bdc7dc4a..4ca136ca90ad9eb21eba418d409cd60f6a99c24c 100644 (file)
@@ -94,37 +94,51 @@ void wxGUIEventLoop::DoStop()
     QuitApplicationEventLoop();
 }
 
-wxModalEventLoop::wxModalEventLoop(wxWindow *winModal)
+// TODO move into a evtloop_osx.cpp
+
+wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow)
 {
-    m_modalWindow = dynamic_cast<wxNonOwnedWindow*> (winModal);
+    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 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 )
     {
@@ -136,8 +150,7 @@ void wxModalEventLoop::DoRun()
 void wxModalEventLoop::DoStop()
 {
     wxMacAutoreleasePool autoreleasepool;
-    WindowRef theWindow = m_modalWindow->GetWXWindow();
-    QuitAppModalLoopForWindow(theWindow);
+    QuitAppModalLoopForWindow(m_modalNativeWindow);
 }
 
 
index cfa7486f84365f21d661ce191e29c9a75a0b4820..bcd24e8405fd41e84156e860d81b92046094a5ae 100644 (file)
@@ -175,12 +175,24 @@ void wxGUIEventLoop::DoStop()
     [NSApp stop:0];
 }
 
-wxModalEventLoop::wxModalEventLoop(wxWindow *winModal)
+// TODO move into a evtloop_osx.cpp
+
+wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow)
 {
-    m_modalWindow = dynamic_cast<wxNonOwnedWindow*> (winModal);
+    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;
@@ -197,8 +209,7 @@ void wxModalEventLoop::DoRun()
         }
     }
     
-    NSWindow* theWindow = m_modalWindow->GetWXWindow();
-    [NSApp runModalForWindow:theWindow];
+    [NSApp runModalForWindow:m_modalNativeWindow];
 }
 
 void wxModalEventLoop::DoStop()
index 41b8235296d5504ddee17da5825442ab8b4451db..e050cdd0ce5829832a09eb8347b3733eeee2e7d3 100644 (file)
@@ -97,12 +97,25 @@ void wxGUIEventLoop::DoRun()
     }
 }
 
-wxModalEventLoop::wxModalEventLoop(wxWindow *winModal)
+// TODO move into a evtloop_osx.cpp
+
+wxModalEventLoop::wxModalEventLoop(wxWindow *modalWindow)
 {
-    m_modalWindow = dynamic_cast<wxNonOwnedWindow*> (winModal);
+    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()
 {
     // presentModalViewController:animated: