one empty line
[enigma2.git] / lib / python / Components / ServiceList.py
1 from HTMLComponent import *
2 from GUIComponent import *
3
4 from enigma import *
5
6 class ServiceList(HTMLComponent, GUIComponent):
7
8         MODE_NORMAL = 0
9         MODE_FAVOURITES = 1
10         
11         def __init__(self):
12                 GUIComponent.__init__(self)
13                 self.l = eListboxServiceContent()
14                 
15         def getCurrent(self):
16                 r = eServiceReference()
17                 self.l.getCurrent(r)
18                 return r
19                 
20         def moveUp(self):
21                 self.instance.moveSelection(self.instance.moveUp)
22
23         def moveDown(self):
24                 self.instance.moveSelection(self.instance.moveDown)
25
26         def GUIcreate(self, parent):
27                 self.instance = eListbox(parent)
28                 self.instance.setContent(self.l)
29         
30         def GUIdelete(self):
31                 self.instance = None
32
33         def setRoot(self, root):
34                 self.l.setRoot(root)
35                 
36                 # mark stuff
37         def clearMarked(self):
38                 self.l.clearMarked()
39                 
40         def clearMarks(self):
41                 self.l.initMarked()
42         
43         def isMarked(self, ref):
44                 return self.l.isMarked(ref)
45
46         def addMarked(self, ref):
47                 self.l.addMarked(ref)
48         
49         def removeMarked(self, ref):
50                 self.l.removeMarked(ref)
51
52         def getMarked(self):
53                 i = self.l
54                 i.markedQueryStart()
55                 ref = eServiceReference()
56                 marked = [ ]
57                 while i.markedQueryNext(ref) == 0:
58                         marked.append(ref)
59                         ref = eServiceReference()
60
61                 return marked
62
63         def setMode(self, mode):
64                 if mode == self.MODE_NORMAL:
65                         self.instance.setItemHeight(20)
66                         self.l.setVisualMode(eListboxServiceContent.visModeSimple)
67                 else:
68                         self.instance.setItemHeight(40)
69                         self.l.setElementFont(self.l.celServiceName, gFont("Arial", 30))
70                         self.l.setElementPosition(self.l.celServiceName, eRect(40, 0, self.instance.size().width(), 40))
71                         self.l.setElementFont(self.l.celServiceNumber, gFont("Arial", 20))
72                         self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 10, 40, 30))
73
74                         self.l.setVisualMode(eListboxServiceContent.visModeComplex)