⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 screenwindow.cpp

📁 ati driver
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*	Copyright (c) 2002, Thomas Kurschel	based on Screen Preferences Panel written for OpenBeOS by Rafael Romo	Part of Radeon Screen Preferences			Main window, handling mode select and set*/#include <InterfaceDefs.h>#include <Application.h>#include <MenuItem.h>#include <Window.h>#include <Button.h>#include <String.h>#include <Screen.h>//#include <Messenger.h>#include <Menu.h>//#include <cstring>//#include <cstdlib>#include <Alert.h>#include "ScreenWindow.h"#include "ScreenDrawView.h"#include "AlertWindow.h"#include "Constants.h"#include <stdlib.h>#include <math.h>#include <stdio.h>#include "multimon.h"// list of officially supported colour spacesstruct {	uint32 space;	int bpp;} bpp_list[] = {	{ B_CMAP8, 8 },	{ B_RGB15, 15 },	{ B_RGB16, 16 },	{ B_RGB32, 32 }};// list of standard refresh ratesstruct {	int refresh;} refresh_list[] = {	{56}, {60}, {70}, {72}, {75}};// list of combine modesstruct {	CombineMode mode;	const char *name;} combine_list[] = {	{ cb_disable, "disable" },	{ cb_horizontally, "horizontally" },	{ cb_vertically, "vertically" }};// define to use fixed standard refresh rates// undefine to get standard refresh rates from driver#define USE_FIXED_REFRESHstatic CombineMode getCombineMode( display_mode *mode ){	if( mode->flags & B_SCROLL == 0 )		return cb_disable;			if( mode->virtual_width == mode->timing.h_display * 2 )		return cb_horizontally;	if( mode->virtual_height == mode->timing.v_display * 2 )		return cb_vertically;			return cb_disable;}// helper to sort modes by resolutionstatic int compare_mode( const void *op1, const void *op2 ){	display_mode		*mode1 = (display_mode *)op1,		*mode2 = (display_mode *)op2;	CombineMode combine1, combine2;	uint16 width1, width2, height1, height2;		combine1 = getCombineMode( mode1 );	combine2 = getCombineMode( mode2 );		width1 = mode1->virtual_width;	height1 = mode1->virtual_height;	width2 = mode2->virtual_width;	height2 = mode2->virtual_height;		if( combine1 == cb_horizontally )		width1 /= 2;	if( combine1 == cb_vertically )		height1 /= 2;	if( combine2 == cb_horizontally )		width2 /= 2;	if( combine2 == cb_vertically )		height2 /= 2;	if( width1 != width2 )		return width1 - width2;	if( height1 != height2 )		return height1 - height2;			return ScreenWindow::getModeRefresh10( mode1 ) - 		ScreenWindow::getModeRefresh10( mode2 );}BString TVStandard2Name(	uint32 mode ){	switch( mode ) {	case 0:	return "disabled";	case 1:	return "NTSC";	case 2:	return "NTSC Japan";	case 3:	return "PAL BDGHI";	case 4:	return "PAL M";	case 5:	return "PAL N";	case 6:	return "SECAM";	case 101:	return "NTSC 443";	case 102:	return "PAL 60";	case 103:	return "PAL NC";	default:	{		BString res;				res << "??? (" << mode << ")";				return res; }	}}// create all elements of main windowScreenWindow::ScreenWindow(ScreenSettings *Settings)	: BWindow(Settings->WindowFrame(), "Radeon Screen", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES){	BScreen screen( this );	BRect frame = Bounds();		BView *view;		view = new BView( frame, "ScreenView", B_FOLLOW_ALL, B_WILL_DRAW );	view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ));	AddChild( view );		fSettings = Settings;	fChangingAllWorkspaces = false;		BRect ButtonRect;	// area with screen preview and workspace count		{		BRect ScreenBoxRect;		BRect ScreenDrawViewRect;		BRect WorkspaceCountMenuRect;				ScreenBoxRect.Set(11.0, 18.0, 153.0, 155.0);				fScreenBox = new BBox(ScreenBoxRect);		fScreenBox->SetBorder(B_FANCY_BORDER);				ScreenDrawViewRect.Set(20.0, 16.0, 122.0, 93.0);				fScreenDrawView = new ScreenDrawView(ScreenDrawViewRect, "ScreenDrawView");				int32 Count;				BString String;				String << count_workspaces();				fWorkspaceCountMenu = new BPopUpMenu(String.String(), true, true);		for (Count = 1; Count <= 32; Count++)		{			String.Truncate(0);			String << Count;			fWorkspaceCountMenu->AddItem(new BMenuItem(String.String(), new BMessage(POP_WORKSPACE_CHANGED_MSG)));		}				String.Truncate(0);		String << count_workspaces();				BMenuItem *Marked = fWorkspaceCountMenu->FindItem(String.String());		Marked->SetMarked(true);				WorkspaceCountMenuRect.Set(7.0, 107.0, 135.0, 127.0);				fWorkspaceCountField = new BMenuField(WorkspaceCountMenuRect, "WorkspaceCountMenu", "Workspace count:", fWorkspaceCountMenu, true);				fWorkspaceCountField->SetDivider(91.0);				fScreenBox->AddChild(fScreenDrawView);				fScreenBox->AddChild(fWorkspaceCountField);				view->AddChild(fScreenBox);	}			// area with screen resolution etc.	{		BRect ControlsBoxRect;		BRect WorkspaceMenuRect;		BRect ControlMenuRect;		fWorkspaceMenu = new BPopUpMenu("Current Workspace", true, true);		fAllWorkspacesItem = new BMenuItem("All Workspaces", new BMessage(WORKSPACE_CHECK_MSG));		fWorkspaceMenu->AddItem(fAllWorkspacesItem);		fCurrentWorkspaceItem = new BMenuItem("Current Workspace", new BMessage(WORKSPACE_CHECK_MSG));		fCurrentWorkspaceItem->SetMarked(true);		fWorkspaceMenu->AddItem(fCurrentWorkspaceItem);				WorkspaceMenuRect.Set(0.0, 0.0, 132.0, 18.0);				fWorkspaceField = new BMenuField(WorkspaceMenuRect, "WorkspaceMenu", NULL, fWorkspaceMenu, true);				ControlsBoxRect.Set(164.0, 7.0, 345.0, 155.0);				fControlsBox = new BBox(ControlsBoxRect);		fControlsBox->SetBorder(B_FANCY_BORDER);		fControlsBox->SetLabel(fWorkspaceField);				ButtonRect.Set(88.0, 114.0, 200.0, 150.0);				fApplyButton = new BButton(ButtonRect, "ApplyButton", "Apply", 		new BMessage(BUTTON_APPLY_MSG));				fApplyButton->AttachedToWindow();		fApplyButton->ResizeToPreferred();		fApplyButton->SetEnabled(false);				fControlsBox->AddChild(fApplyButton);				screen.GetModeList( &fModeList, &fModeListCount );			// sort modes by resolution and refresh to make 		// the resolution and refresh menu look nicer		qsort( fModeList, fModeListCount, sizeof( fModeList[0] ), compare_mode );				fResolutionMenu = new BPopUpMenu("", true, true);				uint16 prev_width, prev_height;		uint i;					prev_width = 0;		prev_height = 0;				for( i = 0; i < fModeListCount; ++i ) {			uint16 width, height;			CombineMode combine;						width = fModeList[i].virtual_width;			height = fModeList[i].virtual_height;						combine = getCombineMode( &fModeList[i] );						if( combine == cb_horizontally )				width /= 2;			if( combine == cb_vertically )				height /= 2;						if( width != prev_width || height != prev_height )			{				BString name;				BMessage *msg;								prev_width = width;				prev_height = height;								name << (uint)width << " x " << (uint)height;								msg = new BMessage( POP_RESOLUTION_MSG );				msg->AddInt32( "width", width );				msg->AddInt32( "height", height );								fResolutionMenu->AddItem( new BMenuItem( name.String(), msg ));			}		}			ControlMenuRect.Set(33.0, 30.0, 171.0, 48.0);				fResolutionField = new BMenuField(ControlMenuRect, "ResolutionMenu", "Resolution:", fResolutionMenu, true);				fResolutionField->SetDivider(55.0);				fControlsBox->AddChild(fResolutionField);				fColorsMenu = new BPopUpMenu("", true, true);					for( i = 0; i < sizeof( bpp_list ) / sizeof( bpp_list[0] ); ++i ) {			BString name;			BMessage *msg;						name << bpp_list[i].bpp << " Bits/Pixel";						msg = new BMessage( POP_COLORS_MSG );			msg->AddInt32( "bpp", bpp_list[i].bpp );			msg->AddInt32( "space", bpp_list[i].space );						fColorsMenu->AddItem( new BMenuItem( name.String(), msg ));		}					ControlMenuRect.Set(50.0, 58.0, 171.0, 76.0);				fColorsField = new BMenuField(ControlMenuRect, "ColorsMenu", "Colors:", fColorsMenu, true);				fColorsField->SetDivider(38.0);				fControlsBox->AddChild(fColorsField);						fRefreshMenu = new BPopUpMenu("", true, true);			#ifdef USE_FIXED_REFRESH		for( i = 0; i < sizeof( refresh_list ) / sizeof( refresh_list[0] ); ++i ) {			BString name;			BMessage *msg;						name << refresh_list[i].refresh << " Hz";						msg = new BMessage( POP_REFRESH_MSG );			msg->AddInt32( "refresh10", refresh_list[i].refresh * 10 );						fRefreshMenu->AddItem( new BMenuItem( name.String(), msg ));		}	#endif			BMessage *msg;				msg = new BMessage( POP_OTHER_REFRESH_MSG );		msg->AddInt32( "refresh10", 0 );				fOtherRefresh = new BMenuItem( "Other...", msg );		fRefreshMenu->AddItem( fOtherRefresh );			ControlMenuRect.Set(19.0, 86.0, 171.0, 104.0);				fRefreshField = new BMenuField(ControlMenuRect, "RefreshMenu", "Refresh Rate:", fRefreshMenu, true);				fRefreshField->SetDivider(69.0);				fControlsBox->AddChild(fRefreshField);				view->AddChild(fControlsBox);	}			// enlarged area for multi-monitor settings	{		BRect rect;		BMenuField *menuField;		BMenuItem *item;		BMessage *msg;		uint i;		bool dummy;		uint32 dummy32;		bool multiMonSupport;		bool useLaptopPanelSupport;		bool tvStandardSupport;		multiMonSupport = TestMultiMonSupport( &screen ) == B_OK;		useLaptopPanelSupport = GetUseLaptopPanel( &screen, &dummy ) == B_OK;		tvStandardSupport = GetTVStandard( &screen, &dummy32 ) == B_OK;				// even if there is no support, we still create all controls		// to make sure we don't access NULL pointers later on		if( multiMonSupport ) {			fApplyButton->MoveTo( 275, 114 );			fControlsBox->ResizeTo( 366, 148 );					ResizeTo( 556, 202 );		}				fCombineMenu = new BPopUpMenu( "CombineDisplays", true, true );		for( i = 0; i < sizeof( combine_list ) / sizeof( combine_list[0] ); ++i ) {			BMessage *msg;			BMenuItem *item;						msg = new BMessage( POP_COMBINE_DISPLAYS_MSG );			msg->AddInt32( "mode", combine_list[i].mode );			item = new BMenuItem( combine_list[i].name, msg );			fCombineMenu->AddItem( item );		}				rect.Set( 185, 30, 356, 48 );		menuField = new BMenuField( rect, "CombineMenu", "Combine Displays:", 			fCombineMenu, true );		menuField->SetDivider( 90 );				fControlsBox->AddChild( menuField );		if( !multiMonSupport )			menuField->Hide();		fSwapDisplaysMenu = new BPopUpMenu( "SwapDisplays", true, true );		// !order is important - we rely that boolean value == idx		msg = new BMessage( POP_SWAP_DISPLAYS_MSG );		msg->AddBool( "swap", false );		item = new BMenuItem( "no", msg );		fSwapDisplaysMenu->AddItem( item );					msg = new BMessage( POP_SWAP_DISPLAYS_MSG );		msg->AddBool( "swap", true );		item = new BMenuItem( "yes", msg );		fSwapDisplaysMenu->AddItem( item );				rect.Set( 199, 58, 356, 76 );		menuField = new BMenuField( rect, "SwapMenu", "Swap Displays:", 			fSwapDisplaysMenu, true );		menuField->SetDivider( 76 );		fControlsBox->AddChild( menuField );		if( !multiMonSupport )			menuField->Hide();		fUseLaptopPanelMenu = new BPopUpMenu( "UseLaptopPanel", true, true );		// !order is important - we rely that boolean value == idx					msg = new BMessage( POP_USE_LAPTOP_PANEL_MSG );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -