Initial checkin of Time preference panel.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@913 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Andrew McCall
2002-08-28 18:46:25 +00:00
parent 6ea3dc7148
commit a51a3bf754
10 changed files with 343 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
/*
* TimeSettings.cpp
* Time [email protected]
*
*/
#include <Application.h>
#include <FindDirectory.h>
#include <File.h>
#include <Path.h>
#include <String.h>
#include <stdio.h>
#include "TimeSettings.h"
#include "TimeMessages.h"
const char TimeSettings::kTimeSettingsFile[] = "Time_settings";
TimeSettings::TimeSettings()
{
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) == B_OK) {
path.Append(kTimeSettingsFile);
BFile file(path.Path(), B_READ_ONLY);
if (file.InitCheck() == B_OK) {
// Now read in the data
if (file.Read(&fCorner, sizeof(BPoint)) != sizeof(BPoint)) {
fCorner.x=50;
fCorner.y=50;
};
}
else {
fCorner.x=50;
fCorner.y=50;
}
}
else
be_app->PostMessage(ERROR_DETECTED);
}
TimeSettings::~TimeSettings()
{
BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) < B_OK)
return;
path.Append(kTimeSettingsFile);
BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE);
if (file.InitCheck() == B_OK) {
file.Write(&fCorner, sizeof(BPoint));
}
}
void
TimeSettings::SetWindowCorner(BPoint corner)
{
fCorner=corner;
}