| version 1.2, 2004/03/02 23:23:06 | version 1.4, 2004/03/22 17:56:35 | 
| Line 13 | Line 13 | 
 | #include "dialog.h" | #include "dialog.h" | 
 | #include "dialogutils.h" | #include "dialogutils.h" | 
 | #include "midiopt.h" | #include "midiopt.h" | 
 |  | #include "dipswbmp.h" | 
 |  |  | 
 | #define setControlValue(a,b,c)          SetControl32BitValue(getControlRefByID(a,b,midiWin),c) | #define setControlValue(a,b,c)          SetControl32BitValue(getControlRefByID(a,b,midiWin),c) | 
 | #define getMenuValue                            (GetControl32BitValue(getControlRefByID(cmd.commandID,0,midiWin))-1) | #define getMenuValue                            (GetControl32BitValue(getControlRefByID(cmd.commandID,0,midiWin))-1) | 
| Line 70  static void setMPUs(void) { | Line 71  static void setMPUs(void) { | 
 |  |  | 
 | setControlValue('usem', 0, mpucfg.def_en); | setControlValue('usem', 0, mpucfg.def_en); | 
 | setMIMPIFilename(); | setMIMPIFilename(); | 
 |  |  | 
 |  | PicHandle   pict; | 
 |  | ControlRef  disp = getControlRefByID('BMP ', 0, midiWin); | 
 |  | setbmp(dipswbmp_getmpu(mpu), &pict); | 
 |  | SetControlData(disp, kControlNoPart, kControlPictureHandleTag, sizeof(PicHandle), &pict); | 
 | } | } | 
 |  |  | 
 | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | static pascal OSStatus cfWinproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | 
| Line 89  static pascal OSStatus cfWinproc(EventHa | Line 95  static pascal OSStatus cfWinproc(EventHa | 
 | strcpy(mpucfg.def, ""); | strcpy(mpucfg.def, ""); | 
 | mpucfg.def_en = 0; | mpucfg.def_en = 0; | 
 | setMPUs(); | setMPUs(); | 
 |  | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case 'MPio': | case 'MPio': | 
 | setjmper(&mpu, getMenuValue << 4, 0xf0); | setjmper(&mpu, getMenuValue << 4, 0xf0); | 
 |  | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case 'MPin': | case 'MPin': | 
 | setjmper(&mpu, getMenuValue, 0x03); | setjmper(&mpu, getMenuValue, 0x03); | 
 |  | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case 'mido': | case 'mido': | 
 | strcpy(mpucfg.mout, midiout_name[getMenuValue]); | strcpy(mpucfg.mout, midiout_name[getMenuValue]); | 
 |  | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case 'midi': | case 'midi': | 
 | strcpy(mpucfg.min, midiout_name[getMenuValue]); | strcpy(mpucfg.min, midiout_name[getMenuValue]); | 
 |  | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case 'midm': | case 'midm': | 
 | strcpy(mpucfg.mdl, cmmidi_mdlname[getMenuValue]); | strcpy(mpucfg.mdl, cmmidi_mdlname[getMenuValue]); | 
 |  | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case 'usem': | case 'usem': | 
 | mpucfg.def_en = GetControl32BitValue(getControlRefByID(cmd.commandID, 0, midiWin)); | mpucfg.def_en = GetControl32BitValue(getControlRefByID(cmd.commandID, 0, midiWin)); | 
 |  | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case 'opnm': | case 'opnm': | 
 | dialog_fileselect(mpucfg.def, sizeof(mpucfg.def), NULL, OPEN_MIMPI); | dialog_fileselect(mpucfg.def, sizeof(mpucfg.def), NULL, OPEN_MIMPI); | 
 | setMIMPIFilename(); | setMIMPIFilename(); | 
 |  | err=noErr; | 
 | break; | break; | 
 |  |  | 
 | case kHICommandOK: | case kHICommandOK: | 
| Line 155  static pascal OSStatus cfWinproc(EventHa | Line 169  static pascal OSStatus cfWinproc(EventHa | 
 | return err; | return err; | 
 | } | } | 
 |  |  | 
 |  | static pascal OSStatus ctrlproc(EventHandlerCallRef myHandler, EventRef event, void* userData) { | 
 |  | OSStatus    err = eventNotHandledErr; | 
 |  | HIPoint         p; | 
 |  | BYTE            bit; | 
 |  | int                     move; | 
 |  | Rect            ctrlbounds, winbounds; | 
 |  | PicHandle   pict; | 
 |  | BOOL            redraw = FALSE; | 
 |  |  | 
 |  | if (GetEventClass(event)==kEventClassControl && GetEventKind(event)==kEventControlClick ) { | 
 |  | err = noErr; | 
 |  | GetEventParameter(event, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &p); | 
 |  | GetControlBounds((ControlRef)userData, &ctrlbounds); | 
 |  | GetWindowBounds(midiWin, kWindowContentRgn, &winbounds); | 
 |  | p.x -= (ctrlbounds.left + winbounds.left); | 
 |  | p.x /= 9; | 
 |  | if ((p.x >= 2) && (p.x < 6)) { | 
 |  | move = (int)(p.x - 2); | 
 |  | bit = 0x80 >> move; | 
 |  | mpu ^= bit; | 
 |  | redraw = TRUE; | 
 |  | } | 
 |  | else if ((p.x >= 9) && (p.x < 13)) { | 
 |  | bit = (BYTE)(13 - p.x); | 
 |  | if ((mpu ^ bit) & 3) { | 
 |  | mpu &= ~0x3; | 
 |  | mpu |= bit; | 
 |  | redraw = TRUE; | 
 |  | } | 
 |  | } | 
 |  | if (redraw) { | 
 |  | setMPUs(); | 
 |  | setbmp(dipswbmp_getmpu(mpu), &pict); | 
 |  | SetControlData((ControlRef)userData, kControlNoPart, kControlPictureHandleTag, sizeof(PicHandle), &pict); | 
 |  | Draw1Control((ControlRef)userData); | 
 |  | } | 
 |  | } | 
 |  |  | 
 |  | (void)myHandler; | 
 |  | (void)userData; | 
 |  | return err; | 
 |  | } | 
 |  |  | 
 | static void initMidiWindow(void) { | static void initMidiWindow(void) { | 
 | mpu = np2cfg.mpuopt; | mpu = np2cfg.mpuopt; | 
 | mpucfg = np2oscfg.mpu; | mpucfg = np2oscfg.mpu; | 
| Line 167  static void initMidiWindow(void) { | Line 224  static void initMidiWindow(void) { | 
 | } | } | 
 |  |  | 
 | static void makeNibWindow (IBNibRef nibRef) { | static void makeNibWindow (IBNibRef nibRef) { | 
| OSStatus    err; | OSStatus            err; | 
 | EventHandlerRef     ref; | EventHandlerRef     ref; | 
 |  | ControlRef              cref; | 
 |  |  | 
 | err = CreateWindowFromNib(nibRef, CFSTR("MidiDialog"), &midiWin); | err = CreateWindowFromNib(nibRef, CFSTR("MidiDialog"), &midiWin); | 
 | if (err == noErr) { | if (err == noErr) { | 
 |  |  | 
 | initMidiWindow(); | initMidiWindow(); | 
| EventTypeSpec   list[]={ { kEventClassCommand, kEventCommandProcess },}; | EventTypeSpec   list[]={ { kEventClassCommand, kEventCommandProcess }, | 
|  | { kEventClassWindow,  kEventWindowShowing} }; | 
 | InstallWindowEventHandler (midiWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)midiWin, &ref); | InstallWindowEventHandler (midiWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)midiWin, &ref); | 
 |  |  | 
 |  | EventTypeSpec   ctrllist[]={ { kEventClassControl, kEventControlClick } }; | 
 |  | cref = getControlRefByID('BMP ', 0, midiWin); | 
 |  | InstallControlEventHandler(cref, NewEventHandlerUPP(ctrlproc), GetEventTypeCount(ctrllist), ctrllist, (void *)cref, NULL); | 
 |  |  | 
 | ShowSheetWindow(midiWin, hWndMain); | ShowSheetWindow(midiWin, hWndMain); | 
 |  |  | 
 | err=RunAppModalLoopForWindow(midiWin); | err=RunAppModalLoopForWindow(midiWin); |