3 from xml.dom import EMPTY_NAMESPACE
5 from Tools.XMLTools import elementsWithTag
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="#294a6b" />
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" />
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" />
55 <screen name="ScartLoopThrough" position="0,0" size="720,576">
57 <screen name="ConfigMenu" position="300,100" size="300,300" title="real main menu">
58 <widget name="txt_var_1" position="20,20" size="100,20" />
59 <widget name="btn_var_1" position="110,20" size="200,20" />
60 <widget name="txt_var_2" position="20,60" size="100,20" />
61 <widget name="btn_var_2" position="110,60" size="200,20" />
63 <screen name="configOSD" position="140,125" size="460,350" title="OSD Settings">
64 <widget name="okbutton" position="20,245" size="205,40" />
65 <widget name="txt_alpha" position="20,20" size="110,20" />
66 <widget name="sld_alpha" position="150,20" size="290,20" />
67 <widget name="txt_brightness" position="20,60" size="120,20" />
68 <widget name="sld_brightness" position="150,20" size="290,20" />
69 <widget name="txt_gamma" position="20,100" size="120,20" />
70 <widget name="sld_gamma" position="150,100" size="290,20" />
72 <screen name="configTest" position="300,100" size="300,300" title="config menu">
73 <widget name="config" position="10,30" size="280,140" />
75 <screen name="TimerEditList" position="160,100" size="420,430" title="Timer Editor">
76 <widget name="timerlist" position="10,30" size="400,300" />
78 <screen name="clockDisplay" position="300,100" size="300,300">
79 <widget name="okbutton" position="10,10" size="280,40" />
80 <widget name="title" position="10,120" size="280,50" />
81 <widget name="theClock" position="10,60" size="280,50" />
83 <screen name="InfoBar" position="0,380" size="720,151" title="InfoBar" flags="wfNoBorder">
84 <ePixmap position="0,0" size="720,151" pixmap="data/info-bg.png" />
86 <widget name="ServiceName" position="69,30" size="427,26" valign="center" font="Arial;32" backgroundColor="#101258" />
87 <widget name="CurrentTime" position="575,10" size="66,30" backgroundColor="dark" font="Arial;16" />
88 <widget name="Event_Now" position="273,68" size="282,30" font="Arial;29" backgroundColor="dark" />
89 <widget name="Event_Next" position="273,98" size="282,30" font="Arial;29" backgroundColor="dark" />
90 <widget name="Event_Now_Duration" position="555,68" size="70,26" font="Arial;26" backgroundColor="dark" />
91 <widget name="Event_Next_Duration" position="555,98" size="70,26" font="Arial;26" backgroundColor="dark" />
92 <!-- <eLabel position="70,0" size="300,30" text=".oO skin Oo." font="Arial;20" /> -->
94 <screen name="ChannelSelection" position="90,100" size="560,420" title="Channel Selection">
95 <widget name="list" position="0,50" size="560,340" />
96 <!-- <widget name="okbutton" position="340,50" size="140,30" />-->
97 <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" />
98 <widget name="key_green" position="140,0" size="140,40" backgroundColor="green" />
99 <widget name="key_yellow" position="280,0" size="140,40" backgroundColor="yellow" />
100 <widget name="key_blue" position="420,0" size="140,40" backgroundColor="blue" />
102 <screen name="ServiceScan" position="150,100" size="300,200" title="Service Scan">
103 <widget name="scan_progress" position="10,10" size="280,50" />
104 <widget name="scan_state" position="10,60" size="280,30" />
106 <screen name="TimerEdit" position="70,100" size="590,335" title="Timer Edit">
107 <widget name="description" position="10,10" size="580,40" font="Arial;25"/>
108 <widget name="lbegin" position="405,102" size="103,30" font="Arial;25" />
109 <widget name="lend" position="405,158" size="103,30" font="Arial;25" />
110 <widget name="begin" position="508,105" size="72,35" font="Arial;25" />
111 <widget name="end" position="508,150" size="72,35" font="Arial;25" />
112 <widget name="apply" position="10,240" size="250,35" />
116 def parsePosition(str):
117 x, y = str.split(',')
118 return ePoint(int(x), int(y))
121 x, y = str.split(',')
122 return eSize(int(x), int(y))
125 name, size = str.split(';')
126 return gFont(name, int(size))
131 return colorNames[str]
133 raise ("color '%s' must be #aarrggbb or valid named color" % (str))
134 return gRGB(int(str[1:], 0x10))
136 def applyAttributes(guiObject, node, desktop):
137 # walk all attributes
138 for p in range(node.attributes.length):
139 a = node.attributes.item(p)
141 # convert to string (was: unicode)
143 # TODO: proper UTF8 translation?! (for value)
144 # TODO: localization? as in e1?
149 if attrib == 'position':
150 guiObject.move(parsePosition(value))
151 elif attrib == 'size':
152 guiObject.resize(parseSize(value))
153 elif attrib == 'title':
154 guiObject.setTitle(value)
155 elif attrib == 'text':
156 guiObject.setText(value)
157 elif attrib == 'font':
158 guiObject.setFont(parseFont(value))
159 elif attrib == "pixmap":
161 if loadPNG(ptr, value):
162 raise "loading PNG failed!"
164 ptr = ptr.__deref__()
165 desktop.makeCompatiblePixmap(ptr)
166 guiObject.setPixmap(ptr)
167 # guiObject.setPixmapFromFile(value)
168 elif attrib == "valign":
171 { "top": guiObject.alignTop,
172 "center": guiObject.alignCenter,
173 "bottom": guiObject.alignBottom
176 print "valign must be either top, center or bottom!"
177 elif attrib == "halign":
180 { "left": guiObject.alignLeft,
181 "center": guiObject.alignCenter,
182 "right": guiObject.alignRight,
183 "block": guiObject.alignBlock
186 print "halign must be either left, center, right or block!"
187 elif attrib == "flags":
188 flags = value.split(',')
191 fv = eWindow.__dict__[f]
192 guiObject.setFlag(fv)
194 print "illegal flag %s!" % f
195 elif attrib == "backgroundColor":
196 guiObject.setBackgroundColor(parseColor(value))
197 elif attrib != 'name':
198 print "unsupported attribute " + attrib + "=" + value
199 except AttributeError:
200 print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
202 def loadSkin(desktop):
203 print "loading skin..."
211 skin = dom.childNodes[0]
212 assert skin.tagName == "skin", "root element in skin must be 'skin'!"
214 for c in elementsWithTag(skin.childNodes, "colors"):
215 for color in elementsWithTag(c.childNodes, "color"):
216 name = str(color.getAttribute("name"))
217 color = str(color.getAttribute("value"))
220 raise ("need color and name, got %s %s" % (name, color))
222 colorNames[name] = parseColor(color)
224 for windowstyle in elementsWithTag(skin.childNodes, "windowstyle"):
225 style = eWindowStyleSkinned()
227 for borderset in elementsWithTag(windowstyle.childNodes, "borderset"):
228 bsName = str(borderset.getAttribute("name"))
229 for pixmap in elementsWithTag(borderset.childNodes, "pixmap"):
230 bpName = str(pixmap.getAttribute("pos"))
231 filename = str(pixmap.getAttribute("filename"))
233 png = getPNG(filename)
236 desktop.makeCompatiblePixmap(png)
237 style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
239 for color in elementsWithTag(windowstyle.childNodes, "color"):
240 type = str(color.getAttribute("name"))
241 color = parseColor(color.getAttribute("color"))
244 style.setColor(eWindowStyleSkinned.__dict__["col" + type], color)
246 raise ("Unknown color %s" % (type))
248 x = eWindowStyleManagerPtr()
249 eWindowStyleManager.getInstance(x)
252 def applyGUIskin(screen, skin, name, desktop):
255 # first, find the corresponding screen element
256 skin = dom.childNodes[0]
258 for x in elementsWithTag(skin.childNodes, "screen"):
259 if x.getAttribute('name') == name:
263 assert myscreen != None, "no skin for screen '" + name + "' found!"
265 applyAttributes(screen.instance, myscreen, desktop)
267 # now walk all widgets
268 for widget in elementsWithTag(myscreen.childNodes, "widget"):
269 wname = widget.getAttribute('name')
271 print "widget has no name!"
274 # get corresponding gui object
276 guiObject = screen[wname].instance
278 raise str("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
280 applyAttributes(guiObject, widget, desktop)
282 # now walk additional objects
283 for widget in elementsWithTag(myscreen.childNodes, lambda x: x != "widget"):
284 if widget.tagName == "eLabel":
285 guiObject = eLabel(screen.instance)
286 elif widget.tagName == "ePixmap":
287 guiObject = ePixmap(screen.instance)
289 raise str("unsupported stuff : %s" % widget.tagName)
291 applyAttributes(guiObject, widget, desktop )
292 guiObject.thisown = 0