| version 1.3, 2003/11/08 17:54:27 | version 1.6, 2004/01/31 19:45:26 | 
| Line 8 | Line 8 | 
 | #include        "macnewdisk.h" | #include        "macnewdisk.h" | 
 |  |  | 
 | static  WindowRef       diskWin; | static  WindowRef       diskWin; | 
| static  SInt32  targetDisk, media, hdsize; | static  SInt32  targetDisk, media, hdsize, hddtype; | 
 | static  char    disklabel[256]; | static  char    disklabel[256]; | 
 | enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; | enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; | 
| #define kMaxNumTabs 2 | #define kMaxNumTabs 4 | 
 | 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)) | 
 |  |  | 
| Line 30  static pascal OSStatus cfWinproc(EventHa | Line 30  static pascal OSStatus cfWinproc(EventHa | 
 | GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); | GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &cmd); | 
 | switch (cmd.commandID) | switch (cmd.commandID) | 
 | { | { | 
| case 'hdsz': | case 'hds2': | 
| data = getControlValue(cmd.commandID,1)-1; | data = getControlValue('hdsz', 3)-1; | 
 | sprintf(outstr, "%d", defaultsize[data]); | sprintf(outstr, "%d", defaultsize[data]); | 
| SetControlData(getControlRefByID(cmd.commandID,0,diskWin),kControlNoPart,kControlStaticTextTextTag,strlen(outstr),outstr); | SetControlData(getControlRefByID('hdsz',2,diskWin),kControlNoPart,kControlStaticTextTextTag,strlen(outstr),outstr); | 
| Draw1Control(getControlRefByID(cmd.commandID,0,diskWin)); | Draw1Control(getControlRefByID('hdsz',2,diskWin)); | 
|  | break; | 
|  |  | 
|  | case 'hds4': | 
|  | data = getControlValue('hdsz', 5)-1; | 
|  | sprintf(outstr, "%d", defaultsize[data]); | 
|  | SetControlData(getControlRefByID('hdsz',4,diskWin),kControlNoPart,kControlStaticTextTextTag,strlen(outstr),outstr); | 
|  | Draw1Control(getControlRefByID('hdsz',4,diskWin)); | 
 | break; | break; | 
 |  |  | 
 | case kHICommandOK: | case kHICommandOK: | 
 | targetDisk = getControlValue(kTabMasterSig, kTabMasterID); | targetDisk = getControlValue(kTabMasterSig, kTabMasterID); | 
 | getFieldText(getControlRefByID('fdlb', 0, diskWin), disklabel); | getFieldText(getControlRefByID('fdlb', 0, diskWin), disklabel); | 
 | media = getControlValue('fdty', 0); | media = getControlValue('fdty', 0); | 
| data = getFieldValue(getControlRefByID('hdsz', 0, diskWin)); | if (targetDisk==2 || targetDisk==4) { | 
| if (data < 0) { | data = getFieldValue(getControlRefByID('hdsz', targetDisk, diskWin)); | 
| data = 0; | if (data < 0) { | 
| } | data = 0; | 
| else if (data > 512) { | } | 
| data = 512; | else if (data > 512) { | 
| } | data = 512; | 
| hdsize = data; | } | 
|  | hdsize = data; | 
|  | } | 
|  | else if (targetDisk==3) { | 
|  | hdsize = getControlValue('hdsz', 20)-1; | 
|  | } | 
 | QuitAppModalLoopForWindow(diskWin); | QuitAppModalLoopForWindow(diskWin); | 
 | err=noErr; | err=noErr; | 
 | break; | break; | 
| Line 70  static pascal OSStatus cfWinproc(EventHa | Line 82  static pascal OSStatus cfWinproc(EventHa | 
 |  |  | 
 | static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | 
 | { | { | 
| WindowRef theWindow = (WindowRef)inUserData;  // get the windowRef, passed around as userData | WindowRef   theWindow = (WindowRef)inUserData;  // get the windowRef, passed around as userData | 
| short ret; | short               ret; | 
|  | ControlRef  focus = NULL; | 
|  |  | 
 | ret = changeTab(theWindow, lastPaneSelected); | ret = changeTab(theWindow, lastPaneSelected); | 
 | if (ret) { | if (ret) { | 
 |  | if (ret == 1) { | 
 |  | focus = getControlRefByID('fdlb', 0, theWindow); | 
 |  | } | 
 |  | else if (ret == 2 || ret == 4) { | 
 |  | focus = getControlRefByID('hdsz', ret, theWindow); | 
 |  | } | 
 |  | SetKeyboardFocus(theWindow, focus, kControlFocusNextPart); | 
 | lastPaneSelected = ret; | lastPaneSelected = ret; | 
 | } | } | 
 | return( eventNotHandledErr ); | return( eventNotHandledErr ); | 
| Line 125  void newdisk(void) { | Line 146  void newdisk(void) { | 
 | else if (targetDisk == 2) { | else if (targetDisk == 2) { | 
 | if (dialog_filewriteselect('.THD', "Newdisk.thd", &fss, diskWin)) { | if (dialog_filewriteselect('.THD', "Newdisk.thd", &fss, diskWin)) { | 
 | fsspec2path(&fss, fname, sizeof(fname)); | fsspec2path(&fss, fname, sizeof(fname)); | 
| newdisk_hdd(fname, hdsize); | newdisk_thd(fname, hdsize); | 
|  | } | 
|  | } | 
|  | else if (targetDisk == 3) { | 
|  | if (dialog_filewriteselect('.HDI', "Newdisk.hdi", &fss, diskWin)) { | 
|  | fsspec2path(&fss, fname, sizeof(fname)); | 
|  | newdisk_hdi(fname, hddtype); | 
|  | } | 
|  | } | 
|  | else if (targetDisk == 4) { | 
|  | if (dialog_filewriteselect('.HDD', "Newdisk.hdd", &fss, diskWin)) { | 
|  | fsspec2path(&fss, fname, sizeof(fname)); | 
|  | newdisk_vhd(fname, hdsize); | 
 | } | } | 
 | } | } | 
 | HideWindow(diskWin); | HideWindow(diskWin); |