- #if !TARGET_CARBON
- if ( !gUseNavServices )
- {
- if ( m_dialogStyle & wxSAVE )
- {
- StandardFileReply reply ;
- Str255 prompt ;
- Str255 filename ;
-
-#if TARGET_CARBON
- c2pstrcpy((StringPtr)prompt, m_message) ;
-#else
- strcpy((char *)prompt, m_message) ;
- c2pstr((char *)prompt ) ;
-#endif
-#if TARGET_CARBON
- c2pstrcpy((StringPtr)filename, m_fileName) ;
-#else
- strcpy((char *)filename, m_fileName) ;
- c2pstr((char *)filename ) ;
-#endif
-
- #if !TARGET_CARBON
-
- StandardPutFile( prompt , filename , &reply ) ;
-
- #else
- #endif
- if ( reply.sfGood == false )
- {
- m_path = "" ;
- return wxID_CANCEL ;
- }
- else
- {
- m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ;
- return wxID_OK ;
- }
- }
- else
- {
- OSType types = '????' ;
- Str255 prompt ;
- Str255 path ;
-
-#if TARGET_CARBON
- c2pstrcpy((StringPtr)prompt, m_message) ;
-#else
- strcpy((char *)prompt, m_message) ;
- c2pstr((char *)prompt ) ;
-#endif
-#if TARGET_CARBON
- c2pstrcpy((StringPtr)path, m_dir ) ;
-#else
- strcpy((char *)path, m_dir ) ;
- c2pstr((char *)path ) ;
-#endif
-
- StandardFileReply reply ;
- FileFilterYDUPP crossPlatformFileFilterUPP = 0 ;
- #if !TARGET_CARBON
- crossPlatformFileFilterUPP =
- NewFileFilterYDProc(CrossPlatformFileFilter);
- #endif
-
- ExtendedOpenFile( prompt , path , m_wildCard , crossPlatformFileFilterUPP, &reply);
- #if !TARGET_CARBON
- DisposeFileFilterYDUPP(crossPlatformFileFilterUPP);
- #endif
- if ( reply.sfGood == false )
- {
- m_path = "" ;
- return wxID_CANCEL ;
- }
- else
- {
- m_path = wxMacFSSpec2UnixFilename( &reply.sfFile ) ;
- return wxID_OK ;
- }
- }
- return wxID_CANCEL;
-}
- else
-#endif
- {
- NavDialogOptions mNavOptions;
- NavObjectFilterUPP mNavFilterUPP = NULL;
- NavPreviewUPP mNavPreviewUPP = NULL ;
- NavReplyRecord mNavReply;
- AEDesc mDefaultLocation ;
- bool mSelectDefault = false ;
-
- ::NavGetDefaultDialogOptions(&mNavOptions);
-
- mNavFilterUPP = nil;
- mNavPreviewUPP = nil;
- mSelectDefault = false;
- mNavReply.validRecord = false;
- mNavReply.replacing = false;
- mNavReply.isStationery = false;
- mNavReply.translationNeeded = false;
- mNavReply.selection.descriptorType = typeNull;
- mNavReply.selection.dataHandle = nil;
- mNavReply.keyScript = smSystemScript;
- mNavReply.fileTranslation = nil;
-
- // Set default location, the location
- // that's displayed when the dialog
- // first appears
-
- FSSpec location ;
- wxUnixFilename2FSSpec( m_dir , &location ) ;
- OSErr err = noErr ;
-
- mDefaultLocation.descriptorType = typeNull;
- mDefaultLocation.dataHandle = nil;
-
- err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation );
-
- if ( mDefaultLocation.dataHandle ) {
-
- if (mSelectDefault) {
- mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
- } else {
- mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
- }
- }
-
-#if TARGET_CARBON
- c2pstrcpy((StringPtr)mNavOptions.message, m_message) ;
-#else
- strcpy((char *)mNavOptions.message, m_message) ;
- c2pstr((char *)mNavOptions.message ) ;
-#endif
-#if TARGET_CARBON
- c2pstrcpy((StringPtr)mNavOptions.savedFileName, m_fileName) ;
-#else
- strcpy((char *)mNavOptions.savedFileName, m_fileName) ;
- c2pstr((char *)mNavOptions.savedFileName ) ;
-#endif
-
- if ( m_dialogStyle & wxSAVE )
- {
-
- mNavOptions.dialogOptionFlags |= kNavNoTypePopup ;
- mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
- mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
-
- err = ::NavPutFile(
- &mDefaultLocation,
- &mNavReply,
- &mNavOptions,
- sStandardNavEventFilter ,
- 'TEXT',
- 'TEXT',
- 0L); // User Data
- }
- else
- {
- if ( m_dialogStyle & wxMULTIPLE )
- mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
- else
- mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
-
- err = ::NavGetFile(
- &mDefaultLocation,
- &mNavReply,
- &mNavOptions,
- sStandardNavEventFilter ,
- mNavPreviewUPP,
- mNavFilterUPP,
- 0L /*inFileTypes.TypeListHandle() */,
- 0L); // User Data
- }
-
- if ( mDefaultLocation.dataHandle != nil )
- {
- ::AEDisposeDesc(&mDefaultLocation);
- }
-
- if ( (err != noErr) && (err != userCanceledErr) ) {
- m_path = "" ;
- return wxID_CANCEL ;
- }
-
- if (mNavReply.validRecord) {
-
- FSSpec outFileSpec ;
- AEDesc specDesc ;
-
- long count ;
- ::AECountItems( &mNavReply.selection , &count ) ;
- for ( long i = 1 ; i <= count ; ++i )
- {
- OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, NULL , &specDesc);
- if ( err != noErr ) {
- m_path = "" ;
- return wxID_CANCEL ;
- }
- outFileSpec = **(FSSpec**) specDesc.dataHandle;
- if (specDesc.dataHandle != nil) {
- ::AEDisposeDesc(&specDesc);
- }
-
-
- // outFolderDirID = thePB.dirInfo.ioDrDirID;
- m_path = wxMacFSSpec2UnixFilename( &outFileSpec ) ;
- m_paths.Add( 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);
-
- return wxID_OK ;
- }
- return wxID_CANCEL;
- }