]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/filedlg.cpp
colors are only set if non-black, otherwise Enable(false) does not gray them out
[wxWidgets.git] / src / mac / carbon / filedlg.cpp
index 08bce85f1f55e5dd5f04f2848969db0dfc632b74..3385b176a9d5ac751524783e2080fd4fceb19e2e 100644 (file)
@@ -105,6 +105,14 @@ NavEventProc(
             if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation))
                 ::NavCustomControl(ioParams->context, kNavCtlSetLocation, (void *) &theLocation);
         }
+
+        NavMenuItemSpec  menuItem;
+        menuItem.version = kNavMenuItemSpecVersion;
+        menuItem.menuCreator = 'WXNG';
+        menuItem.menuType = data->currentfilter;
+        wxMacStringToPascal( data->name[data->currentfilter] , (StringPtr)(menuItem.menuItemName) ) ;
+        ::NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &menuItem);
+
 #else
         if ( data->menuitems )
             NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &(*data->menuitems)[data->currentfilter]);
@@ -114,6 +122,9 @@ NavEventProc(
     {
         NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ;
 #if TARGET_CARBON
+        const size_t numFilters = data->extensions.GetCount();
+
+        if ( menu->menuType < numFilters )
 #else
         if ( menu->menuCreator == 'WXNG' )
 #endif
@@ -369,38 +380,45 @@ int wxFileDialog::ShowModal()
     OpenUserDataRec myData;
     myData.defaultLocation = m_dir;
 
+    MakeUserDataRec(&myData , m_wildCard);
+    myData.currentfilter = m_filterIndex;
+    size_t numFilters = myData.extensions.GetCount();
+    if (numFilters)
+    {
+        CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
+            numFilters , &kCFTypeArrayCallBacks ) ;
+        dialogCreateOptions.popupExtension = popup ;
+        myData.menuitems = dialogCreateOptions.popupExtension ;
+        for ( size_t i = 0 ; i < numFilters ; ++i )
+        {
+            CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] , m_font.GetEncoding() ) ) ;
+        }
+    }
+
     if (m_dialogStyle & wxSAVE)
     {
-        dialogCreateOptions.optionFlags |= kNavNoTypePopup;
+        myData.saveMode = true;
+
+        if (!numFilters)
+        {
+            dialogCreateOptions.optionFlags |= kNavNoTypePopup;
+        }
         dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
         dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
 
         // The extension is important
-        dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
+        if (numFilters < 2)
+            dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
 
         err = ::NavCreatePutFileDialog(&dialogCreateOptions,
-                                       'TEXT',
-                                       'TEXT',
+                                       // Suppresses the 'Default' (top) menu item
+                                       kNavGenericSignature, kNavGenericSignature,
                                        sStandardNavEventFilter,
                                        &myData, // for defaultLocation
                                        &dialog);
     }
     else
     {
-        MakeUserDataRec(&myData , m_wildCard);
-        size_t numfilters = myData.extensions.GetCount();
-        if (numfilters > 0)
-        {
-            CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
-                numfilters , &kCFTypeArrayCallBacks ) ;
-            dialogCreateOptions.popupExtension = popup ;
-            myData.menuitems = dialogCreateOptions.popupExtension ;
-            for ( size_t i = 0 ; i < numfilters ; ++i )
-            {
-                CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] , m_font.GetEncoding() ) ) ;
-            }
-        }
-
         navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
         err = ::NavCreateGetFileDialog(&dialogCreateOptions,
                                        NULL, // NavTypeListHandle
@@ -432,16 +450,19 @@ int wxFileDialog::ShowModal()
         Size        actualSize;
         FSRef       theFSRef;
         wxString thePath ;
+
+        m_filterIndex = myData.currentfilter ;
+
         long count;
         ::AECountItems(&navReply.selection , &count);
         for (long i = 1; i <= count; ++i)
         {
-            err = ::AEGetNthPtr(&(navReply.selection), 1, typeFSRef, &theKeyword, &actualType,
+            err = ::AEGetNthPtr(&(navReply.selection), i, typeFSRef, &theKeyword, &actualType,
                                 &theFSRef, sizeof(theFSRef), &actualSize);
             if (err != noErr)
                 break;
 
-            CFURLRef fullURLRef;
+            CFURLRef fullURLRef = 0 ;
             if (m_dialogStyle & wxSAVE)
             {
                 CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);