add .nfi to filescanner for NFIFlash plugin, whitespace cleanup, change md5sum check...
[enigma2.git] / lib / python / Components / Label.py
1 from HTMLComponent import HTMLComponent
2 from GUIComponent import GUIComponent
3 from VariableText import VariableText
4 from skin import parseColor
5 from ConditionalWidget import ConditionalWidget, BlinkingWidget, BlinkingWidgetConditional
6
7 from enigma import eLabel
8
9 class Label(VariableText, HTMLComponent, GUIComponent):
10         def __init__(self, text=""):
11                 GUIComponent.__init__(self)
12                 VariableText.__init__(self)
13                 self.setText(text)
14         
15 # html: 
16         def produceHTML(self):
17                 return self.getText()
18
19 # GUI:
20         GUI_WIDGET = eLabel
21
22         def getSize(self):
23                 s = self.instance.calculateSize()
24                 return (s.width(), s.height())
25
26 class LabelConditional(Label, ConditionalWidget):
27         def __init__(self, text = "", withTimer = True):
28                 ConditionalWidget.__init__(self, withTimer = withTimer)
29                 Label.__init__(self, text = text)
30                 
31 class BlinkingLabel(Label, BlinkingWidget):
32         def __init__(self, text = ""):
33                 Label.__init__(text = text)
34                 BlinkingWidget.__init__()
35
36 class BlinkingLabelConditional(BlinkingWidgetConditional, LabelConditional):
37         def __init__(self, text = ""):
38                 LabelConditional.__init__(self, text = text)
39                 BlinkingWidgetConditional.__init__(self)
40
41 class MultiColorLabel(Label):
42         def __init__(self, text=""):
43                 Label.__init__(self,text)
44                 self.foreColors = []
45                 self.backColors = []
46
47         def applySkin(self, desktop, screen):
48                 if self.skinAttributes is not None:
49                         foregroundColor = None
50                         backgroundColor = None
51                         attribs = [ ]
52                         for (attrib, value) in self.skinAttributes:
53                                 if attrib == "foregroundColors":
54                                         colors = value.split(',')
55                                         for color in colors:
56                                                 self.foreColors.append(parseColor(color))
57                                         if not foregroundColor:
58                                                 foregroundColor = colors[0]
59                                 elif attrib == "backgroundColors":
60                                         colors = value.split(',')
61                                         for color in colors:
62                                                 self.backColors.append(parseColor(color))
63                                         if not backgroundColor:
64                                                 backgroundColor = colors[0]
65                                 elif attrib == "backgroundColor":
66                                         backgroundColor = value
67                                 elif attrib == "foregroundColor":
68                                         foregroundColor = value
69                                 else:
70                                         attribs.append((attrib,value))
71                         if foregroundColor:
72                                 attribs.append(("foregroundColor",foregroundColor))
73                         if backgroundColor:
74                                 attribs.append(("backgroundColor",backgroundColor))
75                         self.skinAttributes = attribs
76                 return GUIComponent.applySkin(self, desktop, screen)
77         
78         def setForegroundColorNum(self, x):
79                 if self.instance:
80                         if len(self.foreColors) > x:
81                                 self.instance.setForegroundColor(self.foreColors[x])
82                         else:
83                                 print "setForegroundColorNum(%d) failed! defined colors:" %(x), self.foreColors
84
85         def setBackgroundColorNum(self, x):
86                 if self.instance:
87                         if len(self.backColors) > x:
88                                 self.instance.setBackgroundColor(self.backColors[x])
89                         else:
90                                 print "setBackgroundColorNum(%d) failed! defined colors:" %(x), self.backColors
91