xref: /haiku/src/preferences/screen/ScreenSettings.cpp (revision d0ac609964842f8cdb6d54b3c539c6c15293e172)
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 
19 static const char* kSettingsFileName = "Screen_data";
20 
21 
22 ScreenSettings::ScreenSettings()
23 {
24 	fWindowFrame.Set(-1, -1, 450, 250);
25 
26 	BPath path;
27 	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
28 		path.Append(kSettingsFileName);
29 
30 		BFile file(path.Path(), B_READ_ONLY);
31 		if (file.InitCheck() == B_OK)
32 			file.Read(&fWindowFrame, sizeof(BRect));
33 	}
34 }
35 
36 
37 ScreenSettings::~ScreenSettings()
38 {
39 	BPath path;
40 	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) < B_OK)
41 		return;
42 
43 	path.Append(kSettingsFileName);
44 
45 	BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
46 	if (file.InitCheck() == B_OK)
47 		file.Write(&fWindowFrame, sizeof(BRect));
48 }
49 
50 
51 void
52 ScreenSettings::SetWindowFrame(BRect frame)
53 {
54 	fWindowFrame = frame;
55 }
56