- disabled gui for a moment
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 2 Jun 2004 01:11:59 +0000 (01:11 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 2 Jun 2004 01:11:59 +0000 (01:11 +0000)
 - beginning of GDI2 work (region/fill/line works)
 - fixed smartptr self assignment
 - finally replaced "int ref" by something with a constructor

35 files changed:
include/connection.h
lib/Makefile.am
lib/base/eerror.cpp
lib/base/object.h
lib/base/smartptr.h
lib/dvb/db.cpp
lib/dvb/decoder.cpp
lib/dvb/demux.cpp
lib/dvb/dvb.cpp
lib/dvb/esection.cpp
lib/dvb/frontend.cpp
lib/dvb/sec.cpp
lib/gdi/Makefile.am
lib/gdi/erect.h
lib/gdi/fb.cpp
lib/gdi/font.cpp
lib/gdi/gfbdc.cpp
lib/gdi/gfbdc.h
lib/gdi/gpixmap.cpp
lib/gdi/gpixmap.h
lib/gdi/grc.cpp
lib/gdi/grc.h
lib/gdi/region.cpp
lib/gdi/region.h
lib/gui/elabel.cpp
lib/gui/emessage.cpp
lib/gui/enumber.cpp
lib/gui/eskin.cpp
lib/gui/eskin.h
lib/nav/core.cpp
lib/nav/playlist.cpp
lib/service/service.cpp
lib/service/servicedvb.cpp
lib/service/servicefs.cpp
lib/service/servicemp3.cpp

index 8ca75cb90b76ac4965d3442949f7d77699d676dc..a085650d723f1458c9b0017a9df9c69af03dc18f 100644 (file)
@@ -11,7 +11,7 @@ class eConnection: public virtual iObject, public Connection
 public:
 DEFINE_REF(eConnection);
 public:
 public:
 DEFINE_REF(eConnection);
 public:
-       eConnection(iObject *owner, const Connection &conn): Connection(conn), ref(0), m_owner(owner) { };
+       eConnection(iObject *owner, const Connection &conn): Connection(conn), m_owner(owner) { };
        virtual ~eConnection() { disconnect(); }
 };
 
        virtual ~eConnection() { disconnect(); }
 };
 
index c4197e31e3f6843c0f92c620f8e1adf58171d98b..4243911c922f5bf0e4b0245eab6da5e8a06e5b53 100644 (file)
@@ -1,4 +1,5 @@
-SUBDIRS = base  dvb dvb_si gdi  gui  network  service driver nav
+SUBDIRS = base  dvb dvb_si gdi network service driver nav
+#gui
 
 
 
 
 
 
index 0871bb715f78748cd4e823373d28cc1e0ac6c1cf..ac62f1e9ce2cf6c2d9d5d616b17a988ad238cb86 100644 (file)
@@ -20,6 +20,7 @@ void eFatal(const char* fmt, ...)
        va_end(ap);
        logOutput(lvlFatal, buf);
        fprintf(stderr, "%s\n",buf );
        va_end(ap);
        logOutput(lvlFatal, buf);
        fprintf(stderr, "%s\n",buf );
+#if 0
        if (!infatal)
        {
                infatal=1;
        if (!infatal)
        {
                infatal=1;
@@ -27,6 +28,8 @@ void eFatal(const char* fmt, ...)
                msg.show();
                msg.exec();
        }
                msg.show();
                msg.exec();
        }
+#endif
+
        _exit(0);
 }
 
        _exit(0);
 }
 
index 744bff19e02bcddd35f53dd1e8d058abf9627d85..ddb4512c2dea94c2b775c015768fbfc23ccccda5 100644 (file)
@@ -19,10 +19,18 @@ public:
        virtual void Release()=0;
 };
 
        virtual void Release()=0;
 };
 
-#define DECLARE_REF private: int ref; public: void AddRef(); void Release();
+class oRefCount
+{
+       int ref;
+public:
+       oRefCount(): ref(0) { }
+       operator int&() { return ref; }
+};
+
+#define DECLARE_REF private: oRefCount ref; public: void AddRef(); void Release();
 #ifdef OBJECT_DEBUG
 extern int object_total_remaining;
 #ifdef OBJECT_DEBUG
 extern int object_total_remaining;
-#define DEFINE_REF(c) void c::AddRef() { ++object_total_remaining; ++ref; eDebug("OBJECT_DEBUG " #c "+%p now %d", this, ref); } void c::Release() { --object_total_remaining; eDebug("OBJECT_DEBUG " #c "-%p now %d", this, ref-1); if (!--ref) delete this; }
+#define DEFINE_REF(c) void c::AddRef() { ++object_total_remaining; ++ref; eDebug("OBJECT_DEBUG " #c "+%p now %d", this, (int)ref); } void c::Release() { --object_total_remaining; eDebug("OBJECT_DEBUG " #c "-%p now %d", this, ref-1); if (!--ref) delete this; }
 #else
 #define DEFINE_REF(c) void c::AddRef() { ++ref; } void c::Release() { if (!--ref) delete this; }
 #endif
 #else
 #define DEFINE_REF(c) void c::AddRef() { ++ref; } void c::Release() { if (!--ref) delete this; }
 #endif
index 85ad5a90f23e5a31238e3dcb201234d3e27e4f1c..aafecf0eacfc169e8fe8c8872c9ea138023bcad5 100644 (file)
@@ -43,21 +43,21 @@ public:
        }
        ePtr &operator=(T *c)
        {
        }
        ePtr &operator=(T *c)
        {
+               if (c)
+                       c->AddRef();
                if (ptr)
                        ptr->Release();
                ptr=c;
                if (ptr)
                        ptr->Release();
                ptr=c;
-               if (ptr)
-                       ptr->AddRef();
                return *this;
        }
        
        ePtr &operator=(ePtr<T> &c)
        {
                return *this;
        }
        
        ePtr &operator=(ePtr<T> &c)
        {
+               if (c.ptr)
+                       c.ptr->AddRef();
                if (ptr)
                        ptr->Release();
                ptr=c.ptr;
                if (ptr)
                        ptr->Release();
                ptr=c.ptr;
-               if (ptr)
-                       ptr->AddRef();
                return *this;
        }
        
                return *this;
        }
        
index f8233a64bfe4b96604cdbd81ab3524ec4cbfeb7d..5426fa4bf5c106d2f0405592ce344bd2a34a7782 100644 (file)
@@ -9,7 +9,7 @@
 
 DEFINE_REF(eDVBService);
 
 
 DEFINE_REF(eDVBService);
 
-eDVBService::eDVBService(): ref(0)
+eDVBService::eDVBService()
 {
 }
 
 {
 }
 
index e21e4567251bd18780d541c0e10cc434faa516c0..0b3619adfd584bdf9b1652bf4ef27acaaeb3b41e 100644 (file)
@@ -10,7 +10,7 @@
 
 DEFINE_REF(eDVBAudio);
 
 
 DEFINE_REF(eDVBAudio);
 
-eDVBAudio::eDVBAudio(eDVBDemux *demux, int dev): ref(0), m_demux(demux)
+eDVBAudio::eDVBAudio(eDVBDemux *demux, int dev): m_demux(demux)
 {
        char filename[128];
        sprintf(filename, "/dev/dvb/adapter%d/audio%d", demux->adapter, dev);
 {
        char filename[128];
        sprintf(filename, "/dev/dvb/adapter%d/audio%d", demux->adapter, dev);
@@ -69,7 +69,7 @@ eDVBAudio::~eDVBAudio()
 
 DEFINE_REF(eDVBVideo);
 
 
 DEFINE_REF(eDVBVideo);
 
-eDVBVideo::eDVBVideo(eDVBDemux *demux, int dev): ref(0), m_demux(demux)
+eDVBVideo::eDVBVideo(eDVBDemux *demux, int dev): m_demux(demux)
 {
        char filename[128];
        sprintf(filename, "/dev/dvb/adapter%d/video%d", demux->adapter, dev);
 {
        char filename[128];
        sprintf(filename, "/dev/dvb/adapter%d/video%d", demux->adapter, dev);
index be9ac937b04905ffb7dfc037f1ef19e55a52d0a7..4522706d5a30f550ab868f26079ae721b2780dda 100644 (file)
@@ -13,7 +13,7 @@
 #include <lib/dvb/esection.h>
 #include <lib/dvb/decoder.h>
 
 #include <lib/dvb/esection.h>
 #include <lib/dvb/decoder.h>
 
-eDVBDemux::eDVBDemux(int adapter, int demux): adapter(adapter), demux(demux), ref(0)
+eDVBDemux::eDVBDemux(int adapter, int demux): adapter(adapter), demux(demux)
 {
 }
 
 {
 }
 
@@ -58,7 +58,7 @@ void eDVBSectionReader::data(int)
        read(data);
 }
 
        read(data);
 }
 
-eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res): ref(0), demux(demux)
+eDVBSectionReader::eDVBSectionReader(eDVBDemux *demux, eMainloop *context, RESULT &res): demux(demux)
 {
        char filename[128];
        sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
 {
        char filename[128];
        sprintf(filename, "/dev/dvb/adapter%d/demux%d", demux->adapter, demux->demux);
index cfdb05af7649ac55eeee48306033fe51bf5c263f..29ffa1515e4974ed69cf688b647d28918e2731f4 100644 (file)
@@ -8,7 +8,7 @@ DEFINE_REF(eDVBResourceManager);
 
 eDVBResourceManager *eDVBResourceManager::instance;
 
 
 eDVBResourceManager *eDVBResourceManager::instance;
 
-eDVBResourceManager::eDVBResourceManager(): ref(0)
+eDVBResourceManager::eDVBResourceManager()
 {
        avail = 1;
        busy = 0;
 {
        avail = 1;
        busy = 0;
index 08cb49bee96f3d84001d5b7323d2bec99b8933f7..42a056d285fd3a6ec8548d32bce3e99cd0ad65b0 100644 (file)
@@ -30,7 +30,7 @@ void eGTable::timeout()
 }
 
 eGTable::eGTable():
 }
 
 eGTable::eGTable():
-               ref(0), m_timeout(0), error(0)
+               m_timeout(0), error(0)
 {
 }
 
 {
 }
 
index 8948f194513f28dba9a26a50e9f10a451a07f00c..5b1aaa2a68618806420595acec096bb91f082a5a 100644 (file)
@@ -73,7 +73,7 @@ void eDVBFrontendParametersTerrestrial::set(const TerrestrialDeliverySystemDescr
        eFatal("nyi");
 }
 
        eFatal("nyi");
 }
 
-eDVBFrontendParameters::eDVBFrontendParameters(): ref(0), m_type(-1)
+eDVBFrontendParameters::eDVBFrontendParameters(): m_type(-1)
 {
 }
 
 {
 }
 
@@ -188,7 +188,7 @@ RESULT eDVBFrontendParameters::getHash(unsigned long &hash) const
 
 DEFINE_REF(eDVBFrontend);
 
 
 DEFINE_REF(eDVBFrontend);
 
-eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok): ref(0), m_type(-1)
+eDVBFrontend::eDVBFrontend(int adap, int fe, int &ok): m_type(-1)
 {
        char filename[128];
        int result;
 {
        char filename[128];
        int result;
index e8c6b479a0f7732eb8aa3b2e948ba4e48ce7433d..c033266a6d8b744b1dcafe42f7fda630d73d785f 100644 (file)
@@ -4,7 +4,7 @@
 
 DEFINE_REF(eDVBSatelliteEquipmentControl);
 
 
 DEFINE_REF(eDVBSatelliteEquipmentControl);
 
-eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(): ref(0)
+eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl()
 {
 }
 
 {
 }
 
index 49459b6101926010bb2e59e393f9f4358815359e..419163c7bcb5b820cfbf0d3cbf52150658a93a01 100644 (file)
@@ -5,4 +5,4 @@ noinst_LIBRARIES = libenigma_gdi.a
 
 libenigma_gdi_a_SOURCES = \
        region.cpp grc.cpp epng.cpp erect.cpp fb.cpp font.cpp font_arabic.cpp gfbdc.cpp  \
 
 libenigma_gdi_a_SOURCES = \
        region.cpp grc.cpp epng.cpp erect.cpp fb.cpp font.cpp font_arabic.cpp gfbdc.cpp  \
-       glcddc.cpp gpixmap.cpp grc.cpp lcd.cpp
+       glcddc.cpp gpixmap.cpp lcd.cpp
index 30db41f37061d76b9414521b7a73aac68b0f7e0e..9eaa7906786b87d2372e03e50db6290a5ec1a369 100644 (file)
@@ -71,6 +71,14 @@ public:
                y2 += dy;
        }
 
                y2 += dy;
        }
 
+       void moveBy(ePoint r)
+       {
+               x1 += r.x();
+               y1 += r.y();
+               x2 += r.x();
+               y2 += r.y();
+       }
+
        void setRect( int x, int y, int w, int h );
        void setCoords( int x1, int y1, int x2, int y2 );
 
        void setRect( int x, int y, int w, int h );
        void setCoords( int x1, int y1, int x2, int y2 );
 
@@ -224,7 +232,7 @@ inline eSize eRect::size() const
 
 inline bool eRect::contains( int x, int y) const
 {
 
 inline bool eRect::contains( int x, int y) const
 {
-       return x >= x1 && x < x2 && y >= y1 && y < y2;
+       return (x >= x1) && (x < x2) && (y >= y1) && (y < y2);
 }
 
 #endif // eRect_H
 }
 
 #endif // eRect_H
index 52d950a69a0d12b5d30da9b1d89239334ffe7939..4b8a56c9a429406d5ed3de8d9fbe5f15c7ece859 100644 (file)
@@ -29,9 +29,6 @@ fbClass::fbClass(const char *fb)
        cmap.blue=blue;
        cmap.transp=trans;
 
        cmap.blue=blue;
        cmap.transp=trans;
 
-       int state=0;
-       eConfig::getInstance()->getKey("/ezap/osd/showConsoleOnFB", state);
-
        fd=open(fb, O_RDWR);
        if (fd<0)
        {
        fd=open(fb, O_RDWR);
        if (fd<0)
        {
@@ -62,7 +59,7 @@ fbClass::fbClass(const char *fb)
                goto nolfb;
        }
 
                goto nolfb;
        }
 
-       showConsole(state);
+       showConsole(1);
        return;
 nolfb:
        lfb=0;
        return;
 nolfb:
        lfb=0;
@@ -86,8 +83,8 @@ int fbClass::showConsole(int state)
 
 int fbClass::SetMode(unsigned int nxRes, unsigned int nyRes, unsigned int nbpp)
 {
 
 int fbClass::SetMode(unsigned int nxRes, unsigned int nyRes, unsigned int nbpp)
 {
-       screeninfo.xres_virtual=screeninfo.xres=nxRes;
-       screeninfo.yres_virtual=screeninfo.yres=nyRes;
+/*     screeninfo.xres_virtual=screeninfo.xres=nxRes;
+       screeninfo.yres_virtual=screeninfo.yres=nyRes; */
        screeninfo.height=0;
        screeninfo.width=0;
        screeninfo.xoffset=screeninfo.yoffset=0;
        screeninfo.height=0;
        screeninfo.width=0;
        screeninfo.xoffset=screeninfo.yoffset=0;
index a0b6d2e76185e1c95d3b08341765e3e545a56d14..2f2823bb01476aefbb5d801927d0abc733ad3b0c 100644 (file)
@@ -239,7 +239,7 @@ int fontRenderClass::getFont(ePtr<Font> &font, const eString &face, int size, in
 
 DEFINE_REF(Font);
 
 
 DEFINE_REF(Font);
 
-Font::Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tw): ref(0), tabwidth(tw)
+Font::Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tw): tabwidth(tw)
 {
        renderer=render;
        font.font.face_id=faceid;
 {
        renderer=render;
        font.font.face_id=faceid;
@@ -249,7 +249,6 @@ Font::Font(fontRenderClass *render, FTC_FaceID faceid, int isize, int tw): ref(0
        height=isize;
        if (tabwidth==-1)
                tabwidth=8*isize;
        height=isize;
        if (tabwidth==-1)
                tabwidth=8*isize;
-       ref=0;
 //     font.image_type |= ftc_image_flag_autohinted;
 }
 
 //     font.image_type |= ftc_image_flag_autohinted;
 }
 
@@ -262,6 +261,8 @@ Font::~Font()
 {
 }
 
 {
 }
 
+DEFINE_REF(eTextPara);
+
 int eTextPara::appendGlyph(Font *current_font, FT_Face current_face, FT_UInt glyphIndex, int flags, int rflags)
 {
        FTC_SBit glyph;
 int eTextPara::appendGlyph(Font *current_font, FT_Face current_face, FT_UInt glyphIndex, int flags, int rflags)
 {
        FTC_SBit glyph;
index 3247aa6a13bc9bcfd943e85b3667085036ad68fb..d5ce9f3cbced31dc39c1b0fd56c3ea57329d4e79 100644 (file)
@@ -113,11 +113,6 @@ void gFBDC::exec(gOpcode *o)
        }
 }
 
        }
 }
 
-gFBDC *gFBDC::getInstance()
-{
-       return instance;
-}
-
 void gFBDC::setAlpha(int a)
 {
        alpha=a;
 void gFBDC::setAlpha(int a)
 {
        alpha=a;
@@ -162,4 +157,4 @@ void gFBDC::reloadSettings()
        setPalette();
 }
 
        setPalette();
 }
 
-eAutoInitP0<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");
+eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");
index 0b0372d3222a0be697efeac068079ebe9a6880fa..dd03032ef78d9f5be0cc568654f3298a2bbcb043 100644 (file)
@@ -28,8 +28,8 @@ public:
        void saveSettings();
        
        gFBDC();
        void saveSettings();
        
        gFBDC();
-       ~gFBDC();
-       static gFBDC *getInstance();
+       virtual ~gFBDC();
+       static int getInstance(ePtr<gFBDC> &ptr) { if (!instance) return -1; ptr = instance; return 0; }
        int islocked() { return fb->islocked(); }
 };
 
        int islocked() { return fb->islocked(); }
 };
 
index b6711fcb6bc3799c37ffd5e11f00d89d3093be48..1d2a4e395e92f69ec6f158000f908c6be7c4fb80 100644 (file)
@@ -1,4 +1,5 @@
 #include <lib/gdi/gpixmap.h>
 #include <lib/gdi/gpixmap.h>
+#include <lib/gdi/region.h>
 
 gLookup::gLookup()
        :size(0), lookup(0)
 
 gLookup::gLookup()
        :size(0), lookup(0)
@@ -102,121 +103,130 @@ void gPixmap::unlock()
        contentlock.unlock(1);
 }
 
        contentlock.unlock(1);
 }
 
-void gPixmap::fill(const eRect &area, const gColor &color)
+void gPixmap::fill(const gRegion &region, const gColor &color)
 {
 {
-       if ((area.height()<=0) || (area.width()<=0))
-               return;
-       if (surface->bpp == 8)
-               for (int y=area.top(); y<area.bottom(); y++)
-                       memset(((__u8*)surface->data)+y*surface->stride+area.left(), color.color, area.width());
-       else if (surface->bpp == 32)
-               for (int y=area.top(); y<area.bottom(); y++)
+       int i;
+       for (i=0; i<region.rects.size(); ++i)
+       {
+               const eRect &area = region.rects[i];
+               if ((area.height()<=0) || (area.width()<=0))
+                       continue;
+               if (surface->bpp == 8)
                {
                {
-                       __u32 *dst=(__u32*)(((__u8*)surface->data)+y*surface->stride+area.left()*surface->bypp);
-                       int x=area.width();
-                       __u32 col;
+                       for (int y=area.top(); y<area.bottom(); y++)
+                               memset(((__u8*)surface->data)+y*surface->stride+area.left(), color.color, area.width());
+               } else if (surface->bpp == 32)
+                       for (int y=area.top(); y<area.bottom(); y++)
+                       {
+                               __u32 *dst=(__u32*)(((__u8*)surface->data)+y*surface->stride+area.left()*surface->bypp);
+                               int x=area.width();
+                               __u32 col;
 
 
-                       if (surface->clut.data && color < surface->clut.colors)
-                               col=(surface->clut.data[color].a<<24)|(surface->clut.data[color].r<<16)|(surface->clut.data[color].g<<8)|(surface->clut.data[color].b);
-                       else
-                               col=0x10101*color;
-                       col^=0xFF000000;                        
-                       while (x--)
-                               *dst++=col;
-               }
-       else
-               eWarning("couldn't fill %d bpp", surface->bpp);
+                               if (surface->clut.data && color < surface->clut.colors)
+                                       col=(surface->clut.data[color].a<<24)|(surface->clut.data[color].r<<16)|(surface->clut.data[color].g<<8)|(surface->clut.data[color].b);
+                               else
+                                       col=0x10101*color;
+                               col^=0xFF000000;                        
+                               while (x--)
+                                       *dst++=col;
+                       }
+               else
+                       eWarning("couldn't fill %d bpp", surface->bpp);
+       }
 }
 
 }
 
-void gPixmap::blit(const gPixmap &src, ePoint pos, const eRect &clip, int flag)
+void gPixmap::blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flag)
 {
 {
-       eRect area=eRect(pos, src.getSize());
-       area&=clip;
-       area&=eRect(ePoint(0, 0), getSize());
-       if ((area.width()<0) || (area.height()<0))
-               return;
+       for (int i=0; i<clip.rects.size(); ++i)
+       {
+               eRect area=eRect(pos, src.getSize());
+               area&=clip.rects[i];
+               area&=eRect(ePoint(0, 0), getSize());
+               if ((area.width()<0) || (area.height()<0))
+                       continue;
 
 
-       eRect srcarea=area;
-       srcarea.moveBy(-pos.x(), -pos.y());
+               eRect srcarea=area;
+               srcarea.moveBy(-pos.x(), -pos.y());
 
 
-       if ((surface->bpp == 8) && (src.surface->bpp==8))
-       {
-               __u8 *srcptr=(__u8*)src.surface->data;
-               __u8 *dstptr=(__u8*)surface->data;
-       
-               srcptr+=srcarea.left()*surface->bypp+srcarea.top()*src.surface->stride;
-               dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
-               for (int y=0; y<area.height(); y++)
+               if ((surface->bpp == 8) && (src.surface->bpp==8))
                {
                {
-                       if (flag & blitAlphaTest)
+                       __u8 *srcptr=(__u8*)src.surface->data;
+                       __u8 *dstptr=(__u8*)surface->data;
+       
+                       srcptr+=srcarea.left()*surface->bypp+srcarea.top()*src.surface->stride;
+                       dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
+                       for (int y=0; y<area.height(); y++)
                        {
                        {
-             // no real alphatest yet
-                               int width=area.width();
-                               unsigned char *src=(unsigned char*)srcptr;
-                               unsigned char *dst=(unsigned char*)dstptr;
-                                       // use duff's device here!
-                               while (width--)
+                               if (flag & blitAlphaTest)
                                {
                                {
-                                       if (!*src)
+                     // no real alphatest yet
+                                       int width=area.width();
+                                       unsigned char *src=(unsigned char*)srcptr;
+                                       unsigned char *dst=(unsigned char*)dstptr;
+                                               // use duff's device here!
+                                       while (width--)
                                        {
                                        {
-                                               src++;
-                                               dst++;
-                                       } else
-                                               *dst++=*src++;
-                               }
-                       } else
-                               memcpy(dstptr, srcptr, area.width()*surface->bypp);
-                       srcptr+=src.surface->stride;
-                       dstptr+=surface->stride;
-               }
-       } else if ((surface->bpp == 32) && (src.surface->bpp==8))
-       {
-               __u8 *srcptr=(__u8*)src.surface->data;
-               __u8 *dstptr=(__u8*)surface->data; // !!
-               __u32 pal[256];
-               
-               for (int i=0; i<256; ++i)
-               {
-                       if (src.surface->clut.data && (i<src.surface->clut.colors))
-                               pal[i]=(src.surface->clut.data[i].a<<24)|(src.surface->clut.data[i].r<<16)|(src.surface->clut.data[i].g<<8)|(src.surface->clut.data[i].b);
-                       else
-                               pal[i]=0x010101*i;
-                       pal[i]^=0xFF000000;
-               }
+                                               if (!*src)
+                                               {
+                                                       src++;
+                                                       dst++;
+                                               } else
+                                                       *dst++=*src++;
+                                       }
+                               } else
+                                       memcpy(dstptr, srcptr, area.width()*surface->bypp);
+                               srcptr+=src.surface->stride;
+                               dstptr+=surface->stride;
+                       }
+               } else if ((surface->bpp == 32) && (src.surface->bpp==8))
+               {       
+                       __u8 *srcptr=(__u8*)src.surface->data;
+                       __u8 *dstptr=(__u8*)surface->data; // !!
+                       __u32 pal[256];
+
+                       for (int i=0; i<256; ++i)
+                       {
+                               if (src.surface->clut.data && (i<src.surface->clut.colors))
+                                       pal[i]=(src.surface->clut.data[i].a<<24)|(src.surface->clut.data[i].r<<16)|(src.surface->clut.data[i].g<<8)|(src.surface->clut.data[i].b);
+                               else
+                                       pal[i]=0x010101*i;
+                               pal[i]^=0xFF000000;
+                       }
        
        
-               srcptr+=srcarea.left()*surface->bypp+srcarea.top()*src.surface->stride;
-               dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
-               for (int y=0; y<area.height(); y++)
-               {
-                       if (flag & blitAlphaTest)
+                       srcptr+=srcarea.left()*surface->bypp+srcarea.top()*src.surface->stride;
+                       dstptr+=area.left()*surface->bypp+area.top()*surface->stride;
+                       for (int y=0; y<area.height(); y++)
                        {
                        {
-             // no real alphatest yet
-                               int width=area.width();
-                               unsigned char *src=(unsigned char*)srcptr;
-                               __u32 *dst=(__u32*)dstptr;
-                                       // use duff's device here!
-                               while (width--)
+                               if (flag & blitAlphaTest)
                                {
                                {
-                                       if (!*src)
+                     // no real alphatest yet
+                                       int width=area.width();
+                                       unsigned char *src=(unsigned char*)srcptr;
+                                       __u32 *dst=(__u32*)dstptr;
+                                               // use duff's device here!
+                                       while (width--)
                                        {
                                        {
-                                               src++;
-                                               dst++;
-                                       } else
+                                               if (!*src)
+                                               {
+                                                       src++;
+                                                       dst++;
+                                               } else
+                                                       *dst++=pal[*src++];
+                                       }
+                               } else
+                               {
+                                       int width=area.width();
+                                       unsigned char *src=(unsigned char*)srcptr;
+                                       __u32 *dst=(__u32*)dstptr;
+                                       while (width--)
                                                *dst++=pal[*src++];
                                }
                                                *dst++=pal[*src++];
                                }
-                       } else
-                       {
-                               int width=area.width();
-                               unsigned char *src=(unsigned char*)srcptr;
-                               __u32 *dst=(__u32*)dstptr;
-                               while (width--)
-                                       *dst++=pal[*src++];
+                               srcptr+=src.surface->stride;
+                               dstptr+=surface->stride;
                        }
                        }
-                       srcptr+=src.surface->stride;
-                       dstptr+=surface->stride;
-               }
-       } else
-               eFatal("cannot blit %dbpp from %dbpp", surface->bpp, src.surface->bpp);
+               } else
+                       eFatal("cannot blit %dbpp from %dbpp", surface->bpp, src.surface->bpp);
+       }
 }
 
 void gPixmap::mergePalette(const gPixmap &target)
 }
 
 void gPixmap::mergePalette(const gPixmap &target)
@@ -245,26 +255,91 @@ void gPixmap::mergePalette(const gPixmap &target)
        delete [] lookup;
 }
 
        delete [] lookup;
 }
 
-void gPixmap::line(ePoint start, ePoint dst, gColor color)
+static inline int sgn(int a)
+{
+       if (a < 0)
+               return -1;
+       else if (!a)
+               return 0;
+       else
+               return 1;
+}
+
+void gPixmap::line(const gRegion &clip, ePoint start, ePoint dst, gColor color)
 {
 {
-int Ax=start.x(),
-Ay=start.y(), Bx=dst.x(),
-By=dst.y(); int dX, dY, fbXincr,
-fbYincr, fbXYincr, dPr, dPru, P; __u8
-*AfbAddr = &((__u8*)surface->data)[Ay*surface->stride+Ax*surface->bypp]; __u8
-*BfbAddr = &((__u8*)surface->data)[By*surface->stride+Bx*surface->bypp]; fbXincr=
-surface->bypp; if ( (dX=Bx-Ax) >= 0) goto AFTERNEGX; dX=-dX;
-fbXincr=-1; AFTERNEGX: fbYincr=surface->stride; if ( (dY=By 
--Ay) >= 0) goto AFTERNEGY; fbYincr=-surface->stride; dY=-dY;AFTERNEGY: 
-fbXYincr = fbXincr+fbYincr; if (dY > dX) goto YisIndependent; dPr = dY+ 
-dY; P = -dX; dPru = P+P; dY = dX>>1; XLOOP: *AfbAddr=color; *BfbAddr=color; if ((P+=dPr) > 0)
-goto RightAndUp;  AfbAddr+=fbXincr; BfbAddr-=fbXincr; if ((dY=dY-1) > 0) goto XLOOP; *AfbAddr=color; if ((dX & 1)
-== 0) return;  *BfbAddr=color; return; RightAndUp: AfbAddr+=fbXYincr; BfbAddr-=fbXYincr; P+=dPru; if ((dY=dY-1) >
-0) goto XLOOP;  *AfbAddr=color; if ((dX & 1) == 0) return; *BfbAddr=color; return; YisIndependent: dPr = dX+dX; P
-= -dY; dPru = P+P; dX = dY>>1; YLOOP: *AfbAddr=color; *BfbAddr=color; if ((P+=dPr) > 0) goto RightAndUp2; AfbAddr
-+=fbYincr;  BfbAddr-=fbYincr; if ((dX=dX-1) > 0) goto YLOOP; *AfbAddr=color; if ((dY & 1) == 0) return; *BfbAddr=
-color;return; RightAndUp2: AfbAddr+=fbXYincr; BfbAddr-=fbXYincr; P+=dPru; if ((dX=dX-1) > 0) goto YLOOP; *AfbAddr
-=color; if((dY & 1) == 0) return; *BfbAddr=color; return;
+       __u8 *srf = (__u8*)surface->data;
+       int stride = surface->stride;
+       
+       if (clip.rects.empty())
+               return;
+       
+       int xa = start.x(), ya = start.y(), xb = dst.x(), yb = dst.y();
+       int dx, dy, x, y, s1, s2, e, temp, swap, i;
+       dy=abs(yb-ya);
+       dx=abs(xb-xa);
+       s1=sgn(xb-xa);
+       s2=sgn(yb-ya);
+       x=xa;
+       y=ya;
+       if (dy>dx)
+       {
+               temp=dx;
+               dx=dy;
+               dy=temp;
+               swap=1;
+       } else
+               swap=0;
+       e = 2*dy-dx;
+       int lasthit = 0;
+       for(i=1; i<=dx; i++)
+       {
+                               /* i don't like this clipping loop, but the only */
+                               /* other choice i see is to calculate the intersections */
+                               /* before iterating through the pixels. */
+                               
+                               /* one could optimize this because of the ordering */
+                               /* of the bands. */
+                               
+               lasthit = 0;
+               int a = lasthit;
+               
+                       /* if last pixel was invisble, first check bounding box */
+               if (a == -1)
+               {
+                               /* check if we just got into the bbox again */
+                       if (clip.extends.contains(x, y))
+                               lasthit = a = 0;
+                       else
+                               goto fail;
+               } else if (!clip.rects[a].contains(x, y))
+               {
+                       do
+                       {
+                               ++a;
+                               if (a == clip.rects.size())
+                                       a = 0;
+                               if (a == lasthit)
+                               {
+                                       goto fail;
+                                       lasthit = -1;
+                               }
+                       } while (!clip.rects[a].contains(x, y));
+                       lasthit = a;
+               }
+               srf[y * stride + x] = color;
+fail:
+               while (e>=0)
+               {
+                       if (swap==1) x+=s1;
+                       else y+=s2;
+                       e-=2*dx;
+               }
+    if (swap==1)
+       y+=s2;
+               else
+                       x+=s1;
+               e+=2*dy;
+       }
 }
 
 gColor gPalette::findColor(const gRGB &rgb) const
 }
 
 gColor gPalette::findColor(const gRGB &rgb) const
index 048b73a55ef1682e6affd249b61c57aff3d62e0d..0d123b3fe526823753ef13e8bf0210e00409046c 100644 (file)
@@ -23,16 +23,23 @@ struct gColor
 
 struct gRGB
 {
 
 struct gRGB
 {
-       int b, g, r, a;
+       unsigned char b, g, r, a;
        gRGB(int r, int g, int b, int a=0): b(b), g(g), r(r), a(a)
        {
        }
        gRGB(unsigned long val): b(val&0xFF), g((val>>8)&0xFF), r((val>>16)&0xFF), a((val>>24)&0xFF)            // ARGB
        {
        }
        gRGB(int r, int g, int b, int a=0): b(b), g(g), r(r), a(a)
        {
        }
        gRGB(unsigned long val): b(val&0xFF), g((val>>8)&0xFF), r((val>>16)&0xFF), a((val>>24)&0xFF)            // ARGB
        {
        }
-       gRGB()
+       gRGB(): b(0), g(0), r(0), a(0)
        {
        }
        {
        }
+       void operator=(unsigned long val)
+       {
+               b = val&0xFF;
+               g = (val>>8)&0xFF;
+               r = (val>>16)&0xFF;
+               a = (val>>24)&0xFF;
+       }
        bool operator < (const gRGB &c) const
        {
                if (b < c.b)
        bool operator < (const gRGB &c) const
        {
                if (b < c.b)
@@ -127,6 +134,18 @@ struct gSurfaceSystem: gSurface
 struct gPixmap: public iObject
 {
 DECLARE_REF;
 struct gPixmap: public iObject
 {
 DECLARE_REF;
+private:
+       friend class gDC;
+       void fill(const gRegion &clip, const gColor &color);
+       
+       enum
+       {
+               blitAlphaTest=1
+       };
+       void blit(const gPixmap &src, ePoint pos, const gRegion &clip, int flags=0);
+       
+       void mergePalette(const gPixmap &target);
+       void line(const gRegion &clip, ePoint start, ePoint end, gColor color);
 public:
        gSurface *surface;
        
 public:
        gSurface *surface;
        
@@ -138,17 +157,6 @@ public:
        
        eSize getSize() const { return eSize(surface->x, surface->y); }
        
        
        eSize getSize() const { return eSize(surface->x, surface->y); }
        
-       void fill(const eRect &area, const gColor &color);
-       
-       enum
-       {
-               blitAlphaTest=1
-       };
-       void blit(const gPixmap &src, ePoint pos, const eRect &clip=eRect(), int flags=0);
-       
-       void mergePalette(const gPixmap &target);
-       void line(ePoint start, ePoint end, gColor color);
-       void finalLock();
        gPixmap(gSurface *surface);
        gPixmap(eSize, int bpp);
        virtual ~gPixmap();
        gPixmap(gSurface *surface);
        gPixmap(eSize, int bpp);
        virtual ~gPixmap();
index 55c86a0b346b933d245ab1f2ee8484828d5992bc..46181d3256daf9a393072ff6a2151ff75151dbb5 100644 (file)
@@ -1,5 +1,5 @@
 // for debugging use:
 // for debugging use:
-// #define SYNC_PAINT
+ #define SYNC_PAINT
 #include <unistd.h>
 #ifndef SYNC_PAINT
 #include <pthread.h>
 #include <unistd.h>
 #ifndef SYNC_PAINT
 #include <pthread.h>
@@ -7,7 +7,6 @@
 
 #include <lib/gdi/grc.h>
 #include <lib/gdi/font.h>
 
 #include <lib/gdi/grc.h>
 #include <lib/gdi/font.h>
-#include <lib/gdi/lcd.h>
 #include <lib/base/init.h>
 #include <lib/base/init_num.h>
 
 #include <lib/base/init.h>
 #include <lib/base/init_num.h>
 
@@ -29,16 +28,18 @@ gRC::gRC(): queue(2048), queuelock(MAXSIZE)
        instance=this;
        queuelock.lock(MAXSIZE);
 #ifndef SYNC_PAINT
        instance=this;
        queuelock.lock(MAXSIZE);
 #ifndef SYNC_PAINT
-       eDebug(pthread_create(&the_thread, 0, thread_wrapper, this)?"RC thread couldn't be created":"RC thread createted successfully");
+       int res = pthread_create(&the_thread, 0, thread_wrapper, this);
+       if (res)
+               eFatal("RC thread couldn't be created");
+       else
+               eDebug("RC thread createted successfully");
 #endif
 }
 
 #endif
 }
 
+DEFINE_REF(gRC);
+
 gRC::~gRC()
 {
 gRC::~gRC()
 {
-       fbClass::getInstance()->lock();
-#ifndef DISABLE_LCD
-       eDBoxLCD::getInstance()->lock();
-#endif
        instance=0;
 
        gOpcode o;
        instance=0;
 
        gOpcode o;
@@ -82,7 +83,7 @@ gPainter::gPainter(gDC *dc, eRect rect): m_dc(dc), m_rc(gRC::getInstance())
 {
 //     ASSERT(!gPainter_instances);
        gPainter_instances++;
 {
 //     ASSERT(!gPainter_instances);
        gPainter_instances++;
-       begin(rect);
+//     begin(rect);
 }
 
 gPainter::~gPainter()
 }
 
 gPainter::~gPainter()
@@ -171,7 +172,7 @@ void gPainter::clear()
        m_rc->submit(o);
 }
 
        m_rc->submit(o);
 }
 
-void gPainter::blit(gPixmap *pixmap, ePoint pos, gRegion *clip, int flags)
+void gPainter::blit(gPixmap *pixmap, ePoint pos, const eRect &clip, int flags)
 {
        gOpcode o;
 
 {
        gOpcode o;
 
@@ -181,7 +182,6 @@ void gPainter::blit(gPixmap *pixmap, ePoint pos, gRegion *clip, int flags)
        o.parm.blit  = new gOpcode::para::pblit;
        o.parm.blit->pixmap = pixmap;
        o.parm.blit->position = pos;
        o.parm.blit  = new gOpcode::para::pblit;
        o.parm.blit->pixmap = pixmap;
        o.parm.blit->position = pos;
-       clip->AddRef();
        o.parm.blit->clip = clip;
        o.flags=flags;
        m_rc->submit(o);
        o.parm.blit->clip = clip;
        o.flags=flags;
        m_rc->submit(o);
@@ -195,7 +195,9 @@ void gPainter::setPalette(gRGB *colors, int start, int len)
        o.dc = m_dc.grabRef();
        gPalette *p=new gPalette;
        
        o.dc = m_dc.grabRef();
        gPalette *p=new gPalette;
        
+       o.parm.setPalette = new gOpcode::para::psetPalette;
        p->data=new gRGB[len];
        p->data=new gRGB[len];
+       
        memcpy(p->data, colors, len*sizeof(gRGB));
        p->start=start;
        p->colors=len;
        memcpy(p->data, colors, len*sizeof(gRGB));
        p->start=start;
        p->colors=len;
@@ -224,7 +226,7 @@ void gPainter::line(ePoint start, ePoint end)
        m_rc->submit(o);
 }
 
        m_rc->submit(o);
 }
 
-void gPainter::setLogicalZero(ePoint val)
+void gPainter::setOffset(ePoint val)
 {
        gOpcode o;
        o.opcode=gOpcode::setOffset;
 {
        gOpcode o;
        o.opcode=gOpcode::setOffset;
@@ -235,10 +237,10 @@ void gPainter::setLogicalZero(ePoint val)
        m_rc->submit(o);
 }
 
        m_rc->submit(o);
 }
 
-void gPainter::moveLogicalZero(ePoint rel)
+void gPainter::moveOffset(ePoint rel)
 {
        gOpcode o;
 {
        gOpcode o;
-       o.opcode=gOpcode::moveOffset;
+       o.opcode=gOpcode::setOffset;
        o.dc = m_dc.grabRef();
        o.parm.setOffset = new gOpcode::para::psetOffset;
        o.parm.setOffset->rel = 1;
        o.dc = m_dc.grabRef();
        o.parm.setOffset = new gOpcode::para::psetOffset;
        o.parm.setOffset->rel = 1;
@@ -246,24 +248,33 @@ void gPainter::moveLogicalZero(ePoint rel)
        m_rc->submit(o);
 }
 
        m_rc->submit(o);
 }
 
-void gPainter::resetLogicalZero()
+void gPainter::resetOffset()
 {
        gOpcode o;
 {
        gOpcode o;
-       o.opcode=gOpcode::moveOffset;
+       o.opcode=gOpcode::setOffset;
        o.dc = m_dc.grabRef();
        o.parm.setOffset = new gOpcode::para::psetOffset;
        o.parm.setOffset->value = ePoint(0, 0);
        m_rc->submit(o);
 }
 
        o.dc = m_dc.grabRef();
        o.parm.setOffset = new gOpcode::para::psetOffset;
        o.parm.setOffset->value = ePoint(0, 0);
        m_rc->submit(o);
 }
 
+void gPainter::resetClip(const gRegion &region)
+{
+       gOpcode o;
+       o.opcode = gOpcode::setClip;
+       o.dc = m_dc.grabRef();
+       o.parm.clip = new gOpcode::para::psetClip;
+       o.parm.clip->region = region;
+       m_rc->submit(o);
+}
+
 void gPainter::clip(const gRegion &region)
 {
        gOpcode o;
        o.opcode = gOpcode::addClip;
        o.dc = m_dc.grabRef();
        o.parm.clip = new gOpcode::para::psetClip;
 void gPainter::clip(const gRegion &region)
 {
        gOpcode o;
        o.opcode = gOpcode::addClip;
        o.dc = m_dc.grabRef();
        o.parm.clip = new gOpcode::para::psetClip;
-       o.parm.clip->region = new gRegion(region);
-       o.parm.clip->region->AddRef();
+       o.parm.clip->region = region;
        m_rc->submit(o);
 }
 
        m_rc->submit(o);
 }
 
@@ -297,53 +308,74 @@ gDC::~gDC()
 
 void gDC::exec(gOpcode *o)
 {
 
 void gDC::exec(gOpcode *o)
 {
-#if 0
-       switch(o->opcode)
+       switch (o->opcode)
        {
        {
+       case gOpcode::setBackgroundColor:
+               m_background_color = o->parm.setColor->color;
+               delete o->parm.setColor;
+               break;
+       case gOpcode::setForegroundColor:
+               m_foreground_color = o->parm.setColor->color;
+               delete o->parm.setColor;
+               break;
+       case gOpcode::setFont:
+               m_current_font = o->parm.setFont->font;
+               o->parm.setFont->font->Release();
+               delete o->parm.setFont;
+               break;
        case gOpcode::renderText:
        {
        case gOpcode::renderText:
        {
-               ePtr<eTextPara> para = new eTextPara(o->parm.renderText.area);
+               ePtr<eTextPara> para = new eTextPara(o->parm.renderText->area);
                para->setFont(m_current_font);
                para->setFont(m_current_font);
-               para->renderString(*o->parm.renderText.text, o->parm.renderText.flags);
-               para->blit(*this, ePoint(0, 0), m_foregroundColor, m_backgroundColor);
-               delete o->parm.renderText->text;
+               para->renderString(o->parm.renderText->text, o->parm.renderText->flags);
+               para->blit(*this, ePoint(0, 0), getRGB(m_foreground_color), getRGB(m_background_color));
+               delete o->parm.renderText;
                break;
        }
        case gOpcode::renderPara:
        {
                break;
        }
        case gOpcode::renderPara:
        {
-               o->parm.renderPara.textpara->blit(*this, o->parm.renderPara.offset, m_foregroundColor, m_backgroundColor);
-               o->parm.renderPara.textpara.Release();
+               o->parm.renderPara->textpara->blit(*this, o->parm.renderPara->offset, getRGB(m_foreground_color), getRGB(m_background_color));
+               o->parm.renderPara->textpara->Release();
+               delete o->parm.renderPara;
                break;
        }
        case gOpcode::fill:
                break;
        }
        case gOpcode::fill:
-               m_pixmap->fill(o->parm.fill.area, m_foregroundColor);
+       {
+               eRect area = o->parm.fill->area;
+               area.moveBy(m_current_offset);
+               gRegion clip = m_current_clip & area;
+               m_pixmap->fill(clip, m_foreground_color);
+               delete o->parm.fill;
+               break;
+       }
+       case gOpcode::clear:
+               m_pixmap->fill(m_current_clip, m_background_color);
                delete o->parm.fill;
                break;
        case gOpcode::blit:
        {
                gRegion clip;
                delete o->parm.fill;
                break;
        case gOpcode::blit:
        {
                gRegion clip;
-               if (o->parm.blit.clip)
+               if (!o->parm.blit->clip.isValid())
                {
                {
-                       clip.intersect(o->parm.blit.clip, clip);
-                       o->parm.blit.clip->Release();
+                       clip.intersect(gRegion(o->parm.blit->clip), clip);
                } else
                        clip = m_current_clip;
                } else
                        clip = m_current_clip;
-               pixmap->blit(*o->parm.blit.pixmap, o->parm.blit.pos, clip, o->parm.blit.flags);
-               o->parm.blit.pixmap->Release();
+               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;
                break;
        }
        case gOpcode::setPalette:
                break;
        }
        case gOpcode::setPalette:
-#if 0
-               if (o->parm.setPalette->palette->start>pixmap->surface->clut.colors)
-                       o->parm.setPalette->palette->start=pixmap->surface->clut.colors;
-               if (o->parm.setPalette->palette->colors>(pixmap->surface->clut.colors-o->parm.setPalette->palette->start))
-                       o->parm.setPalette->palette->colors=pixmap->surface->clut.colors-o->parm.setPalette->palette->start;
+               if (o->parm.setPalette->palette->start > m_pixmap->surface->clut.colors)
+                       o->parm.setPalette->palette->start = m_pixmap->surface->clut.colors;
+               if (o->parm.setPalette->palette->colors > (m_pixmap->surface->clut.colors-o->parm.setPalette->palette->start))
+                       o->parm.setPalette->palette->colors = m_pixmap->surface->clut.colors-o->parm.setPalette->palette->start;
                if (o->parm.setPalette->palette->colors)
                if (o->parm.setPalette->palette->colors)
-                       memcpy(pixmap->surface->clut.data+o->parm.setPalette->palette->start, o->parm.setPalette->palette->data, o->parm.setPalette->palette->colors*sizeof(gRGB));
+                       memcpy(m_pixmap->surface->clut.data+o->parm.setPalette->palette->start, o->parm.setPalette->palette->data, o->parm.setPalette->palette->colors*sizeof(gRGB));
+               
                delete[] o->parm.setPalette->palette->data;
                delete o->parm.setPalette->palette;
                delete o->parm.setPalette;
                delete[] o->parm.setPalette->palette->data;
                delete o->parm.setPalette->palette;
                delete o->parm.setPalette;
-#endif
                break;
        case gOpcode::mergePalette:
 #if 0
                break;
        case gOpcode::mergePalette:
 #if 0
@@ -353,23 +385,40 @@ void gDC::exec(gOpcode *o)
 #endif
                break;
        case gOpcode::line:
 #endif
                break;
        case gOpcode::line:
-#if 0
-               pixmap->line(o->parm.line->start, o->parm.line->end, o->parm.line->color);
+       {
+               ePoint start = o->parm.line->start + m_current_offset, end = o->parm.line->end + m_current_offset;
+               m_pixmap->line(m_current_clip, start, end, m_foreground_color);
                delete o->parm.line;
                delete o->parm.line;
-#endif
                break;
                break;
-       case gOpcode::setBackgroundColor:
-               m_backgroundColor = o->parm.setColor.color;
+       }
+       case gOpcode::addClip:
+               m_clip_stack.push(m_current_clip);
+               o->parm.clip->region.moveBy(m_current_offset);
+               m_current_clip &= o->parm.clip->region;
+               delete o->parm.clip;
                break;
                break;
-       case gOpcode::setForegroundColor:
-               m_foregroundColor = o->parm.setColor.color;
+       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());
+               delete o->parm.clip;
                break;
                break;
-       case gOpcode::clip:
+       case gOpcode::popClip:
+               if (!m_clip_stack.empty())
+               {
+                       m_current_clip = m_clip_stack.top();
+                       m_clip_stack.pop();
+               }
+               break;
+       case gOpcode::setOffset:
+               if (o->parm.setOffset->rel)
+                       m_current_offset += o->parm.setOffset->value;
+               else
+                       m_current_offset  = o->parm.setOffset->value;
+               delete o->parm.setOffset;
                break;
        default:
                eFatal("illegal opcode %d. expect memory leak!", o->opcode);
        }
                break;
        default:
                eFatal("illegal opcode %d. expect memory leak!", o->opcode);
        }
-#endif
 }
 
 gRGB gDC::getRGB(gColor col)
 }
 
 gRGB gDC::getRGB(gColor col)
@@ -386,4 +435,5 @@ gRGB gDC::getRGB(gColor col)
 
 DEFINE_REF(gDC);
 
 
 DEFINE_REF(gDC);
 
-eAutoInitP0<gRC> init_grc(eAutoInitNumbers::graphic, "gRC");
+eAutoInitPtr<gRC> init_grc(eAutoInitNumbers::graphic, "gRC");
+
index 225fd9de4da054cad05c2346e19f8318d1b21d44..479317924d53f8887b9abb411cac1df165039d73 100644 (file)
@@ -40,9 +40,9 @@ struct gOpcode
                setBackgroundColor,
                setForegroundColor,
                
                setBackgroundColor,
                setForegroundColor,
                
-               setOffset, moveOffset,
+               setOffset,
                
                
-               addClip, popClip,
+               setClip, addClip, popClip,
                
                end,shutdown
        } opcode;
                
                end,shutdown
        } opcode;
@@ -83,7 +83,7 @@ struct gOpcode
                        gPixmap *pixmap;
                        ePoint position;
                        int flags;
                        gPixmap *pixmap;
                        ePoint position;
                        int flags;
-                       gRegion *clip;
+                       eRect clip;
                } *blit;
 
                struct pmergePalette
                } *blit;
 
                struct pmergePalette
@@ -98,7 +98,7 @@ struct gOpcode
 
                struct psetClip
                {
 
                struct psetClip
                {
-                       gRegion *region;
+                       gRegion region;
                } *clip;
                
                struct psetColor
                } *clip;
                
                struct psetColor
@@ -138,7 +138,7 @@ public:
                static int collected=0;
                queue.enqueue(o);
                collected++;
                static int collected=0;
                queue.enqueue(o);
                collected++;
-               if (o.opcode==gOpcode::end||o.opcode==gOpcode::shutdown)
+//             if (o.opcode==gOpcode::end||o.opcode==gOpcode::shutdown)
                {
                        queuelock.unlock(collected);
 #ifdef SYNC_PAINT
                {
                        queuelock.unlock(collected);
 #ifdef SYNC_PAINT
@@ -176,17 +176,18 @@ public:
        
        void clear();
        
        
        void clear();
        
-       void blit(gPixmap *pixmap, ePoint pos, gRegion *clip = 0, int flags=0);
+       void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
 
        void setPalette(gRGB *colors, int start=0, int len=256);
        void mergePalette(gPixmap *target);
        
        void line(ePoint start, ePoint end);
 
 
        void setPalette(gRGB *colors, int start=0, int len=256);
        void mergePalette(gPixmap *target);
        
        void line(ePoint start, ePoint end);
 
-       void setLogicalZero(ePoint abs);
-       void moveLogicalZero(ePoint rel);
-       void resetLogicalZero();
+       void setOffset(ePoint abs);
+       void moveOffset(ePoint rel);
+       void resetOffset();
        
        
+       void resetClip(const gRegion &clip);
        void clip(const gRegion &clip);
        void clippop();
 
        void clip(const gRegion &clip);
        void clippop();
 
@@ -199,18 +200,19 @@ DECLARE_REF;
 protected:
        ePtr<gPixmap> m_pixmap;
 
 protected:
        ePtr<gPixmap> m_pixmap;
 
-       ePtr<gRegion> m_clip_region;
-       gColor m_foregroundColor, m_backgroundColor;
+       gColor m_foreground_color, m_background_color;
        ePtr<gFont> m_current_font;
        ePoint m_current_offset;
        ePtr<gFont> m_current_font;
        ePoint m_current_offset;
+       
+       std::stack<gRegion> m_clip_stack;
        gRegion m_current_clip;
        
 public:
        gRegion m_current_clip;
        
 public:
-       void exec(gOpcode *opcode);
+       virtual void exec(gOpcode *opcode);
        gDC(gPixmap *pixmap);
        gDC();
        virtual ~gDC();
        gDC(gPixmap *pixmap);
        gDC();
        virtual ~gDC();
-       gRegion &getClip() { return *m_clip_region; }
+       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(); }
        int getPixmap(ePtr<gPixmap> &pm) { pm = m_pixmap; return 0; }
        gRGB getRGB(gColor col);
        virtual eSize getSize() { return m_pixmap->getSize(); }
index f341e79a61de30aeb17bc6918c91be336acee6a7..cbac53f8f2d9b1abc6f868164a762c2863fb7817 100644 (file)
@@ -1,6 +1,7 @@
 #include <lib/gdi/erect.h>
 #include <lib/gdi/epoint.h>
 #include <lib/gdi/region.h>
 #include <lib/gdi/erect.h>
 #include <lib/gdi/epoint.h>
 #include <lib/gdi/region.h>
+#include <lib/base/eerror.h>
 
 #undef max
 #define max(a,b)  ((a) > (b) ? (a) : (b))
 
 #undef max
 #define max(a,b)  ((a) > (b) ? (a) : (b))
@@ -87,7 +88,7 @@ void gRegion::appendNonO(std::vector<eRect>::const_iterator r,
        rects.reserve(rects.size() + newRects);
        do {
                assert(r->x1 < r->x2);
        rects.reserve(rects.size() + newRects);
        do {
                assert(r->x1 < r->x2);
-               rects.push_back(eRect(r->x1, y1, r->x2, y2));
+               rects.push_back(eRect(r->x1, y1, r->x2 - r->x1, y2 - y1));
                r++;
        } while (r != rEnd);
 }
                r++;
        } while (r != rEnd);
 }
@@ -110,7 +111,7 @@ void gRegion::intersectO(
                x2 = min(r1->x2, r2->x2);
                
                if (x1 < x2)
                x2 = min(r1->x2, r2->x2);
                
                if (x1 < x2)
-                       rects.push_back(eRect(x1, y1, x2, y2));
+                       rects.push_back(eRect(x1, y1, x2 - x1, y2 - y1));
                if (r1->x2 == x2)
                        r1++;
                if (r2->x2 == x2)
                if (r1->x2 == x2)
                        r1++;
                if (r2->x2 == x2)
@@ -145,7 +146,7 @@ void gRegion::subtractO(
                                ++r2;
                } else if (r2->x1 < r1->x2) {
                        assert(x1<r2->x1);
                                ++r2;
                } else if (r2->x1 < r1->x2) {
                        assert(x1<r2->x1);
-                       rects.push_back(eRect(x1, y1, r2->x1, y2));
+                       rects.push_back(eRect(x1, y1, r2->x1 - x1, y2 - y1));
                        x1 = r2->x2;
                        if (x1 >= r1->x2) {
                                ++r1;
                        x1 = r2->x2;
                        if (x1 >= r1->x2) {
                                ++r1;
@@ -156,7 +157,7 @@ void gRegion::subtractO(
                } else
                {
                        if (r1->x2 > x1)
                } else
                {
                        if (r1->x2 > x1)
-                               rects.push_back(eRect(x1, y1, r1->x2, y2));
+                               rects.push_back(eRect(x1, y1, r1->x2 - x1, y2 - y1));
                        ++r1;
                        if (r1 != r1End)
                                x1 = r1->x1;
                        ++r1;
                        if (r1 != r1End)
                                x1 = r1->x1;
@@ -165,7 +166,7 @@ void gRegion::subtractO(
        while (r1 != r1End)
        {
                assert(x1<r1->x2);
        while (r1 != r1End)
        {
                assert(x1<r1->x2);
-               rects.push_back(eRect(x1, y1, r1->x2, y2));
+               rects.push_back(eRect(x1, y1, r1->x2 - x1, y2 - y1));
                ++r1;
                if (r1 != r1End)
                        x1 = r1->x1;
                ++r1;
                if (r1 != r1End)
                        x1 = r1->x1;
@@ -180,7 +181,7 @@ void gRegion::subtractO(
                if (x2 < r->x2) x2 = r->x2;                             \
        } else {                                                  \
                /* Add current rectangle, start new one */              \
                if (x2 < r->x2) x2 = r->x2;                             \
        } else {                                                  \
                /* Add current rectangle, start new one */              \
-               rects.push_back(eRect(x1, y1, x2, y2));                 \
+               rects.push_back(eRect(x1, y1, x2 - x1, y2 - y1));       \
                x1 = r->x1;                                             \
                x2 = r->x2;                                             \
        }                                                         \
                x1 = r->x1;                                             \
                x2 = r->x2;                                             \
        }                                                         \
@@ -225,7 +226,7 @@ void gRegion::mergeO(
                        MERGERECT(r2);
                } while (r2 != r2End);
        }
                        MERGERECT(r2);
                } while (r2 != r2End);
        }
-       rects.push_back(eRect(x1, y1, x2, y2));
+       rects.push_back(eRect(x1, y1, x2 - x1, y2 - y1));
 }
 
 void gRegion::regionOp(const gRegion &reg1, const gRegion &reg2, int opcode, int &overlap)
 }
 
 void gRegion::regionOp(const gRegion &reg1, const gRegion &reg2, int opcode, int &overlap)
@@ -318,10 +319,24 @@ void gRegion::regionOp(const gRegion &reg1, const gRegion &reg2, int opcode, int
                coalesce(prevBand, curBand);
                AppendRegions(r2BandEnd, r2End);
        }
                coalesce(prevBand, curBand);
                AppendRegions(r2BandEnd, r2End);
        }
+       extends = eRect();
+
+       for (int a=0; a<rects.size(); ++a)
+               extends = extends | eRect(rects[0].topLeft(), rects[rects.size()-1].bottomRight());
 }
        
 void gRegion::intersect(const gRegion &r1, const gRegion &r2)
 {
 }
        
 void gRegion::intersect(const gRegion &r1, const gRegion &r2)
 {
+       if (r1.rects.empty())
+       {
+               *this = r2;
+               return;
+       }
+       if (r2.rects.empty())
+       {
+               *this = r1;
+               return;
+       }
        int overlap;
        // TODO: handle trivial reject
        regionOp(r1, r2, OP_INTERSECT, overlap);
        int overlap;
        // TODO: handle trivial reject
        regionOp(r1, r2, OP_INTERSECT, overlap);
@@ -329,6 +344,11 @@ void gRegion::intersect(const gRegion &r1, const gRegion &r2)
 
 void gRegion::subtract(const gRegion &r1, const gRegion &r2)
 {
 
 void gRegion::subtract(const gRegion &r1, const gRegion &r2)
 {
+       if (r1.rects.empty() || r2.rects.empty())
+       {
+               *this = r1;
+               return;
+       }
        int overlap;
        // TODO: handle trivial reject
        regionOp(r1, r2, OP_SUBTRACT, overlap);
        int overlap;
        // TODO: handle trivial reject
        regionOp(r1, r2, OP_SUBTRACT, overlap);
@@ -336,8 +356,68 @@ void gRegion::subtract(const gRegion &r1, const gRegion &r2)
        
 void gRegion::merge(const gRegion &r1, const gRegion &r2)
 {
        
 void gRegion::merge(const gRegion &r1, const gRegion &r2)
 {
+       if (r1.rects.empty())
+       {
+               *this = r2;
+               return;
+       }
+       if (r2.rects.empty())
+       {
+               *this = r1;
+               return;
+       }
        int overlap;
        // TODO: handle trivial reject
        regionOp(r1, r2, OP_UNION, overlap);
 }
 
        int overlap;
        // TODO: handle trivial reject
        regionOp(r1, r2, OP_UNION, overlap);
 }
 
+gRegion gRegion::operator&(const gRegion &r2) const
+{
+       gRegion res;
+       res.intersect(*this, r2);
+       return res;
+}
+
+gRegion gRegion::operator-(const gRegion &r2) const 
+{
+       gRegion res;
+       res.subtract(*this, r2);
+       return res;
+}
+
+gRegion gRegion::operator|(const gRegion &r2) const
+{
+       gRegion res;
+       res.merge(*this, r2);
+       return res;
+}
+
+gRegion &gRegion::operator&=(const gRegion &r2)
+{
+       gRegion res;
+       res.intersect(*this, r2);
+       return *this = res;
+}
+
+gRegion &gRegion::operator-=(const gRegion &r2)
+{
+       gRegion res;
+       res.subtract(*this, r2);
+       return *this = res;
+}
+
+gRegion &gRegion::operator|=(const gRegion &r2)
+{
+       gRegion res;
+       res.merge(*this, r2);
+       return *this = res;
+}
+
+void gRegion::moveBy(ePoint offset)
+{
+       extends.moveBy(offset);
+       int i;
+       for (i=0; i<rects.size(); ++i)
+               rects[i].moveBy(offset);
+}
+
index a1dbe91660ca64694680970276ea17ccaaf70e30..7f73be753e71378d8f2ce55ea873d5001d3d3e27 100644 (file)
@@ -4,9 +4,8 @@
 #include <lib/base/object.h>
 #include <vector>
 
 #include <lib/base/object.h>
 #include <vector>
 
-class gRegion: public virtual iObject
+class gRegion
 {
 {
-DECLARE_REF;
 private:
        inline void FindBand(
                        std::vector<eRect>::const_iterator r,
 private:
        inline void FindBand(
                        std::vector<eRect>::const_iterator r,
@@ -77,9 +76,18 @@ public:
        gRegion();
        virtual ~gRegion();
 
        gRegion();
        virtual ~gRegion();
 
+       gRegion operator&(const gRegion &r2) const;
+       gRegion operator-(const gRegion &r2) const;
+       gRegion operator|(const gRegion &r2) const;
+       gRegion &operator&=(const gRegion &r2);
+       gRegion &operator-=(const gRegion &r2);
+       gRegion &operator|=(const gRegion &r2);
+       
        void intersect(const gRegion &r1, const gRegion &r2);
        void subtract(const gRegion &r1, const gRegion &r2);
        void merge(const gRegion &r1, const gRegion &r2);
        void intersect(const gRegion &r1, const gRegion &r2);
        void subtract(const gRegion &r1, const gRegion &r2);
        void merge(const gRegion &r1, const gRegion &r2);
+       
+       void moveBy(ePoint offset);
 };
 
 #endif
 };
 
 #endif
index ce4efaf17f02b505bbb3c76e4d2fb504d11695de..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,253 +0,0 @@
-#include <lib/gui/elabel.h>
-
-#include <lib/gdi/fb.h>
-#include <lib/gdi/font.h>
-#include <lib/gdi/lcd.h>
-#include <lib/gui/eskin.h>
-#include <lib/base/init.h>
-#include <lib/base/init_num.h>
-
-eLabel::eLabel(eWidget *parent, int flags, int takefocus, const char *deco ):
-       eDecoWidget(parent, takefocus, deco), blitFlags(0), flags(flags),
-       para(0), align( eTextPara::dirLeft ), shortcutPixmap(0)
-{
-}
-
-eLabel::~eLabel()
-{
-       if (para)
-       {
-               para->destroy();
-               para=0;
-       }
-}
-
-void eLabel::setPixmapPosition( const ePoint &p )
-{
-       pixmap_position = p;
-       invalidate();
-}
-
-void eLabel::validate( const eSize* s )
-{
-       if (!para)
-       {
-               if (s)
-                       para=new eTextPara( eRect(text_position.x(), text_position.y(), s->width() - text_position.x(), s->height() - text_position.y()));
-               else
-                       para=new eTextPara( eRect(text_position.x(), text_position.y(), size.width() - text_position.x(), size.height() - text_position.y()));
-
-               para->setFont(font);
-               para->renderString(text, flags);
-               para->realign(align);
-  }
-}
-
-void eLabel::invalidate()
-{
-       if (para)
-       {
-               para->destroy();
-               para=0;
-       }
-       if (isVisible())
-               eDecoWidget::invalidate();  // we must redraw...
-}
-
-void eLabel::setFlags(int flag)
-{
-       flags|=flag;
-       if (flag)
-               invalidate();
-}
-
-void eLabel::setBlitFlags( int flags )
-{
-       blitFlags |= flags;
-}
-
-void eLabel::removeFlags(int flag)
-{
-       flags &= ~flag;
-       if (flag)
-               invalidate();
-}
-
-void eLabel::setAlign(int align)
-{
-       this->align = align;
-       invalidate();
-}
-
-void eLabel::redrawWidget(gPainter *target, const eRect &rc)
-{
-/*     eDebug("decoStr = %s, text=%s, name=%s, %p left = %d, top = %d, width=%d, height = %d", strDeco?strDeco.c_str():"no", text?text.c_str():"no" , name?name.c_str():"no", this, this->getPosition().x(), this->getPosition().y(), this->getSize().width(), this->getSize().height() ); 
-       eDebug("renderContext left = %d, top = %d, width = %d, height = %d", rc.left(), rc.top(), rc.width(), rc.height() );*/
-
-       target->clip( gRegion(rc) );
-       eRect area=eRect(ePoint(0, 0), ePoint(width(), height()));
-/*     eDebug("area left = %d, top = %d, width = %d, height = %d",
-               area.left(), area.top(),
-               area.width(), area.height() );*/
-
-       if (deco_selected && have_focus)
-       {
-               deco_selected.drawDecoration(target, ePoint(width(), height()));
-               area=crect_selected;
-       } else if (deco)
-       {
-               deco.drawDecoration(target, ePoint(width(), height()));
-               area=crect;
-       }
-/*     eDebug("area left = %d, top = %d, width = %d, height = %d",
-               area.left(), area.top(),
-               area.width(), area.height() );*/
-
-       if (shortcutPixmap)
-       {
-               //area.setWidth(area.width()-area.height());
-               area.setX(area.height());
-       }
-
-       if (text.length())
-       {
-               if ( area.size().height() < size.height() ||
-                               area.size().width() < size.width() )
-               {
-               // then deco is drawed
-                       eSize s=area.size();
-                       validate( &s );
-               } else
-                       validate();
-
-               if (flags & flagVCenter)
-                       yOffs = ( (area.height() - para->getBoundBox().height() ) / 2 + 0) - para->getBoundBox().top();
-               else
-                       yOffs = 0;
-
-               eWidget *w;
-               if ((blitFlags & BF_ALPHATEST) && (transparentBackgroundColor >= 0))
-               {
-                       w=this;
-                       target->setBackgroundColor(transparentBackgroundColor);
-               } else
-               {
-                       w=getNonTransparentBackground();
-                       target->setBackgroundColor(w->getBackgroundColor());
-               }
-               target->setFont(font);
-               target->renderPara(para, ePoint( area.left(), area.top()+yOffs) );
-       }
-       if (pixmap)
-       {
-//             eDebug("blit pixmap area left=%d, top=%d, right=%d, bottom=%d", rc.left(), rc.top(), rc.right(), rc.bottom() );
-//             eDebug("pixmap_pos x = %d, y = %d, xsize=%d, ysize=%d", pixmap_position.x(), pixmap_position.y(), pixmap->x, pixmap->y );
-               target->blit(pixmap, shortcutPixmap?pixmap_position+ePoint( area.left(), 0):pixmap_position, area, (blitFlags & BF_ALPHATEST) ? gPixmap::blitAlphaTest : 0);
-       }
-       if (shortcutPixmap)
-               target->blit(shortcutPixmap, 
-                               ePoint((area.height()-shortcutPixmap->getSize().width())/2, area.top()+(area.height()-shortcutPixmap->getSize().height())/2),
-                               eRect(),
-                               gPixmap::blitAlphaTest);
-       target->clippop();
-}
-
-int eLabel::eventHandler(const eWidgetEvent &event)
-{
-       switch (event.type)
-       {
-               case eWidgetEvent::changedFont:
-               case eWidgetEvent::changedText:
-               if (para)
-               {
-                       para->destroy();
-                       para=0;
-               }
-               if ( have_focus && deco_selected )
-                       eDecoWidget::invalidate( crect_selected );
-               else if ( deco )
-                       eDecoWidget::invalidate( crect );
-               else
-                       eDecoWidget::invalidate();
-       break;
-
-       case eWidgetEvent::changedSize:
-               invalidate();
-       break;
-
-       default:
-               return eDecoWidget::eventHandler(event);
-               break;
-       }
-       return 1;
-}
-
-eSize eLabel::getExtend()
-{
-       validate();
-       return eSize(para->getBoundBox().width()+(shortcutPixmap?shortcutPixmap->x*2:0), para->getBoundBox().height());
-}
-
-ePoint eLabel::getLeftTop()
-{
-       validate();
-       return ePoint(para->getBoundBox().left(), para->getBoundBox().top());
-}
-
-int eLabel::setProperty(const eString &prop, const eString &value)
-{
-       if (prop=="wrap" && value == "on")
-               setFlags(RS_WRAP);
-       else if (prop=="alphatest" && value == "on")
-       {
-               transparentBackgroundColor=getBackgroundColor();
-               setBackgroundColor(-1);
-               blitFlags |= BF_ALPHATEST;
-       } else if (prop=="align")
-       {
-               if (value=="left")
-                       setAlign(eTextPara::dirLeft);
-               else if (value=="center")
-                       setAlign(eTextPara::dirCenter);
-               else if (value=="right")
-                       setAlign(eTextPara::dirRight);
-               else if (value=="block")
-                       setAlign(eTextPara::dirBlock);
-               else
-                       setAlign(eTextPara::dirLeft);
-       }
-       else if (prop=="vcenter")
-               setFlags( flagVCenter );
-       else if (prop == "shortcut")
-       {
-               setShortcutPixmap(value);
-               return eWidget::setProperty(prop, value);
-       } else
-               return eDecoWidget::setProperty(prop, value);
-       return 0;
-}
-
-void eLabel::setShortcutPixmap(const eString &shortcut)
-{
-       eSkin::getActive()->queryImage(shortcutPixmap, "shortcut." + shortcut);
-}
-
-static eWidget *create_eLabel(eWidget *parent)
-{
-       return new eLabel(parent);
-}
-
-class eLabelSkinInit
-{
-public:
-       eLabelSkinInit()
-       {
-               eSkin::addWidgetCreator("eLabel", create_eLabel);
-       }
-       ~eLabelSkinInit()
-       {
-               eSkin::removeWidgetCreator("eLabel", create_eLabel);
-       }
-};
-
-eAutoInitP0<eLabelSkinInit> init_eLabelSkinInit(eAutoInitNumbers::guiobject, "eLabel");
index 388eb14ae6c284706ac8a9a592a020f92597d0ed..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,163 +0,0 @@
-#include <lib/gui/emessage.h>
-
-#include <lib/gui/elabel.h>
-#include <lib/gui/ebutton.h>
-#include <lib/gui/eskin.h>
-#include <lib/gdi/font.h>
-#include <lib/base/i18n.h>
-
-eMessageBox::eMessageBox(eString message, eString caption, int flags, int def): eWindow(0), icon(0)
-{
-       setText(caption);       
-       int fontsize=eSkin::getActive()->queryValue("fontsize", 20);
-       int posx = eSkin::getActive()->queryValue("eMessageBox.pos.x", 100);
-       int posy = eSkin::getActive()->queryValue("eMessageBox.pos.y", 70);
-       move(ePoint(posx, posy));
-       resize(eSize(450, 430));
-
-       if ( flags > 15 ) // we have to draw an icon
-       {
-               ePtr<gPixmap> pm;
-               switch ( flags & ~15 )
-               {
-                       case iconInfo:
-                               eSkin::getActive()->queryImage(pm, "icon_info" );                       
-                               break;
-                       case iconQuestion:
-                               eSkin::getActive()->queryImage(pm, "icon_question" );                   
-                               break;
-                       case iconWarning:
-                               eSkin::getActive()->queryImage(pm, "icon_warning" );                    
-                               break;
-                       case iconError:
-                               eSkin::getActive()->queryImage(pm, "icon_error" );                      
-                               break;
-               }
-               if (pm)
-               {
-                       icon = new eLabel(this);
-                       icon->setPixmap( pm );
-                       icon->pixmap_position=ePoint(0,0);
-                       icon->resize( eSize(pm->x, pm->y) );
-                       icon->setBlitFlags( BF_ALPHATEST );
-               }
-       }
-
-       text=new eLabel(this);
-       text->setText(message);
-       text->resize( eSize( clientrect.width(), clientrect.height() ));
-       text->setFlags( RS_WRAP|eLabel::flagVCenter );
-       eSize txtSize=text->getExtend();
-       txtSize+=eSize(8,4);  // the given Size of the Text is okay... but the renderer sucks...
-       text->resize(txtSize);
-
-       // here the two labels ( icon, text) has the correct size..  now we calc the border
-
-       eSize ext;
-
-       if ( icon )
-       {
-               if ( icon->getSize().height() > text->getSize().height() )
-               {
-                       eDebug("icon is higher");
-                       eSize s = icon->getSize();
-                       icon->move( ePoint( 20, 20 ) );
-                       text->move( ePoint( 20 + s.width() + 20, icon->getPosition().y() + s.height() / 2 - txtSize.height() / 2 ) );
-                       ext.setHeight( icon->getPosition().y() + icon->getSize().height() + 20 );
-               }
-               else
-               {
-                       eDebug("text is higher");
-                       text->move( ePoint( 20 + icon->getSize().width() + 20 , 20 ) );
-                       icon->move( ePoint( 20, text->getPosition().y() + text->getSize().height() / 2 - icon->getSize().height() / 2 ) );
-                       ext.setHeight( text->getPosition().y() + text->getSize().height() + 20 );
-               }
-               ext.setWidth( text->getPosition().x() + text->getSize().width() + 20 );
-       }
-       else
-       {
-               text->move( ePoint(20, 20) );
-               ext.setWidth( text->getPosition().x() + text->getSize().width()+20 );
-               ext.setHeight( text->getPosition().y() + text->getSize().height() + 20 );
-       }
-       
-       if (ext.width()<150)
-               ext.setWidth(150);
-
-       int xpos=20;
-
-       if ( flags & 15)
-       {
-               for (int i=btOK; i<btMax; i<<=1)
-                       if (flags & i)
-                       {
-                               eButton *b=new eButton(this);
-                               b->resize(eSize(size.width(), fontsize+4));
-                               const char *t="", *shortcut="";
-                               switch (i)
-                               {
-                                       case btOK: t=_("OK"); shortcut="green"; CONNECT(b->selected, eMessageBox::pressedOK); break;
-                                       case btCancel: t=_("Cancel"); shortcut="red"; CONNECT(b->selected, eMessageBox::pressedCancel); break;
-                                       case btYes: t=_("Yes"); shortcut="green"; CONNECT(b->selected, eMessageBox::pressedYes); break;
-                                       case btNo: t=_("No"); shortcut="red"; CONNECT(b->selected, eMessageBox::pressedNo); break;
-                               }
-                               b->setProperty("shortcut", shortcut);
-                               b->setText(t);
-                               eSize bSize=b->getExtend();
-                               bSize.setWidth( bSize.width() * 2 );
-                               bSize.setHeight( fontsize + 4 + 10 );
-                               b->resize(bSize);
-                               b->move( ePoint( xpos, ext.height() ) );
-
-                               b->loadDeco();
-                       
-                               if (def == i)
-                                       setFocus(b);
-                       
-                               xpos += bSize.width()+20;
-                               if ( xpos+20 > ext.width() )
-                                       cresize( eSize( xpos+20, ext.height() + bSize.height() + 20 ) );
-                               else
-                                       cresize( eSize( ext.width(), ext.height() + bSize.height() + 20 ) );
-                       }
-       }
-       else
-               cresize( ext );
-       zOrderRaise();
-}
-
-eMessageBox::~eMessageBox()
-{
-}
-
-void eMessageBox::pressedOK()
-{
-       if ( in_loop )
-         close(btOK);
-       else
-               hide();
-}
-
-void eMessageBox::pressedCancel()
-{
-       if ( in_loop )
-         close(btCancel);
-       else
-               hide();
-}
-
-void eMessageBox::pressedYes()
-{
-       if ( in_loop )
-         close(btYes);
-       else
-               hide();
-}
-
-void eMessageBox::pressedNo()
-{
-       if ( in_loop )
-         close(btNo);
-       else
-               hide();
-}
index c03ec8f7527ee40038a1aa3fb4e71acf436976aa..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,447 +0,0 @@
-#include <lib/gui/enumber.h>
-#include <lib/driver/rc.h>
-#include <lib/gui/eskin.h>
-#include <lib/gui/elabel.h>
-#include <lib/gdi/fb.h>
-#include <lib/gdi/grc.h>
-#include <lib/gdi/font.h>
-#include <lib/gui/guiactions.h>
-
-void eNumber::unpack(__u32 l, int *t)
-{
-       for (int i=0; i<4; i++)
-               *t++=(l>>((3-i)*8))&0xFF;
-}
-
-void eNumber::pack(__u32 &l, int *t)
-{
-       l=0;
-       for (int i=0; i<4; i++)
-               l|=(*t++)<<((3-i)*8);
-}
-
-eRect eNumber::getNumberRect(int n)
-{
-       if (deco_selected && have_focus)
-               return eRect( deco_selected.borderLeft + n * space_selected, deco_selected.borderTop, dspace, crect_selected.height() );
-       else if (deco)
-               return eRect( deco.borderLeft + n * dspace, deco.borderTop, dspace, crect.height() );
-       else
-               return eRect( n * dspace, 0, dspace, height() );
-}
-
-void eNumber::redrawNumber(gPainter *p, int n, const eRect &area)
-{
-       eRect pos =     getNumberRect(n);
-
-       if (!area.contains(pos) )
-               return;
-
-       p->setForegroundColor((have_focus && n==active)?cursorB:normalB);
-       p->fill(pos);
-       p->setFont(font);
-
-       eString t;
-       if (flags & flagFillWithZeros || ( (flags & flagFixedNum) && n ))
-       {
-    eString s = "%0"+eString().setNum(maxdigits)+(base==10?"d":"X");
-               const char* p = s.c_str();
-               char* tmp = new char[10];
-               strcpy( tmp, p );
-               t.sprintf(tmp, number[n]);
-               delete [] tmp;
-       }
-       else
-       {
-               if (flags&flagHideInput)
-                       t="*";
-               else if (base==10)
-                       t.sprintf("%d", number[n]);
-               else if (base==0x10)
-                       t.sprintf("%X", number[n]);
-       }
-
-       if (!n && flags & flagPosNeg && neg)
-               t="-"+t;
-
-       if (n && (flags & flagTime))
-               t=":"+t;
-
-       else if (n && ( (flags & flagDrawPoints) || (flags & flagFixedNum)) )
-               t="."+t;
-
-       p->setForegroundColor((have_focus && n==active)?cursorF:normalF);
-       p->setBackgroundColor((have_focus && n==active)?cursorB:normalB);
-
-       p->clip( pos );
-       if (!n && len==2 && ((flags & flagFixedNum) || (flags & flagTime)) ) // first element...
-       {
-               eTextPara *para = new eTextPara( pos );
-               para->setFont( font );
-               para->renderString( t );
-               para->realign( eTextPara::dirRight );
-               p->renderPara( *para );
-               para->destroy();
-       }
-       else
-               p->renderText(pos, t);
-               
-       p->clippop();
-}
-
-double eNumber::getFixedNum()
-{
-       if (flags & flagFixedNum)
-       {
-               if (flags&flagPosNeg && neg)
-               {
-                       double d = -((double)number[0]+(double)number[1]/1000);
-                       eDebug("getFixedNum %lf", d);
-                       return d;
-               }
-               else
-               {
-                       float d = (double)number[0]+(double)number[1]/1000;
-                       eDebug("getFixedNum %lf", d);
-                       return d;
-               }
-       }
-       else
-               return 0;
-}
-
-void eNumber::setFixedNum(double d)
-{
-       eDebug("setFixedNum %lf", d);
-       if (flags & flagPosNeg)
-               neg=d<0;
-       else
-               neg=0;
-
-       d=fabs(d);
-
-       if (flags & flagFixedNum)
-       {
-               number[0]=(int)d;
-               number[1]=(int)round(( ( d - number[0] ) * 1000) );
-       }
-       else
-               eDebug("eNumber bug... the Number %s is not a fixed Point number", name.c_str());
-}
-
-void eNumber::redrawWidget(gPainter *p, const eRect &area)
-{
-       for (int i=0; i<len; i++)
-               redrawNumber(p, i, area);
-
-       if (deco_selected && have_focus)
-               deco_selected.drawDecoration(p, ePoint(width(), height()));
-       else if (deco)
-               deco.drawDecoration(p, ePoint(width(), height()));
-}
-
-void eNumber::invalidateNum()
-{
-       if ( have_focus && deco_selected )
-               invalidate( crect_selected );
-       else if ( deco )
-               invalidate( crect );
-       else
-               invalidate();
-}
-
-int eNumber::eventHandler(const eWidgetEvent &event)
-{
-#ifndef DISABLE_LCD
-       if (LCDTmp)
-               ((eNumber*) LCDTmp)->eventHandler(event);
-#endif
-       switch (event.type)
-       {
-       case eWidgetEvent::changedSize:
-               if (deco)
-                       dspace = (crect.width()) / len;
-               else
-                       dspace = (size.width()) / len;  
-               if (deco_selected)
-                       space_selected = (crect_selected.width()) / len;
-               break;
-       case eWidgetEvent::evtAction:
-               if ( len > 1 && event.action == &i_cursorActions->left)
-               {
-                       int oldac=active;
-                       active--;
-                       invalidate(getNumberRect(oldac));
-                       if (active<0)
-                               active=len-1;
-                       if (active!=oldac)
-                               invalidate(getNumberRect(active));
-                       digit=0;
-               } else if ( len > 1 && (event.action == &i_cursorActions->right) || (event.action == &i_cursorActions->ok))
-               {
-                       int oldac=active;
-                       active++;
-                       invalidate(getNumberRect(oldac));
-                       if (active>=len)
-                       {
-                               if (event.action == &i_cursorActions->ok)
-                               /*emit*/ selected(number);
-                               active=0;
-                       }
-                       if (active!=oldac)
-                               invalidate(getNumberRect(active));
-                       digit=0;
-               } else
-                               break;
-               return 1;
-       default:
-               break;
-       }
-       return eDecoWidget::eventHandler(event);
-}
-
-// isactive is the digit (always in the first field )
-// that ist active after get the first focus ! 
-
-eNumber::eNumber(eWidget *parent, int _len, int _min, int _max, int _maxdigits, int *init, int isactive, eWidget* descr, int grabfocus, const char *deco)
- :eDecoWidget(parent, grabfocus, deco ),
-       active(0), 
-       cursorB(eSkin::getActive()->queryScheme("global.selected.background")), 
-       cursorF(eSkin::getActive()->queryScheme("global.selected.foreground")), 
-       normalB(eSkin::getActive()->queryScheme("global.normal.background")),   
-       normalF(eSkin::getActive()->queryScheme("global.normal.foreground")),   
-       have_focus(0), digit(isactive), isactive(isactive), flags(0), descr(descr), tmpDescr(0),
-       neg(false)
-{
-       setNumberOfFields(_len);
-       setLimits(_min, _max);
-       setMaximumDigits(_maxdigits);
-       setBase(10);
-       for (int i=0; init && i<len; i++)
-               number[i]=init[i];
-       addActionMap(&i_cursorActions->map);
-}                 
-             
-eNumber::~eNumber()
-{
-}
-
-int eNumber::keyDown(int key)
-{
-#ifndef DISABLE_LCD
-       if (LCDTmp)
-               ((eNumber*) LCDTmp)->keyDown(key);
-#endif
-       switch (key)
-       {
-       case eRCInput::RC_0 ... eRCInput::RC_9:
-       {
-               int nn=(digit!=0)?number[active]*10:0;
-               nn+=key-eRCInput::RC_0;
-               if (flags & flagTime)
-               {
-                       if ( active )
-                               max = 59;
-                       else
-                               max = 23;
-               }
-               else if (flags & flagFixedNum)
-               {
-                       if (active)
-                               max=999;
-                       else
-                               max=oldmax;
-               }
-               if (nn>=min && nn<=max)
-               {
-                       number[active]=nn;
-                       invalidate(getNumberRect(active));
-                       digit++;
-                       if ((digit>=maxdigits) || (nn==0))
-                       {        
-                               active++;
-                               invalidate(getNumberRect(active-1));
-                               digit=0;
-                               /*emit*/ numberChanged();
-                               if (active>=len)
-                               {
-                                       /*emit*/ selected(number);
-                                       active=0;
-                               }
-                               else
-                                       invalidate(getNumberRect(active));
-                       }
-               }
-               break;
-
-       break;
-       }
-       case eRCInput::RC_PLUS:
-               if (flags & flagPosNeg && neg )
-               {
-                       neg=false;
-                       invalidate(getNumberRect(0));
-               }
-       break;
-
-       case eRCInput::RC_MINUS:
-               if (flags & flagPosNeg && !neg )
-               {
-                       neg=true;
-                       invalidate(getNumberRect(0));
-               }
-       default:
-               return 0;
-       }
-       return 1;
-}
-
-void eNumber::gotFocus()
-{
-       have_focus++;
-       digit=isactive;
-
-  if (deco && deco_selected)
-               invalidate();
-       else
-               invalidate(getNumberRect(active));
-
-#ifndef DISABLE_LCD
-       if (parent && parent->LCDElement)  // detect if LCD Avail
-       {
-               LCDTmp = new eNumber(parent->LCDElement, len, min, max, maxdigits, &(number[0]), isactive, 0, 0);
-               LCDTmp->hide();
-               ((eNumber*)LCDTmp)->setFlags(flags);
-               eSize s = parent->LCDElement->getSize();
-
-               if (descr)
-               {
-                       LCDTmp->move(ePoint(0,s.height()/2));
-                       LCDTmp->resize(eSize(s.width(), s.height()/2));
-                       tmpDescr = new eLabel(parent->LCDElement);
-                       tmpDescr->hide();
-                       tmpDescr->move(ePoint(0,0));
-                       tmpDescr->resize(eSize(s.width(), s.height()/2));
-                       tmpDescr->setText(descr->getText());
-                       tmpDescr->show();
-               }
-               else
-               {
-                       LCDTmp->resize(s);
-                       LCDTmp->move(ePoint(0,0));
-               }
-               ((eNumber*)LCDTmp)->digit=digit;
-               ((eNumber*)LCDTmp)->active=active;
-               ((eNumber*)LCDTmp)->normalF=255;
-               ((eNumber*)LCDTmp)->normalB=0;
-               ((eNumber*)LCDTmp)->cursorF=0;
-               ((eNumber*)LCDTmp)->cursorB=255;
-               ((eNumber*)LCDTmp)->have_focus=1;
-               LCDTmp->show();
-       }
-       #endif //DISABLE_LCD
-}
-
-void eNumber::lostFocus()
-{
-#ifndef DISABLE_LCD
-       if (LCDTmp)
-       {
-               delete LCDTmp;
-               LCDTmp=0;
-               if (tmpDescr)
-               {
-                       delete tmpDescr;
-                       tmpDescr=0;
-               }
-       }
-#endif
-       have_focus--;
-
-       if (deco && deco_selected)
-               invalidate();
-       else
-               invalidate(getNumberRect(active));
-       isactive=0;
-}
-
-void eNumber::setNumber(int f, int n)
-{
-       if (flags & flagPosNeg)
-       {
-               if(!f && n<0)
-                       neg=true;
-               else
-                       neg=false;
-       }
-       else
-               neg=false;
-
-       if ((f>=0) && (f<len))
-               number[f]=abs(n);
-
-       invalidate(getNumberRect(f));
-}
-
-void eNumber::setLimits(int _min, int _max)
-{
-       min=_min;
-       max=_max;
-       oldmax=max;
-}
-
-void eNumber::setNumberOfFields(int n)
-{
-       len=n;
-}
-
-void eNumber::setMaximumDigits(int n)
-{
-       if (n > 16)
-               n=16;
-       maxdigits=n;
-       if (digit >= maxdigits)
-               digit=0;
-}
-
-void eNumber::setFlags(int _flags)
-{
-  if (flags&flagFixedNum)
-               len=2;
-               
-       flags=_flags;
-}
-
-void eNumber::setBase(int _base)
-{
-       base=_base;
-}
-
-void eNumber::setNumber(int n)
-{
-       if ( flags&flagPosNeg )
-               neg = n < 0;
-       else
-               neg=0;
-
-       if( len == 1 )
-               number[0]=abs(n);
-       else
-               for (int i=len-1; i>=0; --i)
-               {
-                       number[i]=n%base;
-                       n/=base;
-               }
-       invalidateNum();
-}
-
-int eNumber::getNumber()
-{
-       int n=0;
-       for (int i=0; i<len; i++)
-       {
-               n*=base;
-               n+=number[i];
-       }
-       return flags&flagPosNeg && neg ? -n : n;
-}
index 612a80ee304db007418e4c0a470269e7bd80a4b1..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,757 +0,0 @@
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-
-#include <lib/gui/eskin.h>
-#include <lib/gui/ewidget.h>
-#include <lib/gdi/gfbdc.h>
-#include <lib/gdi/glcddc.h>
-#include <lib/gdi/epng.h>
-#include <lib/base/eerror.h>
-#include <lib/gdi/font.h>
-#include <lib/base/eptrlist.h>
-
-std::map< eString,tWidgetCreator > eSkin::widget_creator;
-
-eSkin *eSkin::active;
-
-eNamedColor *eSkin::searchColor(const eString &name)
-{
-       for (std::list<eNamedColor>::iterator i(colors.begin()); i != colors.end(); ++i)
-       {
-               if (!i->name.compare(name))
-                       return &*i;
-       }
-       return 0;
-}
-
-void eSkin::clear()
-{
-}
-
-void eSkin::addWidgetCreator(const eString &name, tWidgetCreator creator)
-{
-       widget_creator[name] = creator; // add this tWidgetCreator to map... if exist.. overwrite
-}
-
-void eSkin::removeWidgetCreator(const eString &name, tWidgetCreator creator)
-{
-       widget_creator.erase(name);
-}
-
-int eSkin::parseColor(const eString &name, const char* color, gRGB &col)
-{
-       if (color[0]=='#')
-       {
-               unsigned long vcol=0;
-               if (sscanf(color+1, "%lx", &vcol)!=1)
-               {
-                       eDebug("invalid color named \"%s\" (value: %s)", name.c_str(), color+1);
-                       return -1;
-               }
-               col.r=(vcol>>16)&0xFF;
-               col.g=(vcol>>8)&0xFF;
-               col.b=vcol&0xFF;
-               col.a=(vcol>>24)&0xFF;
-       } else
-       {
-               eNamedColor *n=searchColor(color);
-               if (!n)
-               {
-                       eDebug("invalid color named \"%s\" (alias to: \"%s\")", name.c_str(), color);
-                       return -1;
-               }
-               col=n->value;
-       }
-       return 0;
-}
-
-int eSkin::parseColors(XMLTreeNode *xcolors)
-{
-       XMLTreeNode *node;
-       
-       std::list<eNamedColor>::iterator newcolors=colors.end();
-       
-       for (node=xcolors->GetChild(); node; node=node->GetNext())
-       {
-               if (strcmp(node->GetType(), "color"))
-               {
-                       eDebug("junk found in colorsection (%s)", node->GetType());
-                       continue;
-               }
-               
-               const char *name=node->GetAttributeValue("name"), *color=node->GetAttributeValue("color"), *end=node->GetAttributeValue("end");
-
-               if (!color || !name)
-               {
-                       eDebug("no color/name specified");
-                       continue;
-               }
-
-               eNamedColor col;
-               col.name=name;
-
-               const char *size=node->GetAttributeValue("size");
-
-               if (size)
-                       col.size=atoi(size);
-               else
-                       col.size=0;
-               
-               if (!col.size)
-                       col.size=1;
-               
-               if ((col.size>1) && (!end))
-               {
-                       eDebug("no end specified in \"%s\" but is gradient", name);
-                       continue;
-               }
-
-               if (parseColor(name, color, col.value))
-                       continue;
-
-               if (end && parseColor(name, end, col.end))
-                       continue;
-
-               colors.push_back(col);
-               if (newcolors == colors.end())
-                       --newcolors;
-       }
-       
-       for (std::list<eNamedColor>::iterator i(newcolors); i != colors.end(); ++i)
-       {
-               eNamedColor &col=*i;
-               int d;
-               for (d=0; d<maxcolors; d+=col.size)
-               {
-                       int s;
-                       for (s=0; s<col.size; s++)
-                               if ((d+s>maxcolors) || colorused[d+s])
-                                       break;
-                       if (s==col.size)
-                               break;
-               }
-               if (d==maxcolors)
-                       continue;
-               col.index=gColor(d);
-               for (int s=0; s<col.size; s++, d++)
-               {
-                       colorused[d]=1;
-                       if (s)
-                       {
-                               int rdiff=-col.value.r+col.end.r;
-                               int gdiff=-col.value.g+col.end.g;
-                               int bdiff=-col.value.b+col.end.b;
-                               int adiff=-col.value.a+col.end.a;
-                               rdiff*=s; rdiff/=(col.size-1);
-                               gdiff*=s; gdiff/=(col.size-1);
-                               bdiff*=s; bdiff/=(col.size-1);
-                               adiff*=s; adiff/=(col.size-1);
-                               palette[d].r=col.value.r+rdiff;
-                               palette[d].g=col.value.g+gdiff;
-                               palette[d].b=col.value.b+bdiff;
-                               palette[d].a=col.value.a+adiff;
-                       } else
-                               palette[d]=col.value;
-               }
-       }
-       return 0;
-}
-
-int eSkin::parseScheme(XMLTreeNode *xscheme)
-{
-       XMLTreeNode *node;
-       for (node=xscheme->GetChild(); node; node=node->GetNext())
-       {
-               if (strcmp(node->GetType(), "map"))
-               {
-                       eDebug("illegal scheme entry found: %s", node->GetType());
-                       continue;
-               }
-               char *name=node->GetAttributeValue("name"), *color=node->GetAttributeValue("color");
-               if (!name || !color)
-               {
-                       eDebug("no name or color specified in colorscheme");
-                       continue;
-               }
-               eString base=color;
-               int offset=0, p;
-               if ((p=base.find('+'))!=-1)
-               {
-                       offset=atoi(base.mid(p).c_str());
-                       base=base.left(p);
-               }
-               eNamedColor *n=searchColor(base);
-               if (!n)
-               {
-                       eDebug("illegal color \"%s\" specified", base.c_str());
-                       continue;
-               }
-               scheme[name] = gColor(n->index+offset);
-       }
-       return 0;
-}
-
-int eSkin::parseFontAlias(XMLTreeNode *xscheme)
-{
-       XMLTreeNode *node;
-       for (node=xscheme->GetChild(); node; node=node->GetNext())
-       {
-               if (strcmp(node->GetType(), "map"))
-               {
-                       eDebug("illegal fontalias entry found: %s", node->GetType());
-                       continue;
-               }
-               char *font=node->GetAttributeValue("font"),
-                                *name=node->GetAttributeValue("name"),
-                                *size=node->GetAttributeValue("size");
-
-               if (!name || !font || !size)
-               {
-                       eDebug("no name, alias or size spezified in fontaliase");
-                       continue;
-               }
-
-               std::map<eString, gFont>::iterator it = fontAlias.find(name);
-               if (it != fontAlias.end())
-                       continue;
-
-               std::map<eString, eString>::iterator i = fonts.find(font);
-               if (i == fonts.end())
-               {
-                       eDebug("font %s not found, skip make alias %s", font, name);
-                       continue;
-               }
-               fontAlias[name]=gFont(i->second, atoi(size));
-       }
-       return 0;
-}
-
-int eSkin::parseImages(XMLTreeNode *inode)
-{
-       char *abasepath=inode->GetAttributeValue("basepath");
-       if (!abasepath)
-               abasepath="";
-       eString basepath=eString("/enigma/pictures/");
-       if (abasepath[0] == '/') // allow absolute paths
-               basepath="";
-       basepath+=abasepath;
-       if (basepath[basepath.length()-1]!='/')
-               basepath+="/";
-
-       for (XMLTreeNode *node=inode->GetChild(); node; node=node->GetNext())
-       {
-               if (strcmp(node->GetType(), "img"))
-               {
-                       eDebug("illegal image entry found: %s", node->GetType());
-                       continue;
-               }
-               const char *name=node->GetAttributeValue("name");
-               if (!name)
-               {
-                       eDebug("illegal <img> entry: no name");
-                       continue;
-               }
-               const char *src=node->GetAttributeValue("src");
-               if (!src)
-               {
-                       eDebug("image/img=\"%s\" no src given", name);
-                       continue;
-               }
-               std::map<eString, ePtr<gPixmap> >::iterator it = images.find(name);
-               if (it != images.end())
-               {
-//                     eDebug("Image with name %s already loaded, skip %s", name, src);
-                       continue;
-               }
-               ePtr<gPixmap> image=0;
-               eString filename=basepath + eString(src);
-               if (abasepath[0] != '/')
-               {
-                       // search first in CONFIGDIR
-                       image=loadPNG((eString(CONFIGDIR)+filename).c_str());
-                       if (!image)
-                               image=loadPNG((eString(DATADIR)+filename).c_str());
-               }
-               else // abs path
-                       image=loadPNG(filename.c_str());
-
-               if (!image)
-               {
-                       eDebug("image/img=\"%s\" - %s: file not found", name, filename.c_str());
-                       continue;
-               }
-
-               if (paldummy && !node->GetAttributeValue("nomerge"))
-               {
-                       gPixmapDC mydc(image);
-                       gPainter p(mydc);
-                       p.mergePalette(paldummy);
-               }
-               images[name] = image;
-       }
-       return 0;
-}
-
-int eSkin::parseImageAlias(XMLTreeNode *xvalues)
-{
-       for (XMLTreeNode *node=xvalues->GetChild(); node; node=node->GetNext())
-       {
-               if (strcmp(node->GetType(), "map"))
-               {
-                       eDebug("illegal values entry %s", node->GetType());
-                       continue;
-               }
-               const char *name=node->GetAttributeValue("name"),
-                                                        *img=node->GetAttributeValue("img");
-               if (!name || !img)
-               {
-                       eDebug("map entry has no name or img");
-                       continue;
-               }
-               std::map<eString, eString>::iterator it = imageAlias.find(name);
-               if (it != imageAlias.end())
-               {
-                       eDebug("imagealias %s does exist, skip make alias for image %s", name, img);
-                       continue;
-               }
-               std::map<eString, ePtr<gPixmap> >::iterator i = images.find(img);
-               if (i == images.end())
-               {
-                       eDebug("image %s not found, skip make alias %s", img , name);
-                       continue;
-               }
-               imageAlias[name]=img;
-       }
-       return 0;
-}
-
-int eSkin::parseFonts(XMLTreeNode *xfonts)
-{
-       const char *abasepath=xfonts->GetAttributeValue("basepath");
-       eString basepath=abasepath?abasepath:FONTDIR;
-
-       if (basepath.length())
-               if (basepath[basepath.length()-1]!='/')
-                       basepath+="/";
-
-       for (XMLTreeNode *node=xfonts->GetChild(); node; node=node->GetNext())
-       {
-               if (strcmp(node->GetType(), "font"))
-               {
-                       eDebug("illegal fonts entry %s", node->GetType());
-                       continue;
-               }
-               const char *file=node->GetAttributeValue("file");
-               if (!file)
-               {
-                       eDebug("fonts entry has no file");
-                       continue;
-               }
-               const char *name=node->GetAttributeValue("name");
-               if (!name)
-               {
-                       eDebug("fonts entry has no name use filename %s as name", file);
-                       name = file;
-               }
-               std::map<eString, eString>::iterator it = fonts.find(name);
-               const char *ascale=node->GetAttributeValue("scale");
-               int scale=0;
-               if (ascale)
-                       scale=atoi(ascale);
-               if (!scale)
-                       scale=100;
-               if (it != fonts.end())
-               {
-                       eDebug("Font with name %s already loaded, skip %s", name, file);
-                       continue;
-               }
-               fonts[name]=fontRenderClass::getInstance()->AddFont(basepath+eString(file), name, scale);
-               if (node->GetAttributeValue("replacement"))
-                       eTextPara::setReplacementFont(name);
-       }
-       return 0;
-}
-
-int eSkin::parseValues(XMLTreeNode *xvalues)
-{
-       for (XMLTreeNode *node=xvalues->GetChild(); node; node=node->GetNext())
-       {
-               if (strcmp(node->GetType(), "value"))
-               {
-                       eDebug("illegal values entry %s", node->GetType());
-                       continue;
-               }
-               const char *name=node->GetAttributeValue("name");
-               if (!name)
-               {
-                       eDebug("values entry has no name");
-                       continue;
-               }
-               const char *value=node->GetAttributeValue("value");
-               if (!value)
-               {
-                       eDebug("values entry has no value");
-                       continue;
-               }
-               std::map<eString, int>::iterator it = values.find(name);
-               if (it != values.end())
-               {
-                       eDebug("value %s does exist, skip make value %s=%i", name, value);
-                       continue;
-               }
-               values[name]=atoi(value);
-       }
-       return 0;
-}
-
-gDC *eSkin::getDCbyName(const char *name)
-{
-       gPixmapDC *dc=0;
-       if (!strcmp(name, "fb"))
-               dc=gFBDC::getInstance();
-#ifndef DISABLE_LCD
-       else if (!strcmp(name, "lcd"))
-               dc=gLCDDC::getInstance();
-#endif
-       return dc;
-}
-
-int eSkin::build(eWidget *widget, XMLTreeNode *node)
-{
-//      eDebug("building a %s", node->GetType());
-/*      if (widget->getType() != node->GetType())
-                       return -1;*/
-       
-       for (XMLAttribute *attrib=node->GetAttributes(); attrib; attrib=attrib->GetNext())
-       {
-//             eDebug("setting %s := %s", attrib->GetName(), attrib->GetValue());
-               if (widget->setProperty(attrib->GetName(), attrib->GetValue()))
-               {
-                       eDebug("failed");
-                       return -1;
-               }
-       }
-       for (XMLTreeNode *c=node->GetChild(); c; c=c->GetNext())
-       {
-               eWidget *w=0;
-
-               const char *name=c->GetAttributeValue("name");
-
-               if (name)
-                       w=widget->search(name);
-
-               if (!w)
-               {
-                       std::map< eString, tWidgetCreator >::iterator it = widget_creator.find(c->GetType());
-
-                       if ( it == widget_creator.end() )
-                       {
-                               eWarning("widget class %s does not exist", c->GetType());
-                               return -ENOENT;
-                       }
-                       w = (it->second)(widget);
-               }
-               if (!w)
-               {
-                       // eDebug("failed.");
-                       return -EINVAL;
-               }
-               w->zOrderRaise();
-               int err;
-               if ((err=build(w, c)))
-               {
-                       return err;
-               }
-       }
-       return 0;
-}
-
-eSkin::eSkin()
-{
-       maxcolors=256;
-
-       palette=new gRGB[maxcolors];
-       
-       memset(palette, 0, sizeof(gRGB)*maxcolors);
-       paldummy=new gImage(eSize(1, 1), 8);
-       paldummy->clut.data=palette;
-       paldummy->clut.colors=maxcolors;
-
-       colorused=new int[maxcolors];
-       memset(colorused, 0, maxcolors*sizeof(int));
-}
-
-eSkin::~eSkin()
-{
-       if (active==this)
-               active=0;
-
-       clear();
-
-       delete colorused;
-
-       for (std::map<eString, ePtr<gPixmap> >::iterator it(images.begin()); it != images.end(); it++)
-               delete it->second;      
-}
-
-int eSkin::load(const char *filename)
-{
-       eDebug("loading skin: %s", filename);
-       FILE *in=fopen(filename, "rt");
-       if (!in)
-               return -1;
-
-       parsers.push_front(new XMLTreeParser("ISO-8859-1"));
-       XMLTreeParser &parser=*parsers.first();
-       char buf[2048];
-
-       int done;
-       do
-       {
-               unsigned int len=fread(buf, 1, sizeof(buf), in);
-               done=len<sizeof(buf);
-               if (!parser.Parse(buf, len, done))
-               {
-                       eDebug("parse error: %s at line %d",
-                               parser.ErrorString(parser.GetErrorCode()),
-                               parser.GetCurrentLineNumber());
-                       parsers.pop_front();
-                       fclose(in);
-                       return -1;
-               }
-       } while (!done);
-       fclose(in);
-
-       XMLTreeNode *root=parser.RootNode();
-       if (!root)
-               return -1;
-       if (strcmp(root->GetType(), "eskin"))
-       {
-               eDebug("not an eskin");
-               return -1;
-       }
-       
-       return 0;
-}
-
-void eSkin::parseSkins()
-{
-       for (ePtrList<XMLTreeParser>::reverse_iterator it(parsers); it != parsers.rend(); it++)
-       {
-               XMLTreeNode *node=it->RootNode();
-       
-               for (node=node->GetChild(); node; node=node->GetNext())
-                       if (!strcmp(node->GetType(), "colors"))
-                               parseColors(node);
-        }
-
-       for (ePtrList<XMLTreeParser>::reverse_iterator it(parsers); it != parsers.rend(); it++)
-       {
-               XMLTreeNode *node=it->RootNode();
-       
-               for (node=node->GetChild(); node; node=node->GetNext())
-                       if (!strcmp(node->GetType(), "colorscheme"))
-                               parseScheme(node);
-        }
-
-       for (ePtrList<XMLTreeParser>::iterator it(parsers); it != parsers.end(); it++)
-       {
-               XMLTreeNode *node=it->RootNode();
-       
-               for (node=node->GetChild(); node; node=node->GetNext())
-                       if (!strcmp(node->GetType(), "fonts"))
-                               parseFonts(node);
-        }
-
-       for (ePtrList<XMLTreeParser>::iterator it(parsers); it != parsers.end(); it++)
-       {
-               XMLTreeNode *node=it->RootNode();
-       
-               for (node=node->GetChild(); node; node=node->GetNext())
-                       if (!strcmp(node->GetType(), "fontalias"))
-                               parseFontAlias(node);
-        }
-
-       for (ePtrList<XMLTreeParser>::iterator it(parsers); it != parsers.end(); it++)
-       {
-               XMLTreeNode *node=it->RootNode();
-       
-               for (node=node->GetChild(); node; node=node->GetNext())
-                       if (!strcmp(node->GetType(), "images"))
-                               parseImages(node);
-
-        }
-
-       for (ePtrList<XMLTreeParser>::iterator it(parsers); it != parsers.end(); it++)
-       {
-               XMLTreeNode *node=it->RootNode();
-       
-               for (node=node->GetChild(); node; node=node->GetNext())
-                       if (!strcmp(node->GetType(), "imagealias"))
-                               parseImageAlias(node);
-
-        }
-
-       for (ePtrList<XMLTreeParser>::iterator it(parsers); it != parsers.end(); it++)
-       {
-               XMLTreeNode *node=it->RootNode();
-       
-               for (node=node->GetChild(); node; node=node->GetNext())
-                       if (!strcmp(node->GetType(), "values"))
-                               parseValues(node);
-       }
-}
-
-
-int eSkin::build(eWidget *widget, const char *name)
-{
-       for (parserList::iterator i(parsers.begin()); i!=parsers.end(); ++i)
-       {
-               XMLTreeNode *node=i->RootNode();
-                       node=node->GetChild();
-               while (node)
-               {
-                       if (!strcmp(node->GetType(), "object"))
-                       {
-                               const char *oname=node->GetAttributeValue("name");
-                               if (!std::strcmp(name, oname))
-                               {
-                                       node=node->GetChild();
-                                       return build(widget, node);
-                               }
-                       }
-                       node=node->GetNext();
-               }
-       }
-       eDebug("didn't found it");
-       return -ENOENT;
-}
-
-void eSkin::setPalette(gPixmapDC *pal)
-{
-       if (palette)
-       {
-               gPainter p(*pal);
-               p.setPalette(palette, 0, 256);
-       }
-}
-
-eSkin *eSkin::getActive()
-{
-       if (!active)
-               eFatal("no active skin");
-       return active;
-}
-
-void eSkin::makeActive()
-{
-       active=this;
-}
-
-gColor eSkin::queryScheme(const eString& name) const
-{
-       eString base=name;
-       int offset=0, p;
-       if ((p=base.find('+'))!=-1)
-       {
-               offset=atoi(base.mid(p).c_str());
-               base=base.left(p);
-       }
-
-       std::map<eString, gColor>::const_iterator it = scheme.find(base);
-
-       if (it != scheme.end())
-               return it->second + offset;
-
-//     eWarning("%s does not exist", name.c_str());
-       
-       return gColor(0);
-}
-
-RESULT eSkin::queryImage(ePtr<gPixmap> &ptr, const eString& name) const
-{
-       eString img;
-
-       std::map<eString, eString>::const_iterator i = imageAlias.find(name);
-               
-       if (i != imageAlias.end())
-               img = i->second;
-       else
-               img = name;
-
-       std::map<eString, ePtr<gPixmap> >::const_iterator it = images.find(img);
-
-       if (it != images.end())
-               ptr = it->second;
-       
-       return 0;
-}
-
-int eSkin::queryValue(const eString& name, int d) const
-{
-       std::map<eString, int>::const_iterator it = values.find(name);
-
-       if (it != values.end())
-               return it->second;
-       
-       return d;
-}
-
-gColor eSkin::queryColor(const eString& name)
-{
-       char *end;
-
-       int numcol=strtol(name.c_str(), &end, 10);
-
-       if (!*end)
-               return gColor(numcol);
-
-       eString base=name;
-       int offset=0, p;
-       if ((p=base.find('+'))!=-1)
-       {
-               offset=atoi(base.mid(p).c_str());
-               base=base.left(p);
-       }
-
-       eNamedColor *col=searchColor(base);
-
-       if (!col)
-       {
-               return queryScheme(name);
-       } else
-               return col->index + offset;
-}
-
-gFont eSkin::queryFont(const eString& name)
-{
-       std::map<eString, gFont>::iterator it = fontAlias.find(name);  // check if name is a font alias
-       
-       if ( it != fontAlias.end() )            // font alias found
-               return it->second;
-
-       eString family;
-       int size=0;
-
-       unsigned int sem = name.rfind(';');             // check if exist ';' in name
-       if (sem != eString::npos)                                               // then exist
-       {
-               family=name.left(sem);          
-               size = atoi( name.mid(sem+1).c_str() );
-               if (size<=0)
-                       size=16;
-       }
-       
-       std::map<eString, eString>::iterator i = fonts.find(family);   // check if family is a font name
-       if ( i != fonts.end() ) // font exist
-               return gFont(i->second, size);
-
-       for (i = fonts.begin() ; i != fonts.end(); i++)                         // as last check if family name is a complete font Face
-               if ( i->second == family)
-                       return gFont(i->second, size);
-
-       eFatal("Font %s does not exist", name.c_str() );                        //  halt Programm now... Font does not exist
-
-       return gFont();
-}
index 7d701adcb50639adf82e4f6d542aa3fea6665c3a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,87 +0,0 @@
-#ifndef __eskin_h
-#define __eskin_h
-
-#include <list>
-#include <map>
-#include <xmltree.h>
-
-#include <lib/base/estring.h>
-#include <lib/base/eptrlist.h>
-#include <lib/gdi/grc.h>
-
-class eWidget;
-class gPixmap;
-typedef eWidget *(*tWidgetCreator)(eWidget *parent);
-
-struct eNamedColor
-{
-       eString name;
-       gRGB value, end;
-       int index;
-       int size;
-};
-
-class eSkin
-{
-       typedef ePtrList<XMLTreeParser> parserList;
-       parserList parsers;
-       void clear();
-       
-       int parseColor(const eString& name, const char *color, gRGB &col);
-       int parseColors(XMLTreeNode *colors);
-       int parseScheme(XMLTreeNode *scheme);
-       int parseImages(XMLTreeNode *images);
-       int parseImageAlias(XMLTreeNode *images);
-       int parseValues(XMLTreeNode *values);
-       int parseFonts(XMLTreeNode *fonts);
-       int parseFontAlias(XMLTreeNode *fonts);
-       
-       gDC *getDCbyName(const char *name);
-       
-       gRGB *palette;
-       int maxcolors;
-       ePtr<gPixmap> paldummy;
-       int *colorused;
-       
-       static std::map< eString, tWidgetCreator > widget_creator;
-       int build(eWidget *widget, XMLTreeNode *rootwidget);
-       
-       std::list<eNamedColor> colors;
-       std::map<eString, gColor> scheme;
-       std::map<eString, ePtr<gPixmap> > images;
-       std::map<eString, int> values;
-       std::map<eString, eString> fonts;
-       std::map<eString, gFont> fontAlias;
-       std::map<eString, eString> imageAlias;
-
-       eNamedColor *searchColor(const eString &name);
-
-       static eSkin *active;
-public:
-       eSkin();
-       ~eSkin();
-
-       static void addWidgetCreator(const eString &name, tWidgetCreator creator);
-       static void removeWidgetCreator(const eString &name, tWidgetCreator creator);
-
-       int load(const char *filename);
-       void parseSkins();
-       
-       int build(eWidget *widget, const char *name);
-       void setPalette(gPixmap *pal);
-
-       gColor queryColor(const eString &name);
-       gColor queryScheme(const eString &name) const;
-       RESULT queryImage(ePtr<gPixmap> &pixmap, const eString &name) const;
-       int queryValue(const eString &name, int d) const;
-       gFont queryFont(const eString &name);
-       
-       void makeActive();
-       
-       static eSkin *getActive();
-};
-
-#define ASSIGN(v, t, n) \
-  v =(t*)search(n); if (! v ) { eWarning("skin has undefined element: %s", n); v=new t(this); }
-
-#endif
index c9dcb5022ec6eaa611fb6f1fee961d6f9f5ca17e..51a02368da2ff30b044feccc3db7569266cd2674 100644 (file)
@@ -109,7 +109,7 @@ RESULT eNavigation::pause(int dop)
                return p->unpause();
 }
 
                return p->unpause();
 }
 
-eNavigation::eNavigation(iServiceHandler *serviceHandler): ref(0)
+eNavigation::eNavigation(iServiceHandler *serviceHandler)
 {
        assert(serviceHandler);
        m_servicehandler = serviceHandler;
 {
        assert(serviceHandler);
        m_servicehandler = serviceHandler;
index 7a96bcda16dafa906778e7560cb5a02ee29be9cb..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,11 +0,0 @@
-#include <lib/nav/playlist.h>
-
-DEFINE_REF(ePlaylist);
-
-ePlaylist::ePlaylist(): ref(0)
-{
-}
-
-ePlaylist::~ePlaylist()
-{
-}
index 6141516ff4ddf3dff15cd5a6e5e84ee76d23d6e6..8abf883fd7f59ec37c0ea15de87b19e96cdd0291 100644 (file)
@@ -32,7 +32,7 @@ eString eServiceReference::toString() const
 
 eServiceCenter *eServiceCenter::instance;
 
 
 eServiceCenter *eServiceCenter::instance;
 
-eServiceCenter::eServiceCenter(): ref(0)
+eServiceCenter::eServiceCenter()
 {
        if (!instance)
        {
 {
        if (!instance)
        {
index 199b58aac962763fa77cc1930bf86fca3e4462a8..cbf9a706e7ebae94922b43785a6550c45dd7c99c 100644 (file)
@@ -8,7 +8,7 @@
 
 DEFINE_REF(eServiceFactoryDVB)
 
 
 DEFINE_REF(eServiceFactoryDVB)
 
-eServiceFactoryDVB::eServiceFactoryDVB(): ref(0)
+eServiceFactoryDVB::eServiceFactoryDVB()
 {
        ePtr<eServiceCenter> sc;
        
 {
        ePtr<eServiceCenter> sc;
        
@@ -46,7 +46,7 @@ RESULT eServiceFactoryDVB::list(const eServiceReference &, ePtr<iListableService
 }
 
 eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref): 
 }
 
 eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref): 
-       ref(0), m_reference(ref)
+       m_reference(ref)
 {
        CONNECT(m_serviceHandler.serviceEvent, eDVBServicePlay::serviceEvent);
        eDebug("DVB start (play)");
 {
        CONNECT(m_serviceHandler.serviceEvent, eDVBServicePlay::serviceEvent);
        eDebug("DVB start (play)");
index 91ae44e3842081b8f8c122f111e7a037e6ecdbe2..4bdc11a970533d39bc9d3c58287bff1ad86863b3 100644 (file)
@@ -13,7 +13,7 @@
 
 // eServiceFactoryFS
 
 
 // eServiceFactoryFS
 
-eServiceFactoryFS::eServiceFactoryFS(): ref(0)
+eServiceFactoryFS::eServiceFactoryFS()
 {
        ePtr<eServiceCenter> sc;
        
 {
        ePtr<eServiceCenter> sc;
        
@@ -56,7 +56,7 @@ RESULT eServiceFactoryFS::list(const eServiceReference &ref, ePtr<iListableServi
 
 DEFINE_REF(eServiceFS);
 
 
 DEFINE_REF(eServiceFS);
 
-eServiceFS::eServiceFS(const char *path): ref(0), path(path)
+eServiceFS::eServiceFS(const char *path): path(path)
 {
 }
 
 {
 }
 
index a6d19287a04c4a6065a80d06f4964786468ca271..0ff36db030f551b2a2d5c37288f31372e8b4af50 100644 (file)
@@ -9,7 +9,7 @@
 
 // eServiceFactoryMP3
 
 
 // eServiceFactoryMP3
 
-eServiceFactoryMP3::eServiceFactoryMP3(): ref(0)
+eServiceFactoryMP3::eServiceFactoryMP3()
 {
        ePtr<eServiceCenter> sc;
        
 {
        ePtr<eServiceCenter> sc;
        
@@ -58,7 +58,7 @@ void eServiceMP3::test_end()
        stop();
 }
 
        stop();
 }
 
-eServiceMP3::eServiceMP3(const char *filename): ref(0), filename(filename), test(eApp)
+eServiceMP3::eServiceMP3(const char *filename): filename(filename), test(eApp)
 {
        m_state = stIdle;
        eDebug("SERVICEMP3 construct!");
 {
        m_state = stIdle;
        eDebug("SERVICEMP3 construct!");