add ability to remove list and config from a wizard
[enigma2.git] / lib / python / Components / Pixmap.py
index a98fef14f0163a0b98a9275c9b2a4c9b8b12634a..211b772c2be02edd02c9b348ea1b7c069e6f69f0 100644 (file)
@@ -1,51 +1,89 @@
-import skin
+from ConditionalWidget import *
 
 from enigma import *
 
-class Pixmap:
-       """Pixmap can be used for components which diplay a pixmap"""
-       
+class Pixmap(Widget):
        def __init__(self):
-               self.instance = None
-       
-       def GUIcreate(self, parent):
-               self.instance = self.createWidget(parent)
-       
-       def GUIdelete(self):
-               self.removeWidget(self.instance)
-               self.instance = None
-       
+               Widget.__init__(self)
+
        def getePixmap(self, parent):
                #pixmap = ePixmap(parent)
                #pixmap.setPixmapFromFile(self.filename)
                return ePixmap(parent)
        
-       def removeWidget(self, instance):
+       def createWidget(self, parent):
+               return self.getePixmap(parent)
+
+       def removeWidget(self, w):
                pass
 
-class PixmapConditional(Pixmap):
+class PixmapConditional(ConditionalWidget, Pixmap):
        def __init__(self, withTimer = True):
+               ConditionalWidget.__init__(self)
+               Pixmap.__init__(self)
+
+class MovingPixmap(Pixmap):
+       def __init__(self):
                Pixmap.__init__(self)
                
-               if (withTimer):
-                       self.conditionCheckTimer = eTimer()
-                       self.conditionCheckTimer.timeout.get().append(self.update)
-                       self.conditionCheckTimer.start(1000)
+               self.moving = False
                
-       def setConnect(self, conditionalFunction):
-               self.conditionalFunction = conditionalFunction
+               # TODO: get real values
+               self.x = 0.0
+               self.y = 0.0
                
-       def activateCondition(self, condition):
-               if (condition):
-                       self.instance.hide()
-               else:
-                       self.instance.show()
+               self.clearPath()
+               
+               self.moveTimer = eTimer()
+               self.moveTimer.timeout.get().append(self.doMove)
+               
+       def clearPath(self, repeated = False):
+               if (self.moving):
+                       self.moving = False
+                       self.moveTimer.stop()
+                       
+               self.path = []
+               self.currDest = 0
+               self.repeated = repeated
+               
+       def addMovePoint(self, x, y, time = 20):
+               self.path.append((x, y, time))
+       
+       def moveTo(self, x, y, time = 20):
+               self.clearPath()
+               self.addMovePoint(x, y, time)
+               
+       def startMoving(self):
+               if not self.moving:
+                       self.time = self.path[self.currDest][2]
+                       self.stepX = (self.path[self.currDest][0] - self.x) / float(self.time)
+                       self.stepY = (self.path[self.currDest][1] - self.y) / float(self.time)
 
-       def update(self):
+                       self.moving = True
+                       self.moveTimer.start(100)
+                       
+       def stopMoving(self):
+               self.moving = False
+               self.moveTimer.stop()
+               
+       def doMove(self):
+               self.x += self.stepX
+               self.y += self.stepY
+               self.time -= 1
                try:
-                       self.conditionalFunction() # check, if the conditionalfunction is still valid
-               except:
-                       self.conditionalFunction = None
-                       self.activateCondition(False)
+                       self.move(int(self.x), int(self.y))
+               except: # moving not possible... widget not there any more... stop moving
+                       self.stopMoving()
                        
-               self.activateCondition(self.conditionalFunction())
+               if (self.time == 0):
+                       self.currDest += 1
+                       self.moveTimer.stop()
+                       self.moving = False
+                       if (self.currDest >= len(self.path)): # end of path
+                               if (self.repeated):
+                                       self.currDest = 0
+                                       self.moving = False
+                                       self.startMoving()
+                       else:
+                               self.moving = False
+                               self.startMoving()