]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/filedlg.mm
adding note for correct wheel params
[wxWidgets.git] / src / osx / cocoa / filedlg.mm
index a509c1bb63e53f9d8075e825830a6a187e648946..916b4e8b7a677880203d9d86de7250b4e27319b7 100644 (file)
@@ -30,6 +30,7 @@
 #endif
 
 #include "wx/filename.h"
+#include "wx/tokenzr.h"
 
 #include "wx/osx/private.h"
 
@@ -102,34 +103,38 @@ NSArray* GetTypesFromFilter( const wxString filter )
         const size_t extCount = extensions.GetCount();
         for ( size_t i = 0 ; i < extCount; i++ )
         {
-            wxString extension = extensions[i];
-
-            // Remove leading '*'
-            if (extension.length() && (extension.GetChar(0) == '*'))
-                extension = extension.Mid( 1 );
-
-            // Remove leading '.'
-            if (extension.length() && (extension.GetChar(0) == '.'))
-                extension = extension.Mid( 1 );
-
-            if ( extension.IsEmpty() )
+            wxString extensiongroup = extensions[i];
+            wxStringTokenizer tokenizer( extensiongroup , wxT(";") ) ;
+            while ( tokenizer.HasMoreTokens() )
             {
-                if ( types != nil )
-                    [types release];
-                return nil;
-            }
+                wxString extension = tokenizer.GetNextToken() ;
+                // Remove leading '*'
+                if (extension.length() && (extension.GetChar(0) == '*'))
+                    extension = extension.Mid( 1 );
 
+                // Remove leading '.'
+                if (extension.length() && (extension.GetChar(0) == '.'))
+                    extension = extension.Mid( 1 );
+
+                if ( extension.IsEmpty() )
+                {
+                    if ( types != nil )
+                        [types release];
+                    return nil;
+                }
 
-            if ( types == nil )
-                types = [[NSMutableArray alloc] init];
+                if ( types == nil )
+                    types = [[NSMutableArray alloc] init];
 
-            wxCFStringRef cfext(extension);
-            [types addObject: (NSString*)cfext.AsNSString()  ];
+                wxCFStringRef cfext(extension);
+                [types addObject: (NSString*)cfext.AsNSString()  ];
 #if 0
-            // add support for classic fileType / creator here
-            wxUint32 fileType, creator;
-            // extension -> mactypes
+                // add support for classic fileType / creator here
+                wxUint32 fileType, creator;
+                // extension -> mactypes
 #endif
+            }
+
         }
     }
     return types;
@@ -148,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()));
     }
@@ -171,32 +179,32 @@ int wxFileDialog::ShowModal()
         if ( HasFlag(wxFD_OVERWRITE_PROMPT) )
         {
         }
-    
+
+/*
         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];
-            result = [sheetDelegate code];
+            returnCode = [sheetDelegate code];
             [sheetDelegate release];
         }
         else
+*/
         {
-            result = [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ];
+            returnCode = [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ];
         }
-        
-        if (result == NSOKButton )
+
+        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 );
         }
@@ -211,33 +219,34 @@ int wxFileDialog::ShowModal()
         [oPanel setCanChooseFiles:YES];
         [oPanel setMessage:cf.AsNSString()];
 
+/*
         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];
-            result = [sheetDelegate code];
+            returnCode = [sheetDelegate code];
             [sheetDelegate release];
         }
         else
+*/
         {
-            result = [oPanel runModalForDirectory:dir.AsNSString() 
+            returnCode = [oPanel runModalForDirectory:dir.AsNSString()
                         file:file.AsNSString() types:types];
         }
-        if (result == NSOKButton )
+        if (returnCode == NSOKButton )
         {
             panel = oPanel;
             result = wxID_OK;
             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 )