Screen now uses the same preference file as R5's one, and it's compatible with it. Now revert works as it should. Some cleanups

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2097 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini
2002-11-27 15:45:32 +00:00
parent 22eb56e099
commit 30d9eb3baf
2 changed files with 26 additions and 45 deletions
+14 -10
View File
@@ -3,7 +3,7 @@
#include "ScreenSettings.h"
const char ScreenSettings::fScreenSettingsFile[] = "OBOS_Screen_data";
const char ScreenSettings::fScreenSettingsFile[] = "Screen_data";
ScreenSettings::ScreenSettings()
{
@@ -11,6 +11,10 @@ ScreenSettings::ScreenSettings()
if (!screen.IsValid())
; //Debugger() ?
fWindowFrame.Set( 0, 0, 356, 202 );
BRect screenFrame = screen.Frame();
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK)
@@ -20,19 +24,17 @@ ScreenSettings::ScreenSettings()
BFile file(path.Path(), B_READ_ONLY);
if (file.InitCheck() == B_OK)
{
file.Read(&fWindowFrame, sizeof(BRect));
BPoint point;
file.Read(&point, sizeof(BPoint));
fWindowFrame.OffsetTo(point);
if (screen.Frame().right >= fWindowFrame.right
&& screen.Frame().bottom >= fWindowFrame.bottom)
return;
}
}
fWindowFrame = screen.Frame();
fWindowFrame.left = (fWindowFrame.right / 2) - 178;
fWindowFrame.top = (fWindowFrame.right / 2) - 101;
fWindowFrame.right = fWindowFrame.left + 356;
fWindowFrame.bottom = fWindowFrame.top + 202;
fWindowFrame.OffsetTo((screenFrame.Width() - fWindowFrame.Width()) / 2,
(screenFrame.Height() - fWindowFrame.Height()) /2 );
}
@@ -45,8 +47,10 @@ ScreenSettings::~ScreenSettings()
path.Append(fScreenSettingsFile);
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
if (file.InitCheck() == B_OK)
file.Write(&fWindowFrame, sizeof(BRect));
if (file.InitCheck() == B_OK) {
BPoint point(fWindowFrame.LeftTop());
file.Write(&point, sizeof(BPoint));
}
}
+12 -35
View File
@@ -12,6 +12,7 @@
#include <math.h>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include "ScreenWindow.h"
#include "ScreenDrawView.h"
@@ -371,8 +372,6 @@ ScreenWindow::MessageReceived(BMessage* message)
PostMessage(Message, fScreenDrawView);
if (fResolutionMenu->FindMarked() == fInitialResolution)
break;
}
@@ -425,6 +424,7 @@ ScreenWindow::MessageReceived(BMessage* message)
}
case BUTTON_REVERT_MSG:
case SET_INITIAL_MODE_MSG:
{
fInitialResolution->SetMarked(true);
fInitialColors->SetMarked(true);
@@ -452,6 +452,14 @@ ScreenWindow::MessageReceived(BMessage* message)
fRefreshMenu->Superitem()->SetLabel(string.String());
}
if (message->what == SET_INITIAL_MODE_MSG)
{
BScreen screen(B_MAIN_SCREEN_ID);
if (!screen.IsValid())
break;
screen.SetMode(&fInitialMode);
}
break;
}
@@ -549,38 +557,7 @@ ScreenWindow::MessageReceived(BMessage* message)
break;
}
case SET_INITIAL_MODE_MSG:
{
BMenuItem *Other = fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG);
if (fInitialRefresh == Other)
{
Other->SetMarked(true);
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());
}
BScreen screen(B_MAIN_SCREEN_ID);
if (!screen.IsValid())
break;
screen.SetMode(&fInitialMode);
break;
}
case SET_CUSTOM_REFRESH_MSG:
{
message->FindFloat("refresh", &fCustomRefresh);
@@ -598,8 +575,8 @@ ScreenWindow::MessageReceived(BMessage* message)
fRefreshMenu->FindItem(POP_OTHER_REFRESH_MSG)->SetLabel(String.String());
point = String.FindFirst('z');
String.Truncate(point + 1);
point = String.FindFirst('/');
String.Truncate(point);
fRefreshMenu->Superitem()->SetLabel(String.String());