add support for up to 128 LNBs
[enigma2.git] / lib / python / Components / SelectionList.py
1 from MenuList import MenuList
2 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
3 from enigma import eListboxPythonMultiContent, eListbox, gFont, RT_HALIGN_LEFT
4 from Tools.LoadPixmap import LoadPixmap
5
6 selectionpng = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/selectioncross.png"))
7
8 def SelectionEntryComponent(description, value, index, selected):
9         res = [ (description, value, index, selected) ]
10         res.append((eListboxPythonMultiContent.TYPE_TEXT, 30, 3, 500, 30, 0, RT_HALIGN_LEFT, description))
11         if selected:
12                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 30, selectionpng))
13         return res
14
15 class SelectionList(MenuList):
16         def __init__(self, list = None, enableWrapAround = False):
17                 MenuList.__init__(self, list or [], enableWrapAround, content = eListboxPythonMultiContent)
18                 self.l.setFont(0, gFont("Regular", 20))
19                 self.l.setItemHeight(30)
20
21         def addSelection(self, description, value, index, selected = True):
22                 self.list.append(SelectionEntryComponent(description, value, index, selected))
23                 self.setList(self.list)
24
25         def toggleSelection(self):
26                 item = self.list[self.getSelectedIndex()][0]
27                 self.list[self.getSelectedIndex()] = SelectionEntryComponent(item[0], item[1], item[2], not item[3])
28                 self.setList(self.list)
29
30         def getSelectionsList(self):
31                 list = []
32                 for item in self.list:
33                         if item[0][3]:
34                                 list.append((item[0][0], item[0][1], item[0][2]))
35                 return list