コード例 #1
0
ファイル: PlayerWin.cpp プロジェクト: ullerrm/frogg
bool enablePlayerButtons(bool bPlay, bool bPause, bool bStop, bool bInfo)
{
    ControlRef cPlay, cPause, cStop, cInfo;
    ControlID cID;
    OSStatus iErr;

    /* Get control references.. */
    
    cID.signature = FOUR_CHAR_CODE('play');
    cID.id = 1;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cPlay)))
    {
        fprintf(stderr, "enableButtons() - GetControlByID(play) failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    cID.signature = FOUR_CHAR_CODE('paus');
    cID.id = 2;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cPause)))
    {
        fprintf(stderr, "enableButtons() - GetControlByID(paus) failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    cID.signature = FOUR_CHAR_CODE('stop');
    cID.id = 3;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cStop)))
    {
        fprintf(stderr, "enableButtons() - GetControlByID(stop) failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    cID.signature = FOUR_CHAR_CODE('info');
    cID.id = 4;
    if (noErr != (iErr = GetControlByID(g_refPlayerWin, &cID, &cInfo)))
    {
        fprintf(stderr, "enableButtons() - GetControlByID(info) failed, returning %lu!\n", (unsigned long) iErr);
        return false;
    }

    /* And set everything en masse. */

    if (bPlay)  {  EnableControl(cPlay);   }
    else        {  DisableControl(cPlay);  }

    if (bPause)  {  EnableControl(cPause);   }
    else         {  DisableControl(cPause);  }

    if (bStop)  {  EnableControl(cStop);   }
    else        {  DisableControl(cStop);  }

    if (bInfo)  {  EnableControl(cInfo);   }
    else        {  DisableControl(cInfo);  }

    return true;
}
コード例 #2
0
void
TabbedWindow::DisableAllPanes( void )
{
    OSStatus status;
    ControlRef controlRef;
    ControlID controlID;
    
    controlID.signature = kTabPaneSignature;
    
    // loop through and disable all of the panes
    for ( int i = 1; i <= kTabPaneCount; i++ )
    {
        controlID.id = gPaneArray[i];
        status = GetControlByID( fWindowRef, &controlID, &controlRef );
        check_noerr( status );
        
        // disable the panes
        if ( status == noErr )
        {
            SetControlVisibility( controlRef, false, false );
            DisableControl( controlRef );
        }
    }
    return;
}
コード例 #3
0
void PreferencesDialog::initDialog()
{
	ControlHandle popupButtonControl;
	ControlID popupButtonControlID = {kAppSignature, 130};
	MenuRef menu;
	
	GetControlByID(preferencesWindow, &popupButtonControlID, &popupButtonControl);
	GetControlData(popupButtonControl, kControlEntireControl, kControlPopupButtonMenuRefTag, sizeof(menu), &menu, NULL);

	unsigned int nPorts = midiin ? midiin->getPortCount() : 0;

	if (nPorts)
	{
		UInt32 numItems = CountMenuItems(menu);
		DeleteMenuItems(menu, 1, numItems); 
		
		// Check inputs.
		std::string portName;
		unsigned int nSelectedDevice = 0;
		for (unsigned int i = 0; i < nPorts; i++ ) 
		{
			try 
			{
				portName = midiin->getPortName(i);
			}
			catch (RtMidiError &error) 
			{
				error.printMessage();
			}
			
			if (strcmp(portName.c_str(), m_dataBase->restore(KEY_MIDIDEVICE)->getStringValue()) == 0)
				nSelectedDevice = i;
			
			CFStringRef CFStrPortName = CFStringCreateWithCString(NULL, portName.c_str(), kCFStringEncodingASCII);
			AppendMenuItemTextWithCFString(menu, CFStrPortName, 0, kMIDIDeviceBaseCommand + i, 0);
			CFRelease(CFStrPortName);
			
		}

		/*AppendMenuItemTextWithCFString(menu, CFSTR("Temp1"), 0, kMIDIDeviceBaseCommand + 1, 0);
		AppendMenuItemTextWithCFString(menu, CFSTR("Temp2"), 0, kMIDIDeviceBaseCommand + 2, 0);
		nPorts+=2;*/
		
		SetControlMaximum(popupButtonControl, nPorts);
		
		SetControlValue(popupButtonControl, nSelectedDevice + 1);
		
		storeMidiDeviceName(nSelectedDevice);

		EnableControl(popupButtonControl);			
	}
	else
	{
		DisableControl(popupButtonControl);	
	}
	
	updateControls();

	updateSliderVelocityAmplify();	
}
コード例 #4
0
ファイル: CANJaguar.cpp プロジェクト: chopshop-166/frc-2011
/**
 * Change the control mode of this Jaguar object.
 * 
 * After changing modes, configure any PID constants or other settings needed
 * and then EnableControl() to actually change the mode on the Jaguar.
 * 
 * @param controlMode The new mode.
 */
void CANJaguar::ChangeControlMode(ControlMode controlMode)
{
	// Disable the previous mode
	DisableControl();

	// Update the local mode
	m_controlMode = controlMode;
}
コード例 #5
0
ファイル: CANJaguar.cpp プロジェクト: errorcodexero/porting
/**
 * Change the control mode of this Jaguar object.
 *
 * After changing modes, configure any PID constants or other settings needed
 * and then EnableControl() to actually change the mode on the Jaguar.
 *
 * @param controlMode The new mode.
 */
void CANJaguar::ChangeControlMode(ControlMode controlMode)
{
    // Disable the previous mode
    DisableControl();

    // Update the local mode
    m_controlMode = controlMode;

    nUsageReporting::report(nUsageReporting::kResourceType_CANJaguar, m_deviceNumber, m_controlMode);
}
コード例 #6
0
OSStatus
TabbedWindow::SwitchTabPane( ControlRef tabControl )
{
    OSStatus status = noErr;
    ControlRef paneRef;

    // get the value of the control
    int tabIndex = GetControlValue( tabControl );
    
    // make sure that the value of the control is within the current count,
    // so we don't step outside the bounds of the array
    paneRef = this->PaneAtIndex( tabIndex );
    
    // check to see if the controlRef is the same as the one that's
    // currently activated
    if ( paneRef != fCurrentTabPane )
    {
        // deactivate and disable the current pane, if we have one
        if ( fCurrentTabPane != NULL )
        {
            SetControlVisibility( fCurrentTabPane, false, false );
            DisableControl( fCurrentTabPane );
        }
        
        // activate the current pane
        EnableControl( paneRef );
        SetControlVisibility( paneRef, true, true );
            
        // set the current pane to be the one that we just activated
        fCurrentTabPane = paneRef;
    }
    else
    {
        // set the error back to eventNotHandled error, since we're
        // not handling it for the same tab that's already activated
        status = eventNotHandledErr;
    }
    return status;

}
コード例 #7
0
bool wxToolBarTool::DoEnable(bool enable)
{
    if ( IsControl() )
    {
        GetControl()->Enable( enable ) ;
    }
    else if ( IsButton() )
    {
#if TARGET_API_MAC_OSX
        if ( enable )
            EnableControl( m_controlHandle ) ;
        else
            DisableControl( m_controlHandle ) ;
#else
        if ( enable )
            ActivateControl( m_controlHandle ) ;
        else
            DeactivateControl( m_controlHandle ) ;
#endif
    }
    return true ;
}
コード例 #8
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolGeomWithJoin::edit_init(WindowRef wd){
ControlRef		c;
ControlID		cid;
bGenericType*	tp=NULL;
char			val[32];

	val[1]=0;
	
/* A GERER PAR UN MAP EVENT*/
	for(int i=_tp_use.count()+1;i<=_gapp->typesMgr()->count();i++){
		tp=NULL;
		_tp_use.add(&tp);
	}
	for(int i=_tp_use.count();i>_gapp->typesMgr()->count();i--){
		_tp_use.rmv(i);
	}
/* A GERER PAR UN MAP EVENT*/
	
	cid.signature=kToolGeomWithJoinSign;
	
	cid.id=kToolGeomWithJoinUseNeaID;
	GetControlByID(wd,&cid,&c);
	SetControl32BitValue(c,_use_nea);
    cid.id=kToolGeomWithJoinKeyNeaID;
    GetControlByID(wd,&cid,&c);
    val[0]=_k_nea;
    SetTextControlValue(c,val);
	
	cid.id=kToolGeomWithJoinUseDirID;
	GetControlByID(wd,&cid,&c);
	SetControl32BitValue(c,_use_dir);
    cid.id=kToolGeomWithJoinKeyDirID;
    GetControlByID(wd,&cid,&c);
    val[0]=_k_dir;
    SetTextControlValue(c,val);
	
	cid.id=kToolGeomWithJoinUseAngID;
	GetControlByID(wd,&cid,&c);
	SetControl32BitValue(c,_use_ang);
    cid.id=kToolGeomWithJoinKeyAngID;
    GetControlByID(wd,&cid,&c);
    val[0]=_k_ang;
    SetTextControlValue(c,val);
	
	cid.id=kToolGeomWithJoinUseEndID;
	GetControlByID(wd,&cid,&c);
	SetControl32BitValue(c,_use_end);
    cid.id=kToolGeomWithJoinKeyEndID;
    GetControlByID(wd,&cid,&c);
    val[0]=_k_end;
    SetTextControlValue(c,val);

    if(!_jnea){
        cid.id=kToolGeomWithJoinUseNeaID;
        GetControlByID(wd,&cid,&c);
        DisableControl(c);
        cid.id=kToolGeomWithJoinKeyNeaID;
        GetControlByID(wd,&cid,&c);
        DisableControl(c);
    }
 
    if(!_jdir){
        cid.id=kToolGeomWithJoinUseDirID;
        GetControlByID(wd,&cid,&c);
        DisableControl(c);
        cid.id=kToolGeomWithJoinKeyDirID;
        GetControlByID(wd,&cid,&c);
        DisableControl(c);
    }
    
    if(!_jang){
        cid.id=kToolGeomWithJoinUseAngID;
        GetControlByID(wd,&cid,&c);
        DisableControl(c);
        cid.id=kToolGeomWithJoinKeyAngID;
        GetControlByID(wd,&cid,&c);
        DisableControl(c);
    }
    
    if(!_jend){
        cid.id=kToolGeomWithJoinUseEndID;
        GetControlByID(wd,&cid,&c);
        DisableControl(c);
        cid.id=kToolGeomWithJoinKeyEndID;
        GetControlByID(wd,&cid,&c);
        DisableControl(c);
    }
    
	cid.id=kToolGeomWithJoinTypesID;
	GetControlByID(wd,&cid,&c);
	DataBrowserInit(c,dtb_proc,NULL,(long)this);

	populate_types(wd);
	SetDataBrowserPropertyFlags(c,kToolGeomWithJoinTypesCheckProperty,kDataBrowserPropertyIsEditable);
}
コード例 #9
0
ファイル: CANJaguar.cpp プロジェクト: errorcodexero/porting
/**
 * Common interface for disabling a motor.
 *
 * @deprecated Call DisableControl instead.
 */
void CANJaguar::Disable()
{
    DisableControl();
}
コード例 #10
0
ファイル: CANJaguar.cpp プロジェクト: errorcodexero/porting
/**
 * Common interface for stopping the motor
 * Part of the MotorSafety interface
 *
 * @deprecated Call DisableControl instead.
 */
void CANJaguar::StopMotor()
{
    DisableControl();
}
コード例 #11
0
ファイル: mac-prefs.cpp プロジェクト: libretro/snes9x
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);
		}
	}
}
コード例 #12
0
ファイル: carbon_ui.c プロジェクト: BackupTheBerlios/geoirc
static void parse_option(install_info *info, const char *component, xmlNodePtr node, OptionsBox *box, int level, OptionsButton *parent, int exclusive, RadioGroup **radio)
{
    xmlNodePtr child;
    char text[1024] = "";
    const char *help;
    const char *wanted;
    char *name;
    int i;
    OptionsButton *button = NULL;

    /* See if this node matches the current architecture */
    wanted = xmlGetProp(node, "arch");
    if ( ! match_arch(info, wanted) ) {
        return;
    }

    wanted = xmlGetProp(node, "libc");
    if ( ! match_libc(info, wanted) ) {
        return;
    }

    wanted = xmlGetProp(node, "distro");
    if ( ! match_distro(info, wanted) ) {
        return;
    }

    if ( ! get_option_displayed(info, node) ) {
		return;
    }

    /* See if the user wants this option */
	if ( node->type == XML_TEXT_NODE ) {
		//name = g_strdup(node->content);
        name = strdup(node->content);
        //!!!TODO - Strip name
		//g_strstrip(name);
		if( *name ) {
			//button = gtk_label_new(name);
			//gtk_widget_show(button);
			//gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(button), FALSE, FALSE, 0);
            button = carbon_OptionsNewLabel(box, name);
		}
        //!!!TODO - Free name
		//g_free(name);
		return;
	} else {
		name = get_option_name(info, node, NULL, 0);
		for(i=0; i < (level*5); i++)
			text[i] = ' ';
		text[i] = '\0';
		strncat(text, name, sizeof(text)-strlen(text));
	}

	if ( GetProductIsMeta(info) ) {
		//button = gtk_radio_button_new_with_label(radio_list, text);
		//radio_list = gtk_radio_button_group(GTK_RADIO_BUTTON(button));
        button = carbon_OptionsNewRadioButton(box, text, &radio_list);
	} else if ( exclusive ) {
		//button = gtk_radio_button_new_with_label(*radio, text);
		//*radio = gtk_radio_button_group(GTK_RADIO_BUTTON(button));
        button = carbon_OptionsNewRadioButton(box, text, radio);
	} else {
		//button = gtk_check_button_new_with_label(text);
        button = carbon_OptionsNewCheckButton(box, text);
	}

    /* Add tooltip help, if available */
    help = get_option_help(info, node);
    if ( help ) {
        //GtkTooltipsData* group;

        //group = gtk_tooltips_data_get(window);
        //if ( group ) {
            //gtk_tooltips_set_tip( group->tooltips, button, help, 0);
            
        //} else {
            //gtk_tooltips_set_tip( gtk_tooltips_new(), button, help, 0);
        //}
        carbon_OptionsSetTooltip(button, help);
    }

    /* Set the data associated with the button */
	if ( button ) {
		//gtk_object_set_data(GTK_OBJECT(button), "data", (gpointer)node);
        button->Data = (void *)node;

		/* Register the button in the window's private data */
		//window = glade_xml_get_widget(setup_glade, "setup_window");
		//gtk_object_set_data(GTK_OBJECT(window), name, (gpointer)button);
        if(strlen(name) >= MAX_BUTTON_NAME)
            carbon_debug("parse_option() - Button name exceeeded length!  This will cause problems with selecting options!\n");
        else
            strcpy(button->Name, name);
	}

    /* Check for required option */
    if ( xmlGetProp(node, "required") ) {
		xmlSetProp(node, "install", "true");
		//gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
        DisableControl(button->Control);
    }

    /* If this is a sub-option and parent is not active, then disable option */
    wanted = xmlGetProp(node, "install");
    //if( level>0 && GTK_IS_TOGGLE_BUTTON(parent) && !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(parent)) ) {
    if( level>0 && parent->Type == ButtonType_Radio && !carbon_OptionsGetValue(parent)) {
		wanted = "false";
		//gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
        DisableControl(button->Control);
    }
    //***This functionality is implemented automatically when creating no option***
    //  buttons and labels
	//if ( button ) {
	//	gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(button), FALSE, FALSE, 0);
	//	gtk_signal_connect(GTK_OBJECT(button), "toggled",
	//					   GTK_SIGNAL_FUNC(setup_checkbox_option_slot), (gpointer)node);
	//	gtk_widget_show(button);
	//}

    if ( wanted && (strcmp(wanted, "true") == 0) ) {
        //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
        carbon_OptionsSetValue(button, true);
    } else {
        /* Unmark this option for installation */
        mark_option(info, node, "false", 1);
    }
    /* Recurse down any other options */
    child = node->childs;
    while ( child ) {
		if ( !strcmp(child->name, "option") ) {
			//parse_option(info, component, child, window, box, level+1, button, 0, NULL);
            parse_option(info, component, child, box, level+1, button, 0, NULL);
		} else if ( !strcmp(child->name, "exclusive") ) {
			xmlNodePtr exchild;
			//GSList *list = NULL;
            RadioGroup *list = NULL;
			for ( exchild = child->childs; exchild; exchild = exchild->next) {
				//parse_option(info, component, exchild, window, box, level+1, button, 1, &list);
                parse_option(info, component, exchild, box, level+1, button, 1, &list);
			}
		}
		child = child->next;
    }

    /* Disable any options that are already installed */
    if ( info->product && ! GetProductReinstall(info) ) {
        product_component_t *comp;

        if ( component ) {
            comp = loki_find_component(info->product, component);
        } else {
            comp = loki_getdefault_component(info->product);
        }
        if ( comp && loki_find_option(comp, name) ) {
            /* Unmark this option for installation */
            //gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
            //gtk_widget_set_sensitive(button, FALSE);
            carbon_OptionsSetValue(button, FALSE);
            DisableControl(button->Control);
            mark_option(info, node, "false", 1);
        }
    }
}
コード例 #13
0
ファイル: carbon_ui.c プロジェクト: BackupTheBerlios/geoirc
//void setup_checkbox_option_slot( GtkWidget* widget, gpointer func_data)
int OnOptionClickEvent(OptionsButton *ButtonWithEventClick)
{
	//GtkWidget *window;
	xmlNodePtr node;
    //xmlNodePtr data_node = (xmlNodePtr) func_data; //gtk_object_get_data(GTK_OBJECT(widget),"data");
    xmlNodePtr data_node = (xmlNodePtr)ButtonWithEventClick->Data;

    carbon_debug("OnOptionClickEvent()\n");

	if(!data_node)
		return true;
	
	//window = glade_xml_get_widget(setup_glade, "setup_window");

	//if(GTK_TOGGLE_BUTTON(widget)->active)
    if(carbon_OptionsGetValue(ButtonWithEventClick))
    {
        carbon_debug("OnOptionClickEvent() - Button toggle to true\n");
		const char *warn = get_option_warn(cur_info, data_node);

		// does this option require a seperate EULA?
		xmlNodePtr child;
		child = data_node->childs;
		while(child)
		{
			if (!strcmp(child->name, "eula"))
			{
				const char* name = GetProductEULANode(cur_info, data_node, NULL);
				if(name)
				{
                    char buffer[MAX_README_SIZE];
                    load_file(name, buffer, MAX_README_SIZE);
                    if(!carbon_ReadmeOrLicense(MyRes, false, buffer))
                    {
                        carbon_OptionsSetValue(ButtonWithEventClick, false);
					    return true;
					}
                    // Else, license was accepted...get out of loop
                    break;
				}
				else
				{
					log_warning("option-specific EULA not found, can't set option on\n");
					// EULA not found 	or not accepted
					carbon_OptionsSetValue(ButtonWithEventClick, false);
					return true;
				}
			}
			child = child->next;
		}
		
		if ( warn && !in_setup ) { // Display a warning message to the user
			carbonui_prompt(warn, RESPONSE_OK);
		}

		/* Mark this option for installation */
		mark_option(cur_info, data_node, "true", 0);
		
		/* Recurse down any other options to re-enable grayed out options */
		node = data_node->childs;
		while ( node ) {
			//enable_tree(node, window);
            EnableTree(node, (OptionsBox *)ButtonWithEventClick->Box);
			node = node->next;
		}
	}
    else
    {
        carbon_debug("OnOptionClickEvent() - Button toggle to false\n");
		/* Unmark this option for installation */
		mark_option(cur_info, data_node, "false", 1);
		
		/* Recurse down any other options */
		node = data_node->childs;
		while ( node ) {
			if ( !strcmp(node->name, "option") ) {
				//GtkWidget *button;
				//button = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(window),
				//										 get_option_name(cur_info, node, NULL, 0));
                OptionsButton *button;
				button = carbon_GetButtonByName((OptionsBox *)ButtonWithEventClick->Box, get_option_name(cur_info, node, NULL, 0));

                if(button){ /* This recursively calls this function */
					//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
					//gtk_widget_set_sensitive(button, FALSE);
                    carbon_OptionsSetValue(button, false);
                    DisableControl(button->Control);
				}
			} else if ( !strcmp(node->name, "exclusive") ) {
				xmlNodePtr child;
				for ( child = node->childs; child; child = child->next) {
					//GtkWidget *button;
					
					//button = (GtkWidget*)gtk_object_get_data(GTK_OBJECT(window),
					//										 get_option_name(cur_info, child, NULL, 0));
                    OptionsButton *button;
                    button = carbon_GetButtonByName((OptionsBox *)ButtonWithEventClick->Box, get_option_name(cur_info, node, NULL, 0));
					if(button){ /* This recursively calls this function */
						//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
						//gtk_widget_set_sensitive(button, FALSE);
                        carbon_OptionsSetValue(button, false);
                        DisableControl(button->Control);
					}
				}
			}
			node = node->next;
		}
	}
    cur_info->install_size = size_tree(cur_info, cur_info->config->root->childs);
	update_size();

    return true;
}
コード例 #14
0
void PreferencesDialog::updateControls()
{
	if (NULL==m_dataBase)
		return;

	ControlHandle checkBoxControl, control;
	ControlID checkBoxControlID[] = {{kAppSignature, 129}, {kAppSignature, 128}, {kAppSignature, 127}, 
									 {kAppSignature, 126}, {kAppSignature, 125}, {kAppSignature, 124},
									 {kAppSignature, 131}, {kAppSignature, 132}};

	GetControlByID(preferencesWindow, &checkBoxControlID[0], &checkBoxControl);
	bool b = false;

	if ((midiin && !midiin->getPortCount()) || !midiin)
		DisableControl(checkBoxControl);	
	else
	{
		EnableControl(checkBoxControl);	
		b = m_dataBase->restore(KEY_USEMIDI)->getBoolValue();
		SetControl32BitValue(checkBoxControl, b ? TRUE : FALSE);
	}

	GetControlByID(preferencesWindow, &checkBoxControlID[1], &checkBoxControl);
	b = m_dataBase->restore(KEY_SAVEPREFS)->getBoolValue();
	SetControl32BitValue(checkBoxControl, b ? TRUE : FALSE);

	GetControlByID(preferencesWindow, &checkBoxControlID[2], &checkBoxControl);
	b = false;
	
	if ((midiin && !midiin->getPortCount()) || !midiin)
	{
		// Disable checkbox
		DisableControl(checkBoxControl);	
		
		// disable min. value text for slider
		GetControlByID(preferencesWindow, &checkBoxControlID[3], &control);
		DisableControl(control);	
		
		// disable slider
		GetControlByID(preferencesWindow, &checkBoxControlID[4], &control);
		DisableControl(control);	
		
		// disable max. value text for slider
		GetControlByID(preferencesWindow, &checkBoxControlID[5], &control);
		DisableControl(control);	
	}
	else
	{
		EnableControl(checkBoxControl);	
		b = m_dataBase->restore(KEY_RECORDVELOCITY)->getBoolValue();
		SetControl32BitValue(checkBoxControl, b ? TRUE : FALSE);

		// enable min. value text for slider
		GetControlByID(preferencesWindow, &checkBoxControlID[3], &control);
		EnableControl(control);	
		
		// enable slider
		GetControlByID(preferencesWindow, &checkBoxControlID[4], &control);
		EnableControl(control);	
		
		// enable max. value text for slider
		GetControlByID(preferencesWindow, &checkBoxControlID[5], &control);
		EnableControl(control);	
	}

	GetControlByID(preferencesWindow, &checkBoxControlID[6], &checkBoxControl);
	UInt32 value = m_dataBase->restore(KEY_INSERTEMULATION)->getIntValue();
	SetControl32BitValue(checkBoxControl, value+1);

	GetControlByID(preferencesWindow, &checkBoxControlID[7], &checkBoxControl);
	b = m_dataBase->restore(KEY_SIXTEENBITCOLOR)->getBoolValue();
	SetControl32BitValue(checkBoxControl, b ? TRUE : FALSE);
}
コード例 #15
0
/*****************************************************
*
* 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
コード例 #16
0
static void SyncPaneFromSettings(MyCustomContext context)
{
    if (context->controls.frameRadioGroup)
    {
        if (context->settings.mHaveFrames)
        {
            EnableControl(context->controls.frameRadioGroup);

            if (context->settings.mPrintSelectedFrame &&
                    context->settings.mHaveFrameSelected)
                SetControl32BitValue(context->controls.frameRadioGroup,
                                kFramesSelectedIndex);
            else if (context->settings.mPrintFramesSeparately)
                SetControl32BitValue(context->controls.frameRadioGroup,
                                kFramesEachSeparatelyIndex);
            else /* (context->settings.mPrintFrameAsIs) */
                SetControl32BitValue(context->controls.frameRadioGroup,
                                kFramesAsLaidOutIndex);
            
            if (!context->settings.mHaveFrameSelected)
            {
                ControlRef radioControl;
                if (GetIndexedSubControl(context->controls.frameRadioGroup,
                                          kFramesSelectedIndex, &radioControl) == noErr)
                    DisableControl(radioControl);
            }
        }
        else
        {
            DisableControl(context->controls.frameRadioGroup);
            SetControl32BitValue(context->controls.frameRadioGroup, 0);
        }
    }
    
    if (context->controls.printSelCheck)
    {
        if (context->settings.mHaveSelection)
        {
            EnableControl(context->controls.printSelCheck);
            SetControl32BitValue(context->controls.printSelCheck,
                            context->settings.mPrintSelection);
        }
        else
        {
            DisableControl(context->controls.printSelCheck);
            SetControl32BitValue(context->controls.printSelCheck, 0);
        }
    }
    if (context->controls.shrinkToFitCheck)
        SetControl32BitValue(context->controls.shrinkToFitCheck,
                        context->settings.mShrinkToFit);
    if (context->controls.printBGColorsCheck)
        SetControl32BitValue(context->controls.printBGColorsCheck,
                        context->settings.mPrintBGColors);
    if (context->controls.printBGImagesCheck)
        SetControl32BitValue(context->controls.printBGImagesCheck,
                        context->settings.mPrintBGImages);
                        
    if (context->controls.headerLeftPopup)
      SetControl32BitValue(context->controls.headerLeftPopup,
                        GetIndexForPrintString(context->settings.mHeaderLeft));
    if (context->controls.headerCenterPopup)
      SetControl32BitValue(context->controls.headerCenterPopup,
                        GetIndexForPrintString(context->settings.mHeaderCenter));
    if (context->controls.headerRightPopup)
      SetControl32BitValue(context->controls.headerRightPopup,
                        GetIndexForPrintString(context->settings.mHeaderRight));

    if (context->controls.footerLeftPopup)
      SetControl32BitValue(context->controls.footerLeftPopup,
                        GetIndexForPrintString(context->settings.mFooterLeft));
    if (context->controls.footerCenterPopup)
      SetControl32BitValue(context->controls.footerCenterPopup,
                        GetIndexForPrintString(context->settings.mFooterCenter));
    if (context->controls.footerRightPopup)
      SetControl32BitValue(context->controls.footerRightPopup,
                         GetIndexForPrintString(context->settings.mFooterRight));

}