X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/5d9ab813e9468a24cc90400e9fb5b0567ec6b12a..624cd1811f54808d23a50840bb35494e4e5ca3b6:/lib/gui/elistboxcontent.cpp diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp index f1eb4bf7..5baaba7d 100644 --- a/lib/gui/elistboxcontent.cpp +++ b/lib/gui/elistboxcontent.cpp @@ -512,7 +512,63 @@ 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 pforeColorSelected, ePyObject pbackColor, ePyObject pbackColorSelected, int selected, gRegion &rc, eRect &sel_clip) +static void clearRegionHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColor) +{ + if (pbackColor) + { + unsigned int color = PyInt_AsUnsignedLongMask(pbackColor); + painter.setBackgroundColor(gRGB(color)); + painter.clear(); + } + else if (local_style) + { + if (local_style && local_style->m_background_color_set) + painter.setBackgroundColor(local_style->m_background_color); + if (local_style->m_background) + { + if (local_style->m_transparent_background) + painter.blit(local_style->m_background, offset, eRect(), gPainter::BT_ALPHATEST); + else + painter.blit(local_style->m_background, offset, eRect(), 0); + } + else if (local_style->m_transparent_background) + ; + else + painter.clear(); + } + else + painter.clear(); +} + +static void clearRegionSelectedHelper(gPainter &painter, eListboxStyle *local_style, const ePoint &offset, ePyObject &pbackColorSelected) +{ + if (pbackColorSelected) + { + unsigned int color = PyInt_AsUnsignedLongMask(pbackColorSelected); + painter.setBackgroundColor(gRGB(color)); + painter.clear(); + } + else if (local_style) + { + if (local_style && local_style->m_background_color_selected_set) + painter.setBackgroundColor(local_style->m_background_color_selected); + if (local_style->m_background) + { + if (local_style->m_transparent_background) + painter.blit(local_style->m_background, offset, eRect(), gPainter::BT_ALPHATEST); + else + painter.blit(local_style->m_background, offset, eRect(), 0); + } + else if (local_style->m_transparent_background) + ; + else + painter.clear(); + } + else + 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) { if (selected && sel_clip.valid()) { @@ -521,18 +577,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l { painter.clip(part); style.setStyle(painter, eWindowStyle::styleListboxNormal); - if (pbackColor) - { - int color = PyInt_AsLong(pbackColor); - painter.setBackgroundColor(gRGB(color)); - } // transparent background? - // if we have a local background color set, use that. - else if (local_style && local_style->m_background_color_set) - painter.setBackgroundColor(local_style->m_background_color); - if (!pbackColor && local_style && local_style->m_transparent_background) - ; - else - painter.clear(); + clearRegionHelper(painter, local_style, offset, pbackColor); painter.clippop(); selected = 0; } @@ -541,54 +586,29 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l { painter.clip(part); style.setStyle(painter, eWindowStyle::styleListboxSelected); - if (pbackColorSelected) - { - 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(); + clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected); painter.clippop(); selected = 1; } } + else if (selected) + { + style.setStyle(painter, eWindowStyle::styleListboxSelected); + clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected); + if (local_style && local_style->m_selection) + painter.blit(local_style->m_selection, offset, eRect(), gPainter::BT_ALPHATEST); + } else { - if (selected) - { - style.setStyle(painter, eWindowStyle::styleListboxSelected); - if (pbackColorSelected) - { - 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 - { - style.setStyle(painter, eWindowStyle::styleListboxNormal); - if (pbackColor) - { - int color = PyInt_AsLong(pbackColor); - painter.setBackgroundColor(gRGB(color)); - }/* if we have a local background color set, use that. */ - else if (local_style && local_style->m_background_color_set) - painter.setBackgroundColor(local_style->m_background_color); - /* if we have no transparent background */ - if (!pbackColor && local_style && local_style->m_transparent_background) - ; - else - painter.clear(); - } + style.setStyle(painter, eWindowStyle::styleListboxNormal); + clearRegionHelper(painter, local_style, offset, pbackColor); } + if (selected) { if (pforeColorSelected) { - int color = PyInt_AsLong(pforeColorSelected); + unsigned int color = PyInt_AsUnsignedLongMask(pforeColorSelected); painter.setForegroundColor(gRGB(color)); } /* if we have a local foreground color set, use that. */ @@ -599,7 +619,7 @@ static void clearRegion(gPainter &painter, eWindowStyle &style, eListboxStyle *l { if (pforeColor) { - int color = PyInt_AsLong(pforeColor); + unsigned int color = PyInt_AsUnsignedLongMask(pforeColor); painter.setForegroundColor(gRGB(color)); } /* if we have a local foreground color set, use that. */ @@ -616,7 +636,7 @@ static ePyObject lookupColor(ePyObject color, ePyObject data) if ((!color) && (!data)) return color; - unsigned int icolor = PyInt_AsLong(color); + unsigned int icolor = PyInt_AsUnsignedLongMask(color); /* check if we have the "magic" template color */ if ((icolor & 0xFF000000) == 0xFF000000) @@ -645,7 +665,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c local_style = m_listbox->getLocalStyle(); painter.clip(itemregion); - clearRegion(painter, style, local_style, ePyObject(), ePyObject(), ePyObject(), ePyObject(), selected, itemregion, sel_clip); + clearRegion(painter, style, local_style, ePyObject(), ePyObject(), ePyObject(), ePyObject(), selected, itemregion, sel_clip, offset); ePyObject items, buildfunc_ret; @@ -779,6 +799,10 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c if (PyInt_Check(pstring) && data) /* if the string is in fact a number, it refers to the 'data' list. */ pstring = PyTuple_GetItem(data, PyInt_AsLong(pstring)); + /* don't do anything if we have 'None' as string */ + if (pstring == Py_None) + continue; + const char *string = (PyString_Check(pstring)) ? PyString_AsString(pstring) : ""; int x = PyInt_AsLong(px) + offset.x(); int y = PyInt_AsLong(py) + offset.y(); @@ -799,7 +823,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c { gRegion rc(rect); - clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip); + clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset); } painter.setFont(m_font[fnt]); @@ -813,7 +837,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c painter.clip(rect); if (pborderColor) { - int color = PyInt_AsLong(pborderColor); + unsigned int color = PyInt_AsUnsignedLongMask(pborderColor); painter.setForegroundColor(gRGB(color)); } @@ -898,7 +922,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c { gRegion rc(rect); - clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip); + clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset); } // border @@ -945,6 +969,10 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c if (PyInt_Check(ppixmap) && data) /* if the pixemap is in fact a number, it refers to the 'data' list. */ ppixmap = PyTuple_GetItem(data, PyInt_AsLong(ppixmap)); + /* don't do anything if we have 'None' as pixmap */ + if (ppixmap == Py_None) + continue; + int x = PyInt_AsLong(px) + offset.x(); int y = PyInt_AsLong(py) + offset.y(); int width = PyInt_AsLong(pwidth); @@ -967,7 +995,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c { gRegion rc(rect); - clearRegion(painter, style, local_style, ePyObject(), ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip); + clearRegion(painter, style, local_style, ePyObject(), ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip, offset); } painter.blit(pixmap, rect.topLeft(), rect, (type == TYPE_PIXMAP_ALPHATEST) ? gPainter::BT_ALPHATEST : 0); @@ -981,7 +1009,7 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c } } - if (selected) + if (selected && (sel_clip.valid() || (!local_style || !local_style->m_selection))) style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry); error_out: