aboutsummaryrefslogtreecommitdiff
path: root/lib/gui
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-04-15 18:00:24 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-04-15 18:00:24 +0000
commit44433f650cd3e5f9f66253b74d194fcb01578595 (patch)
treec67ea0df64ff9bfdd500abd4a641a7aae7450a84 /lib/gui
parent77c45c9d2cabd3c1dc028c41d26573ac62147a34 (diff)
downloadenigma2-44433f650cd3e5f9f66253b74d194fcb01578595.tar.gz
enigma2-44433f650cd3e5f9f66253b74d194fcb01578595.zip
- sdl is now default output
- added skinned window style - added background colors - some RGB color support (but still not how i like it) - some minor bugfixes
Diffstat (limited to 'lib/gui')
-rw-r--r--lib/gui/Makefile.am2
-rw-r--r--lib/gui/elistbox.cpp2
-rw-r--r--lib/gui/epixmap.cpp11
-rw-r--r--lib/gui/epixmap.h1
-rw-r--r--lib/gui/ewidget.cpp27
-rw-r--r--lib/gui/ewidget.h5
-rw-r--r--lib/gui/ewidgetdesktop.cpp15
-rw-r--r--lib/gui/ewidgetdesktop.h2
-rw-r--r--lib/gui/ewindow.cpp57
-rw-r--r--lib/gui/ewindow.h8
-rw-r--r--lib/gui/ewindowstyle.cpp62
-rw-r--r--lib/gui/ewindowstyle.h61
-rw-r--r--lib/gui/ewindowstyleskinned.cpp248
-rw-r--r--lib/gui/ewindowstyleskinned.h71
14 files changed, 477 insertions, 95 deletions
diff --git a/lib/gui/Makefile.am b/lib/gui/Makefile.am
index 076ee36a..44f5a16d 100644
--- a/lib/gui/Makefile.am
+++ b/lib/gui/Makefile.am
@@ -7,6 +7,6 @@ noinst_LIBRARIES = libenigma_gui.a
libenigma_gui_a_SOURCES = \
ebutton.cpp elabel.cpp eslider.cpp ewidget.cpp ewidgetdesktop.cpp \
ewindow.cpp ewindowstyle.cpp elistbox.cpp elistboxcontent.cpp \
- epixmap.cpp
+ epixmap.cpp ewindowstyleskinned.cpp
diff --git a/lib/gui/elistbox.cpp b/lib/gui/elistbox.cpp
index 7764e6b5..2c2525c9 100644
--- a/lib/gui/elistbox.cpp
+++ b/lib/gui/elistbox.cpp
@@ -135,7 +135,7 @@ int eListbox::event(int event, void *data, void *data2)
moveSelection((int)data2);
return 1;
}
- break;
+ return 0;
default:
return eWidget::event(event, data, data2);
}
diff --git a/lib/gui/epixmap.cpp b/lib/gui/epixmap.cpp
index a0655aa9..797c6759 100644
--- a/lib/gui/epixmap.cpp
+++ b/lib/gui/epixmap.cpp
@@ -1,4 +1,6 @@
#include <lib/gui/epixmap.h>
+#include <lib/gdi/epng.h>
+#include <lib/gui/ewidgetdesktop.h>
ePixmap::ePixmap(eWidget *parent): eWidget(parent)
{
@@ -10,6 +12,15 @@ void ePixmap::setPixmap(gPixmap *pixmap)
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)
diff --git a/lib/gui/epixmap.h b/lib/gui/epixmap.h
index 8a12e2e9..220db1ff 100644
--- a/lib/gui/epixmap.h
+++ b/lib/gui/epixmap.h
@@ -9,6 +9,7 @@ public:
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);
diff --git a/lib/gui/ewidget.cpp b/lib/gui/ewidget.cpp
index 7f089361..3ba248ff 100644
--- a/lib/gui/ewidget.cpp
+++ b/lib/gui/ewidget.cpp
@@ -7,6 +7,7 @@ eWidget::eWidget(eWidget *parent): m_parent(parent ? parent->child() : 0)
{
m_vis = 0;
m_desktop = 0;
+ m_have_background_color = 0;
if (m_parent)
m_vis = wVisShow;
@@ -45,10 +46,12 @@ void eWidget::resize(eSize size)
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();
@@ -145,6 +148,13 @@ void eWidget::destruct()
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();
@@ -217,9 +227,16 @@ int eWidget::event(int event, void *data, void *data2)
// 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:
diff --git a/lib/gui/ewidget.h b/lib/gui/ewidget.h
index fbe5a92a..cb39a000 100644
--- a/lib/gui/ewidget.h
+++ b/lib/gui/ewidget.h
@@ -33,6 +33,8 @@ public:
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()); }
/* ... */
@@ -56,6 +58,9 @@ private:
void doPaint(gPainter &painter, const gRegion &region);
void recalcClipRegionsWhenVisible();
+
+ gRGB m_background_color;
+ int m_have_background_color;
protected:
virtual ~eWidget();
public:
diff --git a/lib/gui/ewidgetdesktop.cpp b/lib/gui/ewidgetdesktop.cpp
index 96f74636..8c489eb3 100644
--- a/lib/gui/ewidgetdesktop.cpp
+++ b/lib/gui/ewidgetdesktop.cpp
@@ -108,6 +108,21 @@ void eWidgetDesktop::setRedrawTask(eMainloop &ml)
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)
{
}
diff --git a/lib/gui/ewidgetdesktop.h b/lib/gui/ewidgetdesktop.h
index f76baf60..22914ec5 100644
--- a/lib/gui/ewidgetdesktop.h
+++ b/lib/gui/ewidgetdesktop.h
@@ -30,6 +30,8 @@ public:
void setBackgroundColor(gColor col);
void setRedrawTask(eMainloop &ml);
+
+ void makeCompatiblePixmap(gPixmap &pm);
private:
ePtrList<eWidget> m_root;
void calcWidgetClipRegion(eWidget *widget, gRegion &parent_visible);
diff --git a/lib/gui/ewindow.cpp b/lib/gui/ewindow.cpp
index 1114d258..01f889ff 100644
--- a/lib/gui/ewindow.cpp
+++ b/lib/gui/ewindow.cpp
@@ -2,10 +2,26 @@
#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. */
@@ -27,30 +43,49 @@ void eWindow::setTitle(const std::string &string)
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:
diff --git a/lib/gui/ewindow.h b/lib/gui/ewindow.h
index f5bcd51a..33ad7a72 100644
--- a/lib/gui/ewindow.h
+++ b/lib/gui/ewindow.h
@@ -14,6 +14,13 @@ public:
~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
{
@@ -23,6 +30,7 @@ protected:
private:
std::string m_title;
eWidget *m_child;
+ int m_flags;
};
#endif
diff --git a/lib/gui/ewindowstyle.cpp b/lib/gui/ewindowstyle.cpp
index a2e0efb2..79024a35 100644
--- a/lib/gui/ewindowstyle.cpp
+++ b/lib/gui/ewindowstyle.cpp
@@ -2,10 +2,35 @@
#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()
@@ -22,7 +47,7 @@ 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());
@@ -130,35 +155,4 @@ RESULT eWindowStyleSimple::getFont(int what, ePtr<gFont> &fnt)
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");
diff --git a/lib/gui/ewindowstyle.h b/lib/gui/ewindowstyle.h
index f11d99de..08ea0a41 100644
--- a/lib/gui/ewindowstyle.h
+++ b/lib/gui/ewindowstyle.h
@@ -10,7 +10,7 @@ class gFont;
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;
@@ -38,6 +38,22 @@ public:
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);
@@ -48,7 +64,7 @@ private:
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);
@@ -56,45 +72,4 @@ public:
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
diff --git a/lib/gui/ewindowstyleskinned.cpp b/lib/gui/ewindowstyleskinned.cpp
new file mode 100644
index 00000000..a3152e5f
--- /dev/null
+++ b/lib/gui/ewindowstyleskinned.cpp
@@ -0,0 +1,248 @@
+#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!");
+}
+
diff --git a/lib/gui/ewindowstyleskinned.h b/lib/gui/ewindowstyleskinned.h
new file mode 100644
index 00000000..79557386
--- /dev/null
+++ b/lib/gui/ewindowstyleskinned.h
@@ -0,0 +1,71 @@
+#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