|
|
| version 1.2, 2003/11/06 18:27:59 | version 1.3, 2003/11/08 17:54:27 |
|---|---|
| Line 7 | Line 7 |
| #include "dialogutils.h" | #include "dialogutils.h" |
| #include "macnewdisk.h" | #include "macnewdisk.h" |
| const int defaultsize[5] = {20, 41, 65, 80, 128}; | |
| static WindowRef diskWin; | static WindowRef diskWin; |
| static SInt32 targetDisk, media, hdsize; | static SInt32 targetDisk, media, hdsize; |
| static char disklabel[256]; | static char disklabel[256]; |
| Line 16 enum {kTabMasterSig = 'ScrT',kTabMasterI | Line 15 enum {kTabMasterSig = 'ScrT',kTabMasterI |
| static UInt16 lastPaneSelected = 1; | static UInt16 lastPaneSelected = 1; |
| #define getControlValue(a,b) GetControl32BitValue(getControlRefByID(a,b,diskWin)) | #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) { | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { |
| OSStatus err = eventNotHandledErr; | OSStatus err = eventNotHandledErr; |
| HICommand cmd; | HICommand cmd; |
| Line 81 static void makeNibWindow (IBNibRef nibR | Line 85 static void makeNibWindow (IBNibRef nibR |
| err = CreateWindowFromNib(nibRef, CFSTR("NewDiskDialog"), &diskWin); | err = CreateWindowFromNib(nibRef, CFSTR("NewDiskDialog"), &diskWin); |
| if (err == noErr) { | if (err == noErr) { |
| SetInitialTabState(diskWin, lastPaneSelected, kMaxNumTabs); | SetInitialTabState(diskWin, lastPaneSelected, kMaxNumTabs); |
| EventTypeSpec tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; | |
| InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,diskWin), PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, diskWin, NULL ); | InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,diskWin), PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, diskWin, NULL ); |
| EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess },}; | InstallWindowEventHandler (diskWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(hicommandEvents), hicommandEvents, (void *)diskWin, &ref); |
| InstallWindowEventHandler (diskWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)diskWin, &ref); | |
| ShowWindow(diskWin); | ShowWindow(diskWin); |
| RunAppModalLoopForWindow(diskWin); | RunAppModalLoopForWindow(diskWin); |
| } | } |
| return; | return; |
| } | } |
| Line 115 void newdisk(void) { | Line 117 void newdisk(void) { |
| initNewDisk(); | initNewDisk(); |
| if (targetDisk == 1) { | if (targetDisk == 1) { |
| if (saveFile('.D88', "Newdisk.d88", &fss)) { | if (dialog_filewriteselect('.D88', "Newdisk.d88", &fss, diskWin)) { |
| fsspec2path(&fss, fname, sizeof(fname)); | fsspec2path(&fss, fname, sizeof(fname)); |
| newdisk_fdd(fname, media, disklabel); | newdisk_fdd(fname, media, disklabel); |
| } | } |
| } | } |
| else if (targetDisk == 2) { | else if (targetDisk == 2) { |
| if (saveFile('.THD', "Newdisk.thd", &fss)) { | if (dialog_filewriteselect('.THD', "Newdisk.thd", &fss, diskWin)) { |
| fsspec2path(&fss, fname, sizeof(fname)); | fsspec2path(&fss, fname, sizeof(fname)); |
| newdisk_hdd(fname, hdsize); | newdisk_hdd(fname, hdsize); |
| } | } |
| Line 129 void newdisk(void) { | Line 131 void newdisk(void) { |
| HideWindow(diskWin); | HideWindow(diskWin); |
| DisposeWindow(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 ); | |
| } |