+ gRegion part = rc - sel_clip;
+ if (!part.empty())
+ {
+ painter.clip(part);
+ style.setStyle(painter, eWindowStyle::styleListboxNormal);
+ clearRegionHelper(painter, local_style, offset, pbackColor, cursorValid);
+ painter.clippop();
+ selected = 0;
+ }
+ part = rc & sel_clip;
+ if (!part.empty())
+ {
+ painter.clip(part);
+ style.setStyle(painter, eWindowStyle::styleListboxSelected);
+ clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid);
+ painter.clippop();
+ selected = 1;
+ }
+ }
+ else if (selected)
+ {
+ style.setStyle(painter, eWindowStyle::styleListboxSelected);
+ clearRegionSelectedHelper(painter, local_style, offset, pbackColorSelected, cursorValid);
+ 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);
+ }
+
+ if (selected)
+ {
+ if (pforeColorSelected)
+ {
+ unsigned int color = PyInt_AsUnsignedLongMask(pforeColorSelected);
+ 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)
+ {
+ unsigned int color = PyInt_AsUnsignedLongMask(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);
+ }
+}
+
+static ePyObject lookupColor(ePyObject color, ePyObject data)
+{
+ if (color == Py_None)
+ return ePyObject();
+
+ if ((!color) && (!data))
+ return color;
+
+ unsigned int icolor = PyInt_AsUnsignedLongMask(color);
+
+ /* check if we have the "magic" template color */
+ if ((icolor & 0xFF000000) == 0xFF000000)
+ {
+ int index = icolor & 0xFFFFFF;
+ eDebug("[eListboxPythonMultiContent] template color index: %d", index);
+ return PyTuple_GetItem(data, index);
+ }
+
+ if (color == Py_None)
+ return ePyObject();
+
+ return color;
+}
+
+void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
+{
+ gRegion itemregion(eRect(offset, m_itemsize));
+ eListboxStyle *local_style = 0;
+ eRect sel_clip(m_selection_clip);
+ bool cursorValid = this->cursorValid();
+ if (sel_clip.valid())
+ sel_clip.moveBy(offset);
+
+ /* get local listbox style, if present */
+ if (m_listbox)
+ local_style = m_listbox->getLocalStyle();
+
+ painter.clip(itemregion);
+ clearRegion(painter, style, local_style, ePyObject(), ePyObject(), ePyObject(), ePyObject(), selected, itemregion, sel_clip, offset, cursorValid);
+
+ ePyObject items, buildfunc_ret;
+
+ if (m_list && cursorValid)
+ {
+ /* a multicontent list can be used in two ways:
+ either each item is a list of (TYPE,...)-tuples,
+ or there is a template defined, which is a list of (TYPE,...)-tuples,
+ and the list is an unformatted tuple. The template then references items from the list.
+ */
+ items = PyList_GET_ITEM(m_list, m_cursor); // borrowed reference!
+
+ if (m_buildFunc)
+ {
+ if (PyCallable_Check(m_buildFunc)) // when we have a buildFunc then call it
+ {
+ if (PyTuple_Check(items))
+ buildfunc_ret = items = PyObject_CallObject(m_buildFunc, items);
+ else
+ eDebug("items is no tuple");
+ }
+ else
+ eDebug("buildfunc is not callable");
+ }
+