add foregroundcolor selected and backgroundcolor selected to local listbox
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 9 Nov 2007 00:13:20 +0000 (00:13 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 9 Nov 2007 00:13:20 +0000 (00:13 +0000)
styles (backgroundColorSelected, foregroundColorSelected in skin)
add EntryForegroundColorSelected support to GraphMultiEPG
add possibility to set selected foregroundcolor for listboxmulticontent
entries

lib/gui/elistbox.cpp
lib/gui/elistbox.h
lib/gui/elistboxcontent.cpp
lib/python/Components/MultiContent.py
lib/python/Plugins/Extensions/GraphMultiEPG/GraphMultiEpg.py
skin.py

index c7a46ba..383ac42 100644 (file)
@@ -483,12 +483,24 @@ void eListbox::setBackgroundColor(gRGB &col)
        m_style.m_background_color_set = 1;
 }
 
+void eListbox::setBackgroundColorSelected(gRGB &col)
+{
+       m_style.m_background_color_selected = col;
+       m_style.m_background_color_selected_set = 1;
+}
+
 void eListbox::setForegroundColor(gRGB &col)
 {
        m_style.m_foreground_color = col;
        m_style.m_foreground_color_set = 1;
 }
 
+void eListbox::setForegroundColorSelected(gRGB &col)
+{
+       m_style.m_foreground_color_selected = col;
+       m_style.m_foreground_color_selected_set = 1;
+}
+
 void eListbox::setBackgroundPicture(ePtr<gPixmap> &pm)
 {
        m_style.m_background = pm;
index 20f23b5..e323432 100644 (file)
@@ -59,8 +59,8 @@ struct eListboxStyle
 {
        ePtr<gPixmap> m_background, m_selection;
        int m_transparent_background;
-       gRGB m_background_color, m_foreground_color;
-       int m_background_color_set, m_foreground_color_set;
+       gRGB m_background_color, m_background_color_selected, m_foreground_color, m_foreground_color_selected;
+       int m_background_color_set, m_foreground_color_set, m_background_color_selected_set, m_foreground_color_selected_set;
 
                /*
                        {m_transparent_background m_background_color_set m_background}
@@ -120,7 +120,9 @@ public:
        void setSelectionEnable(int en);
 
        void setBackgroundColor(gRGB &col);
+       void setBackgroundColorSelected(gRGB &col);
        void setForegroundColor(gRGB &col);
+       void setForegroundColorSelected(gRGB &col);
        void setBackgroundPicture(ePtr<gPixmap> &pixmap);
        void setSelectionPicture(ePtr<gPixmap> &pixmap);
 
index 8331ca1..3950906 100644 (file)
@@ -147,15 +147,29 @@ void eListboxPythonStringContent::paint(gPainter &painter, eWindowStyle &style,
        if (m_listbox)
                local_style = m_listbox->getLocalStyle();
 
-               /* if we have a local background color set, use that. */
-       if (local_style && local_style->m_background_color_set)
-               painter.setBackgroundColor(local_style->m_background_color);
-
-               /* same for foreground */
-       if (local_style && local_style->m_foreground_color_set)
-               painter.setForegroundColor(local_style->m_foreground_color);
+       if (local_style)
+       {
+               if (selected)
+               {
+                       /* if we have a local background color set, use that. */
+                       if (local_style->m_background_color_selected_set)
+                               painter.setBackgroundColor(local_style->m_background_color_selected);
+                       /* same for foreground */
+                       if (local_style->m_foreground_color_selected_set)
+                               painter.setForegroundColor(local_style->m_foreground_color_selected);
+               }
+               else
+               {
+                       /* if we have a local background color set, use that. */
+                       if (local_style->m_background_color_set)
+                               painter.setBackgroundColor(local_style->m_background_color);
+                       /* same for foreground */
+                       if (local_style->m_foreground_color_set)
+                               painter.setForegroundColor(local_style->m_foreground_color);
+               }
+       }
 
-               /* if we have no transparent background */
+       /* if we have no transparent background */
        if (!local_style || !local_style->m_transparent_background)
        {
                        /* blit background picture, if available (otherwise, clear only) */
@@ -268,13 +282,27 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style,
        if (m_listbox)
                local_style = m_listbox->getLocalStyle();
 
-               /* if we have a local background color set, use that. */
-       if (local_style && local_style->m_background_color_set)
-               painter.setBackgroundColor(local_style->m_background_color);
-
-               /* same for foreground */
-       if (local_style && local_style->m_foreground_color_set)
-               painter.setForegroundColor(local_style->m_foreground_color);
+       if (local_style)
+       {
+               if (selected)
+               {
+                       /* if we have a local background color set, use that. */
+                       if (local_style->m_background_color_selected_set)
+                               painter.setBackgroundColor(local_style->m_background_color_selected);
+                       /* same for foreground */
+                       if (local_style->m_foreground_color_selected_set)
+                               painter.setForegroundColor(local_style->m_foreground_color_selected);
+               }
+               else
+               {
+                       /* if we have a local background color set, use that. */
+                       if (local_style->m_background_color_set)
+                               painter.setBackgroundColor(local_style->m_background_color);
+                       /* same for foreground */
+                       if (local_style->m_foreground_color_set)
+                               painter.setForegroundColor(local_style->m_foreground_color);
+               }
+       }
 
        if (!local_style || !local_style->m_transparent_background)
                /* if we have no transparent background */
@@ -472,7 +500,7 @@ void eListboxPythonMultiContent::setSelectionClip(eRect &rect, bool update)
                m_listbox->entryChanged(m_cursor);
 }
 
-static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *local_style, ePyObject pforeColor, ePyObject pbackColor, ePyObject pbackColorSelected, int selected, gRegion &rc, eRect &sel_clip)
+static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *local_style, ePyObject pforeColor, ePyObject pforeColorSelected, ePyObject pbackColor, ePyObject pbackColorSelected, int selected, gRegion &rc, eRect &sel_clip)
 {
        if (selected && sel_clip.valid())
        {
@@ -500,6 +528,8 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l
                        int color = PyInt_AsLong(pbackColorSelected);
                        painter.setBackgroundColor(gRGB(color));
                }
+               else if (local_style && local_style->m_background_color_selected_set)
+                       painter.setBackgroundColor(local_style->m_background_color_selected);
                painter.clear();
                painter.clippop();
        }
@@ -513,6 +543,8 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l
                                int color = PyInt_AsLong(pbackColorSelected);
                                painter.setBackgroundColor(gRGB(color));
                        }
+                       else if (local_style && local_style->m_background_color_selected_set)
+                               painter.setBackgroundColor(local_style->m_background_color_selected);
                        painter.clear();
                }
                else
@@ -536,13 +568,28 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l
                                painter.clear();
                }
        }
-       if (pforeColor)
+       if (selected)
        {
-               int color = PyInt_AsLong(pforeColor);
-               painter.setForegroundColor(gRGB(color));
-       }/* if we have a local foreground color set, use that. */
-       else if (local_style && local_style->m_foreground_color_set)
-               painter.setForegroundColor(local_style->m_foreground_color);
+               if (pforeColorSelected)
+               {
+                       int color = PyInt_AsLong(pforeColor);
+                       painter.setForegroundColor(gRGB(color));
+               }
+               /* if we have a local foreground color set, use that. */
+               else if (local_style && local_style->m_foreground_color_selected_set)
+                       painter.setForegroundColor(local_style->m_foreground_color_selected);
+       }
+       else
+       {
+               if (pforeColor)
+               {
+                       int color = PyInt_AsLong(pforeColor);
+                       painter.setForegroundColor(gRGB(color));
+               }
+               /* if we have a local foreground color set, use that. */
+               else if (local_style && local_style->m_foreground_color_set)
+                       painter.setForegroundColor(local_style->m_foreground_color);
+       }
 }
 
 void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
@@ -559,7 +606,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
        painter.clip(itemregion);
 
-       clearRegion(painter, style, local_style, ePyObject(), ePyObject(), ePyObject(), selected, itemregion, sel_clip);
+       clearRegion(painter, style, local_style, ePyObject(), ePyObject(), ePyObject(), ePyObject(), selected, itemregion, sel_clip);
 
        ePyObject items;
 
@@ -625,7 +672,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
                        case TYPE_TEXT: // text
                        {
                        /*
-                               (0, x, y, width, height, fnt, flags, "bla" [, color, backColor, backColorSelected, borderWidth, borderColor] )
+                               (0, x, y, width, height, fnt, flags, "bla" [, color, colorSelected, backColor, backColorSelected, borderWidth, borderColor] )
                        */
                                ePyObject px = PyTuple_GET_ITEM(item, 1),
                                                        py = PyTuple_GET_ITEM(item, 2),
@@ -634,7 +681,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
                                                        pfnt = PyTuple_GET_ITEM(item, 5),
                                                        pflags = PyTuple_GET_ITEM(item, 6),
                                                        pstring = PyTuple_GET_ITEM(item, 7),
-                                                       pforeColor, pbackColor, pbackColorSelected, pborderWidth, pborderColor;
+                                                       pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, pborderWidth, pborderColor;
 
                                if (!(px && py && pwidth && pheight && pfnt && pflags && pstring))
                                {
@@ -650,20 +697,34 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
                                }
                                if (size > 9)
                                {
-                                       pbackColor = PyTuple_GET_ITEM(item, 9);
+                                       pforeColorSelected = PyTuple_GET_ITEM(item, 9);
+                                       if (pforeColorSelected == Py_None)
+                                               pforeColorSelected=ePyObject();
+                               }
+                               if (size > 10)
+                               {
+                                       pbackColor = PyTuple_GET_ITEM(item, 10);
                                        if (pbackColor == Py_None)
                                                pbackColor=ePyObject();
                                }
-                               if (size > 10)
+                               if (size > 11)
                                {
-                                       pbackColorSelected = PyTuple_GET_ITEM(item, 10);
+                                       pbackColorSelected = PyTuple_GET_ITEM(item, 11);
                                        if (pbackColorSelected == Py_None)
                                                pbackColorSelected=ePyObject();
                                }
-                               if (size > 11)
-                                       pborderWidth = PyTuple_GET_ITEM(item, 11);
                                if (size > 12)
-                                       pborderColor = PyTuple_GET_ITEM(item, 12);
+                               {
+                                       pborderWidth = PyTuple_GET_ITEM(item, 12);
+                                       if (pborderWidth == Py_None)
+                                               pborderWidth=ePyObject();
+                               }
+                               if (size > 13)
+                               {
+                                       pborderColor = PyTuple_GET_ITEM(item, 13);
+                                       if (pborderColor == Py_None)
+                                               pborderColor=ePyObject();
+                               }
 
                                const char *string = (PyString_Check(pstring)) ? PyString_AsString(pstring) : "<not-a-string>";
                                int x = PyInt_AsLong(px) + offset.x();
@@ -682,10 +743,10 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
                                eRect rect(x+bwidth, y+bwidth, width-bwidth*2, height-bwidth*2);
                                painter.clip(rect);
-                               if (pbackColor || pbackColorSelected || pforeColor)
+                               if (pbackColor || pbackColorSelected || pforeColor || pforeColorSelected)
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, pforeColor, pbackColor, pbackColorSelected, selected, rc, sel_clip);
+                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip);
                                        reset_colors=true;
                                }
 
@@ -732,7 +793,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
                                                        pwidth = PyTuple_GET_ITEM(item, 3),
                                                        pheight = PyTuple_GET_ITEM(item, 4),
                                                        pfilled_perc = PyTuple_GET_ITEM(item, 5),
-                                                       pborderWidth, pforeColor, pbackColor, pbackColorSelected;
+                                                       pborderWidth, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected;
 
                                if (!(px && py && pwidth && pheight && pfilled_perc))
                                {
@@ -741,18 +802,32 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
                                }
 
                                if (size > 6)
+                               {
                                        pborderWidth = PyTuple_GET_ITEM(item, 6);
+                                       if (pborderWidth == Py_None)
+                                               pborderWidth = ePyObject();
+                               }
                                if (size > 7)
+                               {
                                        pforeColor = PyTuple_GET_ITEM(item, 7);
+                                       if (pforeColor == Py_None)
+                                               pforeColor = ePyObject();
+                               }
                                if (size > 8)
                                {
-                                       pbackColor = PyTuple_GET_ITEM(item, 8);
+                                       pforeColorSelected = PyTuple_GET_ITEM(item, 8);
+                                       if (pforeColorSelected == Py_None)
+                                               pforeColorSelected=ePyObject();
+                               }
+                               if (size > 9)
+                               {
+                                       pbackColor = PyTuple_GET_ITEM(item, 9);
                                        if (pbackColor == Py_None)
                                                pbackColor=ePyObject();
                                }
-                               if (size > 9)
+                               if (size > 10)
                                {
-                                       pbackColorSelected = PyTuple_GET_ITEM(item, 9);
+                                       pbackColorSelected = PyTuple_GET_ITEM(item, 10);
                                        if (pbackColorSelected == Py_None)
                                                pbackColorSelected=ePyObject();
                                }
@@ -766,10 +841,10 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
                                eRect rect(x, y, width, height);
                                painter.clip(rect);
-                               if (pbackColor || pbackColorSelected || pforeColor)
+                               if (pbackColor || pbackColorSelected || pforeColor || pforeColorSelected)
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, pforeColor, pbackColor, pbackColorSelected, selected, rc, sel_clip);
+                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip);
                                        reset_colors=true;
                                }
 
@@ -843,7 +918,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
                                if (pbackColor || pbackColorSelected)
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip);
+                                       clearRegion(painter, style, local_style, ePyObject(), ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip);
                                        reset_colors=true;
                                }
                                
index 3031fb3..71096df 100644 (file)
@@ -1,15 +1,10 @@
 from enigma import eListboxPythonMultiContent, RT_HALIGN_LEFT, RT_VALIGN_TOP
 
-def MultiContentEntryText(pos = (0, 0), size = (0, 0), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_TOP, text = "", color = None):
-       add = ()
-       if color is not None:
-               add = (color, )
-       return (eListboxPythonMultiContent.TYPE_TEXT, pos[0], pos[1], size[0], size[1], font, flags, text) + add
+def MultiContentEntryText(pos = (0, 0), size = (0, 0), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_TOP, text = "", color = None, color_sel = None, backcolor = None, backcolor_sel = None, border_width = None, border_color = None):
+       return (eListboxPythonMultiContent.TYPE_TEXT, pos[0], pos[1], size[0], size[1], font, flags, text, color, color_sel, backcolor, backcolor_sel, border_width, border_color)
 
-def MultiContentEntryPixmap(pos = (0, 0), size = (0, 0), png = None):
-       return (eListboxPythonMultiContent.TYPE_PIXMAP, pos[0], pos[1], size[0], size[1], png)
+def MultiContentEntryPixmap(pos = (0, 0), size = (0, 0), png = None, backcolor = None, backcolor_sel = None):
+       return (eListboxPythonMultiContent.TYPE_PIXMAP, pos[0], pos[1], size[0], size[1], png, backcolor, backcolor_sel)
 
-def MultiContentEntryPixmapAlphaTest(pos = (0, 0), size = (0, 0), png = None):
-       return (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, pos[0], pos[1], size[0], size[1], png)
-
-       
\ No newline at end of file
+def MultiContentEntryPixmapAlphaTest(pos = (0, 0), size = (0, 0), png = None, backcolor = None, backcolor_sel = None):
+       return (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, pos[0], pos[1], size[0], size[1], png, backcolor, backcolor_sel)
index 9040539..72b6945 100644 (file)
@@ -8,6 +8,7 @@ from Components.GUIComponent import GUIComponent
 from Components.EpgList import Rect
 from Components.Sources.Event import Event
 from Components.Sources.Source import ObsoleteSource
+from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
 from Screens.Screen import Screen
 from Screens.EventView import EventViewSimple
 from Screens.TimeDateInput import TimeDateInput
@@ -16,7 +17,7 @@ from Screens.EpgSelection import EPGSelection
 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
 from RecordTimer import RecordTimerEntry, parseEvent
 from ServiceReference import ServiceReference
-from enigma import eEPGCache, eListbox, eListboxPythonMultiContent, gFont, loadPNG, \
+from enigma import eEPGCache, eListbox, gFont, loadPNG, eListboxPythonMultiContent, \
        RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_VALIGN_CENTER, RT_WRAP, eRect, eTimer
 
 from time import localtime, time, strftime
@@ -44,6 +45,7 @@ class EPGList(HTMLComponent, GUIComponent):
                self.event_rect = None
 
                self.foreColor = None
+               self.foreColorSelected = None
                self.borderColor = None
                self.backColor = 0x586d88
                self.backColorSelected = 0x808080
@@ -54,6 +56,8 @@ class EPGList(HTMLComponent, GUIComponent):
                        for (attrib, value) in self.skinAttributes:
                                if attrib == "EntryForegroundColor":
                                        self.foreColor = parseColor(value).argb()
+                               elif attrib == "EntryForegroundColorSelected":
+                                       self.foreColorSelected = parseColor(value).argb()
                                elif attrib == "EntryBorderColor":
                                        self.borderColor = parseColor(value).argb()
                                elif attrib == "EntryBackgroundColor":
@@ -182,8 +186,7 @@ class EPGList(HTMLComponent, GUIComponent):
        def buildEntry(self, service, service_name, events):
                r1=self.service_rect
                r2=self.event_rect
-               res = [ None ] # no private data needed
-               res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, service_name))
+               res = [ None, MultiContentEntryText(pos = (r1.left(),r1.top()), size = (r1.width(), r1.height()), font = 0, flags = RT_HALIGN_LEFT | RT_VALIGN_CENTER, text = service_name) ]
 
                if events:
                        start = self.time_base+self.offs*self.time_epoch*60
@@ -193,6 +196,7 @@ class EPGList(HTMLComponent, GUIComponent):
                        width = r2.width()
                        height = r2.height()
                        foreColor = self.foreColor
+                       foreColorSelected = self.foreColorSelected
                        backColor = self.backColor
                        backColorSelected = self.backColorSelected
                        borderColor = self.borderColor
@@ -200,12 +204,9 @@ class EPGList(HTMLComponent, GUIComponent):
                        for ev in events:  #(event_id, event_title, begin_time, duration)
                                rec=self.timer.isInTimer(ev[0], ev[2], ev[3], service) > ((ev[3]/10)*8)
                                xpos, ewidth = self.calcEntryPosAndWidthHelper(ev[2], ev[3], start, end, width)
-                               if self.borderColor is None:
-                                       res.append((eListboxPythonMultiContent.TYPE_TEXT, left+xpos, top, ewidth, height, 1, RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, ev[1], foreColor, backColor, backColorSelected, 1))
-                               else:
-                                       res.append((eListboxPythonMultiContent.TYPE_TEXT, left+xpos, top, ewidth, height, 1, RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, ev[1], foreColor, backColor, backColorSelected, 1, borderColor))
+                               res.append(MultiContentEntryText(pos = (left+xpos, top), size = (ewidth, height), font = 1, flags = RT_HALIGN_CENTER | RT_VALIGN_CENTER | RT_WRAP, text = ev[1], color = foreColor, color_sel = foreColorSelected, backcolor = backColor, backcolor_sel = backColorSelected, border_width = 1, border_color = borderColor))
                                if rec and ewidth > 23:
-                                       res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, left+xpos+ewidth-22, top+height-22, 21, 21, self.clock_pixmap, backColor, backColorSelected))
+                                       res.append(MultiContentEntryPixmapAlphaTest(pos = (left+xpos+ewidth-22, top+height-22), size = (21, 21), png = self.clock_pixmap, backcolor = backColor, backcolor_selected = backColorSelected))
                return res
 
        def selEntry(self, dir, visible=True):
diff --git a/skin.py b/skin.py
index e5c4837..1f5c9cf 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -168,8 +168,12 @@ def applySingleAttribute(guiObject, desktop, attrib, value):
                                        print "illegal flag %s!" % f
                elif attrib == "backgroundColor":
                        guiObject.setBackgroundColor(parseColor(value))
+               elif attrib == "backgroundColorSelected":
+                       guiObject.setBackgroundColorSelected(parseColor(value))
                elif attrib == "foregroundColor":
                        guiObject.setForegroundColor(parseColor(value))
+               elif attrib == "foregroundColorSelected":
+                       guiObject.setForegroundColorSelected(parseColor(value))
                elif attrib == "shadowColor":
                        guiObject.setShadowColor(parseColor(value))
                elif attrib == "selectionDisabled":