d350f4453530a922de147032f81fa623cbb1a599
[vuplus_dvbapp] / 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 #include <lib/gui/ebutton.h>
18
19 #include <lib/gui/ewindow.h>
20
21 #include <lib/python/python.h>
22
23 #ifdef OBJECT_DEBUG
24 int object_total_remaining;
25
26 void object_dump()
27 {
28         printf("%d items left\n", object_total_remaining);
29 }
30 #endif
31 using namespace std;
32         void print(const string &str, const char *c)
33         {
34                 printf("%s (%s)\n", str.c_str(), c);
35         }
36
37 void dumpRegion(const gRegion &region)
38 {
39         fprintf(stderr, "extends: %d %d -> %d %d (%d rects)\n", 
40                 region.extends.left(), region.extends.top(),
41                 region.extends.right(), region.extends.bottom(), region.rects.size());
42         for (int y=0; y<region.extends.bottom(); ++y)
43         {
44                 for (int x=0; x<region.extends.right(); ++x)
45                 {
46                         unsigned char res = ' ';
47                         for (unsigned int i=0; i < region.rects.size(); ++i)
48                                 if (region.rects[i].contains(ePoint(x, y)))
49                                         res = '0' + i;
50                         fprintf(stderr, "%c", res);
51                 }
52                 fprintf(stderr, "\n");
53         }
54 }
55
56
57 class eMain: public eApplication, public Object
58 {
59         eInit init;
60 public:
61         eMain()
62         {
63                 init.setRunlevel(eAutoInitNumbers::main);
64         }
65 };
66
67 eWidgetDesktop *wdsk;
68
69 int main(int argc, char **argv)
70 {
71 #ifdef OBJECT_DEBUG
72         atexit(object_dump);
73 #endif
74
75
76 #if 1
77         eMain main;
78
79         ePtr<gFBDC> my_dc;
80         gFBDC::getInstance(my_dc);
81
82         gPainter p(my_dc);
83         
84         gRGB pal[256];
85         pal[0] = 0;
86         pal[1] = 0xff00ff;
87         pal[2] = 0xffFFff;
88         pal[3] = 0x00ff00;
89         
90         for (int a=0; a<0x10; ++a)
91                 pal[a | 0x10] = 0x111111 * a;
92         for (int a=0; a<0x10; ++a)
93                 pal[a | 0x20] = (0x111100 * a) | 0xFF;
94         for (int a=0; a<0x10; ++a)
95                 pal[a | 0x30] = (0x110011 * a) | 0xFF00;
96         for (int a=0; a<0x10; ++a)
97                 pal[a | 0x40] = (0x001111 * a) | 0xFF0000;
98         p.setPalette(pal, 0, 256);
99
100         fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100);
101
102         eWidgetDesktop dsk(eSize(720, 576));
103         
104         wdsk = &dsk;
105         dsk.setDC(my_dc);
106
107         eWindow *wnd = new eWindow(&dsk);
108         wnd->move(ePoint(100, 100));
109         wnd->resize(eSize(200, 200));
110         wnd->show();
111
112         eLabel *label = new eButton(wnd);
113         label->setText("Hello!!");
114         label->move(ePoint(40, 40));
115         label->resize(eSize(100, 40));
116
117         label = new eButton(wnd);
118         label->setText("2nd!!");
119         label->move(ePoint(40, 90));
120         label->resize(eSize(100, 40));
121
122 #if 0   
123         eWidget *bla2 = new eWidget(0);
124         dsk.addRootWidget(bla2, 0);
125         
126         bla2->move(ePoint(160, 160));
127         bla2->resize(eSize(200, 200));
128         bla2->show();
129 #endif
130
131 //      dsk.recalcClipRegions();
132 //      dsk.paint();
133 //      dsk.invalidate(gRegion(eRect(0, 0, 720, 576)));
134
135 //      dumpRegion(wnd->m_visible_region);
136 //      dumpRegion(label->m_visible_region);
137 //      dumpRegion(label->m_visible_region);
138         
139         eDebug("painting!");
140         
141
142         ePython python;
143         
144         printf("about to execute TEST :)\n");
145         python.execute("mytest", "test");
146
147         sleep(2);
148 #endif
149
150 #if 0
151
152                 // connections mit parametern: geht! :)
153         using namespace std;
154         using namespace SigC;
155
156         
157         Signal1<void,const string &> printer;
158         int i;
159         for (i=1; i<argc; ++i)
160                 printer.connect(bind(slot(print), argv[i]));
161         printer("hello world\n");
162 #endif
163
164         return 0;
165 }
166
167 eWidgetDesktop *getDesktop()
168 {
169         return wdsk;
170 }
171