generic show/hide support for GUIComponents
authorFelix Domke <tmbinc@elitedvb.net>
Fri, 24 Feb 2006 14:14:57 +0000 (14:14 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Fri, 24 Feb 2006 14:14:57 +0000 (14:14 +0000)
lib/python/Components/ConditionalWidget.py
lib/python/Components/GUIComponent.py
lib/python/Components/GUISkin.py
lib/python/Components/Input.py
lib/python/Components/Label.py
lib/python/Screens/EpgSelection.py
lib/python/Screens/HelpMenu.py

index b77d865..07d59e0 100644 (file)
@@ -4,17 +4,13 @@ from GUIComponent import *
 from enigma import *
 
 class Widget(GUIComponent):
 from enigma import *
 
 class Widget(GUIComponent):
-       
-       SHOWN = 0
-       HIDDEN = 1
-       
        def __init__(self):
                GUIComponent.__init__(self)
        def __init__(self):
                GUIComponent.__init__(self)
-               self.instance = None
-               self.state = self.SHOWN
        
        def GUIcreate(self, parent):
                self.instance = self.createWidget(parent)
        
        def GUIcreate(self, parent):
                self.instance = self.createWidget(parent)
+               if self.state == self.HIDDEN:
+                       self.instance.hide()
        
        def GUIdelete(self):
                self.removeWidget(self.instance)
        
        def GUIdelete(self):
                self.removeWidget(self.instance)
@@ -23,14 +19,6 @@ class Widget(GUIComponent):
        def removeWidget(self, w):
                pass
        
        def removeWidget(self, w):
                pass
        
-       def showWidget(self):
-               self.state = self.SHOWN
-               self.instance.show()
-
-       def hideWidget(self):
-               self.state = self.HIDDEN
-               self.instance.hide()
-               
        def move(self, x, y):
                self.instance.move(ePoint(int(x), int(y)))
        
        def move(self, x, y):
                self.instance.move(ePoint(int(x), int(y)))
        
@@ -50,11 +38,11 @@ class ConditionalWidget(Widget):
                
        def activateCondition(self, condition):
                if (condition):
                
        def activateCondition(self, condition):
                if (condition):
-                       if (self.state == self.HIDDEN):
-                               self.showWidget()
+                       if self.state == self.HIDDEN:
+                               self.show()
                else:
                else:
-                       if (self.state == self.SHOWN):
-                               self.hideWidget()
+                       if self.state == self.SHOWN:
+                               self.hide()
 
        def update(self):
                if (self.conditionalFunction != None):
 
        def update(self):
                if (self.conditionalFunction != None):
@@ -83,10 +71,10 @@ class BlinkingWidget(Widget):
                
        def blink(self):
                if self.blinking == True:
                
        def blink(self):
                if self.blinking == True:
-                       if (self.state == self.SHOWN):
-                               self.hideWidget()
-                       elif (self.state == self.HIDDEN):
-                               self.showWidget()
+                       if self.state == self.SHOWN:
+                               self.hide()
+                       elif self.state == self.HIDDEN:
+                               self.show()
                        
        def startBlinking(self):
                self.blinking = True
                        
        def startBlinking(self):
                self.blinking = True
@@ -94,8 +82,8 @@ class BlinkingWidget(Widget):
                
        def stopBlinking(self):
                self.blinking = False
                
        def stopBlinking(self):
                self.blinking = False
-               if (self.state == self.SHOWN):
-                       self.hideWidget()
+               if self.state == self.SHOWN:
+                       self.hide()
                self.timer.stop()
                
 class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
                self.timer.stop()
                
 class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
@@ -109,4 +97,4 @@ class BlinkingWidgetConditional(BlinkingWidget, ConditionalWidget):
                                self.startBlinking()
                else:
                        if self.blinking: # we are blinking
                                self.startBlinking()
                else:
                        if self.blinking: # we are blinking
-                               self.stopBlinking()                     
\ No newline at end of file
+                               self.stopBlinking()
index 5483d18..1476ba8 100644 (file)
@@ -5,8 +5,12 @@ from enigma import ePoint
 class GUIComponent:
        """ GUI component """
        
 class GUIComponent:
        """ GUI component """
        
+       SHOWN = 0
+       HIDDEN = 1
+       
        def __init__(self):
        def __init__(self):
-               pass
+               self.state = self.SHOWN
+               self.instance = None
        
        def execBegin(self):
                pass
        
        def execBegin(self):
                pass
@@ -16,7 +20,19 @@ class GUIComponent:
        
        # this works only with normal widgets - if you don't have self.instance, override this.
        def applySkin(self, desktop):
        
        # this works only with normal widgets - if you don't have self.instance, override this.
        def applySkin(self, desktop):
+               if self.state == self.HIDDEN:
+                       self.instance.hide()
                skin.applyAllAttributes(self.instance, desktop, self.skinAttributes)
 
        def move(self, x, y):
                self.instance.move(ePoint(int(x), int(y)))
                skin.applyAllAttributes(self.instance, desktop, self.skinAttributes)
 
        def move(self, x, y):
                self.instance.move(ePoint(int(x), int(y)))
+
+       def show(self):
+               self.state = self.SHOWN
+               if self.instance is not None:
+                       self.instance.show()
+
+       def hide(self):
+               self.state = self.HIDDEN
+               if self.instance is not None:
+                       self.instance.hide()
index cf8e189..f97dd8b 100644 (file)
@@ -25,8 +25,6 @@ class GUISkin:
                        else:
                                f()
 
                        else:
                                f()
 
-
-
        def deleteGUIScreen(self):
                for (name, val) in self.items():
                        if isinstance(val, GUIComponent):
        def deleteGUIScreen(self):
                for (name, val) in self.items():
                        if isinstance(val, GUIComponent):
index a0252e4..f1a17d9 100644 (file)
@@ -78,9 +78,3 @@ class Input(HTMLComponent, GUIComponent, VariableText):
                if self.type == self.PIN or self.type == self.NUMBER:
                        self.right()
                self.update()
                if self.type == self.PIN or self.type == self.NUMBER:
                        self.right()
                self.update()
-
-       def show(self):
-               self.instance.show()
-
-       def hide(self):
-               self.instance.hide()
\ No newline at end of file
index 129180f..5ad071a 100644 (file)
@@ -24,12 +24,6 @@ class Label(HTMLComponent, GUIComponent, VariableText):
                s = self.instance.calculateSize()
                return (s.width(), s.height())
 
                s = self.instance.calculateSize()
                return (s.width(), s.height())
 
-       def show(self):
-               self.instance.show()
-
-       def hide(self):
-               self.instance.hide()
-
 class LabelConditional(Label, ConditionalWidget):
        def __init__(self, text = "", withTimer = True):
                ConditionalWidget.__init__(self, withTimer = withTimer)
 class LabelConditional(Label, ConditionalWidget):
        def __init__(self, text = "", withTimer = True):
                ConditionalWidget.__init__(self, withTimer = withTimer)
index c8db81b..378e0d8 100644 (file)
@@ -155,25 +155,25 @@ class EPGSelection(Screen):
 
        def applyButtonState(self, state):
                if state == 1:
 
        def applyButtonState(self, state):
                if state == 1:
-                       self["now_button_sel"].showWidget()
-                       self["now_button"].hideWidget()
+                       self["now_button_sel"].show()
+                       self["now_button"].hide()
                else:
                else:
-                       self["now_button"].showWidget()
-                       self["now_button_sel"].hideWidget()
+                       self["now_button"].show()
+                       self["now_button_sel"].hide()
 
                if state == 2:
 
                if state == 2:
-                       self["next_button_sel"].showWidget()
-                       self["next_button"].hideWidget()
+                       self["next_button_sel"].show()
+                       self["next_button"].hide()
                else:
                else:
-                       self["next_button"].showWidget()
-                       self["next_button_sel"].hideWidget()
+                       self["next_button"].show()
+                       self["next_button_sel"].hide()
 
                if state == 3:
 
                if state == 3:
-                       self["more_button_sel"].showWidget()
-                       self["more_button"].hideWidget()
+                       self["more_button_sel"].show()
+                       self["more_button"].hide()
                else:
                else:
-                       self["more_button"].showWidget()
-                       self["more_button_sel"].hideWidget()
+                       self["more_button"].show()
+                       self["more_button_sel"].hide()
 
        def onSelectionChanged(self):
                if self.type == EPG_TYPE_MULTI:
 
        def onSelectionChanged(self):
                if self.type == EPG_TYPE_MULTI:
index e947ac9..06f0cfa 100644 (file)
@@ -31,12 +31,14 @@ class HelpMenu(Screen):
                
        def SelectionChanged(self):
                selection = self["list"].getCurrent()[3]
                
        def SelectionChanged(self):
                selection = self["list"].getCurrent()[3]
+               arrow = self["arrowup"]
+
                if selection is None:
                if selection is None:
-                       self["arrowup"].instance.hide()
+                       arrow.hide()
                else:
                else:
-                       self["arrowup"].moveTo(selection[1], selection[2], 1)
-                       self["arrowup"].startMoving()
-                       self["arrowup"].instance.show()
+                       arrow.moveTo(selection[1], selection[2], 1)
+                       arrow.startMoving()
+                       arrow.show()
 
 class HelpableScreen:
        def __init__(self):
 
 class HelpableScreen:
        def __init__(self):
@@ -44,8 +46,10 @@ class HelpableScreen:
                        {
                                "displayHelp": self.showHelp,
                        })
                        {
                                "displayHelp": self.showHelp,
                        })
+
        def showHelp(self):
                self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
        def showHelp(self):
                self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
+
        def callHelpAction(self, *args):
                if len(args):
                        (actionmap, context, action) = args
        def callHelpAction(self, *args):
                if len(args):
                        (actionmap, context, action) = args