2002-11-24 00:26:55 +00:00
|
|
|
#include <Alert.h>
|
2002-07-09 12:24:59 +00:00
|
|
|
#include <Application.h>
|
|
|
|
|
#include <Button.h>
|
2002-11-24 00:26:55 +00:00
|
|
|
#include <InterfaceDefs.h>
|
|
|
|
|
#include <Menu.h>
|
|
|
|
|
#include <MenuItem.h>
|
|
|
|
|
#include <Messenger.h>
|
2002-07-09 12:24:59 +00:00
|
|
|
#include <String.h>
|
|
|
|
|
#include <Screen.h>
|
2002-11-24 00:26:55 +00:00
|
|
|
#include <Window.h>
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
2002-07-09 12:24:59 +00:00
|
|
|
#include <cstring>
|
|
|
|
|
#include <cstdlib>
|
2002-11-27 15:45:32 +00:00
|
|
|
#include <cstdio>
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
#include "ScreenWindow.h"
|
|
|
|
|
#include "ScreenDrawView.h"
|
|
|
|
|
#include "ScreenView.h"
|
|
|
|
|
#include "AlertWindow.h"
|
|
|
|
|
#include "Constants.h"
|
2002-11-24 00:26:55 +00:00
|
|
|
#include "Utility.h"
|
|
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
|
|
|
|
: BWindow(Settings->WindowFrame(), "Screen", B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES)
|
|
|
|
|
{
|
2002-11-24 00:26:55 +00:00
|
|
|
BRect frame(Bounds());
|
|
|
|
|
BScreen screen(B_MAIN_SCREEN_ID);
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
if (!screen.IsValid())
|
|
|
|
|
;//debugger() ?
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
screen.GetModeList(&fSupportedModes, &fTotalModes);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fScreenView = new ScreenView(frame, "ScreenView");
|
|
|
|
|
AddChild(fScreenView);
|
|
|
|
|
|
|
|
|
|
fSettings = Settings;
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BRect ScreenBoxRect(11.0, 18.0, 153.0, 155.0);
|
|
|
|
|
BRect ScreenDrawViewRect(20.0, 16.0, 122.0, 93.0);
|
2002-07-09 12:24:59 +00:00
|
|
|
BRect ControlsBoxRect;
|
|
|
|
|
BRect WorkspaceMenuRect;
|
|
|
|
|
BRect WorkspaceCountMenuRect;
|
|
|
|
|
BRect ControlMenuRect;
|
|
|
|
|
BRect ButtonRect;
|
2003-06-06 08:48:56 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
fScreenBox = new BBox(ScreenBoxRect);
|
|
|
|
|
fScreenBox->SetBorder(B_FANCY_BORDER);
|
2003-06-06 08:48:56 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
fScreenDrawView = new ScreenDrawView(ScreenDrawViewRect, "ScreenDrawView");
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BString string;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string << count_workspaces();
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fWorkspaceCountMenu = new BPopUpMenu(string.String(), true, true);
|
2002-11-24 00:26:55 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
for (int32 count = 1; count <= 32; count++) {
|
|
|
|
|
string.Truncate(0);
|
|
|
|
|
string << count;
|
|
|
|
|
fWorkspaceCountMenu->AddItem(new BMenuItem(string.String(), new BMessage(POP_WORKSPACE_CHANGED_MSG)));
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string.Truncate(0);
|
|
|
|
|
string << count_workspaces();
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BMenuItem *marked = fWorkspaceCountMenu->FindItem(string.String());
|
|
|
|
|
marked->SetMarked(true);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
WorkspaceCountMenuRect.Set(7.0, 107.0, 135.0, 127.0);
|
|
|
|
|
|
|
|
|
|
fWorkspaceCountField = new BMenuField(WorkspaceCountMenuRect, "WorkspaceCountMenu", "Workspace count:", fWorkspaceCountMenu, true);
|
|
|
|
|
|
|
|
|
|
fWorkspaceCountField->SetDivider(91.0);
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fScreenBox->AddChild(fScreenDrawView);
|
|
|
|
|
fScreenBox->AddChild(fWorkspaceCountField);
|
2002-07-09 12:24:59 +00:00
|
|
|
fScreenView->AddChild(fScreenBox);
|
|
|
|
|
|
|
|
|
|
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",
|
2003-06-06 08:48:56 +00:00
|
|
|
new BMessage(BUTTON_APPLY_MSG));
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fApplyButton->AttachedToWindow();
|
|
|
|
|
fApplyButton->ResizeToPreferred();
|
|
|
|
|
fApplyButton->SetEnabled(false);
|
|
|
|
|
|
|
|
|
|
fControlsBox->AddChild(fApplyButton);
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fResolutionMenu = new BPopUpMenu("", true, true);
|
2002-11-24 00:26:55 +00:00
|
|
|
for (uint32 c = 0; c < fTotalModes; c++) {
|
|
|
|
|
BString mode;
|
|
|
|
|
mode << (int32)fSupportedModes[c].virtual_width << " x " << (int32)fSupportedModes[c].virtual_height;
|
|
|
|
|
if (!fResolutionMenu->FindItem(mode.String()))
|
|
|
|
|
fResolutionMenu->AddItem(new BMenuItem(mode.String(),
|
|
|
|
|
new BMessage(POP_RESOLUTION_MSG)));
|
|
|
|
|
}
|
2002-07-09 12:24:59 +00:00
|
|
|
ControlMenuRect.Set(33.0, 30.0, 171.0, 48.0);
|
|
|
|
|
|
|
|
|
|
fResolutionField = new BMenuField(ControlMenuRect, "ResolutionMenu", "Resolution:", fResolutionMenu, true);
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
marked = fResolutionMenu->ItemAt(0);
|
|
|
|
|
marked->SetMarked(true);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fResolutionField->SetDivider(55.0);
|
|
|
|
|
|
|
|
|
|
fControlsBox->AddChild(fResolutionField);
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fColorsMenu = new BPopUpMenu("", true, true);
|
2002-12-04 14:26:01 +00:00
|
|
|
|
|
|
|
|
// Get the supported colorspaces
|
|
|
|
|
for (uint32 c = 0; c < fTotalModes; c++) {
|
|
|
|
|
BString colorSpace;
|
|
|
|
|
switch (fSupportedModes[c].space) {
|
|
|
|
|
case B_CMAP8:
|
|
|
|
|
colorSpace = "8 Bits/Pixel";
|
|
|
|
|
break;
|
|
|
|
|
case B_RGB15:
|
|
|
|
|
colorSpace = "15 Bits/Pixel";
|
|
|
|
|
break;
|
|
|
|
|
case B_RGB16:
|
|
|
|
|
colorSpace = "16 Bits/Pixel";
|
|
|
|
|
break;
|
|
|
|
|
case B_RGB32:
|
|
|
|
|
colorSpace = "32 Bits/Pixel";
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-06-06 08:48:56 +00:00
|
|
|
|
2002-12-04 14:26:01 +00:00
|
|
|
if (!fColorsMenu->FindItem(colorSpace.String()))
|
|
|
|
|
fColorsMenu->AddItem(new BMenuItem(colorSpace.String(),
|
2003-06-06 08:48:56 +00:00
|
|
|
new BMessage(POP_COLORS_MSG)));
|
2002-12-04 14:26:01 +00:00
|
|
|
}
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
ControlMenuRect.Set(50.0, 58.0, 171.0, 76.0);
|
|
|
|
|
|
|
|
|
|
fColorsField = new BMenuField(ControlMenuRect, "ColorsMenu", "Colors:", fColorsMenu, true);
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
marked = fColorsMenu->ItemAt(0);
|
|
|
|
|
marked->SetMarked(true);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fColorsField->SetDivider(38.0);
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
fControlsBox->AddChild(fColorsField);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fRefreshMenu = new BPopUpMenu("", true, true);
|
2002-07-09 12:24:59 +00:00
|
|
|
fRefreshMenu->AddItem(new BMenuItem("56 Hz", new BMessage(POP_REFRESH_MSG)));
|
|
|
|
|
fRefreshMenu->AddItem(new BMenuItem("60 Hz", new BMessage(POP_REFRESH_MSG)));
|
|
|
|
|
fRefreshMenu->AddItem(new BMenuItem("70 Hz", new BMessage(POP_REFRESH_MSG)));
|
|
|
|
|
fRefreshMenu->AddItem(new BMenuItem("72 Hz", new BMessage(POP_REFRESH_MSG)));
|
|
|
|
|
fRefreshMenu->AddItem(new BMenuItem("75 Hz", new BMessage(POP_REFRESH_MSG)));
|
|
|
|
|
fRefreshMenu->AddItem(new BMenuItem("Other...", new BMessage(POP_OTHER_REFRESH_MSG)));
|
2002-12-04 14:26:01 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
ControlMenuRect.Set(19.0, 86.0, 171.0, 104.0);
|
|
|
|
|
|
|
|
|
|
fRefreshField = new BMenuField(ControlMenuRect, "RefreshMenu", "Refresh Rate:", fRefreshMenu, true);
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
marked = fRefreshMenu->FindItem("60 Hz");
|
|
|
|
|
marked->SetMarked(true);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fRefreshField->SetDivider(69.0);
|
|
|
|
|
|
|
|
|
|
fControlsBox->AddChild(fRefreshField);
|
|
|
|
|
|
|
|
|
|
fScreenView->AddChild(fControlsBox);
|
|
|
|
|
|
|
|
|
|
ButtonRect.Set(10.0, 167, 100.0, 200.0);
|
|
|
|
|
|
|
|
|
|
fDefaultsButton = new BButton(ButtonRect, "DefaultsButton", "Defaults",
|
2002-11-24 00:26:55 +00:00
|
|
|
new BMessage(BUTTON_DEFAULTS_MSG));
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fDefaultsButton->AttachedToWindow();
|
|
|
|
|
fDefaultsButton->ResizeToPreferred();
|
|
|
|
|
|
|
|
|
|
fScreenView->AddChild(fDefaultsButton);
|
|
|
|
|
|
|
|
|
|
ButtonRect.Set(95.0, 167, 160.0, 200.0);
|
|
|
|
|
|
|
|
|
|
fRevertButton = new BButton(ButtonRect, "RevertButton", "Revert",
|
2002-11-24 00:26:55 +00:00
|
|
|
new BMessage(BUTTON_REVERT_MSG));
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fRevertButton->AttachedToWindow();
|
|
|
|
|
fRevertButton->ResizeToPreferred();
|
|
|
|
|
fRevertButton->SetEnabled(false);
|
|
|
|
|
|
|
|
|
|
fScreenView->AddChild(fRevertButton);
|
2002-11-24 00:26:55 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
display_mode mode;
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
screen.GetMode(&mode);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fInitialMode = mode;
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string.Truncate(0);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string << (uint32)mode.virtual_width << " x " << (uint32)mode.virtual_height;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
marked = fResolutionMenu->FindItem(string.String());
|
|
|
|
|
marked->SetMarked(true);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fInitialResolution = marked;
|
2002-11-24 00:26:55 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
switch (mode.space) {
|
|
|
|
|
case B_RGB32:
|
|
|
|
|
marked = fColorsMenu->FindItem("32 Bits/Pixel");
|
|
|
|
|
break;
|
2002-11-24 00:26:55 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
case B_RGB16:
|
|
|
|
|
marked = fColorsMenu->FindItem("16 Bits/Pixel");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case B_RGB15:
|
|
|
|
|
marked = fColorsMenu->FindItem("15 Bits/Pixel");
|
|
|
|
|
break;
|
2002-11-24 00:26:55 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
case B_CMAP8:
|
|
|
|
|
default:
|
|
|
|
|
marked = fColorsMenu->FindItem("8 Bits/Pixel");
|
|
|
|
|
break;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
marked->SetMarked(true);
|
|
|
|
|
fInitialColors = marked;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string.Truncate(0);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
float total_size = mode.timing.h_total * mode.timing.v_total;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
fInitialRefreshN = round((mode.timing.pixel_clock * 1000) / total_size, 1);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fCustomRefresh = fInitialRefreshN;
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string << fInitialRefreshN << " Hz";
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
marked = fRefreshMenu->FindItem(string.String());
|
2002-12-04 14:26:01 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
if (marked != NULL) {
|
2002-12-04 14:26:01 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
marked->SetMarked(true);
|
|
|
|
|
fInitialRefresh = marked;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-12-04 14:26:01 +00:00
|
|
|
} else {
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BMenuItem *other = fRefreshMenu->FindItem("Other...");
|
|
|
|
|
string.Truncate(0);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string << fInitialRefreshN;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
int32 point = string.FindFirst('.');
|
|
|
|
|
string.Truncate(point + 2);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string << " Hz/Other...";
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
other->SetLabel(string.String());
|
|
|
|
|
other->SetMarked(true);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
point = string.FindFirst('/');
|
|
|
|
|
string.Truncate(point);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fRefreshMenu->Superitem()->SetLabel(string.String());
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fInitialRefresh = other;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScreenWindow::~ScreenWindow()
|
|
|
|
|
{
|
|
|
|
|
delete fSettings;
|
2002-11-24 00:26:55 +00:00
|
|
|
delete[] fSupportedModes;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
ScreenWindow::QuitRequested()
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
|
be_app->PostMessage(B_QUIT_REQUESTED);
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
return BWindow::QuitRequested();
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ScreenWindow::FrameMoved(BPoint position)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
|
fSettings->SetWindowFrame(Frame());
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ScreenWindow::ScreenChanged(BRect frame, color_space mode)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
|
if (frame.right <= Frame().right
|
|
|
|
|
&& frame.bottom <= Frame().bottom)
|
|
|
|
|
MoveTo(((frame.right / 2) - 178), ((frame.right / 2) - 101));
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ScreenWindow::WorkspaceActivated(int32 ws, bool state)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
|
PostMessage(new BMessage(UPDATE_DESKTOP_COLOR_MSG), fScreenDrawView);
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ScreenWindow::CheckApplyEnabled()
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
|
int equals = 0;
|
|
|
|
|
|
|
|
|
|
if (fResolutionMenu->FindMarked() == fInitialResolution)
|
2002-11-24 00:26:55 +00:00
|
|
|
equals++;
|
2002-07-09 12:24:59 +00:00
|
|
|
else
|
2002-11-24 00:26:55 +00:00
|
|
|
equals--;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
if (fColorsMenu->FindMarked() == fInitialColors)
|
2002-11-24 00:26:55 +00:00
|
|
|
equals++;
|
2002-07-09 12:24:59 +00:00
|
|
|
else
|
2002-11-24 00:26:55 +00:00
|
|
|
equals--;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
if (fRefreshMenu->FindMarked() == fInitialRefresh)
|
2002-11-24 00:26:55 +00:00
|
|
|
equals++;
|
2002-07-09 12:24:59 +00:00
|
|
|
else
|
2002-11-24 00:26:55 +00:00
|
|
|
equals--;
|
|
|
|
|
|
2002-12-04 14:26:01 +00:00
|
|
|
if(equals != 3) {
|
2002-07-09 12:24:59 +00:00
|
|
|
fApplyButton->SetEnabled(true);
|
|
|
|
|
fRevertButton->SetEnabled(true);
|
2002-11-24 00:26:55 +00:00
|
|
|
} else {
|
2002-07-09 12:24:59 +00:00
|
|
|
fApplyButton->SetEnabled(false);
|
|
|
|
|
fRevertButton->SetEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ScreenWindow::MessageReceived(BMessage* message)
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
|
switch(message->what)
|
|
|
|
|
{
|
|
|
|
|
case WORKSPACE_CHECK_MSG:
|
|
|
|
|
{
|
|
|
|
|
fApplyButton->SetEnabled(true);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case POP_WORKSPACE_CHANGED_MSG:
|
|
|
|
|
{
|
|
|
|
|
BMenuItem *Item = fWorkspaceCountMenu->FindMarked();
|
|
|
|
|
|
|
|
|
|
set_workspace_count(fWorkspaceCountMenu->IndexOf(Item) + 1);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case POP_RESOLUTION_MSG:
|
|
|
|
|
{
|
|
|
|
|
CheckApplyEnabled();
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BMessage *newMessage = new BMessage(UPDATE_DESKTOP_MSG);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
const char *resolution = fResolutionMenu->FindMarked()->Label();
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
newMessage->AddString("resolution", resolution);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
PostMessage(newMessage, fScreenDrawView);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case POP_COLORS_MSG:
|
|
|
|
|
{
|
|
|
|
|
CheckApplyEnabled();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case POP_REFRESH_MSG:
|
|
|
|
|
{
|
2003-06-06 08:48:56 +00:00
|
|
|
CheckApplyEnabled();
|
2002-07-09 12:24:59 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case POP_OTHER_REFRESH_MSG:
|
|
|
|
|
{
|
2003-06-06 08:48:56 +00:00
|
|
|
BRect frame(Frame());
|
|
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
CheckApplyEnabled();
|
2002-11-24 00:26:55 +00:00
|
|
|
int32 value = (int32)(fCustomRefresh * 10);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
RefreshWindow *fRefreshWindow = new RefreshWindow(BRect((frame.left + 201.0),
|
|
|
|
|
(frame.top + 34.0), (frame.left + 509.0),
|
|
|
|
|
(frame.top + 169.0)), value);
|
|
|
|
|
fRefreshWindow->Show();
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BString string;
|
|
|
|
|
|
|
|
|
|
string << other->Label();
|
|
|
|
|
|
|
|
|
|
int32 point = string.FindFirst('z');
|
|
|
|
|
string.Truncate(point + 1);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fRefreshMenu->Superitem()->SetLabel(string.String());
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case BUTTON_DEFAULTS_MSG:
|
|
|
|
|
{
|
2002-11-27 14:41:16 +00:00
|
|
|
fResolutionMenu->ItemAt(0)->SetMarked(true);
|
2002-07-09 12:24:59 +00:00
|
|
|
fColorsMenu->FindItem("8 Bits/Pixel")->SetMarked(true);
|
|
|
|
|
fRefreshMenu->FindItem("60 Hz")->SetMarked(true);
|
|
|
|
|
|
|
|
|
|
CheckApplyEnabled();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case BUTTON_REVERT_MSG:
|
2002-11-27 15:45:32 +00:00
|
|
|
case SET_INITIAL_MODE_MSG:
|
2002-07-09 12:24:59 +00:00
|
|
|
{
|
|
|
|
|
fInitialResolution->SetMarked(true);
|
|
|
|
|
fInitialColors->SetMarked(true);
|
|
|
|
|
fInitialRefresh->SetMarked(true);
|
|
|
|
|
|
|
|
|
|
CheckApplyEnabled();
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
if (fInitialRefresh == other) {
|
2002-11-26 06:21:36 +00:00
|
|
|
BString string;
|
2002-11-24 00:26:55 +00:00
|
|
|
string << fInitialRefreshN;
|
2002-11-26 06:21:36 +00:00
|
|
|
|
|
|
|
|
int32 point = string.FindFirst('.');
|
|
|
|
|
string.Truncate(point + 2);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
string << " Hz/Other...";
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(string.String());
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-26 06:21:36 +00:00
|
|
|
point = string.FindFirst('/');
|
|
|
|
|
string.Truncate(point);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
fRefreshMenu->Superitem()->SetLabel(string.String());
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
if (message->what == SET_INITIAL_MODE_MSG) {
|
|
|
|
|
|
2002-11-27 15:45:32 +00:00
|
|
|
BScreen screen(B_MAIN_SCREEN_ID);
|
|
|
|
|
if (!screen.IsValid())
|
|
|
|
|
break;
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
screen.SetMode(&fInitialMode, true);
|
2002-11-27 15:45:32 +00:00
|
|
|
}
|
2002-07-09 12:24:59 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case BUTTON_APPLY_MSG:
|
|
|
|
|
{
|
2002-11-24 00:26:55 +00:00
|
|
|
BScreen screen(B_MAIN_SCREEN_ID);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
if (!screen.IsValid())
|
|
|
|
|
break;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
display_mode *mode = NULL;
|
|
|
|
|
BString string;
|
|
|
|
|
int32 height;
|
|
|
|
|
int32 width;
|
|
|
|
|
float refresh;
|
|
|
|
|
|
|
|
|
|
BString menuLabel = fResolutionMenu->FindMarked()->Label();
|
|
|
|
|
int32 space = menuLabel.FindFirst(' ');
|
|
|
|
|
menuLabel.MoveInto(string, 0, space);
|
2002-11-26 06:21:36 +00:00
|
|
|
menuLabel.Remove(0, 3);
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
width = atoi(string.String());
|
|
|
|
|
height = atoi(menuLabel.String());
|
2002-11-26 06:21:36 +00:00
|
|
|
|
|
|
|
|
if (fRefreshMenu->FindMarked() == fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG))
|
|
|
|
|
refresh = fCustomRefresh;
|
|
|
|
|
else
|
|
|
|
|
refresh = atof(fRefreshMenu->FindMarked()->Label());
|
2002-11-24 00:26:55 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
for (uint32 c = 0; c < fTotalModes; c++) {
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
if ((fSupportedModes[c].virtual_width == width)
|
|
|
|
|
&& (fSupportedModes[c].virtual_height == height))
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
mode = &fSupportedModes[c];
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-26 06:21:36 +00:00
|
|
|
mode->timing.pixel_clock = (uint32)((mode->timing.h_total * mode->timing.v_total) * refresh / 1000);
|
|
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("8 Bits/Pixel"))
|
2002-07-09 12:24:59 +00:00
|
|
|
mode->space = B_CMAP8;
|
2003-06-06 08:48:56 +00:00
|
|
|
else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("15 Bits/Pixel"))
|
2002-07-09 12:24:59 +00:00
|
|
|
mode->space = B_RGB15;
|
2003-06-06 08:48:56 +00:00
|
|
|
else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("16 Bits/Pixel"))
|
2002-07-09 12:24:59 +00:00
|
|
|
mode->space = B_RGB16;
|
|
|
|
|
else if (fColorsMenu->FindMarked() == fColorsMenu->FindItem("32 Bits/Pixel"))
|
|
|
|
|
mode->space = B_RGB32;
|
|
|
|
|
|
|
|
|
|
mode->h_display_start = 0;
|
|
|
|
|
mode->v_display_start = 0;
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
if (fWorkspaceMenu->FindMarked() == fWorkspaceMenu->FindItem("All Workspaces")) {
|
|
|
|
|
BAlert *WorkspacesAlert =
|
|
|
|
|
new BAlert("WorkspacesAlert", "Change all workspaces?\nThis action cannot be reverted",
|
|
|
|
|
"Okay", "Cancel", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
2002-11-26 06:21:36 +00:00
|
|
|
|
|
|
|
|
int32 button = WorkspacesAlert->Go();
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
if (button == 1)
|
|
|
|
|
break;
|
|
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
int32 old = current_workspace();
|
|
|
|
|
int32 totalWorkspaces = count_workspaces();
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
for (int32 count = 0; count < totalWorkspaces; count ++) {
|
2002-07-09 12:24:59 +00:00
|
|
|
activate_workspace(count);
|
2002-12-04 14:26:01 +00:00
|
|
|
screen.SetMode(mode, true);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activate_workspace(old);
|
|
|
|
|
}
|
|
|
|
|
else
|
2002-11-24 00:26:55 +00:00
|
|
|
screen.SetMode(mode);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BRect rect(100.0, 100.0, 400.0, 193.0);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
rect.left = (screen.Frame().right / 2) - 150;
|
|
|
|
|
rect.top = (screen.Frame().bottom / 2) - 42;
|
|
|
|
|
rect.right = rect.left + 300.0;
|
|
|
|
|
rect.bottom = rect.top + 93.0;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
(new AlertWindow(rect))->Show();
|
2002-12-04 14:26:01 +00:00
|
|
|
|
2002-11-24 00:26:55 +00:00
|
|
|
fApplyButton->SetEnabled(false);
|
|
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case SET_CUSTOM_REFRESH_MSG:
|
|
|
|
|
{
|
|
|
|
|
message->FindFloat("refresh", &fCustomRefresh);
|
|
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
other->SetMarked(true);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
BString string;
|
|
|
|
|
string << fCustomRefresh;
|
|
|
|
|
int32 point = string.FindFirst('.');
|
|
|
|
|
string.Truncate(point + 2);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
string << " Hz/Other...";
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(string.String());
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
point = string.FindFirst('/');
|
|
|
|
|
string.Truncate(point);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
fRefreshMenu->Superitem()->SetLabel(string.String());
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2003-06-06 08:48:56 +00:00
|
|
|
if (fCustomRefresh != fInitialRefreshN) {
|
2002-07-09 12:24:59 +00:00
|
|
|
fApplyButton->SetEnabled(true);
|
|
|
|
|
fRevertButton->SetEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case MAKE_INITIAL_MSG:
|
|
|
|
|
{
|
2002-11-27 14:41:16 +00:00
|
|
|
BScreen screen(B_MAIN_SCREEN_ID);
|
|
|
|
|
if (!screen.IsValid())
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
display_mode mode;
|
2002-11-24 00:26:55 +00:00
|
|
|
screen.GetMode(&mode);
|
2002-12-04 14:26:01 +00:00
|
|
|
screen.SetMode(&mode, true);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
|
fInitialRefreshN = fCustomRefresh;
|
|
|
|
|
fInitialResolution = fResolutionMenu->FindMarked();
|
|
|
|
|
fInitialColors = fColorsMenu->FindMarked();
|
|
|
|
|
fInitialRefresh = fRefreshMenu->FindMarked();
|
|
|
|
|
fInitialMode = mode;
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
2002-11-24 00:26:55 +00:00
|
|
|
BWindow::MessageReceived(message);
|
2002-07-09 12:24:59 +00:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|