X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fgui%2Felistboxcontent.cpp;h=97e2cc67787fe53e65a2fd782eba594df2d1183e;hp=4465d84c1e28250c1e40061959f57ead8973afd9;hb=c46808cedb700ae515a8a12b0d122dae83d68800;hpb=98c7a787df63a93f868548c2b1e357c0d873ebbe diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp index 4465d84..97e2cc6 100644 --- a/lib/gui/elistboxcontent.cpp +++ b/lib/gui/elistboxcontent.cpp @@ -49,7 +49,8 @@ int iListboxContent::currentCursorSelectable() DEFINE_REF(eListboxPythonStringContent); -eListboxPythonStringContent::eListboxPythonStringContent(): m_itemheight(25), m_cursor(0) +eListboxPythonStringContent::eListboxPythonStringContent() + :m_cursor(0), m_itemheight(25) { } @@ -81,7 +82,7 @@ int eListboxPythonStringContent::cursorMove(int count) int eListboxPythonStringContent::cursorValid() { - return ((unsigned int)m_cursor) < size(); + return m_cursor < size(); } int eListboxPythonStringContent::cursorSet(int n) @@ -342,7 +343,6 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style, if (PyTuple_Check(item)) { /* handle left part. get item from tuple, convert to string, display. */ - text = PyTuple_GET_ITEM(item, 0); text = PyObject_Str(text); /* creates a new object - old object was borrowed! */ const char *string = (text && PyString_Check(text)) ? PyString_AsString(text) : ""; @@ -356,7 +356,9 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style, int value_alignment_left = !*string; /* now, handle the value. get 2nd part from tuple*/ - value = PyTuple_GET_ITEM(item, 1); + if (PyTuple_Size(item) >= 2) // when no 2nd entry is in tuple this is a non selectable entry without config part + value = PyTuple_GET_ITEM(item, 1); + if (value) { ePyObject args = PyTuple_New(1); @@ -467,7 +469,7 @@ void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style, } } /* type is borrowed */ - } else + } else if (value) eWarning("eListboxPythonConfigContent: second value of tuple is not a tuple."); if (value) Py_DECREF(value); @@ -855,6 +857,10 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c } break; } + case TYPE_PROGRESS_PIXMAP: // Progress + /* + (1, x, y, width, height, filled_percent, pixmap [, borderWidth, foreColor, backColor, backColorSelected] ) + */ case TYPE_PROGRESS: // Progress { /* @@ -865,41 +871,55 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c pwidth = PyTuple_GET_ITEM(item, 3), pheight = PyTuple_GET_ITEM(item, 4), pfilled_perc = PyTuple_GET_ITEM(item, 5), - pborderWidth, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected; - - if (!(px && py && pwidth && pheight && pfilled_perc)) + ppixmap, pborderWidth, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected; + int idx = 6; + if (type == TYPE_PROGRESS) { - eDebug("eListboxPythonMultiContent received too small tuple (must be (TYPE_PROGRESS, x, y, width, height, filled percent [,border width, foreColor, backColor, backColorSelected]))"); - goto error_out; + if (!(px && py && pwidth && pheight && pfilled_perc)) + { + eDebug("eListboxPythonMultiContent received too small tuple (must be (TYPE_PROGRESS, x, y, width, height, filled percent [,border width, foreColor, backColor, backColorSelected]))"); + goto error_out; + } + } + else + { + ppixmap = PyTuple_GET_ITEM(item, idx++); + if (ppixmap == Py_None) + continue; + if (!(px && py && pwidth && pheight && pfilled_perc, ppixmap)) + { + eDebug("eListboxPythonMultiContent received too small tuple (must be (TYPE_PROGRESS_PIXMAP, x, y, width, height, filled percent, pixmap, [,border width, foreColor, backColor, backColorSelected]))"); + goto error_out; + } } - if (size > 6) + if (size > idx) { - pborderWidth = PyTuple_GET_ITEM(item, 6); + pborderWidth = PyTuple_GET_ITEM(item, idx++); if (pborderWidth == Py_None) pborderWidth = ePyObject(); } - if (size > 7) + if (size > idx) { - pforeColor = PyTuple_GET_ITEM(item, 7); + pforeColor = PyTuple_GET_ITEM(item, idx++); if (pforeColor == Py_None) pforeColor = ePyObject(); } - if (size > 8) + if (size > idx) { - pforeColorSelected = PyTuple_GET_ITEM(item, 8); + pforeColorSelected = PyTuple_GET_ITEM(item, idx++); if (pforeColorSelected == Py_None) pforeColorSelected=ePyObject(); } - if (size > 9) + if (size > idx) { - pbackColor = PyTuple_GET_ITEM(item, 9); + pbackColor = PyTuple_GET_ITEM(item, idx++); if (pbackColor == Py_None) pbackColor=ePyObject(); } - if (size > 10) + if (size > idx) { - pbackColorSelected = PyTuple_GET_ITEM(item, 10); + pbackColorSelected = PyTuple_GET_ITEM(item, idx++); if (pbackColorSelected == Py_None) pbackColorSelected=ePyObject(); } @@ -941,12 +961,27 @@ void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, c rect.setRect(x+width-bwidth, y+bwidth, bwidth, height-bwidth); painter.fill(rect); - // progress rect.setRect(x+bwidth, y+bwidth, (width-bwidth*2) * filled / 100, height-bwidth*2); - painter.fill(rect); - painter.clippop(); + // progress + if (ppixmap) + { + ePtr pixmap; + if (PyInt_Check(ppixmap) && data) /* if the pixmap is in fact a number, it refers to the data list */ + ppixmap = PyTuple_GetItem(data, PyInt_AsLong(ppixmap)); + if (SwigFromPython(pixmap, ppixmap)) + { + eDebug("eListboxPythonMultiContent (Pixmap) get pixmap failed"); + painter.clippop(); + continue; + } + painter.blit(pixmap, rect.topLeft(), rect, 0); + } + else + painter.fill(rect); + + painter.clippop(); break; } case TYPE_PIXMAP_ALPHABLEND: