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:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user