- 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 )
+
+ NavDialogRef dialog;
+ NavObjectFilterUPP navFilterUPP = NULL;
+ CFArrayRef cfArray = NULL; // for popupExtension
+ 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 )