Revert "lib/gdi/font.cpp: call libfribidi for single lines on multi line texts to...
[enigma2.git] / lib / gui / elistboxcontent.cpp
index 081bde706a7f6694d27efd3593910ef517314c89..b9e71df8d8637404575660ff0a9516ac24709bcc 100644 (file)
@@ -49,7 +49,8 @@ int iListboxContent::currentCursorSelectable()
 
 DEFINE_REF(eListboxPythonStringContent);
 
-eListboxPythonStringContent::eListboxPythonStringContent(): m_itemheight(25)
+eListboxPythonStringContent::eListboxPythonStringContent()
+       :m_cursor(0), m_itemheight(25)
 {
 }
 
@@ -514,7 +515,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 +537,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)
        {
@@ -559,10 +561,11 @@ static void clearRegionSelectedHelper(gPainter &painter, eListboxStyle *local_st
                        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())
        {
@@ -571,7 +574,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;
                }
@@ -580,7 +583,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;
                }
@@ -588,14 +591,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)
@@ -818,7 +821,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]);
@@ -909,6 +913,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;
 
@@ -917,7 +925,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
@@ -941,6 +950,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c
 
                                break;
                        }
+                       case TYPE_PIXMAP_ALPHABLEND:
                        case TYPE_PIXMAP_ALPHATEST:
                        case TYPE_PIXMAP: // pixmap
                        {
@@ -990,10 +1000,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;
                        }