- sdl is now default output
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 15 Apr 2005 18:00:24 +0000 (18:00 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 15 Apr 2005 18:00:24 +0000 (18:00 +0000)
 - added skinned window style
 - added background colors
 - some RGB color support (but still not how i like it)
 - some minor bugfixes

30 files changed:
lib/components/scan.cpp
lib/dvb/frontend.cpp
lib/dvb/idvb.h
lib/dvb/specs.h
lib/gdi/epng.cpp
lib/gdi/gfbdc.cpp
lib/gdi/gpixmap.cpp
lib/gdi/gpixmap.h
lib/gdi/grc.cpp
lib/gdi/grc.h
lib/gui/Makefile.am
lib/gui/elistbox.cpp
lib/gui/epixmap.cpp
lib/gui/epixmap.h
lib/gui/ewidget.cpp
lib/gui/ewidget.h
lib/gui/ewidgetdesktop.cpp
lib/gui/ewidgetdesktop.h
lib/gui/ewindow.cpp
lib/gui/ewindow.h
lib/gui/ewindowstyle.cpp
lib/gui/ewindowstyle.h
lib/gui/ewindowstyleskinned.cpp [new file with mode: 0644]
lib/gui/ewindowstyleskinned.h [new file with mode: 0644]
lib/python/enigma_python.i
main/Makefile.am
main/enigma.cpp
mytest.py
screens.py
skin.py

index 8fb60b5863237ba81fe3b932597b539715fab42b..c82d04efa39547ffc139a9c024af51d13149111f 100644 (file)
@@ -59,7 +59,9 @@ int eComponentScan::start()
        ePtr<eDVBResourceManager> mgr;
        
        eDVBResourceManager::getInstance(mgr);
-       
+
+       eDVBFrontendParameters *fe = new eDVBFrontendParameters();
+#if 0  
        eDVBFrontendParametersSatellite fesat;
                
        fesat.frequency = 11817000; // 12070000;
@@ -69,9 +71,20 @@ int eComponentScan::start()
        fesat.inversion = eDVBFrontendParametersSatellite::Inversion::Off;
        fesat.orbital_position = 192;
 
-       eDVBFrontendParameters *fe = new eDVBFrontendParameters();
        
        fe->setDVBS(fesat);
+#endif
+
+       eDVBFrontendParametersTerrestrial fet;
+       fet.frequency = 626000000;
+       fet.inversion = eDVBFrontendParametersTerrestrial::Inversion::Unknown;
+       fet.bandwidth = eDVBFrontendParametersTerrestrial::Bandwidth::Bw8MHz;
+       fet.code_rate_HP = fet.code_rate_LP = eDVBFrontendParametersTerrestrial::FEC::fAuto;
+       fet.modulation = eDVBFrontendParametersTerrestrial::Modulation::QAM16;
+       fet.transmission_mode = eDVBFrontendParametersTerrestrial::TransmissionMode::TM8k;
+       fet.guard_interval = eDVBFrontendParametersTerrestrial::GuardInterval::GI_1_32;
+       fet.hierarchy = eDVBFrontendParametersTerrestrial::Hierarchy::HNone;
+       fe->setDVBT(fet);
        
        ePtr<iDVBChannel> channel;
 
index 690824db27a39f89da858a218d334c749c9b8fec..1322ea23da5f0ab81cd71cb19ce0a362a54bda0f 100644 (file)
@@ -261,7 +261,7 @@ eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok): m_type(-1)
                ok = 0;
                return;
        }
-       eDebug("detected %s frontend", "satellite\0cable\0    terrestrial"+feSatellite*9);
+       eDebug("detected %s frontend", "satellite\0cable\0    terrestrial"+fe_info.type*9);
        ok = 1;
 
        m_sn = new eSocketNotifier(eApp, m_fd, eSocketNotifier::Read);
@@ -365,6 +365,8 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
 
        feEvent(-1);
        
+       eDebug("eDVBFrontend::tune. type: %d", m_type);
+       
        switch (m_type)
        {
        case feSatellite:
@@ -403,11 +405,69 @@ RESULT eDVBFrontend::tune(const iDVBFrontendParameters &where)
        {
                eDVBFrontendParametersTerrestrial feparm;
                if (where.getDVBT(feparm))
+               {
+                       eDebug("no -T data");
+                       return -EINVAL;
+               }
+               parm.frequency = feparm.frequency;
+               
+               switch (feparm.bandwidth)
+               {
+               case eDVBFrontendParametersTerrestrial::Bandwidth::Bw8MHz:
+                       parm.u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
+                       break;
+               case eDVBFrontendParametersTerrestrial::Bandwidth::Bw7MHz:
+                       parm.u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
+                       break;
+               case eDVBFrontendParametersTerrestrial::Bandwidth::Bw6MHz:
+                       parm.u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
+                       break;
+               case eDVBFrontendParametersTerrestrial::Bandwidth::BwAuto:
+                       parm.u.ofdm.bandwidth = BANDWIDTH_AUTO;
+                       break;
+               default:
+                       eWarning("invalid OFDM bandwith");
                        return -EINVAL;
-               eFatal("terrestrial tuning nyi");
+               }
+               
+               parm.u.ofdm.code_rate_HP = FEC_AUTO;
+               parm.u.ofdm.code_rate_LP = FEC_AUTO;
+               
+               switch (feparm.modulation)
+               {
+               case eDVBFrontendParametersTerrestrial::Modulation::QPSK:
+                       parm.u.ofdm.constellation = QPSK;
+                       break;
+               case eDVBFrontendParametersTerrestrial::Modulation::QAM16:
+                       parm.u.ofdm.constellation = QAM_16;
+                       break;
+               case eDVBFrontendParametersTerrestrial::Modulation::Auto:
+                       parm.u.ofdm.constellation = QAM_AUTO;
+                       break;
+               }
+               
+               switch (feparm.transmission_mode)
+               {
+               case eDVBFrontendParametersTerrestrial::TransmissionMode::TM2k:
+                       parm.u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
+                       break;
+               case eDVBFrontendParametersTerrestrial::TransmissionMode::TM8k:
+                       parm.u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
+                       break;
+               case eDVBFrontendParametersTerrestrial::TransmissionMode::TMAuto:
+                       parm.u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO;
+                       break;
+               }
+               
+               parm.u.ofdm.guard_interval = GUARD_INTERVAL_AUTO;
+               parm.u.ofdm.hierarchy_information = HIERARCHY_AUTO;
+               parm.inversion = INVERSION_AUTO;
+               break;
        }
        }
        
+       eDebug("setting frontend..\n");
+       
        if (ioctl(m_fd, FE_SET_FRONTEND, &parm) == -1)
        {
                perror("FE_SET_FRONTEND failed");
index da626866d6ec44d51c5dc0172697925dfa2722fd..c201c1a47dbed1d7fb6719bc35c211c2dcaf8f46 100644 (file)
@@ -291,7 +291,57 @@ struct eDVBFrontendParametersCable
 
 struct eDVBFrontendParametersTerrestrial
 {
-       int unknown;
+       unsigned int frequency;
+       struct Bandwidth {
+               enum { Bw8MHz, Bw7MHz, Bw6MHz, BwAuto };
+       };
+       
+       struct FEC
+       {
+               enum {
+                       fNone, f1_2, f2_3, f3_4, f5_6, f7_8, fAuto
+               };
+       };
+       
+       struct TransmissionMode {
+               enum {
+                       TM2k, TM8k, TMAuto
+               };
+       };
+       
+       struct GuardInterval {
+               enum {
+                       GI_1_32, GI_1_16, GI_1_8, GI_1_4, GI_Auto
+               };
+       };
+       
+       struct Hierarchy {
+               enum {
+                       HNone, H1, H2, H4, HAuto
+               };
+       };
+       
+       struct Modulation {
+               enum {
+                       QPSK, QAM16, Auto
+               };
+       };
+
+       struct Inversion
+       {
+               enum {
+                       On, Off, Unknown
+               };
+       };
+       
+       int bandwidth;
+       int code_rate_HP, code_rate_LP;
+       int modulation;
+       int transmission_mode;
+       int guard_interval;
+       int hierarchy;
+       int inversion;
+       
        void set(const TerrestrialDeliverySystemDescriptor  &);
 };
 
index 544573427de18d26baa4932d6f60e823457a25a0..1a0353e576c2cb94d5b509a0c858eb330db55f86 100644 (file)
@@ -38,7 +38,7 @@ public:
        {
                m_spec.pid     = ServiceDescriptionTable::PID;
                m_spec.tid     = ServiceDescriptionTable::TID;
-               m_spec.timeout = ServiceDescriptionTable::TIMEOUT;
+               m_spec.timeout = 20000; // ServiceDescriptionTable::TIMEOUT;
                m_spec.flags   = eDVBTableSpec::tfAnyVersion |
                        eDVBTableSpec::tfHaveTID | eDVBTableSpec::tfCheckCRC |
                        eDVBTableSpec::tfHaveTimeout;
index 0d1072f80f67d4f4a2bbc8d531d590ea9c226333..8a4c3f4cf35cdbe49abedd69b443103123653e4a 100644 (file)
@@ -66,7 +66,7 @@ int loadPNG(ePtr<gPixmap> &result, const char *filename)
        
        png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0);
        
-//     eDebug("%s: %dx%dx%d png, %d", filename, (int)width, (int)height, (int)bit_depth, color_type);
+       eDebug("%s: %dx%dx%d png, %d", filename, (int)width, (int)height, (int)bit_depth, color_type);
        
        if (color_type != 6)
        {
index d5ce9f3cbced31dc39c1b0fd56c3ea57329d4e79..83ffed2b9280439a6c1eb4c3117752c85bce8c31 100644 (file)
@@ -157,4 +157,4 @@ void gFBDC::reloadSettings()
        setPalette();
 }
 
-eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");
+// eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");
index fe0c0a1f41c34ef9764667c941ba0861c761e3a0..e9c469c425714241441a5ad7717b3754e4887ce6 100644 (file)
@@ -139,9 +139,9 @@ void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag
 {
        for (unsigned int i=0; i<clip.rects.size(); ++i)
        {
-               eRect area=eRect(pos, src.getSize());
+               eRect area=eRect(pos, src.size());
                area&=clip.rects[i];
-               area&=eRect(ePoint(0, 0), getSize());
+               area&=eRect(ePoint(0, 0), size());
                if ((area.width()<0) || (area.height()<0))
                        continue;
 
@@ -153,7 +153,7 @@ void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag
                        __u8 *srcptr=(__u8*)src.surface->data;
                        __u8 *dstptr=(__u8*)surface->data;
        
-                       srcptr+=srcarea.left()*surface->bypp+srcarea.top()*src.surface->stride;
+                       srcptr+=srcarea.left()*src.surface->bypp+srcarea.top()*src.surface->stride;
                        dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
                        for (int y=0; y<area.height(); y++)
                        {
@@ -193,7 +193,7 @@ void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag
                                pal[i]^=0xFF000000;
                        }
        
-                       srcptr+=srcarea.left()*surface->bypp+srcarea.top()*src.surface->stride;
+                       srcptr+=srcarea.left()*src.surface->bypp+srcarea.top()*src.surface->stride;
                        dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
                        for (int y=0; y<area.height(); y++)
                        {
@@ -231,8 +231,10 @@ void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag
 
 void gPixmap::mergePalette(const gPixmap &target)
 {
+       eDebug("merge palette! %p %p", surface, target.surface);
        if ((!surface->clut.colors) || (!target.surface->clut.colors))
                return;
+#if 0
        gColor *lookup=new gColor[surface->clut.colors];
 
        for (int i=0; i<surface->clut.colors; i++)
@@ -253,6 +255,7 @@ void gPixmap::mergePalette(const gPixmap &target)
        }
        
        delete [] lookup;
+#endif
 }
 
 static inline int sgn(int a)
index f29a0fe747cbb805a7bf40fb8e5201623e7833c0..d598fdbd3786a9f78661f5a6917cad88d6ffec66 100644 (file)
@@ -97,8 +97,9 @@ struct gSurfaceSystem: gSurface
        ~gSurfaceSystem();
 };
 
-struct gPixmap: public iObject
+class gPixmap: public iObject
 {
+private:
 DECLARE_REF(gPixmap);
 private:
        friend class gDC;
@@ -121,7 +122,7 @@ public:
        gPixmap *lock();
        void unlock();
        
-       eSize getSize() const { return eSize(surface->x, surface->y); }
+       eSize size() const { return eSize(surface->x, surface->y); }
        
        gPixmap(gSurface *surface);
        gPixmap(eSize, int bpp);
index 3b5476a2ba85df4b51e7621f2a70d2708fc4ce2c..9cb1a0720f9f8044fd40e77d7a9ba3ae7663a892 100644 (file)
@@ -1,5 +1,5 @@
 // for debugging use:
-// #define SYNC_PAINT
+#define SYNC_PAINT
 #include <unistd.h>
 #ifndef SYNC_PAINT
 #include <pthread.h>
@@ -116,6 +116,28 @@ void gPainter::setForegroundColor(const gColor &color)
        m_rc->submit(o);
 }
 
+void gPainter::setBackgroundColor(const gRGB &color)
+{
+       gOpcode o;
+       o.opcode = gOpcode::setBackgroundColorRGB;
+       o.dc = m_dc.grabRef();
+       o.parm.setColorRGB = new gOpcode::para::psetColorRGB;
+       o.parm.setColorRGB->color = color;
+       
+       m_rc->submit(o);
+}
+
+void gPainter::setForegroundColor(const gRGB &color)
+{
+       gOpcode o;
+       o.opcode = gOpcode::setForegroundColorRGB;
+       o.dc = m_dc.grabRef();
+       o.parm.setColorRGB = new gOpcode::para::psetColorRGB;
+       o.parm.setColorRGB->color = color;
+       
+       m_rc->submit(o);
+}
+
 void gPainter::setFont(gFont *font)
 {
        gOpcode o;
@@ -221,9 +243,10 @@ void gPainter::setPalette(gRGB *colors, int start, int len)
 void gPainter::mergePalette(gPixmap *target)
 {
        gOpcode o;
-       o.opcode=gOpcode::mergePalette;
+       o.opcode = gOpcode::mergePalette;
        o.dc = m_dc.grabRef();
        target->AddRef();
+       o.parm.mergePalette = new gOpcode::para::pmergePalette;
        o.parm.mergePalette->target = target;
        m_rc->submit(o);
 }
@@ -336,6 +359,14 @@ void gDC::exec(gOpcode *o)
                m_foreground_color = o->parm.setColor->color;
                delete o->parm.setColor;
                break;
+       case gOpcode::setBackgroundColorRGB:
+               m_background_color = m_pixmap->surface->clut.findColor(o->parm.setColorRGB->color);
+               delete o->parm.setColorRGB;
+               break;
+       case gOpcode::setForegroundColorRGB:
+               m_foreground_color = m_pixmap->surface->clut.findColor(o->parm.setColorRGB->color);
+               delete o->parm.setColorRGB;
+               break;
        case gOpcode::setFont:
                m_current_font = o->parm.setFont->font;
                o->parm.setFont->font->Release();
@@ -404,7 +435,8 @@ void gDC::exec(gOpcode *o)
                
                if (o->parm.blit->clip.valid())
                {
-                       clip.intersect(gRegion(o->parm.blit->clip), clip);
+                       o->parm.blit->clip.moveBy(m_current_offset);
+                       clip.intersect(gRegion(o->parm.blit->clip), m_current_clip);
                } else
                        clip = m_current_clip;
                
@@ -426,12 +458,10 @@ void gDC::exec(gOpcode *o)
                delete o->parm.setPalette;
                break;
        case gOpcode::mergePalette:
-#if 0
-               pixmap->mergePalette(*o->parm.blit->pixmap);
-               o->parm.blit->pixmap->unlock();
-               delete o->parm.blit;
-#endif
-               break;
+               m_pixmap->mergePalette(*o->parm.mergePalette->target);
+               o->parm.mergePalette->target->Release();
+               delete o->parm.mergePalette;
+               break; 
        case gOpcode::line:
        {
                ePoint start = o->parm.line->start + m_current_offset, end = o->parm.line->end + m_current_offset;
@@ -447,7 +477,7 @@ void gDC::exec(gOpcode *o)
                break;
        case gOpcode::setClip:
                o->parm.clip->region.moveBy(m_current_offset);
-               m_current_clip = o->parm.clip->region & eRect(ePoint(0, 0), m_pixmap->getSize());
+               m_current_clip = o->parm.clip->region & eRect(ePoint(0, 0), m_pixmap->size());
                delete o->parm.clip;
                break;
        case gOpcode::popClip:
index 8de5dadf3fb935eb37587e199bf1adf3044ea262..574391789c70d39ebf3bcefc9a8e998c8e157275 100644 (file)
@@ -41,6 +41,9 @@ struct gOpcode
                setBackgroundColor,
                setForegroundColor,
                
+               setBackgroundColorRGB,
+               setForegroundColorRGB,
+               
                setOffset,
                
                setClip, addClip, popClip,
@@ -114,6 +117,11 @@ struct gOpcode
                        gColor color;
                } *setColor;
                
+               struct psetColorRGB
+               {
+                       gRGB color;
+               } *setColorRGB;
+               
                struct psetOffset
                {
                        ePoint value;
@@ -176,6 +184,9 @@ public:
        void setBackgroundColor(const gColor &color);
        void setForegroundColor(const gColor &color);
 
+       void setBackgroundColor(const gRGB &color);
+       void setForegroundColor(const gRGB &color);
+
        void setFont(gFont *font);
                /* flags only THESE: */
        enum
@@ -240,7 +251,7 @@ public:
        gRegion &getClip() { return m_current_clip; }
        int getPixmap(ePtr<gPixmap> &pm) { pm = m_pixmap; return 0; }
        gRGB getRGB(gColor col);
-       virtual eSize getSize() { return m_pixmap->getSize(); }
+       virtual eSize size() { return m_pixmap->size(); }
 };
 
 #endif
index 076ee36a8cb08537f72da9ed22ca1e1ef3cebd63..44f5a16db68140f614ed408c250c58334846ad00 100644 (file)
@@ -7,6 +7,6 @@ noinst_LIBRARIES = libenigma_gui.a
 libenigma_gui_a_SOURCES = \
        ebutton.cpp elabel.cpp eslider.cpp ewidget.cpp ewidgetdesktop.cpp  \
        ewindow.cpp ewindowstyle.cpp elistbox.cpp elistboxcontent.cpp \
-       epixmap.cpp
+       epixmap.cpp ewindowstyleskinned.cpp
 
 
index 7764e6b5d503a9a19ecc4f621fac5ccae3c34c56..2c2525c9c9aa29e52fc504a5421a209c2550102d 100644 (file)
@@ -135,7 +135,7 @@ int eListbox::event(int event, void *data, void *data2)
                        moveSelection((int)data2);
                        return 1;
                }
-               break;
+               return 0;
        default:
                return eWidget::event(event, data, data2);
        }
index a0655aa9df8c0a873cac8bde5b65e01c396c00c9..797c675991f60ad4fc26d7169d11300cd2bd5bbf 100644 (file)
@@ -1,4 +1,6 @@
 #include <lib/gui/epixmap.h>
+#include <lib/gdi/epng.h>
+#include <lib/gui/ewidgetdesktop.h>
 
 ePixmap::ePixmap(eWidget *parent): eWidget(parent)
 {
@@ -10,6 +12,15 @@ void ePixmap::setPixmap(gPixmap *pixmap)
        event(evtChangedPixmap);
 }
 
+void ePixmap::setPixmapFromFile(const char *filename)
+{
+       loadPNG(m_pixmap, filename);
+       
+               // TODO
+       getDesktop()->makeCompatiblePixmap(*m_pixmap);
+       event(evtChangedPixmap);
+}
+
 int ePixmap::event(int event, void *data, void *data2)
 {
        switch (event)
index 8a12e2e9037416c0b1c887f0ff3af313a3ad215c..220db1ffc527b6eaede74848446ab6def4841337 100644 (file)
@@ -9,6 +9,7 @@ public:
        ePixmap(eWidget *parent);
        
        void setPixmap(gPixmap *pixmap);
+       void setPixmapFromFile(const char *filename);
 protected:
        ePtr<gPixmap> m_pixmap;
        int event(int event, void *data=0, void *data2=0);
index 7f0893613939d89642293f2545e67b63c1c08612..3ba248ff5eda6f81cdcf7d80513c6a7db28d7ad0 100644 (file)
@@ -7,6 +7,7 @@ eWidget::eWidget(eWidget *parent): m_parent(parent ? parent->child() : 0)
 {
        m_vis = 0;
        m_desktop = 0;
+       m_have_background_color = 0;
        
        if (m_parent)
                m_vis = wVisShow;
@@ -45,10 +46,12 @@ void eWidget::resize(eSize size)
                   fits into the other completely, and invalidate
                   only once. */
        eSize old_size = m_size;
-       event(evtWillChangeSize, &size);
+       eSize offset = eSize(0, 0);
+       event(evtWillChangeSize, &size, &offset);
        if (old_size == m_size)
                return;
-
+       move(position() + offset);
+       
        invalidate();
        event(evtChangedSize);
        recalcClipRegionsWhenVisible(); 
@@ -145,6 +148,13 @@ void eWidget::destruct()
        delete this;
 }
 
+void eWidget::setBackgroundColor(const gRGB &col)
+{
+       eDebug("set background color in ewidget!");
+       m_background_color = col;
+       m_have_background_color = 1;
+}
+
 eWidget::~eWidget()
 {
        hide();
@@ -217,9 +227,16 @@ int eWidget::event(int event, void *data, void *data2)
                
 //             eDebug("eWidget::evtPaint");
 //             dumpRegion(*(gRegion*)data);
-               ePtr<eWindowStyle> style;
-               if (!getStyle(style))
-                       style->paintBackground(painter, ePoint(0, 0), size());
+               if (!m_have_background_color)
+               {
+                       ePtr<eWindowStyle> style;
+                       if (!getStyle(style))
+                               style->paintBackground(painter, ePoint(0, 0), size());
+               } else
+               {
+                       painter.setBackgroundColor(m_background_color);
+                       painter.clear();
+               }
                break;
        }
        case evtKey:
index fbe5a92ae9c8683f1191b7170955bd14a5f9196b..cb39a000461cc355d7ee2c39934b20a6b82403a4 100644 (file)
@@ -33,6 +33,8 @@ public:
        int getStyle(ePtr<eWindowStyle> &style) { if (!m_style) return 1; style = m_style; return 0; }
        void setStyle(eWindowStyle *style) { m_style = style; }
        
+       void setBackgroundColor(const gRGB &col);
+       
                /* untested code */
        int isVisible() { return (m_vis & wVisShow) && ((!m_parent) || m_parent->isVisible()); }
                /* ... */
@@ -56,6 +58,9 @@ private:
        
        void doPaint(gPainter &painter, const gRegion &region);
        void recalcClipRegionsWhenVisible();
+       
+       gRGB m_background_color;
+       int m_have_background_color;
 protected:
        virtual ~eWidget();
 public:
index 96f7463662f0070126d1e835a87e6771e11624a4..8c489eb3afccc890cd8561c8cc454dcd8d4a74ab 100644 (file)
@@ -108,6 +108,21 @@ void eWidgetDesktop::setRedrawTask(eMainloop &ml)
                m_timer->start(0, 1);
 }
 
+void eWidgetDesktop::makeCompatiblePixmap(gPixmap &pm)
+{
+       eDebug("widgetDesktop: make compatible pixmap of %p\n", &pm);
+       if (!m_dc)
+       {
+               eWarning("eWidgetDesktop: no DC to make pixmap compatible with!");
+               return;
+       }
+       eDebug("painter..");
+       gPainter painter(m_dc);
+       eDebug("merge!");
+       painter.mergePalette(&pm);
+       eDebug("gone!");
+}
+
 eWidgetDesktop::eWidgetDesktop(eSize size): m_screen_size(size), m_mainloop(0), m_timer(0)
 {
 }
index f76baf60ac3178377c9aeddf7514d4aff181cc92..22914ec5cd7d1b32b24d2ec41f1eebeb8d11b1de 100644 (file)
@@ -30,6 +30,8 @@ public:
        void setBackgroundColor(gColor col);
        
        void setRedrawTask(eMainloop &ml);
+       
+       void makeCompatiblePixmap(gPixmap &pm);
 private:
        ePtrList<eWidget> m_root;
        void calcWidgetClipRegion(eWidget *widget, gRegion &parent_visible);
index 1114d2587fc85230976aae3cfd709ddfec17e9bd..01f889ffd20cb8cad11db728eb43243e829d033e 100644 (file)
@@ -2,10 +2,26 @@
 #include <lib/gui/ewidgetdesktop.h>
 
 #include <lib/gui/ewindowstyle.h>
+#include <lib/gui/ewindowstyleskinned.h>
+
+#include <lib/gdi/epng.h>
 
 eWindow::eWindow(eWidgetDesktop *desktop): eWidget(0)
 {
-       setStyle(new eWindowStyleSimple());
+       m_flags = 0;
+               /* ask style manager for current style */
+       ePtr<eWindowStyleManager> mgr;
+       eWindowStyleManager::getInstance(mgr);
+       
+       ePtr<eWindowStyle> style;
+       if (mgr)
+               mgr->getStyle(style);
+       
+               /* when there is either no style manager or no style, revert to simple style. */
+       if (!style)
+               style = new eWindowStyleSimple();
+       
+       setStyle(style);
 
                /* we are the parent for the child window. */
                /* as we are in the constructor, this is thread safe. */
@@ -27,30 +43,49 @@ void eWindow::setTitle(const std::string &string)
        event(evtTitleChanged);
 }
 
+void eWindow::setFlag(int flags)
+{
+       m_flags |= flags;
+}
+
+void eWindow::clearFlag(int flags)
+{
+       m_flags &= ~flags;
+}
+
 int eWindow::event(int event, void *data, void *data2)
 {
        switch (event)
        {
        case evtWillChangeSize:
        {
-               ePtr<eWindowStyle> style;
-               if (!getStyle(style))
+               eSize &new_size = *static_cast<eSize*>(data);
+               eSize &offset = *static_cast<eSize*>(data2);
+               if (!(m_flags & wfNoBorder))
                {
-                       const eSize &new_size = *static_cast<eSize*>(data);
+                       ePtr<eWindowStyle> style;
+                       if (!getStyle(style))
+                       {
 //                     eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
-                       style->handleNewSize(this, new_size);
+                               style->handleNewSize(this, new_size, offset);
+                       }
+               } else
+               {
+                       m_child->resize(new_size);
                }
                break;
        }
        case evtPaint:
        {
-               ePtr<eWindowStyle> style;
-               if (!getStyle(style))
+               if (!(m_flags & wfNoBorder))
                {
-                       gPainter &painter = *static_cast<gPainter*>(data2);
-                       style->paintWindowDecoration(this, painter, m_title);
-               } else
-                       eDebug("no style :(");
+                       ePtr<eWindowStyle> style;
+                       if (!getStyle(style))
+                       {
+                               gPainter &painter = *static_cast<gPainter*>(data2);
+                               style->paintWindowDecoration(this, painter, m_title);
+                       }
+               }
                return 0;
        }
        default:
index f5bcd51af72e3930bf394032b8890eafd4c4cdd2..33ad7a7262a1316a1b1fc86dc7f0fcb11651a77d 100644 (file)
@@ -14,6 +14,13 @@ public:
        ~eWindow();
        void setTitle(const std::string &string);
        eWidget *child() { return m_child; }
+       
+       enum {
+               wfNoBorder = 1
+       };
+       
+       void setFlag(int flags);
+       void clearFlag(int flags);
 protected:
        enum eWindowEvents
        {
@@ -23,6 +30,7 @@ protected:
 private:
        std::string m_title;
        eWidget *m_child;
+       int m_flags;
 };
 
 #endif
index a2e0efb2651b9d67a1b8369fcf3117004e183825..79024a35d1ee80d7d573baf5906ee26b86682fcb 100644 (file)
@@ -2,10 +2,35 @@
 #include <lib/gdi/esize.h>
 #include <lib/gui/ewindow.h>
 #include <lib/gui/ewindowstyle.h>
-
+#include <lib/base/init.h>
+#include <lib/base/init_num.h>
 
 eWindowStyle::~eWindowStyle() {}
 
+DEFINE_REF(eWindowStyleManager);
+
+eWindowStyleManager::eWindowStyleManager()
+{
+       m_instance = this;
+}
+
+eWindowStyleManager::~eWindowStyleManager()
+{
+       m_instance = 0;
+}
+
+void eWindowStyleManager::getStyle(ePtr<eWindowStyle> &style)
+{
+       style = m_current_style;
+}
+
+void eWindowStyleManager::setStyle(eWindowStyle *style)
+{
+       m_current_style = style;
+}
+
+eWindowStyleManager *eWindowStyleManager::m_instance;
+
 DEFINE_REF(eWindowStyleSimple);
 
 eWindowStyleSimple::eWindowStyleSimple()
@@ -22,7 +47,7 @@ eWindowStyleSimple::eWindowStyleSimple()
        m_background_color = gColor(0x19);
 }
 
-void eWindowStyleSimple::handleNewSize(eWindow *wnd, const eSize &size)
+void eWindowStyleSimple::handleNewSize(eWindow *wnd, eSize &size, eSize &offset)
 {
 //     eDebug("handle new size: %d x %d", size.width(), size.height());
        
@@ -130,35 +155,4 @@ RESULT eWindowStyleSimple::getFont(int what, ePtr<gFont> &fnt)
        return 0;
 }
 
-#if 0
-DEFINE_REF(eWindowStyleSkinned);
-
-eWindowStyleSkinned::eWindowStyleSkinned()
-{
-}
-
-void eWindowStyleSkinned::handleNewSize(eWindow *wnd, const eSize &size)
-{
-}
-
-void eWindowStyleSkinned::paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title)
-{
-}
-
-void eWindowStyleSkinned::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
-{
-}
-
-void eWindowStyleSkinned::setStyle(gPainter &painter, int what)
-{
-}
-
-void eWindowStyleSkinned::drawFrame(gPainter &painter, const eRect &frame, int what)
-{
-}
-
-void eWindowStyleSkinned::drawBorder(gPainter &painter, const eSize &size, const struct borderSet &border, int where)
-{
-}
-
-#endif
+eAutoInitPtr<eWindowStyleManager> init_eWindowStyleManager(eAutoInitNumbers::skin, "eWindowStyleManager");
index f11d99de8449b7649fefc69c2d8ebd453b5cf714..08ea0a4179105292471819c8a712a359268ffafe 100644 (file)
@@ -10,7 +10,7 @@ class gFont;
 class eWindowStyle: public iObject
 {
 public:
-       virtual void handleNewSize(eWindow *wnd, const eSize &size) = 0;
+       virtual void handleNewSize(eWindow *wnd, eSize &size, eSize &offset) = 0;
        virtual void paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title) = 0;
        virtual void paintBackground(gPainter &painter, const ePoint &offset, const eSize &size) = 0;
        virtual void setStyle(gPainter &painter, int what) = 0;
@@ -38,6 +38,22 @@ public:
        virtual ~eWindowStyle() = 0;
 };
 
+class eWindowStyleManager: public iObject
+{
+       DECLARE_REF(eWindowStyleManager);
+public:
+       eWindowStyleManager();
+       ~eWindowStyleManager();
+       void getStyle(ePtr<eWindowStyle> &style);
+       void setStyle(eWindowStyle *style);
+       static int getInstance(ePtr<eWindowStyleManager> &mgr) { mgr = m_instance; if (!mgr) return -1; return 0; }
+private:
+       static eWindowStyleManager *m_instance;
+       ePtr<eWindowStyle> m_current_style;
+};
+
+TEMPLATE_TYPEDEF(ePtr<eWindowStyleManager>, eWindowStyleManagerPtr);
+
 class eWindowStyleSimple: public eWindowStyle
 {
        DECLARE_REF(eWindowStyleSimple);
@@ -48,7 +64,7 @@ private:
        int m_border_top, m_border_left, m_border_right, m_border_bottom;
 public:
        eWindowStyleSimple();
-       void handleNewSize(eWindow *wnd, const eSize &size);
+       void handleNewSize(eWindow *wnd, eSize &size, eSize &offset);
        void paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title);
        void paintBackground(gPainter &painter, const ePoint &offset, const eSize &size);
        void setStyle(gPainter &painter, int what);
@@ -56,45 +72,4 @@ public:
        RESULT getFont(int what, ePtr<gFont> &font);
 };
 
-#if 0
-class eWindowStyleSkinned: public eWindowStyle
-{
-       DECLARE_REF(eWindowStyleSkinned);
-public:
-       eWindowStyleSkinned();
-       void handleNewSize(eWindow *wnd, const eSize &size);
-       void paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title);
-       void paintBackground(gPainter &painter, const ePoint &offset, const eSize &size);
-       void setStyle(gPainter &painter, int what);
-       void drawFrame(gPainter &painter, const eRect &frame, int what);
-       
-       enum {
-               bsWindow,
-               bsButton,
-#ifndef SWIG
-               bsMax
-#endif
-       };
-       
-       enum {
-               bpTopLeft     =     1,
-               bpTop         =     2,
-               bpTopRight    =     4,
-               bpLeft        =     8,
-               bpRight       =  0x10,
-               bpBottomLeft  =  0x20,
-               bpBottom      =  0x40,
-               bpBottomRight =  0x80,
-               bpBackground  = 0x100
-       };
-private:
-       struct borderSet
-       {
-               ePtr<gPixmap> m_pixmap[9];
-       };
-       
-       void drawBorder(gPainter &painter, const eSize &size, const struct borderSet &border, int where);
-};
-#endif
-
 #endif
diff --git a/lib/gui/ewindowstyleskinned.cpp b/lib/gui/ewindowstyleskinned.cpp
new file mode 100644 (file)
index 0000000..a3152e5
--- /dev/null
@@ -0,0 +1,248 @@
+#include <lib/base/eerror.h>
+#include <lib/gdi/esize.h>
+#include <lib/gui/ewindow.h>
+#include <lib/gui/ewindowstyle.h>
+#include <lib/gui/ewindowstyleskinned.h>
+
+DEFINE_REF(eWindowStyleSkinned);
+
+eWindowStyleSkinned::eWindowStyleSkinned()
+{
+       m_background_color = gRGB(0x808080);
+}
+
+void eWindowStyleSkinned::handleNewSize(eWindow *wnd, eSize &size, eSize &offset)
+{
+//     eDebug("handle new size: %d x %d", size.width(), size.height());
+       
+       size = eSize(
+                       size.width() + m_border[bsWindow].m_border_left + m_border[bsWindow].m_border_right,
+                       size.height() + m_border[bsWindow].m_border_top + m_border[bsWindow].m_border_bottom
+               );
+       
+       offset = eSize(-m_border[bsWindow].m_border_left, -m_border[bsWindow].m_border_top);
+       
+       eWidget *child = wnd->child();
+       
+       wnd->m_clip_region = eRect(ePoint(0, 0), size);
+       
+       child->move(ePoint(m_border[bsWindow].m_border_left, m_border[bsWindow].m_border_top));
+       child->resize(eSize(size.width() - m_border[bsWindow].m_border_left - m_border[bsWindow].m_border_right, size.height() - m_border[bsWindow].m_border_top - m_border[bsWindow].m_border_bottom));
+}
+
+void eWindowStyleSkinned::paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title)
+{
+       drawBorder(painter, eRect(ePoint(0, 0), wnd->size()), m_border[bsWindow], bpAll);
+}
+
+void eWindowStyleSkinned::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
+{
+       painter.setBackgroundColor(m_background_color);
+       painter.clear();
+}
+
+void eWindowStyleSkinned::setStyle(gPainter &painter, int what)
+{
+       switch (what)
+       {
+       case styleLabel:
+               painter.setForegroundColor(gColor(0x1F));
+               break;
+       case styleListboxSelected:
+               painter.setForegroundColor(gColor(0x1F));
+               painter.setBackgroundColor(gColor(0x1A));
+               break;
+       case styleListboxNormal:
+               painter.setForegroundColor(gColor(0x1C));
+               painter.setBackgroundColor(m_background_color);
+               break;
+       case styleListboxMarked:
+               painter.setForegroundColor(gColor(0x2F));
+               painter.setBackgroundColor(gColor(0x2A));
+               break;
+       }
+}
+
+void eWindowStyleSkinned::drawFrame(gPainter &painter, const eRect &frame, int what)
+{
+       int bs;
+       switch (what)
+       {
+       case frameButton:
+               bs = bsButton;
+               break;
+       case frameListboxEntry:
+               bs = bsListboxEntry;
+               break;
+       default:
+               eWarning("invalid frame style %d", what);
+               return;
+       }
+       drawBorder(painter, frame, m_border[bs], bpAll);
+}
+
+void eWindowStyleSkinned::drawBorder(gPainter &painter, const eRect &pos, struct borderSet &border, int what)
+{
+       int x = pos.left(), xm = pos.right();
+       
+       ePtr<gPixmap> 
+               &tl = border.m_pixmap[bpiTopLeft],
+               &t  = border.m_pixmap[bpiTop],
+               &tr = border.m_pixmap[bpiTopRight],
+               &l  = border.m_pixmap[bpiLeft],
+               &r  = border.m_pixmap[bpiRight],
+               &bl = border.m_pixmap[bpiBottomLeft],
+               &b  = border.m_pixmap[bpiBottom],
+               &br = border.m_pixmap[bpiBottomRight];
+       
+       if (tl)
+       {
+               painter.blit(tl, ePoint(x, pos.top()));
+               x += tl->size().width();
+       }
+       
+       if (tr)
+       {
+               xm -= tr->size().width();
+               painter.blit(tr, ePoint(xm, pos.top()), pos);
+       }
+
+       if (t)
+       {
+               while (x < xm)
+               {
+                       painter.blit(t, ePoint(x, pos.top()), eRect(x, pos.top(), xm - x, pos.height()));
+                       x += t->size().width();
+               }
+       }
+       
+       x = pos.left();
+       xm = pos.right();
+       
+       if (bl)
+       {
+               painter.blit(bl, ePoint(pos.left(), pos.bottom()-bl->size().height()));
+               x += bl->size().width();
+       }
+       
+       if (br)
+       {
+               xm -= br->size().width();
+               painter.blit(br, ePoint(xm, pos.bottom()-br->size().height()), eRect(x, pos.bottom()-br->size().height(), pos.width() - x, bl->size().height()));
+       }
+       
+       if (b)
+       {
+               while (x < xm)
+               {
+                       painter.blit(b, ePoint(x, pos.bottom()-b->size().height()), eRect(x, pos.bottom()-b->size().height(), xm - x, pos.height()));
+                       x += b->size().width();
+               }
+       }
+       
+       int y = 0;
+       if (tl)
+               y = tl->size().height();
+       
+       y += pos.top();
+       
+       int ym = pos.bottom();
+       if (bl)
+               ym -= bl->size().height();
+       
+       if (l)
+       {
+               while (y < ym)
+               {
+                       painter.blit(l, ePoint(pos.left(), y), eRect(pos.left(), y, pos.width(), ym - y));
+                       y += l->size().height();
+               }
+       }
+       
+       y = 0;
+       
+       if (tr)
+               y = tr->size().height();
+       
+       y += pos.top();
+       
+       ym = pos.bottom();
+       if (br)
+               ym -= br->size().height();
+       
+       if (r)
+       {
+               while (y < ym)
+               {
+                       painter.blit(r, ePoint(pos.right() - r->size().width(), y), eRect(pos.right()-r->size().width(), y, r->size().width(), ym - y));
+                       y += r->size().height();
+               }
+       }
+}
+
+RESULT eWindowStyleSkinned::getFont(int what, ePtr<gFont> &fnt)
+{
+       fnt = 0;
+       switch (what)
+       {
+       case fontStatic:
+               fnt = new gFont("Arial", 12);
+               break;
+       case fontButton:
+               fnt = new gFont("Arial", 20);
+               break;
+       case fontTitlebar:
+               fnt = new gFont("Arial", 25);
+               break;
+       default:
+               return -1;
+       }
+       return 0;
+}
+
+void eWindowStyleSkinned::setPixmap(int bs, int bp, gPixmap &pixmap)
+{
+       if ((bs >= bsMax) || (bs < 0))
+               return;
+       
+       int i = 0;
+       for (int b = 1; b < bpMax; b <<= 1, ++i)
+       {
+               if (bp & b)
+                       m_border[bs].m_pixmap[i] = &pixmap;
+       }
+       
+               /* recalc border sizes */
+       m_border[bs].m_border_top = 0;
+       m_border[bs].m_border_left = 0;
+       m_border[bs].m_border_bottom = 0;
+       m_border[bs].m_border_right = 0;
+       
+       for (int i = 0; i < 3; ++i)
+               if (m_border[bs].m_pixmap[i])
+                       if (m_border[bs].m_border_top < m_border[bs].m_pixmap[i]->size().height())
+                               m_border[bs].m_border_top = m_border[bs].m_pixmap[i]->size().height();
+       for (int i = 6; i < 9; ++i)
+               if (m_border[bs].m_pixmap[i])
+                       if (m_border[bs].m_border_bottom < m_border[bs].m_pixmap[i]->size().height())
+                               m_border[bs].m_border_bottom = m_border[bs].m_pixmap[i]->size().height();
+       for (int i = 0; i < 9; i += 3)
+               if (m_border[bs].m_pixmap[i])
+                       if (m_border[bs].m_border_left < m_border[bs].m_pixmap[i]->size().width())
+                               m_border[bs].m_border_left = m_border[bs].m_pixmap[i]->size().width();
+       for (int i = 2; i < 9; i += 3)
+               if (m_border[bs].m_pixmap[i])
+                       if (m_border[bs].m_border_right < m_border[bs].m_pixmap[i]->size().width())
+                               m_border[bs].m_border_right = m_border[bs].m_pixmap[i]->size().width();
+       eDebug("recalced border size for %d: %d:%d %d:%d",
+               bs, 
+               m_border[bs].m_border_left, m_border[bs].m_border_top, 
+               m_border[bs].m_border_right, m_border[bs].m_border_bottom); 
+}
+
+void eWindowStyleSkinned::setDefaultBackgroundColor(const gRGB &back)
+{
+       m_background_color = back;
+       eDebug("set default background color!");
+}
+
diff --git a/lib/gui/ewindowstyleskinned.h b/lib/gui/ewindowstyleskinned.h
new file mode 100644 (file)
index 0000000..7955738
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef __lib_gui_ewindowstyleskinned_h
+#define __lib_gui_ewindowstyleskinned_h
+
+#include <lib/gui/ewindowstyle.h>
+
+class eWindowStyleSkinned: public eWindowStyle
+{
+       DECLARE_REF(eWindowStyleSkinned);
+public:
+       eWindowStyleSkinned();
+       void handleNewSize(eWindow *wnd, eSize &size, eSize &offset);
+       void paintWindowDecoration(eWindow *wnd, gPainter &painter, const std::string &title);
+       void paintBackground(gPainter &painter, const ePoint &offset, const eSize &size);
+       void setStyle(gPainter &painter, int what);
+       void drawFrame(gPainter &painter, const eRect &frame, int what);
+       RESULT getFont(int what, ePtr<gFont> &font);
+       
+       enum {
+               bsWindow,
+               bsButton,
+               bsListboxEntry,
+#ifndef SWIG
+               bsMax
+#endif
+       };
+       
+       enum {
+               bpTopLeft     =     1,
+               bpTop         =     2,
+               bpTopRight    =     4,
+               bpLeft        =     8,
+               bpBackground  =  0x10,
+               bpRight       =  0x20,
+               bpBottomLeft  =  0x40,
+               bpBottom      =  0x80,
+               bpBottomRight = 0x100,
+               bpAll         = 0x1ff,
+               bpMax         = 0x200
+       };
+       
+       enum {
+               bpiTopLeft     =  0,
+               bpiTop         =  1,
+               bpiTopRight    =  2,
+               bpiLeft        =  3,
+               bpiBackground  =  4,
+               bpiRight       =  5,
+               bpiBottomLeft  =  6,
+               bpiBottom      =  7,
+               bpiBottomRight =  8,
+       };
+       
+       void setPixmap(int bs, int bp, gPixmap &pixmap);
+       
+       void setDefaultBackgroundColor(const gRGB &back);
+       
+private:
+       struct borderSet
+       {
+               ePtr<gPixmap> m_pixmap[9];
+               int m_border_top, m_border_left, m_border_right, m_border_bottom;
+       };
+       
+       borderSet m_border[bsMax];
+       
+       gRGB m_background_color;
+       
+       void drawBorder(gPainter &painter, const eRect &size, struct borderSet &border, int where);
+};
+
+#endif
index 7369b6465c953c7d62595aa2caca4a03b615e371..11faff1c4ecf5c68d86e1c066fef1ca483d212e1 100644 (file)
@@ -53,6 +53,7 @@ is usually caused by not marking PSignals as immutable.
 #include <lib/gui/ewindow.h>
 #include <lib/gui/ewidgetdesktop.h>
 #include <lib/gui/ewindowstyle.h>
+#include <lib/gui/ewindowstyleskinned.h>
 #include <lib/gui/eslider.h>
 #include <lib/python/connections.h>
 #include <lib/gui/elistbox.h>
@@ -94,9 +95,6 @@ extern PSignal1<void,int> &keyPressedSignal();
 %immutable eComponentScan::statusChanged;
 %immutable pNavigation::m_event;
 
-
-%include <lib/gdi/gpixmap.h>
-
 %include <lib/gdi/epoint.h>
 %include <lib/gdi/erect.h>
 %include <lib/gdi/esize.h>
@@ -111,6 +109,7 @@ extern PSignal1<void,int> &keyPressedSignal();
 %include <lib/gui/elistbox.h>
 %include <lib/gui/elistboxcontent.h>
 %include <lib/gui/ewindowstyle.h>
+%include <lib/gui/ewindowstyleskinned.h>
 %include <lib/service/listboxservice.h>
 %include <lib/components/scan.h>
 %include <lib/nav/pcore.h>
@@ -118,6 +117,7 @@ extern PSignal1<void,int> &keyPressedSignal();
 %include <lib/gdi/gfont.h>
 %include <lib/gdi/epng.h>
 
+%include <lib/gdi/gpixmap.h>
 /**************  eptr  **************/
 
 %template(eActionMapPtr) ePtr<eActionMap>;
@@ -156,7 +156,6 @@ public:
        $1 = $input->get();
 }
 
-
 /**************  base  **************/
 
 %immutable eTimer::timeout;
index 1fdf8c3251d86f291589904e96c751b81c36f5c0..ad838f5fd280d23d752fb69ef92bda8064f73bb3 100644 (file)
@@ -27,8 +27,10 @@ enigma2_LDADD = \
        @MAD_LIBS@ \
        @PNG_LIBS@ \
        @SIGC_LIBS@ \
+       @SDL_LIBS@ \
        -ldl -lpthread -lcrypt -lresolv -lpython2.3
 
 enigma2$(EXEEXT): $(enigma2_OBJECTS) $(enigma2_DEPENDENCIES) $(enigma2_LDADD_WHOLE)
        @rm -f enigma2$(EXEEXT)
-       $(CXXLINK) $(enigma2_LDFLAGS) $(enigma2_OBJECTS) -Wl,--export-dynamic -Wl,--whole-archive $(enigma2_LDADD_WHOLE) -Wl,--no-whole-archive $(enigma2_LDADD) $(LIBS)
+#      $(CXXLINK) $(enigma2_LDFLAGS) $(enigma2_OBJECTS) -Wl,--export-dynamic -Wl,--whole-archive $(enigma2_LDADD_WHOLE) -Wl,--no-whole-archive $(enigma2_LDADD) $(LIBS)
+       g++ -o enigma2$(EXEEXT) $(enigma2_LDFLAGS) $(enigma2_OBJECTS) -Wl,--export-dynamic -Wl,--whole-archive $(enigma2_LDADD_WHOLE) -Wl,--no-whole-archive $(enigma2_LDADD) $(LIBS)
index 6bf0bb9759e711a7a910859862de8f8542bcd308..222bdebc3526ad9e9c769057fc77e316dcd838df 100644 (file)
@@ -1,3 +1,4 @@
+#define SDLDC
 #include <stdio.h>
 #include <libsig_comp.h>
 #include <lib/base/ebase.h>
@@ -9,6 +10,7 @@
 
 #include <lib/gdi/grc.h>
 #include <lib/gdi/gfbdc.h>
+#include <lib/gdi/sdl.h>
 #include <lib/gdi/font.h> 
 
 #include <lib/gui/ewidget.h>
@@ -132,8 +134,13 @@ int main(int argc, char **argv)
        eMain main;
 
 #if 1
+#ifdef SDLDC
+       ePtr<gSDLDC> my_dc;
+       gSDLDC::getInstance(my_dc);
+#else
        ePtr<gFBDC> my_dc;
        gFBDC::getInstance(my_dc);
+#endif
 
        gPainter p(my_dc);
        
@@ -151,9 +158,13 @@ int main(int argc, char **argv)
                pal[a | 0x30] = (0x110011 * a) | 0xFF00;
        for (int a=0; a<0x10; ++a)
                pal[a | 0x40] = (0x001111 * a) | 0xFF0000;
+       
+       pal[0x50] = 0x586D88;
+       pal[0x51] = 0x4075a7;
+       
        p.setPalette(pal, 0, 256);
 
-       fontRenderClass::getInstance()->AddFont("/dbox2/cdkroot/share/fonts/arial.ttf", "Arial", 100);
+       fontRenderClass::getInstance()->AddFont("/home/tmbinc/enigma2/fonts/arial.ttf", "Arial", 100);
 
        eWidgetDesktop dsk(eSize(720, 576));
        
index 74ac27365e2428d60e591961157b88fd350eb20b..1a4b03630fed5769acd189c5599d31e8b397041e 100644 (file)
--- a/mytest.py
+++ b/mytest.py
@@ -103,7 +103,7 @@ class Session:
                gui.parent = dlg.instance
                gui.create(dlg)
 
-               applyGUIskin(dlg, None, dlg.skinName)
+               applyGUIskin(dlg, None, dlg.skinName, self.desktop)
                
                return dlg
         
@@ -162,6 +162,8 @@ def runScreenTest():
 
 import keymapparser
 keymapparser.readKeymap()
+import skin
+skin.loadSkin()
 
 # first, setup a screen
 runScreenTest()
index a0d0d7f6ee45d9c42c5e5a493c8652a37042595d..77d064f586b48292d76bb71275c5f77bdfef63c5 100644 (file)
@@ -83,14 +83,6 @@ class mainMenu(Screen):
                                ("wie spaet ists?!", self.goClock)
                        ])
 
-#class mainMenu(Screen):
-#      def __init__(self):
-#              GUISkin.__init__(self)
-#              
-#              self["title"] = Header("this is the\nMAIN MENU !!!");
-#              self["okbutton"] = Button("ok")
-#              self["okbutton"].onClick = [ self.close ]
-
 class channelSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
diff --git a/skin.py b/skin.py
index 51433bd7f4ca4b95666589aa1b6dcb6a0073a675..73d4b02de0a5e0251cdadab59ef4110601d5d06c 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -11,10 +11,22 @@ def dump(x, i=0):
                None
 
 dom = xml.dom.minidom.parseString(
-       """
-       <skin>
+       """<skin>
+               <windowstyle type="skinned">
+                       <color name="defaultBackground" color="#4075a7" />
+                       <borderset name="bsWindow">
+                               <pixmap pos="bpTopLeft"     filename="data/b_w_tl.png" />
+                               <pixmap pos="bpTop"         filename="data/b_w_t.png"  />
+                               <pixmap pos="bpTopRight"    filename="data/b_w_tr.png" />
+                               <pixmap pos="bpLeft"        filename="data/b_w_l.png"  />
+                               <pixmap pos="bpRight"       filename="data/b_w_r.png"  />
+                               <pixmap pos="bpBottomLeft"  filename="data/b_w_bl.png" />
+                               <pixmap pos="bpBottom"      filename="data/b_w_b.png"  />
+                               <pixmap pos="bpBottomRight" filename="data/b_w_br.png" />
+                       </borderset>
+               </windowstyle>
                <screen name="mainMenu" position="300,100" size="300,300" title="real main menu">
-                       <widget name="okbutton" position="10,190" size="280,50" font="Arial:20" valign="center" halign="center" />
+                       <widget name="okbutton" position="10,190" size="280,50" font="Arial;20" valign="center" halign="center" />
                        <widget name="title" position="10,10" size="280,20" />
                        <widget name="menu" position="10,30" size="280,140" />
                </screen>
@@ -23,15 +35,16 @@ dom = xml.dom.minidom.parseString(
                        <widget name="title" position="10,120" size="280,50" />
                        <widget name="theClock" position="10,60" size="280,50" />
                </screen>
-               <screen name="infoBar" position="80,350" size="540,150" title="InfoBar">
-                       <widget name="CurrentTime" position="10,10" size="40,30" />
-                       <widget name="ServiceName" position="50,20" size="200,30" />
-                       <widget name="Event_Now" position="100,40" size="300,30" valign="top" halign="left" />
-                       <widget name="Event_Next" position="100,90" size="300,30" valign="top" halign="left" />
-                       <widget name="Event_Now_Duration" position="440,40" size="80,30" valign="top" halign="left" />
-                       <widget name="Event_Next_Duration" position="440,90" size="80,30" valign="top" halign="left" />
-                       <eLabel position="70,0" size="300,30" text=".oO skin Oo." font="Arial:20" />
-<!--                   <ePixmap position="70,0" size="300,30" pixmap="info-bg.png" /> -->
+               <screen name="infoBar" position="0,380" size="720,151" title="InfoBar" flags="wfNoBorder">
+                       <ePixmap position="0,0" size="720,151" pixmap="info-bg.png" />
+                       
+                       <widget name="ServiceName" position="69,30" size="427,26" valign="center" font="Arial;32" />
+                       <widget name="CurrentTime" position="575,10" size="66,30" />
+                       <widget name="Event_Now" position="273,68" size="282,30" font="Arial;29" backgroundColor="#586D88" />
+                       <widget name="Event_Next" position="273,98" size="282,30" font="Arial;29" />
+                       <widget name="Event_Now_Duration" position="555,68" size="70,26" font="Arial;26" />
+                       <widget name="Event_Next_Duration" position="555,98" size="70,26" font="Arial;26" />
+<!--                   <eLabel position="70,0" size="300,30" text=".oO skin Oo." font="Arial;20" /> -->
                </screen>
                <screen name="channelSelection" position="100,80" size="500,240" title="Channel Selection">
                        <widget name="list" position="20,50" size="300,150" />
@@ -42,12 +55,17 @@ dom = xml.dom.minidom.parseString(
                        <widget name="scan_state" position="10,60" size="280,30" />
                        <widget name="okbutton" position="10,100" size="280,40" />
                </screen>
-       </skin>
-""")
+       </skin>""")
 
 # filters all elements of childNode with the specified function
 # example: nodes = elementsWithTag(childNodes, lambda x: x == "bla")
 def elementsWithTag(el, tag):
+
+       # fiiixme! (works but isn't nice)
+       if tag.__class__ == "".__class__:
+               str = tag
+               tag = lambda x: x == str
+               
        for x in el:
                if x.nodeType != xml.dom.minidom.Element.nodeType:
                        continue
@@ -63,10 +81,15 @@ def parseSize(str):
        return eSize(int(x), int(y))
 
 def parseFont(str):
-       name, size = str.split(':')
+       name, size = str.split(';')
        return gFont(name, int(size))
 
-def applyAttributes(guiObject, node):
+def parseColor(str):
+       if str[0] != '#':
+               raise "color must be #aarrggbb"
+       return gRGB(int(str[1:], 0x10))
+
+def applyAttributes(guiObject, node, desktop):
        # walk all attributes
        for p in range(node.attributes.length):
                a = node.attributes.item(p)
@@ -93,7 +116,12 @@ def applyAttributes(guiObject, node):
                                ptr = gPixmapPtr()
                                if loadPNG(ptr, value):
                                        raise "loading PNG failed!"
-                               guiObject.setPixmap(ptr.__deref__())
+                               x = ptr
+                               ptr = ptr.__deref__()
+                               print desktop
+                               desktop.makeCompatiblePixmap(ptr)
+                               guiObject.setPixmap(ptr)
+#                              guiObject.setPixmapFromFile(value)
                        elif attrib == "valign":
                                try:
                                        guiObject.setVAlign(
@@ -113,29 +141,74 @@ def applyAttributes(guiObject, node):
                                                }[value])
                                except KeyError:
                                        print "halign must be either left, center, right or block!"
+                       elif attrib == "flags":
+                               flags = value.split(',')
+                               for f in flags:
+                                       try:
+                                               fv = eWindow.__dict__[f]
+                                               guiObject.setFlag(fv)
+                                       except KeyError:
+                                               print "illegal flag %s!" % f
+                       elif attrib == "backgroundColor":
+                               guiObject.setBackgroundColor(parseColor(value))
                        elif attrib != 'name':
                                print "unsupported attribute " + attrib + "=" + value
                except AttributeError:
                        print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
 
-def applyGUIskin(screen, skin, name):
+def loadSkin():
+       print "loading skin..."
+       
+       def getPNG(x):
+               g = gPixmapPtr()
+               loadPNG(g, x)
+               g = g.grabRef()
+               return g
+       
+       skin = dom.childNodes[0]
+       assert skin.tagName == "skin", "root element in skin must be 'skin'!"
+       
+       for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"):
+               style = eWindowStyleSkinned()
+               
+               for borderset in elementsWithTag(windowstyle.childNodes, "borderset"):
+                       bsName = str(borderset.getAttribute("name"))
+                       for pixmap in elementsWithTag(borderset.childNodes, "pixmap"):
+                               bpName = str(pixmap.getAttribute("pos"))
+                               filename = str(pixmap.getAttribute("filename"))
+                               
+                               style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], getPNG(filename))
+
+               for color in elementsWithTag(windowstyle.childNodes, "color"):
+                       type = str(color.getAttribute("name"))
+                       color = parseColor(color.getAttribute("color"))
+                       
+                       if type == "defaultBackground":
+                               style.setDefaultBackgroundColor(color)
+                       else:
+                               raise "unknown color %s" % (type)
+                       
+               x = eWindowStyleManagerPtr()
+               eWindowStyleManager.getInstance(x)
+               x.setStyle(style)
+
+def applyGUIskin(screen, skin, name, desktop):
        myscreen = None
        
        # first, find the corresponding screen element
        skin = dom.childNodes[0]
-       assert skin.tagName == "skin", "root element in skin must be 'skin'!"
        
-       for x in elementsWithTag(skin.childNodes, lambda x: x == "screen"):
+       for x in elementsWithTag(skin.childNodes, "screen"):
                if x.getAttribute('name') == name:
                        myscreen = x
        del skin
        
        assert myscreen != None, "no skin for screen '" + name + "' found!"
        
-       applyAttributes(screen.instance, myscreen)
+       applyAttributes(screen.instance, myscreen, desktop)
        
        # now walk all widgets
-       for widget in elementsWithTag(myscreen.childNodes, lambda x: x == "widget"):
+       for widget in elementsWithTag(myscreen.childNodes, "widget"):
                wname = widget.getAttribute('name')
                if wname == None:
                        print "widget has no name!"
@@ -147,7 +220,7 @@ def applyGUIskin(screen, skin, name):
                except:
                        raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
                
-               applyAttributes(guiObject, widget)
+               applyAttributes(guiObject, widget, desktop)
 
        # now walk additional objects
        for widget in elementsWithTag(myscreen.childNodes, lambda x: x != "widget"):
@@ -158,5 +231,5 @@ def applyGUIskin(screen, skin, name):
                else:
                        raise str("unsupported stuff : %s" % widget.tagName)
                
-               applyAttributes(guiObject, widget)
+               applyAttributes(guiObject, widget, desktop      )
                guiObject.thisown = 0