From 44d3e2ee98d74e9dca4275a1cdf98a2365401d3f Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 22 Aug 2003 22:17:30 +0000 Subject: fixed theme items for pixmapwithmask --- src/FbTk/Theme.cc | 96 ++++++++++++++++++++++++++++++++++--------------------- 1 file 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.cc,v 1.12 2003/08/19 21:25:26 fluxgen Exp $ +// $Id: Theme.cc,v 1.13 2003/08/22 22:17:30 fluxgen Exp $ #include "Theme.hh" @@ -28,20 +28,15 @@ #include "Color.hh" #include "Texture.hh" #include "App.hh" +#include "Image.hh" +#include "PixmapWithMask.hh" -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - -#ifdef HAVE_XPM -#include -#endif // HAVE_XPM +#include +#include #include - using namespace std; + namespace FbTk { // create default handlers for Color, Font, Texture, int and string @@ -132,33 +127,44 @@ void ThemeItem::load() { if (!m_value.colorTo().setFromString(colorto_name.c_str(), m_tm.screenNum())) m_value.colorTo().setFromString("white", m_tm.screenNum()); - - -#ifdef HAVE_XPM - XpmAttributes xpm_attr; - xpm_attr.valuemask = 0; - Display *dpy = FbTk::App::instance()->display(); - Pixmap pm = 0, mask = 0; - int retvalue = XpmReadFileToPixmap(dpy, - RootWindow(dpy, m_tm.screenNum()), - const_cast(pixmap_name.c_str()), - &pm, - &mask, &xpm_attr); - if (retvalue == 0) { // success - m_value.pixmap() = pm; - if (mask != 0) - XFreePixmap(dpy, mask); - } else { // failure -#ifdef DEBUG - cerr<<"Couldn't load pixmap: "< pm(Image::load(pixmap_name, m_tm.screenNum())); + if (pm.get() == 0) { + cerr<<"Resource("<pixmap().release(); +} + +// not used +template <> +void FbTk::ThemeItem:: +load() { } + +template <> +void FbTk::ThemeItem:: +setDefaultValue() { + // create empty pixmap + (*this)->pixmap() = FbTk::FbPixmap(); // pixmap + (*this)->mask() = FbTk::FbPixmap(); // mask } +template <> +void FbTk::ThemeItem:: +setFromString(const char *str) { + if (str == 0) + setDefaultValue(); + else { + std::auto_ptr pm(Image::load(str, m_tm.screenNum())); + if (pm.get() == 0) + setDefaultValue(); + else { + (*this)->pixmap() = pm->pixmap().release(); + (*this)->mask() = pm->mask().release(); + } + } +} template <> void ThemeItem::setDefaultValue() { @@ -287,5 +293,23 @@ std::string ThemeManager::resourceValue(const std::string &name, const std::stri return ""; } - +/* +void ThemeManager::listItems() { + ThemeList::iterator it = m_themelist.begin(); + ThemeList::iterator it_end = m_themelist.end(); + for (; it != it_end; ++it) { + std::list::iterator item = (*it)->itemList().begin(); + std::list::iterator item_end = (*it)->itemList().end(); + for (; item != item_end; ++item) { + cerr<<(*item)->name()<<":"<)) { + cerr<<(*item)->name()<<".pixmap:"<name()<<".color:"<name()<<".colorTo:"<