PiPSetup should be working now
[enigma2.git] / lib / python / Screens / PiPSetup.py
1 from enigma import *
2 from Screens.Screen import Screen
3 from Screens.MessageBox import MessageBox
4 from Components.ActionMap import NumberActionMap
5 from Components.Label import Label
6 from Components.MenuList import MenuList
7 from Components.GUIComponent import *
8 from Components.ChoiceList import ChoiceEntryComponent, ChoiceList
9
10 import os
11
12 class PiPSetup(Screen):
13         def __init__(self, session, pip):
14                 Screen.__init__(self, session)
15                 
16                 self.pip = pip
17                 
18                 self.pos = (self.pip.instance.position().x(), self.pip.instance.position().y())
19                 self.orgpos = self.pos
20                 
21                 self.size = self.pip.getSize()
22                 
23                 self.resize = 100
24
25                 self["text"] = Label(_("Please use direction keys to move the PiP window.\nPress Bouquet +/- to resize the window.\nPress OK to go back to the TV mode or EXIT to cancel the moving."))
26
27                 self["actions"] = NumberActionMap(["PiPSetupActions"], 
28                 {
29                         "ok": self.go,
30                         "cancel": self.cancel,
31                         "up": self.up,
32                         "down": self.down,
33                         "left": self.left,
34                         "right": self.right,
35                         "size+": self.bigger,
36                         "size-": self.smaller,
37                 }, -1)
38                 
39         def go(self):
40                 self.close()
41         
42         def cancel(self):
43                 self.movePiP(self.orgpos[0], self.orgpos[1])
44                 self.resizePiP(100)
45                 self.close()
46                 
47         def movePiP(self, x, y):
48                 if x < 0:
49                         x = 0
50                 if y < 0:
51                         y = 0
52                 self.pip.move(x, y)
53                 self.pos = (x, y)
54                 
55         def resizePiP(self, resize):
56                 w = int(self.size[0] * self.resize / 100)
57                 h = int(self.size[1] * self.resize / 100)
58                 self.pip.resize(w, h)
59                 self.resize = resize
60         
61         def up(self):
62                 self.movePiP(self.pos[0], self.pos[1] - 10)
63
64         def down(self):
65                 self.movePiP(self.pos[0], self.pos[1] + 10)
66         
67         def left(self):
68                 self.movePiP(self.pos[0] - 10, self.pos[1])
69         
70         def right(self):
71                 self.movePiP(self.pos[0] + 10, self.pos[1])
72                 
73         def bigger(self):
74                 self.resizePiP(self.resize + 5)
75         
76         def smaller(self):
77                 self.resizePiP(self.resize - 5)