1 /* 2 * Copyright (c) 2003-2013, Haiku, Inc. All Rights Reserved. 3 * Copyright (c) 2004 Daniel Furrer <assimil8or@users.sourceforge.net> 4 * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net> 5 * Copyright (c) 1998,99 Kazuho Okui and Takashi Murai. 6 * 7 * Distributed unter the terms of the MIT License. 8 * 9 * Authors: 10 * Kian Duffy, myob@users.sourceforge.net 11 * Daniel Furrer, assimil8or@users.sourceforge.net 12 * Siarzhuk Zharski, zharik@gmx.li 13 */ 14 #ifndef PREF_HANDLER_H 15 #define PREF_HANDLER_H 16 17 18 #include <SupportDefs.h> 19 #include <GraphicsDefs.h> 20 #include <Message.h> 21 22 class BFont; 23 class BPath; 24 25 26 struct pref_defaults { 27 const char *key; 28 const char *item; 29 }; 30 31 #define PREF_TRUE "true" 32 #define PREF_FALSE "false" 33 34 #define PREF_BLOCK_CURSOR "block" 35 #define PREF_IBEAM_CURSOR "ibeam" 36 #define PREF_UNDERLINE_CURSOR "underline" 37 38 39 class BMessage; 40 class BEntry; 41 42 class PrefHandler { 43 public: 44 PrefHandler(const PrefHandler* p); 45 PrefHandler(bool loadSettings = true); 46 ~PrefHandler(); 47 48 static PrefHandler *Default(); 49 static void DeleteDefault(); 50 static void SetDefault(PrefHandler *handler); 51 52 status_t OpenText(const char *path); 53 void SaveDefaultAsText(); 54 void SaveAsText(const char *path, const char *minmtype = NULL, 55 const char *signature = NULL); 56 57 int32 getInt32(const char *key); 58 float getFloat(const char *key); 59 const char* getString(const char *key); 60 bool getBool(const char *key); 61 rgb_color getRGB(const char *key); 62 int getCursor(const char *key); 63 64 void setInt32(const char *key, int32 data); 65 void setFloat(const char *key, float data); 66 void setString(const char *key, const char *data); 67 void setBool(const char *key, bool data); 68 void setRGB(const char *key, const rgb_color data); 69 70 bool IsEmpty() const; 71 72 static status_t GetDefaultPath(BPath& path); 73 74 private: 75 void _ConfirmFont(const BFont *fallbackFont); 76 status_t _LoadFromDefault(const pref_defaults* defaults = NULL); 77 status_t _LoadFromTextFile(const char * path); 78 79 BMessage fContainer; 80 81 static PrefHandler *sPrefHandler; 82 }; 83 84 #endif // PREF_HANDLER_H 85