- fixed blit in gRC
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 31 Mar 2005 19:55:46 +0000 (19:55 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 31 Mar 2005 19:55:46 +0000 (19:55 +0000)
 - enable use of loadPNG trough python (something is still broken, sorry)
 - add ePixmap
 - dummy widgets now possible as pixmaps

lib/gdi/epng.h
lib/gdi/gpixmap.cpp
lib/gdi/gpixmap.h
lib/gdi/grc.cpp
lib/gui/Makefile.am
lib/gui/epixmap.cpp [new file with mode: 0644]
lib/gui/epixmap.h [new file with mode: 0644]
lib/python/enigma_python.i
skin.py

index 244019f345ce02f5e2dd9b27714a53954298ac61..09f3023380e4b86863aabd05feea6f8c2bb2a366 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef __png_h
 #define __png_h
 
-#include "grc.h"
+#include <lib/gdi/gpixmap.h>
 
 int loadPNG(ePtr<gPixmap> &pixmap, const char *filename);
 int savePNG(const char *filename, gPixmap *pixmap);
index c2c75e7a21e74a5266b06c8004b9129209bb19e1..fe0c0a1f41c34ef9764667c941ba0861c761e3a0 100644 (file)
@@ -147,7 +147,7 @@ void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag
 
                eRect srcarea=area;
                srcarea.moveBy(-pos.x(), -pos.y());
-
+               
                if ((surface->bpp == 8) && (src.surface->bpp==8))
                {
                        __u8 *srcptr=(__u8*)src.surface->data;
index e549787cffc7ca253694733def027145a88d425c..f29a0fe747cbb805a7bf40fb8e5201623e7833c0 100644 (file)
@@ -128,4 +128,6 @@ public:
        virtual ~gPixmap();
 };
 
+TEMPLATE_TYPEDEF(ePtr<gPixmap>, gPixmapPtr);
+
 #endif
index e77489679f1ae25677875bb149bcdceb7f4f2f32..3b5476a2ba85df4b51e7621f2a70d2708fc4ce2c 100644 (file)
@@ -188,7 +188,7 @@ void gPainter::clear()
 void gPainter::blit(gPixmap *pixmap, ePoint pos, const eRect &clip, int flags)
 {
        gOpcode o;
-
+       
        o.opcode=gOpcode::blit;
        o.dc = m_dc.grabRef();
        pixmap->AddRef();
@@ -398,11 +398,16 @@ void gDC::exec(gOpcode *o)
        case gOpcode::blit:
        {
                gRegion clip;
-               if (!o->parm.blit->clip.valid())
+                               // this code should be checked again but i'm too tired now
+               
+               o->parm.blit->position += m_current_offset;
+               
+               if (o->parm.blit->clip.valid())
                {
                        clip.intersect(gRegion(o->parm.blit->clip), clip);
                } else
                        clip = m_current_clip;
+               
                m_pixmap->blit(*o->parm.blit->pixmap, o->parm.blit->position, clip, o->parm.blit->flags);
                o->parm.blit->pixmap->Release();
                delete o->parm.blit;
index 375a9469e67c22fd5f1bd7f4e66ba5545f06d943..076ee36a8cb08537f72da9ed22ca1e1ef3cebd63 100644 (file)
@@ -6,6 +6,7 @@ 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
+       ewindow.cpp ewindowstyle.cpp elistbox.cpp elistboxcontent.cpp \
+       epixmap.cpp
 
 
diff --git a/lib/gui/epixmap.cpp b/lib/gui/epixmap.cpp
new file mode 100644 (file)
index 0000000..a0655aa
--- /dev/null
@@ -0,0 +1,37 @@
+#include <lib/gui/epixmap.h>
+
+ePixmap::ePixmap(eWidget *parent): eWidget(parent)
+{
+}
+
+void ePixmap::setPixmap(gPixmap *pixmap)
+{
+       m_pixmap = pixmap;
+       event(evtChangedPixmap);
+}
+
+int ePixmap::event(int event, void *data, void *data2)
+{
+       switch (event)
+       {
+       case evtPaint:
+       {
+               ePtr<eWindowStyle> style;
+               
+               getStyle(style);
+               
+               eWidget::event(event, data, data2);
+               
+               gPainter &painter = *(gPainter*)data2;
+               if (m_pixmap)
+                       painter.blit(m_pixmap, ePoint(0, 0));
+               
+               return 0;
+       }
+       case evtChangedPixmap:
+               invalidate();
+               return 0;
+       default:
+               return eWidget::event(event, data, data2);
+       }
+}
diff --git a/lib/gui/epixmap.h b/lib/gui/epixmap.h
new file mode 100644 (file)
index 0000000..8a12e2e
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef __lib_gui_epximap_h
+#define __lib_gui_epixmap_h
+
+#include <lib/gui/ewidget.h>
+
+class ePixmap: public eWidget
+{
+public:
+       ePixmap(eWidget *parent);
+       
+       void setPixmap(gPixmap *pixmap);
+protected:
+       ePtr<gPixmap> m_pixmap;
+       int event(int event, void *data=0, void *data2=0);
+private:
+       enum eLabelEvent
+       {
+               evtChangedPixmap = evtUserWidget,
+       };
+};
+
+#endif
index 59133cc57ca84f90c28fdd842d05d6356fcb8d98..7369b6465c953c7d62595aa2caca4a03b615e371 100644 (file)
@@ -44,8 +44,11 @@ is usually caused by not marking PSignals as immutable.
 #include <lib/service/service.h>
 #include <lib/service/event.h>
 
+#include <lib/gdi/gpixmap.h>
+
 #include <lib/gui/ewidget.h>
 #include <lib/gui/elabel.h>
+#include <lib/gui/epixmap.h>
 #include <lib/gui/ebutton.h>
 #include <lib/gui/ewindow.h>
 #include <lib/gui/ewidgetdesktop.h>
@@ -59,6 +62,7 @@ is usually caused by not marking PSignals as immutable.
 #include <lib/nav/pcore.h>
 #include <lib/actions/action.h>
 #include <lib/gdi/gfont.h>
+#include <lib/gdi/epng.h>
 
 extern void runMainloop();
 extern void quitMainloop();
@@ -90,12 +94,16 @@ 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>
 %include <lib/gdi/region.h>
 %include <lib/gui/ewidget.h>
 %include <lib/gui/elabel.h>
+%include <lib/gui/epixmap.h>
 %include <lib/gui/ebutton.h>
 %include <lib/gui/ewindow.h>
 %include <lib/gui/eslider.h>
@@ -108,6 +116,7 @@ extern PSignal1<void,int> &keyPressedSignal();
 %include <lib/nav/pcore.h>
 %include <lib/actions/action.h>
 %include <lib/gdi/gfont.h>
+%include <lib/gdi/epng.h>
 
 /**************  eptr  **************/
 
diff --git a/skin.py b/skin.py
index 0367b60fd0a072b0d58838a4312e9c81d2b10e00..51433bd7f4ca4b95666589aa1b6dcb6a0073a675 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -31,6 +31,7 @@ dom = xml.dom.minidom.parseString(
                        <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>
                <screen name="channelSelection" position="100,80" size="500,240" title="Channel Selection">
                        <widget name="list" position="20,50" size="300,150" />
@@ -88,6 +89,11 @@ def applyAttributes(guiObject, node):
                                guiObject.setText(value)
                        elif attrib == 'font':
                                guiObject.setFont(parseFont(value))
+                       elif attrib == "pixmap":
+                               ptr = gPixmapPtr()
+                               if loadPNG(ptr, value):
+                                       raise "loading PNG failed!"
+                               guiObject.setPixmap(ptr.__deref__())
                        elif attrib == "valign":
                                try:
                                        guiObject.setVAlign(
@@ -147,8 +153,10 @@ def applyGUIskin(screen, skin, name):
        for widget in elementsWithTag(myscreen.childNodes, lambda x: x != "widget"):
                if widget.tagName == "eLabel":
                        guiObject = eLabel(screen.instance)
+               elif widget.tagName == "ePixmap":
+                       guiObject = ePixmap(screen.instance)
                else:
-                       raise "unsupported stuff : %s" % widget.tagName
+                       raise str("unsupported stuff : %s" % widget.tagName)
                
                applyAttributes(guiObject, widget)
                guiObject.thisown = 0