3 from xml.dom import EMPTY_NAMESPACE
5 from Tools.XMLTools import elementsWithTag, mergeText
10 print " " * i + str(x)
12 for n in x.childNodes:
17 dom = xml.dom.minidom.parseString(
21 <color name="white" value="#ffffff" />
22 <color name="black" value="#000000" />
23 <color name="dark" value="#20294a6b" />
25 <color name="red" value="#ff0000" />
26 <color name="green" value="#00ff00" />
27 <color name="blue" value="#0000ff" />
28 <color name="yellow" value="#c0c000" />
30 <windowstyle type="skinned">
31 <color name="Background" color="#4075a7" />
32 <color name="LabelForeground" color="#ffffff" />
33 <color name="ListboxBackground" color="#4075a7" />
34 <color name="ListboxForeground" color="#ffffff" />
35 <color name="ListboxSelectedBackground" color="#404080" />
36 <color name="ListboxSelectedForeground" color="#ffffff" />
37 <color name="ListboxMarkedBackground" color="#ff0000" />
38 <color name="ListboxMarkedForeground" color="#ffffff" />
39 <borderset name="bsWindow">
40 <pixmap pos="bpTopLeft" filename="data/b_w_tl.png" />
41 <pixmap pos="bpTop" filename="data/b_w_t.png" />
42 <pixmap pos="bpTopRight" filename="data/b_w_tr.png" />
43 <pixmap pos="bpLeft" filename="data/b_w_l.png" />
44 <pixmap pos="bpRight" filename="data/b_w_r.png" />
45 <pixmap pos="bpBottomLeft" filename="data/b_w_bl.png" />
46 <pixmap pos="bpBottom" filename="data/b_w_b.png" />
47 <pixmap pos="bpBottomRight" filename="data/b_w_br.png" />
49 </windowstyle> """ """
50 <screen name="Menu" position="300,100" size="300,300" title="real main menu">
51 <!-- <widget name="okbutton" position="10,190" size="280,50" font="Arial;20" valign="center" halign="center" />-->
52 <widget name="title" position="10,10" size="280,20" />
53 <widget name="menu" position="10,30" size="280,200" />
56 <screen name="ScartLoopThrough" position="0,0" size="720,576">
58 <screen name="ConfigMenu" position="300,100" size="300,300" title="real main menu">
59 <widget name="txt_var_1" position="20,20" size="100,20" />
60 <widget name="btn_var_1" position="110,20" size="200,20" />
61 <widget name="txt_var_2" position="20,60" size="100,20" />
62 <widget name="btn_var_2" position="110,60" size="200,20" />
64 <screen name="Setup" position="140,125" size="460,350" title="RCU Setup">
65 <widget name="config" position="10,30" size="280,140" />
67 <screen name="configOSD" position="140,125" size="460,350" title="OSD Settings">
68 <widget name="okbutton" position="20,245" size="205,40" />
69 <widget name="txt_alpha" position="20,20" size="110,20" />
70 <widget name="sld_alpha" position="150,20" size="290,20" />
71 <widget name="txt_brightness" position="20,60" size="120,20" />
72 <widget name="sld_brightness" position="150,20" size="290,20" />
73 <widget name="txt_gamma" position="20,100" size="120,20" />
74 <widget name="sld_gamma" position="150,100" size="290,20" />
76 <screen name="configTest" position="300,100" size="300,300" title="config menu">
77 <widget name="config" position="10,30" size="280,140" />
79 <screen name="TimerEditList" position="160,100" size="420,430" title="Timer Editor">
80 <widget name="timerlist" position="10,30" size="400,300" />
82 <screen name="clockDisplay" position="300,100" size="300,300">
83 <widget name="okbutton" position="10,10" size="280,40" />
84 <widget name="title" position="10,120" size="280,50" />
85 <widget name="theClock" position="10,60" size="280,50" />
87 <screen name="InfoBar" flags="wfNoBorder" position="0,380" size="720,148" title="InfoBar">
88 <ePixmap position="0,0" size="720,148" pixmap="data/info-bg.png" />
90 <widget name="ServiceName" position="69,25" size="427,26" valign="center" font="Arial;22" backgroundColor="#101258" />
91 <widget name="CurrentTime" position="575,10" size="80,30" backgroundColor="dark" font="Arial;19" />
92 <widget name="Volume" position="575,45" size="100,5" backgroundColor="dark" />
93 <widget name="Event_Now" position="273,68" size="282,30" font="Arial;22" backgroundColor="dark" />
94 <widget name="Event_Next" position="273,98" size="282,30" font="Arial;22" backgroundColor="dark" />
95 <widget name="Event_Now_Duration" position="555,68" size="70,26" font="Arial;22" backgroundColor="dark" />
96 <widget name="Event_Next_Duration" position="555,98" size="70,26" font="Arial;22" backgroundColor="dark" />
97 <!-- <eLabel position="70,0" size="300,30" text=".oO skin Oo." font="Arial;20" /> -->
99 <screen name="ChannelSelection" position="90,100" size="560,420" title="Channel Selection">
100 <widget name="list" position="0,50" size="560,340" />
101 <!-- <widget name="okbutton" position="340,50" size="140,30" />-->
102 <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" />
103 <widget name="key_green" position="140,0" size="140,40" backgroundColor="green" />
104 <widget name="key_yellow" position="280,0" size="140,40" backgroundColor="yellow" />
105 <widget name="key_blue" position="420,0" size="140,40" backgroundColor="blue" />
107 <screen name="MovieSelection" position="150,100" size="400,420" title="Select-a-movie">
108 <widget name="list" position="0,50" size="400,300" />
110 <screen name="ServiceScan" position="150,100" size="300,200" title="Service Scan">
111 <widget name="scan_progress" position="10,10" size="280,50" />
112 <widget name="scan_state" position="10,60" size="280,30" />
114 <screen name="TimerEdit" position="70,100" size="590,335" title="Timer Edit">
115 <widget name="description" position="10,10" size="580,40" font="Arial;25" />
116 <widget name="lbegin" position="405,102" size="103,30" font="Arial;25" foregroundColor="red" />
117 <widget name="lend" position="405,158" size="103,30" font="Arial;25" foregroundColor="green" />
118 <widget name="begin" position="508,105" size="72,35" font="Arial;25" />
119 <widget name="end" position="508,150" size="72,35" font="Arial;25" />
120 <widget name="apply" position="10,240" size="250,35" />
122 <screen name="MessageBox" position="0,300" size="720,10" title="Message">
123 <widget name="text" position="0,0" size="500,0" font="Arial;25" />
124 <applet type="onLayoutFinish">
125 # this should be factored out into some helper code, but currently demonstrated applets.
126 from enigma import eSize, ePoint
128 orgwidth = self.instance.size().width()
129 orgpos = self.instance.position()
130 textsize = self["text"].getSize()
132 # y size still must be fixed in font stuff...
133 textsize = (textsize[0], textsize[1] + 20)
134 wsize = (textsize[0] + 20, textsize[1] + 20)
137 self.instance.resize(eSize(*wsize))
140 self["text"].instance.resize(eSize(*textsize))
144 self.instance.move(ePoint(orgpos.x() + (orgwidth - newwidth)/2, orgpos.y()))
149 def parsePosition(str):
150 x, y = str.split(',')
151 return ePoint(int(x), int(y))
154 x, y = str.split(',')
155 return eSize(int(x), int(y))
158 name, size = str.split(';')
159 return gFont(name, int(size))
164 return colorNames[str]
166 raise ("color '%s' must be #aarrggbb or valid named color" % (str))
167 return gRGB(int(str[1:], 0x10))
169 def collectAttributes(skinAttributes, node):
170 # walk all attributes
171 for p in range(node.attributes.length):
172 a = node.attributes.item(p)
174 # convert to string (was: unicode)
176 # TODO: proper UTF8 translation?! (for value)
177 # TODO: localization? as in e1?
180 skinAttributes.append((attrib, value))
182 def applySingleAttribute(guiObject, desktop, attrib, value):
185 if attrib == 'position':
186 guiObject.move(parsePosition(value))
187 elif attrib == 'size':
188 guiObject.resize(parseSize(value))
189 elif attrib == 'title':
190 guiObject.setTitle(value)
191 elif attrib == 'text':
192 guiObject.setText(value)
193 elif attrib == 'font':
194 guiObject.setFont(parseFont(value))
195 elif attrib == "pixmap":
197 if loadPNG(ptr, value):
198 raise "loading PNG failed!"
200 ptr = ptr.__deref__()
201 desktop.makeCompatiblePixmap(ptr)
202 guiObject.setPixmap(ptr)
203 # guiObject.setPixmapFromFile(value)
204 elif attrib == "valign":
207 { "top": guiObject.alignTop,
208 "center": guiObject.alignCenter,
209 "bottom": guiObject.alignBottom
212 print "valign must be either top, center or bottom!"
213 elif attrib == "halign":
216 { "left": guiObject.alignLeft,
217 "center": guiObject.alignCenter,
218 "right": guiObject.alignRight,
219 "block": guiObject.alignBlock
222 print "halign must be either left, center, right or block!"
223 elif attrib == "flags":
224 flags = value.split(',')
227 fv = eWindow.__dict__[f]
228 guiObject.setFlag(fv)
230 print "illegal flag %s!" % f
231 elif attrib == "backgroundColor":
232 guiObject.setBackgroundColor(parseColor(value))
233 elif attrib == "foregroundColor":
234 guiObject.setForegroundColor(parseColor(value))
235 elif attrib != 'name':
236 print "unsupported attribute " + attrib + "=" + value
239 print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
241 def applyAllAttributes(guiObject, desktop, attributes):
242 for (attrib, value) in attributes:
243 applySingleAttribute(guiObject, desktop, attrib, value)
245 def loadSkin(desktop):
246 print "loading skin..."
254 skin = dom.childNodes[0]
255 assert skin.tagName == "skin", "root element in skin must be 'skin'!"
257 for c in elementsWithTag(skin.childNodes, "colors"):
258 for color in elementsWithTag(c.childNodes, "color"):
259 name = str(color.getAttribute("name"))
260 color = str(color.getAttribute("value"))
263 raise ("need color and name, got %s %s" % (name, color))
265 colorNames[name] = parseColor(color)
267 for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"):
268 style = eWindowStyleSkinned()
270 for borderset in elementsWithTag(windowstyle.childNodes, "borderset"):
271 bsName = str(borderset.getAttribute("name"))
272 for pixmap in elementsWithTag(borderset.childNodes, "pixmap"):
273 bpName = str(pixmap.getAttribute("pos"))
274 filename = str(pixmap.getAttribute("filename"))
276 png = getPNG(filename)
279 desktop.makeCompatiblePixmap(png)
280 style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
282 for color in elementsWithTag(windowstyle.childNodes, "color"):
283 type = str(color.getAttribute("name"))
284 color = parseColor(color.getAttribute("color"))
287 style.setColor(eWindowStyleSkinned.__dict__["col" + type], color)
289 raise ("Unknown color %s" % (type))
291 x = eWindowStyleManagerPtr()
292 eWindowStyleManager.getInstance(x)
295 def readSkin(screen, skin, name, desktop):
298 # first, find the corresponding screen element
299 skin = dom.childNodes[0]
301 for x in elementsWithTag(skin.childNodes, "screen"):
302 if x.getAttribute('name') == name:
306 assert myscreen != None, "no skin for screen '" + name + "' found!"
308 screen.skinAttributes = [ ]
309 collectAttributes(screen.skinAttributes, myscreen)
311 screen.additionalWidgets = [ ]
313 # now walk all widgets
314 for widget in elementsWithTag(myscreen.childNodes, "widget"):
315 wname = widget.getAttribute('name')
317 print "widget has no name!"
320 # get corresponding gui object
322 attributes = screen[wname].skinAttributes = [ ]
324 raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
326 collectAttributes(attributes, widget)
328 # now walk additional objects
329 for widget in elementsWithTag(myscreen.childNodes, lambda x: x != "widget"):
330 if widget.tagName == "applet":
331 codeText = mergeText(widget.childNodes).strip()
332 type = widget.getAttribute('type')
334 code = compile(codeText, "skin applet", "exec")
336 if type == "onLayoutFinish":
337 screen.onLayoutFinish.append(code)
339 raise str("applet type '%s' unknown!" % type)
343 class additionalWidget:
346 w = additionalWidget()
348 if widget.tagName == "eLabel":
350 elif widget.tagName == "ePixmap":
353 raise str("unsupported stuff : %s" % widget.tagName)
355 w.skinAttributes = [ ]
356 collectAttributes(w.skinAttributes, widget)
358 # applyAttributes(guiObject, widget, desktop)
359 # guiObject.thisown = 0
360 print screen.additionalWidgets
361 screen.additionalWidgets.append(w)