diff options
author | akir <akir> | 2004-10-21 16:46:50 (GMT) |
---|---|---|
committer | akir <akir> | 2004-10-21 16:46:50 (GMT) |
commit | 66afb1e517325abe97e6ac62640ccd1c224172aa (patch) | |
tree | 571eacdaa27b8c26896e76fdc85e5e7b11107a96 /src | |
parent | 6b541c9162bb219777653196e84c86998bd9641f (diff) | |
download | fluxbox_paul-66afb1e517325abe97e6ac62640ccd1c224172aa.zip fluxbox_paul-66afb1e517325abe97e6ac62640ccd1c224172aa.tar.bz2 |
moved ThemeItems.hh -> ThemeItems.cc
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/ThemeItems.hh | 230 |
1 files changed, 0 insertions, 230 deletions
diff --git a/src/FbTk/ThemeItems.hh b/src/FbTk/ThemeItems.hh deleted file mode 100644 index 60efe2f..0000000 --- a/src/FbTk/ThemeItems.hh +++ /dev/null | |||
@@ -1,230 +0,0 @@ | |||
1 | // ThemeItems.cc for FbTk - Fluxbox ToolKit | ||
2 | // Copyright (c) 2002 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | |||
22 | // $Id: ThemeItems.hh,v 1.9 2004/10/21 10:29:49 akir Exp $ | ||
23 | |||
24 | /// @file implements common theme items | ||
25 | |||
26 | #ifndef THEMEITEMS_HH | ||
27 | #define THEMEITEMS_HH | ||
28 | |||
29 | #include "Theme.hh" | ||
30 | #include "Color.hh" | ||
31 | #include "Texture.hh" | ||
32 | #include "Font.hh" | ||
33 | #include "PixmapWithMask.hh" | ||
34 | #include "Image.hh" | ||
35 | #include "StringUtil.hh" | ||
36 | |||
37 | #include <string> | ||
38 | #ifdef HAVE_CSTDIO | ||
39 | #include <cstdio> | ||
40 | #else | ||
41 | #include <stdio.h> | ||
42 | #endif | ||
43 | #include <iostream> | ||
44 | namespace FbTk { | ||
45 | |||
46 | using namespace std; | ||
47 | |||
48 | // create default handlers for Color, Font, Texture, int and string | ||
49 | template <> | ||
50 | void FbTk::ThemeItem<std::string>::load(const std::string *name, const std::string *altname) { } | ||
51 | |||
52 | template <> | ||
53 | void FbTk::ThemeItem<std::string>::setDefaultValue() { | ||
54 | *(*this) = ""; | ||
55 | } | ||
56 | |||
57 | template <> | ||
58 | void FbTk::ThemeItem<std::string>::setFromString(const char *str) { | ||
59 | *(*this) = (str ? str : ""); | ||
60 | } | ||
61 | |||
62 | template <> | ||
63 | void FbTk::ThemeItem<int>::load(const std::string *name, const std::string *altname) { } | ||
64 | |||
65 | template<> | ||
66 | void FbTk::ThemeItem<int>::setDefaultValue() { | ||
67 | *(*this) = 0; | ||
68 | } | ||
69 | |||
70 | template <> | ||
71 | void FbTk::ThemeItem<int>::setFromString(const char *str) { | ||
72 | if (str == 0) { | ||
73 | setDefaultValue(); | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | if (sscanf(str, "%d", &m_value) < 1) | ||
78 | setDefaultValue(); | ||
79 | } | ||
80 | |||
81 | template <> | ||
82 | void ThemeItem<FbTk::Font>::setDefaultValue() { | ||
83 | if (!m_value.load("fixed")) { | ||
84 | cerr<<"FbTk::ThemeItem<FbTk::Font>: Warning! Failed to load default value 'fixed'"<<endl; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | template <> | ||
89 | void ThemeItem<FbTk::Font>::setFromString(const char *str) { | ||
90 | |||
91 | if (str == 0 || m_value.load(str) == false) { | ||
92 | if (FbTk::ThemeManager::instance().verbose()) { | ||
93 | cerr<<"FbTk::Theme: Error loading font "<< | ||
94 | ((m_value.isAntialias() || m_value.utf8()) ? "(" : "")<< | ||
95 | |||
96 | (m_value.isAntialias() ? "antialias" : "")<< | ||
97 | (m_value.utf8() ? " utf8" : "")<< | ||
98 | |||
99 | ((m_value.isAntialias() || m_value.utf8()) ? ") " : "")<< | ||
100 | "for \""<<name()<<"\" or \""<<altName()<<"\": "<<str<<endl; | ||
101 | |||
102 | cerr<<"FbTk::Theme: Setting default value"<<endl; | ||
103 | } | ||
104 | setDefaultValue(); | ||
105 | } | ||
106 | |||
107 | } | ||
108 | |||
109 | // do nothing | ||
110 | template <> | ||
111 | void ThemeItem<FbTk::Font>::load(const std::string *name, const std::string *altname) { | ||
112 | } | ||
113 | |||
114 | |||
115 | template <> | ||
116 | void ThemeItem<FbTk::Texture>::load(const std::string *o_name, const std::string *o_altname) { | ||
117 | const std::string &m_name = (o_name==0)?name():*o_name; | ||
118 | const std::string &m_altname = (o_altname==0)?altName():*o_altname; | ||
119 | |||
120 | string color_name(ThemeManager::instance(). | ||
121 | resourceValue(m_name+".color", m_altname+".Color")); | ||
122 | string colorto_name(ThemeManager::instance(). | ||
123 | resourceValue(m_name+".colorTo", m_altname+".ColorTo")); | ||
124 | string pixmap_name(ThemeManager::instance(). | ||
125 | resourceValue(m_name+".pixmap", m_altname+".Pixmap")); | ||
126 | |||
127 | |||
128 | // set default value if we failed to load color | ||
129 | if (!m_value.color().setFromString(color_name.c_str(), | ||
130 | m_tm.screenNum())) | ||
131 | m_value.color().setFromString("darkgray", m_tm.screenNum()); | ||
132 | |||
133 | if (!m_value.colorTo().setFromString(colorto_name.c_str(), | ||
134 | m_tm.screenNum())) | ||
135 | m_value.colorTo().setFromString("white", m_tm.screenNum()); | ||
136 | |||
137 | |||
138 | if ((m_value.type() & FbTk::Texture::SOLID) != 0 && (m_value.type() & FbTk::Texture::FLAT) == 0) | ||
139 | m_value.calcHiLoColors(m_tm.screenNum()); | ||
140 | |||
141 | StringUtil::removeFirstWhitespace(pixmap_name); | ||
142 | StringUtil::removeTrailingWhitespace(pixmap_name); | ||
143 | if (pixmap_name.empty()) { | ||
144 | m_value.pixmap() = 0; | ||
145 | return; | ||
146 | } | ||
147 | |||
148 | std::auto_ptr<FbTk::PixmapWithMask> pm(FbTk::Image::load(pixmap_name, | ||
149 | m_tm.screenNum())); | ||
150 | if (pm.get() == 0) { | ||
151 | if (FbTk::ThemeManager::instance().verbose()) { | ||
152 | cerr<<"Resource("<<m_name+".pixmap" | ||
153 | <<"): Failed to load image: "<<pixmap_name<<endl; | ||
154 | } | ||
155 | m_value.pixmap() = 0; | ||
156 | } else | ||
157 | m_value.pixmap() = pm->pixmap().release(); | ||
158 | |||
159 | } | ||
160 | |||
161 | template <> | ||
162 | void ThemeItem<FbTk::Texture>::setDefaultValue() { | ||
163 | m_value.setType(FbTk::Texture::FLAT | FbTk::Texture::SOLID); | ||
164 | load(); // one might forget to add line something: so we try to load something.*: too | ||
165 | } | ||
166 | |||
167 | template <> | ||
168 | void ThemeItem<FbTk::Texture>::setFromString(const char *str) { | ||
169 | m_value.setFromString(str); | ||
170 | if (m_value.type() == 0) // failed to set value | ||
171 | setDefaultValue(); | ||
172 | } | ||
173 | |||
174 | |||
175 | |||
176 | // not used | ||
177 | template <> | ||
178 | void FbTk::ThemeItem<PixmapWithMask>::load(const std::string *name, const std::string *altname) { } | ||
179 | |||
180 | template <> | ||
181 | void FbTk::ThemeItem<PixmapWithMask>:: | ||
182 | setDefaultValue() { | ||
183 | // create empty pixmap | ||
184 | (*this)->pixmap() = 0; | ||
185 | (*this)->mask() = 0; | ||
186 | } | ||
187 | |||
188 | template <> | ||
189 | void FbTk::ThemeItem<PixmapWithMask>:: | ||
190 | setFromString(const char *str) { | ||
191 | if (str == 0) | ||
192 | setDefaultValue(); | ||
193 | else { | ||
194 | std::string filename(str); | ||
195 | |||
196 | StringUtil::removeFirstWhitespace(filename); | ||
197 | StringUtil::removeTrailingWhitespace(filename); | ||
198 | |||
199 | std::auto_ptr<FbTk::PixmapWithMask> pm(Image::load(filename, m_tm.screenNum())); | ||
200 | if (pm.get() == 0) | ||
201 | setDefaultValue(); | ||
202 | else { | ||
203 | (*this)->pixmap() = pm->pixmap().release(); | ||
204 | (*this)->mask() = pm->mask().release(); | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | |||
209 | |||
210 | template <> | ||
211 | void ThemeItem<FbTk::Color>::setDefaultValue() { | ||
212 | m_value.setFromString("white", m_tm.screenNum()); | ||
213 | } | ||
214 | |||
215 | template <> | ||
216 | void ThemeItem<FbTk::Color>::setFromString(const char *str) { | ||
217 | if (!m_value.setFromString(str, m_tm.screenNum())) { | ||
218 | if (FbTk::ThemeManager::instance().verbose()) | ||
219 | cerr<<"FbTk::Theme: Error loading color value for \""<<name()<<"\" or \""<<altName()<<"\"."<<endl; | ||
220 | setDefaultValue(); | ||
221 | } | ||
222 | } | ||
223 | |||
224 | // does nothing | ||
225 | template <> | ||
226 | void ThemeItem<FbTk::Color>::load(const std::string *name, const std::string *altname) { } | ||
227 | |||
228 | } // end namespace FbTk | ||
229 | |||
230 | #endif // THEMEITEMS_HH | ||