1/* 2 * Copyright 2001-2015, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Rafael Romo 7 * Stefano Ceccherini (burton666@libero.it) 8 * Axel Dörfler, axeld@pinc-software.de 9 */ 10 11 12#include "ScreenSettings.h" 13 14#include <File.h> 15#include <FindDirectory.h> 16#include <Path.h> 17 18 19static const char* kSettingsFileName = "Screen_data"; 20 21 22ScreenSettings::ScreenSettings() 23{ 24 fWindowFrame.Set(0, 0, 450, 250); 25 BPoint offset; 26 27 BPath path; 28 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { 29 path.Append(kSettingsFileName); 30 31 BFile file(path.Path(), B_READ_ONLY); 32 if (file.InitCheck() == B_OK) 33 file.Read(&offset, sizeof(BPoint)); 34 } 35 36 fWindowFrame.OffsetBy(offset); 37} 38 39 40ScreenSettings::~ScreenSettings() 41{ 42 BPath path; 43 if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK) 44 return; 45 46 path.Append(kSettingsFileName); 47 48 BPoint offset = fWindowFrame.LeftTop(); 49 50 BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); 51 if (file.InitCheck() == B_OK) 52 file.Write(&offset, sizeof(BPoint)); 53} 54 55 56void 57ScreenSettings::SetWindowFrame(BRect frame) 58{ 59 fWindowFrame = frame; 60} 61