add some CVS information into crashlog
[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::setPixmapFromFile(const char *filename)
23 {
24         loadPNG(m_pixmap, filename);
25         
26         if (!m_pixmap)
27         {
28                 eDebug("ePixmap::setPixmapFromFile: loadPNG failed");
29                 return;
30         }
31         
32                 // TODO: This only works for desktop 0
33         getDesktop(0)->makeCompatiblePixmap(*m_pixmap);
34         event(evtChangedPixmap);
35 }
36
37 int ePixmap::event(int event, void *data, void *data2)
38 {
39         switch (event)
40         {
41         case evtPaint:
42         {
43                 ePtr<eWindowStyle> style;
44                 
45                 getStyle(style);
46                 
47 //              eWidget::event(event, data, data2);
48                 
49                 gPainter &painter = *(gPainter*)data2;
50                 if (m_pixmap)
51                         painter.blit(m_pixmap, ePoint(0, 0), eRect(), m_alphatest?gPainter::BT_ALPHATEST:0);
52                 
53                 return 0;
54         }
55         case evtChangedPixmap:
56                 invalidate();
57                 return 0;
58         default:
59                 return eWidget::event(event, data, data2);
60         }
61 }