TkScrollbar * TkpCreateScrollbar( Tk_Window tkwin) /* New Tk Window. */ { static int initialized = 0; MacScrollbar * macScrollPtr; TkWindow *winPtr = (TkWindow *)tkwin; if (scrollActionProc == NULL) { scrollActionProc = NewControlActionUPP(ScrollbarActionProc); thumbActionProc = NewControlActionUPP(ThumbActionProc); } if (!initialized) { TkMacOSXInitScrollbarMetrics(); initialized = 1; } macScrollPtr = (MacScrollbar *) ckalloc(sizeof(MacScrollbar)); macScrollPtr->sbHandle = NULL; macScrollPtr->macFlags = 0; SetRect(&macScrollPtr->eraseRect, 0, 0, 0, 0); Tk_CreateEventHandler(tkwin, ActivateMask|ExposureMask| StructureNotifyMask|FocusChangeMask, ScrollbarEventProc, (ClientData) macScrollPtr); if (!Tcl_GetAssocData(winPtr->mainPtr->interp, "TkScrollbar", NULL)) { Tcl_SetAssocData(winPtr->mainPtr->interp, "TkScrollbar", NULL, (ClientData)1); TkCreateBindingProcedure(winPtr->mainPtr->interp, winPtr->mainPtr->bindingTable, (ClientData)Tk_GetUid("Scrollbar"), "<ButtonPress>", ScrollbarBindProc, NULL, NULL); } return (TkScrollbar *) macScrollPtr; }
void shellinitscroll(void) { //Code change by Timothy Paustian Saturday, July 22, 2000 12:04:35 AM //Needed in shellscroll #if TARGET_API_MAC_CARBON #if TARGET_RT_MAC_CFM shellvertscrollDesc = NewControlActionUPP(shellvertscroll); shellhorizscrollDesc = NewControlActionUPP(shellhorizscroll); shelllivescrollupp = NewControlActionUPP (ScrollThumbActionProc); #endif #endif }
int main(int argc, char* argv[]) { IBNibRef nibRef; OSStatus err; InitCursor(); // check the correct BASS was loaded if (HIWORD(BASS_GetVersion())!=BASSVERSION) { Error("An incorrect version of BASS.DLL was loaded (2.4 is required)"); return 0; } // check the correct BASS_FX was loaded if (HIWORD(BASS_FX_GetVersion())!=BASSVERSION) { Error("An incorrect version of BASS_FX.DLL was loaded (2.4 is required)"); return 0; } // initialize default output device if(!BASS_Init(-1,44100,0,NULL,NULL)) { Error("Can't initialize device"); return 0; } // Create Window and Stuff err = CreateNibReference(CFSTR("reverse"), &nibRef); if (err) return err; err = CreateWindowFromNib(nibRef, CFSTR("MainWindow"), &win); if (err) return err; DisposeNibReference(nibRef); SetupControlHandler(10,kEventControlHit,OpenEventHandler); SetControlAction(GetControl(11),NewControlActionUPP(VolEventHandler)); SetControlAction(GetControl(13),NewControlActionUPP(TempoEventHandler)); SetControlAction(GetControl(15),NewControlActionUPP(PosEventHandler)); SetupControlHandler(16,kEventControlHit,DirEventHandler); EventLoopTimerRef timer; InstallEventLoopTimer(GetCurrentEventLoop(),kEventDurationNoWait,kEventDurationSecond/2,TimerProc,0,&timer); // The window was created hidden so show it. ShowWindow(win); // Call the event loop RunApplicationEventLoop(); // Close output BASS_Free(); return 0; }
TActiveScroller::TActiveScroller(ControlHandle scrollBar) { disabled=false; this->scrollBar=scrollBar; wasScrollHilight=kControlInactivePart; // make the tracking proc scrollBarProcUPP=NewControlActionUPP(TrackingProc); if (!scrollBarProcUPP) Throw_(memFullErr); AdjustToControlSize(); }
TkScale * TkpCreateScale( Tk_Window tkwin) { MacScale *macScalePtr = (MacScale *) ckalloc(sizeof(MacScale)); macScalePtr->scaleHandle = NULL; if (scaleActionProc == NULL) { scaleActionProc = NewControlActionUPP(ScaleActionProc); } Tk_CreateEventHandler(tkwin, ButtonPressMask, MacScaleEventProc, (ClientData) macScalePtr); return (TkScale *) macScalePtr; }
wxControl::wxControl() { m_macControl = NULL ; m_macControlAction = NULL ; m_macHorizontalBorder = 0 ; // additional pixels around the real control m_macVerticalBorder = 0 ; m_backgroundColour = *wxWHITE; m_foregroundColour = *wxBLACK; if ( wxMacLiveScrollbarActionUPP == NULL ) { #if defined(UNIVERSAL_INTERFACES_VERSION) && (UNIVERSAL_INTERFACES_VERSION >= 0x0340) wxMacLiveScrollbarActionUPP = NewControlActionUPP( wxMacLiveScrollbarActionProc ); #else wxMacLiveScrollbarActionUPP = NewControlActionProc( wxMacLiveScrollbarActionProc ) ; #endif } }
// Associate a tracking procedure UPP with each of a scroll control. OSStatus ControlRegisterActionProc( WindowRef window, ControlRef scrollControl, TXNScrollBarOrientation orientation ) { OSStatus status = noErr; SInt32 max = 200; require( IsValidControlHandle( scrollControl ), BadControl ); // Create the callback if( gControlActionUPP == NULL ) gControlActionUPP = NewControlActionUPP( MyTrackActionProcedure ); require( gControlActionUPP != NULL, NullControlActionUPP ); // Associate the callback with the control SetControlAction( scrollControl, gControlActionUPP ); // set the max value of the control based on the height of the text // in the text view if( orientation = kTXNVertical ) { SInt32 height = (SInt32)TextViewGetTextHeight( window, kMyMLTEDataStructProperty ); max = ( height <= kMyINT32_MAX ? height : kMyINT32_MAX ); } else { SInt32 width = (SInt32)TextViewGetTextWidth( window, kMyMLTEDataStructProperty ); max = ( width <= kMyINT32_MAX ? width : kMyINT32_MAX ); } SetControl32BitMaximum( scrollControl, max ); BadControl: NullControlActionUPP: return status; }
CV_IMPL int cvCreateTrackbar (const char* trackbar_name, const char* window_name,int* val, int count, CvTrackbarCallback on_notify) { int result = 0; CV_FUNCNAME( "cvCreateTrackbar" ); __BEGIN__; /*char slider_name[32];*/ CvWindow* window = 0; CvTrackbar* trackbar = 0; Rect stboundsRect; ControlRef outControl; ControlRef stoutControl; Rect bounds; if( !window_name || !trackbar_name ) CV_ERROR( CV_StsNullPtr, "NULL window or trackbar name" ); if( count <= 0 ) CV_ERROR( CV_StsOutOfRange, "Bad trackbar maximal value" ); window = icvFindWindowByName(window_name); if( !window ) EXIT; trackbar = icvFindTrackbarByName(window,trackbar_name); if( !trackbar ) { int len = strlen(trackbar_name); trackbar = (CvTrackbar*)cvAlloc(sizeof(CvTrackbar) + len + 1); memset( trackbar, 0, sizeof(*trackbar)); trackbar->signature = CV_TRACKBAR_MAGIC_VAL; trackbar->name = (char*)(trackbar+1); memcpy( trackbar->name, trackbar_name, len + 1 ); trackbar->parent = window; trackbar->next = window->toolbar.first; window->toolbar.first = trackbar; if( val ) { int value = *val; if( value < 0 ) value = 0; if( value > count ) value = count; trackbar->pos = value; trackbar->data = val; } trackbar->maxval = count; trackbar->notify = on_notify; int c = icvCountTrackbarInWindow(window); GetWindowBounds(window->window,kWindowContentRgn,&bounds); stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE; stboundsRect.left = INTERWIDGETSPACE; stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT; stboundsRect.right = stboundsRect.left+LABELWIDTH; fprintf(stdout,"create trackabar bounds (%d %d %d %d)\n",stboundsRect.top,stboundsRect.left,stboundsRect.bottom,stboundsRect.right); CreateStaticTextControl (window->window,&stboundsRect,CFStringCreateWithCString(NULL,trackbar_name,kCFStringEncodingASCII),NULL,&stoutControl); stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE; stboundsRect.left = INTERWIDGETSPACE*2+LABELWIDTH; stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT; stboundsRect.right = bounds.right-INTERWIDGETSPACE; CreateSliderControl (window->window,&stboundsRect, trackbar->pos,0,trackbar->maxval,kControlSliderLiveFeedback,0,true,NewControlActionUPP(TrackbarActionProcPtr),&outControl); bounds.bottom += INTERWIDGETSPACE + WIDGETHEIGHT; SetControlVisibility (outControl,true,true); SetControlVisibility (stoutControl,true,true); trackbar->trackbar = outControl; trackbar->label = stoutControl; if (c == 1) window->trackbarheight = INTERWIDGETSPACE*2 + WIDGETHEIGHT; else window->trackbarheight += INTERWIDGETSPACE + WIDGETHEIGHT; icvUpdateWindowSize( window ); } __END__; return result; }
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); } } }
int main(int argc, char* argv[]) { IBNibRef nibRef; OSStatus err; glob_t g; // check the correct BASS was loaded if (HIWORD(BASS_GetVersion())!=BASSVERSION) { Error("An incorrect version of BASS was loaded"); return 0; } // initialize default output device if (!BASS_Init(-1,44100,0,NULL,NULL)) { Error("Can't initialize device"); return 0; } // Create Window and stuff err = CreateNibReference(CFSTR("plugins"), &nibRef); if (err) return err; err = CreateWindowFromNib(nibRef, CFSTR("Window"), &win); if (err) return err; DisposeNibReference(nibRef); DataBrowserCallbacks dbc; dbc.version=kDataBrowserLatestCallbacks; InitDataBrowserCallbacks(&dbc); dbc.u.v1.itemDataCallback=MyDataBrowserItemDataCallback; ControlRef list=GetControl(20); SetDataBrowserCallbacks(list,&dbc); { // look for plugins (in the executable directory) char path[300]; DWORD l=sizeof(path); _NSGetExecutablePath(path,&l); strcpy(strrchr(path,'/')+1,"libbass*.dylib"); if (!glob(path,0,0,&g)) { int a; for (a=0;a<g.gl_pathc;a++) { if (BASS_PluginLoad(g.gl_pathv[a],0)) { // plugin loaded, add it to the list... char *p=strrchr(g.gl_pathv[a],'/')+1; AddDataBrowserItems(list,kDataBrowserNoItem,1,(DataBrowserItemID*)&p,kDataBrowserItemNoProperty); } } } DWORD c; GetDataBrowserItemCount(list,kDataBrowserNoItem,FALSE,kDataBrowserItemNoState,(DataBrowserItemState*)&c); if (!c) { // no plugins... static const char *noplugins="no plugins - visit the BASS webpage to get some"; AddDataBrowserItems(list,kDataBrowserNoItem,1,(DataBrowserItemID*)&noplugins,kDataBrowserItemNoProperty); } } SetupControlHandler(10,kEventControlHit,OpenEventHandler); SetControlAction(GetControl(12),NewControlActionUPP(PosEventHandler)); EventLoopTimerRef timer; InstallEventLoopTimer(GetCurrentEventLoop(),kEventDurationNoWait,kEventDurationSecond/2,NewEventLoopTimerUPP(TimerProc),0,&timer); ShowWindow(win); RunApplicationEventLoop(); globfree(&g); // "free" the output device and all plugins BASS_Free(); BASS_PluginFree(0); return 0; }
void ConfigureAutofire (void) { OSStatus err; IBNibRef nibRef; err = CreateNibReference(kMacS9XCFString, &nibRef); if (err == noErr) { WindowRef tWindowRef; err = CreateWindowFromNib(nibRef, CFSTR("AutoFire"), &tWindowRef); if (err == noErr) { EventHandlerRef wRef, tRef; EventHandlerUPP wUPP, tUPP; EventTypeSpec wEvent[] = { { kEventClassWindow, kEventWindowClose }, { kEventClassCommand, kEventCommandProcess }, { kEventClassCommand, kEventCommandUpdateStatus } }, tEvent[] = { { kEventClassControl, kEventControlHit } }; ControlActionUPP actionUPP; HIViewRef ctl, root; HIViewID cid; root = HIViewGetRoot(tWindowRef); wUPP = NewEventHandlerUPP(AutofireWindowEventHandler); err = InstallWindowEventHandler(tWindowRef, wUPP, GetEventTypeCount(wEvent), wEvent, (void *) tWindowRef, &wRef); cid.signature = 'Ftab'; cid.id = 256; HIViewFindByID(root, cid, &ctl); SetControl32BitValue(ctl, autofireLastTabIndex); AutofireSelectTabPane(ctl, autofireLastTabIndex); tUPP = NewEventHandlerUPP(AutofireTabEventHandler); err = InstallControlEventHandler(ctl, tUPP, GetEventTypeCount(tEvent), tEvent, 0, &tRef); actionUPP = NewControlActionUPP(AutofireSliderActionProc); for (int player = 0; player < 2; player++) { AutofireSetAllIconImages(player + 1, root); AutofireReadAllSettings(player + 1, root); cid.id = player + 1; cid.signature = 'Slid'; HIViewFindByID(root, cid, &ctl); SetControlAction(ctl, actionUPP); } MoveWindowPosition(tWindowRef, kWindowAutoFire, false); ShowWindow(tWindowRef); err = RunAppModalLoopForWindow(tWindowRef); HideWindow(tWindowRef); SaveWindowPosition(tWindowRef, kWindowAutoFire); for (int player = 0; player < 2; player++) AutofireWriteAllSettings(player + 1, root); autofire = (autofireRec[0].buttonMask || autofireRec[1].buttonMask) ? true : false; err = RemoveEventHandler(tRef); DisposeEventHandlerUPP(tUPP); err = RemoveEventHandler(wRef); DisposeEventHandlerUPP(wUPP); DisposeControlActionUPP(actionUPP); CFRelease(tWindowRef); } DisposeNibReference(nibRef); } }
static int icvCreateTrackbar (const char* trackbar_name, const char* window_name, int* val, int count, CvTrackbarCallback on_notify, CvTrackbarCallback2 on_notify2, void* userdata) { int result = 0; CV_FUNCNAME( "icvCreateTrackbar" ); __BEGIN__; /*char slider_name[32];*/ CvWindow* window = 0; CvTrackbar* trackbar = 0; Rect stboundsRect; ControlRef outControl; ControlRef stoutControl; Rect bounds; if( !window_name || !trackbar_name ) CV_ERROR( CV_StsNullPtr, "NULL window or trackbar name" ); if( count <= 0 ) CV_ERROR( CV_StsOutOfRange, "Bad trackbar maximal value" ); window = icvFindWindowByName(window_name); if( !window ) EXIT; trackbar = icvFindTrackbarByName(window,trackbar_name); if( !trackbar ) { int len = strlen(trackbar_name); trackbar = (CvTrackbar*)cvAlloc(sizeof(CvTrackbar) + len + 1); memset( trackbar, 0, sizeof(*trackbar)); trackbar->signature = CV_TRACKBAR_MAGIC_VAL; trackbar->name = (char*)(trackbar+1); memcpy( trackbar->name, trackbar_name, len + 1 ); trackbar->parent = window; trackbar->next = window->toolbar.first; window->toolbar.first = trackbar; if( val ) { int value = *val; if( value < 0 ) value = 0; if( value > count ) value = count; trackbar->pos = value; trackbar->data = val; } trackbar->maxval = count; //----------- YV ---------------------- //get nb of digits int nbDigit = 0; while((count/=10)>10){ nbDigit++; } //pad size maxvalue in pixel Point qdSize; char valueinchar[strlen(trackbar_name)+1 +1 +1+nbDigit+1];//length+\n +space +(+nbDigit+) sprintf(valueinchar, "%s (%d)",trackbar_name, trackbar->maxval); SInt16 baseline; CFStringRef text = CFStringCreateWithCString(NULL,valueinchar,kCFStringEncodingASCII); GetThemeTextDimensions( text, kThemeCurrentPortFont, kThemeStateActive, false, &qdSize, &baseline ); trackbar->labelSize = qdSize.h; //-------------------------------------- int c = icvCountTrackbarInWindow(window); GetWindowBounds(window->window,kWindowContentRgn,&bounds); stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE; stboundsRect.left = INTERWIDGETSPACE; stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT; stboundsRect.right = stboundsRect.left+LABELWIDTH; //fprintf(stdout,"create trackabar bounds (%d %d %d %d)\n",stboundsRect.top,stboundsRect.left,stboundsRect.bottom,stboundsRect.right); //----------- YV ---------------------- sprintf(valueinchar, "%s (%d)",trackbar_name, trackbar->pos); CreateStaticTextControl (window->window,&stboundsRect,CFStringCreateWithCString(NULL,valueinchar,kCFStringEncodingASCII),NULL,&stoutControl); //-------------------------------------- stboundsRect.top = (INTERWIDGETSPACE +WIDGETHEIGHT)* (c-1)+INTERWIDGETSPACE; stboundsRect.left = INTERWIDGETSPACE*2+LABELWIDTH; stboundsRect.bottom = stboundsRect.top + WIDGETHEIGHT; stboundsRect.right = bounds.right-INTERWIDGETSPACE; CreateSliderControl (window->window,&stboundsRect, trackbar->pos,0,trackbar->maxval,kControlSliderLiveFeedback,0,true,NewControlActionUPP(TrackbarActionProcPtr),&outControl); bounds.bottom += INTERWIDGETSPACE + WIDGETHEIGHT; SetControlVisibility (outControl,true,true); SetControlVisibility (stoutControl,true,true); trackbar->trackbar = outControl; trackbar->label = stoutControl; if (c == 1) window->trackbarheight = INTERWIDGETSPACE*2 + WIDGETHEIGHT; else window->trackbarheight += INTERWIDGETSPACE + WIDGETHEIGHT; icvUpdateWindowSize( window ); } trackbar->notify = on_notify; trackbar->notify2 = on_notify2; trackbar->userdata = userdata; result = 1; __END__; return result; }
void InLicenseContent(EventRecord* evt, WindowPtr wCurrPtr) { Point localPt; Rect r; ControlPartCode part; short code, value; ControlHandle scrollBar; ControlActionUPP scrollActionFunctionUPP; GrafPtr oldPort; GetPort(&oldPort); SetPort(gWPtr); localPt = evt->where; GlobalToLocal( &localPt); code = FindControl(localPt, wCurrPtr, &scrollBar); switch (code) { case kControlUpButtonPart: case kControlDownButtonPart: case kControlPageUpPart: case kControlPageDownPart: scrollActionFunctionUPP = NewControlActionUPP(DoScrollProc); value = TrackControl(scrollBar, localPt, scrollActionFunctionUPP); return; case kControlIndicatorPart: value = GetControlValue(scrollBar); code = TrackControl(scrollBar, localPt, nil); if (code) { value -= GetControlValue(scrollBar); if (value) { TEScroll(0, value * kScrollAmount, gControls->lw->licTxt); ShowTxt(); } } return; } HLock((Handle)gControls->backB); r = (**(gControls->backB)).contrlRect; HUnlock((Handle)gControls->backB); if (PtInRect( localPt, &r)) { part = TrackControl(gControls->backB, evt->where, NULL); if (part) gDone = true; /* Decline pressed */ } HLock((Handle)gControls->nextB); r = (**(gControls->nextB)).contrlRect; HUnlock((Handle)gControls->nextB); if (PtInRect( localPt, &r)) { part = TrackControl(gControls->nextB, evt->where, NULL); if (part) { KillControls(gWPtr); ShowSetupTypeWin(); return; } } ShowTxt(); // TO DO SetPort(oldPort); }
void main(void) { int code; int exit_code; int argc; char **argv; char dformat[64], ddevice[32]; SInt32 response; /* Initialize operating environment */ #if TARGET_API_MAC_CARBON MoreMasterPointers(224); #else MoreMasters(); #endif InitCursor(); FlushEvents(everyEvent,0); if (AEInstallEventHandler(kCoreEventClass,kAEQuitApplication, NewAEEventHandlerUPP((AEEventHandlerProcPtr) quitAppEventHandler), 0L,false) != noErr) ExitToShell(); gActionFunctionScrollUPP = NewControlActionUPP(&actionFunctionScroll); Gestalt(gestaltMenuMgrAttr,&response); if(response & gestaltMenuMgrAquaLayoutMask) gRunningOnX = true; /* Initialize SIOUX */ SIOUXSettings.initializeTB = false; SIOUXSettings.standalone = false; SIOUXSettings.asktosaveonclose = false; SIOUXSettings.sleep = GetCaretTime(); SIOUXSettings.userwindowtitle = "\pGhostscript"; /* Get arguments from user */ argc = ccommand(&argv); /* Show command line window */ if (InstallConsole(0)) ExitToShell(); /* Part of fudge to make SIOUX accept characters without becoming modal */ SelectWindow(SIOUXTextWindow->window); PostEvent(keyDown, 0x4c00); // Enter ReadCharsFromConsole(dformat, 0x7FFF); clrscr(); /* Add in the display format as the first command line argument */ if (argc >= MAX_ARGS - 1) { printf("Too many command line arguments\n"); return; } memmove(&argv[3], &argv[1], (argc-1) * sizeof(char**)); argc += 2; argv[1] = ddevice; argv[2] = dformat; gs_sprintf(ddevice, "-sDEVICE=display"); gs_sprintf(dformat, "-dDisplayFormat=%d", display_format); /* Run Ghostscript */ if (gsapi_new_instance(&instance, NULL) < 0) { printf("Can't create Ghostscript instance\n"); return; } #ifdef DEBUG visual_tracer_init(); set_visual_tracer(&visual_tracer); #endif gsapi_set_stdio(instance, gsdll_stdin, gsdll_stdout, gsdll_stderr); gsapi_set_poll(instance, gsdll_poll); gsapi_set_display_callback(instance, &display); code = gsapi_init_with_args(instance, argc, argv); if (code == 0) code = gsapi_run_string(instance, start_string, 0, &exit_code); else { printf("Failed to initialize. Error %d.\n", code); fflush(stdout); } code = gsapi_exit(instance); if (code != 0) { printf("Failed to terminate. Error %d.\n", code); fflush(stdout); } gsapi_delete_instance(instance); #ifdef DEBUG visual_tracer_close(); #endif /* Ghostscript has finished - let user see output before quitting */ WriteCharsToConsole("\r[Finished - hit any key to quit]", 33); fflush(stdout); /* Process events until a key is hit or user quits from menu */ while(!gDone) { EventRecord eventStructure; if(WaitNextEvent(everyEvent,&eventStructure,SIOUXSettings.sleep,NULL)) { if (eventStructure.what == keyDown) gDone = true; doEvents(&eventStructure); } else SIOUXHandleOneEvent(&eventStructure); } }
bool loadPlayerWin(bool bInitMetal) { ControlID cID; ControlRef cRef, cRef2; IBNibRef nibFile; OSStatus iResult; EventTypeSpec pEvent; g_lpfnVolumeProc = NewControlActionUPP(playerVolHandler); g_lpfnPlayerProc = NewEventHandlerUPP(playerEvtHandler); if (noErr != (iResult = CreateNibReference(CFSTR("PlayerWin"), &nibFile))) { DisposeEventHandlerUPP(g_lpfnPlayerProc); DisposeControlActionUPP(g_lpfnVolumeProc); fprintf(stderr, "loadPlayerWin() - CreateNibReference(PlayerWin) failed, returning %lu!\n", (unsigned long) iResult); return false; } if (noErr != (iResult = CreateWindowFromNib(nibFile, CFSTR("FroggPlayerWindow"), &g_refPlayerWin))) { DisposeNibReference(nibFile); DisposeEventHandlerUPP(g_lpfnPlayerProc); DisposeControlActionUPP(g_lpfnVolumeProc); fprintf(stderr, "loadPlayerWin() - CreateWindowFromNib(FroggPlayerWindow) failed, returning %lu!\n", (unsigned long) iResult); return false; } DisposeNibReference(nibFile); if (bInitMetal) { if (noErr != (iResult = ChangeWindowAttributes(g_refPlayerWin, kWindowMetalAttribute, 0))) { DisposeWindow(g_refPlayerWin); DisposeEventHandlerUPP(g_lpfnPlayerProc); DisposeControlActionUPP(g_lpfnVolumeProc); fprintf(stderr, "loadPlayerWin() - ChangeWindowAttributes() failed, returning %lu!\n", (unsigned long) iResult); return false; } } pEvent.eventClass = kEventClassWindow; pEvent.eventKind = kEventWindowClose; if (noErr != (iResult = InstallWindowEventHandler(g_refPlayerWin, g_lpfnPlayerProc, 1, &pEvent, NULL, &g_refPlayerHdlr))) { DisposeWindow(g_refPlayerWin); DisposeEventHandlerUPP(g_lpfnPlayerProc); DisposeControlActionUPP(g_lpfnVolumeProc); fprintf(stderr, "loadPlayerWin() - InstallWindowEventHandler() failed, returning %lu!\n", (unsigned long) iResult); return false; } cID.signature = FOUR_CHAR_CODE('volu'); cID.id = 6; if (noErr != (iResult = GetControlByID(g_refPlayerWin, &cID, &cRef))) { RemoveEventHandler(g_refPlayerHdlr); DisposeWindow(g_refPlayerWin); DisposeEventHandlerUPP(g_lpfnPlayerProc); DisposeControlActionUPP(g_lpfnVolumeProc); fprintf(stderr, "loadPlayerWin() - GetControlByID() failed, returning %lu!\n", (unsigned long) iResult); return false; } SetControlAction(cRef, g_lpfnVolumeProc); cID.signature = FOUR_CHAR_CODE('fpos'); cID.id = 7; if (noErr != (iResult = GetControlByID(g_refPlayerWin, &cID, &cRef2))) { RemoveEventHandler(g_refPlayerHdlr); DisposeWindow(g_refPlayerWin); DisposeEventHandlerUPP(g_lpfnPlayerProc); DisposeControlActionUPP(g_lpfnVolumeProc); fprintf(stderr, "loadPlayerWin() - GetControlByID() failed, returning %lu!\n", (unsigned long) iResult); return false; } pEvent.eventClass = kEventClassControl; pEvent.eventKind = kEventControlClick; if (noErr != (iResult = InstallControlEventHandler(cRef2, g_lpfnPlayerProc, 1, &pEvent, NULL, &g_refSeekHdlr))) { SetControlAction(cRef, (ControlActionUPP) -1); RemoveEventHandler(g_refPlayerHdlr); DisposeWindow(g_refPlayerWin); DisposeEventHandlerUPP(g_lpfnPlayerProc); DisposeControlActionUPP(g_lpfnVolumeProc); fprintf(stderr, "loadPlayerWin() - InstallWindowEventHandler() failed, returning %lu!\n", (unsigned long) iResult); return false; } setPlayerWinVolSlider(getSavedVolumePos()); g_bLoaded = true; return true; }