X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/129435aa2331ed21d08baea536d5915d287fd472..d8bb70354594dddb6ef28f6d41ce733bd9caf4e6:/lib/python/Components/GUIComponent.py?ds=sidebyside diff --git a/lib/python/Components/GUIComponent.py b/lib/python/Components/GUIComponent.py index 1f4c1e4f..7e1bafb9 100644 --- a/lib/python/Components/GUIComponent.py +++ b/lib/python/Components/GUIComponent.py @@ -1,14 +1,17 @@ import skin -from enigma import ePoint +from enigma import ePoint, eSize class GUIComponent(object): """ GUI component """ def __init__(self): self.instance = None + self.onVisibilityChange = [ ] + self.__visible = 0 self.visible = 1 self.skinAttributes = None + self.deprecationInfo = None def execBegin(self): pass @@ -26,28 +29,51 @@ class GUIComponent(object): self.__dict__.clear() # this works only with normal widgets - if you don't have self.instance, override this. - def applySkin(self, desktop): + def applySkin(self, desktop, parent): if not self.visible: self.instance.hide() if self.skinAttributes is None: - print "warning, skin is missing some elements." - return + return False - skin.applyAllAttributes(self.instance, desktop, self.skinAttributes) + skin.applyAllAttributes(self.instance, desktop, self.skinAttributes, parent.scale) + return True - def move(self, x, y): - self.instance.move(ePoint(int(x), int(y))) + 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, x, y = None): + self.width = x + self.height = y + if y is None: + self.instance.resize(x) + else: + self.instance.resize(eSize(int(x), int(y))) + + def setZPosition(self, z): + self.instance.setZPosition(z) def show(self): + old = self.__visible self.__visible = 1 if self.instance is not None: self.instance.show() + if old != self.__visible: + for fnc in self.onVisibilityChange: + fnc(True) def hide(self): + old = self.__visible self.__visible = 0 if self.instance is not None: self.instance.hide() + if old != self.__visible: + for fnc in self.onVisibilityChange: + fnc(False) def getVisible(self): return self.__visible @@ -66,6 +92,12 @@ class GUIComponent(object): def getPosition(self): p = self.instance.position() return (p.x(), p.y()) + + def getWidth(self): + return self.width + + def getHeight(self): + return self.height position = property(getPosition, setPosition)