]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/filedlg.cpp
Aplied patch [ 816113 ] Inconsistent GetCharWidth over platforms
[wxWidgets.git] / src / mac / carbon / filedlg.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: filedlg.cpp
3 // Purpose: wxFileDialog
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "filedlg.h"
14 #endif
15
16 #include "wx/defs.h"
17 #include "wx/app.h"
18 #include "wx/utils.h"
19 #include "wx/dialog.h"
20 #include "wx/filedlg.h"
21 #include "wx/intl.h"
22 #include "wx/tokenzr.h"
23
24 #ifndef __DARWIN__
25 #include "PLStringFuncs.h"
26 #endif
27
28 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
30 #endif
31
32 // begin wxmac
33
34 #include "wx/mac/private.h"
35
36 #include <Navigation.h>
37
38 #ifdef __DARWIN__
39 # include "MoreFilesX.h"
40 #else
41 # include "MoreFiles.h"
42 # include "MoreFilesExtras.h"
43 #endif
44
45 extern bool gUseNavServices ;
46
47 // the data we need to pass to our standard file hook routine
48 // includes a pointer to the dialog, a pointer to the standard
49 // file reply record (so we can inspect the current selection)
50 // and a copy of the "previous" file spec of the reply record
51 // so we can see if the selection has changed
52
53 struct OpenUserDataRec {
54 int currentfilter ;
55 bool saveMode ;
56 wxArrayString name ;
57 wxArrayString extensions ;
58 wxArrayLong filtermactypes ;
59 wxString defaultLocation;
60 #if TARGET_CARBON
61 CFArrayRef menuitems ;
62 #else
63 NavMenuItemSpecArrayHandle menuitems ;
64 #endif
65 };
66
67 typedef struct OpenUserDataRec
68 OpenUserDataRec, *OpenUserDataRecPtr;
69
70 static pascal void NavEventProc(
71 NavEventCallbackMessage inSelector,
72 NavCBRecPtr ioParams,
73 NavCallBackUserData ioUserData);
74
75 #if TARGET_CARBON
76 static NavEventUPP sStandardNavEventFilter = NewNavEventUPP(NavEventProc);
77 #else
78 static NavEventUPP sStandardNavEventFilter = NewNavEventProc(NavEventProc);
79 #endif
80
81 static pascal void
82 NavEventProc(
83 NavEventCallbackMessage inSelector,
84 NavCBRecPtr ioParams,
85 NavCallBackUserData ioUserData )
86 {
87 OpenUserDataRec * data = ( OpenUserDataRec *) ioUserData ;
88 if (inSelector == kNavCBEvent) {
89 #if TARGET_CARBON
90 #else
91 wxTheApp->MacHandleOneEvent(ioParams->eventData.eventDataParms.event);
92 #endif
93 }
94 else if ( inSelector == kNavCBStart )
95 {
96 #if TARGET_CARBON
97 if (data && !(data->defaultLocation).IsEmpty())
98 {
99 // Set default location for the modern Navigation APIs
100 // Apple Technical Q&A 1151
101 FSSpec theFSSpec;
102 wxMacFilename2FSSpec(data->defaultLocation, &theFSSpec);
103 AEDesc theLocation = {typeNull, NULL};
104 if (noErr == ::AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation))
105 ::NavCustomControl(ioParams->context, kNavCtlSetLocation, (void *) &theLocation);
106 }
107 #else
108 if ( data->menuitems )
109 NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &(*data->menuitems)[data->currentfilter]);
110 #endif
111 }
112 else if ( inSelector == kNavCBPopupMenuSelect )
113 {
114 NavMenuItemSpec * menu = (NavMenuItemSpec *) ioParams->eventData.eventDataParms.param ;
115 #if TARGET_CARBON
116 #else
117 if ( menu->menuCreator == 'WXNG' )
118 #endif
119 {
120 data->currentfilter = menu->menuType ;
121 if ( data->saveMode )
122 {
123 int i = menu->menuType ;
124 wxString extension = data->extensions[i].AfterLast('.') ;
125 extension.MakeLower() ;
126 wxString sfilename ;
127
128 #if TARGET_CARBON
129 wxMacCFStringHolder cfString( NavDialogGetSaveFileName( ioParams->context ) , false );
130 sfilename = cfString.AsString() ;
131 #else
132 Str255 filename ;
133 // get the current filename
134 NavCustomControl(ioParams->context, kNavCtlGetEditFileName, &filename);
135 sfilename = wxMacMakeStringFromPascal( filename ) ;
136 #endif
137
138 int pos = sfilename.Find('.', true) ;
139 if ( pos != wxNOT_FOUND )
140 {
141 sfilename = sfilename.Left(pos+1)+extension ;
142 #if TARGET_CARBON
143 cfString = sfilename ;
144 NavDialogSetSaveFileName( ioParams->context , cfString ) ;
145 #else
146 wxMacStringToPascal( sfilename , filename ) ;
147 NavCustomControl(ioParams->context, kNavCtlSetEditFileName, &filename);
148 #endif
149 }
150 }
151 }
152 }
153 }
154
155 const wxChar * gfilters[] =
156 {
157 wxT("*.TXT") ,
158 wxT("*.TIF") ,
159 wxT("*.JPG") ,
160
161 NULL
162 } ;
163
164 OSType gfiltersmac[] =
165 {
166 'TEXT' ,
167 'TIFF' ,
168 'JPEG' ,
169
170 '****'
171 } ;
172
173
174 void MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter )
175 {
176 myData->menuitems = NULL ;
177 myData->currentfilter = 0 ;
178 myData->saveMode = false ;
179
180 if ( filter && filter[0] )
181 {
182 wxString filter2(filter) ;
183 int filterIndex = 0;
184 bool isName = true ;
185 wxString current ;
186 for( unsigned int i = 0; i < filter2.Len() ; i++ )
187 {
188 if( filter2.GetChar(i) == wxT('|') )
189 {
190 if( isName ) {
191 myData->name.Add( current ) ;
192 }
193 else {
194 myData->extensions.Add( current.MakeUpper() ) ;
195 ++filterIndex ;
196 }
197 isName = !isName ;
198 current = wxEmptyString ;
199 }
200 else
201 {
202 current += filter2.GetChar(i) ;
203 }
204 }
205 // we allow for compatibility reason to have a single filter expression (like *.*) without
206 // an explanatory text, in that case the first part is name and extension at the same time
207
208 wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ;
209 if ( current.IsEmpty() )
210 myData->extensions.Add( myData->name[filterIndex] ) ;
211 else
212 myData->extensions.Add( current.MakeUpper() ) ;
213 if ( filterIndex == 0 || isName )
214 myData->name.Add( current.MakeUpper() ) ;
215
216 ++filterIndex ;
217
218 const size_t extCount = myData->extensions.GetCount();
219 for ( size_t i = 0 ; i < extCount; i++ )
220 {
221 int j ;
222 for ( j = 0 ; gfilters[j] ; j++ )
223 {
224 if ( myData->extensions[i] == gfilters[j] )
225 {
226 myData->filtermactypes.Add( gfiltersmac[j] ) ;
227 break ;
228 }
229 }
230 if( gfilters[j] == NULL )
231 {
232 myData->filtermactypes.Add( '****' ) ;
233 }
234 }
235 }
236 }
237
238 static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataRecPtr data)
239 {
240 wxString file(filename) ;
241 file.MakeUpper() ;
242
243 if ( data->extensions.GetCount() > 0 )
244 {
245 //for ( int i = 0 ; i < data->numfilters ; ++i )
246 int i = data->currentfilter ;
247 if ( data->extensions[i].Right(2) == wxT(".*") )
248 return true ;
249
250 {
251 if ( type == (OSType)data->filtermactypes[i] )
252 return true ;
253
254 wxStringTokenizer tokenizer( data->extensions[i] , wxT(";") ) ;
255 while( tokenizer.HasMoreTokens() )
256 {
257 wxString extension = tokenizer.GetNextToken() ;
258 if ( extension.GetChar(0) == '*' )
259 extension = extension.Mid(1) ;
260
261 if ( file.Len() >= extension.Len() && extension == file.Right(extension.Len() ) )
262 return true ;
263 }
264 }
265 return false ;
266 }
267 return true ;
268 }
269
270 #ifndef __DARWIN__
271 static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr)
272 {
273 OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ;
274 // return true if this item is invisible or a file
275
276 Boolean visibleFlag;
277 Boolean folderFlag;
278
279 visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible);
280 folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10);
281
282 // because the semantics of the filter proc are "true means don't show
283 // it" we need to invert the result that we return
284
285 if ( !visibleFlag )
286 return true ;
287
288 if ( !folderFlag )
289 {
290 wxString file = wxMacMakeStringFromPascal( myCInfoPBPtr->hFileInfo.ioNamePtr ) ;
291 return !CheckFile( file , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ;
292 }
293
294 return false ;
295 }
296 #endif
297
298 // end wxmac
299
300 wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
301 const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
302 long style, const wxPoint& pos)
303 :wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
304 {
305 wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
306 }
307
308 pascal Boolean CrossPlatformFilterCallback (
309 AEDesc *theItem,
310 void *info,
311 void *callBackUD,
312 NavFilterModes filterMode
313 )
314 {
315 bool display = true;
316 OpenUserDataRecPtr data = (OpenUserDataRecPtr) callBackUD ;
317
318 if (filterMode == kNavFilteringBrowserList)
319 {
320 NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
321 if ( !theInfo->isFolder )
322 {
323 if (theItem->descriptorType == typeFSS )
324 {
325 FSSpec spec;
326 memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
327 wxString file = wxMacMakeStringFromPascal( spec.name ) ;
328 display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
329 }
330 #if TARGET_CARBON
331 else if ( theItem->descriptorType == typeFSRef )
332 {
333 FSRef fsref ;
334 memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ;
335 wxString file ;
336 const short maxpath = 1024 ;
337 FSRefMakePath( &fsref , (UInt8*) file.GetWriteBuf(maxpath+1),maxpath) ;
338 file.UngetWriteBuf() ;
339 display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ;
340 }
341 #endif
342 }
343 }
344
345 return display;
346 }
347
348 int wxFileDialog::ShowModal()
349 {
350 #if TARGET_CARBON
351 OSErr err;
352 NavDialogCreationOptions dialogCreateOptions;
353 // set default options
354 ::NavGetDefaultDialogCreationOptions(&dialogCreateOptions);
355
356 // this was always unset in the old code
357 dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation;
358
359 #if wxUSE_UNICODE
360 // tried using wxMacCFStringHolder in the code below, but it seems
361 // the CFStrings were being released before the save dialog was called,
362 // causing a crash - open dialog works fine with or without wxMacCFStringHolder
363 CFStringRef titleRef = ::CFStringCreateWithCharacters( kCFAllocatorDefault,
364 (const unsigned short*)m_message.wc_str(),
365 m_message.Len() );
366 #else
367 CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
368 m_message.c_str(),
369 CFStringGetSystemEncoding());
370 #endif
371 dialogCreateOptions.windowTitle = titleRef;
372 #if wxUSE_UNICODE
373 CFStringRef defaultFileNameRef = ::CFStringCreateWithCharacters( kCFAllocatorDefault,
374 (const unsigned short*)m_fileName.wc_str(),
375 m_fileName.Len() );
376 #else
377 CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
378 m_fileName.c_str(),
379 CFStringGetSystemEncoding());
380 #endif
381 dialogCreateOptions.saveFileName = defaultFileNameRef;
382 NavDialogRef dialog;
383 NavObjectFilterUPP navFilterUPP = NULL;
384 CFArrayRef cfArray = NULL; // for popupExtension
385 OpenUserDataRec myData;
386 myData.defaultLocation = m_dir;
387
388 if (m_dialogStyle & wxSAVE)
389 {
390 dialogCreateOptions.optionFlags |= kNavNoTypePopup;
391 dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
392 dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
393
394 // The extension is important
395 dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
396
397 err = ::NavCreatePutFileDialog(&dialogCreateOptions,
398 'TEXT',
399 'TEXT',
400 sStandardNavEventFilter,
401 &myData, // for defaultLocation
402 &dialog);
403 }
404 else
405 {
406 MakeUserDataRec(&myData , m_wildCard);
407 size_t numfilters = myData.extensions.GetCount();
408 if (numfilters > 0)
409 {
410 CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
411 numfilters , &kCFTypeArrayCallBacks ) ;
412 dialogCreateOptions.popupExtension = popup ;
413 myData.menuitems = dialogCreateOptions.popupExtension ;
414 for ( size_t i = 0 ; i < numfilters ; ++i )
415 {
416 CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] ) ) ;
417 }
418 }
419
420 navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
421 err = ::NavCreateGetFileDialog(&dialogCreateOptions,
422 NULL, // NavTypeListHandle
423 sStandardNavEventFilter,
424 NULL, // NavPreviewUPP
425 navFilterUPP,
426 (void *) &myData, // inClientData
427 &dialog);
428 }
429
430 if (err == noErr)
431 err = ::NavDialogRun(dialog);
432
433 // clean up filter related data, etc.
434 if (navFilterUPP)
435 ::DisposeNavObjectFilterUPP(navFilterUPP);
436 if (cfArray)
437 {
438 CFIndex n = ::CFArrayGetCount(cfArray);
439 for (CFIndex i = 0; i < n; i++)
440 {
441 CFStringRef str = (CFStringRef) ::CFArrayGetValueAtIndex(cfArray, i);
442 if (str)
443 ::CFRelease(str);
444 }
445 ::CFRelease(cfArray);
446 }
447 if (titleRef)
448 ::CFRelease(titleRef);
449 if (defaultFileNameRef)
450 ::CFRelease(defaultFileNameRef);
451 if (err != noErr)
452 return wxID_CANCEL;
453
454 NavReplyRecord navReply;
455 err = ::NavDialogGetReply(dialog, &navReply);
456 if (err == noErr && navReply.validRecord)
457 {
458 AEKeyword theKeyword;
459 DescType actualType;
460 Size actualSize;
461 FSRef theFSRef;
462 wxString thePath ;
463 long count;
464 ::AECountItems(&navReply.selection , &count);
465 for (long i = 1; i <= count; ++i)
466 {
467 err = ::AEGetNthPtr(&(navReply.selection), 1, typeFSRef, &theKeyword, &actualType,
468 &theFSRef, sizeof(theFSRef), &actualSize);
469 if (err != noErr)
470 break;
471
472 if (m_dialogStyle & wxSAVE)
473 {
474 CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
475
476 if (parentURLRef)
477 {
478 CFURLRef fullURLRef =
479 ::CFURLCreateCopyAppendingPathComponent(NULL,
480 parentURLRef,
481 navReply.saveFileName,
482 false);
483 ::CFRelease(parentURLRef);
484 if (fullURLRef)
485 {
486 CFStringRef cfString = ::CFURLCopyPath(fullURLRef);
487 ::CFRelease(fullURLRef);
488
489 if (cfString)
490 {
491 // unescape the URL for
492 // "file name" instead of "file%20name"
493 CFStringRef cfStringUnescaped =
494 ::CFURLCreateStringByReplacingPercentEscapes(NULL,
495 cfString,
496 CFSTR(""));
497 ::CFRelease(cfString);
498
499 if (cfStringUnescaped)
500 {
501 Size len = CFStringGetLength( cfStringUnescaped ) ;
502 wxChar* buf = thePath.GetWriteBuf( len ) ;
503 //buf[0] = '\0';
504 #if wxUSE_UNICODE
505 CFStringGetCharacters(cfStringUnescaped , CFRangeMake( 0 , len ) , (UniChar*) buf ) ;
506 #else
507 CFStringGetCString( cfStringUnescaped , buf , len+1 , CFStringGetSystemEncoding() ) ;
508 #endif
509 buf[len] = 0 ;
510 wxMacConvertNewlines10To13( buf ) ;
511 thePath.UngetWriteBuf() ;
512 ::CFRelease(cfStringUnescaped);
513 }
514 }
515 }
516 }
517 if (!thePath)
518 {
519 ::NavDisposeReply(&navReply);
520 return wxID_CANCEL;
521 }
522 }
523 else
524 {
525 const short maxpath = 1024 ;
526 ::FSRefMakePath( &theFSRef , (UInt8*) thePath.GetWriteBuf(maxpath+1),maxpath) ;
527 thePath.UngetWriteBuf() ;
528 if (err != noErr)
529 break;
530 }
531 m_path = thePath;
532 m_paths.Add(m_path);
533 m_fileName = wxFileNameFromPath(m_path);
534 m_fileNames.Add(m_fileName);
535 }
536 // set these to the first hit
537 m_path = m_paths[0];
538 m_fileName = wxFileNameFromPath(m_path);
539 m_dir = wxPathOnly(m_path);
540 }
541 ::NavDisposeReply(&navReply);
542
543 return (err == noErr) ? wxID_OK : wxID_CANCEL;
544 #else // TARGET_CARBON
545
546 NavDialogOptions mNavOptions;
547 NavObjectFilterUPP mNavFilterUPP = NULL;
548 NavPreviewUPP mNavPreviewUPP = NULL ;
549 NavReplyRecord mNavReply;
550 AEDesc mDefaultLocation ;
551 bool mSelectDefault = false ;
552 OSStatus err = noErr ;
553 // setup dialog
554
555 mNavFilterUPP = nil;
556 mNavPreviewUPP = nil;
557 mSelectDefault = false;
558 mDefaultLocation.descriptorType = typeNull;
559 mDefaultLocation.dataHandle = nil;
560
561 NavGetDefaultDialogOptions(&mNavOptions);
562 wxMacStringToPascal( m_message , (StringPtr)mNavOptions.message ) ;
563 wxMacStringToPascal( m_fileName , (StringPtr)mNavOptions.savedFileName ) ;
564
565 // Set default location, the location
566 // that's displayed when the dialog
567 // first appears
568
569 FSSpec location ;
570 wxMacFilename2FSSpec( m_dir , &location ) ;
571
572 err = ::AECreateDesc(typeFSS, &location, sizeof(FSSpec), &mDefaultLocation );
573
574 if ( mDefaultLocation.dataHandle )
575 {
576 if (mSelectDefault)
577 {
578 mNavOptions.dialogOptionFlags |= kNavSelectDefaultLocation;
579 } else {
580 mNavOptions.dialogOptionFlags &= ~kNavSelectDefaultLocation;
581 }
582 }
583
584 memset( &mNavReply , 0 , sizeof( mNavReply ) ) ;
585 mNavReply.validRecord = false;
586 mNavReply.replacing = false;
587 mNavReply.isStationery = false;
588 mNavReply.translationNeeded = false;
589 mNavReply.selection.descriptorType = typeNull;
590 mNavReply.selection.dataHandle = nil;
591 mNavReply.keyScript = smSystemScript;
592 mNavReply.fileTranslation = nil;
593 mNavReply.version = kNavReplyRecordVersion ;
594
595 // zero all data
596
597 m_path = wxEmptyString ;
598 m_fileName = wxEmptyString ;
599 m_paths.Empty();
600 m_fileNames.Empty();
601
602 OpenUserDataRec myData;
603 MakeUserDataRec( &myData , m_wildCard ) ;
604 myData.currentfilter = m_filterIndex ;
605 if ( myData.extensions.GetCount() > 0 )
606 {
607 mNavOptions.popupExtension = (NavMenuItemSpecArrayHandle) NewHandle( sizeof( NavMenuItemSpec ) * myData.extensions.GetCount() ) ;
608 myData.menuitems = mNavOptions.popupExtension ;
609 for ( size_t i = 0 ; i < myData.extensions.GetCount() ; ++i )
610 {
611 (*mNavOptions.popupExtension)[i].version = kNavMenuItemSpecVersion ;
612 (*mNavOptions.popupExtension)[i].menuCreator = 'WXNG' ;
613 // TODO : according to the new docs -1 to 10 are reserved for the OS
614 (*mNavOptions.popupExtension)[i].menuType = i ;
615 wxMacStringToPascal( myData.name[i] , (StringPtr)(*mNavOptions.popupExtension)[i].menuItemName ) ;
616 }
617 }
618 if ( m_dialogStyle & wxSAVE )
619 {
620 myData.saveMode = true ;
621
622 mNavOptions.dialogOptionFlags |= kNavDontAutoTranslate ;
623 mNavOptions.dialogOptionFlags |= kNavDontAddTranslateItems ;
624
625 err = ::NavPutFile(
626 &mDefaultLocation,
627 &mNavReply,
628 &mNavOptions,
629 sStandardNavEventFilter ,
630 NULL,
631 kNavGenericSignature,
632 &myData); // User Data
633 m_filterIndex = myData.currentfilter ;
634 }
635 else
636 {
637 myData.saveMode = false ;
638
639 mNavFilterUPP = NewNavObjectFilterUPP( CrossPlatformFilterCallback ) ;
640 if ( m_dialogStyle & wxMULTIPLE )
641 mNavOptions.dialogOptionFlags |= kNavAllowMultipleFiles ;
642 else
643 mNavOptions.dialogOptionFlags &= ~kNavAllowMultipleFiles ;
644
645 err = ::NavGetFile(
646 &mDefaultLocation,
647 &mNavReply,
648 &mNavOptions,
649 sStandardNavEventFilter ,
650 mNavPreviewUPP,
651 mNavFilterUPP,
652 NULL ,
653 &myData);
654 m_filterIndex = myData.currentfilter ;
655 }
656
657 DisposeNavObjectFilterUPP(mNavFilterUPP);
658 if ( mDefaultLocation.dataHandle != nil )
659 {
660 ::AEDisposeDesc(&mDefaultLocation);
661 }
662
663 if ( (err != noErr) && (err != userCanceledErr) ) {
664 return wxID_CANCEL ;
665 }
666
667 if (mNavReply.validRecord)
668 {
669 FSSpec outFileSpec ;
670 AEDesc specDesc ;
671 AEKeyword keyWord ;
672
673 long count ;
674 ::AECountItems( &mNavReply.selection , &count ) ;
675 for ( long i = 1 ; i <= count ; ++i )
676 {
677 OSErr err = ::AEGetNthDesc( &mNavReply.selection , i , typeFSS, &keyWord , &specDesc);
678 if ( err != noErr )
679 {
680 m_path = wxT("") ;
681 return wxID_CANCEL ;
682 }
683 outFileSpec = **(FSSpec**) specDesc.dataHandle;
684 if (specDesc.dataHandle != nil) {
685 ::AEDisposeDesc(&specDesc);
686 }
687 m_path = wxMacFSSpec2MacFilename( &outFileSpec ) ;
688
689 m_paths.Add( m_path ) ;
690 m_fileName = wxFileNameFromPath(m_path);
691 m_fileNames.Add(m_fileName);
692 }
693 // set these to the first hit
694 m_path = m_paths[ 0 ] ;
695 m_fileName = wxFileNameFromPath(m_path);
696 m_dir = wxPathOnly(m_path);
697 NavDisposeReply( &mNavReply ) ;
698 return wxID_OK ;
699 }
700 return wxID_CANCEL;
701 #endif // TARGET_CARBON
702 }
703