|
|
| version 1.1, 2003/10/23 21:00:24 | version 1.3, 2003/10/25 21:28:14 |
|---|---|
| Line 13 | Line 13 |
| #include "iocore.h" | #include "iocore.h" |
| #include "scrndraw.h" | #include "scrndraw.h" |
| #include "palettes.h" | #include "palettes.h" |
| #include "configure.h" | #include "dialogutils.h" |
| static WindowRef screenWin; | #define getControlValue(a) GetControl32BitValue(getControlRefByID(a,0,screenWin)) |
| static void SetInitialTabState(WindowRef theWindow); | #define setControlValue(a,b) SetControl32BitValue(getControlRefByID(a,0,screenWin),b) |
| static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ); | |
| enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb',kMaxNumTabs= 3}; | #define kMaxNumTabs 3 |
| enum {kTabMasterSig = 'ScrT',kTabMasterID = 1000,kTabPaneSig= 'ScTb'}; | |
| static WindowRef screenWin; | |
| static UInt16 lastPaneSelected = 1; // static, to keep track of it long term (in a more complex application | |
| // you might store this in a data structure in the window refCon) | |
| static void endLoop(void) { | |
| OSStatus err; | |
| HideSheetWindow(screenWin); | |
| DisposeWindow(screenWin); | |
| err=QuitAppModalLoopForWindow(screenWin); | |
| } | |
| static void setFieldValue(UInt32 type) { | static void setFieldValue(UInt32 type) { |
| ControlRef conRef; | ControlRef conRef; |
| Str255 title; | Str255 title; |
| SInt32 value; | SInt32 value; |
| value = GetControl32BitValue(getControlRefByID(type, 0, screenWin)); | value = getControlValue(type); |
| if (type == 'RPAd') { | if (type == 'RPAd') { |
| value -= 31; | value -= 31; |
| } | } |
| Line 44 static void setFieldValue(UInt32 type) { | Line 42 static void setFieldValue(UInt32 type) { |
| } | } |
| static void setReverseStatus(void) { | static void setReverseStatus(void) { |
| if (GetControl32BitValue(getControlRefByID('LCDy', 0, screenWin))) { | if (getControlValue('LCDy')) { |
| ActivateControl(getControlRefByID('rvrs', 0, screenWin)); | ActivateControl(getControlRefByID('rvrs', 0, screenWin)); |
| } | } |
| else { | else { |
| Line 53 static void setReverseStatus(void) { | Line 51 static void setReverseStatus(void) { |
| } | } |
| static void initScreenWindow(void) { | static void initScreenWindow(void) { |
| SetControl32BitValue(getControlRefByID('LCDy', 0, screenWin), np2cfg.LCD_MODE & 1); | setControlValue('LCDy', np2cfg.LCD_MODE & 1); |
| setReverseStatus(); | setReverseStatus(); |
| SetControl32BitValue(getControlRefByID('rvrs', 0, screenWin), np2cfg.LCD_MODE & 2?1:0); | setControlValue('rvrs', np2cfg.LCD_MODE & 2?1:0); |
| SetControl32BitValue(getControlRefByID('uskr', 0, screenWin), np2cfg.skipline); | setControlValue('uskr', np2cfg.skipline); |
| SetControl32BitValue(getControlRefByID('rati', 0, screenWin), np2cfg.skiplight); | setControlValue('rati', np2cfg.skiplight); |
| setFieldValue('rati'); | setFieldValue('rati'); |
| SetControl32BitValue(getControlRefByID('GDCl', 0, screenWin), np2cfg.uPD72020 + 1); | setControlValue('GDCl', np2cfg.uPD72020 + 1); |
| SetControl32BitValue(getControlRefByID('GrCh', 0, screenWin), (np2cfg.grcg & 3) + 1); | setControlValue('GrCh', (np2cfg.grcg & 3) + 1); |
| SetControl32BitValue(getControlRefByID('16cl', 0, screenWin), np2cfg.color16); | setControlValue('16cl', np2cfg.color16); |
| SetControl32BitValue(getControlRefByID('tram', 0, screenWin), np2cfg.wait[0]); | setControlValue('tram', np2cfg.wait[0]); |
| setFieldValue('tram'); | setFieldValue('tram'); |
| SetControl32BitValue(getControlRefByID('vram', 0, screenWin), np2cfg.wait[2]); | setControlValue('vram', np2cfg.wait[2]); |
| setFieldValue('vram'); | setFieldValue('vram'); |
| SetControl32BitValue(getControlRefByID('crgc', 0, screenWin), np2cfg.wait[4]); | setControlValue('crgc', np2cfg.wait[4]); |
| setFieldValue('crgc'); | setFieldValue('crgc'); |
| SetControl32BitValue(getControlRefByID('RPAd', 0, screenWin), np2cfg.realpal); | setControlValue('RPAd', np2cfg.realpal); |
| setFieldValue('RPAd'); | setFieldValue('RPAd'); |
| } | } |
| Line 102 static pascal OSStatus cfWinproc(EventHa | Line 100 static pascal OSStatus cfWinproc(EventHa |
| case kHICommandOK: | case kHICommandOK: |
| renewal = 0; | renewal = 0; |
| val=GetControl32BitValue(getControlRefByID('uskr', 0, screenWin)); | val=getControlValue('uskr'); |
| if (np2cfg.skipline != val) { | if (np2cfg.skipline != val) { |
| np2cfg.skipline = val; | np2cfg.skipline = val; |
| renewal = 1; | renewal = 1; |
| } | } |
| val=GetControl32BitValue(getControlRefByID('rati', 0, screenWin)); | val=getControlValue('rati'); |
| if (val != np2cfg.skiplight); | if (val != np2cfg.skiplight); |
| if (renewal) { | if (renewal) { |
| pal_makeskiptable(); | pal_makeskiptable(); |
| } | } |
| val=GetControl32BitValue(getControlRefByID('LCDy', 0, screenWin)) | | val=getControlValue('LCDy') | getControlValue('rvrs') << 1; |
| GetControl32BitValue(getControlRefByID('rvrs', 0, screenWin)) << 1; | |
| if (np2cfg.LCD_MODE != val) { | if (np2cfg.LCD_MODE != val) { |
| np2cfg.LCD_MODE = val; | np2cfg.LCD_MODE = val; |
| pal_makelcdpal(); | pal_makelcdpal(); |
| Line 125 static pascal OSStatus cfWinproc(EventHa | Line 122 static pascal OSStatus cfWinproc(EventHa |
| } | } |
| update = 0; | update = 0; |
| val=GetControl32BitValue(getControlRefByID('GDCl', 0, screenWin))-1; | val=getControlValue('GDCl')-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=GetControl32BitValue(getControlRefByID('GrCh', 0, screenWin))-1; | val=getControlValue('GrCh')-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=GetControl32BitValue(getControlRefByID('16cl', 0, screenWin)); | val=getControlValue('16cl'); |
| if (np2cfg.color16 != val) { | if (np2cfg.color16 != val) { |
| np2cfg.color16 = val; | np2cfg.color16 = val; |
| update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; |
| } | } |
| value[0]=GetControl32BitValue(getControlRefByID('tram', 0, screenWin)); | value[0]=getControlValue('tram'); |
| if (value[0]) { | if (value[0]) { |
| value[1] = 1; | value[1] = 1; |
| } | } |
| value[2]=GetControl32BitValue(getControlRefByID('vram', 0, screenWin)); | value[2]=getControlValue('vram'); |
| if (value[0]) { | if (value[0]) { |
| value[3] = 1; | value[3] = 1; |
| } | } |
| value[4]=GetControl32BitValue(getControlRefByID('crgc', 0, screenWin)); | value[4]=getControlValue('crgc'); |
| if (value[0]) { | if (value[0]) { |
| value[5] = 1; | value[5] = 1; |
| } | } |
| Line 162 static pascal OSStatus cfWinproc(EventHa | Line 159 static pascal OSStatus cfWinproc(EventHa |
| update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; |
| } | } |
| } | } |
| val=GetControl32BitValue(getControlRefByID('RPAd', 0, screenWin)); | val=getControlValue('RPAd'); |
| if (val != np2cfg.realpal) { | if (val != np2cfg.realpal) { |
| np2cfg.realpal = val; | np2cfg.realpal = val; |
| update |= SYS_UPDATECFG; | update |= SYS_UPDATECFG; |
| } | } |
| sysmng_update(update); | sysmng_update(update); |
| endLoop(); | endLoop(screenWin); |
| err=noErr; | err=noErr; |
| break; | break; |
| case kHICommandCancel: | case kHICommandCancel: |
| endLoop(); | endLoop(screenWin); |
| err=noErr; | err=noErr; |
| break; | break; |
| } | } |
| Line 185 static pascal OSStatus cfWinproc(EventHa | Line 182 static pascal OSStatus cfWinproc(EventHa |
| return err; | return err; |
| } | } |
| static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | |
| { | |
| WindowRef theWindow = (WindowRef)inUserData; // get the windowRef, passed around as userData | |
| short ret; | |
| ret = changeTab(theWindow, lastPaneSelected); | |
| if (ret) { | |
| lastPaneSelected = ret; | |
| } | |
| return( eventNotHandledErr ); | |
| } | |
| static void makeNibWindow (IBNibRef nibRef) { | static void makeNibWindow (IBNibRef nibRef) { |
| OSStatus err; | OSStatus err; |
| err = CreateWindowFromNib(nibRef, CFSTR("ScreenDialog"), &screenWin); | err = CreateWindowFromNib(nibRef, CFSTR("ScreenDialog"), &screenWin); |
| if (err == noErr) { | if (err == noErr) { |
| initScreenWindow(); | initScreenWindow(); |
| SetInitialTabState(screenWin); | SetInitialTabState(screenWin, lastPaneSelected, kMaxNumTabs); |
| 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[]={ | EventTypeSpec list[]={ { kEventClassCommand, kEventCommandProcess },}; |
| { kEventClassCommand, kEventCommandProcess }, | |
| }; | |
| EventHandlerRef ref; | EventHandlerRef ref; |
| InstallWindowEventHandler (screenWin, NewEventHandlerUPP(cfWinproc), sizeof(list)/sizeof(EventTypeSpec), list, (void *)screenWin, &ref); | InstallWindowEventHandler (screenWin, NewEventHandlerUPP(cfWinproc), GetEventTypeCount(list), list, (void *)screenWin, &ref); |
| ShowSheetWindow(screenWin, hWndMain); | ShowSheetWindow(screenWin, hWndMain); |
| err=RunAppModalLoopForWindow(screenWin); | err=RunAppModalLoopForWindow(screenWin); |
| Line 219 void initScreenOpt( void ) { | Line 225 void initScreenOpt( void ) { |
| return; | return; |
| } | } |
| } | } |
| static UInt16 lastPaneSelected = 1; // static, to keep track of it long term (in a more complex application | |
| // you might store this in a data structure in the window refCon) | |
| static void SetInitialTabState(WindowRef theWindow) | |
| { | |
| short qq; | |
| for(qq=0;qq<kMaxNumTabs+1;qq++) | |
| SetControlVisibility( getControlRefByID( kTabPaneSig, kTabMasterID+qq, theWindow), false, true ); | |
| SetControlValue(getControlRefByID(kTabMasterSig,kTabMasterID,theWindow),lastPaneSelected ); | |
| SetControlVisibility( getControlRefByID( kTabPaneSig, kTabMasterID+lastPaneSelected, theWindow), true, true ); | |
| } | |
| static pascal OSStatus PrefsTabEventHandlerProc( EventHandlerCallRef inCallRef, EventRef inEvent, void* inUserData ) | |
| { | |
| WindowRef theWindow = (WindowRef)inUserData; // get the windowRef, passed around as userData | |
| short controlValue = 2; | |
| controlValue = GetControlValue( getControlRefByID(kTabMasterSig,kTabMasterID,theWindow) ); | |
| if ( controlValue != lastPaneSelected ) | |
| { | |
| SetControlVisibility( getControlRefByID( kTabPaneSig, kTabMasterID+lastPaneSelected, theWindow), false, true ); | |
| SetControlVisibility( getControlRefByID( kTabPaneSig, kTabMasterID+controlValue, theWindow), true, true ); | |
| Draw1Control( getControlRefByID(kTabMasterSig,kTabMasterID,theWindow) ); | |
| lastPaneSelected= controlValue; | |
| } | |
| return( eventNotHandledErr ); | |
| } | |