* Now shows some info about the monitor if detected.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32030 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-07-31 17:36:45 +00:00
parent 42158ac76f
commit 12966d04e9
3 changed files with 56 additions and 4 deletions

View File

@ -331,13 +331,33 @@ ScreenMode::GetMonitorInfo(monitor_info& info, float* _diagonalInches)
return status;
if (_diagonalInches != NULL) {
*_diagonalInches = sqrt(info.width * info.width
+ info.height * info.height) / 2.54;
*_diagonalInches = round(sqrt(info.width * info.width
+ info.height * info.height) / 0.254) / 10.0;
}
if (!strcmp(info.vendor, "LEN"))
strcpy(info.vendor, "Lenovo");
// TODO: If the names aren't sound, we could see if we find/create a
// database for the entries with user presentable names; they are fine
// for the models I could test with so far.
uint32 id = (info.vendor[0] << 24) | (info.vendor[1] << 16)
| (info.vendor[2] << 8) | (info.vendor[3]);
// TODO: replace more vendor strings with something readable
switch (id) {
case 'BNQ\0':
strcpy(info.vendor, "BenQ");
break;
case 'LEN\0':
strcpy(info.vendor, "Lenovo");
break;
case 'SAM\0':
strcpy(info.vendor, "Samsung");
break;
case 'VSC\0':
strcpy(info.vendor, "ViewSonic");
break;
}
return B_OK;
}

View File

@ -201,6 +201,9 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
layout->SetInsets(10, 10, 10, 10);
screenBox->SetLayout(layout);
fMonitorInfo = new BStringView("monitor info", "");
screenBox->AddChild(fMonitorInfo);
fMonitorView = new MonitorView(BRect(0.0, 0.0, 80.0, 80.0), "monitor",
screen.Frame().IntegerWidth() + 1, screen.Frame().IntegerHeight() + 1);
screenBox->AddChild(fMonitorView);
@ -464,6 +467,7 @@ ScreenWindow::ScreenWindow(ScreenSettings* settings)
controlsBox->TopBorderOffset() - 1));
_UpdateControls();
_UpdateMonitor();
}
@ -720,6 +724,7 @@ ScreenWindow::_UpdateActiveMode()
fScreenMode.Get(fActive);
fSelected = fActive;
_UpdateMonitor();
_UpdateControls();
}
@ -1068,6 +1073,30 @@ ScreenWindow::_UpdateOriginal()
}
void
ScreenWindow::_UpdateMonitor()
{
monitor_info info;
float diagonalInches;
status_t status = fScreenMode.GetMonitorInfo(info, &diagonalInches);
if (status != B_OK) {
if (!fMonitorInfo->IsHidden())
fMonitorInfo->Hide();
return;
}
char text[256];
snprintf(text, sizeof(text), "%s %s %g\"", info.vendor, info.name,
diagonalInches);
fMonitorInfo->SetText(text);
if (fMonitorInfo->IsHidden())
fMonitorInfo->Show();
}
void
ScreenWindow::_Apply()
{

View File

@ -20,6 +20,7 @@
class BBox;
class BPopUpMenu;
class BMenuField;
class BStringView;
class BTextControl;
class RefreshWindow;
@ -52,6 +53,7 @@ class ScreenWindow : public BWindow {
void _UpdateMonitorView();
void _UpdateControls();
void _UpdateOriginal();
void _UpdateMonitor();
void _Apply();
@ -62,6 +64,7 @@ class ScreenWindow : public BWindow {
bool fIsVesa;
bool fBootWorkspaceApplied;
BStringView* fMonitorInfo;
MonitorView* fMonitorView;
BMenuItem* fAllWorkspacesItem;