void CDisplayResolutionPane::OnSelchangeCombo1() {
	char str[32];
	CComboBox* pCB = (CComboBox*) GetDlgItem(IDC_COMBO1);

	pCB->GetLBText(pCB->GetCurSel(), str);

	VisualGraphics* theVisualGraphics = VisualGraphics::getInstance();
	UInt16 horizontalPixels;
	UInt16 verticalPixels;
	UInt16 bitsPerPixel;
	UInt16 refreshRate;
	theVisualGraphics->matchDisplayResolutionShowStrWithPrefs(str, horizontalPixels, verticalPixels, bitsPerPixel, refreshRate);

	VisualDataStore::setPreferenceValueInt(VisualConfiguration::kFullscreenWidth, horizontalPixels);
	VisualDataStore::setPreferenceValueInt(VisualConfiguration::kFullscreenHeight, verticalPixels);
	VisualDataStore::setPreferenceValueInt(VisualConfiguration::kFullscreenBitsPerPixel, bitsPerPixel);
	VisualDataStore::setPreferenceValueInt(VisualConfiguration::kFullscreenRefreshRate, refreshRate);
	
	VisualDataStore::storePreferences();
	
	UInt16 minBitsPerPixel = 24;
	UInt16 maxBitsPerPixel = 32;
	VisualDataStore::setPreferredDisplayResolution(minBitsPerPixel, maxBitsPerPixel, bitsPerPixel, horizontalPixels, verticalPixels);

}
示例#2
0
void OptionsDialog::handleEvent(EventHandlerCallRef inRef, EventRef inEvent, void* userData) {
    
	UInt32 eventClass;
	UInt32 eventKind;
	
	eventClass = GetEventClass(inEvent);
	eventKind = GetEventKind(inEvent);
	
	switch (eventClass) {
	
		case kEventClassWindow:
			// window event
			if (eventKind == kEventWindowClose) {
				HideWindow(theOptionsDialog->optionsDialogWindow);
			}
			break;
	
		case kEventClassControl:
			// control event
			ControlID controlID;
			ControlRef control = NULL;
			GetEventParameter(inEvent, kEventParamDirectObject, typeControlRef, NULL, sizeof(ControlRef), NULL, &control);
			GetControlID(control, &controlID);
			UInt32 stringLength = 0;
			CFStringRef selectedText = NULL;
			
			switch(controlID.id) {

				case displayResolutionMenuId:
					{
						SInt32 selectedMenuItemIdx;
						selectedMenuItemIdx = GetControl32BitValue(control);
						theOptionsDialog->displayResolutionMenuSelectedIdx = selectedMenuItemIdx;
						char str[32];
						CopyMenuItemTextAsCFString(theOptionsDialog->displayResolutionMenu, selectedMenuItemIdx, &selectedText);
						stringLength = CFStringGetLength(selectedText);
						stringLength += 1; // incl. terminating null-byte
						CFStringGetCString(selectedText, str, stringLength, kCFStringEncodingASCII);
						CFRelease(selectedText);
						
						VisualGraphics* theVisualGraphics = VisualGraphics::getInstance();
						UInt16 horizontalPixels;
						UInt16 verticalPixels;
						UInt16 bitsPerPixel;
						UInt16 refreshRate;
						theVisualGraphics->matchDisplayResolutionShowStrWithPrefs(str, horizontalPixels, verticalPixels, bitsPerPixel, refreshRate);

						VisualDataStore::setPreferenceValueInt(VisualConfiguration::kFullscreenWidth, horizontalPixels);
						VisualDataStore::setPreferenceValueInt(VisualConfiguration::kFullscreenHeight, verticalPixels);
						VisualDataStore::setPreferenceValueInt(VisualConfiguration::kFullscreenBitsPerPixel, bitsPerPixel);
						VisualDataStore::setPreferenceValueInt(VisualConfiguration::kFullscreenRefreshRate, refreshRate);
						
						VisualDataStore::storePreferences();
						
						UInt16 minBitsPerPixel = 24;
						UInt16 maxBitsPerPixel = 32;
						VisualDataStore::setPreferredDisplayResolution(minBitsPerPixel, maxBitsPerPixel, bitsPerPixel, horizontalPixels, verticalPixels);
					}
					break;
					
				case tabControlId:
					theOptionsDialog->showSelectedPaneOfTabControl();
					break;
			}
			break;
	}
}