]> git.saurik.com Git - wxWidgets.git/commitdiff
supporting nested window disablers on the same window
authorStefan Csomor <csomor@advancedconcepts.ch>
Mon, 6 Jun 2011 16:32:41 +0000 (16:32 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Mon, 6 Jun 2011 16:32:41 +0000 (16:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67866 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/cocoa/evtloop.h
src/osx/cocoa/evtloop.mm

index c8b5d9e66641ad03054810a326e220cfb9da3ca3..e38cf92c388d4c292fe8a7750d0fbfe2e0e689b6 100644 (file)
@@ -31,7 +31,12 @@ protected:
     virtual CFRunLoopRef CFGetCurrentRunLoop() const;
     
     void* m_modalSession;
     virtual CFRunLoopRef CFGetCurrentRunLoop() const;
     
     void* m_modalSession;
+    
+    wxWindow* m_modalWindow;
+    
     WXWindow m_dummyWindow;
     WXWindow m_dummyWindow;
+    
+    int m_modalNestedLevel;
 };
 
 #endif // _WX_OSX_COCOA_EVTLOOP_H_
 };
 
 #endif // _WX_OSX_COCOA_EVTLOOP_H_
index c9ac5ee75d8216e057500322aa0fbf3d3b028843..4814425583f7b88a8f5380297b878f6f3be1d617 100644 (file)
@@ -107,12 +107,15 @@ wxGUIEventLoop::wxGUIEventLoop()
 {
     m_modalSession = nil;
     m_dummyWindow = nil;
 {
     m_modalSession = nil;
     m_dummyWindow = nil;
+    m_modalNestedLevel = 0;
+    m_modalWindow = NULL;
 }
 
 wxGUIEventLoop::~wxGUIEventLoop()
 {
     wxASSERT( m_modalSession == nil );
     wxASSERT( m_dummyWindow == nil );
 }
 
 wxGUIEventLoop::~wxGUIEventLoop()
 {
     wxASSERT( m_modalSession == nil );
     wxASSERT( m_dummyWindow == nil );
+    wxASSERT( m_modalNestedLevel == 0 );
 }
 
 //-----------------------------------------------------------------------------
 }
 
 //-----------------------------------------------------------------------------
@@ -308,6 +311,16 @@ void wxModalEventLoop::DoStop()
 void wxGUIEventLoop::BeginModalSession( wxWindow* modalWindow )
 {
     WXWindow nsnow = nil;
 void wxGUIEventLoop::BeginModalSession( wxWindow* modalWindow )
 {
     WXWindow nsnow = nil;
+
+    if ( m_modalNestedLevel > 0 )
+    {
+        wxASSERT_MSG( m_modalWindow == modalWindow, "Nested Modal Sessions must be based on same window");
+        m_modalNestedLevel++;
+        return;
+    }
+    
+    m_modalWindow = modalWindow;
+    m_modalNestedLevel = 1;
     
     if ( modalWindow )
     {
     
     if ( modalWindow )
     {
@@ -339,12 +352,18 @@ void wxGUIEventLoop::BeginModalSession( wxWindow* modalWindow )
 void wxGUIEventLoop::EndModalSession()
 {
     wxASSERT_MSG(m_modalSession != NULL, "no modal session active");
 void wxGUIEventLoop::EndModalSession()
 {
     wxASSERT_MSG(m_modalSession != NULL, "no modal session active");
-    [NSApp endModalSession:(NSModalSession)m_modalSession];
-    m_modalSession = nil;
-    if ( m_dummyWindow )
+    
+    wxASSERT_MSG(m_modalNestedLevel > 0, "incorrect modal nesting level");
+    
+    if ( --m_modalNestedLevel == 0 )
     {
     {
-        [m_dummyWindow release];
-        m_dummyWindow = nil;
+        [NSApp endModalSession:(NSModalSession)m_modalSession];
+        m_modalSession = nil;
+        if ( m_dummyWindow )
+        {
+            [m_dummyWindow release];
+            m_dummyWindow = nil;
+        }
     }
 }
 
     }
 }