X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FComponents%2FGUIComponent.py;h=401a004da350b9f5bd1fc1988b2cb827d2573850;hp=bcd99d245e86fc32fb9a08e5b09b5d7c993d14ad;hb=67b53c1cb06988394c35a6e965c99b72b67fe1be;hpb=aa3e781f31a04223416f0a34b25ab95fc0bef429 diff --git a/lib/python/Components/GUIComponent.py b/lib/python/Components/GUIComponent.py index bcd99d2..401a004 100644 --- a/lib/python/Components/GUIComponent.py +++ b/lib/python/Components/GUIComponent.py @@ -1,12 +1,100 @@ -class GUIComponent: - """ GUI component """ +import skin + +from enigma import ePoint +class GUIComponent(object): + """ GUI component """ + def __init__(self): - pass - + self.instance = None + self.visible = 1 + self.skinAttributes = None + def execBegin(self): pass def execEnd(self): pass + + def onShow(self): + pass + + def onHide(self): + pass + + def destroy(self): + self.__dict__.clear() + + # this works only with normal widgets - if you don't have self.instance, override this. + def applySkin(self, desktop): + if not self.visible: + self.instance.hide() + + if self.skinAttributes is None: + print "warning, skin is missing some elements." + return + + skin.applyAllAttributes(self.instance, desktop, self.skinAttributes) + + def move(self, x, y = None): + # we assume, that x is already an ePoint + if y is None: + self.instance.move(x) + else: + self.instance.move(ePoint(int(x), int(y))) + + def resize(self, size): + self.instance.resize(size) + + def setZPosition(self, z): + self.instance.setZPosition(z) + + def show(self): + self.__visible = 1 + if self.instance is not None: + self.instance.show() + + def hide(self): + self.__visible = 0 + if self.instance is not None: + self.instance.hide() + + def getVisible(self): + return self.__visible + + def setVisible(self, visible): + if visible: + self.show() + else: + self.hide() + + visible = property(getVisible, setVisible) + + def setPosition(self, x, y): + self.instance.move(ePoint(int(x), int(y))) + def getPosition(self): + p = self.instance.position() + return (p.x(), p.y()) + + position = property(getPosition, setPosition) + + # default implementation for only one widget per component + # feel free to override! + def GUIcreate(self, parent): + self.instance = self.createWidget(parent) + self.postWidgetCreate(self.instance) + + def GUIdelete(self): + self.preWidgetRemove(self.instance) + self.instance = None + + # default for argumentless widget constructor + def createWidget(self, parent): + return self.GUI_WIDGET(parent) + + def postWidgetCreate(self, instance): + pass + + def preWidgetRemove(self, instance): + pass