add orBottomToTop, orRightToLeft, orLeftToRight(orHorizontal), orTopToBottom(OrVertic...
[enigma2.git] / lib / python / Components / Sources / List.py
index 82504401f866cf4a5531d3534f0aef17957348e1..26c68ab5a874f30ef6e29ab6eadb9e2d9b80bf9b 100644 (file)
@@ -16,6 +16,8 @@ to generate HTML."""
                self.item_height = item_height
                self.fonts = fonts
                self.disable_callbacks = False
+               self.enableWrapAround = enableWrapAround
+               self.__style = "default" # style might be an optional string which can be used to define different visualisations in the skin
 
        def setList(self, list):
                self.__list = list
@@ -26,6 +28,9 @@ to generate HTML."""
        def entry_changed(self, index):
                if not self.disable_callbacks:
                        self.downstream_elements.entry_changed(self, index)
+                       
+       def count(self):
+               return len(self.__list)
 
        def selectionChanged(self, index):
                if self.disable_callbacks:
@@ -43,6 +48,7 @@ to generate HTML."""
        def setIndex(self, index):
                if self.master is not None:
                        self.master.index = index
+                       self.selectionChanged(index)
 
        @cached
        def getIndex(self):
@@ -54,18 +60,38 @@ to generate HTML."""
        setCurrentIndex = setIndex
 
        index = property(getIndex, setIndex)
+       
+       def selectNext(self):
+               if self.getIndex() + 1 >= self.count():
+                       if self.enableWrapAround:
+                               self.index = 0
+               else:
+                       self.index += 1
+               self.setIndex(self.index)
+
+       def selectPrevious(self):
+               if self.getIndex() - 1 < 0:
+                       if self.enableWrapAround:
+                               self.index = self.count() - 1
+               else:
+                       self.index -= 1
+               self.setIndex(self.index)
+
+       @cached
+       def getStyle(self):
+               return self.__style
+
+       def setStyle(self, style):
+               self.__style = style
+               self.changed((self.CHANGED_SPECIFIC, "style"))
+
+       style = property(getStyle, setStyle)
 
        def updateList(self, list):
                """Changes the list without changing the selection or emitting changed Events"""
                assert len(list) == len(self.__list)
-               print "get old index"
                old_index = self.index
-               print "disable callback"
                self.disable_callbacks = True
-               print "set list"
                self.list = list
-               print "set index"
                self.index = old_index
-               print "reenable callbacks"
                self.disable_callbacks = False
-               print "done"