* 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

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)
: BView(rect, name, B_FOLLOW_ALL, B_WILL_DRAW),
fMaxSize(1600),
fWidth(width),
fHeight(height)
{
@ -65,8 +66,8 @@ MonitorView::MonitorBounds()
float maxSize = min_c(Bounds().Width(), Bounds().Height());
picWidth = maxSize * fWidth / 1600;
picHeight = maxSize * fHeight / 1600;
picWidth = maxSize * fWidth / fMaxSize;
picHeight = maxSize * fHeight / fMaxSize;
if (picWidth > maxSize) {
picHeight = picHeight * maxSize / picWidth;
@ -79,7 +80,7 @@ MonitorView::MonitorBounds()
}
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);
}
@ -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
MonitorView::MessageReceived(BMessage* message)
{
@ -157,7 +171,7 @@ MonitorView::MessageReceived(BMessage* message)
}
default:
BView::MessageReceived(message);
BView::MessageReceived(message);
break;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2001-2005, Haiku.
* Copyright 2001-2009, Haiku.
* Copyright 2002, Thomas Kurschel.
* Distributed under the terms of the MIT License.
*
@ -17,7 +17,8 @@
class MonitorView : public BView {
public:
MonitorView(BRect frame, char *name, int32 screenWidth, int32 screenHeight);
MonitorView(BRect frame, char *name, int32 screenWidth,
int32 screenHeight);
~MonitorView();
virtual void AttachedToWindow();
@ -26,11 +27,13 @@ class MonitorView : public BView {
virtual void MouseDown(BPoint point);
void SetResolution(int32 width, int32 height);
void SetMaxResolution(int32 width, int32 height);
private:
BRect MonitorBounds();
rgb_color fDesktopColor;
int32 fMaxSize;
int32 fWidth;
int32 fHeight;
};

View File

@ -208,15 +208,6 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
screen.Frame().IntegerWidth() + 1, screen.Frame().IntegerHeight() + 1);
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",
new BMessage(kMsgWorkspaceColumnsChanged));
fRowsControl = new BTextControl("Rows:", "0",
@ -251,7 +242,10 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
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++) {
screen_mode mode = fScreenMode.ModeAt(i);
@ -260,6 +254,10 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
previousWidth = mode.width;
previousHeight = mode.height;
if (maxWidth < mode.width)
maxWidth = mode.width;
if (maxHeight < mode.height)
maxHeight = mode.height;
BMessage *message = new BMessage(POP_RESOLUTION_MSG);
message->AddInt32("width", mode.width);
@ -271,6 +269,8 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
fResolutionMenu->AddItem(new BMenuItem(name.String(), message));
}
fMonitorView->SetMaxResolution(maxWidth, maxHeight);
BRect rect(0.0, 0.0, 200.0, 15.0);
// fResolutionField needs to be at the correct
// left-top offset, because all other menu fields
@ -1087,8 +1087,8 @@ ScreenWindow::_UpdateMonitor()
}
char text[256];
snprintf(text, sizeof(text), "%s %s %g\"", info.vendor, info.name,
diagonalInches);
snprintf(text, sizeof(text), "%s%s%s %g\"", info.vendor,
info.name[0] ? " " : "", info.name, diagonalInches);
fMonitorInfo->SetText(text);