From: Felix Domke Date: Wed, 2 Jun 2004 01:11:59 +0000 (+0000) Subject: - disabled gui for a moment X-Git-Tag: 2.6.0~5958 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/3bad22d5566624804a73b3791980bab2d84c8266?hp=d6f6602d7cea3a7899990fe79216af7d98d05917 - disabled gui for a moment - beginning of GDI2 work (region/fill/line works) - fixed smartptr self assignment - finally replaced "int ref" by something with a constructor --- diff --git a/include/connection.h b/include/connection.h index 8ca75cb9..a085650d 100644 --- a/include/connection.h +++ b/include/connection.h @@ -11,7 +11,7 @@ class eConnection: public virtual iObject, public Connection 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(); } }; diff --git a/lib/Makefile.am b/lib/Makefile.am index c4197e31..4243911c 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -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 diff --git a/lib/base/eerror.cpp b/lib/base/eerror.cpp index 0871bb71..ac62f1e9 100644 --- a/lib/base/eerror.cpp +++ b/lib/base/eerror.cpp @@ -20,6 +20,7 @@ void eFatal(const char* fmt, ...) va_end(ap); logOutput(lvlFatal, buf); fprintf(stderr, "%s\n",buf ); +#if 0 if (!infatal) { infatal=1; @@ -27,6 +28,8 @@ void eFatal(const char* fmt, ...) msg.show(); msg.exec(); } +#endif + _exit(0); } diff --git a/lib/base/object.h b/lib/base/object.h index 744bff19..ddb4512c 100644 --- a/lib/base/object.h +++ b/lib/base/object.h @@ -19,10 +19,18 @@ public: 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; -#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 diff --git a/lib/base/smartptr.h b/lib/base/smartptr.h index 85ad5a90..aafecf0e 100644 --- a/lib/base/smartptr.h +++ b/lib/base/smartptr.h @@ -43,21 +43,21 @@ public: } ePtr &operator=(T *c) { + if (c) + c->AddRef(); if (ptr) ptr->Release(); ptr=c; - if (ptr) - ptr->AddRef(); return *this; } ePtr &operator=(ePtr &c) { + if (c.ptr) + c.ptr->AddRef(); if (ptr) ptr->Release(); ptr=c.ptr; - if (ptr) - ptr->AddRef(); return *this; } diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp index f8233a64..5426fa4b 100644 --- a/lib/dvb/db.cpp +++ b/lib/dvb/db.cpp @@ -9,7 +9,7 @@ DEFINE_REF(eDVBService); -eDVBService::eDVBService(): ref(0) +eDVBService::eDVBService() { } diff --git a/lib/dvb/decoder.cpp b/lib/dvb/decoder.cpp index e21e4567..0b3619ad 100644 --- a/lib/dvb/decoder.cpp +++ b/lib/dvb/decoder.cpp @@ -10,7 +10,7 @@ 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); @@ -69,7 +69,7 @@ eDVBAudio::~eDVBAudio() 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); diff --git a/lib/dvb/demux.cpp b/lib/dvb/demux.cpp index be9ac937..4522706d 100644 --- a/lib/dvb/demux.cpp +++ b/lib/dvb/demux.cpp @@ -13,7 +13,7 @@ #include #include -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); } -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); diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index cfdb05af..29ffa151 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -8,7 +8,7 @@ DEFINE_REF(eDVBResourceManager); eDVBResourceManager *eDVBResourceManager::instance; -eDVBResourceManager::eDVBResourceManager(): ref(0) +eDVBResourceManager::eDVBResourceManager() { avail = 1; busy = 0; diff --git a/lib/dvb/esection.cpp b/lib/dvb/esection.cpp index 08cb49be..42a056d2 100644 --- a/lib/dvb/esection.cpp +++ b/lib/dvb/esection.cpp @@ -30,7 +30,7 @@ void eGTable::timeout() } eGTable::eGTable(): - ref(0), m_timeout(0), error(0) + m_timeout(0), error(0) { } diff --git a/lib/dvb/frontend.cpp b/lib/dvb/frontend.cpp index 8948f194..5b1aaa2a 100644 --- a/lib/dvb/frontend.cpp +++ b/lib/dvb/frontend.cpp @@ -73,7 +73,7 @@ void eDVBFrontendParametersTerrestrial::set(const TerrestrialDeliverySystemDescr 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); -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; diff --git a/lib/dvb/sec.cpp b/lib/dvb/sec.cpp index e8c6b479..c033266a 100644 --- a/lib/dvb/sec.cpp +++ b/lib/dvb/sec.cpp @@ -4,7 +4,7 @@ DEFINE_REF(eDVBSatelliteEquipmentControl); -eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(): ref(0) +eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl() { } diff --git a/lib/gdi/Makefile.am b/lib/gdi/Makefile.am index 49459b61..419163c7 100644 --- a/lib/gdi/Makefile.am +++ b/lib/gdi/Makefile.am @@ -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 \ - glcddc.cpp gpixmap.cpp grc.cpp lcd.cpp + glcddc.cpp gpixmap.cpp lcd.cpp diff --git a/lib/gdi/erect.h b/lib/gdi/erect.h index 30db41f3..9eaa7906 100644 --- a/lib/gdi/erect.h +++ b/lib/gdi/erect.h @@ -71,6 +71,14 @@ public: 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 ); @@ -224,7 +232,7 @@ inline eSize eRect::size() 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 diff --git a/lib/gdi/fb.cpp b/lib/gdi/fb.cpp index 52d950a6..4b8a56c9 100644 --- a/lib/gdi/fb.cpp +++ b/lib/gdi/fb.cpp @@ -29,9 +29,6 @@ fbClass::fbClass(const char *fb) cmap.blue=blue; cmap.transp=trans; - int state=0; - eConfig::getInstance()->getKey("/ezap/osd/showConsoleOnFB", state); - fd=open(fb, O_RDWR); if (fd<0) { @@ -62,7 +59,7 @@ fbClass::fbClass(const char *fb) goto nolfb; } - showConsole(state); + showConsole(1); 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) { - 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; diff --git a/lib/gdi/font.cpp b/lib/gdi/font.cpp index a0b6d2e7..2f2823bb 100644 --- a/lib/gdi/font.cpp +++ b/lib/gdi/font.cpp @@ -239,7 +239,7 @@ int fontRenderClass::getFont(ePtr &font, const eString &face, int size, in 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; @@ -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; - ref=0; // 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; diff --git a/lib/gdi/gfbdc.cpp b/lib/gdi/gfbdc.cpp index 3247aa6a..d5ce9f3c 100644 --- a/lib/gdi/gfbdc.cpp +++ b/lib/gdi/gfbdc.cpp @@ -113,11 +113,6 @@ void gFBDC::exec(gOpcode *o) } } -gFBDC *gFBDC::getInstance() -{ - return instance; -} - void gFBDC::setAlpha(int a) { alpha=a; @@ -162,4 +157,4 @@ void gFBDC::reloadSettings() setPalette(); } -eAutoInitP0 init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC"); +eAutoInitPtr init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC"); diff --git a/lib/gdi/gfbdc.h b/lib/gdi/gfbdc.h index 0b0372d3..dd03032e 100644 --- a/lib/gdi/gfbdc.h +++ b/lib/gdi/gfbdc.h @@ -28,8 +28,8 @@ public: void saveSettings(); gFBDC(); - ~gFBDC(); - static gFBDC *getInstance(); + virtual ~gFBDC(); + static int getInstance(ePtr &ptr) { if (!instance) return -1; ptr = instance; return 0; } int islocked() { return fb->islocked(); } }; diff --git a/lib/gdi/gpixmap.cpp b/lib/gdi/gpixmap.cpp index b6711fcb..1d2a4e39 100644 --- a/lib/gdi/gpixmap.cpp +++ b/lib/gdi/gpixmap.cpp @@ -1,4 +1,5 @@ #include +#include gLookup::gLookup() :size(0), lookup(0) @@ -102,121 +103,130 @@ void gPixmap::unlock() contentlock.unlock(1); } -void gPixmap::fill(const eRect &area, const gColor &color) +void gPixmap::fill(const gRegion ®ion, const gColor &color) { - if ((area.height()<=0) || (area.width()<=0)) - return; - if (surface->bpp == 8) - for (int y=area.top(); ydata)+y*surface->stride+area.left(), color.color, area.width()); - else if (surface->bpp == 32) - for (int y=area.top(); ybpp == 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(); ydata)+y*surface->stride+area.left(), color.color, area.width()); + } else if (surface->bpp == 32) + for (int y=area.top(); ydata)+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; ibpp == 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; ybpp == 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; ybypp); - 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 && (iclut.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 && (iclut.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; ybypp+srcarea.top()*src.surface->stride; + dstptr+=area.left()*surface->bypp+area.top()*surface->stride; + for (int y=0; ystride; + 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) @@ -245,26 +255,91 @@ void gPixmap::mergePalette(const gPixmap &target) 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 diff --git a/lib/gdi/gpixmap.h b/lib/gdi/gpixmap.h index 048b73a5..0d123b3f 100644 --- a/lib/gdi/gpixmap.h +++ b/lib/gdi/gpixmap.h @@ -23,16 +23,23 @@ struct gColor 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() + 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) @@ -127,6 +134,18 @@ struct gSurfaceSystem: gSurface 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; @@ -138,17 +157,6 @@ public: 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(); diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp index 55c86a0b..46181d32 100644 --- a/lib/gdi/grc.cpp +++ b/lib/gdi/grc.cpp @@ -1,5 +1,5 @@ // for debugging use: -// #define SYNC_PAINT + #define SYNC_PAINT #include #ifndef SYNC_PAINT #include @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -29,16 +28,18 @@ gRC::gRC(): queue(2048), queuelock(MAXSIZE) 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 } +DEFINE_REF(gRC); + gRC::~gRC() { - fbClass::getInstance()->lock(); -#ifndef DISABLE_LCD - eDBoxLCD::getInstance()->lock(); -#endif 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++; - begin(rect); +// begin(rect); } gPainter::~gPainter() @@ -171,7 +172,7 @@ void gPainter::clear() 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; @@ -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; - clip->AddRef(); 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.parm.setPalette = new gOpcode::para::psetPalette; p->data=new gRGB[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); } -void gPainter::setLogicalZero(ePoint val) +void gPainter::setOffset(ePoint val) { gOpcode o; o.opcode=gOpcode::setOffset; @@ -235,10 +237,10 @@ void gPainter::setLogicalZero(ePoint val) m_rc->submit(o); } -void gPainter::moveLogicalZero(ePoint rel) +void gPainter::moveOffset(ePoint rel) { 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; @@ -246,24 +248,33 @@ void gPainter::moveLogicalZero(ePoint rel) m_rc->submit(o); } -void gPainter::resetLogicalZero() +void gPainter::resetOffset() { 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); } +void gPainter::resetClip(const gRegion ®ion) +{ + 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 ®ion) { 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); } @@ -297,53 +308,74 @@ gDC::~gDC() 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: { - ePtr para = new eTextPara(o->parm.renderText.area); + ePtr para = new eTextPara(o->parm.renderText->area); 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: { - 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: - 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; - 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; - 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: -#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) - 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; -#endif break; case gOpcode::mergePalette: #if 0 @@ -353,23 +385,40 @@ void gDC::exec(gOpcode *o) #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; -#endif 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; - 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; - 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); } -#endif } gRGB gDC::getRGB(gColor col) @@ -386,4 +435,5 @@ gRGB gDC::getRGB(gColor col) DEFINE_REF(gDC); -eAutoInitP0 init_grc(eAutoInitNumbers::graphic, "gRC"); +eAutoInitPtr init_grc(eAutoInitNumbers::graphic, "gRC"); + diff --git a/lib/gdi/grc.h b/lib/gdi/grc.h index 225fd9de..47931792 100644 --- a/lib/gdi/grc.h +++ b/lib/gdi/grc.h @@ -40,9 +40,9 @@ struct gOpcode setBackgroundColor, setForegroundColor, - setOffset, moveOffset, + setOffset, - addClip, popClip, + setClip, addClip, popClip, end,shutdown } opcode; @@ -83,7 +83,7 @@ struct gOpcode gPixmap *pixmap; ePoint position; int flags; - gRegion *clip; + eRect clip; } *blit; struct pmergePalette @@ -98,7 +98,7 @@ struct gOpcode struct psetClip { - gRegion *region; + gRegion region; } *clip; struct psetColor @@ -138,7 +138,7 @@ public: 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 @@ -176,17 +176,18 @@ public: 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 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(); @@ -199,18 +200,19 @@ DECLARE_REF; protected: ePtr m_pixmap; - ePtr m_clip_region; - gColor m_foregroundColor, m_backgroundColor; + gColor m_foreground_color, m_background_color; ePtr m_current_font; ePoint m_current_offset; + + std::stack m_clip_stack; gRegion m_current_clip; public: - void exec(gOpcode *opcode); + virtual void exec(gOpcode *opcode); gDC(gPixmap *pixmap); gDC(); virtual ~gDC(); - gRegion &getClip() { return *m_clip_region; } + gRegion &getClip() { return m_current_clip; } int getPixmap(ePtr &pm) { pm = m_pixmap; return 0; } gRGB getRGB(gColor col); virtual eSize getSize() { return m_pixmap->getSize(); } diff --git a/lib/gdi/region.cpp b/lib/gdi/region.cpp index f341e79a..cbac53f8 100644 --- a/lib/gdi/region.cpp +++ b/lib/gdi/region.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #undef max #define max(a,b) ((a) > (b) ? (a) : (b)) @@ -87,7 +88,7 @@ void gRegion::appendNonO(std::vector::const_iterator r, 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); } @@ -110,7 +111,7 @@ void gRegion::intersectO( 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) @@ -145,7 +146,7 @@ void gRegion::subtractO( ++r2; } else if (r2->x1 < r1->x2) { assert(x1x1); - 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; @@ -156,7 +157,7 @@ void gRegion::subtractO( } 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; @@ -165,7 +166,7 @@ void gRegion::subtractO( while (r1 != r1End) { assert(x1x2); - 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; @@ -180,7 +181,7 @@ void gRegion::subtractO( 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; \ } \ @@ -225,7 +226,7 @@ void gRegion::mergeO( 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 ®1, const gRegion ®2, int opcode, int &overlap) @@ -318,10 +319,24 @@ void gRegion::regionOp(const gRegion ®1, const gRegion ®2, int opcode, int coalesce(prevBand, curBand); AppendRegions(r2BandEnd, r2End); } + extends = eRect(); + + for (int a=0; a #include -class gRegion: public virtual iObject +class gRegion { -DECLARE_REF; private: inline void FindBand( std::vector::const_iterator r, @@ -77,9 +76,18 @@ public: 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 moveBy(ePoint offset); }; #endif diff --git a/lib/gui/elabel.cpp b/lib/gui/elabel.cpp index ce4efaf1..e69de29b 100644 --- a/lib/gui/elabel.cpp +++ b/lib/gui/elabel.cpp @@ -1,253 +0,0 @@ -#include - -#include -#include -#include -#include -#include -#include - -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 init_eLabelSkinInit(eAutoInitNumbers::guiobject, "eLabel"); diff --git a/lib/gui/emessage.cpp b/lib/gui/emessage.cpp index 388eb14a..e69de29b 100644 --- a/lib/gui/emessage.cpp +++ b/lib/gui/emessage.cpp @@ -1,163 +0,0 @@ -#include - -#include -#include -#include -#include -#include - -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 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; iresize(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(); -} diff --git a/lib/gui/enumber.cpp b/lib/gui/enumber.cpp index c03ec8f7..e69de29b 100644 --- a/lib/gui/enumber.cpp +++ b/lib/gui/enumber.cpp @@ -1,447 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -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; ieventHandler(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 && imap); -} - -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 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 -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -std::map< eString,tWidgetCreator > eSkin::widget_creator; - -eSkin *eSkin::active; - -eNamedColor *eSkin::searchColor(const eString &name) -{ - for (std::list::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::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::iterator i(newcolors); i != colors.end(); ++i) - { - eNamedColor &col=*i; - int d; - for (d=0; dmaxcolors) || colorused[d+s]) - break; - if (s==col.size) - break; - } - if (d==maxcolors) - continue; - col.index=gColor(d); - for (int s=0; sGetChild(); 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::iterator it = fontAlias.find(name); - if (it != fontAlias.end()) - continue; - - std::map::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 entry: no name"); - continue; - } - const char *src=node->GetAttributeValue("src"); - if (!src) - { - eDebug("image/img=\"%s\" no src given", name); - continue; - } - std::map >::iterator it = images.find(name); - if (it != images.end()) - { -// eDebug("Image with name %s already loaded, skip %s", name, src); - continue; - } - ePtr 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::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 >::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::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::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 >::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=lenGetType(), "eskin")) - { - eDebug("not an eskin"); - return -1; - } - - return 0; -} - -void eSkin::parseSkins() -{ - for (ePtrList::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::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::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::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::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::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::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::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 &ptr, const eString& name) const -{ - eString img; - - std::map::const_iterator i = imageAlias.find(name); - - if (i != imageAlias.end()) - img = i->second; - else - img = name; - - std::map >::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::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::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::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(); -} diff --git a/lib/gui/eskin.h b/lib/gui/eskin.h index 7d701adc..e69de29b 100644 --- a/lib/gui/eskin.h +++ b/lib/gui/eskin.h @@ -1,87 +0,0 @@ -#ifndef __eskin_h -#define __eskin_h - -#include -#include -#include - -#include -#include -#include - -class eWidget; -class gPixmap; -typedef eWidget *(*tWidgetCreator)(eWidget *parent); - -struct eNamedColor -{ - eString name; - gRGB value, end; - int index; - int size; -}; - -class eSkin -{ - typedef ePtrList 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 paldummy; - int *colorused; - - static std::map< eString, tWidgetCreator > widget_creator; - int build(eWidget *widget, XMLTreeNode *rootwidget); - - std::list colors; - std::map scheme; - std::map > images; - std::map values; - std::map fonts; - std::map fontAlias; - std::map 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 &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 diff --git a/lib/nav/core.cpp b/lib/nav/core.cpp index c9dcb502..51a02368 100644 --- a/lib/nav/core.cpp +++ b/lib/nav/core.cpp @@ -109,7 +109,7 @@ RESULT eNavigation::pause(int dop) return p->unpause(); } -eNavigation::eNavigation(iServiceHandler *serviceHandler): ref(0) +eNavigation::eNavigation(iServiceHandler *serviceHandler) { assert(serviceHandler); m_servicehandler = serviceHandler; diff --git a/lib/nav/playlist.cpp b/lib/nav/playlist.cpp index 7a96bcda..e69de29b 100644 --- a/lib/nav/playlist.cpp +++ b/lib/nav/playlist.cpp @@ -1,11 +0,0 @@ -#include - -DEFINE_REF(ePlaylist); - -ePlaylist::ePlaylist(): ref(0) -{ -} - -ePlaylist::~ePlaylist() -{ -} diff --git a/lib/service/service.cpp b/lib/service/service.cpp index 6141516f..8abf883f 100644 --- a/lib/service/service.cpp +++ b/lib/service/service.cpp @@ -32,7 +32,7 @@ eString eServiceReference::toString() const eServiceCenter *eServiceCenter::instance; -eServiceCenter::eServiceCenter(): ref(0) +eServiceCenter::eServiceCenter() { if (!instance) { diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 199b58aa..cbf9a706 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -8,7 +8,7 @@ DEFINE_REF(eServiceFactoryDVB) -eServiceFactoryDVB::eServiceFactoryDVB(): ref(0) +eServiceFactoryDVB::eServiceFactoryDVB() { ePtr sc; @@ -46,7 +46,7 @@ RESULT eServiceFactoryDVB::list(const eServiceReference &, ePtr sc; @@ -56,7 +56,7 @@ RESULT eServiceFactoryFS::list(const eServiceReference &ref, ePtr sc; @@ -58,7 +58,7 @@ void eServiceMP3::test_end() 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!");