fixed theme items for pixmapwithmask
This commit is contained in:
parent
dafe9f9fb6
commit
44d3e2ee98
1 changed files with 60 additions and 36 deletions
|
@ -19,7 +19,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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"
|
#include "Theme.hh"
|
||||||
|
|
||||||
|
@ -28,20 +28,15 @@
|
||||||
#include "Color.hh"
|
#include "Color.hh"
|
||||||
#include "Texture.hh"
|
#include "Texture.hh"
|
||||||
#include "App.hh"
|
#include "App.hh"
|
||||||
|
#include "Image.hh"
|
||||||
|
#include "PixmapWithMask.hh"
|
||||||
|
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <memory>
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "config.h"
|
|
||||||
#endif // HAVE_CONFIG_H
|
|
||||||
|
|
||||||
#ifdef HAVE_XPM
|
|
||||||
#include <X11/xpm.h>
|
|
||||||
#endif // HAVE_XPM
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace FbTk {
|
namespace FbTk {
|
||||||
|
|
||||||
// create default handlers for Color, Font, Texture, int and string
|
// create default handlers for Color, Font, Texture, int and string
|
||||||
|
@ -134,32 +129,43 @@ void ThemeItem<FbTk::Texture>::load() {
|
||||||
m_value.colorTo().setFromString("white", m_tm.screenNum());
|
m_value.colorTo().setFromString("white", m_tm.screenNum());
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_XPM
|
std::auto_ptr<PixmapWithMask> pm(Image::load(pixmap_name, m_tm.screenNum()));
|
||||||
XpmAttributes xpm_attr;
|
if (pm.get() == 0) {
|
||||||
xpm_attr.valuemask = 0;
|
cerr<<"Resource("<<name()+".pixmap"<<"): Failed to load image: "<<pixmap_name<<endl;
|
||||||
Display *dpy = FbTk::App::instance()->display();
|
} else
|
||||||
Pixmap pm = 0, mask = 0;
|
m_value.pixmap() = pm->pixmap().release();
|
||||||
int retvalue = XpmReadFileToPixmap(dpy,
|
|
||||||
RootWindow(dpy, m_tm.screenNum()),
|
|
||||||
const_cast<char *>(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: "<<pixmap_name<<endl;
|
|
||||||
#endif // DEBUG
|
|
||||||
// create empty pixmap
|
|
||||||
m_value.pixmap() = FbTk::FbPixmap();
|
|
||||||
}
|
|
||||||
#endif // HAVE_XPM
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// not used
|
||||||
|
template <>
|
||||||
|
void FbTk::ThemeItem<PixmapWithMask>::
|
||||||
|
load() { }
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void FbTk::ThemeItem<PixmapWithMask>::
|
||||||
|
setDefaultValue() {
|
||||||
|
// create empty pixmap
|
||||||
|
(*this)->pixmap() = FbTk::FbPixmap(); // pixmap
|
||||||
|
(*this)->mask() = FbTk::FbPixmap(); // mask
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
void FbTk::ThemeItem<PixmapWithMask>::
|
||||||
|
setFromString(const char *str) {
|
||||||
|
if (str == 0)
|
||||||
|
setDefaultValue();
|
||||||
|
else {
|
||||||
|
std::auto_ptr<FbTk::PixmapWithMask> pm(Image::load(str, m_tm.screenNum()));
|
||||||
|
if (pm.get() == 0)
|
||||||
|
setDefaultValue();
|
||||||
|
else {
|
||||||
|
(*this)->pixmap() = pm->pixmap().release();
|
||||||
|
(*this)->mask() = pm->mask().release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void ThemeItem<FbTk::Color>::setDefaultValue() {
|
void ThemeItem<FbTk::Color>::setDefaultValue() {
|
||||||
m_value.setFromString("white", m_tm.screenNum());
|
m_value.setFromString("white", m_tm.screenNum());
|
||||||
|
@ -287,5 +293,23 @@ std::string ThemeManager::resourceValue(const std::string &name, const std::stri
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void ThemeManager::listItems() {
|
||||||
|
ThemeList::iterator it = m_themelist.begin();
|
||||||
|
ThemeList::iterator it_end = m_themelist.end();
|
||||||
|
for (; it != it_end; ++it) {
|
||||||
|
std::list<ThemeItem_base *>::iterator item = (*it)->itemList().begin();
|
||||||
|
std::list<ThemeItem_base *>::iterator item_end = (*it)->itemList().end();
|
||||||
|
for (; item != item_end; ++item) {
|
||||||
|
cerr<<(*item)->name()<<":"<<endl;
|
||||||
|
if (typeid(**item) == typeid(ThemeItem<Texture>)) {
|
||||||
|
cerr<<(*item)->name()<<".pixmap:"<<endl;
|
||||||
|
cerr<<(*item)->name()<<".color:"<<endl;
|
||||||
|
cerr<<(*item)->name()<<".colorTo:"<<endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
}; // end namespace FbTk
|
}; // end namespace FbTk
|
||||||
|
|
Loading…
Reference in a new issue