<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>
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;
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)
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):
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"],
{
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,
"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