work on web interface
[enigma2.git] / lib / python / Components / GUIComponent.py
1 import skin
2
3 from enigma import ePoint
4
5 class GUIComponent(object):
6         """ GUI component """
7         
8         def __init__(self):
9                 self.instance = None
10                 self.visible = 1
11         
12         def execBegin(self):
13                 pass
14         
15         def execEnd(self):
16                 pass
17         
18         def onShow(self):
19                 pass
20
21         def onHide(self):
22                 pass
23         
24         def destroy(self):
25                 self.__dict__.clear()
26         
27         # this works only with normal widgets - if you don't have self.instance, override this.
28         def applySkin(self, desktop):
29                 if not self.visible:
30                         self.instance.hide()
31                 skin.applyAllAttributes(self.instance, desktop, self.skinAttributes)
32
33         def move(self, x, y):
34                 self.instance.move(ePoint(int(x), int(y)))
35
36         def show(self):
37                 self.__visible = 1
38                 if self.instance is not None:
39                         self.instance.show()
40
41         def hide(self):
42                 self.__visible = 0
43                 if self.instance is not None:
44                         self.instance.hide()
45
46         def getVisible(self):
47                 return self.__visible
48         
49         def setVisible(self, visible):
50                 if visible:
51                         self.show()
52                 else:
53                         self.hide()
54
55         visible = property(getVisible, setVisible)
56
57         def setPosition(self, x, y):
58                 self.instance.move(ePoint(int(x), int(y)))
59
60         def getPosition(self):
61                 p = self.instance.position()
62                 return (p.x(), p.y())
63
64         position = property(getPosition, setPosition)
65
66         # default implementation for only one widget per component
67         # feel free to override!
68         def GUIcreate(self, parent):
69                 self.instance = self.createWidget(parent)
70                 self.postWidgetCreate(self.instance)
71         
72         def GUIdelete(self):
73                 self.preWidgetRemove(self.instance)
74                 self.instance = None
75
76         # default for argumentless widget constructor
77         def createWidget(self, parent):
78                 return self.GUI_WIDGET(parent)
79
80         def postWidgetCreate(self, instance):
81                 pass
82         
83         def preWidgetRemove(self, instance):
84                 pass