* Copyright 2001-2015, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
* Rafael Romo
* Stefano Ceccherini (burton666@libero.it)
* Axel DΓΆrfler, axeld@pinc-software.de
*/
#include "ScreenSettings.h"
#include <File.h>
#include <FindDirectory.h>
#include <Path.h>
static const char* kSettingsFileName = "Screen_data";
ScreenSettings::ScreenSettings()
{
fWindowFrame.Set(0, 0, 450, 250);
BPoint offset;
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
path.Append(kSettingsFileName);
BFile file(path.Path(), B_READ_ONLY);
if (file.InitCheck() == B_OK)
file.Read(&offset, sizeof(BPoint));
}
fWindowFrame.OffsetBy(offset);
}
ScreenSettings::~ScreenSettings()
{
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
return;
path.Append(kSettingsFileName);
BPoint offset = fWindowFrame.LeftTop();
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
if (file.InitCheck() == B_OK)
file.Write(&offset, sizeof(BPoint));
}
void
ScreenSettings::SetWindowFrame(BRect frame)
{
fWindowFrame = frame;
}