* Added a max resolution to MonitorView that can be chosen to define when it

should fill its space completely (which is now the maximal resolution that
  can be chosen).
* Improved monitor info in case there is no name.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32033 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-07-31 18:47:44 +00:00
parent ed8a411691
commit 66ab166689
3 changed files with 35 additions and 18 deletions
+18 -4
View File
@@ -28,6 +28,7 @@ operator!=(const rgb_color& x, const rgb_color& y)
MonitorView::MonitorView(BRect rect, char *name, int32 width, int32 height) MonitorView::MonitorView(BRect rect, char *name, int32 width, int32 height)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW), : BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
fMaxSize(1600),
fWidth(width), fWidth(width),
fHeight(height) fHeight(height)
{ {
@@ -65,8 +66,8 @@ MonitorView::MonitorBounds()
float maxSize = min_c(Bounds().Width(), Bounds().Height()); float maxSize = min_c(Bounds().Width(), Bounds().Height());
picWidth = maxSize * fWidth / 1600; picWidth = maxSize * fWidth / fMaxSize;
picHeight = maxSize * fHeight / 1600; picHeight = maxSize * fHeight / fMaxSize;
if (picWidth > maxSize) { if (picWidth > maxSize) {
picHeight = picHeight * maxSize / picWidth; picHeight = picHeight * maxSize / picWidth;
@@ -79,7 +80,7 @@ MonitorView::MonitorBounds()
} }
BPoint size = BPoint(Bounds().Width(), Bounds().Height()); BPoint size = BPoint(Bounds().Width(), Bounds().Height());
return BRect((size.x - picWidth) / 2, (size.y - picHeight) / 2, return BRect((size.x - picWidth) / 2, (size.y - picHeight) / 2,
(size.x + picWidth) / 2, (size.y + picHeight) / 2); (size.x + picWidth) / 2, (size.y + picHeight) / 2);
} }
@@ -133,6 +134,19 @@ MonitorView::SetResolution(int32 width, int32 height)
} }
void
MonitorView::SetMaxResolution(int32 width, int32 height)
{
int32 maxSize = max_c(width, height);
if (fMaxSize == maxSize)
return;
fMaxSize = maxSize;
Invalidate();
}
void void
MonitorView::MessageReceived(BMessage* message) MonitorView::MessageReceived(BMessage* message)
{ {
@@ -157,7 +171,7 @@ MonitorView::MessageReceived(BMessage* message)
} }
default: default:
BView::MessageReceived(message); BView::MessageReceived(message);
break; break;
} }
} }
+5 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2005, Haiku. * Copyright 2001-2009, Haiku.
* Copyright 2002, Thomas Kurschel. * Copyright 2002, Thomas Kurschel.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
@@ -17,7 +17,8 @@
class MonitorView : public BView { class MonitorView : public BView {
public: public:
MonitorView(BRect frame, char *name, int32 screenWidth, int32 screenHeight); MonitorView(BRect frame, char *name, int32 screenWidth,
int32 screenHeight);
~MonitorView(); ~MonitorView();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
@@ -26,11 +27,13 @@ class MonitorView : public BView {
virtual void MouseDown(BPoint point); virtual void MouseDown(BPoint point);
void SetResolution(int32 width, int32 height); void SetResolution(int32 width, int32 height);
void SetMaxResolution(int32 width, int32 height);
private: private:
BRect MonitorBounds(); BRect MonitorBounds();
rgb_color fDesktopColor; rgb_color fDesktopColor;
int32 fMaxSize;
int32 fWidth; int32 fWidth;
int32 fHeight; int32 fHeight;
}; };
+12 -12
View File
@@ -208,15 +208,6 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
screen.Frame().IntegerWidth() + 1, screen.Frame().IntegerHeight() + 1); screen.Frame().IntegerWidth() + 1, screen.Frame().IntegerHeight() + 1);
screenBox->AddChild(fMonitorView); screenBox->AddChild(fMonitorView);
/*
BStringView* columnsView = new BStringView("", "Columns:");
columnsView->SetExplicitAlignment(
BAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET));
BStringView* rowsView = new BStringView("", "Rows:");
rowsView->SetExplicitAlignment(
BAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET));
*/
fColumnsControl = new BTextControl("Columns:", "0", fColumnsControl = new BTextControl("Columns:", "0",
new BMessage(kMsgWorkspaceColumnsChanged)); new BMessage(kMsgWorkspaceColumnsChanged));
fRowsControl = new BTextControl("Rows:", "0", fRowsControl = new BTextControl("Rows:", "0",
@@ -251,7 +242,10 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
fResolutionMenu = new BPopUpMenu("resolution", true, true); fResolutionMenu = new BPopUpMenu("resolution", true, true);
uint16 previousWidth = 0, previousHeight = 0; uint16 maxWidth = 0;
uint16 maxHeight = 0;
uint16 previousWidth = 0;
uint16 previousHeight = 0;
for (int32 i = 0; i < fScreenMode.CountModes(); i++) { for (int32 i = 0; i < fScreenMode.CountModes(); i++) {
screen_mode mode = fScreenMode.ModeAt(i); screen_mode mode = fScreenMode.ModeAt(i);
@@ -260,6 +254,10 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
previousWidth = mode.width; previousWidth = mode.width;
previousHeight = mode.height; previousHeight = mode.height;
if (maxWidth < mode.width)
maxWidth = mode.width;
if (maxHeight < mode.height)
maxHeight = mode.height;
BMessage *message = new BMessage(POP_RESOLUTION_MSG); BMessage *message = new BMessage(POP_RESOLUTION_MSG);
message->AddInt32("width", mode.width); message->AddInt32("width", mode.width);
@@ -271,6 +269,8 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
fResolutionMenu->AddItem(new BMenuItem(name.String(), message)); fResolutionMenu->AddItem(new BMenuItem(name.String(), message));
} }
fMonitorView->SetMaxResolution(maxWidth, maxHeight);
BRect rect(0.0, 0.0, 200.0, 15.0); BRect rect(0.0, 0.0, 200.0, 15.0);
// fResolutionField needs to be at the correct // fResolutionField needs to be at the correct
// left-top offset, because all other menu fields // left-top offset, because all other menu fields
@@ -1087,8 +1087,8 @@ ScreenWindow::_UpdateMonitor()
} }
char text[256]; char text[256];
snprintf(text, sizeof(text), "%s %s %g\"", info.vendor, info.name, snprintf(text, sizeof(text), "%s%s%s %g\"", info.vendor,
diagonalInches); info.name[0] ? " " : "", info.name, diagonalInches);
fMonitorInfo->SetText(text); fMonitorInfo->SetText(text);