]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/dirdlg.mm
Add wxDataViewCtrl::SetRowHeight() and provide its generic implementation.
[wxWidgets.git] / src / osx / cocoa / dirdlg.mm
index 9baab201ae0cfedb2888e407bb438374c71df973..917e35dfeb45611435009449ed2c0493f1b4c612 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Stefan Csomor
 // Modified by:
 // Created:     2008-08-30
-// RCS-ID:      $Id: dirdlg.mm 40007 2006-07-05 13:10:46Z SC $
+// RCS-ID:      $Id$
 // Copyright:   (c) Stefan Csomor
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -47,11 +47,12 @@ wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
     SetPath(defaultPath);
 }
 
-
-int wxDirDialog::ShowModal()
+void wxDirDialog::ShowWindowModal()
 {
-    int result = wxID_CANCEL;
-
+    wxCFStringRef dir( m_path );
+    
+    m_modality = wxDIALOG_MODALITY_WINDOW_MODAL;
+    
     NSOpenPanel *oPanel = [NSOpenPanel openPanel];
     [oPanel setCanChooseDirectories:YES];
     [oPanel setResolvesAliases:YES];
@@ -62,47 +63,65 @@ int wxDirDialog::ShowModal()
 
     if ( HasFlag(wxDD_NEW_DIR_BUTTON) )
         [oPanel setCanCreateDirectories:YES];
-
-    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");
-    }
-
-/*
+    
+    wxASSERT_MSG(parentWindow, "Window modal display requires parent.");
+    
     if (parentWindow)
     {
         NSWindow* nativeParent = parentWindow->GetWXWindow();
         ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init];
+        [sheetDelegate setImplementation: this];
         [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];
     }
+}
+
+int wxDirDialog::ShowModal()
+{
+    NSOpenPanel *oPanel = [NSOpenPanel openPanel];
+    [oPanel setCanChooseDirectories:YES];
+    [oPanel setResolvesAliases:YES];
+    [oPanel setCanChooseFiles:NO];
+
+    wxCFStringRef cf( m_message );
+    [oPanel setMessage:cf.AsNSString()];
+
+    if ( HasFlag(wxDD_NEW_DIR_BUTTON) )
+        [oPanel setCanCreateDirectories:YES];
+
+    wxCFStringRef dir( m_path );
+
+    m_path = wxEmptyString;
+
+    int returnCode = -1;
+
+    returnCode = (NSInteger)[oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil];
+    ModalFinishedCallback(oPanel, returnCode);
+
+    return GetReturnCode();
+}
+
+void wxDirDialog::ModalFinishedCallback(void* panel, int returnCode)
+{
+    int result = wxID_CANCEL;
+
     if (returnCode == NSOKButton )
     {
+        NSOpenPanel* oPanel = (NSOpenPanel*)panel;
         SetPath( wxCFStringRef::AsString([[oPanel filenames] objectAtIndex:0]));
         result = wxID_OK;
     }
-    return result;
+    SetReturnCode(result);
+    
+    if (GetModality() == wxDIALOG_MODALITY_WINDOW_MODAL)
+        SendWindowModalDialogEvent ( wxEVT_WINDOW_MODAL_DIALOG_CLOSED  );
 }
 
 #endif // wxUSE_DIRDLG