--- np2/macosx/dialog/dialog.cpp 2003/11/03 18:50:25 1.3 +++ np2/macosx/dialog/dialog.cpp 2003/11/08 17:54:27 1.4 @@ -111,8 +111,8 @@ void fsspec2path(FSSpec *fs, char *dst, } while(cipbr.dirInfo.ioDrDirID != fsRtDirID); } -#if 1 static NavDialogRef navWin; + static pascal void dummyproc(NavEventCallbackMessage sel, NavCBRecPtr prm, NavCallBackUserData ud) { switch( sel ) @@ -175,23 +175,54 @@ BOOL dialog_fileselect(char *name, int s fsel_exit: return(ret); } -#else -BOOL dialog_fileselect(char *name, int size, WindowRef parent) { - StandardFileReply sfr; +BOOL dialog_filewriteselect(OSType type, char *title, FSSpec *fsc, WindowRef parentWindow) +{ + OSType sign='SMil'; + NavEventUPP eventUPP; + NavReplyRecord reply; + DescType rtype; + OSErr ret; + AEKeyword key; + Size len; + FSRef parent; + UniCharCount ulen; + UniChar* buffer = NULL; + NavDialogCreationOptions copt; + + InitCursor(); + NavGetDefaultDialogCreationOptions(&copt); + copt.parentWindow = parentWindow; + copt.saveFileName = CFStringCreateWithCString(NULL, title, CFStringGetSystemEncoding()); + copt.optionFlags += kNavNoTypePopup; + copt.modality = kWindowModalityWindowModal; + eventUPP=NewNavEventUPP( dummyproc ); + NavCreatePutFileDialog(&copt, type, sign, eventUPP, NULL, &navWin); + + NavDialogRun(navWin); + RunAppModalLoopForWindow(NavDialogGetWindow(navWin)); + + NavDialogGetReply(navWin, &reply); + NavDialogDispose(navWin); + DisposeNavEventUPP(eventUPP); - StandardGetFile(NULL, -1, NULL, &sfr); - if (sfr.sfGood) { - fsspec2path(&sfr.sfFile, name, size); - return(TRUE); - } - else { - return(FALSE); + if( reply.validRecord) + { + ret=AEGetNthPtr( &(reply.selection),1,typeFSRef,&key,&rtype,(Ptr)&parent,(long)sizeof(FSRef),&len ); + ulen = (UniCharCount)CFStringGetLength(reply.saveFileName); + buffer = (UniChar*)NewPtr(ulen); + CFStringGetCharacters(reply.saveFileName, CFRangeMake(0, ulen), buffer); + ret = FSCreateFileUnicode(&parent, ulen, buffer, kFSCatInfoNone, NULL, NULL, fsc); + DisposePtr((Ptr)buffer); + NavDisposeReply( &reply ); + if (ret == noErr) { + return true; + } } - (void)paret; + return( false ); } -#endif +// ---- void dialog_changefdd(BYTE drv) { @@ -243,7 +274,7 @@ void dialog_writebmp(void) { bmp = scrnbmp(); if (bmp) { - if (saveFile('BMP ', "np2.bmp", &fss)) { + if (dialog_filewriteselect('BMP ', "np2.bmp", &fss, hWndMain)) { fsspec2path(&fss, path, MAX_PATH); fh = file_create(path); if (fh != FILEH_INVALID) { @@ -266,7 +297,7 @@ void dialog_s98(void) { if (check) { check = FALSE; } - else if (saveFile('.S98', "S98 log.s98", &fsc)) { + else if (dialog_filewriteselect('.S98', "S98 log.s98", &fsc, hWndMain)) { fsspec2path(&fsc, fname, MAX_PATH); if (S98_open(fname) == SUCCESS) { check = TRUE;