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(); }
};
-SUBDIRS = base dvb dvb_si gdi gui network service driver nav
+SUBDIRS = base dvb dvb_si gdi network service driver nav
+#gui
va_end(ap);
logOutput(lvlFatal, buf);
fprintf(stderr, "%s\n",buf );
+#if 0
if (!infatal)
{
infatal=1;
msg.show();
msg.exec();
}
+#endif
+
_exit(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;
-#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
}
ePtr &operator=(T *c)
{
+ if (c)
+ c->AddRef();
if (ptr)
ptr->Release();
ptr=c;
- if (ptr)
- ptr->AddRef();
return *this;
}
ePtr &operator=(ePtr<T> &c)
{
+ if (c.ptr)
+ c.ptr->AddRef();
if (ptr)
ptr->Release();
ptr=c.ptr;
- if (ptr)
- ptr->AddRef();
return *this;
}
DEFINE_REF(eDVBService);
-eDVBService::eDVBService(): ref(0)
+eDVBService::eDVBService()
{
}
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);
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);
#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)
{
}
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);
eDVBResourceManager *eDVBResourceManager::instance;
-eDVBResourceManager::eDVBResourceManager(): ref(0)
+eDVBResourceManager::eDVBResourceManager()
{
avail = 1;
busy = 0;
}
eGTable::eGTable():
- ref(0), m_timeout(0), error(0)
+ m_timeout(0), error(0)
{
}
eFatal("nyi");
}
-eDVBFrontendParameters::eDVBFrontendParameters(): ref(0), m_type(-1)
+eDVBFrontendParameters::eDVBFrontendParameters(): m_type(-1)
{
}
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;
DEFINE_REF(eDVBSatelliteEquipmentControl);
-eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl(): ref(0)
+eDVBSatelliteEquipmentControl::eDVBSatelliteEquipmentControl()
{
}
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
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 );
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
cmap.blue=blue;
cmap.transp=trans;
- int state=0;
- eConfig::getInstance()->getKey("/ezap/osd/showConsoleOnFB", state);
-
fd=open(fb, O_RDWR);
if (fd<0)
{
goto nolfb;
}
- showConsole(state);
+ showConsole(1);
return;
nolfb:
lfb=0;
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;
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;
height=isize;
if (tabwidth==-1)
tabwidth=8*isize;
- ref=0;
// font.image_type |= ftc_image_flag_autohinted;
}
{
}
+DEFINE_REF(eTextPara);
+
int eTextPara::appendGlyph(Font *current_font, FT_Face current_face, FT_UInt glyphIndex, int flags, int rflags)
{
FTC_SBit glyph;
}
}
-gFBDC *gFBDC::getInstance()
-{
- return instance;
-}
-
void gFBDC::setAlpha(int a)
{
alpha=a;
setPalette();
}
-eAutoInitP0<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "GFBDC");
+eAutoInitPtr<gFBDC> init_gFBDC(eAutoInitNumbers::graphic-1, "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(); }
};
#include <lib/gdi/gpixmap.h>
+#include <lib/gdi/region.h>
gLookup::gLookup()
:size(0), lookup(0)
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(); 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++];
}
- } 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)
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
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)
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;
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();
// for debugging use:
-// #define SYNC_PAINT
+ #define SYNC_PAINT
#include <unistd.h>
#ifndef SYNC_PAINT
#include <pthread.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>
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;
{
// ASSERT(!gPainter_instances);
gPainter_instances++;
- begin(rect);
+// begin(rect);
}
gPainter::~gPainter()
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;
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.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;
m_rc->submit(o);
}
-void gPainter::setLogicalZero(ePoint val)
+void gPainter::setOffset(ePoint val)
{
gOpcode o;
o.opcode=gOpcode::setOffset;
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;
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);
}
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<eTextPara> para = new eTextPara(o->parm.renderText.area);
+ ePtr<eTextPara> 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
#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)
DEFINE_REF(gDC);
-eAutoInitP0<gRC> init_grc(eAutoInitNumbers::graphic, "gRC");
+eAutoInitPtr<gRC> init_grc(eAutoInitNumbers::graphic, "gRC");
+
setBackgroundColor,
setForegroundColor,
- setOffset, moveOffset,
+ setOffset,
- addClip, popClip,
+ setClip, addClip, popClip,
end,shutdown
} opcode;
gPixmap *pixmap;
ePoint position;
int flags;
- gRegion *clip;
+ eRect clip;
} *blit;
struct pmergePalette
struct psetClip
{
- gRegion *region;
+ gRegion region;
} *clip;
struct psetColor
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
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();
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;
+
+ std::stack<gRegion> 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<gPixmap> &pm) { pm = m_pixmap; return 0; }
gRGB getRGB(gColor col);
virtual eSize getSize() { return m_pixmap->getSize(); }
#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))
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);
}
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)
++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;
} 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;
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;
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; \
} \
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)
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)
{
+ 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);
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);
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);
}
+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);
+}
+
#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,
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
-#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");
-#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();
-}
-#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;
-}
-#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();
-}
-#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
return p->unpause();
}
-eNavigation::eNavigation(iServiceHandler *serviceHandler): ref(0)
+eNavigation::eNavigation(iServiceHandler *serviceHandler)
{
assert(serviceHandler);
m_servicehandler = serviceHandler;
-#include <lib/nav/playlist.h>
-
-DEFINE_REF(ePlaylist);
-
-ePlaylist::ePlaylist(): ref(0)
-{
-}
-
-ePlaylist::~ePlaylist()
-{
-}
eServiceCenter *eServiceCenter::instance;
-eServiceCenter::eServiceCenter(): ref(0)
+eServiceCenter::eServiceCenter()
{
if (!instance)
{
DEFINE_REF(eServiceFactoryDVB)
-eServiceFactoryDVB::eServiceFactoryDVB(): ref(0)
+eServiceFactoryDVB::eServiceFactoryDVB()
{
ePtr<eServiceCenter> sc;
}
eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref):
- ref(0), m_reference(ref)
+ m_reference(ref)
{
CONNECT(m_serviceHandler.serviceEvent, eDVBServicePlay::serviceEvent);
eDebug("DVB start (play)");
// eServiceFactoryFS
-eServiceFactoryFS::eServiceFactoryFS(): ref(0)
+eServiceFactoryFS::eServiceFactoryFS()
{
ePtr<eServiceCenter> sc;
DEFINE_REF(eServiceFS);
-eServiceFS::eServiceFS(const char *path): ref(0), path(path)
+eServiceFS::eServiceFS(const char *path): path(path)
{
}
// eServiceFactoryMP3
-eServiceFactoryMP3::eServiceFactoryMP3(): ref(0)
+eServiceFactoryMP3::eServiceFactoryMP3()
{
ePtr<eServiceCenter> sc;
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!");