except:
pass
+ # DIESER KOMMENTAR IST NUTZLOS UND MITTLERWEILE VERALTET! (glaub ich)
+ # BITTE NICHT LESEN!
# note: you'll probably run into this assert. if this happens, don't panic!
# yes, it's evil. I told you that programming in python is just fun, and
# suddently, you have to care about things you don't even know.
self.instance.setContent(None)
del self.instance
+
+# temp stuff :)
+class configBoolean:
+ def __init__(self, reg):
+ self.reg = reg
+ self.val = 0
+
+ def toggle(self):
+ self.val += 1
+ self.val %= 3
+
+ def __str__(self):
+ return ("NO", "YES", "MAYBE")[self.val]
+
+class configValue:
+ def __init__(self, obj):
+ self.obj = obj
+
+ def __str__(self):
+ return self.obj
+
+def configEntry(obj):
+ # das hier ist ein zugriff auf die registry...
+ if obj == "HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/SDTV/FLASHES/GREEN":
+ return ("SDTV green flashes", configBoolean(obj))
+ elif obj == "HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/HDTV/FLASHES/GREEN":
+ return ("HDTV reen flashes", configBoolean(obj))
+ else:
+ return ("invalid", "")
+
+class ConfigList(HTMLComponent, GUIComponent):
+ def __init__(self, list):
+ GUIComponent.__init__(self)
+ self.l = eListboxPythonConfigContent()
+ self.l.setList(list)
+ self.l.setSeperation(100)
+
+ def toggle(self):
+ selection = self.getCurrent()
+ selection[1].toggle()
+ self.invalidateCurrent()
+
+ def getCurrent(self):
+ return self.l.getCurrentSelection()
+
+ def invalidateCurrent(self):
+ self.l.invalidateEntry(self.l.getCurrentSelectionIndex())
+
+ def GUIcreate(self, parent, skindata):
+ self.instance = eListbox(parent)
+ self.instance.setContent(self.l)
+
+ def GUIdelete(self):
+ self.instance.setContent(None)
+ del self.instance
+
class ServiceList(HTMLComponent, GUIComponent):
def __init__(self):
GUIComponent.__init__(self)
}
//////////////////////////////////////
+
+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);
+}
+
void setList(PyObject *list);
PyObject *getCurrentSelection();
+ int getCurrentSelectionIndex() { return m_cursor; }
#ifndef SWIG
protected:
void cursorHome();
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
def close(self, retval=None):
self.session.close()
+class configTest(Screen):
+
+ def __init__(self, session):
+ Screen.__init__(self, session)
+
+
+ self["config"] = ConfigList(
+ [
+ configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/SDTV/FLASHES/GREEN"),
+ configEntry("HKEY_LOCAL_ENIGMA/IMPORTANT/USER_ANNOYING_STUFF/HDTV/FLASHES/GREEN"),
+ ])
+
+ self["actions"] = ActionMap(["OkCancelActions"],
+ {
+ "ok": self["config"].toggle,
+ "cancel": self.close
+ })
+
+
class mainMenu(Screen):
- def goEmu(self):
- self["title"].setText("EMUs ARE ILLEGAL AND NOT SUPPORTED!")
+ def goSetup(self):
+ self.session.open(configTest)
def goTimeshift(self):
self["title"].setText("JUST PRESS THE YELLOW BUTTON!")
("Close Main Menu", self.close),
("Service Scan", self.goScan),
("Quit", quitMainloop),
- ("EMU SETUP", self.goEmu),
+ ("setup", self.goSetup),
("TIMESHIFT SETUP", self.goTimeshift),
("HDTV PIP CONFIG", self.goHDTV),
("wie spaet ists?!", self.goClock)
<widget name="title" position="10,10" size="280,20" />
<widget name="menu" position="10,30" size="280,140" />
</screen>
+ <screen name="configTest" position="300,100" size="300,300" title="config menu">
+ <widget name="config" position="10,30" size="280,140" />
+ </screen>
<screen name="clockDisplay" position="300,100" size="300,300">
<widget name="okbutton" position="10,10" size="280,40" />
<widget name="title" position="10,120" size="280,50" />