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