]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/filedlg.mm
add alignment flags support to wxSpinCtrl[Double] (closes #10621)
[wxWidgets.git] / src / osx / cocoa / filedlg.mm
index 462ee154e477e7d604f7fcb7e385642a0cf11f63..0b34682a7213d23efefd8e70aaf49d59af26c53b 100644 (file)
@@ -30,6 +30,7 @@
 #endif
 
 #include "wx/filename.h"
 #endif
 
 #include "wx/filename.h"
+#include "wx/tokenzr.h"
 
 #include "wx/osx/private.h"
 
 
 #include "wx/osx/private.h"
 
@@ -51,7 +52,6 @@ wxFileDialog::wxFileDialog(
 {
 }
 
 {
 }
 
-
 NSArray* GetTypesFromFilter( const wxString filter )
 {
     NSMutableArray* types = nil;
 NSArray* GetTypesFromFilter( const wxString filter )
 {
     NSMutableArray* types = nil;
@@ -103,34 +103,38 @@ NSArray* GetTypesFromFilter( const wxString filter )
         const size_t extCount = extensions.GetCount();
         for ( size_t i = 0 ; i < extCount; i++ )
         {
         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 ( types == nil )
-                types = [[NSMutableArray alloc] init];
+                if ( extension.IsEmpty() )
+                {
+                    if ( types != nil )
+                        [types release];
+                    return nil;
+                }
+
+                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
 #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
 #endif
+            }
+
         }
     }
     return types;
         }
     }
     return types;
@@ -149,6 +153,14 @@ int wxFileDialog::ShowModal()
 
     m_path = wxEmptyString;
     m_fileNames.Clear();
 
     m_path = wxEmptyString;
     m_fileNames.Clear();
+    
+    wxNonOwnedWindow* parentWindow = NULL;
+    int returnCode = -1;
+    
+    if (GetParent()) 
+    {
+        parentWindow = dynamic_cast<wxNonOwnedWindow*>(wxGetTopLevelParent(GetParent()));
+    }
 
     if (HasFlag(wxFD_SAVE))
     {
 
     if (HasFlag(wxFD_SAVE))
     {
@@ -165,7 +177,26 @@ int wxFileDialog::ShowModal()
         {
         }
 
         {
         }
 
-        if ( [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ] == NSOKButton )
+/*
+        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:) 
+                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;
         {
             panel = sPanel;
             result = wxID_OK;
@@ -187,7 +218,27 @@ int wxFileDialog::ShowModal()
         [oPanel setCanChooseFiles:YES];
         [oPanel setMessage:cf.AsNSString()];
 
         [oPanel setCanChooseFiles:YES];
         [oPanel setMessage:cf.AsNSString()];
 
-        if ( [oPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() types:types] == NSOKButton )
+/*
+        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:) 
+                contextInfo: nil];
+            [sheetDelegate waitForSheetToFinish];
+            returnCode = [sheetDelegate code];
+            [sheetDelegate release];
+        }
+        else
+*/
+        {
+            returnCode = [oPanel runModalForDirectory:dir.AsNSString() 
+                        file:file.AsNSString() types:types];
+        }
+        if (returnCode == NSOKButton )
         {
             panel = oPanel;
             result = wxID_OK;
         {
             panel = oPanel;
             result = wxID_OK;