diff options
Diffstat (limited to 'src/Resources.cc')
-rw-r--r-- | src/Resources.cc | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/src/Resources.cc b/src/Resources.cc index feab9ea..9603523 100644 --- a/src/Resources.cc +++ b/src/Resources.cc | |||
@@ -35,7 +35,10 @@ | |||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | #include <string> | 36 | #include <string> |
37 | #include <vector> | 37 | #include <vector> |
38 | using namespace std; | 38 | |
39 | using std::string; | ||
40 | using std::vector; | ||
41 | |||
39 | using namespace FbTk; | 42 | using namespace FbTk; |
40 | 43 | ||
41 | //----------------------------------------------------------------- | 44 | //----------------------------------------------------------------- |
@@ -52,7 +55,7 @@ setFromString(const char* strval) { | |||
52 | } | 55 | } |
53 | 56 | ||
54 | template<> | 57 | template<> |
55 | void FbTk::Resource<std::string>:: | 58 | void FbTk::Resource<string>:: |
56 | setFromString(const char *strval) { | 59 | setFromString(const char *strval) { |
57 | *this = strval; | 60 | *this = strval; |
58 | } | 61 | } |
@@ -64,13 +67,13 @@ setFromString(char const *strval) { | |||
64 | } | 67 | } |
65 | 68 | ||
66 | template<> | 69 | template<> |
67 | void FbTk::Resource<std::vector<WinButton::Type> >:: | 70 | void FbTk::Resource<vector<WinButton::Type> >:: |
68 | setFromString(char const *strval) { | 71 | setFromString(char const *strval) { |
69 | vector<std::string> val; | 72 | vector<string> val; |
70 | StringUtil::stringtok(val, strval); | 73 | StringUtil::stringtok(val, strval); |
71 | //clear old values | 74 | //clear old values |
72 | m_value.clear(); | 75 | m_value.clear(); |
73 | 76 | ||
74 | for (size_t i = 0; i < val.size(); i++) { | 77 | for (size_t i = 0; i < val.size(); i++) { |
75 | if (strcasecmp(val[i].c_str(), "Maximize")==0) | 78 | if (strcasecmp(val[i].c_str(), "Maximize")==0) |
76 | m_value.push_back(WinButton::MAXIMIZE); | 79 | m_value.push_back(WinButton::MAXIMIZE); |
@@ -98,14 +101,14 @@ setFromString(char const *strval) { | |||
98 | 101 | ||
99 | template<> | 102 | template<> |
100 | void FbTk::Resource<unsigned int>:: | 103 | void FbTk::Resource<unsigned int>:: |
101 | setFromString(const char *strval) { | 104 | setFromString(const char *strval) { |
102 | if (sscanf(strval, "%ul", &m_value) != 1) | 105 | if (sscanf(strval, "%ul", &m_value) != 1) |
103 | setDefaultValue(); | 106 | setDefaultValue(); |
104 | } | 107 | } |
105 | 108 | ||
106 | template<> | 109 | template<> |
107 | void FbTk::Resource<long long>:: | 110 | void FbTk::Resource<long long>:: |
108 | setFromString(const char *strval) { | 111 | setFromString(const char *strval) { |
109 | if (sscanf(strval, "%llu", &m_value) != 1) | 112 | if (sscanf(strval, "%llu", &m_value) != 1) |
110 | setDefaultValue(); | 113 | setDefaultValue(); |
111 | } | 114 | } |
@@ -115,26 +118,26 @@ setFromString(const char *strval) { | |||
115 | //---- manipulators for int, bool, and some enums with Resource --- | 118 | //---- manipulators for int, bool, and some enums with Resource --- |
116 | //----------------------------------------------------------------- | 119 | //----------------------------------------------------------------- |
117 | template<> | 120 | template<> |
118 | std::string FbTk::Resource<bool>:: | 121 | string FbTk::Resource<bool>:: |
119 | getString() const { | 122 | getString() const { |
120 | return std::string(**this == true ? "true" : "false"); | 123 | return string(**this == true ? "true" : "false"); |
121 | } | 124 | } |
122 | 125 | ||
123 | template<> | 126 | template<> |
124 | std::string FbTk::Resource<int>:: | 127 | string FbTk::Resource<int>:: |
125 | getString() const { | 128 | getString() const { |
126 | char strval[256]; | 129 | char strval[256]; |
127 | sprintf(strval, "%d", **this); | 130 | sprintf(strval, "%d", **this); |
128 | return std::string(strval); | 131 | return string(strval); |
129 | } | 132 | } |
130 | 133 | ||
131 | template<> | 134 | template<> |
132 | std::string FbTk::Resource<std::string>:: | 135 | string FbTk::Resource<string>:: |
133 | getString() const { return **this; } | 136 | getString() const { return **this; } |
134 | 137 | ||
135 | 138 | ||
136 | template<> | 139 | template<> |
137 | std::string FbTk::Resource<std::vector<WinButton::Type> >:: | 140 | string FbTk::Resource<vector<WinButton::Type> >:: |
138 | getString() const { | 141 | getString() const { |
139 | string retval; | 142 | string retval; |
140 | for (size_t i = 0; i < m_value.size(); i++) { | 143 | for (size_t i = 0; i < m_value.size(); i++) { |
@@ -167,7 +170,7 @@ getString() const { | |||
167 | } | 170 | } |
168 | 171 | ||
169 | template<> | 172 | template<> |
170 | std::string FbTk::Resource<Fluxbox::TabsAttachArea>:: | 173 | string FbTk::Resource<Fluxbox::TabsAttachArea>:: |
171 | getString() const { | 174 | getString() const { |
172 | if (m_value == Fluxbox::ATTACH_AREA_TITLEBAR) | 175 | if (m_value == Fluxbox::ATTACH_AREA_TITLEBAR) |
173 | return "Titlebar"; | 176 | return "Titlebar"; |
@@ -211,43 +214,43 @@ setFromString(const char *strval) { | |||
211 | m_value = ::Layer::BOTTOM; | 214 | m_value = ::Layer::BOTTOM; |
212 | else if (strcasecmp(strval, "Desktop") == 0) | 215 | else if (strcasecmp(strval, "Desktop") == 0) |
213 | m_value = ::Layer::DESKTOP; | 216 | m_value = ::Layer::DESKTOP; |
214 | else | 217 | else |
215 | setDefaultValue(); | 218 | setDefaultValue(); |
216 | } | 219 | } |
217 | 220 | ||
218 | 221 | ||
219 | template<> | 222 | template<> |
220 | std::string FbTk::Resource<Layer>:: | 223 | string FbTk::Resource<Layer>:: |
221 | getString() const { | 224 | getString() const { |
222 | switch (m_value.getNum()) { | 225 | switch (m_value.getNum()) { |
223 | case Layer::MENU: | 226 | case Layer::MENU: |
224 | return std::string("Menu"); | 227 | return string("Menu"); |
225 | case Layer::ABOVE_DOCK: | 228 | case Layer::ABOVE_DOCK: |
226 | return std::string("AboveDock"); | 229 | return string("AboveDock"); |
227 | case Layer::DOCK: | 230 | case Layer::DOCK: |
228 | return std::string("Dock"); | 231 | return string("Dock"); |
229 | case Layer::TOP: | 232 | case Layer::TOP: |
230 | return std::string("Top"); | 233 | return string("Top"); |
231 | case Layer::NORMAL: | 234 | case Layer::NORMAL: |
232 | return std::string("Normal"); | 235 | return string("Normal"); |
233 | case Layer::BOTTOM: | 236 | case Layer::BOTTOM: |
234 | return std::string("Bottom"); | 237 | return string("Bottom"); |
235 | case Layer::DESKTOP: | 238 | case Layer::DESKTOP: |
236 | return std::string("Desktop"); | 239 | return string("Desktop"); |
237 | default: | 240 | default: |
238 | char tmpstr[128]; | 241 | char tmpstr[128]; |
239 | sprintf(tmpstr, "%d", m_value.getNum()); | 242 | sprintf(tmpstr, "%d", m_value.getNum()); |
240 | return std::string(tmpstr); | 243 | return string(tmpstr); |
241 | } | 244 | } |
242 | } | 245 | } |
243 | 246 | ||
244 | template<> | 247 | template<> |
245 | void FbTk::Resource<long>:: | 248 | void FbTk::Resource<long>:: |
246 | setFromString(const char *strval) { | 249 | setFromString(const char *strval) { |
247 | if (sscanf(strval, "%ld", &m_value) != 1) | 250 | if (sscanf(strval, "%ld", &m_value) != 1) |
248 | setDefaultValue(); | 251 | setDefaultValue(); |
249 | } | 252 | } |
250 | 253 | ||
251 | template<> | 254 | template<> |
252 | string FbTk::Resource<long>:: | 255 | string FbTk::Resource<long>:: |
253 | getString() const { | 256 | getString() const { |