1acd2548e0e66fff36c3792691b217329a1d6040
[enigma2.git] / lib / python / Tools / NumericalTextInput.py
1 # -*- coding: latin-1 -*-
2 from enigma import *
3 from Components.Language import language
4
5 class NumericalTextInput:
6         def __init__(self, nextFunction = None):
7                 self.mapping = []
8                 self.lang = language.getLanguage()
9                 
10                 if self.lang == 'de_DE':
11                         self.mapping.append (u".,?'\"0-()@/:_") # 0
12                         self.mapping.append (u" 1") # 1
13                         self.mapping.append (u"aäbc2AÄBC") # 2
14                         self.mapping.append (u"def3DEF") # 3
15                         self.mapping.append (u"ghi4GHI") # 4
16                         self.mapping.append (u"jkl5JKL") # 5
17                         self.mapping.append (u"mnoö6MNOÖ") # 6
18                         self.mapping.append (u"pqrsß7PQRSß") # 7
19                         self.mapping.append (u"tuüv8TUÜV") # 8
20                         self.mapping.append (u"wxyz9WXYZ") # 9
21                 elif self.lang == 'es_ES':
22                         self.mapping.append (u".,?'\"0-()@/:_") # 0
23                         self.mapping.append (u" 1") # 1
24                         self.mapping.append (u"abcáà2ABCÁÀ") # 2
25                         self.mapping.append (u"deéèf3DEFÉÈ") # 3
26                         self.mapping.append (u"ghiíì4GHIÍÌ") # 4
27                         self.mapping.append (u"jkl5JKL") # 5
28                         self.mapping.append (u"mnñoóò6MNÑOÓÒ") # 6
29                         self.mapping.append (u"pqrs7PQRS") # 7
30                         self.mapping.append (u"tuvúù8TUVÚÙ") # 8
31                         self.mapping.append (u"wxyz9WXYZ") # 9
32                 else:
33                         self.mapping.append (u".,?'\"0-()@/:_") # 0
34                         self.mapping.append (u" 1") # 1
35                         self.mapping.append (u"abc2ABC") # 2
36                         self.mapping.append (u"def3DEF") # 3
37                         self.mapping.append (u"ghi4GHI") # 4
38                         self.mapping.append (u"jkl5JKL") # 5
39                         self.mapping.append (u"mno6MNO") # 6
40                         self.mapping.append (u"pqrs7PQRS") # 7
41                         self.mapping.append (u"tuv8TUV") # 8
42                         self.mapping.append (u"wxyz9WXYZ") # 9
43                 
44                 self.nextFunction = nextFunction
45                 self.Timer = eTimer()
46                 self.Timer.timeout.get().append(self.nextChar)
47                 self.lastKey = -1
48                 self.pos = 0
49
50         def getKey(self, num):
51                 self.Timer.start(1000, True)
52                 if (self.lastKey != num):
53                         self.lastKey = num
54                         self.pos = 0
55                 else:
56                         self.pos += 1
57                         if (len(self.mapping[num]) <= self.pos):
58                                 self.pos = 0
59                 return self.mapping[num][self.pos]
60
61         def nextKey(self):
62                 self.Timer.stop()
63                 self.lastKey = -1
64
65         def nextChar(self):
66                 print "Timer done"
67                 try:
68                         self.nextKey()
69                         if (self.nextFunction != None):
70                                 self.nextFunction()
71                 except AttributeError:
72                         print "Text Input object deleted with running nextChar timer?"