|
|
| version 1.3, 2003/10/25 21:28:14 | version 1.4, 2003/10/28 16:44:44 |
|---|---|
| Line 14 | Line 14 |
| #include "scrndraw.h" | #include "scrndraw.h" |
| #include "palettes.h" | #include "palettes.h" |
| #include "dialogutils.h" | #include "dialogutils.h" |
| #include "screenopt.h" | |
| #define getControlValue(a) GetControl32BitValue(getControlRefByID(a,0,screenWin)) | #define getControlValue(a,b) GetControl32BitValue(getControlRefByID(a,b,screenWin)) |
| #define setControlValue(a,b) SetControl32BitValue(getControlRefByID(a,0,screenWin),b) | #define setControlValue(a,b,c) SetControl32BitValue(getControlRefByID(a,b,screenWin),c) |
| #define kMaxNumTabs 3 | #define kMaxNumTabs 3 |
| enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; | enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; |
| Line 26 static UInt16 lastPaneSelected = 1; // s | Line 27 static UInt16 lastPaneSelected = 1; // s |
| // you might store this in a data structure in the window refCon) | // you might store this in a data structure in the window refCon) |
| static void setFieldValue(UInt32 type) { | |
| ControlRef conRef; | |
| Str255 title; | |
| SInt32 value; | |
| value = getControlValue(type); | |
| if (type == 'RPAd') { | |
| value -= 31; | |
| } | |
| NumToString(value, title); | |
| conRef = getControlRefByID(type, 1, screenWin); | |
| SetControlData(conRef, kControlNoPart, kControlStaticTextTextTag, *title, title+1); | |
| Draw1Control(conRef); | |
| } | |
| static void setReverseStatus(void) { | static void setReverseStatus(void) { |
| if (getControlValue('LCDy')) { | if (getControlValue('LCDy', 0)) { |
| ActivateControl(getControlRefByID('rvrs', 0, screenWin)); | ActivateControl(getControlRefByID('rvrs', 0, screenWin)); |
| } | } |
| else { | else { |
| Line 51 static void setReverseStatus(void) { | Line 37 static void setReverseStatus(void) { |
| } | } |
| static void initScreenWindow(void) { | static void initScreenWindow(void) { |
| setControlValue('LCDy', np2cfg.LCD_MODE & 1); | setControlValue('LCDy', 0, np2cfg.LCD_MODE & 1); |
| setReverseStatus(); | setReverseStatus(); |
| setControlValue('rvrs', np2cfg.LCD_MODE & 2?1:0); | setControlValue('rvrs', 0, np2cfg.LCD_MODE & 2?1:0); |
| setControlValue('uskr', np2cfg.skipline); | setControlValue('uskr', 0, np2cfg.skipline); |
| setControlValue('rati', np2cfg.skiplight); | setControlValue('sl/f', 0, np2cfg.skiplight); |
| setFieldValue('rati'); | |
| setControlValue('GDCl', 0, np2cfg.uPD72020 + 1); | |
| setControlValue('GDCl', np2cfg.uPD72020 + 1); | setControlValue('GrCh', 0, (np2cfg.grcg & 3) + 1); |
| setControlValue('GrCh', (np2cfg.grcg & 3) + 1); | setControlValue('16cl', 0, np2cfg.color16); |
| setControlValue('16cl', np2cfg.color16); | |
| setControlValue('sl/f', 1, np2cfg.wait[0]); | |
| setControlValue('tram', np2cfg.wait[0]); | setControlValue('sl/f', 2, np2cfg.wait[2]); |
| setFieldValue('tram'); | setControlValue('sl/f', 3, np2cfg.wait[4]); |
| setControlValue('vram', np2cfg.wait[2]); | setControlValue('sl/f', 4, np2cfg.realpal); |
| setFieldValue('vram'); | |
| setControlValue('crgc', np2cfg.wait[4]); | |
| setFieldValue('crgc'); | |
| setControlValue('RPAd', np2cfg.realpal); | |
| setFieldValue('RPAd'); | |
| } | } |
| 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 69 static pascal OSStatus cfWinproc(EventHa |
| case 'LCDy': | case 'LCDy': |
| setReverseStatus(); | setReverseStatus(); |
| break; | break; |
| case 'rati': | |
| case 'tram': | |
| case 'vram': | |
| case 'crgc': | |
| case 'RPAd': | |
| setFieldValue(cmd.commandID); | |
| break; | |
| case kHICommandOK: | case kHICommandOK: |
| renewal = 0; | renewal = 0; |
| val=getControlValue('uskr'); | val=getControlValue('uskr', 0); |
| if (np2cfg.skipline != val) { | if (np2cfg.skipline != val) { |
| np2cfg.skipline = val; | np2cfg.skipline = val; |
| renewal = 1; | renewal = 1; |
| } | } |
| val=getControlValue('rati'); | val=getControlValue('sl/f', 0); |
| if (val != np2cfg.skiplight); | if (val != np2cfg.skiplight); |
| if (renewal) { | if (renewal) { |
| pal_makeskiptable(); | pal_makeskiptable(); |
| } | } |
| val=getControlValue('LCDy') | getControlValue('rvrs') << 1; | val=getControlValue('LCDy', 0) | getControlValue('rvrs', 0) << 1; |
| if (np2cfg.LCD_MODE != val) { | if (np2cfg.LCD_MODE != val) { |
| np2cfg.LCD_MODE = val; | np2cfg.LCD_MODE = val; |
| pal_makelcdpal(); | pal_makelcdpal(); |
| Line 122 static pascal OSStatus cfWinproc(EventHa | Line 94 static pascal OSStatus cfWinproc(EventHa |
| } | } |
| update = 0; | update = 0; |
| val=getControlValue('GDCl')-1; | val=getControlValue('GDCl', 0)-1; |
| if (np2cfg.uPD72020 != val) { | if (np2cfg.uPD72020 != val) { |
| np2cfg.uPD72020 = val; | np2cfg.uPD72020 = val; |
| update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; |
| gdc_restorekacmode(); | gdc_restorekacmode(); |
| gdcs.grphdisp |= GDCSCRN_ALLDRAW2; | gdcs.grphdisp |= GDCSCRN_ALLDRAW2; |
| } | } |
| val=getControlValue('GrCh')-1; | val=getControlValue('GrCh', 0)-1; |
| if (np2cfg.grcg != val) { | if (np2cfg.grcg != val) { |
| np2cfg.grcg = val; | np2cfg.grcg = val; |
| update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; |
| gdcs.grphdisp |= GDCSCRN_ALLDRAW2; | gdcs.grphdisp |= GDCSCRN_ALLDRAW2; |
| } | } |
| val=getControlValue('16cl'); | val=getControlValue('16cl', 0); |
| if (np2cfg.color16 != val) { | if (np2cfg.color16 != val) { |
| np2cfg.color16 = val; | np2cfg.color16 = val; |
| update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; |
| } | } |
| value[0]=getControlValue('tram'); | value[0]=getControlValue('sl/f', 1); |
| if (value[0]) { | if (value[0]) { |
| value[1] = 1; | value[1] = 1; |
| } | } |
| value[2]=getControlValue('vram'); | value[2]=getControlValue('sl/f', 2); |
| if (value[0]) { | if (value[0]) { |
| value[3] = 1; | value[3] = 1; |
| } | } |
| value[4]=getControlValue('crgc'); | value[4]=getControlValue('sl/f', 3); |
| if (value[0]) { | if (value[0]) { |
| value[5] = 1; | value[5] = 1; |
| } | } |
| Line 159 static pascal OSStatus cfWinproc(EventHa | Line 131 static pascal OSStatus cfWinproc(EventHa |
| update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; |
| } | } |
| } | } |
| val=getControlValue('RPAd'); | val=getControlValue('sl/f', 4); |
| if (val != np2cfg.realpal) { | if (val != np2cfg.realpal) { |
| np2cfg.realpal = val; | np2cfg.realpal = val; |
| update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; |
| Line 182 static pascal OSStatus cfWinproc(EventHa | Line 154 static pascal OSStatus cfWinproc(EventHa |
| return err; | return err; |
| } | } |
| static pascal OSStatus sliderEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | |
| { | |
| short base = 0; | |
| ControlID conID; | |
| ControlRef theControl = (ControlRef)inUserData; | |
| if (GetControlID(theControl, &conID) == noErr) { | |
| if (conID.signature == 'sl/f' && conID.id == 4) { | |
| base = 31; | |
| } | |
| } | |
| return( changeSlider(theControl, screenWin, base) ); | |
| } | |
| 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 |
| Line 195 static pascal OSStatus PrefsTabEventHand | Line 180 static pascal OSStatus PrefsTabEventHand |
| static void makeNibWindow (IBNibRef nibRef) { | static void makeNibWindow (IBNibRef nibRef) { |
| OSStatus err; | OSStatus err; |
| short i; | |
| ControlRef targetCon[5]; | |
| err = CreateWindowFromNib(nibRef, CFSTR("ScreenDialog"), &screenWin); | err = CreateWindowFromNib(nibRef, CFSTR("ScreenDialog"), &screenWin); |
| if (err == noErr) { | if (err == noErr) { |
| Line 203 static void makeNibWindow (IBNibRef nibR | Line 190 static void makeNibWindow (IBNibRef nibR |
| EventTypeSpec tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; | EventTypeSpec tabControlEvents[] ={ { kEventClassControl, kEventControlHit }}; |
| InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,screenWin), PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, screenWin, NULL ); | InstallControlEventHandler( getControlRefByID(kTabMasterSig,kTabMasterID,screenWin), PrefsTabEventHandlerProc , GetEventTypeCount(tabControlEvents), tabControlEvents, screenWin, NULL ); |
| EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess },}; | EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess },}; |
| EventTypeSpec sliderControlEvents[] ={ | |
| { kEventClassControl, kEventControlDraw }, | |
| { kEventClassControl, kEventControlValueFieldChanged } | |
| }; | |
| for (i=0;i<5;i++) { | |
| targetCon[i] = getControlRefByID('sl/f',i,screenWin); | |
| InstallControlEventHandler( targetCon[i], sliderEventHandlerProc , GetEventTypeCount(sliderControlEvents), sliderControlEvents, (void *)targetCon[i], NULL ); | |
| } | |
| EventHandlerRef ref; | EventHandlerRef ref; |
| InstallWindowEventHandler (screenWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)screenWin, &ref); | InstallWindowEventHandler (screenWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)screenWin, &ref); |
| ShowSheetWindow(screenWin, hWndMain); | ShowSheetWindow(screenWin, hWndMain); |