1 #include <lib/gui/epixmap.h>
2 #include <lib/gdi/epng.h>
3 #include <lib/gui/ewidgetdesktop.h>
5 ePixmap::ePixmap(eWidget *parent)
6 :eWidget(parent), m_alphatest(false)
10 void ePixmap::setAlphatest(bool alphatest)
12 m_alphatest = alphatest;
13 setTransparent(alphatest);
16 void ePixmap::setPixmap(gPixmap *pixmap)
19 event(evtChangedPixmap);
22 void ePixmap::setPixmap(ePtr<gPixmap> &pixmap)
25 event(evtChangedPixmap);
28 void ePixmap::setPixmapFromFile(const char *filename)
30 loadPNG(m_pixmap, filename);
34 eDebug("ePixmap::setPixmapFromFile: loadPNG failed");
38 // TODO: This only works for desktop 0
39 getDesktop(0)->makeCompatiblePixmap(*m_pixmap);
40 event(evtChangedPixmap);
43 void ePixmap::checkSize()
45 /* when we have no pixmap, or a pixmap of different size, we need
46 to enable transparency in any case. */
47 if (m_pixmap && m_pixmap->size() == size() && !m_alphatest)
54 int ePixmap::event(int event, void *data, void *data2)
60 ePtr<eWindowStyle> style;
64 // we don't clear the background before because of performance reasons.
65 // when the pixmap is too small to fix the whole widget area, the widget is
66 // transparent anyway, so the background is already painted.
67 // eWidget::event(event, data, data2);
69 gPainter &painter = *(gPainter*)data2;
71 painter.blit(m_pixmap, ePoint(0, 0), eRect(), m_alphatest?gPainter::BT_ALPHATEST:0);
75 case evtChangedPixmap:
83 return eWidget::event(event, data, data2);