+ if (m_dialogStyle & wxSAVE)
+ {
+ myData.saveMode = true;
+
+ if (!numFilters)
+ {
+ dialogCreateOptions.optionFlags |= kNavNoTypePopup;
+ }
+ dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
+ dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
+
+ // The extension is important
+ if (numFilters < 2)
+ dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
+
+#if TARGET_API_MAC_OSX
+ if (!(m_dialogStyle & wxOVERWRITE_PROMPT))
+ {
+ dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
+ }
+#endif
+ err = ::NavCreatePutFileDialog(&dialogCreateOptions,
+ // Suppresses the 'Default' (top) menu item
+ kNavGenericSignature, kNavGenericSignature,
+ sStandardNavEventFilter,
+ &myData, // for defaultLocation
+ &dialog);
+ }
+ else
+ {
+
+ //let people select bundles/programs in dialogs
+ dialogCreateOptions.optionFlags |= kNavSupportPackages;
+
+ navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
+ err = ::NavCreateGetFileDialog(&dialogCreateOptions,
+ NULL, // NavTypeListHandle
+ sStandardNavEventFilter,
+ NULL, // NavPreviewUPP
+ navFilterUPP,
+ (void *) &myData, // inClientData
+ &dialog);
+ }
+
+ if (err == noErr)
+ err = ::NavDialogRun(dialog);
+
+ // clean up filter related data, etc.
+ if (navFilterUPP)
+ ::DisposeNavObjectFilterUPP(navFilterUPP);
+ if (cfArray)
+ ::CFRelease(cfArray);
+
+ if (err != noErr)
+ return wxID_CANCEL;
+
+ NavReplyRecord navReply;
+ err = ::NavDialogGetReply(dialog, &navReply);
+ if (err == noErr && navReply.validRecord)
+ {
+ AEKeyword theKeyword;
+ DescType actualType;
+ 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), i, typeFSRef, &theKeyword, &actualType,
+ &theFSRef, sizeof(theFSRef), &actualSize);
+ if (err != noErr)
+ break;
+
+ if (m_dialogStyle & wxSAVE)
+ thePath = wxMacFSRefToPath( &theFSRef , navReply.saveFileName ) ;
+ else
+ thePath = wxMacFSRefToPath( &theFSRef ) ;
+
+ if (!thePath)
+ {
+ ::NavDisposeReply(&navReply);
+ return wxID_CANCEL;
+ }
+ m_path = thePath;
+ m_paths.Add(m_path);
+ m_fileName = wxFileNameFromPath(m_path);
+ m_fileNames.Add(m_fileName);
+ }
+ // set these to the first hit
+ m_path = m_paths[0];
+ m_fileName = wxFileNameFromPath(m_path);
+ m_dir = wxPathOnly(m_path);
+ }
+ ::NavDisposeReply(&navReply);
+
+ return (err == noErr) ? wxID_OK : wxID_CANCEL;
+}