From: Stefan Pluecken Date: Thu, 19 Jan 2006 03:59:43 +0000 (+0000) Subject: use Components.Input in seek window X-Git-Tag: 2.6.0~4368 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/73c8ccf2a900e59f8450ddad57b80a215bb658b4 use Components.Input in seek window --- diff --git a/data/keymap.xml b/data/keymap.xml index 2034aa1a..fea9cf76 100644 --- a/data/keymap.xml +++ b/data/keymap.xml @@ -96,6 +96,13 @@ + + + + + + + @@ -160,6 +167,8 @@ + + diff --git a/lib/gui/elabel.cpp b/lib/gui/elabel.cpp index 970669c1..3cec3a1c 100644 --- a/lib/gui/elabel.cpp +++ b/lib/gui/elabel.cpp @@ -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; diff --git a/lib/python/Components/Input.py b/lib/python/Components/Input.py index 7ffc5c77..a0252e46 100644 --- a/lib/python/Components/Input.py +++ b/lib/python/Components/Input.py @@ -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): diff --git a/lib/python/Plugins/test/plugin.py b/lib/python/Plugins/test/plugin.py index d85a80c9..90c45e6e 100644 --- a/lib/python/Plugins/test/plugin.py +++ b/lib/python/Plugins/test/plugin.py @@ -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"], { diff --git a/lib/python/Screens/MinuteInput.py b/lib/python/Screens/MinuteInput.py index 68909b61..d804570f 100644 --- a/lib/python/Screens/MinuteInput.py +++ b/lib/python/Screens/MinuteInput.py @@ -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