- add python, missing gui
[enigma2.git] / main / enigma.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 #include <lib/gui/ewindow.h>
19
20 #include <lib/python/python.h>
21
22 #ifdef OBJECT_DEBUG
23 int object_total_remaining;
24
25 void object_dump()
26 {
27         printf("%d items left\n", object_total_remaining);
28 }
29 #endif
30
31 void dumpRegion(const gRegion &region)
32 {
33         fprintf(stderr, "extends: %d %d -> %d %d (%d rects)\n", 
34                 region.extends.left(), region.extends.top(),
35                 region.extends.right(), region.extends.bottom(), region.rects.size());
36         for (int y=0; y<region.extends.bottom(); ++y)
37         {
38                 for (int x=0; x<region.extends.right(); ++x)
39                 {
40                         unsigned char res = ' ';
41                         for (unsigned int i=0; i < region.rects.size(); ++i)
42                                 if (region.rects[i].contains(ePoint(x, y)))
43                                         res = '0' + i;
44                         fprintf(stderr, "%c", res);
45                 }
46                 fprintf(stderr, "\n");
47         }
48 }
49
50 int main()
51 {
52 #ifdef OBJECT_DEBUG
53         atexit(object_dump);
54 #endif
55         eInit init;
56         
57         init.setRunlevel(eAutoInitNumbers::main);
58
59                 // gui stuff
60 #if 0
61         ePtr<gFBDC> my_dc;
62         gFBDC::getInstance(my_dc);
63 #if 1
64
65         gPainter p(my_dc);
66         
67         gRGB pal[256];
68         pal[0] = 0;
69         pal[1] = 0xff00ff;
70         pal[2] = 0xffFFff;
71         pal[3] = 0x00ff00;
72         
73         for (int a=0; a<0x10; ++a)
74                 pal[a | 0x10] = (0x111111 * a) | 0xFF;
75         p.setPalette(pal, 0, 256);
76
77         fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100);
78
79 #if 0
80         p.resetClip(gRegion(eRect(0, 0, 720, 576)));
81         
82          
83         gRegion c;
84         eDebug("0");
85         int i;
86         
87         c |= eRect(0, 20, 100, 10);
88         c |= eRect(0, 50, 100, 10);
89         c |= eRect(10, 10, 80, 100);
90         
91         c -= eRect(20, 20, 40, 40);
92         
93         p.setForegroundColor(gColor(3));
94         p.fill(eRect(0, 0, 100, 100));
95         p.fill(eRect(200, 0, 100, 100));
96         
97         for (int a=0; a<c.rects.size(); ++a)
98                 eDebug("%d %d -> %d %d", c.rects[a].left(), c.rects[a].top(), c.rects[a].right(), c.rects[a].bottom());
99         eDebug("extends: %d %d %d %d", c.extends.left(), c.extends.top(), c.extends.right(), c.extends.bottom());
100         p.setOffset(ePoint(100, 100));
101         p.clip(c);
102
103         p.setBackgroundColor(gColor(1));
104         p.clear();
105         p.setForegroundColor(gColor(2));
106         p.line(ePoint(0, 0), ePoint(220, 190));
107         p.clippop();
108
109         p.setBackgroundColor(gColor(0x1f));
110         p.setForegroundColor(gColor(0x10));
111
112         ePtr<gFont> fnt = new gFont("Arial", 70);
113         p.setFont(fnt);
114         p.renderText(eRect(100, 100, 500, 200), "Hello welt!");
115 #else
116
117
118         eWidgetDesktop dsk(eSize(720, 576));
119         dsk.setDC(my_dc);
120
121         eWindow *bla = new eWindow(&dsk);
122         
123         bla->move(ePoint(100, 100));
124         bla->resize(eSize(200, 200));
125         bla->show();
126
127         eLabel *blablub = new eLabel(bla->child());
128         blablub->setText("hello world");
129         blablub->move(ePoint(0, 0));
130         blablub->resize(eSize(400,400));
131
132 #if 0
133         eWidget *bla2 = new eWidget(0);
134         dsk.addRootWidget(bla2, 0);
135         
136         bla2->move(ePoint(160, 160));
137         bla2->resize(eSize(200, 200));
138         bla2->show();
139 #endif
140
141         dsk.recalcClipRegions();
142
143 //      dumpRegion(bla->m_visible_region);
144 //      dumpRegion(bla2->m_visible_region);
145 //      dumpRegion(blablub->m_visible_region);
146         
147         eDebug("painting!");
148
149         dsk.invalidate(gRegion(eRect(0, 0, 720, 576)));
150         dsk.paint();
151 #endif
152
153 #else
154
155         extern void contentTest();
156
157         eDebug("Contenttest");
158         contentTest();
159
160 #endif
161
162         p.resetClip(gRegion(eRect(0, 0, 720, 576)));
163 //      p.clear();
164         sleep(1);
165         
166 //      blablub->setText("123");
167 //      dumpRegion(blablub->m_visible_region);
168 //      dumpRegion(dsk.m_dirty_region);
169         dsk.paint();
170         
171
172 #endif
173
174         ePython python;
175         
176         printf("about to execute TEST :)\n");
177         python.execute("mytest", "test");
178
179         return 0;
180 }