use Components.Input in seek window
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 19 Jan 2006 03:59:43 +0000 (03:59 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Thu, 19 Jan 2006 03:59:43 +0000 (03:59 +0000)
data/keymap.xml
lib/gui/elabel.cpp
lib/python/Components/Input.py
lib/python/Plugins/test/plugin.py
lib/python/Screens/MinuteInput.py

index 2034aa1a2cd5662a23634ee028e52e2130a828ce..fea9cf76954d6dc06e634faf1c75fd7b9a55534d 100644 (file)
                <key id="KEY_OK" mapto="ok" flags="m" />
                <key id="KEY_EXIT" mapto="back" flags="m" />
        </map>
+
+       <map context="MinuteInputActions">
+               <key id="KEY_UP" mapto="up" flags="mr" />
+               <key id="KEY_DOWN" mapto="down" flags="mr" />
+               <key id="KEY_OK" mapto="ok" flags="m" />
+               <key id="KEY_EXIT" mapto="cancel" flags="m" />
+       </map>
        
        <map context="InfobarMenuActions">
                <key id="KEY_MENU" mapto="mainMenu" flags="mr" />
                <key id="KEY_0" mapto="0" flags="m" />
        </map>
        
+
+       
        <map context="TextEntryActions">
                <key id="KEY_MUTE" mapto="delete" flags="mr" />
        </map>  
index 970669c126b688bf70099979a6da40c864cfe0d1..3cec3a1cdc4003313ba47a706b62fe9ad4dd19dc 100644 (file)
@@ -37,13 +37,18 @@ int eLabel::event(int event, void *data, void *data2)
                        para->setFont(m_font);
                        para->renderString(m_text, 0);
                        para->realign(eTextPara::dirLeft);
+                       int glyphs = para->size();
 
-                       para->setGlyphFlag(m_pos, GS_INVERT);
-                       eRect bbox;
-                       bbox = para->getGlyphBBox(m_pos);
-                       printf("BBOX: %d %d %d %d\n", bbox.left(), 0, bbox.width(), size().height());
-                       bbox = eRect(bbox.left(), 0, bbox.width(), size().height());
-                       painter.fill(bbox);
+                       if ((m_pos < 0) || (m_pos >= glyphs))
+                               eWarning("glyph index %d in eLabel out of bounds!");
+                       else
+                       {
+                               para->setGlyphFlag(m_pos, GS_INVERT);
+                               eRect bbox;
+                               bbox = para->getGlyphBBox(m_pos);
+                               bbox = eRect(bbox.left(), 0, bbox.width(), size().height());
+                               painter.fill(bbox);
+                       }
 
                        painter.renderPara(para, ePoint(0, 0));
                        return 0;
index 7ffc5c77bdf0e97ca0c4bbf9cb8e0735184166cb..a0252e46d83f13976468972013efee436c254371 100644 (file)
@@ -7,19 +7,30 @@ from enigma import eLabel
 from Tools.NumericalTextInput import NumericalTextInput
 
 class Input(HTMLComponent, GUIComponent, VariableText):
-       def __init__(self, text=""):
+       TEXT = 0
+       PIN = 1
+       NUMBER = 2      
+       
+       def __init__(self, text="", maxSize = False, type = TEXT):
                GUIComponent.__init__(self)
                VariableText.__init__(self)
                self.numericalTextInput = NumericalTextInput(self.right)
+               self.type = type
+               self.maxSize = maxSize
                self.currPos = 0
                self.text = text
                self.update()
 
        def update(self):
                self.setMarkedPos(self.currPos)
-               self.setText(self.text)
+               text = self.text
+               if self.type == self.PIN:
+                       text = "*" * len(self.text)
+               self.setText(text)
                #self.setText(self.text[0:self.currPos] + "_" + self.text[self.currPos] + "_" + self.text[self.currPos + 1:])
 
+       def getText(self):
+               return self.text
        
        def createWidget(self, parent):
                return eLabel(parent, self.currPos)
@@ -31,15 +42,41 @@ class Input(HTMLComponent, GUIComponent, VariableText):
        def right(self):
                self.currPos += 1
                if self.currPos == len(self.text):
-                       self.text = self.text + " "
+                       if self.maxSize:
+                               self.currPos -= 1
+                       else:
+                               self.text = self.text + " "
+                       
                self.update()
                
        def left(self):
                self.currPos -= 1
                self.update()
                
+       def up(self):
+               if self.text[self.currPos] == "9":
+                       newNumber = "0"
+               else:
+                       newNumber = str(int(self.text[self.currPos]) + 1)
+               self.text = self.text[0:self.currPos] + newNumber + self.text[self.currPos + 1:]
+               self.update()
+               
+       def down(self):
+               if self.text[self.currPos] == "0":
+                       newNumber = "9"
+               else:
+                       newNumber = str(int(self.text[self.currPos]) - 1)
+               self.text = self.text[0:self.currPos] + newNumber + self.text[self.currPos + 1:]
+               self.update()
+               
        def number(self, number):
-               self.text = self.text[0:self.currPos] + self.numericalTextInput.getKey(number) + self.text[self.currPos + 1:]
+               if self.type == self.TEXT:
+                       newChar = self.numericalTextInput.getKey(number)
+               elif self.type == self.PIN or self.type == self.NUMBER:
+                       newChar = str(number)
+               self.text = self.text[0:self.currPos] + newChar + self.text[self.currPos + 1:]
+               if self.type == self.PIN or self.type == self.NUMBER:
+                       self.right()
                self.update()
 
        def show(self):
index d85a80c9b49863389820491739508b0534fa45cc..90c45e6e1bbf708acebced5408170d5c412f627e 100644 (file)
@@ -18,7 +18,7 @@ class Test(Screen):
                self.skin = Test.skin
                Screen.__init__(self, session)
 
-               self["text"] = Input("Please press OK!")
+               self["text"] = Input("1234", maxSize=True, type=Input.NUMBER)
                                
                self["actions"] = NumberActionMap(["WizardActions", "InputActions"], 
                {
index 68909b613b103d0bf2fb5e45361617baf14a8ea6..d804570fcf4b6154ab2dd2f0c2061b44c5fd4c21 100644 (file)
@@ -4,16 +4,16 @@ from Components.Label import Label
 from Components.Button import Button
 from Components.Pixmap import Pixmap
 from Components.MenuList import MenuList
+from Components.Input import Input
 from enigma import eSize, ePoint
 
 class MinuteInput(Screen):
                def __init__(self, session, basemins = 5):
                        Screen.__init__(self, session)
                                                
-                       self["minutes"] = Label()
-                       self.updateValue(basemins)
+                       self["minutes"] = Input(str(basemins), type=Input.NUMBER)
                        
-                       self["actions"] = NumberActionMap([ "NumberZapActions", "MinuteInputActions" ],
+                       self["actions"] = NumberActionMap([ "InputActions" , "MinuteInputActions" ],
                        {
                                "1": self.keyNumberGlobal,
                                "2": self.keyNumberGlobal,
@@ -25,29 +25,32 @@ class MinuteInput(Screen):
                                "8": self.keyNumberGlobal,
                                "9": self.keyNumberGlobal,
                                "0": self.keyNumberGlobal,
+                               "left": self.left,
+                               "right": self.right,
                                "up": self.up,
                                "down": self.down,
                                "ok": self.ok,
                                "cancel": self.cancel
                        })
                        
-               def updateValue(self, minutes):
-                       self.minutes = minutes
-                       self["minutes"].setText(str(self.minutes) + _(" mins"))
-                       
                def keyNumberGlobal(self, number):
-                       #self.updateValue(self.minutes * 10 + number)
+                       self["minutes"].number(number)
                        pass
                        
+               def left(self):
+                       self["minutes"].left()
+                       
+               def right(self):
+                       self["minutes"].right()
+                       
                def up(self):
-                       self.updateValue(self.minutes + 1)
+                       self["minutes"].up()
                
                def down(self):
-                       if self.minutes > 0:
-                               self.updateValue(self.minutes - 1)
+                       self["minutes"].down()
                                
                def ok(self):
-                       self.close(self.minutes)
+                       self.close(int(self["minutes"].getText()))
                        
                def cancel(self):
                        self.close(0)
\ No newline at end of file