]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/filedlg.mm
simplifying code, removing outdated API
[wxWidgets.git] / src / osx / cocoa / filedlg.mm
index dfb81bc98dec7ce5c44a0f1f7744600479418030..916b4e8b7a677880203d9d86de7250b4e27319b7 100644 (file)
@@ -153,11 +153,14 @@ int wxFileDialog::ShowModal()
 
     m_path = wxEmptyString;
     m_fileNames.Clear();
-    
+    m_paths.Clear();
+    // since we don't support retrieving the matching filter
+    m_filterIndex = -1;
+
     wxNonOwnedWindow* parentWindow = NULL;
     int returnCode = -1;
-    
-    if (GetParent()) 
+
+    if (GetParent())
     {
         parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
     }
@@ -176,33 +179,32 @@ int wxFileDialog::ShowModal()
         if ( HasFlag(wxFD_OVERWRITE_PROMPT) )
         {
         }
-    
-        // avoid multiple event handlers on stack
-        if ( 0 /*parentWindow*/)
+
+/*
+        if (parentWindow)
         {
             NSWindow* nativeParent = parentWindow->GetWXWindow();
-            ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init]; 
-            [sPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString() 
-                modalForWindow: nativeParent modalDelegate: sheetDelegate 
-                didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) 
+            ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init];
+            [sPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString()
+                modalForWindow: nativeParent modalDelegate: sheetDelegate
+                didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
                 contextInfo: nil];
             [sheetDelegate waitForSheetToFinish];
             returnCode = [sheetDelegate code];
             [sheetDelegate release];
         }
         else
+*/
         {
             returnCode = [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ];
         }
-        
+
         if (returnCode == NSOKButton )
         {
             panel = sPanel;
             result = wxID_OK;
 
-            wxCFStringRef filename( [[sPanel filename] retain] );
-
-            m_path = filename.AsString();
+            m_path = wxCFStringRef::AsString([sPanel filename]);
             m_fileName = wxFileNameFromPath(m_path);
             m_dir = wxPathOnly( m_path );
         }
@@ -217,23 +219,24 @@ int wxFileDialog::ShowModal()
         [oPanel setCanChooseFiles:YES];
         [oPanel setMessage:cf.AsNSString()];
 
-        // avoid multiple event handlers on stack
-        if ( 0 /*parentWindow*/)
+/*
+        if (parentWindow)
         {
             NSWindow* nativeParent = parentWindow->GetWXWindow();
-            ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init]; 
-            [oPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString() 
-                types: types modalForWindow: nativeParent 
-                modalDelegate: sheetDelegate 
-                didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) 
+            ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init];
+            [oPanel beginSheetForDirectory:dir.AsNSString() file:file.AsNSString()
+                types: types modalForWindow: nativeParent
+                modalDelegate: sheetDelegate
+                didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
                 contextInfo: nil];
             [sheetDelegate waitForSheetToFinish];
             returnCode = [sheetDelegate code];
             [sheetDelegate release];
         }
         else
+*/
         {
-            returnCode = [oPanel runModalForDirectory:dir.AsNSString() 
+            returnCode = [oPanel runModalForDirectory:dir.AsNSString()
                         file:file.AsNSString() types:types];
         }
         if (returnCode == NSOKButton )
@@ -243,8 +246,7 @@ int wxFileDialog::ShowModal()
             NSArray* filenames = [oPanel filenames];
             for ( size_t i = 0 ; i < [filenames count] ; ++ i )
             {
-                wxCFStringRef filename( [(NSString*) [filenames objectAtIndex:i] retain] );
-                wxString fnstr = filename.AsString();
+                wxString fnstr = wxCFStringRef::AsString([filenames objectAtIndex:i]);
                 m_paths.Add( fnstr );
                 m_fileNames.Add( wxFileNameFromPath(fnstr) );
                 if ( i == 0 )