cut away 1/4th of enigma loading time by loading languages when they are used
[enigma2.git] / lib / python / Components / GUIComponent.py
index c3edaa737241dbdb11a5623ad1ae5184bb2402e0..a3b1b9e198dea2830af46ebb46259344e90b202a 100644 (file)
@@ -5,12 +5,13 @@ from enigma import ePoint
 class GUIComponent(object):
        """ GUI component """
        
-       SHOWN = 0
-       HIDDEN = 1
-       
        def __init__(self):
                self.instance = None
-               self.state = self.SHOWN
+               self.onVisibilityChange = [ ]
+               self.__visible = 0
+               self.visible = 1
+               self.skinAttributes = None
+               self.deprecationInfo = None
        
        def execBegin(self):
                pass
@@ -29,33 +30,56 @@ class GUIComponent(object):
        
        # 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()
+               
+               if self.skinAttributes is None:
+                       return False
+
                skin.applyAllAttributes(self.instance, desktop, self.skinAttributes)
+               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, size):
+               self.instance.resize(size)
+               
+       def setZPosition(self, z):
+               self.instance.setZPosition(z)
 
        def show(self):
-               self.__state = self.SHOWN
+               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):
-               self.__state = self.HIDDEN
+               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 getState(self):
-               return self.__state
+       def getVisible(self):
+               return self.__visible
        
-       def setState(self, state):
-               if state == self.SHOWN:
+       def setVisible(self, visible):
+               if visible:
                        self.show()
-               elif state == self.HIDDEN:
+               else:
                        self.hide()
 
-       state = property(getState, setState)
+       visible = property(getVisible, setVisible)
 
        def setPosition(self, x, y):
                self.instance.move(ePoint(int(x), int(y)))