1b0ee9f443816d111b33865fb1dfa9d42cca4de6
[openblackhole/openblackhole-enigma2.git] / lib / python / Screens / VirtualKeyBoard.py
1 # -*- coding: UTF-8 -*-
2 from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER, getPrevAsciiCode
3 from Screen import Screen
4 from Components.Language import language
5 from Components.ActionMap import NumberActionMap
6 from Components.Sources.StaticText import StaticText
7 from Components.Input import Input
8 from Components.Label import Label
9 from Components.Pixmap import Pixmap
10 from Components.MenuList import MenuList
11 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
12 from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN
13 from Tools.LoadPixmap import LoadPixmap
14 from Tools.NumericalTextInput import NumericalTextInput
15 import skin
16
17 class VirtualKeyBoardList(MenuList):
18         def __init__(self, list, enableWrapAround=False):
19                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
20                 font = skin.fonts.get("VirtualKeyboard", ("Regular", 28, 45))
21                 self.l.setFont(0, gFont(font[0], font[1]))
22                 self.l.setItemHeight(font[2])
23
24 class VirtualKeyBoardEntryComponent:
25         pass
26
27 class VirtualKeyBoard(Screen):
28
29         def __init__(self, session, title="", **kwargs):
30                 Screen.__init__(self, session)
31                 self.setTitle(_("Virtual KeyBoard"))
32                 self.keys_list = []
33                 self.shiftkeys_list = []
34                 self.lang = language.getLanguage()
35                 self.nextLang = None
36                 self.shiftMode = False
37                 self.selectedKey = 0
38                 self.smsChar = None
39                 self.sms = NumericalTextInput(self.smsOK)
40
41                 self.key_bg = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_bg.png"))
42                 self.key_sel = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_sel.png"))
43                 self.key_backspace = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_backspace.png"))
44                 self.key_all = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_all.png"))
45                 self.key_clr = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_clr.png"))
46                 self.key_esc = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_esc.png"))
47                 self.key_ok = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_ok.png"))
48                 self.key_shift = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_shift.png"))
49                 self.key_shift_sel = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_shift_sel.png"))
50                 self.key_space = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_space.png"))
51                 self.key_left = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_left.png"))
52                 self.key_right = LoadPixmap(path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_right.png"))
53
54                 self.keyImages =  {
55                                 "BACKSPACE": self.key_backspace,
56                                 "ALL": self.key_all,
57                                 "EXIT": self.key_esc,
58                                 "OK": self.key_ok,
59                                 "SHIFT": self.key_shift,
60                                 "SPACE": self.key_space,
61                                 "LEFT": self.key_left,
62                                 "RIGHT": self.key_right
63                         }
64                 self.keyImagesShift = {
65                                 "BACKSPACE": self.key_backspace,
66                                 "CLEAR": self.key_clr,
67                                 "EXIT": self.key_esc,
68                                 "OK": self.key_ok,
69                                 "SHIFT": self.key_shift_sel,
70                                 "SPACE": self.key_space,
71                                 "LEFT": self.key_left,
72                                 "RIGHT": self.key_right
73                         }
74
75                 self["country"] = StaticText("")
76                 self["header"] = Label(title)
77                 self["text"] = Input(currPos=len(kwargs.get("text", "").decode("utf-8",'ignore')), allMarked=False, **kwargs)
78                 self["list"] = VirtualKeyBoardList([])
79
80                 self["actions"] = NumberActionMap(["OkCancelActions", "WizardActions", "ColorActions", "KeyboardInputActions", "InputBoxActions", "InputAsciiActions"],
81                         {
82                                 "gotAsciiCode": self.keyGotAscii,
83                                 "ok": self.okClicked,
84                                 "cancel": self.exit,
85                                 "left": self.left,
86                                 "right": self.right,
87                                 "up": self.up,
88                                 "down": self.down,
89                                 "red": self.exit,
90                                 "green": self.ok,
91                                 "yellow": self.switchLang,
92                                 "blue": self.shiftClicked,
93                                 "deleteBackward": self.backClicked,
94                                 "deleteForward": self.forwardClicked,
95                                 "back": self.exit,
96                                 "pageUp": self.cursorRight,
97                                 "pageDown": self.cursorLeft,
98                                 "1": self.keyNumberGlobal,
99                                 "2": self.keyNumberGlobal,
100                                 "3": self.keyNumberGlobal,
101                                 "4": self.keyNumberGlobal,
102                                 "5": self.keyNumberGlobal,
103                                 "6": self.keyNumberGlobal,
104                                 "7": self.keyNumberGlobal,
105                                 "8": self.keyNumberGlobal,
106                                 "9": self.keyNumberGlobal,
107                                 "0": self.keyNumberGlobal,
108                         }, -2)
109                 self.setLang()
110                 self.onExecBegin.append(self.setKeyboardModeAscii)
111                 self.onLayoutFinish.append(self.buildVirtualKeyBoard)
112                 self.onClose.append(self.__onClose)
113
114         def __onClose(self):
115                 self.sms.timer.stop()
116
117         def switchLang(self):
118                 self.lang = self.nextLang
119                 self.setLang()
120                 self.buildVirtualKeyBoard()
121
122         def setLang(self):
123                 if self.lang == 'de_DE':
124                         self.keys_list = [
125                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
126                                 [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ü", u"+"],
127                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],
128                                 [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"ALL"],
129                                 [u"SHIFT", u"SPACE", u"@", u"ß", u"OK", u"LEFT", u"RIGHT"]]
130                         self.shiftkeys_list = [
131                                 [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
132                                 [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ü", u"*"],
133                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],
134                                 [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
135                                 [u"SHIFT", u"SPACE", u"?", u"\\", u"OK", u"LEFT", u"RIGHT"]]
136                         self.nextLang = 'es_ES'
137                 elif self.lang == 'es_ES':
138                         #still missing keys (u"ùÙ")
139                         self.keys_list = [
140                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
141                                 [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"],
142                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ó", u"á", u"#"],
143                                 [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"ALL"],
144                                 [u"SHIFT", u"SPACE", u"@", u"Ł", u"ŕ", u"é", u"č", u"í", u"ě", u"ń", u"ň", u"OK"]]
145                         self.shiftkeys_list = [
146                                 [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
147                                 [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ú", u"*"],
148                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ó", u"Á", u"'"],
149                                 [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
150                                 [u"SHIFT", u"SPACE", u"?", u"\\", u"Ŕ", u"É", u"Č", u"Í", u"Ě", u"Ń", u"Ň", u"OK"]]
151                         self.nextLang = 'fi_FI'
152                 elif self.lang == 'fi_FI':
153                         self.keys_list = [
154                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
155                                 [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"é", u"+"],
156                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],
157                                 [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"ALL"],
158                                 [u"SHIFT", u"SPACE", u"@", u"ß", u"ĺ", u"OK", u"LEFT", u"RIGHT"]]
159                         self.shiftkeys_list = [
160                                 [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
161                                 [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"É", u"*"],
162                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],
163                                 [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
164                                 [u"SHIFT", u"SPACE", u"?", u"\\", u"Ĺ", u"OK", u"LEFT", u"RIGHT"]]
165                         self.nextLang = 'lv_LV'
166                 elif self.lang == 'lv_LV':
167                         self.keys_list = [
168                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
169                                 [u"q", u"w", u"e", u"r", u"t", u"y", u"u", u"i", u"o", u"p", u"-", u"š"],
170                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u";", u"'", u"ū"],
171                                 [u"<", u"z", u"x", u"c", u"v", u"b", u"n", u"m", u",", u".", u"ž", u"ALL"],
172                                 [u"SHIFT", u"SPACE", u"ā", u"č", u"ē", u"ģ", u"ī", u"ķ", u"ļ", u"ņ", u"LEFT", u"RIGHT"]]
173                         self.shiftkeys_list = [
174                                 [u"EXIT", u"!", u"@", u"$", u"*", u"(", u")", u"_", u"=", u"/", u"\\", u"BACKSPACE"],
175                                 [u"Q", u"W", u"E", u"R", u"T", u"Y", u"U", u"I", u"O", u"P", u"+", u"Š"],
176                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u":", u'"', u"Ū"],
177                                 [u">", u"Z", u"X", u"C", u"V", u"B", u"N", u"M", u"#", u"?", u"Ž", u"CLEAR"],
178                                 [u"SHIFT", u"SPACE", u"Ā", u"Č", u"Ē", u"Ģ", u"Ī", u"Ķ", u"Ļ", u"Ņ", u"LEFT", u"RIGHT"]]
179                         self.nextLang = 'ru_RU'
180                 elif self.lang == 'ru_RU':
181                         self.keys_list = [
182                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
183                                 [u"а", u"б", u"в", u"г", u"д", u"е", u"ё", u"ж", u"з", u"и", u"й", u"+"],
184                                 [u"к", u"л", u"м", u"н", u"о", u"п", u"р", u"с", u"т", u"у", u"ф", u"#"],
185                                 [u"<", u"х", u"ц", u"ч", u"ш", u"щ", u"ъ", u"ы", u",", u".", u"-", u"ALL"],
186                                 [u"SHIFT", u"SPACE", u"@", u"ь", u"э", u"ю", u"я", u"OK", u"LEFT", u"RIGHT"]]
187                         self.shiftkeys_list = [
188                                 [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
189                                 [u"А", u"Б", u"В", u"Г", u"Д", u"Е", u"Ё", u"Ж", u"З", u"И", u"Й", u"*"],
190                                 [u"К", u"Л", u"М", u"Н", u"О", u"П", u"Р", u"С", u"Т", u"У", u"Ф", u"'"],
191                                 [u">", u"Х", u"Ц", u"Ч", u"Ш", u"Щ", u"Ъ", u"Ы", u";", u":", u"_", u"CLEAR"],
192                                 [u"SHIFT", u"SPACE", u"?", u"\\", u"Ь", u"Э", u"Ю", u"Я", u"OK", u"LEFT", u"RIGHT"]]
193                         self.nextLang = 'sv_SE'
194                 elif self.lang == 'sv_SE':
195                         self.keys_list = [
196                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
197                                 [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"é", u"+"],
198                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],
199                                 [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"ALL"],
200                                 [u"SHIFT", u"SPACE", u"@", u"ß", u"ĺ", u"OK", u"LEFT", u"RIGHT"]]
201                         self.shiftkeys_list = [
202                                 [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
203                                 [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"É", u"*"],
204                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],
205                                 [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
206                                 [u"SHIFT", u"SPACE", u"?", u"\\", u"Ĺ", u"OK", u"LEFT", u"RIGHT"]]
207                         self.nextLang = 'sk_SK'
208                 elif self.lang =='sk_SK':
209                         self.keys_list = [
210                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
211                                 [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"],
212                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ľ", u"@", u"#"],
213                                 [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"ALL"],
214                                 [u"SHIFT", u"SPACE", u"š", u"č", u"ž", u"ý", u"á", u"í", u"é", u"OK", u"LEFT", u"RIGHT"]]
215                         self.shiftkeys_list = [
216                                 [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
217                                 [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"ť", u"*"],
218                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"ň", u"ď", u"'"],
219                                 [u"Á", u"É", u"Ď", u"Í", u"Ý", u"Ó", u"Ú", u"Ž", u"Š", u"Č", u"Ť", u"Ň"],
220                                 [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
221                                 [u"SHIFT", u"SPACE", u"?", u"\\", u"ä", u"ö", u"ü", u"ô", u"ŕ", u"ĺ", u"OK"]]
222                         self.nextLang = 'cs_CZ'
223                 elif self.lang == 'cs_CZ':
224                         self.keys_list = [
225                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
226                                 [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"],
227                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ů", u"@", u"#"],
228                                 [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"ALL"],
229                                 [u"SHIFT", u"SPACE", u"ě", u"š", u"č", u"ř", u"ž", u"ý", u"á", u"í", u"é", u"OK"]]
230                         self.shiftkeys_list = [
231                                 [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
232                                 [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"ť", u"*"],
233                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"ň", u"ď", u"'"],
234                                 [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
235                                 [u"SHIFT", u"SPACE", u"?", u"\\", u"Č", u"Ř", u"Š", u"Ž", u"Ú", u"Á", u"É", u"OK"]]
236                         self.nextLang = 'el_GR'
237                 elif self.lang == 'el_GR':
238                         self.keys_list = [
239                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
240                                 [u"=", u"ς", u"ε", u"ρ", u"τ", u"υ", u"θ", u"ι", u"ο", u"π", u"[", u"]"],
241                                 [u"α", u"σ", u"δ", u"φ", u"γ", u"η", u"ξ", u"κ", u"λ", u";", u"'", u"-"],
242                                 [u"\\", u"ζ", u"χ", u"ψ", u"ω", u"β", u"ν", u"μ", u",", ".", u"/", u"ALL"],
243                                 [u"SHIFT", u"SPACE", u"ά", u"έ", u"ή", u"ί", u"ό", u"ύ", u"ώ", u"ϊ", u"ϋ", u"OK"]]
244                         self.shiftkeys_list = [
245                                 [u"EXIT", u"!", u"@", u"#", u"$", u"%", u"^", u"&", u"*", u"(", u")", u"BACKSPACE"],
246                                 [u"+", u"€", u"Ε", u"Ρ", u"Τ", u"Υ", u"Θ", u"Ι", u"Ο", u"Π", u"{", u"}"],
247                                 [u"Α", u"Σ", u"Δ", u"Φ", u"Γ", u"Η", u"Ξ", u"Κ", u"Λ", u":", u'"', u"_"],
248                                 [u"|", u"Ζ", u"Χ", u"Ψ", u"Ω", u"Β", u"Ν", u"Μ", u"<", u">", u"?", u"CLEAR"],
249                                 [u"SHIFT", u"SPACE", u"Ά", u"Έ", u"Ή", u"Ί", u"Ό", u"Ύ", u"Ώ", u"Ϊ", u"Ϋ", u"OK"]]
250                         self.nextLang = 'pl_PL'
251                 elif self.lang == 'pl_PL':
252                         self.keys_list = [
253                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
254                                 [u"q", u"w", u"e", u"r", u"t", u"y", u"u", u"i", u"o", u"p", u"-", u"["],
255                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u";", u"'", u"\\"],
256                                 [u"<", u"z", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"/", u"ALL"],
257                                 [u"SHIFT", u"SPACE", u"ą", u"ć", u"ę", u"ł", u"ń", u"ó", u"ś", u"ź", u"ż", u"OK"]]
258                         self.shiftkeys_list = [
259                                 [u"EXIT", u"!", u"@", u"#", u"$", u"%", u"^", u"&", u"(", u")", u"=", u"BACKSPACE"],
260                                 [u"Q", u"W", u"E", u"R", u"T", u"Y", u"U", u"I", u"O", u"P", u"*", u"]"],
261                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"?", u'"', u"|"],
262                                 [u">", u"Z", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
263                                 [u"SHIFT", u"SPACE", u"Ą", u"Ć", u"Ę", u"Ł", u"Ń", u"Ó", u"Ś", u"Ź", u"Ż", u"OK"]]
264                         self.nextLang = 'en_EN'
265                 else:
266                         self.keys_list = [
267                                 [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
268                                 [u"q", u"w", u"e", u"r", u"t", u"y", u"u", u"i", u"o", u"p", u"-", u"["],
269                                 [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u";", u"'", u"\\"],
270                                 [u"<", u"z", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"/", u"ALL"],
271                                 [u"SHIFT", u"SPACE", u"OK", u"LEFT", u"RIGHT", u"*"]]
272                         self.shiftkeys_list = [
273                                 [u"EXIT", u"!", u"@", u"#", u"$", u"%", u"^", u"&", u"(", u")", u"=", u"BACKSPACE"],
274                                 [u"Q", u"W", u"E", u"R", u"T", u"Y", u"U", u"I", u"O", u"P", u"+", u"]"],
275                                 [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"?", u'"', u"|"],
276                                 [u">", u"Z", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
277                                 [u"SHIFT", u"SPACE", u"OK", u"LEFT", u"RIGHT", u"~"]]
278                         self.lang = 'en_EN'
279                         self.nextLang = 'de_DE'
280                 self["country"].setText(self.lang)
281                 self.max_key=47+len(self.keys_list[4])
282
283         def virtualKeyBoardEntryComponent(self, keys):
284                 w, h = skin.parameters.get("VirtualKeyboard",(45, 45))
285                 key_bg_width = self.key_bg and self.key_bg.size().width() or w
286                 key_images = self.shiftMode and self.keyImagesShift or self.keyImages
287                 res = [(keys)]
288                 text = []
289                 x = 0
290                 for key in keys:
291                         png = key_images.get(key, None)
292                         if png:
293                                 width = png.size().width()
294                                 res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, h), png=png))
295                         else:
296                                 width = key_bg_width
297                                 res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, h), png=self.key_bg))
298                                 text.append(MultiContentEntryText(pos=(x, 0), size=(width, h), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER))
299                         x += width
300                 return res + text
301
302         def buildVirtualKeyBoard(self):
303                 self.previousSelectedKey = None
304                 self.list = []
305                 for keys in self.shiftMode and self.shiftkeys_list or self.keys_list:
306                         self.list.append(self.virtualKeyBoardEntryComponent(keys))
307                 self.markSelectedKey()
308
309         def markSelectedKey(self):
310                 w, h = skin.parameters.get("VirtualKeyboard",(45, 45))
311                 if self.previousSelectedKey is not None:
312                         self.list[self.previousSelectedKey /12] = self.list[self.previousSelectedKey /12][:-1]
313                 width = self.key_sel.size().width()
314                 x = self.list[self.selectedKey/12][self.selectedKey % 12 + 1][1]
315                 self.list[self.selectedKey / 12].append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, h), png=self.key_sel))
316                 self.previousSelectedKey = self.selectedKey
317                 self["list"].setList(self.list)
318
319         def backClicked(self):
320                 self["text"].deleteBackward()
321
322         def forwardClicked(self):
323                 self["text"].deleteForward()
324
325         def shiftClicked(self):
326                 self.smsChar = None
327                 self.shiftMode = not self.shiftMode
328                 self.buildVirtualKeyBoard()
329
330         def okClicked(self):
331                 self.smsChar = None
332                 text = (self.shiftMode and self.shiftkeys_list or self.keys_list)[self.selectedKey / 12][self.selectedKey % 12].encode("UTF-8")
333
334                 if text == "EXIT":
335                         self.close(None)
336
337                 elif text == "BACKSPACE":
338                         self["text"].deleteBackward()
339
340                 elif text == "ALL":
341                         self["text"].markAll()
342
343                 elif text == "CLEAR":
344                         self["text"].deleteAllChars()
345                         self["text"].update()
346
347                 elif text == "SHIFT":
348                         self.shiftClicked()
349
350                 elif text == "SPACE":
351                         self["text"].char(" ".encode("UTF-8"))
352
353                 elif text == "OK":
354                         self.close(self["text"].getText())
355
356                 elif text == "LEFT":
357                         self["text"].left()
358
359                 elif text == "RIGHT":
360                         self["text"].right()
361
362                 else:
363                         self["text"].char(text)
364
365         def ok(self):
366                 self.close(self["text"].getText())
367
368         def exit(self):
369                 self.close(None)
370
371         def cursorRight(self):
372                 self["text"].right()
373
374         def cursorLeft(self):
375                 self["text"].left()
376
377         def left(self):
378                 self.smsChar = None
379                 self.selectedKey = self.selectedKey / 12 * 12 + (self.selectedKey + 11) % 12
380                 if self.selectedKey > self.max_key:
381                         self.selectedKey = self.max_key
382                 self.markSelectedKey()
383
384         def right(self):
385                 self.smsChar = None
386                 self.selectedKey = self.selectedKey / 12 * 12 + (self.selectedKey + 1) % 12
387                 if self.selectedKey > self.max_key:
388                         self.selectedKey = self.selectedKey / 12 * 12
389                 self.markSelectedKey()
390
391         def up(self):
392                 self.smsChar = None
393                 self.selectedKey -= 12
394                 if self.selectedKey < 0:
395                         self.selectedKey = self.max_key / 12 * 12 + self.selectedKey % 12
396                         if self.selectedKey > self.max_key:
397                                 self.selectedKey -= 12
398                 self.markSelectedKey()
399
400         def down(self):
401                 self.smsChar = None
402                 self.selectedKey += 12
403                 if self.selectedKey > self.max_key:
404                         self.selectedKey = self.selectedKey % 12
405                 self.markSelectedKey()
406
407         def keyNumberGlobal(self, number):
408                 self.smsChar = self.sms.getKey(number)
409                 self.selectAsciiKey(self.smsChar)
410
411         def smsOK(self):
412                 if self.smsChar and self.selectAsciiKey(self.smsChar):
413                         print "pressing ok now"
414                         self.okClicked()
415
416         def keyGotAscii(self):
417                 self.smsChar = None
418                 if self.selectAsciiKey(str(unichr(getPrevAsciiCode()).encode('utf-8'))):
419                         self.okClicked()
420
421         def selectAsciiKey(self, char):
422                 if char == " ":
423                         char = "SPACE"
424                 for keyslist in (self.shiftkeys_list, self.keys_list):
425                         selkey = 0
426                         for keys in keyslist:
427                                 for key in keys:
428                                         if key == char:
429                                                 self.selectedKey = selkey
430                                                 if self.shiftMode != (keyslist is self.shiftkeys_list):
431                                                         self.shiftMode = not self.shiftMode
432                                                         self.buildVirtualKeyBoard()
433                                                 else:
434                                                         self.markSelectedKey()
435                                                 return True
436                                         selkey += 1
437                 return False