Allow playback of VCD (Video CD) and SVCD
[enigma2.git] / lib / python / Components / Renderer / Canvas.py
1 from Renderer import Renderer
2
3 from enigma import eCanvas, eRect, gRGB
4
5 class Canvas(Renderer):
6         GUI_WIDGET = eCanvas
7
8         def __init__(self):
9                 Renderer.__init__(self)
10                 self.sequence = None
11                 self.draw_count = 0
12
13         def pull_updates(self):
14                 if self.instance is None:
15                         return
16
17                 # do an incremental update
18                 list = self.source.drawlist
19                 if list is None:
20                         return
21
22                 # if the lists sequence count changed, re-start from begin
23                 if list[0] != self.sequence:
24                         self.sequence = list[0]
25                         self.draw_count = 0
26
27                 self.draw(list[1][self.draw_count:])
28                 self.draw_count = len(list[1])
29
30         def draw(self, list):
31                 for l in list:
32                         if l[0] == 1:
33                                 self.instance.fillRect(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]))
34                         elif l[0] == 2:
35                                 self.instance.writeText(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]), gRGB(l[6]), l[7], l[8], l[9])
36                         else:
37                                 print "drawlist entry:", l
38                                 raise "invalid drawlist entry"
39
40         def changed(self, what):
41                 self.pull_updates()
42
43         def postWidgetCreate(self, instance):
44                 self.sequence = None
45
46                 from enigma import eSize
47
48                 def parseSize(str):
49                         x, y = str.split(',')
50                         return eSize(int(x), int(y))
51
52                 for (attrib, value) in self.skinAttributes:
53                         if attrib == "size":
54                                 self.instance.setSize(parseSize(value))
55
56                 self.pull_updates()