- 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
- {
- OpenUserDataRec myData;
- MakeUserDataRec( &myData , m_wildCard ) ;
- NavTypeListHandle typelist = NULL ;
-
- if ( myData.numfilters > 0 )
- {
- mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.numfilters ) ;
- for ( int i = 0 ; i < myData.numfilters ; ++i ) {
- (*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ;
- (*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ;
- (*mNavOptions.popupExtension)[i].menuType = i ;
- #if TARGET_CARBON
- c2pstrcpy((StringPtr)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
- #else
- strcpy((char *)(*mNavOptions.popupExtension)[i].menuItemName, myData.name[i]) ;
- c2pstr((char *)(*mNavOptions.popupExtension)[i].menuItemName ) ;
- #endif
- }
- }
-
- mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
- if ( m_dialogStyle & wxMULTIPLE )
- mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
- else
- mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
-
- err = ::NavGetFile(
- &mDefaultLocation,
- &mNavReply,
- &mNavOptions,
- sStandardNavEventFilter ,
- mNavPreviewUPP,
- mNavFilterUPP,
- typelist /*inFileTypes.TypeListHandle() */,
- &myData); // User Data
- if ( typelist )
- DisposeHandle( (Handle) typelist ) ;
- }
-
- DisposeNavObjectFilterUPP(mNavFilterUPP);
- if ( mDefaultLocation.dataHandle != nil )
- {
- ::AEDisposeDesc(&mDefaultLocation);
- }
-
- if ( (err != noErr) && (err != userCanceledErr) ) {
- m_path = "" ;
- return wxID_CANCEL ;
- }
-
- if (mNavReply.validRecord) {
-
- FSSpec outFileSpec ;
- AEDesc specDesc ;
- AEKeyword keyWord ;
-
- long count ;
- ::AECountItems( &mNavReply.selection , &count ) ;
- for ( long i = 1 ; i <= count ; ++i )
- {
- OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
- if ( err != noErr ) {
- m_path = "" ;
- return wxID_CANCEL ;
- }
- outFileSpec = **(FSSpec**) specDesc.dataHandle;
- if (specDesc.dataHandle != nil) {
- ::AEDisposeDesc(&specDesc);
- }
-#ifdef __DARWIN__
- FSRef fsr ;
- err = FSpMakeFSRef( &outFileSpec , &fsr ) ;
- if ( err == fnfErr )
+ memset( &mNavReply , 0 , sizeof( mNavReply ) ) ;
+ 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;
+ mNavReply.version = kNavReplyRecordVersion ;
+
+ // zero all data
+
+ m_path = wxEmptyString ;
+ m_fileName = wxEmptyString ;
+ m_paths.Empty();
+ m_fileNames.Empty();
+
+ OpenUserDataRec myData;
+ MakeUserDataRec( &myData , m_wildCard ) ;
+ myData.currentfilter = m_filterIndex ;
+ if ( myData.extensions.GetCount() > 0 )
+ {
+#if TARGET_CARBON
+ CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
+ myData.extensions.GetCount() , &kCFTypeArrayCallBacks ) ;
+ mNavOptions.popupExtension = popup ;
+ myData.menuitems = mNavOptions.popupExtension ;
+ for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )
+ {
+ CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] ) ) ;
+ }
+#else
+ mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.extensions.GetCount() ) ;
+ myData.menuitems = mNavOptions.popupExtension ;
+ for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )