finally fix satfinder with new config
[enigma2.git] / lib / python / Components / GUIComponent.py
index 1476ba8393b02f0f6ae2da89916df7cff74acb96..414613066f9072c07d30ba1f74f5e8f644ae3b00 100644 (file)
@@ -2,15 +2,12 @@ import skin
 
 from enigma import ePoint
 
-class GUIComponent:
+class GUIComponent(object):
        """ GUI component """
        
-       SHOWN = 0
-       HIDDEN = 1
-       
        def __init__(self):
-               self.state = self.SHOWN
                self.instance = None
+               self.visible = 1
        
        def execBegin(self):
                pass
@@ -18,9 +15,18 @@ class GUIComponent:
        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 self.state == self.HIDDEN:
+               if not self.visible:
                        self.instance.hide()
                skin.applyAllAttributes(self.instance, desktop, self.skinAttributes)
 
@@ -28,11 +34,51 @@ class GUIComponent:
                self.instance.move(ePoint(int(x), int(y)))
 
        def show(self):
-               self.state = self.SHOWN
+               self.__visible = 1
                if self.instance is not None:
                        self.instance.show()
 
        def hide(self):
-               self.state = self.HIDDEN
+               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