add some extension-icons
[enigma2.git] / lib / python / Components / Pixmap.py
1 from ConditionalWidget import *
2
3 from enigma import *
4
5 class Pixmap(Widget):
6         def __init__(self):
7                 Widget.__init__(self)
8
9         def getePixmap(self, parent):
10                 #pixmap = ePixmap(parent)
11                 #pixmap.setPixmapFromFile(self.filename)
12                 return ePixmap(parent)
13         
14         def createWidget(self, parent):
15                 return self.getePixmap(parent)
16
17         def removeWidget(self, w):
18                 pass
19
20 class PixmapConditional(ConditionalWidget, Pixmap):
21         def __init__(self, withTimer = True):
22                 ConditionalWidget.__init__(self)
23                 Pixmap.__init__(self)
24
25 class MovingPixmap(Pixmap):
26         def __init__(self):
27                 Pixmap.__init__(self)
28                 
29                 self.moving = False
30                 
31                 # TODO: get real values
32                 self.x = 0.0
33                 self.y = 0.0
34                 
35                 self.clearPath()
36                 
37                 self.moveTimer = eTimer()
38                 self.moveTimer.timeout.get().append(self.doMove)
39                 
40         def clearPath(self, repeated = False):
41                 if (self.moving):
42                         self.moving = False
43                         self.moveTimer.stop()
44                         
45                 self.path = []
46                 self.currDest = 0
47                 self.repeated = repeated
48                 
49         def addMovePoint(self, x, y, time = 20):
50                 self.path.append((x, y, time))
51         
52         def moveTo(self, x, y, time = 20):
53                 self.clearPath()
54                 self.addMovePoint(x, y, time)
55                 
56         def startMoving(self):
57                 if not self.moving:
58                         self.time = self.path[self.currDest][2]
59                         self.stepX = (self.path[self.currDest][0] - self.x) / float(self.time)
60                         self.stepY = (self.path[self.currDest][1] - self.y) / float(self.time)
61
62                         self.moving = True
63                         self.moveTimer.start(100)
64                         
65         def stopMoving(self):
66                 self.moving = False
67                 self.moveTimer.stop()
68                 
69         def doMove(self):
70                 self.x += self.stepX
71                 self.y += self.stepY
72                 self.time -= 1
73                 try:
74                         self.move(int(self.x), int(self.y))
75                 except: # moving not possible... widget not there any more... stop moving
76                         self.stopMoving()
77                         
78                 if (self.time == 0):
79                         self.currDest += 1
80                         self.moveTimer.stop()
81                         self.moving = False
82                         if (self.currDest >= len(self.path)): # end of path
83                                 if (self.repeated):
84                                         self.currDest = 0
85                                         self.moving = False
86                                         self.startMoving()
87                         else:
88                                 self.moving = False
89                                 self.startMoving()