now its possible to call ePixmap.setPixmap from python without use of
[enigma2.git] / lib / gui / epixmap.cpp
1 #include <lib/gui/epixmap.h>
2 #include <lib/gdi/epng.h>
3 #include <lib/gui/ewidgetdesktop.h>
4
5 ePixmap::ePixmap(eWidget *parent)
6         :eWidget(parent), m_alphatest(false)
7 {
8 }
9
10 void ePixmap::setAlphatest(bool alphatest)
11 {
12         m_alphatest = alphatest;
13         setTransparent(alphatest);
14 }
15
16 void ePixmap::setPixmap(gPixmap *pixmap)
17 {
18         m_pixmap = pixmap;
19         event(evtChangedPixmap);
20 }
21
22 void ePixmap::setPixmap(ePtr<gPixmap> &pixmap)
23 {
24         m_pixmap = pixmap;
25         event(evtChangedPixmap);
26 }
27
28 void ePixmap::setPixmapFromFile(const char *filename)
29 {
30         loadPNG(m_pixmap, filename);
31         
32         if (!m_pixmap)
33         {
34                 eDebug("ePixmap::setPixmapFromFile: loadPNG failed");
35                 return;
36         }
37         
38                 // TODO: This only works for desktop 0
39         getDesktop(0)->makeCompatiblePixmap(*m_pixmap);
40         event(evtChangedPixmap);
41 }
42
43 int ePixmap::event(int event, void *data, void *data2)
44 {
45         switch (event)
46         {
47         case evtPaint:
48         {
49                 ePtr<eWindowStyle> style;
50                 
51                 getStyle(style);
52                 
53 //              eWidget::event(event, data, data2);
54                 
55                 gPainter &painter = *(gPainter*)data2;
56                 if (m_pixmap)
57                         painter.blit(m_pixmap, ePoint(0, 0), eRect(), m_alphatest?gPainter::BT_ALPHATEST:0);
58                 
59                 return 0;
60         }
61         case evtChangedPixmap:
62                 invalidate();
63                 return 0;
64         default:
65                 return eWidget::event(event, data, data2);
66         }
67 }