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; }
static DialogRef DrawDialogTheSystem6or7Way(void) { DialogItemType itemType; Handle itemHandle; Rect itemBox; DialogRef theDialog = GetNewDialog(256, NULL, (WindowRef)-1L); if (theDialog == NULL) return(NULL); // Move it! MoveWindow(GetDialogWindow(theDialog), 10, 271, false); // Setting the check box GetDialogItem(theDialog, 2, &itemType, &itemHandle, &itemBox); SetControlValue((ControlHandle)itemHandle, 1); // Setting a radio button GetDialogItem(theDialog, 3, &itemType, &itemHandle, &itemBox); SetControlValue((ControlHandle)itemHandle, 1); // Setting the draw proc for the user item GetDialogItem(theDialog, 13, &itemType, &itemHandle, &itemBox); gUserH = (itemBox.left + itemBox.right) / 2; gUserV = (itemBox.top + itemBox.bottom) / 2; SetDialogItem(theDialog, 13, itemType, (Handle)&MyDrawUserItem, &itemBox); // Setting the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work GetDialogItem(theDialog, 14, &itemType, &itemHandle, &itemBox); SetControlAction((ControlHandle)itemHandle, ScrollBarActionProc); ShowWindow(GetDialogWindow(theDialog)); return(theDialog); }
bool unloadPlayerWin() { ControlRef cRef; ControlID cID; OSStatus iErr; cID.signature = FOUR_CHAR_CODE('volu'); cID.id = 6; if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cRef))) { /* We don't return false here since this is always called on the way out. */ fprintf(stderr, "unloadPlayerWin() - GetControlByID() failed, returning %lu!\n", (unsigned long) iErr); } else { SetControlAction(cRef, (ControlActionUPP) -1); } HideWindow(g_refPlayerWin); RemoveEventHandler(g_refSeekHdlr); RemoveEventHandler(g_refPlayerHdlr); DisposeWindow(g_refPlayerWin); DisposeEventHandlerUPP(g_lpfnPlayerProc); DisposeControlActionUPP(g_lpfnVolumeProc); return true; }
// 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; }
/***************************************************** * * Do_NewWindowFromAPI(outWindow) * * Purpose: called to create a new window using only API calls fron MacWindows.h, Controls.h, and HIView.h * * Notes: called by Do_NewWindow() * * Inputs: outWindow - if not NULL, the address where to return the WindowRef * - if not NULL, the callee will have to ShowWindow * * Returns: OSStatus - error code (0 == no error) */ static OSStatus Do_NewWindowFromAPI(WindowRef * outWindow) { WindowRef aWindowRef = NULL; CFStringRef theTitle = NULL; OSStatus status; // Create a window Rect bounds = {0, 0, 360, 480}; status = CreateNewWindow(kDocumentWindowClass, kWindowStandardFloatingAttributes | kWindowStandardHandlerAttribute | kWindowCompositingAttribute | kWindowMetalAttribute, &bounds, &aWindowRef); require_noerr(status, CreateNewWindow); require(aWindowRef != NULL, CreateNewWindow); status = RepositionWindow(aWindowRef, NULL, kWindowCascadeOnMainScreen); require_noerr(status, RepositionWindow); HIViewRef contentView; status = HIViewFindByID(HIViewGetRoot(aWindowRef), kHIViewWindowContentID, &contentView); require_noerr(status, HIViewFindByID); ControlRef aControlRef; Rect statBounds = {113, 20, 177, 460}; ControlFontStyleRec style = {kControlUseJustMask, 0, 0, 0, 0, teJustCenter}; status = CreateStaticTextControl(NULL, &statBounds, CFSTR("Click in the LittleArrows control above."), &style, &aControlRef); require_noerr(status, CreateStaticTextControl); HIViewID staticTextID = { 'STTC', 100 }; HIViewSetID(aControlRef, staticTextID); status = HIViewAddSubview(contentView, aControlRef); require_noerr(status, HIViewAddSubview); Rect littleArrowBounds = {51, 234, 73, 247}; status = CreateLittleArrowsControl(NULL, &littleArrowBounds, 0, 0, 10, 1, &aControlRef); require_noerr(status, CreateLittleArrowsControl); status = HIViewAddSubview(contentView, aControlRef); require_noerr(status, HIViewAddSubview); SetControlAction(aControlRef, LittleArrowsControlAction); EventTypeSpec eventTypeCVFC = {kEventClassControl, kEventControlValueFieldChanged}; status = HIViewInstallEventHandler(aControlRef, Handle_PostLittleArrowsClick, 1, &eventTypeCVFC, (void *)aControlRef, NULL); require_noerr(status, CantInstallEventHandler); Rect buttonBounds = {320, 390, 340, 460}; status = CreatePushButtonControl(NULL, &buttonBounds, CFSTR("OK"), &aControlRef); require_noerr(status, CreatePushButtonControl); status = SetControlCommandID(aControlRef, kHICommandOK); require_noerr(status, SetControlCommandID); status = HIViewAddSubview(contentView, aControlRef); require_noerr(status, HIViewAddSubview); status = SetWindowDefaultButton(aWindowRef, aControlRef); require_noerr(status, SetWindowDefaultButton); WindowDataPtr wdr = (WindowDataPtr)calloc(1, sizeof(WindowDataRec)); require(wdr != NULL, CantAllocateWindowData); SetWRefCon(aWindowRef, (long)wdr); theTitle = CFStringCreateWithFormat(NULL, NULL, CFSTR("LittleArrowsShowcase Window From API #%ld"), ++gWindowCount); require(theTitle != NULL, CFStringCreateWithFormat); status = SetWindowTitleWithCFString(aWindowRef, theTitle); require_noerr(status, SetWindowTitleWithCFString); EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess}; status = InstallWindowEventHandler(aWindowRef, Handle_WindowCommandProcess, 1, &eventTypeCP, (void *)aWindowRef, NULL); require_noerr(status, CantInstallEventHandler); EventTypeSpec eventTypeWC = {kEventClassWindow, kEventWindowClosed}; status = InstallWindowEventHandler(aWindowRef, Handle_WindowIsClosing, 1, &eventTypeWC, (void *)aWindowRef, NULL); require_noerr(status, CantInstallEventHandler); // The window was created hidden so show it if the outWindow parameter is NULL, // if it's not, it will be the responsibility of the caller to show it. if (outWindow == NULL) ShowWindow(aWindowRef); SetWindowModified(aWindowRef, false); CantInstallEventHandler: SetWindowTitleWithCFString: CFStringCreateWithFormat: if (theTitle != NULL) CFRelease(theTitle); CantAllocateWindowData: SetWindowDefaultButton: SetControlCommandID: CreatePushButtonControl: CreateLittleArrowsControl: HIViewAddSubview: CreateStaticTextControl: HIViewFindByID: RepositionWindow: CreateNewWindow: if (outWindow != NULL) *outWindow = aWindowRef; return status; } // Do_NewWindowFromAPI
/***************************************************** * * Do_NewWindowFromIB(outWindow) * * Purpose: called to create a new window that has been constructed with Interface Builder * * Notes: called by Do_NewWindow() * * Inputs: outWindow - if not NULL, the address where to return the WindowRef * - if not NULL, the callee will have to ShowWindow * * Returns: OSStatus - error code (0 == no error) */ static OSStatus Do_NewWindowFromIB(WindowRef * outWindow) { OSStatus status; WindowRef aWindowRef = NULL; CFStringRef theTitle = NULL; CFMutableStringRef theNewTitle = NULL; // Create a window. "MainWindow" is the name of the window object. This name is set in // InterfaceBuilder when the nib is created. status = CreateWindowFromNib(gIBNibRef, CFSTR("MainWindow"), &aWindowRef); require_noerr(status, CreateWindowFromNib); require(aWindowRef != NULL, CreateWindowFromNib); WindowDataPtr wdr = (WindowDataPtr)calloc(1, sizeof(WindowDataRec)); require(wdr != NULL, CantAllocateWindowData); SetWRefCon(aWindowRef, (long)wdr); status = CopyWindowTitleAsCFString(aWindowRef, &theTitle); require_noerr(status, CopyWindowTitleAsCFString); theNewTitle = CFStringCreateMutableCopy(NULL, 0, theTitle); require(theNewTitle != NULL, CFStringCreateMutableCopy); CFStringAppendFormat(theNewTitle, NULL, CFSTR(" %ld"), ++gWindowCount); status = SetWindowTitleWithCFString(aWindowRef, theNewTitle); require_noerr(status, SetWindowTitleWithCFString); EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess}; status = InstallWindowEventHandler(aWindowRef, Handle_WindowCommandProcess, 1, &eventTypeCP, (void *)aWindowRef, NULL); require_noerr(status, CantInstallEventHandler); EventTypeSpec eventTypeWC = {kEventClassWindow, kEventWindowClosed}; status = InstallWindowEventHandler(aWindowRef, Handle_WindowIsClosing, 1, &eventTypeWC, (void *)aWindowRef, NULL); require_noerr(status, CantInstallEventHandler); HIViewID littleArrowsId = { 'LARC', 100 }; HIViewRef littleArrows; status = HIViewFindByID(HIViewGetRoot(aWindowRef), littleArrowsId, &littleArrows); require_noerr(status, HIViewFindByID); require(littleArrows != NULL, HIViewFindByID); SetControlAction(littleArrows, LittleArrowsControlAction); EventTypeSpec eventTypeCVFC = {kEventClassControl, kEventControlValueFieldChanged}; status = HIViewInstallEventHandler(littleArrows, Handle_PostLittleArrowsClick, 1, &eventTypeCVFC, (void *)littleArrows, NULL); require_noerr(status, CantInstallEventHandler); // The window was created hidden so show it if the outWindow parameter is NULL, // if it's not, it will be the responsibility of the caller to show it. if (outWindow == NULL) ShowWindow(aWindowRef); SetWindowModified(aWindowRef, false); HIViewFindByID: CantInstallEventHandler: SetWindowTitleWithCFString: CFStringCreateMutableCopy: CopyWindowTitleAsCFString: if (theTitle != NULL) CFRelease(theTitle); if (theNewTitle != NULL) CFRelease(theNewTitle); CantAllocateWindowData: CreateWindowFromNib: if (outWindow != NULL) *outWindow = aWindowRef; return status; } // Do_NewWindowFromIB
static WindowRef DrawDialogTheMacOSXWay(void) { // Create a window. "DLOG:257" is the name of the window object. This name is set in // InterfaceBuilder when the resource file is imported. OSStatus status = noErr; IBNibRef nibRef; WindowRef window = NULL; static HIObjectClassRef theClass; if (theClass == NULL) { static EventTypeSpec kFactoryEvents[] = { { kEventClassHIObject, kEventHIObjectConstruct }, { kEventClassHIObject, kEventHIObjectInitialize }, { kEventClassHIObject, kEventHIObjectDestruct }, { kEventClassControl, kEventControlHitTest }, { kEventClassControl, kEventControlTrack }, { kEventClassControl, kEventControlBoundsChanged }, { kEventClassControl, kEventControlDraw } }; HIObjectRegisterSubclass(kCustomSpotViewClassID, kHIViewClassID, 0, CustomSpotViewHandler, GetEventTypeCount(kFactoryEvents), kFactoryEvents, 0, &theClass); } status = CreateNibReference(CFSTR("main"), &nibRef); require_noerr(status, CantGetNibRef); status = CreateWindowFromNib(nibRef, CFSTR("DLOG:257"), &window); require_noerr(status, CantCreateWindow); // Let's react to User's commands. EventTypeSpec eventTypeCP = {kEventClassCommand, kEventCommandProcess}; InstallEventHandler(GetWindowEventTarget(window), MacOSXDialogCommandProcess, 1, &eventTypeCP, window, NULL); // we still assign the key filter on our edit text box so that only digits can be entered HIViewID hidnst = {0, 9}; HIViewRef numEditText; HIViewFindByID(HIViewGetRoot(window), hidnst, &numEditText); ControlKeyFilterUPP keyFilter = MyEditKeyFilter; SetControlData(numEditText, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter); SetKeyboardFocus(window, numEditText, kControlFocusNextPart); // we still set the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work // and still associate the previous edit text box with the scroll bar so it gets updated HIViewID hidsb = {0, 14}; HIViewRef scrollBar; HIViewFindByID(HIViewGetRoot(window), hidsb, &scrollBar); SetControlAction(scrollBar, ScrollBar32BitActionProc); SetControlReference(scrollBar, (SInt32)numEditText); // Move it! MoveWindow(window, 854, 271, false); // and use the replacement for ModalDialog // one good thing is that our behaviors are no longer half-done at the dialog level // and half-done at the control level, they are all handled by the view handlers ShowWindow(window); CantCreateWindow: CantGetNibRef: return (window); }
static DialogRef DrawDialogTheMacOS8or9Way(void) { short i; ControlRef theControl; DialogRef theDialog = GetNewDialog(257, NULL, (WindowRef)-1L); if (theDialog == NULL) return(NULL); // Let's get a pulsing blue default button! GetDialogItemAsControl(theDialog, 1, &theControl); SetWindowDefaultButton(GetDialogWindow(theDialog), theControl); // Setting the check box GetDialogItemAsControl(theDialog, 2, &theControl); SetControl32BitValue(theControl, 1); // We need to autoembed our radio buttons in the radio group // so that they work automatically for (i = 4; i <= 8; i++) { GetDialogItemAsControl(theDialog, i, &theControl); AutoEmbedControl(theControl, GetDialogWindow(theDialog)); } // we assign a key filter on our edit text box so that only digits can be entered ControlRef theTextControl; ControlKeyFilterUPP keyFilter = MyEditKeyFilter; GetDialogItemAsControl(theDialog, 9, &theTextControl); SetKeyboardFocus(GetDialogWindow(theDialog), theTextControl, kControlFocusNextPart); SetControlData(theTextControl, kControlEntireControl, kControlEditTextKeyFilterTag, sizeof(keyFilter), &keyFilter); // Setting the action proc for the scroll bar so that the PageUp/PageDown/Up/Down buttons work // We also associate the previous edit text box with the scroll bar so it gets updated GetDialogItemAsControl(theDialog, 14, &theControl); SetControlAction(theControl, ScrollBar32BitActionProc); SetControl32BitMaximum(theControl, 0x7fffffff); SetControlReference(theControl, (SInt32)theTextControl); // The static text control is created as a resource but we could only set its title and // not its content. We set the content now! GetDialogItemAsControl(theDialog, 15, &theControl); Str255 theTitle; GetControlTitle(theControl, theTitle); SetControlData(theControl, kControlEntireControl, kControlStaticTextTextTag, theTitle[0], &theTitle[1]); // We set up our User Pane Control with the draw, hit test, and track (actually action) procs GetDialogItemAsControl(theDialog, 13, &theControl); Rect bounds; GetControlBounds(theControl, &bounds); gUserH = (bounds.left + bounds.right) / 2; gUserV = (bounds.top + bounds.bottom) / 2; ControlUserPaneDrawUPP userPaneDraw = MyUserPaneDrawProc; SetControlData(theControl, kControlEntireControl, kControlUserPaneDrawProcTag, sizeof(userPaneDraw), &userPaneDraw); ControlUserPaneHitTestUPP userPaneHitTest = MyUserPaneHitTestProc; SetControlData(theControl, kControlEntireControl, kControlUserPaneHitTestProcTag, sizeof(userPaneHitTest), &userPaneHitTest); SetControlAction(theControl, MoveSpotActionProc); ShowWindow(GetDialogWindow(theDialog)); return(theDialog); }
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); } }
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; }