Merge commit 'origin/translations' into experimental
[enigma2.git] / lib / gui / elistboxcontent.cpp
index dccd1b05d31567ac203765dd0c5b87135b592b5a..4465d84c1e28250c1e40061959f57ead8973afd9 100644 (file)
@@ -49,7 +49,7 @@ int iListboxContent::currentCursorSelectable()
 
 DEFINE_REF(eListboxPythonStringContent);
 
-eListboxPythonStringContent::eListboxPythonStringContent(): m_itemheight(25)
+eListboxPythonStringContent::eListboxPythonStringContent(): m_itemheight(25), m_cursor(0)
 {
 }
 
@@ -81,7 +81,7 @@ int eListboxPythonStringContent::cursorMove(int count)
 
 int eListboxPythonStringContent::cursorValid()
 {
-       return m_cursor < size();
+       return ((unsigned int)m_cursor) < size();
 }
 
 int eListboxPythonStringContent::cursorSet(int n)
@@ -514,7 +514,7 @@ void eListboxPythonMultiContent::setSelectionClip(eRect &rect, bool update)
                m_listbox->entryChanged(m_cursor);
 }
 
-static void clearRegionHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColor, bool cursorValid)
+static void clearRegionHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColor, bool cursorValid, bool clear=true)
 {
        if (pbackColor)
        {
@@ -536,10 +536,11 @@ static void clearRegionHelper(gPainter &painter, eListboxStyle *local_style, con
                else if (local_style->m_transparent_background)
                        return;
        }
-       painter.clear();
+       if (clear)
+               painter.clear();
 }
 
-static void clearRegionSelectedHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColorSelected, bool cursorValid)
+static void clearRegionSelectedHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColorSelected, bool cursorValid, bool clear=true)
 {
        if (pbackColorSelected)
        {
@@ -558,13 +559,12 @@ static void clearRegionSelectedHelper(gPainter &painter, eListboxStyle *local_st
                                painter.blit(local_style->m_background, offset, eRect(), 0);
                        return;
                }
-               else if (local_style->m_transparent_background)
-                       return;
        }
-       painter.clear();
+       if (clear)
+               painter.clear();
 }
 
-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, const ePoint &offset, bool cursorValid)
+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, const ePoint &offset, bool cursorValid, bool clear=true)
 {
        if (selected && sel_clip.valid())
        {
@@ -573,7 +573,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l
                {
                        painter.clip(part);
                        style.setStyle(painter, eWindowStyle::styleListboxNormal);
-                       clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid);
+                       clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid, clear);
                        painter.clippop();
                        selected = 0;
                }
@@ -582,7 +582,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l
                {
                        painter.clip(part);
                        style.setStyle(painter, eWindowStyle::styleListboxSelected);
-                       clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid);
+                       clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid, clear);
                        painter.clippop();
                        selected = 1;
                }
@@ -590,14 +590,14 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l
        else if (selected)
        {
                style.setStyle(painter, eWindowStyle::styleListboxSelected);
-               clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid);
+               clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid, clear);
                if (local_style && local_style->m_selection)
                        painter.blit(local_style->m_selection, offset, eRect(), gPainter::BT_ALPHATEST);
        }
        else
        {
                style.setStyle(painter, eWindowStyle::styleListboxNormal);
-               clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid);
+               clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid, clear);
        }
 
        if (selected)
@@ -820,7 +820,8 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid);
+                                       bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor);
+                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear);
                                }
 
                                painter.setFont(m_font[fnt]);
@@ -911,6 +912,10 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
                                if ((filled < 0) && data) /* if the string is in a negative number, it refers to the 'data' list. */
                                        filled = PyInt_AsLong(PyTuple_GetItem(data, -filled));
+                                       
+                                                       /* don't do anything if percent out of range */
+                               if ((filled < 0) || (filled > 100))
+                                       continue;
 
                                int bwidth = pborderWidth ? PyInt_AsLong(pborderWidth) : 2;
 
@@ -919,7 +924,8 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid);
+                                       bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor);
+                                       clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear);
                                }
 
                                // border
@@ -943,6 +949,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
                                break;
                        }
+                       case TYPE_PIXMAP_ALPHABLEND:
                        case TYPE_PIXMAP_ALPHATEST:
                        case TYPE_PIXMAP: // pixmap
                        {
@@ -992,10 +999,11 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
                                {
                                        gRegion rc(rect);
-                                       clearRegion(painter, style, local_style, ePyObject(), ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid);
+                                       bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor);
+                                       clearRegion(painter, style, local_style, ePyObject(), ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear);
                                }
 
-                               painter.blit(pixmap, rect.topLeft(), rect, (type == TYPE_PIXMAP_ALPHATEST) ? gPainter::BT_ALPHATEST : 0);
+                               painter.blit(pixmap, rect.topLeft(), rect, (type == TYPE_PIXMAP_ALPHATEST) ? gPainter::BT_ALPHATEST : (type == TYPE_PIXMAP_ALPHABLEND) ? gPainter::BT_ALPHABLEND : 0);
                                painter.clippop();
                                break;
                        }