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 ;
|
SubDir OBOS_TOP src prefs screen ;
|
||||||
|
|
||||||
SubDirC++Flags [ FDefines BEOS_R5_COMPATIBLE ] ;
|
|
||||||
|
|
||||||
Preference Screen :
|
Preference Screen :
|
||||||
AlertView.cpp
|
AlertView.cpp
|
||||||
AlertWindow.cpp
|
AlertWindow.cpp
|
||||||
@@ -9,11 +7,10 @@ Preference Screen :
|
|||||||
RefreshView.cpp
|
RefreshView.cpp
|
||||||
RefreshWindow.cpp
|
RefreshWindow.cpp
|
||||||
Screen.cpp
|
Screen.cpp
|
||||||
ScreenDrawView.cpp
|
MonitorView.cpp
|
||||||
ScreenSettings.cpp
|
ScreenSettings.cpp
|
||||||
ScreenWindow.cpp
|
ScreenWindow.cpp
|
||||||
Utility.cpp
|
Utility.cpp
|
||||||
: libbe.so
|
: libbe.so
|
||||||
: Screen.rdef
|
: 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 "AlertWindow.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "RefreshWindow.h"
|
#include "RefreshWindow.h"
|
||||||
#include "ScreenDrawView.h"
|
#include "MonitorView.h"
|
||||||
#include "ScreenSettings.h"
|
#include "ScreenSettings.h"
|
||||||
#include "ScreenWindow.h"
|
#include "ScreenWindow.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
@@ -118,6 +118,9 @@ set_pixel_clock(display_mode * mode, float refresh_rate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
||||||
: BWindow(Settings->WindowFrame(), "Screen", B_TITLED_WINDOW,
|
: BWindow(Settings->WindowFrame(), "Screen", B_TITLED_WINDOW,
|
||||||
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES)
|
B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES)
|
||||||
@@ -139,8 +142,9 @@ ScreenWindow::ScreenWindow(ScreenSettings *Settings)
|
|||||||
BBox *screenBox = new BBox(screenBoxRect);
|
BBox *screenBox = new BBox(screenBoxRect);
|
||||||
screenBox->SetBorder(B_FANCY_BORDER);
|
screenBox->SetBorder(B_FANCY_BORDER);
|
||||||
|
|
||||||
fScreenDrawView = new ScreenDrawView(BRect(20.0, 16.0, 122.0, 93.0), "ScreenDrawView");
|
fMonitorView = new MonitorView(BRect(20.0, 16.0, 122.0, 93.0), "monitor",
|
||||||
screenBox->AddChild(fScreenDrawView);
|
screen.Frame().Width() + 1, screen.Frame().Height() + 1);
|
||||||
|
screenBox->AddChild(fMonitorView);
|
||||||
|
|
||||||
fWorkspaceCountMenu = new BPopUpMenu("", true, true);
|
fWorkspaceCountMenu = new BPopUpMenu("", true, true);
|
||||||
fWorkspaceCountField = new BMenuField(BRect(7.0, 107.0, 135.0, 127.0), "WorkspaceCountMenu", "Workspace count:", fWorkspaceCountMenu, 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++) {
|
for (int32 count = 1; count <= 32; count++) {
|
||||||
BString workspaceCount;
|
BString workspaceCount;
|
||||||
workspaceCount << count;
|
workspaceCount << count;
|
||||||
|
|
||||||
|
BMessage *message = new BMessage(POP_WORKSPACE_CHANGED_MSG);
|
||||||
|
message->AddInt32("workspace count", count);
|
||||||
|
|
||||||
fWorkspaceCountMenu->AddItem(new BMenuItem(workspaceCount.String(),
|
fWorkspaceCountMenu->AddItem(new BMenuItem(workspaceCount.String(),
|
||||||
new BMessage(POP_WORKSPACE_CHANGED_MSG)));
|
message));
|
||||||
}
|
}
|
||||||
|
|
||||||
BString string;
|
BMenuItem *marked = fWorkspaceCountMenu->ItemAt(count_workspaces() - 1);
|
||||||
string << count_workspaces();
|
|
||||||
|
|
||||||
BMenuItem *marked = fWorkspaceCountMenu->FindItem(string.String());
|
|
||||||
if (marked != NULL)
|
if (marked != NULL)
|
||||||
marked->SetMarked(true);
|
marked->SetMarked(true);
|
||||||
|
|
||||||
@@ -345,28 +350,23 @@ ScreenWindow::ScreenChanged(BRect frame, color_space mode)
|
|||||||
void
|
void
|
||||||
ScreenWindow::WorkspaceActivated(int32 ws, bool state)
|
ScreenWindow::WorkspaceActivated(int32 ws, bool state)
|
||||||
{
|
{
|
||||||
PostMessage(new BMessage(UPDATE_DESKTOP_COLOR_MSG), fScreenDrawView);
|
PostMessage(new BMessage(UPDATE_DESKTOP_COLOR_MSG), fMonitorView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScreenWindow::MessageReceived(BMessage* message)
|
ScreenWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch(message->what)
|
switch (message->what) {
|
||||||
{
|
|
||||||
case WORKSPACE_CHECK_MSG:
|
case WORKSPACE_CHECK_MSG:
|
||||||
{
|
|
||||||
fApplyButton->SetEnabled(true);
|
fApplyButton->SetEnabled(true);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case POP_WORKSPACE_CHANGED_MSG:
|
case POP_WORKSPACE_CHANGED_MSG:
|
||||||
{
|
{
|
||||||
BMenuItem *item = fWorkspaceCountMenu->FindMarked();
|
BMenuItem *item = fWorkspaceCountMenu->FindMarked();
|
||||||
|
|
||||||
set_workspace_count(fWorkspaceCountMenu->IndexOf(item) + 1);
|
set_workspace_count(fWorkspaceCountMenu->IndexOf(item) + 1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,29 +374,20 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
{
|
{
|
||||||
CheckApplyEnabled();
|
CheckApplyEnabled();
|
||||||
|
|
||||||
BMessage newMessage(UPDATE_DESKTOP_MSG);
|
BMessage updateMessage(*message);
|
||||||
|
updateMessage.what = UPDATE_DESKTOP_MSG;
|
||||||
const char *resolution = fResolutionMenu->FindMarked()->Label();
|
|
||||||
|
|
||||||
//CheckModesByResolution(resolution);
|
|
||||||
newMessage.AddString("resolution", resolution);
|
|
||||||
|
|
||||||
PostMessage(&newMessage, fScreenDrawView);
|
|
||||||
|
|
||||||
|
PostMessage(&updateMessage, fMonitorView);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case POP_COLORS_MSG:
|
case POP_COLORS_MSG:
|
||||||
{
|
|
||||||
CheckApplyEnabled();
|
CheckApplyEnabled();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case POP_REFRESH_MSG:
|
case POP_REFRESH_MSG:
|
||||||
{
|
|
||||||
CheckApplyEnabled();
|
CheckApplyEnabled();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case POP_OTHER_REFRESH_MSG:
|
case POP_OTHER_REFRESH_MSG:
|
||||||
{
|
{
|
||||||
@@ -414,34 +405,35 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
|
|
||||||
case BUTTON_DEFAULTS_MSG:
|
case BUTTON_DEFAULTS_MSG:
|
||||||
{
|
{
|
||||||
char str[256];
|
char string[256];
|
||||||
BMenuItem * item = 0;
|
BMenuItem * item = 0;
|
||||||
display_mode mode;
|
display_mode mode;
|
||||||
mode.virtual_width = 640;
|
mode.virtual_width = 640;
|
||||||
mode.virtual_height = 480;
|
mode.virtual_height = 480;
|
||||||
mode_to_string(mode,str);
|
mode_to_string(mode, string);
|
||||||
if ((item = fResolutionMenu->FindItem(str)) != NULL) {
|
if ((item = fResolutionMenu->FindItem(string)) != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
} else {
|
else
|
||||||
fResolutionMenu->ItemAt(0)->SetMarked(true);
|
fResolutionMenu->ItemAt(0)->SetMarked(true);
|
||||||
}
|
|
||||||
colorspace_to_string(B_CMAP8,str);
|
colorspace_to_string(B_CMAP8, string);
|
||||||
if ((item = fColorsMenu->FindItem(str)) != NULL) {
|
if ((item = fColorsMenu->FindItem(string)) != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
} else {
|
else
|
||||||
fColorsMenu->ItemAt(0)->SetMarked(true);
|
fColorsMenu->ItemAt(0)->SetMarked(true);
|
||||||
}
|
|
||||||
refresh_rate_to_string(60.0,str);
|
refresh_rate_to_string(60.0, string);
|
||||||
if ((item = fRefreshMenu->FindItem(str)) != NULL) {
|
if ((item = fRefreshMenu->FindItem(string)) != NULL)
|
||||||
item->SetMarked(true);
|
item->SetMarked(true);
|
||||||
} else {
|
else
|
||||||
fRefreshMenu->ItemAt(0)->SetMarked(true);
|
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();
|
CheckApplyEnabled();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -474,27 +466,22 @@ ScreenWindow::MessageReceived(BMessage* message)
|
|||||||
fRefreshMenu->Superitem()->SetLabel(string.String());
|
fRefreshMenu->Superitem()->SetLabel(string.String());
|
||||||
}
|
}
|
||||||
|
|
||||||
BMessage newMessage(UPDATE_DESKTOP_MSG);
|
if (fInitialResolution != NULL) {
|
||||||
const char *resolution = fInitialResolution->Label();
|
BMessage updateMessage(*fInitialResolution->Message());
|
||||||
newMessage.AddString("resolution", resolution);
|
updateMessage.what = UPDATE_DESKTOP_MSG;
|
||||||
PostMessage(&newMessage, fScreenDrawView);
|
PostMessage(&updateMessage, fMonitorView);
|
||||||
|
}
|
||||||
|
|
||||||
if (message->what == SET_INITIAL_MODE_MSG) {
|
if (message->what == SET_INITIAL_MODE_MSG) {
|
||||||
|
BScreen screen(this);
|
||||||
BScreen screen(B_MAIN_SCREEN_ID);
|
|
||||||
if (!screen.IsValid())
|
|
||||||
break;
|
|
||||||
|
|
||||||
screen.SetMode(&fInitialMode, true);
|
screen.SetMode(&fInitialMode, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case BUTTON_APPLY_MSG:
|
case BUTTON_APPLY_MSG:
|
||||||
{
|
|
||||||
ApplyMode();
|
ApplyMode();
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case SET_CUSTOM_REFRESH_MSG:
|
case SET_CUSTOM_REFRESH_MSG:
|
||||||
{
|
{
|
||||||
@@ -589,8 +576,13 @@ ScreenWindow::CheckUpdateDisplayModes()
|
|||||||
for (c = 0; c < fTotalModes; c++) {
|
for (c = 0; c < fTotalModes; c++) {
|
||||||
mode_to_string(fSupportedModes[c], mode);
|
mode_to_string(fSupportedModes[c], mode);
|
||||||
|
|
||||||
if (!fResolutionMenu->FindItem(mode))
|
if (!fResolutionMenu->FindItem(mode)) {
|
||||||
fResolutionMenu->AddItem(new BMenuItem(mode, new BMessage(POP_RESOLUTION_MSG)));
|
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
|
// Add supported colorspaces to the menu
|
||||||
|
|||||||
@@ -9,14 +9,16 @@
|
|||||||
#ifndef SCREEN_WINDOW_H
|
#ifndef SCREEN_WINDOW_H
|
||||||
#define SCREEN_WINDOW_H
|
#define SCREEN_WINDOW_H
|
||||||
|
|
||||||
|
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
class BBox;
|
class BBox;
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
|
|
||||||
class RefreshWindow;
|
class RefreshWindow;
|
||||||
class ScreenDrawView;
|
class MonitorView;
|
||||||
class ScreenSettings;
|
class ScreenSettings;
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +42,7 @@ class ScreenWindow : public BWindow {
|
|||||||
|
|
||||||
ScreenSettings *fSettings;
|
ScreenSettings *fSettings;
|
||||||
|
|
||||||
ScreenDrawView *fScreenDrawView;
|
MonitorView *fMonitorView;
|
||||||
BPopUpMenu *fWorkspaceMenu;
|
BPopUpMenu *fWorkspaceMenu;
|
||||||
BMenuField *fWorkspaceField;
|
BMenuField *fWorkspaceField;
|
||||||
BPopUpMenu *fWorkspaceCountMenu;
|
BPopUpMenu *fWorkspaceCountMenu;
|
||||||
|
|||||||
Reference in New Issue
Block a user