--- np2/macosx/dialog/macnewdisk.cpp 2003/11/06 18:27:59 1.2 +++ np2/macosx/dialog/macnewdisk.cpp 2003/11/08 17:54:27 1.3 @@ -7,7 +7,6 @@ #include "dialogutils.h" #include "macnewdisk.h" -const int defaultsize[5] = {20, 41, 65, 80, 128}; static WindowRef diskWin; static SInt32 targetDisk, media, hdsize; static char disklabel[256]; @@ -16,6 +15,11 @@ enum {kTabMasterSig = 'ScrT',kTabMasterI static UInt16 lastPaneSelected = 1; #define getControlValue(a,b) GetControl32BitValue(getControlRefByID(a,b,diskWin)) +const int defaultsize[5] = {20, 41, 65, 80, 128}; +const EventTypeSpec tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; +const EventTypeSpec hicommandEvents[]={ { kEventClassCommand, kEventCommandProcess },}; + + static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { OSStatus err = eventNotHandledErr; HICommand cmd; @@ -81,15 +85,13 @@ static void makeNibWindow (IBNibRef nibR err = CreateWindowFromNib(nibRef, CFSTR("NewDiskDialog"), &diskWin); if (err == noErr) { - SetInitialTabState(diskWin, lastPaneSelected, kMaxNumTabs); - EventTypeSpec tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; + InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,diskWin), PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, diskWin, NULL ); - EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess },}; - InstallWindowEventHandler (diskWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)diskWin, &ref); + InstallWindowEventHandler (diskWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(hicommandEvents), hicommandEvents, (void *)diskWin, &ref); + ShowWindow(diskWin); RunAppModalLoopForWindow(diskWin); - } return; } @@ -115,13 +117,13 @@ void newdisk(void) { initNewDisk(); if (targetDisk == 1) { - if (saveFile('.D88', "Newdisk.d88", &fss)) { + if (dialog_filewriteselect('.D88', "Newdisk.d88", &fss, diskWin)) { fsspec2path(&fss, fname, sizeof(fname)); newdisk_fdd(fname, media, disklabel); } } else if (targetDisk == 2) { - if (saveFile('.THD', "Newdisk.thd", &fss)) { + if (dialog_filewriteselect('.THD', "Newdisk.thd", &fss, diskWin)) { fsspec2path(&fss, fname, sizeof(fname)); newdisk_hdd(fname, hdsize); } @@ -129,48 +131,3 @@ void newdisk(void) { HideWindow(diskWin); DisposeWindow(diskWin); } - -static pascal void navEventProc( NavEventCallbackMessage sel,NavCBRecPtr parm,NavCallBackUserData ud ) -{ - switch( sel ) - { - case kNavCBEvent: - { - switch( parm->eventData.eventDataParms.event->what ) - { - } - break; - } - } -} - -Boolean saveFile(OSType type, char *title, FSSpec *fsc) -{ - OSType sign='SMil'; - NavEventUPP eventUPP; - NavReplyRecord reply; - DescType rtype; - short ret; - AEKeyword key; - Size len; - NavDialogOptions opt; - - InitCursor(); - NavGetDefaultDialogOptions( &opt ); - mkstr255(opt.savedFileName, title); - opt.dialogOptionFlags+=kNavNoTypePopup; - - eventUPP=NewNavEventUPP( navEventProc ); - ret=NavPutFile( NULL,&reply,&opt,eventUPP,type,sign,NULL ); - DisposeNavEventUPP( eventUPP ); - - if( reply.validRecord && ret==0 ) - { - ret=AEGetNthPtr( &(reply.selection),1,typeFSS,&key,&rtype,(Ptr)fsc,(long)sizeof(FSSpec),&len ); - NavDisposeReply( &reply ); - } - if (ret == noErr) { - return true; - } - return( false ); -}