1 /* 2 * DataTranslationsSettings.cpp 3 * DataTranslations Oliver Siebenmarck 4 * 5 */ 6 7 #include <Application.h> 8 #include <Debug.h> 9 #include <FindDirectory.h> 10 #include <File.h> 11 #include <Path.h> 12 #include <String.h> 13 #include <stdio.h> 14 15 #include "DataTranslationsSettings.h" 16 #include "DataTranslationsMessages.h" 17 18 const char DataTranslationsSettings::kDataTranslationsSettingsFile[] = "Translation Settings"; 19 20 DataTranslationsSettings::DataTranslationsSettings() 21 { 22 BPath path; 23 24 if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) == B_OK) { 25 path.Append(kDataTranslationsSettingsFile); 26 BFile file(path.Path(), B_READ_ONLY); 27 if (file.InitCheck() == B_OK) { 28 // Now read in the data 29 file.Seek(-8,SEEK_END); // Skip over the first 497 bytes to just the window 30 // position. 31 if (file.Read(&fCorner, sizeof(BPoint)) != sizeof(BPoint)) { 32 fCorner.x=50; 33 fCorner.y=50; 34 }; 35 } 36 else { 37 fCorner.x=50; 38 fCorner.y=50; 39 } 40 } 41 else 42 be_app->PostMessage(ERROR_DETECTED); 43 } 44 45 DataTranslationsSettings::~DataTranslationsSettings() 46 { 47 BPath path; 48 49 if (find_directory(B_USER_SETTINGS_DIRECTORY,&path) < B_OK) 50 return; 51 52 path.Append(kDataTranslationsSettingsFile); 53 54 BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE); 55 if (file.InitCheck() == B_OK) { 56 file.Seek(-8,SEEK_END); // Skip over the first 497 bytes to just the window 57 // position. 58 PRINT_OBJECT(fCorner); 59 file.Write(&fCorner, sizeof(BPoint)); 60 } 61 } 62 63 void 64 DataTranslationsSettings::SetWindowCorner(BPoint corner) 65 { 66 fCorner=corner; 67 } 68