servicedvd.cpp: fix merge error (caused by the vob subtitle bug merge)
[enigma2.git] / main / enigma-gdi.cpp
1 #include <stdio.h>
2 #include <libsig_comp.h>
3 #include <lib/base/ebase.h>
4 #include <lib/base/eenv.h>
5 #include <lib/base/eerror.h>
6 #include <lib/base/init.h>
7 #include <lib/base/init_num.h>
8
9 #include <unistd.h>
10
11 #include <lib/gdi/grc.h>
12 #include <lib/gdi/gmaindc.h>
13 #include <lib/gdi/font.h> 
14
15 #include <lib/gui/ewidget.h>
16 #include <lib/gui/ewidgetdesktop.h>
17 #include <lib/gui/elabel.h>
18
19 #ifdef OBJECT_DEBUG
20 int object_total_remaining;
21
22 void object_dump()
23 {
24         printf("%d items left\n", object_total_remaining);
25 }
26 #endif
27
28 void dumpRegion(const gRegion &region)
29 {
30         fprintf(stderr, "extends: %d %d -> %d %d\n", 
31                 region.extends.left(), region.extends.top(),
32                 region.extends.right(), region.extends.bottom());
33         for (int y=0; y<region.extends.bottom(); ++y)
34         {
35                 for (int x=0; x<region.extends.right(); ++x)
36                 {
37                         unsigned char res = ' ';
38                         for (unsigned int i=0; i < region.rects.size(); ++i)
39                                 if (region.rects[i].contains(ePoint(x, y)))
40                                         res = '0' + i;
41                         fprintf(stderr, "%c", res);
42                 }
43                 fprintf(stderr, "\n");
44         }
45 }
46
47 int main()
48 {
49 #ifdef OBJECT_DEBUG
50         atexit(object_dump);
51 #endif
52
53         eInit init;
54
55         init.setRunlevel(eAutoInitNumbers::main);
56         ePtr<gMainDC> my_dc;
57         gMainDC::getInstance(my_dc);
58
59         gPainter p(my_dc);
60         
61         gRGB pal[256];
62         pal[0] = 0;
63         pal[1] = 0xff00ff;
64         pal[2] = 0xffFFff;
65         pal[3] = 0x00ff00;
66         
67         for (int a=0; a<0x10; ++a)
68                 pal[a | 0x10] = (0x111111 * a) | 0xFF;
69         p.setPalette(pal, 0, 256);
70
71         fontRenderClass::getInstance()->AddFont(eEnv::resolve("${datadir}/fonts/arial.ttf"), "Regular", 100);
72
73         p.resetClip(gRegion(eRect(0, 0, 720, 576)));
74         
75          
76         gRegion c;
77         eDebug("0");
78         int i;
79         
80         c |= eRect(0, 20, 100, 10);
81         c |= eRect(0, 50, 100, 10);
82         c |= eRect(10, 10, 80, 100);
83         
84         c -= eRect(20, 20, 40, 40);
85         
86         p.setForegroundColor(gColor(3));
87         p.fill(eRect(0, 0, 100, 100));
88         p.fill(eRect(200, 0, 100, 100));
89         
90         for (int a=0; a<c.rects.size(); ++a)
91                 eDebug("%d %d -> %d %d", c.rects[a].left(), c.rects[a].top(), c.rects[a].right(), c.rects[a].bottom());
92         eDebug("extends: %d %d %d %d", c.extends.left(), c.extends.top(), c.extends.right(), c.extends.bottom());
93         p.setOffset(ePoint(100, 100));
94         p.clip(c);
95
96         p.setBackgroundColor(gColor(1));
97         p.clear();
98         p.setForegroundColor(gColor(2));
99         p.line(ePoint(0, 0), ePoint(220, 190));
100         p.clippop();
101
102         p.setBackgroundColor(gColor(0x1f));
103         p.setForegroundColor(gColor(0x10));
104
105         ePtr<gFont> fnt = new gFont("Regular", 70);
106         p.setFont(fnt);
107         p.renderText(eRect(100, 100, 500, 200), "Hello welt!");
108         
109         sleep(1);
110         return 0;
111 }