aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-04-17 20:01:28 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-04-17 20:01:28 +0000
commit78c828aae07db0b15a66577d9230cb848fe536fa (patch)
tree28f8a54388094420c73c01938a389b52b6c2015b /lib
parent18ee5e9c8a01b3ddd899a6aeea40ab0a6ce3da7d (diff)
downloadenigma2-78c828aae07db0b15a66577d9230cb848fe536fa.tar.gz
enigma2-78c828aae07db0b15a66577d9230cb848fe536fa.zip
- load palette from png
- named color support
Diffstat (limited to 'lib')
-rw-r--r--lib/gdi/gpixmap.cpp2
-rw-r--r--lib/gdi/grc.cpp6
-rw-r--r--lib/gdi/grc.h1
-rw-r--r--lib/gui/ewidgetdesktop.cpp9
-rw-r--r--lib/gui/ewidgetdesktop.h6
-rw-r--r--lib/gui/ewindowstyleskinned.cpp26
-rw-r--r--lib/gui/ewindowstyleskinned.h16
7 files changed, 49 insertions, 17 deletions
diff --git a/lib/gdi/gpixmap.cpp b/lib/gdi/gpixmap.cpp
index e9c469c4..9e8219a5 100644
--- a/lib/gdi/gpixmap.cpp
+++ b/lib/gdi/gpixmap.cpp
@@ -388,6 +388,8 @@ gColor gPalette::findColor(const gRGB &rgb) const
ttd+=td;
if (ttd>=difference)
continue;
+ if (!ttd)
+ return t;
difference=ttd;
best_choice=t;
}
diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp
index 9cb1a072..756ed9b7 100644
--- a/lib/gdi/grc.cpp
+++ b/lib/gdi/grc.cpp
@@ -240,6 +240,12 @@ void gPainter::setPalette(gRGB *colors, int start, int len)
m_rc->submit(o);
}
+void gPainter::setPalette(gPixmap *source)
+{
+ ASSERT(source);
+ setPalette(source->surface->clut.data, source->surface->clut.start, source->surface->clut.colors);
+}
+
void gPainter::mergePalette(gPixmap *target)
{
gOpcode o;
diff --git a/lib/gdi/grc.h b/lib/gdi/grc.h
index 57439178..53bf7f09 100644
--- a/lib/gdi/grc.h
+++ b/lib/gdi/grc.h
@@ -215,6 +215,7 @@ public:
void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
void setPalette(gRGB *colors, int start=0, int len=256);
+ void setPalette(gPixmap *source);
void mergePalette(gPixmap *target);
void line(ePoint start, ePoint end);
diff --git a/lib/gui/ewidgetdesktop.cpp b/lib/gui/ewidgetdesktop.cpp
index 8c489eb3..24fb334b 100644
--- a/lib/gui/ewidgetdesktop.cpp
+++ b/lib/gui/ewidgetdesktop.cpp
@@ -55,7 +55,7 @@ void eWidgetDesktop::invalidate(const gRegion &region)
m_dirty_region |= region;
}
-void eWidgetDesktop::setBackgroundColor(gColor col)
+void eWidgetDesktop::setBackgroundColor(gRGB col)
{
m_background_color = col;
@@ -70,6 +70,13 @@ void eWidgetDesktop::setBackgroundColor(gColor col)
}
}
+void eWidgetDesktop::setPalette(gPixmap &pm)
+{
+ ASSERT(m_dc);
+ gPainter painter(m_dc);
+ painter.setPalette(&pm);
+}
+
void eWidgetDesktop::paint()
{
gPainter painter(m_dc);
diff --git a/lib/gui/ewidgetdesktop.h b/lib/gui/ewidgetdesktop.h
index 22914ec5..c917e36a 100644
--- a/lib/gui/ewidgetdesktop.h
+++ b/lib/gui/ewidgetdesktop.h
@@ -15,7 +15,7 @@ public: // weil debug
gRegion m_dirty_region;
gRegion m_background_region;
ePtr<gDC> m_dc;
- gColor m_background_color;
+ gRGB m_background_color;
public:
eWidgetDesktop(eSize screen);
~eWidgetDesktop();
@@ -27,7 +27,9 @@ public:
void paint();
void setDC(gDC *dc);
- void setBackgroundColor(gColor col);
+ void setBackgroundColor(gRGB col);
+
+ void setPalette(gPixmap &pm);
void setRedrawTask(eMainloop &ml);
diff --git a/lib/gui/ewindowstyleskinned.cpp b/lib/gui/ewindowstyleskinned.cpp
index a3152e5f..55092e1d 100644
--- a/lib/gui/ewindowstyleskinned.cpp
+++ b/lib/gui/ewindowstyleskinned.cpp
@@ -8,7 +8,9 @@ DEFINE_REF(eWindowStyleSkinned);
eWindowStyleSkinned::eWindowStyleSkinned()
{
- m_background_color = gRGB(0x808080);
+ // m_background_color = gRGB(0x808080);
+
+ // TODO: initialize colors!!
}
void eWindowStyleSkinned::handleNewSize(eWindow *wnd, eSize &size, eSize &offset)
@@ -37,7 +39,7 @@ void eWindowStyleSkinned::paintWindowDecoration(eWindow *wnd, gPainter &painter,
void eWindowStyleSkinned::paintBackground(gPainter &painter, const ePoint &offset, const eSize &size)
{
- painter.setBackgroundColor(m_background_color);
+ painter.setBackgroundColor(m_color[colBackground]);
painter.clear();
}
@@ -46,19 +48,19 @@ void eWindowStyleSkinned::setStyle(gPainter &painter, int what)
switch (what)
{
case styleLabel:
- painter.setForegroundColor(gColor(0x1F));
+ painter.setForegroundColor(m_color[colLabelForeground]);
break;
case styleListboxSelected:
- painter.setForegroundColor(gColor(0x1F));
- painter.setBackgroundColor(gColor(0x1A));
+ painter.setForegroundColor(m_color[colListboxSelectedForeground]);
+ painter.setBackgroundColor(m_color[colListboxSelectedBackground]);
break;
case styleListboxNormal:
- painter.setForegroundColor(gColor(0x1C));
- painter.setBackgroundColor(m_background_color);
+ painter.setForegroundColor(m_color[colListboxForeground]);
+ painter.setBackgroundColor(m_color[colListboxBackground]);
break;
case styleListboxMarked:
- painter.setForegroundColor(gColor(0x2F));
- painter.setBackgroundColor(gColor(0x2A));
+ painter.setForegroundColor(m_color[colListboxMarkedForeground]);
+ painter.setBackgroundColor(m_color[colListboxMarkedBackground]);
break;
}
}
@@ -240,9 +242,9 @@ void eWindowStyleSkinned::setPixmap(int bs, int bp, gPixmap &pixmap)
m_border[bs].m_border_right, m_border[bs].m_border_bottom);
}
-void eWindowStyleSkinned::setDefaultBackgroundColor(const gRGB &back)
+void eWindowStyleSkinned::setColor(int what, const gRGB &col)
{
- m_background_color = back;
- eDebug("set default background color!");
+ if ((what < colMax) && (what >= 0))
+ m_color[what] = col;
}
diff --git a/lib/gui/ewindowstyleskinned.h b/lib/gui/ewindowstyleskinned.h
index 79557386..bc9c0549 100644
--- a/lib/gui/ewindowstyleskinned.h
+++ b/lib/gui/ewindowstyleskinned.h
@@ -52,7 +52,19 @@ public:
void setPixmap(int bs, int bp, gPixmap &pixmap);
- void setDefaultBackgroundColor(const gRGB &back);
+ enum {
+ colBackground,
+ colLabelForeground,
+ colListboxBackground,
+ colListboxForeground,
+ colListboxSelectedBackground,
+ colListboxSelectedForeground,
+ colListboxMarkedBackground,
+ colListboxMarkedForeground,
+ colMax
+ };
+
+ void setColor(int what, const gRGB &back);
private:
struct borderSet
@@ -63,7 +75,7 @@ private:
borderSet m_border[bsMax];
- gRGB m_background_color;
+ gRGB m_color[colMax];
void drawBorder(gPainter &painter, const eRect &size, struct borderSet &border, int where);
};