diff options
author | fluxgen <fluxgen> | 2003-08-22 22:17:30 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-08-22 22:17:30 (GMT) |
commit | 44d3e2ee98d74e9dca4275a1cdf98a2365401d3f (patch) | |
tree | b6024502bb4fd421d0ba9d0105c4b113e75766a0 /src | |
parent | dafe9f9fb6c2c71711b172b1e73c2da0664a2bd3 (diff) | |
download | fluxbox_paul-44d3e2ee98d74e9dca4275a1cdf98a2365401d3f.zip fluxbox_paul-44d3e2ee98d74e9dca4275a1cdf98a2365401d3f.tar.bz2 |
fixed theme items for pixmapwithmask
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Theme.cc | 96 |
1 files changed, 60 insertions, 36 deletions
diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index 6467fc7..4c1504b 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc | |||
@@ -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: Theme.cc,v 1.12 2003/08/19 21:25:26 fluxgen Exp $ | 22 | // $Id: Theme.cc,v 1.13 2003/08/22 22:17:30 fluxgen Exp $ |
23 | 23 | ||
24 | #include "Theme.hh" | 24 | #include "Theme.hh" |
25 | 25 | ||
@@ -28,20 +28,15 @@ | |||
28 | #include "Color.hh" | 28 | #include "Color.hh" |
29 | #include "Texture.hh" | 29 | #include "Texture.hh" |
30 | #include "App.hh" | 30 | #include "App.hh" |
31 | #include "Image.hh" | ||
32 | #include "PixmapWithMask.hh" | ||
31 | 33 | ||
32 | #include <cstdio> | ||
33 | |||
34 | #ifdef HAVE_CONFIG_H | ||
35 | #include "config.h" | ||
36 | #endif // HAVE_CONFIG_H | ||
37 | |||
38 | #ifdef HAVE_XPM | ||
39 | #include <X11/xpm.h> | ||
40 | #endif // HAVE_XPM | ||
41 | 34 | ||
35 | #include <cstdio> | ||
36 | #include <memory> | ||
42 | #include <iostream> | 37 | #include <iostream> |
43 | |||
44 | using namespace std; | 38 | using namespace std; |
39 | |||
45 | namespace FbTk { | 40 | namespace FbTk { |
46 | 41 | ||
47 | // create default handlers for Color, Font, Texture, int and string | 42 | // create default handlers for Color, Font, Texture, int and string |
@@ -132,33 +127,44 @@ void ThemeItem<FbTk::Texture>::load() { | |||
132 | 127 | ||
133 | if (!m_value.colorTo().setFromString(colorto_name.c_str(), m_tm.screenNum())) | 128 | if (!m_value.colorTo().setFromString(colorto_name.c_str(), m_tm.screenNum())) |
134 | m_value.colorTo().setFromString("white", m_tm.screenNum()); | 129 | m_value.colorTo().setFromString("white", m_tm.screenNum()); |
135 | 130 | ||
136 | 131 | ||
137 | #ifdef HAVE_XPM | 132 | std::auto_ptr<PixmapWithMask> pm(Image::load(pixmap_name, m_tm.screenNum())); |
138 | XpmAttributes xpm_attr; | 133 | if (pm.get() == 0) { |
139 | xpm_attr.valuemask = 0; | 134 | cerr<<"Resource("<<name()+".pixmap"<<"): Failed to load image: "<<pixmap_name<<endl; |
140 | Display *dpy = FbTk::App::instance()->display(); | 135 | } else |
141 | Pixmap pm = 0, mask = 0; | 136 | m_value.pixmap() = pm->pixmap().release(); |
142 | int retvalue = XpmReadFileToPixmap(dpy, | 137 | } |
143 | RootWindow(dpy, m_tm.screenNum()), | 138 | |
144 | const_cast<char *>(pixmap_name.c_str()), | ||
145 | &pm, | ||
146 | &mask, &xpm_attr); | ||
147 | if (retvalue == 0) { // success | ||
148 | m_value.pixmap() = pm; | ||
149 | if (mask != 0) | ||
150 | XFreePixmap(dpy, mask); | ||
151 | } else { // failure | ||
152 | #ifdef DEBUG | ||
153 | cerr<<"Couldn't load pixmap: "<<pixmap_name<<endl; | ||
154 | #endif // DEBUG | ||
155 | // create empty pixmap | ||
156 | m_value.pixmap() = FbTk::FbPixmap(); | ||
157 | } | ||
158 | #endif // HAVE_XPM | ||
159 | 139 | ||
140 | // not used | ||
141 | template <> | ||
142 | void FbTk::ThemeItem<PixmapWithMask>:: | ||
143 | load() { } | ||
144 | |||
145 | template <> | ||
146 | void FbTk::ThemeItem<PixmapWithMask>:: | ||
147 | setDefaultValue() { | ||
148 | // create empty pixmap | ||
149 | (*this)->pixmap() = FbTk::FbPixmap(); // pixmap | ||
150 | (*this)->mask() = FbTk::FbPixmap(); // mask | ||
160 | } | 151 | } |
161 | 152 | ||
153 | template <> | ||
154 | void FbTk::ThemeItem<PixmapWithMask>:: | ||
155 | setFromString(const char *str) { | ||
156 | if (str == 0) | ||
157 | setDefaultValue(); | ||
158 | else { | ||
159 | std::auto_ptr<FbTk::PixmapWithMask> pm(Image::load(str, m_tm.screenNum())); | ||
160 | if (pm.get() == 0) | ||
161 | setDefaultValue(); | ||
162 | else { | ||
163 | (*this)->pixmap() = pm->pixmap().release(); | ||
164 | (*this)->mask() = pm->mask().release(); | ||
165 | } | ||
166 | } | ||
167 | } | ||
162 | 168 | ||
163 | template <> | 169 | template <> |
164 | void ThemeItem<FbTk::Color>::setDefaultValue() { | 170 | void ThemeItem<FbTk::Color>::setDefaultValue() { |
@@ -287,5 +293,23 @@ std::string ThemeManager::resourceValue(const std::string &name, const std::stri | |||
287 | return ""; | 293 | return ""; |
288 | } | 294 | } |
289 | 295 | ||
290 | 296 | /* | |
297 | void ThemeManager::listItems() { | ||
298 | ThemeList::iterator it = m_themelist.begin(); | ||
299 | ThemeList::iterator it_end = m_themelist.end(); | ||
300 | for (; it != it_end; ++it) { | ||
301 | std::list<ThemeItem_base *>::iterator item = (*it)->itemList().begin(); | ||
302 | std::list<ThemeItem_base *>::iterator item_end = (*it)->itemList().end(); | ||
303 | for (; item != item_end; ++item) { | ||
304 | cerr<<(*item)->name()<<":"<<endl; | ||
305 | if (typeid(**item) == typeid(ThemeItem<Texture>)) { | ||
306 | cerr<<(*item)->name()<<".pixmap:"<<endl; | ||
307 | cerr<<(*item)->name()<<".color:"<<endl; | ||
308 | cerr<<(*item)->name()<<".colorTo:"<<endl; | ||
309 | } | ||
310 | } | ||
311 | } | ||
312 | |||
313 | } | ||
314 | */ | ||
291 | }; // end namespace FbTk | 315 | }; // end namespace FbTk |