aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Resource.hh53
-rw-r--r--src/RootTheme.hh8
2 files changed, 34 insertions, 27 deletions
diff --git a/src/Resource.hh b/src/Resource.hh
index 0ea2dd1..d657b5b 100644
--- a/src/Resource.hh
+++ b/src/Resource.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Resource.hh,v 1.11 2003/05/07 11:32:42 fluxgen Exp $ 22// $Id: Resource.hh,v 1.12 2003/05/10 13:44:24 fluxgen Exp $
23 23
24#ifndef RESOURCE_HH 24#ifndef RESOURCE_HH
25#define RESOURCE_HH 25#define RESOURCE_HH
@@ -27,9 +27,8 @@
27#include "NotCopyable.hh" 27#include "NotCopyable.hh"
28#include <string> 28#include <string>
29#include <list> 29#include <list>
30/** 30
31 Base class for resources 31/// Base class for resources, this is only used in ResourceManager
32*/
33class Resource_base:private FbTk::NotCopyable 32class Resource_base:private FbTk::NotCopyable
34{ 33{
35public: 34public:
@@ -66,40 +65,47 @@ public:
66 65
67 ResourceManager() { } 66 ResourceManager() { }
68 virtual ~ResourceManager() {} 67 virtual ~ResourceManager() {}
69 /** 68
70 load all resouces registered to this class 69 /// Load all resources registered to this class
71 */ 70 /// @return true on success
72 virtual bool load(const char *filename); 71 virtual bool load(const char *filename);
73 /** 72
74 save all resouces registered to this class 73 /// Save all resouces registered to this class
75 */ 74 /// @return true on success
76 virtual bool save(const char *filename, const char *mergefilename=0); 75 virtual bool save(const char *filename, const char *mergefilename=0);
77 /** 76
78 add resource to list 77 /// Add resource to list, only used in Resource<T>
79 */
80 template <class T> 78 template <class T>
81 void addResource(Resource<T> &r) { 79 void addResource(Resource<T> &r) {
82 m_resourcelist.push_back(&r); 80 m_resourcelist.push_back(&r);
83 m_resourcelist.unique(); 81 m_resourcelist.unique();
84 } 82 }
85 /** 83
86 Remove a specific resource 84 /// Remove a specific resource, only used in Resource<T>
87 */
88 template <class T> 85 template <class T>
89 void removeResource(Resource<T> &r) { 86 void removeResource(Resource<T> &r) {
90 m_resourcelist.remove(&r); 87 m_resourcelist.remove(&r);
91 } 88 }
89
92protected: 90protected:
93 static void ensureXrmIsInitialize(); 91 static void ensureXrmIsInitialize();
94private:
95 92
93private:
96 static bool m_init; 94 static bool m_init;
97 ResourceList m_resourcelist; 95 ResourceList m_resourcelist;
98}; 96};
99 97
98
99/// Real resource class
100/** 100/**
101 Real resource class 101 * usage: Resource<int> someresource(resourcemanager, 10, "someresourcename", "somealternativename"); \n
102*/ 102 * and then implement setFromString and getString \n
103 * example: \n
104 * template <> \n
105 * void Resource<int>::setFromString(const char *str) { \n
106 * *(*this) = atoi(str); \n
107 * }
108 */
103template <typename T> 109template <typename T>
104class Resource:public Resource_base 110class Resource:public Resource_base
105{ 111{
@@ -117,10 +123,13 @@ public:
117 } 123 }
118 124
119 inline void setDefaultValue() { m_value = m_defaultval; } 125 inline void setDefaultValue() { m_value = m_defaultval; }
126 /// sets resource from string, specialized, must be implemented
120 void setFromString(const char *strval); 127 void setFromString(const char *strval);
121 inline Resource<T>& operator = (const T& newvalue) { m_value = newvalue; return *this;} 128 inline Resource<T>& operator = (const T& newvalue) { m_value = newvalue; return *this;}
122 129 /// specialized, must be implemented
123 std::string getString(); 130 /// @return string value of resource
131 std::string getString();
132
124 inline T& operator*() { return m_value; } 133 inline T& operator*() { return m_value; }
125 inline const T& operator*() const { return m_value; } 134 inline const T& operator*() const { return m_value; }
126 inline T *operator->() { return &m_value; } 135 inline T *operator->() { return &m_value; }
@@ -130,4 +139,4 @@ private:
130 ResourceManager &m_rm; 139 ResourceManager &m_rm;
131}; 140};
132 141
133#endif //_RESOURCE_HH_ 142#endif // RESOURCE_HH
diff --git a/src/RootTheme.hh b/src/RootTheme.hh
index e848e66..b1b9406 100644
--- a/src/RootTheme.hh
+++ b/src/RootTheme.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: RootTheme.hh,v 1.1 2003/04/25 10:14:54 fluxgen Exp $ 22// $Id: RootTheme.hh,v 1.2 2003/05/10 13:45:50 fluxgen Exp $
23 23
24#ifndef ROOTTHEME_HH 24#ifndef ROOTTHEME_HH
25#define ROOTTHEME_HH 25#define ROOTTHEME_HH
@@ -30,10 +30,8 @@
30#include <X11/Xlib.h> 30#include <X11/Xlib.h>
31#include <string> 31#include <string>
32 32
33/** 33
34 Contains border color, border size, bevel width and opGC for objects like 34/// Contains border color, border size, bevel width and opGC for objects like geometry window in BScreen
35 geometry window in BScreen
36*/
37class RootTheme: public FbTk::Theme { 35class RootTheme: public FbTk::Theme {
38public: 36public:
39 /// constructor 37 /// constructor