aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Theme.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Theme.cc')
-rw-r--r--src/FbTk/Theme.cc40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc
index 6ff26a9..cd03f5e 100644
--- a/src/FbTk/Theme.cc
+++ b/src/FbTk/Theme.cc
@@ -39,7 +39,9 @@
39#include <iostream> 39#include <iostream>
40#include <algorithm> 40#include <algorithm>
41 41
42using namespace std; 42using std::cerr;
43using std::endl;
44using std::string;
43 45
44namespace FbTk { 46namespace FbTk {
45 47
@@ -49,8 +51,8 @@ struct LoadThemeHelper {
49 m_tm.loadTheme(*tm); 51 m_tm.loadTheme(*tm);
50 } 52 }
51 void operator ()(ThemeManager::ThemeList &tmlist) { 53 void operator ()(ThemeManager::ThemeList &tmlist) {
52 54
53 for_each(tmlist.begin(), tmlist.end(), 55 for_each(tmlist.begin(), tmlist.end(),
54 *this); 56 *this);
55 // send reconfiguration signal to theme and listeners 57 // send reconfiguration signal to theme and listeners
56 ThemeManager::ThemeList::iterator it = tmlist.begin(); 58 ThemeManager::ThemeList::iterator it = tmlist.begin();
@@ -61,7 +63,7 @@ struct LoadThemeHelper {
61 } 63 }
62 } 64 }
63 65
64 ThemeManager &m_tm; 66 ThemeManager &m_tm;
65}; 67};
66 68
67Theme::Theme(int screen_num):m_screen_num(screen_num) { 69Theme::Theme(int screen_num):m_screen_num(screen_num) {
@@ -78,9 +80,9 @@ ThemeManager &ThemeManager::instance() {
78} 80}
79 81
80ThemeManager::ThemeManager(): 82ThemeManager::ThemeManager():
81 // max_screens: we initialize this later so we can set m_verbose 83 // max_screens: we initialize this later so we can set m_verbose
82 // without having a display connection 84 // without having a display connection
83 m_max_screens(-1), 85 m_max_screens(-1),
84 m_verbose(false), 86 m_verbose(false),
85 m_themelocation("") { 87 m_themelocation("") {
86 88
@@ -96,7 +98,7 @@ bool ThemeManager::registerTheme(Theme &tm) {
96 if (m_max_screens < tm.screenNum() || tm.screenNum() < 0) 98 if (m_max_screens < tm.screenNum() || tm.screenNum() < 0)
97 return false; 99 return false;
98 // TODO: use find and return false if it's already there 100 // TODO: use find and return false if it's already there
99 // instead of unique 101 // instead of unique
100 102
101 m_themes[tm.screenNum()].push_back(&tm); 103 m_themes[tm.screenNum()].push_back(&tm);
102 m_themes[tm.screenNum()].unique(); 104 m_themes[tm.screenNum()].unique();
@@ -112,10 +114,10 @@ bool ThemeManager::unregisterTheme(Theme &tm) {
112 return true; 114 return true;
113} 115}
114 116
115bool ThemeManager::load(const std::string &filename, 117bool ThemeManager::load(const string &filename,
116 const std::string &overlay_filename, int screen_num) { 118 const string &overlay_filename, int screen_num) {
117 std::string location = FbTk::StringUtil::expandFilename(filename); 119 string location = FbTk::StringUtil::expandFilename(filename);
118 std::string prefix = ""; 120 string prefix = "";
119 121
120 if (FileUtil::isDirectory(filename.c_str())) { 122 if (FileUtil::isDirectory(filename.c_str())) {
121 prefix = location; 123 prefix = location;
@@ -139,7 +141,7 @@ bool ThemeManager::load(const std::string &filename,
139 141
140 142
141 if (!overlay_filename.empty()) { 143 if (!overlay_filename.empty()) {
142 std::string overlay_location = FbTk::StringUtil::expandFilename(overlay_filename); 144 string overlay_location = FbTk::StringUtil::expandFilename(overlay_filename);
143 if (FileUtil::isRegularFile(overlay_location.c_str())) { 145 if (FileUtil::isRegularFile(overlay_location.c_str())) {
144 XrmDatabaseHelper overlay_db; 146 XrmDatabaseHelper overlay_db;
145 if (overlay_db.load(overlay_location.c_str())) { 147 if (overlay_db.load(overlay_location.c_str())) {
@@ -204,7 +206,7 @@ bool ThemeManager::loadItem(ThemeItem_base &resource) {
204} 206}
205 207
206/// handles resource item loading with specific name/altname 208/// handles resource item loading with specific name/altname
207bool ThemeManager::loadItem(ThemeItem_base &resource, const std::string &name, const std::string &alt_name) { 209bool ThemeManager::loadItem(ThemeItem_base &resource, const string &name, const string &alt_name) {
208 XrmValue value; 210 XrmValue value;
209 char *value_type; 211 char *value_type;
210 if (XrmGetResource(*m_database, name.c_str(), 212 if (XrmGetResource(*m_database, name.c_str(),
@@ -217,7 +219,7 @@ bool ThemeManager::loadItem(ThemeItem_base &resource, const std::string &name, c
217 return true; 219 return true;
218} 220}
219 221
220std::string ThemeManager::resourceValue(const std::string &name, const std::string &altname) { 222string ThemeManager::resourceValue(const string &name, const string &altname) {
221 XrmValue value; 223 XrmValue value;
222 char *value_type; 224 char *value_type;
223 if (*m_database != 0 && XrmGetResource(*m_database, name.c_str(), 225 if (*m_database != 0 && XrmGetResource(*m_database, name.c_str(),
@@ -232,10 +234,10 @@ void ThemeManager::listItems() {
232 ThemeList::iterator it = m_themelist.begin(); 234 ThemeList::iterator it = m_themelist.begin();
233 ThemeList::iterator it_end = m_themelist.end(); 235 ThemeList::iterator it_end = m_themelist.end();
234 for (; it != it_end; ++it) { 236 for (; it != it_end; ++it) {
235 std::list<ThemeItem_base *>::iterator item = (*it)->itemList().begin(); 237 list<ThemeItem_base *>::iterator item = (*it)->itemList().begin();
236 std::list<ThemeItem_base *>::iterator item_end = (*it)->itemList().end(); 238 list<ThemeItem_base *>::iterator item_end = (*it)->itemList().end();
237 for (; item != item_end; ++item) { 239 for (; item != item_end; ++item) {
238 240
239 if (typeid(**item) == typeid(ThemeItem<Texture>)) { 241 if (typeid(**item) == typeid(ThemeItem<Texture>)) {
240 cerr<<(*item)->name()<<": <texture type>"<<endl; 242 cerr<<(*item)->name()<<": <texture type>"<<endl;
241 cerr<<(*item)->name()<<".pixmap: <filename>"<<endl; 243 cerr<<(*item)->name()<<".pixmap: <filename>"<<endl;
@@ -249,7 +251,7 @@ void ThemeManager::listItems() {
249 cerr<<(*item)->name()<<": <boolean>"<<endl; 251 cerr<<(*item)->name()<<": <boolean>"<<endl;
250 } else if (typeid(**item) == typeid(ThemeItem<PixmapWithMask>)) { 252 } else if (typeid(**item) == typeid(ThemeItem<PixmapWithMask>)) {
251 cerr<<(*item)->name()<<": <filename>"<<endl; 253 cerr<<(*item)->name()<<": <filename>"<<endl;
252 } else if (typeid(**item) == typeid(ThemeItem<std::string>)) { 254 } else if (typeid(**item) == typeid(ThemeItem<string>)) {
253 cerr<<(*item)->name()<<": <string>"<<endl; 255 cerr<<(*item)->name()<<": <string>"<<endl;
254 } else if (typeid(**item) == typeid(ThemeItem<Font>)) { 256 } else if (typeid(**item) == typeid(ThemeItem<Font>)) {
255 cerr<<(*item)->name()<<": <font>"<<endl; 257 cerr<<(*item)->name()<<": <font>"<<endl;
@@ -258,7 +260,7 @@ void ThemeManager::listItems() {
258 } 260 }
259 } 261 }
260 } 262 }
261 263
262} 264}
263*/ 265*/
264}; // end namespace FbTk 266}; // end namespace FbTk