pascal OSStatus keyval_update_clicked (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { TKEYVAL *keyval_t = (TKEYVAL *) inUserData; DataBrowserItemID item = DBITEM_ID + 1, first, last; DataBrowserCallbacks dbCallbacks; ThemeDrawingState outState = NULL; UInt16 colSize[2] = { 150, 250 }; SInt16 outBaseline; Point ioBound; CFStringRef data[2]; Size len; int i = 0, j; if (keyval_t) { GetThemeDrawingState (&outState); GetControlData (keyval_t->key_entry, 0, kControlEditTextCFStringTag, sizeof (CFStringRef), &data[0], &len); if (CFStringGetLength(data[0])) { GetControlData (keyval_t->value_entry, 0, kControlEditTextCFStringTag, sizeof (CFStringRef), &data[1], &len); if(GetDataBrowserSelectionAnchor (keyval_t->key_list, &first, &last) == noErr) { i = first - DBITEM_ID - 1; item += i; } else i = 0; /* Install an event handler on the component databrowser */ dbCallbacks.version = kDataBrowserLatestCallbacks; InitDataBrowserCallbacks (&dbCallbacks); dbCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP (keyval_notification_item); /* On Mac OS X 10.0.x : this is clientDataCallback */ dbCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP (keyval_getset_item); SetDataBrowserCallbacks (keyval_t->key_list, &dbCallbacks); /* Begin the draw of the data browser */ SetDataBrowserTarget (keyval_t->key_list, DBITEM_ID); /* An update operation */ if(i<KEYVAL_nrows) { CFRelease (KEYVAL_array[0][i]); CFRelease (KEYVAL_array[1][i]); KEYVAL_array[0][i] = data[0]; KEYVAL_array[1][i] = data[1]; UpdateDataBrowserItems (keyval_t->key_list, DBITEM_ID, 1, &item, GSKEYWORD_ID, kDataBrowserItemNoProperty); } for(j = 0 ; j < KEYVAL_nrows ; j++) { for(i = 0 ; i < 2 ; i++) { GetThemeTextDimensions (KEYVAL_array[i][j], kThemeSystemFont, kThemeStateActive, false, &ioBound, &outBaseline); if(colSize[i] < ioBound.h) colSize[i] = ioBound.h; } } ActivateControl (keyval_t->key_list); /* Resize the columns to have a good look */ SetDataBrowserTableViewNamedColumnWidth (keyval_t->key_list, GSKEYWORD_ID, colSize[0] + 20); SetDataBrowserTableViewNamedColumnWidth (keyval_t->key_list, GSVALUE_ID, colSize[1] + 20); DrawOneControl (keyval_t->key_list); /* Remove the DataBrowser callback */ SetDataBrowserCallbacks (NULL, &dbCallbacks); } SetControlData (keyval_t->key_entry, 0, kControlEditTextTextTag, 0, ""); DrawOneControl (keyval_t->key_entry); SetControlData (keyval_t->value_entry, 0, kControlEditTextTextTag, 0, ""); DrawOneControl (keyval_t->value_entry); DeactivateControl (KEYVAL->bupdate); DrawOneControl (KEYVAL->bupdate); } return noErr; }
pascal OSStatus gensetup_add_clicked (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { TGENSETUP *gensetup_t = (TGENSETUP *) inUserData; DataBrowserItemID item = DBITEM_ID + 1; DataBrowserCallbacks dbCallbacks; ThemeDrawingState outState = NULL; UInt16 colSize[2] = { 150, 250 }; SInt16 outBaseline; Point ioBound; CFStringRef data[2]; Size len; int i = 0, j; if (gensetup_t) { GetThemeDrawingState (&outState); GetControlData (gensetup_t->key_entry, 0, kControlEditTextCFStringTag, sizeof (CFStringRef), &data[0], &len); if (CFStringGetLength(data[0])) { GetControlData (gensetup_t->value_entry, 0, kControlEditTextCFStringTag, sizeof (CFStringRef), &data[1], &len); /* Try to see if the keyword already exists */ for (i = 0; i < DSNSETUP_nrows; i++, item++) if (CFStringCompare (data[0], DSNSETUP_array[0][i], 0) == kCFCompareEqualTo) goto done; /* Install an event handler on the component databrowser */ dbCallbacks.version = kDataBrowserLatestCallbacks; InitDataBrowserCallbacks (&dbCallbacks); dbCallbacks.u.v1.itemNotificationCallback = NewDataBrowserItemNotificationUPP (dsnsetup_notification_item); /* On Mac OS X 10.0.x : this is clientDataCallback */ dbCallbacks.u.v1.itemDataCallback = NewDataBrowserItemDataUPP (dsnsetup_getset_item); SetDataBrowserCallbacks (gensetup_t->key_list, &dbCallbacks); /* Begin the draw of the data browser */ SetDataBrowserTarget (gensetup_t->key_list, DBITEM_ID); /* An update operation */ if(i<DSNSETUP_nrows) { CFRelease (DSNSETUP_array[1][i]); DSNSETUP_array[1][i] = data[1]; UpdateDataBrowserItems (gensetup_t->key_list, DBITEM_ID, 1, &item, GSKEYWORD_ID, kDataBrowserItemNoProperty); } else if(len) { DSNSETUP_array[0][i] = data[0]; DSNSETUP_array[1][i] = data[1]; AddDataBrowserItems (gensetup_t->key_list, DBITEM_ID, 1, &item, GSKEYWORD_ID); DSNSETUP_nrows++; } for(j = 0 ; j < DSNSETUP_nrows ; j++) { for(i = 0 ; i < 2 ; i++) { GetThemeTextDimensions (DSNSETUP_array[i][j], kThemeSystemFont, kThemeStateActive, false, &ioBound, &outBaseline); if(colSize[i] < ioBound.h) colSize[i] = ioBound.h; } } ActivateControl (gensetup_t->key_list); /* Resize the columns to have a good look */ SetDataBrowserTableViewNamedColumnWidth (gensetup_t->key_list, GSKEYWORD_ID, colSize[0] + 20); SetDataBrowserTableViewNamedColumnWidth (gensetup_t->key_list, GSVALUE_ID, colSize[1] + 20); DrawOneControl (gensetup_t->key_list); /* Remove the DataBrowser callback */ SetDataBrowserCallbacks (NULL, &dbCallbacks); } done: SetControlData (gensetup_t->key_entry, 0, kControlEditTextTextTag, 0, ""); DrawOneControl (gensetup_t->key_entry); SetControlData (gensetup_t->value_entry, 0, kControlEditTextTextTag, 0, ""); DrawOneControl (gensetup_t->value_entry); DeactivateControl (DSNSETUP->bupdate); DrawOneControl (DSNSETUP->bupdate); } return noErr; }
pascal OSStatus gensetup_ok_clicked (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { TGENSETUP *gensetup_t = (TGENSETUP *) inUserData; char *cour, *curr; int i = 0, size = 0; char msg[1024], msg1[1024]; Size len; if (gensetup_t) { /* What is the size of the block to malloc */ GetControlDataSize (gensetup_t->dsn_entry, 0, kControlEditTextTextTag, &len); size += len + STRLEN ("DSN=") + 1; GetControlDataSize (gensetup_t->comment_entry, 0, kControlEditTextTextTag, &len); size += len + STRLEN ("Description=") + 1; /* Malloc it */ if ((gensetup_t->connstr = (char *) malloc (++size))) { for (curr = STRCONN, cour = gensetup_t->connstr; i < STRCONN_NB_TOKENS; i++, curr += (STRLEN (curr) + 1)) switch (i) { case 0: GetControlData (gensetup_t->dsn_entry, 0, kControlEditTextTextTag, sizeof (msg), msg, &len); msg[len] = '\0'; sprintf (cour, curr, msg); cour += (STRLEN (cour) + 1); break; case 1: GetControlData (gensetup_t->comment_entry, 0, kControlEditTextTextTag, sizeof (msg), msg, &len); msg[len] = '\0'; sprintf (cour, curr, msg); cour += (STRLEN (cour) + 1); break; }; for (i = 0; i < DSNSETUP_nrows; i++) { CFStringGetCString (DSNSETUP_array[0][i], msg, sizeof (msg), kCFStringEncodingUTF8); CFStringGetCString (DSNSETUP_array[1][i], msg1, sizeof (msg1), kCFStringEncodingUTF8); cour = (char *) gensetup_t->connstr; gensetup_t->connstr = (LPSTR) malloc (size + STRLEN (msg) + STRLEN (msg1) + 2); if (gensetup_t->connstr) { memcpy (gensetup_t->connstr, cour, size); sprintf (((char*)gensetup_t->connstr) + size - 1, "%s=%s", msg, msg1); free (cour); size += STRLEN (msg) + STRLEN (msg1) + 2; } else gensetup_t->connstr = cour; } ((char*)gensetup_t->connstr)[size - 1] = '\0'; } DisposeWindow (gensetup_t->mainwnd); gensetup_t->mainwnd = NULL; gensetup_t->dsn_entry = gensetup_t->comment_entry = NULL; gensetup_t->key_list = NULL; DSNSETUP = NULL; } return noErr; }
void ConfigurePreferences (void) { OSStatus err; IBNibRef nibRef; err = CreateNibReference(kMacS9XCFString, &nibRef); if (err == noErr) { WindowRef tWindowRef; SInt32 oldVolume; uint32 oldPlaybackRate, oldInputRate, oldInterval, oldBufferSize; bool8 oldSynchronize, old16BitPlayback, oldStereo, oldReverseStereo, oldLagEnable; oldSynchronize = Settings.SoundSync; old16BitPlayback = Settings.SixteenBitSound; oldStereo = Settings.Stereo; oldReverseStereo = Settings.ReverseStereo; oldPlaybackRate = Settings.SoundPlaybackRate; oldInputRate = Settings.SoundInputRate; oldInterval = macSoundInterval_ms; oldBufferSize = macSoundBuffer_ms; oldLagEnable = macSoundLagEnable; oldVolume = macSoundVolume; if (cartOpen) DeinitGameWindow(); S9xGraphicsDeinit(); err = CreateWindowFromNib(nibRef, CFSTR("Preferences"), &tWindowRef); if (err == noErr) { EventHandlerUPP tUPP, iUPP, aUPP, pUPP; EventHandlerRef tRef, iRef, aRef, pRef; EventTypeSpec tEvents[] = { { kEventClassControl, kEventControlHit } }, iEvents[] = { { kEventClassControl, kEventControlClick } }, aEvents[] = { { kEventClassControl, kEventControlClick } }, pEvents[] = { { kEventClassWindow, kEventWindowClose }, { kEventClassCommand, kEventCommandProcess }, { kEventClassCommand, kEventCommandUpdateStatus } }; ControlActionUPP arrowsUPP, sliderUPP; HIViewRef ctl, root; HIViewID cid; MenuRef menu; char num[16]; root = HIViewGetRoot(tWindowRef); cid.signature = 'tabs'; cid.id = 128; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, lastTabIndex); SelectTabPane(ctl, lastTabIndex); tUPP = NewEventHandlerUPP(TabEventHandler); err = InstallControlEventHandler(ctl, tUPP, GetEventTypeCount(tEvents), tEvents, 0, &tRef); cid.signature = 'snd_'; cid.id = iNibSInputRateText; HIViewFindByID(root, cid, &ctl); iUPP = NewEventHandlerUPP(InputRateTextEventHandler); err = InstallControlEventHandler(ctl, iUPP, GetEventTypeCount(iEvents), iEvents, 0, &iRef); cid.signature = 'grap'; cid.id = iNibGAspectRatioText; HIViewFindByID(root, cid, &ctl); aUPP = NewEventHandlerUPP(AspectRatioTextEventHandler); err = InstallControlEventHandler(ctl, aUPP, GetEventTypeCount(aEvents), aEvents, 0, &aRef); pUPP = NewEventHandlerUPP(PreferencesEventHandler); err = InstallWindowEventHandler(tWindowRef, pUPP, GetEventTypeCount(pEvents), pEvents, (void *) tWindowRef, &pRef); sliderUPP = NewControlActionUPP(InputRateSliderActionProc); arrowsUPP = NewControlActionUPP(LittleArrowsActionProc); cid.signature = 'grap'; cid.id = iNibGFullScreen; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, fullscreen); cid.id = iNibGSwitchResolution; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, autoRes); cid.id = iNibGShowFrameRate; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, Settings.DisplayFrameRate); cid.id = iNibGTransparency; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, Settings.Transparency); cid.id = iNibGGL32bit; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, gl32bit); cid.id = iNibGGLStretch; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, glstretch); cid.id = iNibGVideoMode; HIViewFindByID(root, cid, &ctl); switch (videoMode) { case VIDEOMODE_BLOCKY: SetControl32BitValue(ctl, iOpenGLBlocky); break; case VIDEOMODE_TV: SetControl32BitValue(ctl, iOpenGLTVMode); break; case VIDEOMODE_SMOOTH: SetControl32BitValue(ctl, iOpenGLSmoothMode); break; case VIDEOMODE_BLEND: SetControl32BitValue(ctl, iOpenGLBlendMode); break; case VIDEOMODE_SUPEREAGLE: SetControl32BitValue(ctl, iOpenGLEagleMode); break; case VIDEOMODE_2XSAI: SetControl32BitValue(ctl, iOpenGL2xSAIMode); break; case VIDEOMODE_SUPER2XSAI: SetControl32BitValue(ctl, iOpenGLSuper2xSAIMode); break; case VIDEOMODE_EPX: SetControl32BitValue(ctl, iOpenGLEPXMode); break; case VIDEOMODE_HQ2X: SetControl32BitValue(ctl, iOpenGLHQ2xMode); break; case VIDEOMODE_HQ3X: SetControl32BitValue(ctl, iOpenGLHQ3xMode); break; case VIDEOMODE_HQ4X: SetControl32BitValue(ctl, iOpenGLHQ4xMode); break; case VIDEOMODE_NTSC_C: SetControl32BitValue(ctl, iOpenGLNTSC_CMode); break; case VIDEOMODE_NTSC_S: SetControl32BitValue(ctl, iOpenGLNTSC_SMode); break; case VIDEOMODE_NTSC_R: SetControl32BitValue(ctl, iOpenGLNTSC_RMode); break; case VIDEOMODE_NTSC_M: SetControl32BitValue(ctl, iOpenGLNTSC_MMode); break; case VIDEOMODE_NTSC_TV_C: SetControl32BitValue(ctl, iOpenGLNTSC_TV_CMode); break; case VIDEOMODE_NTSC_TV_S: SetControl32BitValue(ctl, iOpenGLNTSC_TV_SMode); break; case VIDEOMODE_NTSC_TV_R: SetControl32BitValue(ctl, iOpenGLNTSC_TV_RMode); break; case VIDEOMODE_NTSC_TV_M: SetControl32BitValue(ctl, iOpenGLNTSC_TV_MMode); break; } cid.id = iNibGDirectMP; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, multiprocessor); cid.id = iNibGGLVSync; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, vsync); cid.id = iNibGDrawOverscan; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, drawoverscan); cid.id = iNibGScreenCurvature; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, screencurvature); cid.id = iNibGCurvatureWarp; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, macCurvatureWarp); if (!screencurvature) DeactivateControl(ctl); cid.id = iNibGAspectRatio; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, macAspectRatio); if (!glstretch) DeactivateControl(ctl); cid.id = iNibGCIFilterEnable; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, ciFilterEnable); if (systemVersion < 0x1040) DisableControl(ctl); if (systemVersion < 0x1040) { cid.id = iNibGCoreImageFilter; HIViewFindByID(root, cid, &ctl); DisableControl(ctl); } cid.signature = 'snd_'; cid.id = iNibSSynchronize; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, Settings.SoundSync); cid.id = iNibS16BitPlayback; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, Settings.SixteenBitSound); DeactivateControl(ctl); cid.id = iNibSStereo; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, Settings.Stereo); DeactivateControl(ctl); cid.id = iNibSReverseStereo; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, Settings.ReverseStereo); DeactivateControl(ctl); cid.id = iNibSPlaybackRate; HIViewFindByID(root, cid, &ctl); switch (Settings.SoundPlaybackRate) { case 48000: SetControl32BitValue(ctl, 1); break; case 44100: SetControl32BitValue(ctl, 2); break; case 35000: SetControl32BitValue(ctl, 3); break; case 32000: SetControl32BitValue(ctl, 4); break; case 30000: SetControl32BitValue(ctl, 5); break; case 22050: SetControl32BitValue(ctl, 6); break; case 16000: SetControl32BitValue(ctl, 7); break; case 11025: SetControl32BitValue(ctl, 8); break; case 8000: SetControl32BitValue(ctl, 9); break; } cid.id = iNibSInputRate; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, Settings.SoundInputRate); SetControlAction(ctl, sliderUPP); cid.id = iNibSInputRateText; HIViewFindByID(root, cid, &ctl); sprintf(num, "%d", Settings.SoundInputRate); SetStaticTextCStr(ctl, num, false); cid.id = iNibSInterval; HIViewFindByID(root, cid, &ctl); switch (macSoundInterval_ms) { case 8: SetControl32BitValue(ctl, 1); break; case 16: SetControl32BitValue(ctl, 2); break; case 32: SetControl32BitValue(ctl, 3); break; case 64: SetControl32BitValue(ctl, 4); break; case 0: default: SetControl32BitValue(ctl, 6); break; } cid.id = iNibSBufferSize; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, macSoundBuffer_ms / 20); cid.id = iNibSAllowLag; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, macSoundLagEnable); DeactivateControl(ctl); cid.id = iNibSVolume; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, macSoundVolume); cid.signature = 'othe'; cid.id = iNibOSaveFolder; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, saveInROMFolder + 1); err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL); if (saveFolderPath) { CFURLRef url; CFStringRef ref; url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, saveFolderPath, kCFURLPOSIXPathStyle, true); ref = CFURLCopyLastPathComponent(url); err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, ref); CFRelease(ref); CFRelease(url); EnableMenuItem(menu, iNibSaveFolderNameMenuItem); } else { CFStringRef ref; ref = CFCopyLocalizedString(CFSTR("NoneSelected"), "NoneSelected"); err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, ref); CFRelease(ref); DisableMenuItem(menu, iNibSaveFolderNameMenuItem); } cid.id = iNibOAutoSaveInterval; HIViewFindByID(root, cid, &ctl); sprintf(num, "%d", Settings.AutoSaveDelay); SetEditTextCStr(ctl, num, false); cid.signature = 'msc2'; cid.id = iNibMCPUCycles; HIViewFindByID(root, cid, &ctl); sprintf(num, "%" PRIi32, Settings.HDMATimingHack); SetEditTextCStr(ctl, num, false); cid.id = iNibMTurboSkipArrows; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, macFastForwardRate); SetControlAction(ctl, arrowsUPP); cid.id = iNibMTurboSkipText; HIViewFindByID(root, cid, &ctl); sprintf(num, "%d", macFastForwardRate); SetStaticTextCStr(ctl, num, false); cid.id = iNibMFrameSkip; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, macFrameSkip + 2); cid.id = iNibMAllowInvalidVRAMAccess; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, !Settings.BlockInvalidVRAMAccessMaster); cid.id = iNibMAllowSpecificGameHacks; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, !Settings.DisableGameSpecificHacks); cid.signature = 'osx_'; cid.id = iNibXStartOpenDialog; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, startopendlog); cid.id = iNibXShowTimeInFrz; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, showtimeinfrz); cid.id = iNibXMusicBoxMode; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, musicboxmode); cid.id = iNibXEnableToggle; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, enabletoggle); cid.id = iNibXSaveWindowPos; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, savewindowpos); cid.id = iNibXUseIPSPatch; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, !Settings.NoPatch); cid.id = iNibXOnScreenInfo; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, onscreeninfo); cid.id = iNibXInactiveMode; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, inactiveMode); cid.id = iNibXBSXBootup; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, Settings.BSXBootup); MoveWindowPosition(tWindowRef, kWindowPreferences, false); ShowWindow(tWindowRef); err = RunAppModalLoopForWindow(tWindowRef); HideWindow(tWindowRef); SaveWindowPosition(tWindowRef, kWindowPreferences); cid.signature = 'grap'; cid.id = iNibGFullScreen; HIViewFindByID(root, cid, &ctl); fullscreen = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGSwitchResolution; HIViewFindByID(root, cid, &ctl); autoRes = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGShowFrameRate; HIViewFindByID(root, cid, &ctl); Settings.DisplayFrameRate = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGTransparency; HIViewFindByID(root, cid, &ctl); Settings.Transparency = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGGL32bit; HIViewFindByID(root, cid, &ctl); gl32bit = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGGLStretch; HIViewFindByID(root, cid, &ctl); glstretch = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGVideoMode; HIViewFindByID(root, cid, &ctl); switch (GetControl32BitValue(ctl)) { case iOpenGLBlocky: drawingMethod = kDrawingOpenGL; videoMode = VIDEOMODE_BLOCKY; break; case iOpenGLTVMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_TV; break; case iOpenGLSmoothMode: drawingMethod = kDrawingOpenGL; videoMode = VIDEOMODE_SMOOTH; break; case iOpenGLBlendMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_BLEND; break; case iOpenGLEagleMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_SUPEREAGLE; break; case iOpenGL2xSAIMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_2XSAI; break; case iOpenGLSuper2xSAIMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_SUPER2XSAI; break; case iOpenGLEPXMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_EPX; break; case iOpenGLHQ2xMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_HQ2X; break; case iOpenGLHQ3xMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_HQ3X; break; case iOpenGLHQ4xMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_HQ4X; break; case iOpenGLNTSC_CMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_NTSC_C; S9xBlitNTSCFilterSet(&snes_ntsc_composite); break; case iOpenGLNTSC_SMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_NTSC_S; S9xBlitNTSCFilterSet(&snes_ntsc_svideo); break; case iOpenGLNTSC_RMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_NTSC_R; S9xBlitNTSCFilterSet(&snes_ntsc_rgb); break; case iOpenGLNTSC_MMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_NTSC_M; S9xBlitNTSCFilterSet(&snes_ntsc_monochrome); break; case iOpenGLNTSC_TV_CMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_NTSC_TV_C; S9xBlitNTSCFilterSet(&snes_ntsc_composite); break; case iOpenGLNTSC_TV_SMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_NTSC_TV_S; S9xBlitNTSCFilterSet(&snes_ntsc_svideo); break; case iOpenGLNTSC_TV_RMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_NTSC_TV_R; S9xBlitNTSCFilterSet(&snes_ntsc_rgb); break; case iOpenGLNTSC_TV_MMode: drawingMethod = kDrawingBlitGL; videoMode = VIDEOMODE_NTSC_TV_M; S9xBlitNTSCFilterSet(&snes_ntsc_monochrome); break; } cid.id = iNibGDirectMP; HIViewFindByID(root, cid, &ctl); multiprocessor = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGGLVSync; HIViewFindByID(root, cid, &ctl); vsync = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGDrawOverscan; HIViewFindByID(root, cid, &ctl); drawoverscan = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGScreenCurvature; HIViewFindByID(root, cid, &ctl); screencurvature = GetControl32BitValue(ctl) ? true : false; cid.id = iNibGCurvatureWarp; HIViewFindByID(root, cid, &ctl); macCurvatureWarp = GetControl32BitValue(ctl); cid.id = iNibGAspectRatio; HIViewFindByID(root, cid, &ctl); macAspectRatio = GetControl32BitValue(ctl); cid.id = iNibGCIFilterEnable; HIViewFindByID(root, cid, &ctl); ciFilterEnable = GetControl32BitValue(ctl) ? true : false; cid.signature = 'snd_'; cid.id = iNibSSynchronize; HIViewFindByID(root, cid, &ctl); Settings.SoundSync = GetControl32BitValue(ctl) ? true : false; cid.id = iNibS16BitPlayback; HIViewFindByID(root, cid, &ctl); Settings.SixteenBitSound = GetControl32BitValue(ctl) ? true : false; cid.id = iNibSStereo; HIViewFindByID(root, cid, &ctl); Settings.Stereo = GetControl32BitValue(ctl) ? true : false; cid.id = iNibSReverseStereo; HIViewFindByID(root, cid, &ctl); Settings.ReverseStereo = GetControl32BitValue(ctl) ? true : false; cid.id = iNibSPlaybackRate; HIViewFindByID(root, cid, &ctl); switch (GetControl32BitValue(ctl)) { case 1: Settings.SoundPlaybackRate = 48000; break; case 2: Settings.SoundPlaybackRate = 44100; break; case 3: Settings.SoundPlaybackRate = 35000; break; case 4: Settings.SoundPlaybackRate = 32000; break; case 5: Settings.SoundPlaybackRate = 30000; break; case 6: Settings.SoundPlaybackRate = 22050; break; case 7: Settings.SoundPlaybackRate = 16000; break; case 8: Settings.SoundPlaybackRate = 11025; break; case 9: Settings.SoundPlaybackRate = 8000; break; } cid.id = iNibSInputRate; HIViewFindByID(root, cid, &ctl); Settings.SoundInputRate = GetControl32BitValue(ctl); cid.id = iNibSInterval; HIViewFindByID(root, cid, &ctl); switch (GetControl32BitValue(ctl)) { case 1: macSoundInterval_ms = 8; break; case 2: macSoundInterval_ms = 16; break; case 3: macSoundInterval_ms = 32; break; case 4: macSoundInterval_ms = 64; break; case 6: default: macSoundInterval_ms = 0; break; } cid.id = iNibSBufferSize; HIViewFindByID(root, cid, &ctl); macSoundBuffer_ms = GetControl32BitValue(ctl) * 20; cid.id = iNibSAllowLag; HIViewFindByID(root, cid, &ctl); macSoundLagEnable = GetControl32BitValue(ctl); cid.id = iNibSVolume; HIViewFindByID(root, cid, &ctl); macSoundVolume = GetControl32BitValue(ctl); cid.signature = 'othe'; cid.id = iNibOSaveFolder; HIViewFindByID(root, cid, &ctl); saveInROMFolder = GetControl32BitValue(ctl) - 1; cid.id = iNibOAutoSaveInterval; HIViewFindByID(root, cid, &ctl); GetEditTextCStr(ctl, num); Settings.AutoSaveDelay = atoi(num); cid.signature = 'msc2'; cid.id = iNibMCPUCycles; HIViewFindByID(root, cid, &ctl); GetEditTextCStr(ctl, num); Settings.HDMATimingHack = atoi(num); if ((Settings.HDMATimingHack <= 0) || (Settings.HDMATimingHack >= 200)) Settings.HDMATimingHack = 100; cid.id = iNibMTurboSkipArrows; HIViewFindByID(root, cid, &ctl); macFastForwardRate = GetControl32BitValue(ctl); cid.id = iNibMFrameSkip; HIViewFindByID(root, cid, &ctl); macFrameSkip = GetControl32BitValue(ctl) - 2; cid.id = iNibMAllowInvalidVRAMAccess; HIViewFindByID(root, cid, &ctl); Settings.BlockInvalidVRAMAccessMaster = GetControl32BitValue(ctl) ? false : true; cid.id = iNibMAllowSpecificGameHacks; HIViewFindByID(root, cid, &ctl); Settings.DisableGameSpecificHacks = GetControl32BitValue(ctl) ? false : true; cid.signature = 'osx_'; cid.id = iNibXStartOpenDialog; HIViewFindByID(root, cid, &ctl); startopendlog = GetControl32BitValue(ctl) ? true : false; cid.id = iNibXShowTimeInFrz; HIViewFindByID(root, cid, &ctl); showtimeinfrz = GetControl32BitValue(ctl) ? true : false; cid.id = iNibXMusicBoxMode; HIViewFindByID(root, cid, &ctl); musicboxmode = GetControl32BitValue(ctl); cid.id = iNibXEnableToggle; HIViewFindByID(root, cid, &ctl); enabletoggle = GetControl32BitValue(ctl) ? true : false; cid.id = iNibXSaveWindowPos; HIViewFindByID(root, cid, &ctl); savewindowpos = GetControl32BitValue(ctl) ? true : false; cid.id = iNibXUseIPSPatch; HIViewFindByID(root, cid, &ctl); Settings.NoPatch = GetControl32BitValue(ctl) ? false : true; cid.id = iNibXOnScreenInfo; HIViewFindByID(root, cid, &ctl); onscreeninfo = GetControl32BitValue(ctl) ? true : false; cid.id = iNibXInactiveMode; HIViewFindByID(root, cid, &ctl); inactiveMode = GetControl32BitValue(ctl); cid.id = iNibXBSXBootup; HIViewFindByID(root, cid, &ctl); Settings.BSXBootup = GetControl32BitValue(ctl) ? true : false; DisposeControlActionUPP(arrowsUPP); DisposeControlActionUPP(sliderUPP); err = RemoveEventHandler(pRef); DisposeEventHandlerUPP(pUPP); err = RemoveEventHandler(aRef); DisposeEventHandlerUPP(aUPP); err = RemoveEventHandler(iRef); DisposeEventHandlerUPP(iUPP); err = RemoveEventHandler(tRef); DisposeEventHandlerUPP(tUPP); CFRelease(tWindowRef); } DisposeNibReference(nibRef); S9xGraphicsInit(); if (((oldSynchronize != Settings.SoundSync ) || (old16BitPlayback != Settings.SixteenBitSound ) || (oldStereo != Settings.Stereo ) || (oldReverseStereo != Settings.ReverseStereo ) || (oldPlaybackRate != Settings.SoundPlaybackRate) || (oldInputRate != Settings.SoundInputRate ) || (oldInterval != macSoundInterval_ms ) || (oldBufferSize != macSoundBuffer_ms ) || (oldLagEnable != macSoundLagEnable ) || (oldVolume != macSoundVolume )) && cartOpen) SNES9X_InitSound(); if (!fullscreen && cartOpen) { InitGameWindow(); ShowWindow(gWindow); } if (cartOpen) { FSRef ref; err = FSPathMakeRef((unsigned char *) Memory.ROMFilename, &ref, NULL); if (err == noErr) CheckSaveFolder(&ref); } } }
bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString &name) { if ( !wxCheckListBoxBase::Create(parent, id, pos, size, n, choices, style, validator, name) ) return false; m_noItems = 0 ; // this will be increased by our append command m_selected = 0; m_checkBoxWidth = 12; m_checkBoxHeight= 10; long h = m_checkBoxHeight ; #if TARGET_CARBON GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth); GetThemeMetric(kThemeMetricCheckBoxHeight,&h); #endif const wxFont& font = GetFont(); FontInfo finfo; FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo); m_TextBaseLineOffset= finfo.leading+finfo.ascent; m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent; if (m_checkBoxHeight<h) { m_TextBaseLineOffset+= (h-m_checkBoxHeight)/2; m_checkBoxHeight= h; } Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macCheckListDefUPP == NULL ) { macCheckListDefUPP = NewListDefUPP( wxMacCheckListDefinition ); } listDef.u.userProc = macCheckListDefUPP ; #if TARGET_CARBON Size asize; CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, false, true, m_checkBoxHeight+2, 14, false, &listDef, (ControlRef *)&m_macControl ); GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag, sizeof(ListHandle), (Ptr) &m_macList, &asize); SetControlReference( (ControlHandle) m_macControl, (long) this); SetControlVisibility( (ControlHandle) m_macControl, false, false); #else long result ; wxStAppResource resload ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; HLock( (Handle) m_macList ) ; ldefHandle ldef ; ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ; if ( (**(ListHandle)m_macList).listDefProc != NULL ) { (**ldef).instruction = 0x4EF9; /* JMP instruction */ (**ldef).function = (void(*)()) listDef.u.userProc; (**(ListHandle)m_macList).listDefProc = (Handle) ldef ; } Point pt = (**(ListHandle)m_macList).cellSize ; pt.v = 14 ; LCellSize( pt , (ListHandle)m_macList ) ; LAddColumn( 1 , 0 , (ListHandle)m_macList ) ; #endif OptionBits options = 0; if ( style & wxLB_MULTIPLE ) { options += lNoExtend ; } else if ( style & wxLB_EXTENDED ) { options += lExtendDrag ; } else { options = (OptionBits) lOnlyOne ; } SetListSelectionFlags((ListHandle)m_macList, options); MacPostControlCreate() ; for ( int i = 0 ; i < n ; i++ ) { Append( choices[i] ) ; } LSetDrawingMode( true , (ListHandle) m_macList ) ; return TRUE; }
void XControl::GetText(Str255 text) { Size length = sizeof(text) - 1; GetControlData(mControl, 0, kControlEditTextTextTag, length, &text[1], &length); text[0] = length; }
static pascal OSStatus PreferencesEventHandler (EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData) { OSStatus err, result = eventNotHandledErr; WindowRef tWindowRef = (WindowRef) inUserData; switch (GetEventClass(inEvent)) { case kEventClassWindow: { switch (GetEventKind(inEvent)) { case kEventWindowClose: { QuitAppModalLoopForWindow(tWindowRef); result = noErr; break; } } break; } case kEventClassCommand: { switch (GetEventKind(inEvent)) { HICommand tHICommand; case kEventCommandUpdateStatus: { err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand); if (err == noErr && tHICommand.commandID == 'clos') { UpdateMenuCommandStatus(true); result = noErr; } break; } case kEventCommandProcess: { HIViewRef ctl, root; HIViewID cid; SInt32 value; FSRef ref; bool8 r; root = HIViewGetRoot(tWindowRef); err = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(HICommand), NULL, &tHICommand); if (err == noErr) { switch (tHICommand.commandID) { case 'S_EF': { HideWindow(tWindowRef); ConfigureSoundEffects(); ShowWindow(tWindowRef); result = noErr; break; } case 'G_FL': { if (systemVersion >= 0x1040) { HideWindow(tWindowRef); ConfigureCoreImageFilter(); ShowWindow(tWindowRef); } result = noErr; break; } case 'G__7': { cid.signature = 'grap'; cid.id = iNibGGLStretch; HIViewFindByID(root, cid, &ctl); value = GetControl32BitValue(ctl); cid.id = iNibGAspectRatio; HIViewFindByID(root, cid, &ctl); if (value) ActivateControl(ctl); else DeactivateControl(ctl); result = noErr; break; } case 'G_13': { cid.signature = 'grap'; cid.id = iNibGScreenCurvature; HIViewFindByID(root, cid, &ctl); value = GetControl32BitValue(ctl); cid.id = iNibGCurvatureWarp; HIViewFindByID(root, cid, &ctl); if (value) ActivateControl(ctl); else DeactivateControl(ctl); result = noErr; break; } case 'S__3': { cid.signature = 'snd_'; cid.id = iNibSStereo; HIViewFindByID(root, cid, &ctl); value = GetControl32BitValue(ctl); cid.id = iNibSReverseStereo; HIViewFindByID(root, cid, &ctl); if (value) ActivateControl(ctl); else DeactivateControl(ctl); result = noErr; break; } case 'F_FL': { UInt32 modifierkey; err = GetEventParameter(inEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifierkey); if (err == noErr) { if (modifierkey & optionKey) { CFStringRef str; MenuRef menu; str = CFCopyLocalizedString(CFSTR("NoneSelected"), "NoneSelected"); cid.signature = 'othe'; cid.id = iNibOSaveFolder; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, 3); err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL); err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, str); DisableMenuItem(menu, iNibSaveFolderNameMenuItem); HIViewSetNeedsDisplay(ctl, true); CFRelease(str); if (saveFolderPath) CFRelease(saveFolderPath); saveFolderPath = NULL; } else r = NavBeginChooseFolderSheet(tWindowRef); } result = noErr; break; } case 'NvDn': { r = NavEndChooseFolderSheet(&ref); if (r) { CFStringRef str; CFURLRef url; MenuRef menu; url = CFURLCreateFromFSRef(kCFAllocatorDefault, &ref); str = CFURLCopyLastPathComponent(url); cid.signature = 'othe'; cid.id = iNibOSaveFolder; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, iNibSaveFolderNameMenuItem); err = GetControlData(ctl, kControlMenuPart, kControlPopupButtonMenuRefTag, sizeof(MenuRef), &menu, NULL); err = SetMenuItemTextWithCFString(menu, iNibSaveFolderNameMenuItem, str); EnableMenuItem(menu, iNibSaveFolderNameMenuItem); HIViewSetNeedsDisplay(ctl, true); CFRelease(str); str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); if (saveFolderPath) CFRelease(saveFolderPath); saveFolderPath = str; CFRelease(url); } result = noErr; break; } } } break; } } break; } } return (result); }
bool wxListBox::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], long style, const wxValidator& validator, const wxString& name) { if ( !wxListBoxBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) ) return false; m_noItems = 0 ; // this will be increased by our append command m_selected = 0; Rect bounds ; Str255 title ; MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ; ListDefSpec listDef; listDef.defType = kListDefUserProcType; if ( macListDefUPP == NULL ) { macListDefUPP = NewListDefUPP( wxMacListDefinition ); } listDef.u.userProc = macListDefUPP ; Str255 fontName ; SInt16 fontSize ; Style fontStyle ; #if TARGET_CARBON GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ; #else GetFontName( kFontIDMonaco , fontName ) ; fontSize = 9 ; fontStyle = normal ; #endif SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) ) ) ; #if TARGET_CARBON Size asize; CreateListBoxControl( MAC_WXHWND(parent->MacGetRootWindow()), &bounds, false, 0, 1, (style & wxLB_HSCROLL), true, kwxMacListItemHeight, kwxMacListItemHeight, false, &listDef, (ControlRef *)&m_macControl ); GetControlData( (ControlHandle) m_macControl, kControlNoPart, kControlListBoxListHandleTag, sizeof(ListHandle), (Ptr) &m_macList, &asize); SetControlReference( (ControlHandle) m_macControl, (long) this); SetControlVisibility( (ControlHandle) m_macControl, false, false); #else long result ; wxStAppResource resload ; m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , (style & wxLB_HSCROLL) ? kwxMacListWithVerticalAndHorizontalScrollbar : kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; HLock( (Handle) m_macList ) ; ldefHandle ldef ; ldef = (ldefHandle) NewHandle( sizeof(ldefRec) ) ; if ( (**(ListHandle)m_macList).listDefProc != NULL ) { (**ldef).instruction = 0x4EF9; /* JMP instruction */ (**ldef).function = (void(*)()) listDef.u.userProc; (**(ListHandle)m_macList).listDefProc = (Handle) ldef ; } Point pt = (**(ListHandle)m_macList).cellSize ; pt.v = kwxMacListItemHeight ; LCellSize( pt , (ListHandle)m_macList ) ; LAddColumn( 1 , 0 , (ListHandle)m_macList ) ; #endif OptionBits options = 0; if ( style & wxLB_MULTIPLE ) { options += lExtendDrag + lUseSense ; } else if ( style & wxLB_EXTENDED ) { // default behaviour } else { options = (OptionBits) lOnlyOne ; } SetListSelectionFlags((ListHandle)m_macList, options); for ( int i = 0 ; i < n ; i++ ) { Append( choices[i] ) ; } MacPostControlCreate() ; LSetDrawingMode( true , (ListHandle)m_macList ) ; return true; }
pascal OSStatus IGraphicsCarbon::TextEntryHandler(EventHandlerCallRef pHandlerCall, EventRef pEvent, void* pGraphicsCarbon) { IGraphicsCarbon* _this = (IGraphicsCarbon*) pGraphicsCarbon; UInt32 eventClass = GetEventClass(pEvent); UInt32 eventKind = GetEventKind(pEvent); switch (eventClass) { case kEventClassKeyboard: { switch (eventKind) { case kEventRawKeyDown: case kEventRawKeyRepeat: { char c; GetEventParameter(pEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(c), NULL, &c); UInt32 k; GetEventParameter(pEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &k); // trap enter key if (c == 3 || c == 13) { _this->EndUserInput(true); return noErr; } // pass arrow keys if (k == 125 || k == 126 || k == 123 || k == 124) break; // pass delete keys if (c == 8 || c == 127) break; if (_this->mEdParam) { switch ( _this->mEdParam->Type() ) { case IParam::kTypeEnum: case IParam::kTypeInt: case IParam::kTypeBool: if (c >= '0' && c <= '9') break; else if (c == '-') break; else if (c == '+') break; else return noErr; case IParam::kTypeDouble: if (c >= '0' && c <= '9') break; else if (c == '.') break; else if (c == '-') break; else if (c == '+') break; else return noErr; default: break; } } // check the length of the text Str31 theText; Size textLength; GetControlData(_this->mTextEntryView, kControlNoPart, kControlEditTextTextTag, sizeof(theText) -1, (Ptr) &theText[1], &textLength); if(textLength >= _this->mEdControl->GetTextEntryLength()) return noErr; break; } } break; } } return eventNotHandledErr; }
/*=========================================================================== * * Class CSrLvlEditDlg Event - void OnOK (); * *=========================================================================*/ void CSrLvlEditDlg::OnOK() { GetControlData(); CDialog::OnOK(); }
void CSrNewScriptPropertyDlg::OnOK (void) { GetControlData(); CDialogEx::OnOK(); }
/*=========================================================================== * * Class CSrBodyPartsDlg Event - void OnOK (void); * *=========================================================================*/ void CSrBodyPartsDlg::OnOK (void) { GetControlData(); CDialog::OnOK(); }
/***************************************************** * * Handle_WindowCommandProcess(inHandlerCallRef, inEvent, inUserData) * * Purpose: called to handle of the events generated by the various controls of the HICustomView_Tester window * * Inputs: inHandlerCallRef - reference to the current handler call chain * inEvent - the event * inUserData - app-specified data you passed in the call to InstallEventHandler * * Returns: OSStatus - noErr indicates the event was handled * eventNotHandledErr indicates the event was not handled and the Toolbox should take over */ static pascal OSStatus Handle_WindowCommandProcess(EventHandlerCallRef inHandlerCallRef, EventRef inEvent, void *inUserData) { OSStatus status; HIViewRef customView = (HIViewRef)inUserData; // getting the command HICommandExtended aCommand; status = GetEventParameter(inEvent, kEventParamDirectObject, typeHICommand, NULL, sizeof(aCommand), NULL, &aCommand); require_noerr(status, ExitCommandProcess); status = eventNotHandledErr; // cheking that the command came from a control if ( ! (aCommand.attributes & kHICommandFromControl) ) goto ExitCommandProcess; switch (aCommand.commandID) { // // Asking for a refresh of the custom view // case 'SNDt': HIViewSetNeedsDisplay(customView, true); status = noErr; break; // // Setting the control value of the custom view // case 'SV00': SetControl32BitValue(customView, 0); status = noErr; break; case 'SV01': SetControl32BitValue(customView, 1); status = noErr; break; case 'SV17': SetControl32BitValue(customView, 17); status = noErr; break; case 'SVTH': SetControl32BitValue(customView, 1000); status = noErr; break; case 'SVet': { HIViewRef editText; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kSetValueEditID, &editText); char buffer[11]; Size actualSize; GetControlData(editText, kControlEntireControl, kControlEditTextTextTag, 10, buffer, &actualSize); if (actualSize > 10) actualSize = 10; buffer[actualSize] = 0; SetControl32BitValue(customView, atoi(buffer)); } status = noErr; break; // // Setting the state of the custom view // case 'CHlt': // setting the hilite to non-0 also stomps the previous hilite state if any // and we don't want that in our testing if (GetControl32BitValue(aCommand.source.control) == 1) HiliteControl(customView, 1); else HiliteControl(customView, 0); status = noErr; break; case 'CEnb': { HIViewRef hiliteControl; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckHiliteID, &hiliteControl); if (GetControl32BitValue(aCommand.source.control) == 1) EnableControl(customView); else DisableControl(customView); UInt16 prevHilite = GetControlHilite(customView); if ((prevHilite == kControlInactivePart) || (prevHilite == kControlDisabledPart)) DisableControl(hiliteControl); else EnableControl(hiliteControl); HIViewSetNeedsDisplay(customView, true); } status = noErr; break; case 'CAct': { HIViewRef hiliteControl; HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckHiliteID, &hiliteControl); if (GetControl32BitValue(aCommand.source.control) == 1) ActivateControl(customView); else DeactivateControl(customView); UInt16 prevHilite = GetControlHilite(customView); if ((prevHilite == kControlInactivePart) || (prevHilite == kControlDisabledPart)) DisableControl(hiliteControl); else EnableControl(hiliteControl); HIViewSetNeedsDisplay(customView, true); } status = noErr; break; // // Testing the custom view in or as a scroller in a HIScrollView // case 'CTiS': case 'CTaS': if (GetControl32BitValue(aCommand.source.control) == 1) { // create a HIScrollView and install it where and as the custom view was HIViewRef scrollView; status = HIScrollViewCreate(kHIScrollViewValidOptions, &scrollView); require_noerr(status, ExitCommandProcess); HIRect frame; status = HIViewGetFrame(customView, &frame); require_noerr(status, ExitCommandProcess); status = HIViewSetFrame(scrollView, &frame); require_noerr(status, ExitCommandProcess); HIViewSetLayoutInfo(scrollView, &kBindToParentLayout); HIViewSetLayoutInfo(customView, &kNoBindLayout); status = HIViewAddSubview(HIViewGetSuperview(customView), scrollView); require_noerr(status, ExitCommandProcess); if (aCommand.commandID == 'CTiS') { // if we are testing the custom view in a scroller, we embed it in a scrolling User Pane // that we embed in the HIScrollView Rect boundsRect = {0, 0, 1000, 1000}; HIViewRef userPane; status = CreateUserPaneControl(NULL, &boundsRect, kControlSupportsEmbedding, &userPane); require_noerr(status, ExitCommandProcess); EventTypeSpec userPaneEvents[] = { {kEventClassScrollable, kEventScrollableGetInfo}, {kEventClassScrollable, kEventScrollableScrollTo} }; InstallControlEventHandler(userPane, UserPaneHandler, 2, userPaneEvents, userPane, NULL); status = HIViewAddSubview(scrollView, userPane); require_noerr(status, ExitCommandProcess); status = HIViewAddSubview(userPane, customView); require_noerr(status, ExitCommandProcess); HIViewSetVisible(userPane, true); } else { // else we just embed the custom view directly in the HIScrollView status = HIViewAddSubview(scrollView, customView); require_noerr(status, ExitCommandProcess); } HIViewSetVisible(scrollView, true); // the 2 modes are not compatible so we disable the other check box HIViewRef otherCheckToDisable; if (aCommand.commandID == 'CTiS') HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestAsScrollID, &otherCheckToDisable); else HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestInScrollID, &otherCheckToDisable); require_noerr(status, ExitCommandProcess); DisableControl(otherCheckToDisable); // if we reach here, status is already set to noErr so we don't set it again } else { // we remove the HIScrollView and set the custom view back to where and as it was HIViewRef scrollView; if (aCommand.commandID == 'CTiS') scrollView = HIViewGetSuperview(HIViewGetSuperview(customView)); else scrollView = HIViewGetSuperview(customView); status = HIViewAddSubview(HIViewGetSuperview(scrollView), customView); require_noerr(status, ExitCommandProcess); HIRect frame; status = HIViewGetFrame(scrollView, &frame); require_noerr(status, ExitCommandProcess); status = HIViewSetFrame(customView, &frame); require_noerr(status, ExitCommandProcess); HIViewSetLayoutInfo(customView, &kBindToParentLayout); // by releasing the HIScrollView, we also release the scrolling User Pane if any // which was embedded inside CFRelease(scrollView); // we renable the other check box HIViewRef otherCheckToEnable; if (aCommand.commandID == 'CTiS') HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestAsScrollID, &otherCheckToEnable); else HIViewFindByID(HIViewGetRoot(GetControlOwner(customView)), kCheckTestInScrollID, &otherCheckToEnable); require_noerr(status, ExitCommandProcess); EnableControl(otherCheckToEnable); // if we reach here, status is already set to noErr so we don't set it again } break; } ExitCommandProcess: return status; } // Handle_WindowCommandProcess
bool CSrScriptView::SaveCurrentScript (void) { GetControlData(); return SaveScript(m_pCurrentScript); }