aboutsummaryrefslogtreecommitdiff
path: root/lib/gui
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2005-04-25 23:12:23 +0000
committerFelix Domke <tmbinc@elitedvb.net>2005-04-25 23:12:23 +0000
commit9a1eb9bbf5d26648c761459ec7019f9c6eae24d7 (patch)
treed6384b47ed3a64f8d5e474b4253f190d3da8782c /lib/gui
parent949a07352f59a32a5ae00f30650a6d067ef59b77 (diff)
downloadenigma2-9a1eb9bbf5d26648c761459ec7019f9c6eae24d7.tar.gz
enigma2-9a1eb9bbf5d26648c761459ec7019f9c6eae24d7.zip
- add new listbox content type for multiple strings
- add first version of config class - a bit ugly
Diffstat (limited to 'lib/gui')
-rw-r--r--lib/gui/elistboxcontent.cpp51
-rw-r--r--lib/gui/elistboxcontent.h15
2 files changed, 64 insertions, 2 deletions
diff --git a/lib/gui/elistboxcontent.cpp b/lib/gui/elistboxcontent.cpp
index 209b5250..d51729d2 100644
--- a/lib/gui/elistboxcontent.cpp
+++ b/lib/gui/elistboxcontent.cpp
@@ -378,3 +378,54 @@ PyObject *eListboxPythonStringContent::getCurrentSelection()
}
//////////////////////////////////////
+
+void eListboxPythonConfigContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected)
+{
+ ePtr<gFont> fnt = new gFont("Arial", 14);
+ ePtr<gFont> fnt2 = new gFont("Arial", 16);
+ painter.clip(eRect(offset, m_itemsize));
+ style.setStyle(painter, selected ? eWindowStyle::styleListboxSelected : eWindowStyle::styleListboxNormal);
+ painter.clear();
+
+ if (m_list && cursorValid())
+ {
+ PyObject *item = PyList_GetItem(m_list, m_cursor); // borrowed reference!
+ PyObject *text = 0, *value = 0;
+ painter.setFont(fnt);
+
+ /* the user can supply tuples, in this case the first one will be displayed. */
+ if (PyTuple_Check(item))
+ {
+ text = PyTuple_GetItem(item, 0);
+ value = PyTuple_GetItem(item, 1);
+ }
+
+ text = PyObject_Str(text);
+ value = PyObject_Str(value);
+
+ const char *string = (text && PyString_Check(text)) ? PyString_AsString(text) : "<not-a-string>";
+ const char *string_val = (value && PyString_Check(value)) ? PyString_AsString(value) : "<not-a-string>";
+
+ eSize item_left = eSize(m_seperation, m_itemsize.height());
+ eSize item_right = eSize(m_itemsize.width() - m_seperation, m_itemsize.height());
+
+ painter.renderText(eRect(offset, item_left), string, gPainter::RT_HALIGN_LEFT);
+
+ painter.setFont(fnt2);
+ painter.renderText(eRect(offset + eSize(m_seperation, 0), item_right), string_val, gPainter::RT_HALIGN_RIGHT);
+
+ Py_XDECREF(text);
+ Py_XDECREF(value);
+
+ if (selected)
+ style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry);
+ }
+
+ painter.clippop();
+}
+
+void eListboxPythonConfigContent::invalidateEntry(int index)
+{
+ m_listbox->entryChanged(index);
+}
+
diff --git a/lib/gui/elistboxcontent.h b/lib/gui/elistboxcontent.h
index a2e1fd36..0c4cb001 100644
--- a/lib/gui/elistboxcontent.h
+++ b/lib/gui/elistboxcontent.h
@@ -82,6 +82,7 @@ public:
void setList(PyObject *list);
PyObject *getCurrentSelection();
+ int getCurrentSelectionIndex() { return m_cursor; }
#ifndef SWIG
protected:
void cursorHome();
@@ -101,13 +102,23 @@ protected:
void setSize(const eSize &size);
/* the following functions always refer to the selected item */
- void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected);
+ virtual void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected);
-private:
+protected:
PyObject *m_list;
int m_cursor, m_saved_cursor;
eSize m_itemsize;
#endif
};
+class eListboxPythonConfigContent: public eListboxPythonStringContent
+{
+public:
+ void paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected);
+ void invalidateEntry(int index);
+ void setSeperation(int sep) { m_seperation = sep; }
+private:
+ int m_seperation;
+};
+
#endif