Merge branch 'experimental' of git.opendreambox.org:/git/enigma2 into experimental
[enigma2.git] / lib / python / Screens / VirtualKeyBoard.py
index 9b676a5ff3eb5c780736c409aeae90cd60dfb750..7846e4b85dc5aeb0165472e8005bdc9acb9dd85d 100755 (executable)
@@ -7,26 +7,25 @@ from Components.MenuList import MenuList
 from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
 from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER
 from Screen import Screen
-from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
+from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN
 from Tools.LoadPixmap import LoadPixmap
 
 class VirtualKeyBoardList(MenuList):
        def __init__(self, list, enableWrapAround=False):
                MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
-               self.l.setFont(0, gFont("Regular", 22))
+               self.l.setFont(0, gFont("Regular", 28))
                self.l.setItemHeight(45)
 
 def VirtualKeyBoardEntryComponent(keys, selectedKey,shiftMode=False):
-       key_backspace = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_backspace.png"))
-       key_bg = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_bg.png"))
-       key_clr = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_clr.png"))
-       key_esc = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_esc.png"))
-       key_ok = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_ok.png"))
-       key_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_sel.png"))
-       key_shift = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift.png"))
-       key_shift_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift_sel.png"))
-       key_space = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_space.png"))
-       
+       key_backspace = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_backspace.png"))
+       key_bg = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_bg.png"))
+       key_clr = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_clr.png"))
+       key_esc = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_esc.png"))
+       key_ok = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_ok.png"))
+       key_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_sel.png"))
+       key_shift = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_shift.png"))
+       key_shift_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_shift_sel.png"))
+       key_space = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/vkey_space.png"))
        res = [ (keys) ]
        
        x = 0
@@ -36,33 +35,45 @@ def VirtualKeyBoardEntryComponent(keys, selectedKey,shiftMode=False):
        else:
                shiftkey_png = key_shift
        for key in keys:
+               width = None
                if key == "EXIT":
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_esc))
+                       width = key_esc.size().width()
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, 45), png=key_esc))
                elif key == "BACKSPACE":
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_backspace))
+                       width = key_backspace.size().width()
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, 45), png=key_backspace))
                elif key == "CLEAR":
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_clr))
+                       width = key_clr.size().width()
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, 45), png=key_clr))
                elif key == "SHIFT":
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=shiftkey_png))
+                       width = shiftkey_png.size().width()
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, 45), png=shiftkey_png))
                elif key == "SPACE":
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_space))
+                       width = key_space.size().width()
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, 45), png=key_space))
                elif key == "OK":
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_ok))
+                       width = key_ok.size().width()
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, 45), png=key_ok))
                #elif key == "<-":
                #       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_left))
                #elif key == "->":
                #       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_right))
                
                else:
+                       width = key_bg.size().width()
                        res.extend((
-                               MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_bg),
-                               MultiContentEntryText(pos=(x, 0), size=(45, 45), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER)
+                               MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, 45), png=key_bg),
+                               MultiContentEntryText(pos=(x, 0), size=(width, 45), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER)
                        ))
                
                if selectedKey == count:
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_sel))
-               
-               x += 45
+                       width = key_sel.size().width()
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(width, 45), png=key_sel))
+
+               if width is not None:
+                       x += width
+               else:
+                       x += 45
                count += 1
        
        return res
@@ -157,6 +168,8 @@ class VirtualKeyBoard(Screen):
                        }, -2)
                
                self.onLayoutFinish.append(self.buildVirtualKeyBoard)
+       
+               self.max_key=47+len(self.keys_list[4])
 
        def buildVirtualKeyBoard(self, selectedKey=0):
                list = []
@@ -193,13 +206,19 @@ class VirtualKeyBoard(Screen):
                
                selectedKey = self.selectedKey
 
+               text = None
+
                for x in list:
                        if selectedKey < 12:
-                               text = x[selectedKey]
+                               if selectedKey < len(x):
+                                       text = x[selectedKey]
                                break
                        else:
                                selectedKey -= 12
 
+               if text is None:
+                       return
+
                text = text.encode("utf-8")
 
                if text == "EXIT":
@@ -251,7 +270,7 @@ class VirtualKeyBoard(Screen):
                elif self.selectedKey == 35:
                        self.selectedKey = 47
                elif self.selectedKey == 47:
-                       self.selectedKey = 59
+                       self.selectedKey = self.max_key
                
                self.showActiveKey()
 
@@ -266,7 +285,7 @@ class VirtualKeyBoard(Screen):
                        self.selectedKey = 24
                elif self.selectedKey == 48:
                        self.selectedKey = 36
-               elif self.selectedKey == 60:
+               elif self.selectedKey > self.max_key:
                        self.selectedKey = 48
                
                self.showActiveKey()
@@ -274,16 +293,20 @@ class VirtualKeyBoard(Screen):
        def up(self):
                self.selectedKey -= 12
                
-               if self.selectedKey < 0:
-                       self.selectedKey += 60
+               if (self.selectedKey < 0) and (self.selectedKey > (self.max_key-60)):
+                       self.selectedKey += 48
+               elif self.selectedKey < 0:
+                       self.selectedKey += 60  
                
                self.showActiveKey()
 
        def down(self):
                self.selectedKey += 12
                
-               if self.selectedKey > 59:
+               if (self.selectedKey > self.max_key) and (self.selectedKey > 59):
                        self.selectedKey -= 60
+               elif self.selectedKey > self.max_key:
+                       self.selectedKey -= 48
                
                self.showActiveKey()