fix background transparency..
[enigma2.git] / main / enigma-gui.cpp
1 #include <stdio.h>
2 #include <libsig_comp.h>
3 #include <lib/base/ebase.h>
4 #include <lib/base/eerror.h>
5 #include <lib/base/init.h>
6 #include <lib/base/init_num.h>
7
8 #include <unistd.h>
9
10 #include <lib/gdi/grc.h>
11 #include <lib/gdi/gfbdc.h>
12 #include <lib/gdi/font.h> 
13
14 #include <lib/gui/ewidget.h>
15 #include <lib/gui/ewidgetdesktop.h>
16 #include <lib/gui/elabel.h>
17
18 #ifdef OBJECT_DEBUG
19 int object_total_remaining;
20
21 void object_dump()
22 {
23         printf("%d items left\n", object_total_remaining);
24 }
25 #endif
26
27 void dumpRegion(const gRegion &region)
28 {
29         fprintf(stderr, "extends: %d %d -> %d %d\n", 
30                 region.extends.left(), region.extends.top(),
31                 region.extends.right(), region.extends.bottom());
32         for (int y=0; y<region.extends.bottom(); ++y)
33         {
34                 for (int x=0; x<region.extends.right(); ++x)
35                 {
36                         unsigned char res = ' ';
37                         for (unsigned int i=0; i < region.rects.size(); ++i)
38                                 if (region.rects[i].contains(ePoint(x, y)))
39                                         res = '0' + i;
40                         fprintf(stderr, "%c", res);
41                 }
42                 fprintf(stderr, "\n");
43         }
44 }
45
46 int main()
47 {
48 #ifdef OBJECT_DEBUG
49         atexit(object_dump);
50 #endif
51
52         eInit init;
53
54         init.setRunlevel(eAutoInitNumbers::main);
55         ePtr<gFBDC> my_dc;
56         gFBDC::getInstance(my_dc);
57
58         gPainter p(my_dc);
59         
60         gRGB pal[256];
61         pal[0] = 0;
62         pal[1] = 0xff00ff;
63         pal[2] = 0xffFFff;
64         pal[3] = 0x00ff00;
65         
66         for (int a=0; a<0x10; ++a)
67                 pal[a | 0x10] = (0x111111 * a) | 0xFF;
68         p.setPalette(pal, 0, 256);
69
70         fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100);
71
72         eWidgetDesktop dsk(eSize(720, 576));
73         dsk.setDC(my_dc);
74
75         eWidget *bla = new eWidget(0);
76         dsk.addRootWidget(bla, 0);
77         
78         bla->move(ePoint(100, 100));
79         bla->resize(eSize(200, 200));
80         bla->show();
81
82         eWidget *blablub = new eLabel(bla);
83         blablub->move(ePoint(40, 40));
84         blablub->resize(eSize(100, 100));
85         
86         eWidget *bla2 = new eWidget(0);
87         dsk.addRootWidget(bla2, 0);
88         
89         bla2->move(ePoint(160, 160));
90         bla2->resize(eSize(200, 200));
91         bla2->show();
92
93         dsk.recalcClipRegions();
94
95         dumpRegion(bla->m_visible_region);
96 //      dumpRegion(bla2->m_visible_region);
97 //      dumpRegion(blablub->m_visible_region);
98         
99         eDebug("painting!");
100         
101         dsk.invalidate(gRegion(eRect(0, 0, 720, 576)));
102         dsk.paint();
103
104         sleep(1);
105         return 0;
106 }