]> git.saurik.com Git - wxWidgets.git/commitdiff
Sheet support for wxDirDialog.
authorKevin Ollivier <kevino@theolliviers.com>
Thu, 5 Mar 2009 21:21:45 +0000 (21:21 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Thu, 5 Mar 2009 21:21:45 +0000 (21:21 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59354 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index 8e7761505da90c84aa82d64d5510ddad08a0fc95..4ffad16d3495f979733acb73570bd8a45412c756 100644 (file)
@@ -26,7 +26,6 @@ public:
     virtual int ShowModal();
 
 protected:
-    wxWindow *  m_parent;
 
     DECLARE_DYNAMIC_CLASS(wxDirDialog)
 };
index 6094f86e03751ee10a982e2b6d90316ddf5fe6b1..4f5063ba61a8e607a2644a91fff40752083a5c77 100644 (file)
@@ -66,8 +66,36 @@ int wxDirDialog::ShowModal()
     wxCFStringRef dir( m_path );
     
     m_path = wxEmptyString;
+
+    wxNonOwnedWindow* parentWindow = NULL;
+    int returnCode = -1;
+    
+    if (GetParent()) 
+    {
+        parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
+    }
+    else
+    {
+        fprintf(stderr, "No parent!\n");
+    }
     
-    if ( [oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil] == NSOKButton )
+    if (parentWindow)
+    {
+        NSWindow* nativeParent = parentWindow->GetWXWindow();
+        ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init]; 
+        [oPanel beginSheetForDirectory:dir.AsNSString() file:nil types: nil 
+            modalForWindow: nativeParent modalDelegate: sheetDelegate 
+            didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) 
+            contextInfo: nil];
+        [sheetDelegate waitForSheetToFinish];
+        returnCode = [sheetDelegate code];
+        [sheetDelegate release];
+    }
+    else
+    {
+        returnCode = (NSInteger)[oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil];
+    }
+    if (returnCode == NSOKButton )
     {
         wxCFStringRef resultpath( [[[oPanel filenames] objectAtIndex:0] retain] );