make DieMade happy (show current path in Channellist titlebar)
[enigma2.git] / main / enigma.cpp
index b055619e240b3d505c9abc407680db9c163e8aa4..2c719225b6f3ca2ed23d343e5a09faca4ac66fa4 100644 (file)
@@ -1,3 +1,7 @@
+#ifdef WITH_SDL
+#define SDLDC
+#endif
+
 #include <stdio.h>
 #include <libsig_comp.h>
 #include <lib/base/ebase.h>
@@ -9,6 +13,11 @@
 
 #include <lib/gdi/grc.h>
 #include <lib/gdi/gfbdc.h>
+#include <lib/gdi/glcddc.h>
+
+#ifdef WITH_SDL
+#include <lib/gdi/sdl.h>
+#endif
 #include <lib/gdi/font.h> 
 
 #include <lib/gui/ewidget.h>
 
 #include <lib/driver/rc.h>
 
+#include <lib/actions/action.h>
+
+#include <lib/gdi/epng.h>
+
 #ifdef OBJECT_DEBUG
 int object_total_remaining;
 
@@ -39,6 +52,7 @@ void dumpRegion(const gRegion &region)
        fprintf(stderr, "extends: %d %d -> %d %d (%d rects)\n", 
                region.extends.left(), region.extends.top(),
                region.extends.right(), region.extends.bottom(), region.rects.size());
+#if 0
        for (int y=0; y<region.extends.bottom(); ++y)
        {
                for (int x=0; x<region.extends.right(); ++x)
@@ -51,9 +65,11 @@ void dumpRegion(const gRegion &region)
                }
                fprintf(stderr, "\n");
        }
+#endif
+
 }
 
-eWidgetDesktop *wdsk;
+eWidgetDesktop *wdsk, *lcddsk;
 
 // typedef struct _object PyObject;
 
@@ -71,8 +87,11 @@ PSignal1<void,int> &keyPressedSignal()
 
 void keyEvent(const eRCKey &key)
 {
-       if (!key.flags)
-               keyPressed(key.code);
+       ePtr<eActionMap> ptr;
+       eActionMap::getInstance(ptr);
+       ptr->keyPressed(0, key.code, key.flags);
+//     if (!key.flags)
+//             keyPressed(key.code);
 }
 
 /************************************************/
@@ -81,6 +100,8 @@ void keyEvent(const eRCKey &key)
 #include <lib/dvb/idvb.h>
 #include <lib/dvb/dvb.h>
 #include <lib/dvb/db.h>
+#include <lib/dvb/dvbtime.h>
+#include <lib/dvb/epgcache.h>
 
 class eMain: public eApplication, public Object
 {
@@ -88,9 +109,10 @@ class eMain: public eApplication, public Object
        
        ePtr<eDVBResourceManager> m_mgr;
        ePtr<eDVBDB> m_dvbdb;
-
+       ePtr<eDVBLocalTimeHandler> m_locale_time_handler;
        ePtr<eComponentScan> m_scan;
-       
+       ePtr<eEPGCache> m_epgcache;
+
 public:
        eMain()
        {
@@ -99,22 +121,23 @@ public:
                                /* TODO: put into init */
                m_dvbdb = new eDVBDB();
                m_mgr = new eDVBResourceManager();
-               
+               m_locale_time_handler = new eDVBLocalTimeHandler();
+               m_epgcache = new eEPGCache();
                m_mgr->setChannelList(m_dvbdb);
-               
-//             m_scan = new eComponentScan();
-//             m_scan->start();
-
        }
        
        ~eMain()
        {
+               m_dvbdb->saveServicelist();
                m_scan = 0;
        }
 };
 
 /************************************************/
 
+eLabel *lcd_label, *lcd_clock;
+
+int exit_code;
 
 int main(int argc, char **argv)
 {
@@ -122,52 +145,102 @@ int main(int argc, char **argv)
        atexit(object_dump);
 #endif
 
+       // set pythonpath if unset
+       setenv("PYTHONPATH", LIBDIR "/enigma2/python", 0);
+       printf("PYTHONPATH: %s\n", getenv("PYTHONPATH"));
+
 
        ePython python;
        eMain main;
-
+       
 #if 1
+#ifdef SDLDC
+       ePtr<gSDLDC> my_dc;
+       gSDLDC::getInstance(my_dc);
+#else
        ePtr<gFBDC> my_dc;
        gFBDC::getInstance(my_dc);
+       
+       int double_buffer = my_dc->haveDoubleBuffering();
+#endif
 
-       gPainter p(my_dc);
+       ePtr<gLCDDC> my_lcd_dc;
+       gLCDDC::getInstance(my_lcd_dc);
+
+       fontRenderClass::getInstance()->AddFont(FONTDIR "/md_khmurabi_10.ttf", "Regular", 100);
+       fontRenderClass::getInstance()->AddFont(FONTDIR "/ae_AlMateen.ttf", "Replacement", 90);
+       eTextPara::setReplacementFont("Replacement");
        
-       gRGB pal[256];
-       pal[0] = 0;
-       pal[1] = 0xff00ff;
-       pal[2] = 0xffFFff;
-       pal[3] = 0x00ff00;
+                       /* some characters are wrong in the regular font, force them to use the replacement font */
+       for (int i = 0x60c; i <= 0x66d; ++i)
+               eTextPara::forceReplacementGlyph(i);
+       eTextPara::forceReplacementGlyph(0xfdf2);
+       for (int i = 0xfe80; i < 0xff00; ++i)
+               eTextPara::forceReplacementGlyph(i);
        
-       for (int a=0; a<0x10; ++a)
-               pal[a | 0x10] = 0x111111 * a;
-       for (int a=0; a<0x10; ++a)
-               pal[a | 0x20] = (0x111100 * a) | 0xFF;
-       for (int a=0; a<0x10; ++a)
-               pal[a | 0x30] = (0x110011 * a) | 0xFF00;
-       for (int a=0; a<0x10; ++a)
-               pal[a | 0x40] = (0x001111 * a) | 0xFF0000;
-       p.setPalette(pal, 0, 256);
-
-       fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100);
 
        eWidgetDesktop dsk(eSize(720, 576));
+       eWidgetDesktop dsk_lcd(eSize(132, 64));
+       
+/*     if (double_buffer)
+       {
+               eDebug(" - double buffering found, enable buffered graphics mode.");
+               dsk.setCompositionMode(eWidgetDesktop::cmBuffered);
+       } */
        
        wdsk = &dsk;
-       dsk.setBackgroundColor(gColor(0));
+       lcddsk = &dsk_lcd;
+
        dsk.setDC(my_dc);
+       dsk_lcd.setDC(my_lcd_dc);
+
+       ePtr<gPixmap> m_pm;
+       loadPNG(m_pm, DATADIR "/enigma2/pal.png");
+       if (!m_pm)
+       {
+               eFatal("pal.png not found!");
+       } else
+               dsk.setPalette(*m_pm);
+
+       dsk.setBackgroundColor(gRGB(0,0,0,0xFF));
 #endif
 
                /* redrawing is done in an idle-timer, so we have to set the context */
        dsk.setRedrawTask(main);
+       dsk_lcd.setRedrawTask(main);
+
+       eWindow *lcd_win = new eWindow(&dsk_lcd);
+       
+       lcd_win->setFlag(eWindow::wfNoBorder);
+       
+       lcd_win->move(ePoint(0, 0));
+       lcd_win->resize(eSize(132, 64));
+       
+       lcd_label = new eLabel(lcd_win);
+       lcd_label->move(ePoint(0, 4));
+       lcd_label->resize(eSize(132, 42));
+       ePtr<gFont> font = new gFont("Regular", 19);
+       //ePtr<gFont> font = new gFont("Regular", 16);
+       lcd_label->setFont(font);
+
+       lcd_clock = new eLabel(lcd_win);
+       lcd_clock->move(ePoint(50, 46));
+       lcd_clock->resize(eSize(132, 18));
+       ePtr<gFont> clkfont = new gFont("Regular", 16);
+       lcd_clock->setFont(clkfont);
+
+       //lcd_label->setText("bla bla bla, this lcd\nSUCKS!");
+       //lcd_clock->setText("88:88:88");
+
+       lcd_win->show();
        
        eRCInput::getInstance()->keyEvent.connect(slot(keyEvent));
        
        printf("executing main\n");
-       python.execute("mytest", "__main__");
 
-//     eApp->exec();
+       python.execute("mytest", "__main__");
 
-       return 0;
+       return exit_code;
 }
 
 eWidgetDesktop *getDesktop()
@@ -175,12 +248,27 @@ eWidgetDesktop *getDesktop()
        return wdsk;
 }
 
+eApplication *getApplication()
+{
+       return eApp;
+}
+
 void runMainloop()
 {
-       eApp->exec();
+       exit_code = eApp->runLoop();
+}
+
+void quitMainloop(int exitCode)
+{
+       eApp->quit(exitCode);
+}
+
+void setLCD(const char *string)
+{
+       lcd_label->setText(string);
 }
 
-void quitMainloop()
+void setLCDClock(const char *string)
 {
-       eApp->quit(0);
+       lcd_clock->setText(string);
 }