+ wxMacCFStringHolder message(m_message, m_font.GetEncoding());
+ dialogCreateOptions.windowTitle = message;
+
+ wxMacCFStringHolder defaultFileName(m_fileName, m_font.GetEncoding());
+ dialogCreateOptions.saveFileName = defaultFileName;
+
+
+ NavDialogRef dialog;
+ NavObjectFilterUPP navFilterUPP = NULL;
+ CFArrayRef cfArray = NULL; // for popupExtension
+ OpenUserDataRec myData;
+ myData.defaultLocation = m_dir;
+
+ if (m_dialogStyle & wxSAVE)
+ {
+ dialogCreateOptions.optionFlags |= kNavNoTypePopup;
+ dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
+ dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
+
+ // The extension is important
+ dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
+
+ err = ::NavCreatePutFileDialog(&dialogCreateOptions,
+ 'TEXT',
+ 'TEXT',
+ 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
+ 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 ;
+ 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;
+
+ CFURLRef fullURLRef;
+ if (m_dialogStyle & wxSAVE)
+ {
+ CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
+
+ if (parentURLRef)
+ {
+ fullURLRef =
+ ::CFURLCreateCopyAppendingPathComponent(NULL,
+ parentURLRef,
+ navReply.saveFileName,
+ false);
+ ::CFRelease(parentURLRef);
+ }
+ }
+ else
+ {
+ fullURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
+ }
+#ifdef __UNIX__
+ CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
+#else
+ CFURLPathStyle pathstyle = kCFURLHFSPathStyle;
+#endif
+ CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
+ thePath = wxMacCFStringHolder(cfString).AsString(m_font.GetEncoding());
+ 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;
+#else // TARGET_CARBON
+
+ NavDialogOptions mNavOptions;
+ NavObjectFilterUPP mNavFilterUPP = NULL;
+ NavPreviewUPP mNavPreviewUPP = NULL ;
+ NavReplyRecord mNavReply;
+ AEDesc mDefaultLocation ;
+ bool mSelectDefault = false ;
+ OSStatus err = noErr ;
+ // setup dialog
+
+ mNavFilterUPP = nil;
+ mNavPreviewUPP = nil;
+ mSelectDefault = false;
+ mDefaultLocation.descriptorType = typeNull;
+ mDefaultLocation.dataHandle = nil;
+
+ NavGetDefaultDialogOptions(&mNavOptions);
+ wxMacStringToPascal( m_message , (StringPtr)mNavOptions.message ) ;
+ wxMacStringToPascal( m_fileName , (StringPtr)mNavOptions.savedFileName ) ;
+
+ // Set default location, the location
+ // that's displayed when the dialog
+ // first appears