Redone ScreenDrawView to something better, also it's now called MonitorView.
Accidently, Thomas seems to have done almost all changes I wanted to apply here, anyway, in his RadeonScreen version (which is a lot cleaner than what we have here). More to come later. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13217 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
SubDir OBOS_TOP src prefs screen ;
|
||||
|
||||
SubDirC++Flags [ FDefines BEOS_R5_COMPATIBLE ] ;
|
||||
|
||||
Preference Screen :
|
||||
AlertView.cpp
|
||||
AlertWindow.cpp
|
||||
@@ -9,11 +7,10 @@ Preference Screen :
|
||||
RefreshView.cpp
|
||||
RefreshWindow.cpp
|
||||
Screen.cpp
|
||||
ScreenDrawView.cpp
|
||||
MonitorView.cpp
|
||||
ScreenSettings.cpp
|
||||
ScreenWindow.cpp
|
||||
Utility.cpp
|
||||
: libbe.so
|
||||
: Screen.rdef
|
||||
;
|
||||
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Copyright 2002, Thomas Kurschel.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Thomas Kurschel
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
#include "MonitorView.h"
|
||||
#include "Constants.h"
|
||||
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
|
||||
|
||||
MonitorView::MonitorView(BRect rect, char *name, int32 width, int32 height)
|
||||
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
|
||||
fWidth(width),
|
||||
fHeight(height)
|
||||
{
|
||||
BScreen screen(B_MAIN_SCREEN_ID);
|
||||
fDesktopColor = screen.DesktopColor(current_workspace());
|
||||
}
|
||||
|
||||
|
||||
MonitorView::~MonitorView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MonitorView::AttachedToWindow()
|
||||
{
|
||||
if (Parent())
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
else
|
||||
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MonitorView::MouseDown(BPoint point)
|
||||
{
|
||||
be_roster->Launch("application/x-vnd.Be-BACK");
|
||||
}
|
||||
|
||||
|
||||
BRect
|
||||
MonitorView::MonitorBounds()
|
||||
{
|
||||
float maxWidth, maxHeight;
|
||||
float picWidth, picHeight;
|
||||
|
||||
maxWidth = Bounds().Width();
|
||||
maxHeight = Bounds().Height();
|
||||
|
||||
picWidth = maxWidth * fWidth / 1600;
|
||||
picHeight = maxHeight * fHeight / 1200;
|
||||
|
||||
if (picWidth > maxWidth) {
|
||||
picHeight = picHeight * maxWidth / picWidth;
|
||||
picWidth = maxWidth;
|
||||
}
|
||||
|
||||
if (picHeight > maxHeight) {
|
||||
picWidth = picWidth * maxHeight / picHeight;
|
||||
picHeight = maxHeight;
|
||||
}
|
||||
|
||||
return BRect((maxWidth - picWidth) / 2, (maxHeight - picHeight) / 2,
|
||||
(maxWidth + picWidth) / 2, (maxHeight + picHeight) / 2);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MonitorView::Draw(BRect updateRect)
|
||||
{
|
||||
rgb_color darkColor = {160, 160, 160, 255};
|
||||
rgb_color blackColor = {0, 0, 0, 255};
|
||||
rgb_color redColor = {228, 0, 0, 255};
|
||||
BRect outerRect = MonitorBounds();
|
||||
|
||||
// frame & background
|
||||
|
||||
SetHighColor(darkColor);
|
||||
FillRoundRect(outerRect, 3.0, 3.0);
|
||||
|
||||
SetHighColor(blackColor);
|
||||
StrokeRoundRect(outerRect, 3.0, 3.0);
|
||||
|
||||
SetHighColor(fDesktopColor);
|
||||
|
||||
BRect innerRect(outerRect.InsetByCopy(4, 4));
|
||||
FillRoundRect(innerRect, 2.0, 2.0);
|
||||
|
||||
SetHighColor(blackColor);
|
||||
StrokeRoundRect(innerRect, 2.0, 2.0);
|
||||
|
||||
// power light
|
||||
|
||||
SetHighColor(redColor);
|
||||
BPoint powerPos(outerRect.left + 5, outerRect.bottom - 2);
|
||||
StrokeLine(powerPos, BPoint(powerPos.x + 2, powerPos.y));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MonitorView::SetResolution(int32 width, int32 height)
|
||||
{
|
||||
if (fWidth == width && fHeight == height)
|
||||
return;
|
||||
|
||||
fWidth = width;
|
||||
fHeight = height;
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MonitorView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case UPDATE_DESKTOP_MSG:
|
||||
{
|
||||
int32 width, height;
|
||||
if (message->FindInt32("width", &width) == B_OK
|
||||
&& message->FindInt32("height", &height) == B_OK)
|
||||
SetResolution(width, height);
|
||||
break;
|
||||
}
|
||||
|
||||
case UPDATE_DESKTOP_COLOR_MSG:
|
||||
{
|
||||
BScreen screen(Window());
|
||||
rgb_color color = screen.DesktopColor(current_workspace());
|
||||
if (color != fDesktopColor) {
|
||||
fDesktopColor = color;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2001-2005, Haiku.
|
||||
* Copyright 2002, Thomas Kurschel.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Rafael Romo
|
||||
* Thomas Kurschel
|
||||
* Axel Dörfler, [email protected]
|
||||
*/
|
||||
#ifndef MONITOR_VIEW_H
|
||||
#define MONITOR_VIEW_H
|
||||
|
||||
|
||||
#include <View.h>
|
||||
|
||||
|
||||
class MonitorView : public BView {
|
||||
public:
|
||||
MonitorView(BRect frame, char *name, int32 screenWidth, int32 screenHeight);
|
||||
~MonitorView();
|
||||
|
||||
virtual void AttachedToWindow();
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void MouseDown(BPoint point);
|
||||
|
||||
void SetResolution(int32 width, int32 height);
|
||||
|
||||
private:
|
||||
BRect MonitorView::MonitorBounds();
|
||||
|
||||
rgb_color fDesktopColor;
|
||||
int32 fWidth;
|
||||
int32 fHeight;
|
||||
};
|
||||
|
||||
#endif /* MONITOR_VIEW_H */
|
||||
@@ -1,240 +0,0 @@
|
||||
#include <Bitmap.h>
|
||||
#include <Message.h>
|
||||
#include <Picture.h>
|
||||
#include <Roster.h>
|
||||
#include <Screen.h>
|
||||
#include <String.h>
|
||||
#include <TranslationUtils.h>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
|
||||
#include "Constants.h"
|
||||
#include "ScreenDrawView.h"
|
||||
|
||||
ScreenDrawView::ScreenDrawView(BRect rect, char *name)
|
||||
:BBox(rect, name)
|
||||
{
|
||||
BScreen screen(B_MAIN_SCREEN_ID);
|
||||
if (!screen.IsValid())
|
||||
; // TODO: Debugger()? Actually, the check shouldn't
|
||||
// be needed, as the only situation where the screen wouldn't
|
||||
// be valid is when a BApplication has not been created
|
||||
|
||||
desktopColor = screen.DesktopColor(current_workspace());
|
||||
|
||||
display_mode mode;
|
||||
screen.GetMode(&mode);
|
||||
|
||||
fWidth = mode.virtual_width;
|
||||
fHeight = mode.virtual_height;
|
||||
}
|
||||
|
||||
|
||||
ScreenDrawView::~ScreenDrawView()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScreenDrawView::MouseDown(BPoint point)
|
||||
{
|
||||
be_roster->Launch("application/x-vnd.Be-BACK");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScreenDrawView::Draw(BRect updateRect)
|
||||
{
|
||||
rgb_color red = { 228, 0, 0, 255 };
|
||||
rgb_color black = { 0, 0, 0, 255 };
|
||||
rgb_color darkColor = {160, 160, 160, 255};
|
||||
|
||||
// TODO: Make the draw code resolution independent, if possible.
|
||||
// Using a scaled BPicture doesn't look so nice
|
||||
if (fWidth == 1600) {
|
||||
SetHighColor(darkColor);
|
||||
|
||||
FillRoundRect(Bounds(), 3.0, 3.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(Bounds(), 3.0, 3.0);
|
||||
|
||||
SetHighColor(desktopColor);
|
||||
|
||||
FillRoundRect(BRect(4.0, 4.0, 98.0, 73.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(4.0, 4.0, 98.0, 73.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(red);
|
||||
|
||||
StrokeLine(BPoint(4.0, 75.0), BPoint(5.0, 75.0));
|
||||
|
||||
} else if (fWidth == 1280) {
|
||||
SetHighColor(darkColor);
|
||||
|
||||
FillRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(10.0, 6.0, 92.0, 72.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(desktopColor);
|
||||
|
||||
FillRoundRect(BRect(14.0, 10.0, 88.0, 68.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(14.0, 10.0, 88.0, 68.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(red);
|
||||
|
||||
StrokeLine(BPoint(15.0, 70.0), BPoint(16.0, 70.0));
|
||||
|
||||
} else if (fWidth == 1152) {
|
||||
SetHighColor(darkColor);
|
||||
|
||||
FillRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(15.0, 9.0, 89.0, 68.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(desktopColor);
|
||||
|
||||
FillRoundRect(BRect(19.0, 13.0, 85.0, 64.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(19.0, 13.0, 85.0, 64.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(red);
|
||||
|
||||
StrokeLine(BPoint(19.0, 66.0), BPoint(20.0, 66.0));
|
||||
|
||||
} else if (fWidth == 1024) {
|
||||
SetHighColor(darkColor);
|
||||
|
||||
FillRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(18.0, 14.0, 84.0, 64.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(desktopColor);
|
||||
|
||||
FillRoundRect(BRect(22.0, 18.0, 80.0, 60.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(22.0, 18.0, 80.0, 60.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(red);
|
||||
|
||||
StrokeLine(BPoint(22.0, 62.0), BPoint(23.0, 62.0));
|
||||
} else if (fWidth == 800) {
|
||||
SetHighColor(darkColor);
|
||||
|
||||
FillRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(25.0, 19.0, 77.0, 58.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(desktopColor);
|
||||
|
||||
FillRoundRect(BRect(29.0, 23.0, 73.0, 54.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(29.0, 23.0, 73.0, 54.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(red);
|
||||
|
||||
StrokeLine(BPoint(29.0, 56.0), BPoint(30.0, 56.0));
|
||||
|
||||
} else if (fWidth == 640) {
|
||||
SetHighColor(darkColor);
|
||||
|
||||
FillRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(31.0, 23.0, 73.0, 55.0), 3.0, 3.0);
|
||||
|
||||
SetHighColor(desktopColor);
|
||||
|
||||
FillRoundRect(BRect(35.0, 27.0, 69.0, 51.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(35.0, 27.0, 69.0, 51.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(red);
|
||||
|
||||
StrokeLine(BPoint(35.0, 53.0), BPoint(36.0, 53.0));
|
||||
|
||||
} else {
|
||||
SetHighColor(darkColor);
|
||||
|
||||
FillRoundRect(Bounds(), 3.0, 3.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(Bounds(), 3.0, 3.0);
|
||||
|
||||
SetHighColor(desktopColor);
|
||||
|
||||
FillRoundRect(BRect(4.0, 4.0, 98.0, 73.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(black);
|
||||
|
||||
StrokeRoundRect(BRect(4.0, 4.0, 98.0, 73.0), 2.0, 2.0);
|
||||
|
||||
SetHighColor(red);
|
||||
|
||||
StrokeLine(BPoint(4.0, 75.0), BPoint(5.0, 75.0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScreenDrawView::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
case UPDATE_DESKTOP_MSG:
|
||||
{
|
||||
BString resolution;
|
||||
message->FindString("resolution", &resolution);
|
||||
|
||||
int32 nextWidth = atoi(resolution.String());
|
||||
resolution.Remove(0, resolution.FindFirst('x') + 1);
|
||||
|
||||
if (fWidth != nextWidth) {
|
||||
fWidth = nextWidth;
|
||||
fHeight = atoi(resolution.String());
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
case UPDATE_DESKTOP_COLOR_MSG:
|
||||
{
|
||||
BScreen screen;
|
||||
if (!screen.IsValid())
|
||||
break;
|
||||
|
||||
desktopColor = screen.DesktopColor(current_workspace());
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef __SCREENDRAWVIEW_H
|
||||
#define __SCREENDRAWVIEW_H
|
||||
|
||||
#include <Box.h>
|
||||
|
||||
class ScreenDrawView : public BBox
|
||||
{
|
||||
public:
|
||||
ScreenDrawView(BRect frame, char *name);
|
||||
~ScreenDrawView();
|
||||
virtual void Draw(BRect updateRect);
|
||||
virtual void MessageReceived(BMessage *message);
|
||||
virtual void MouseDown(BPoint point);
|
||||
|
||||
private:
|
||||
rgb_color desktopColor;
|
||||
int32 fWidth;
|
||||
int32 fHeight;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "AlertWindow.h"
|
||||
#include "Constants.h"
|
||||
#include "RefreshWindow.h"
|
||||
#include "ScreenDrawView.h"
|
||||
#include "MonitorView.h"
|
||||
#include "ScreenSettings.h"
|
||||
#include "ScreenWindow.h"
|
||||
#include "Utility.h"
|
||||
@@ -118,6 +118,9 @@ set_pixel_clock(display_mode * mode, float refresh_rate)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
: BWindow(Settings->WindowFrame(), "Screen", B_TITLED_WINDOW,
|
||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES)
|
||||
@@ -139,8 +142,9 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
BBox *screenBox = new BBox(screenBoxRect);
|
||||
screenBox->SetBorder(B_FANCY_BORDER);
|
||||
|
||||
fScreenDrawView = new ScreenDrawView(BRect(20.0, 16.0, 122.0, 93.0), "ScreenDrawView");
|
||||
screenBox->AddChild(fScreenDrawView);
|
||||
fMonitorView = new MonitorView(BRect(20.0, 16.0, 122.0, 93.0), "monitor",
|
||||
screen.Frame().Width() + 1, screen.Frame().Height() + 1);
|
||||
screenBox->AddChild(fMonitorView);
|
||||
|
||||
fWorkspaceCountMenu = new BPopUpMenu("", true, true);
|
||||
fWorkspaceCountField = new BMenuField(BRect(7.0, 107.0, 135.0, 127.0), "WorkspaceCountMenu", "Workspace count:", fWorkspaceCountMenu, true);
|
||||
@@ -149,14 +153,15 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
for (int32 count = 1; count <= 32; count++) {
|
||||
BString workspaceCount;
|
||||
workspaceCount << count;
|
||||
|
||||
BMessage *message = new BMessage(POP_WORKSPACE_CHANGED_MSG);
|
||||
message->AddInt32("workspace count", count);
|
||||
|
||||
fWorkspaceCountMenu->AddItem(new BMenuItem(workspaceCount.String(),
|
||||
new BMessage(POP_WORKSPACE_CHANGED_MSG)));
|
||||
message));
|
||||
}
|
||||
|
||||
BString string;
|
||||
string << count_workspaces();
|
||||
|
||||
BMenuItem *marked = fWorkspaceCountMenu->FindItem(string.String());
|
||||
BMenuItem *marked = fWorkspaceCountMenu->ItemAt(count_workspaces() - 1);
|
||||
if (marked != NULL)
|
||||
marked->SetMarked(true);
|
||||
|
||||
@@ -182,19 +187,19 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||
BRect ButtonRect(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);
|
||||
|
||||
|
||||
controlsBox->AddChild(fApplyButton);
|
||||
|
||||
|
||||
fResolutionMenu = new BPopUpMenu("", true, true);
|
||||
fColorsMenu = new BPopUpMenu("", true, true);
|
||||
fRefreshMenu = new BPopUpMenu("", true, true);
|
||||
|
||||
|
||||
CheckUpdateDisplayModes();
|
||||
|
||||
|
||||
const char *resolutionLabel = "Resolution: ";
|
||||
float resolutionWidth = controlsBox->StringWidth(resolutionLabel);
|
||||
BRect controlMenuRect(88.0-resolutionWidth, 30.0, 171.0, 48.0);
|
||||
@@ -345,157 +350,139 @@ ScreenWindow::ScreenChanged(BRect frame, color_space mode)
|
||||
void
|
||||
ScreenWindow::WorkspaceActivated(int32 ws, bool state)
|
||||
{
|
||||
PostMessage(new BMessage(UPDATE_DESKTOP_COLOR_MSG), fScreenDrawView);
|
||||
PostMessage(new BMessage(UPDATE_DESKTOP_COLOR_MSG), fMonitorView);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ScreenWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch(message->what)
|
||||
{
|
||||
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();
|
||||
|
||||
BMessage newMessage(UPDATE_DESKTOP_MSG);
|
||||
|
||||
const char *resolution = fResolutionMenu->FindMarked()->Label();
|
||||
|
||||
//CheckModesByResolution(resolution);
|
||||
newMessage.AddString("resolution", resolution);
|
||||
|
||||
PostMessage(&newMessage, fScreenDrawView);
|
||||
|
||||
|
||||
BMessage updateMessage(*message);
|
||||
updateMessage.what = UPDATE_DESKTOP_MSG;
|
||||
|
||||
PostMessage(&updateMessage, fMonitorView);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case POP_COLORS_MSG:
|
||||
{
|
||||
CheckApplyEnabled();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case POP_REFRESH_MSG:
|
||||
{
|
||||
CheckApplyEnabled();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case POP_OTHER_REFRESH_MSG:
|
||||
{
|
||||
BRect frame(Frame());
|
||||
|
||||
CheckApplyEnabled();
|
||||
int32 value = (int32)(fCustomRefresh * 10);
|
||||
|
||||
|
||||
RefreshWindow *fRefreshWindow = new RefreshWindow(BRect((frame.left + 201.0),
|
||||
(frame.top + 34.0), (frame.left + 509.0),
|
||||
(frame.top + 169.0)), value);
|
||||
fRefreshWindow->Show();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case BUTTON_DEFAULTS_MSG:
|
||||
{
|
||||
char str[256];
|
||||
char string[256];
|
||||
BMenuItem * item = 0;
|
||||
display_mode mode;
|
||||
mode.virtual_width = 640;
|
||||
mode.virtual_height = 480;
|
||||
mode_to_string(mode,str);
|
||||
if ((item = fResolutionMenu->FindItem(str)) != NULL) {
|
||||
mode_to_string(mode, string);
|
||||
if ((item = fResolutionMenu->FindItem(string)) != NULL)
|
||||
item->SetMarked(true);
|
||||
} else {
|
||||
else
|
||||
fResolutionMenu->ItemAt(0)->SetMarked(true);
|
||||
}
|
||||
colorspace_to_string(B_CMAP8,str);
|
||||
if ((item = fColorsMenu->FindItem(str)) != NULL) {
|
||||
|
||||
colorspace_to_string(B_CMAP8, string);
|
||||
if ((item = fColorsMenu->FindItem(string)) != NULL)
|
||||
item->SetMarked(true);
|
||||
} else {
|
||||
else
|
||||
fColorsMenu->ItemAt(0)->SetMarked(true);
|
||||
}
|
||||
refresh_rate_to_string(60.0,str);
|
||||
if ((item = fRefreshMenu->FindItem(str)) != NULL) {
|
||||
|
||||
refresh_rate_to_string(60.0, string);
|
||||
if ((item = fRefreshMenu->FindItem(string)) != NULL)
|
||||
item->SetMarked(true);
|
||||
} else {
|
||||
else
|
||||
fRefreshMenu->ItemAt(0)->SetMarked(true);
|
||||
|
||||
if ((item = fResolutionMenu->FindMarked()) != NULL) {
|
||||
BMessage updateMessage(*item->Message());
|
||||
updateMessage.what = UPDATE_DESKTOP_MSG;
|
||||
PostMessage(&updateMessage, fMonitorView);
|
||||
}
|
||||
|
||||
BMessage newMessage(UPDATE_DESKTOP_MSG);
|
||||
const char *resolution = fResolutionMenu->FindMarked()->Label();
|
||||
newMessage.AddString("resolution", resolution);
|
||||
PostMessage(&newMessage, fScreenDrawView);
|
||||
|
||||
CheckApplyEnabled();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case BUTTON_REVERT_MSG:
|
||||
case SET_INITIAL_MODE_MSG:
|
||||
{
|
||||
fInitialResolution->SetMarked(true);
|
||||
fInitialColors->SetMarked(true);
|
||||
fInitialRefresh->SetMarked(true);
|
||||
|
||||
|
||||
CheckApplyEnabled();
|
||||
|
||||
|
||||
BMenuItem *other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG);
|
||||
|
||||
|
||||
if (fInitialRefresh == other) {
|
||||
BString string;
|
||||
string << fInitialRefreshN;
|
||||
|
||||
|
||||
int32 point = string.FindFirst('.');
|
||||
string.Truncate(point + 2);
|
||||
|
||||
|
||||
string << " Hz/Other...";
|
||||
|
||||
|
||||
fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(string.String());
|
||||
|
||||
|
||||
point = string.FindFirst('/');
|
||||
string.Truncate(point);
|
||||
|
||||
|
||||
fRefreshMenu->Superitem()->SetLabel(string.String());
|
||||
}
|
||||
|
||||
BMessage newMessage(UPDATE_DESKTOP_MSG);
|
||||
const char *resolution = fInitialResolution->Label();
|
||||
newMessage.AddString("resolution", resolution);
|
||||
PostMessage(&newMessage, fScreenDrawView);
|
||||
|
||||
|
||||
if (fInitialResolution != NULL) {
|
||||
BMessage updateMessage(*fInitialResolution->Message());
|
||||
updateMessage.what = UPDATE_DESKTOP_MSG;
|
||||
PostMessage(&updateMessage, fMonitorView);
|
||||
}
|
||||
|
||||
if (message->what == SET_INITIAL_MODE_MSG) {
|
||||
|
||||
BScreen screen(B_MAIN_SCREEN_ID);
|
||||
if (!screen.IsValid())
|
||||
break;
|
||||
|
||||
BScreen screen(this);
|
||||
screen.SetMode(&fInitialMode, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case BUTTON_APPLY_MSG:
|
||||
{
|
||||
ApplyMode();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case SET_CUSTOM_REFRESH_MSG:
|
||||
{
|
||||
message->FindFloat("refresh", &fCustomRefresh);
|
||||
@@ -589,8 +576,13 @@ ScreenWindow::CheckUpdateDisplayModes()
|
||||
for (c = 0; c < fTotalModes; c++) {
|
||||
mode_to_string(fSupportedModes[c], mode);
|
||||
|
||||
if (!fResolutionMenu->FindItem(mode))
|
||||
fResolutionMenu->AddItem(new BMenuItem(mode, new BMessage(POP_RESOLUTION_MSG)));
|
||||
if (!fResolutionMenu->FindItem(mode)) {
|
||||
BMessage *message = new BMessage(POP_RESOLUTION_MSG);
|
||||
message->AddInt32("width", fSupportedModes[c].virtual_width);
|
||||
message->AddInt32("height", fSupportedModes[c].virtual_height);
|
||||
|
||||
fResolutionMenu->AddItem(new BMenuItem(mode, message));
|
||||
}
|
||||
}
|
||||
|
||||
// Add supported colorspaces to the menu
|
||||
|
||||
@@ -9,14 +9,16 @@
|
||||
#ifndef SCREEN_WINDOW_H
|
||||
#define SCREEN_WINDOW_H
|
||||
|
||||
|
||||
#include <Screen.h>
|
||||
#include <Window.h>
|
||||
|
||||
class BBox;
|
||||
class BPopUpMenu;
|
||||
class BMenuField;
|
||||
|
||||
class RefreshWindow;
|
||||
class ScreenDrawView;
|
||||
class MonitorView;
|
||||
class ScreenSettings;
|
||||
|
||||
|
||||
@@ -40,7 +42,7 @@ class ScreenWindow : public BWindow {
|
||||
|
||||
ScreenSettings *fSettings;
|
||||
|
||||
ScreenDrawView *fScreenDrawView;
|
||||
MonitorView *fMonitorView;
|
||||
BPopUpMenu *fWorkspaceMenu;
|
||||
BMenuField *fWorkspaceField;
|
||||
BPopUpMenu *fWorkspaceCountMenu;
|
||||
|
||||
Reference in New Issue
Block a user