make local listbox styles working for text lists
authorFelix Domke <tmbinc@elitedvb.net>
Mon, 20 Aug 2007 22:20:22 +0000 (22:20 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Mon, 20 Aug 2007 22:20:22 +0000 (22:20 +0000)
lib/gui/elistbox.cpp
lib/gui/elistbox.h
lib/gui/elistboxcontent.cpp
skin.py

index c3b202cb65fc57b9551c4a6dfdb526d14cf1a6e3..b7b1e3ff595a6538e3d571f1a2bb3f532bebaf1e 100644 (file)
@@ -8,6 +8,7 @@ eListbox::eListbox(eWidget *parent) :
        m_content_changed(false), m_enabled_wrap_around(false), m_top(0), m_selected(0), m_itemheight(25),
        m_items_per_page(0), m_selection_enabled(1), m_scrollbar(NULL)
 {
+       memset(&m_style, 0, sizeof(m_style));
 //     setContent(new eListboxStringContent());
 
        ePtr<eActionMap> ptr;
@@ -484,12 +485,12 @@ void eListbox::setForegroundColor(gRGB &col)
        m_style.m_foreground_color_set = 1;
 }
 
-void eListbox::setBackgroundPicture(gPixmap *pm)
+void eListbox::setBackgroundPicture(ePtr<gPixmap> &pm)
 {
        m_style.m_background = pm;
 }
 
-void eListbox::setSelectionPicture(gPixmap *pm)
+void eListbox::setSelectionPicture(ePtr<gPixmap> &pm)
 {
        m_style.m_selection = pm;
 }
index ace418984dcd7415f9246fb86d437bd9188f4cad..1cadf74b75085d4c0b8537fbc9471f1c73b1fc21 100644 (file)
@@ -120,8 +120,8 @@ public:
 
        void setBackgroundColor(gRGB &col);
        void setForegroundColor(gRGB &col);
-       void setBackgroundPicture(gPixmap *pm);
-       void setSelectionPicture(gPixmap *pm);
+       void setBackgroundPicture(ePtr<gPixmap> &pixmap);
+       void setSelectionPicture(ePtr<gPixmap> &pixmap);
 
        struct eListboxStyle *getLocalStyle(void);
 #ifndef SWIG
index b397ddcae40e66fba82ea58cfe4d380ad0417f1f..0378aefcb5d4ea480b92ac17a472a5d5b932580d 100644 (file)
@@ -140,7 +140,34 @@ void eListboxPythonStringContent::paint(gPainter &painter, eWindowStyle &style,
        ePtr<gFont> fnt = new gFont("Regular", 20);
        painter.clip(eRect(offset, m_itemsize));
        style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
-       painter.clear();
+
+       eListboxStyle *local_style = 0;
+
+               /* get local listbox style, if present */
+       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.setBackgroundColor(local_style->m_foreground_color);
+
+               /* if we have no transparent background */
+       if (!local_style || !local_style->m_transparent_background)
+       {
+                       /* blit background picture, if available (otherwise, clear only) */
+               if (local_style && local_style->m_background)
+                       painter.blit(local_style->m_background, offset, eRect(), 0);
+               else
+                       painter.clear();
+       } else
+       {
+               if (local_style && local_style->m_background)
+                       painter.blit(local_style->m_background, offset, eRect(), gPainter::BT_ALPHATEST);
+       }
 
        if (m_list && cursorValid())
        {
@@ -155,11 +182,14 @@ void eListboxPythonStringContent::paint(gPainter &painter, eWindowStyle &style,
                                gray = 1;
                        item = PyTuple_GET_ITEM(item, 0);
                }
-               
+
+               if (selected && local_style && local_style->m_selection)
+                       painter.blit(local_style->m_selection, offset, eRect(), gPainter::BT_ALPHATEST);
+
                if (item == Py_None)
                {
+                               /* seperator */
                        int half_height = m_itemsize.height() / 2;
-                       
                        painter.fill(eRect(offset.x() + half_height, offset.y() + half_height - 2, m_itemsize.width() - m_itemsize.height(), 4));
                } else
                {
@@ -169,11 +199,11 @@ void eListboxPythonStringContent::paint(gPainter &painter, eWindowStyle &style,
                                painter.setForegroundColor(gRGB(0x808080));
                        painter.renderText(eRect(text_offset, m_itemsize), string);
                }
-               
-               if (selected)
+
+               if (selected && (!local_style || !local_style->m_selection))
                        style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
        }
-       
+
        painter.clippop();
 }
 
diff --git a/skin.py b/skin.py
index 07213915e404de20767e225993fc0a07364c25e3..3b448127c59a038dc72a2fb93583c0aa74123342 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -88,7 +88,7 @@ def collectAttributes(skinAttributes, node, skin_path_prefix=None, ignore=[]):
                # TODO: localization? as in e1?
                value = a.value.encode("utf-8")
                
-               if attrib in ["pixmap", "pointer", "seek_pointer"]:
+               if attrib in ["pixmap", "pointer", "seek_pointer", "backgroundPixmap", "selectionPixmap"]:
                        value = resolveFilename(SCOPE_SKIN_IMAGE, value, path_prefix=skin_path_prefix)
                
                if attrib not in ignore:
@@ -115,10 +115,15 @@ def applySingleAttribute(guiObject, desktop, attrib, value):
                        guiObject.setFont(parseFont(value))
                elif attrib == 'zPosition':
                        guiObject.setZPosition(int(value))
-               elif attrib == "pixmap":
+               elif attrib in ["pixmap", "backgroundPixmap", "selectionPixmap"]:
                        ptr = loadPixmap(value) # this should already have been filename-resolved.
                        desktop.makeCompatiblePixmap(ptr)
-                       guiObject.setPixmap(ptr)
+                       if attrib == "pixmap":
+                               guiObject.setPixmap(ptr)
+                       elif attrib == "backgroundPixmap":
+                               guiObject.setBackgroundPicture(ptr)
+                       elif attrib == "selectionPixmap":
+                               guiObject.setSelectionPicture(ptr)
                        # guiObject.setPixmapFromFile(value)
                elif attrib == "alphatest": # used by ePixmap
                        guiObject.setAlphatest(