enigma2 20130114 (master) -> 20130216 (master)
[enigma2.git] / usr / lib / enigma2 / python / skin.py
1 from Tools.Profile import profile
2 profile("LOAD:ElementTree")
3 import xml.etree.cElementTree
4 from os import path
5
6 profile("LOAD:enigma_skin")
7 from enigma import eSize, ePoint, gFont, eWindow, eLabel, ePixmap, eWindowStyleManager, \
8         addFont, gRGB, eWindowStyleSkinned
9 from Components.config import ConfigSubsection, ConfigText, config
10 from Components.Converter.Converter import Converter
11 from Components.Sources.Source import Source, ObsoleteSource
12 from Tools.Directories import resolveFilename, SCOPE_SKIN, SCOPE_SKIN_IMAGE, SCOPE_FONTS, SCOPE_CURRENT_SKIN, SCOPE_CONFIG, fileExists
13 from Tools.Import import my_import
14 from Tools.LoadPixmap import LoadPixmap
15
16 colorNames = dict()
17
18 def dump(x, i=0):
19         print " " * i + str(x)
20         try:
21                 for n in x.childNodes:
22                         dump(n, i + 1)
23         except:
24                 None
25
26 class SkinError(Exception):
27         def __init__(self, message):
28                 self.msg = message
29
30         def __str__(self):
31                 return "{%s}: %s" % (config.skin.primary_skin.value, self.msg)
32
33 dom_skins = [ ]
34
35 def loadSkin(name, scope = SCOPE_SKIN):
36         # read the skin
37         filename = resolveFilename(scope, name)
38         mpath = path.dirname(filename) + "/"
39         dom_skins.append((mpath, xml.etree.cElementTree.parse(filename).getroot()))
40
41 # we do our best to always select the "right" value
42 # skins are loaded in order of priority: skin with
43 # highest priority is loaded last, usually the user-provided
44 # skin.
45
46 # currently, loadSingleSkinData (colors, bordersets etc.)
47 # are applied one-after-each, in order of ascending priority.
48 # the dom_skin will keep all screens in descending priority,
49 # so the first screen found will be used.
50
51 # example: loadSkin("nemesis_greenline/skin.xml")
52 config.skin = ConfigSubsection()
53 config.skin.primary_skin = ConfigText(default = "skin.xml")
54
55 profile("LoadSkin")
56 try:
57         loadSkin('skin_user.xml', SCOPE_CONFIG)
58 except (SkinError, IOError, AssertionError), err:
59         print "not loading user skin: ", err
60
61 try:
62         loadSkin(config.skin.primary_skin.value)
63 except (SkinError, IOError, AssertionError), err:
64         print "SKIN ERROR:", err
65         print "defaulting to standard skin..."
66         config.skin.primary_skin.value = 'skin.xml'
67         loadSkin('skin.xml')
68
69 profile("LoadSkinDefault")
70 loadSkin('skin_default.xml')
71 profile("LoadSkinDefaultDone")
72
73 def evalPos(pos, wsize, ssize, scale):
74         if pos == "center":
75                 pos = (ssize - wsize) / 2
76         else:
77                 pos = int(pos) * scale[0] / scale[1]
78         return int(pos)
79
80 def parsePosition(str, scale, desktop = None, size = None):
81         x, y = str.split(',')
82         
83         wsize = 1, 1
84         ssize = 1, 1
85         if desktop is not None:
86                 ssize = desktop.size().width(), desktop.size().height()
87         if size is not None:
88                 wsize = size.width(), size.height()
89
90         x = evalPos(x, wsize[0], ssize[0], scale[0])
91         y = evalPos(y, wsize[1], ssize[1], scale[1])
92
93         return ePoint(x, y)
94
95 def parseSize(str, scale):
96         x, y = str.split(',')
97         return eSize(int(x) * scale[0][0] / scale[0][1], int(y) * scale[1][0] / scale[1][1])
98
99 def parseFont(str, scale):
100         name, size = str.split(';')
101         return gFont(name, int(size) * scale[0][0] / scale[0][1])
102
103 def parseColor(str):
104         if str[0] != '#':
105                 try:
106                         return colorNames[str]
107                 except:
108                         raise SkinError("color '%s' must be #aarrggbb or valid named color" % (str))
109         return gRGB(int(str[1:], 0x10))
110
111 def collectAttributes(skinAttributes, node, skin_path_prefix=None, ignore=[]):
112         # walk all attributes
113         for a in node.items():
114                 #print a
115                 attrib = a[0]
116                 value = a[1]
117
118                 if attrib in ("pixmap", "pointer", "seek_pointer", "backgroundPixmap", "selectionPixmap"):
119                         value = resolveFilename(SCOPE_SKIN_IMAGE, value, path_prefix=skin_path_prefix)
120
121                 if attrib not in ignore:
122                         skinAttributes.append((attrib, value.encode("utf-8")))
123
124 def loadPixmap(path, desktop):
125         cached = False
126         option = path.find("#")
127         if option != -1:
128                 options = path[option+1:].split(',')
129                 path = path[:option]
130                 cached = "cached" in options
131         ptr = LoadPixmap(path, desktop, cached)
132         if ptr is None:
133                 raise SkinError("pixmap file %s not found!" % (path))
134         return ptr
135
136 def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1))):
137         # and set attributes
138         try:
139                 if attrib == 'position':
140                         guiObject.move(parsePosition(value, scale, desktop, guiObject.csize()))
141                 elif attrib == 'size':
142                         guiObject.resize(parseSize(value, scale))
143                 elif attrib == 'title':
144                         guiObject.setTitle(_(value))
145                 elif attrib == 'text':
146                         guiObject.setText(_(value))
147                 elif attrib == 'font':
148                         guiObject.setFont(parseFont(value, scale))
149                 elif attrib == 'zPosition':
150                         guiObject.setZPosition(int(value))
151                 elif attrib == 'itemHeight':
152                         guiObject.setItemHeight(int(value))
153                 elif attrib in ("pixmap", "backgroundPixmap", "selectionPixmap", "scrollbarSliderPicture", "scrollbarSliderBackgroundPicture"):
154                         ptr = loadPixmap(value, desktop) # this should already have been filename-resolved.
155                         if attrib == "pixmap":
156                                 guiObject.setPixmap(ptr)
157                         elif attrib == "backgroundPixmap":
158                                 guiObject.setBackgroundPicture(ptr)
159                         elif attrib == "selectionPixmap":
160                                 guiObject.setSelectionPicture(ptr)
161                         elif attrib == "scrollbarSliderPicture":
162                                 guiObject.setScrollbarSliderPicture(ptr)
163                         elif attrib == "scrollbarSliderBackgroundPicture":
164                                 guiObject.setScrollbarSliderBackgroundPicture(ptr)
165                         # guiObject.setPixmapFromFile(value)
166                 elif attrib == "alphatest": # used by ePixmap
167                         guiObject.setAlphatest(
168                                 { "on": 1,
169                                   "off": 0,
170                                   "blend": 2,
171                                 }[value])
172                 elif attrib == "scale":
173                         guiObject.setScale(1)
174                 elif attrib == "orientation": # used by eSlider
175                         try:
176                                 guiObject.setOrientation(*
177                                         { "orVertical": (guiObject.orVertical, False),
178                                                 "orTopToBottom": (guiObject.orVertical, False),
179                                                 "orBottomToTop": (guiObject.orVertical, True),
180                                                 "orHorizontal": (guiObject.orHorizontal, False),
181                                                 "orLeftToRight": (guiObject.orHorizontal, False),
182                                                 "orRightToLeft": (guiObject.orHorizontal, True),
183                                         }[value])
184                         except KeyError:
185                                 print "oprientation must be either orVertical or orHorizontal!"
186                 elif attrib == "valign":
187                         try:
188                                 guiObject.setVAlign(
189                                         { "top": guiObject.alignTop,
190                                                 "center": guiObject.alignCenter,
191                                                 "bottom": guiObject.alignBottom
192                                         }[value])
193                         except KeyError:
194                                 print "valign must be either top, center or bottom!"
195                 elif attrib == "halign":
196                         try:
197                                 guiObject.setHAlign(
198                                         { "left": guiObject.alignLeft,
199                                                 "center": guiObject.alignCenter,
200                                                 "right": guiObject.alignRight,
201                                                 "block": guiObject.alignBlock
202                                         }[value])
203                         except KeyError:
204                                 print "halign must be either left, center, right or block!"
205                 elif attrib == "flags":
206                         flags = value.split(',')
207                         for f in flags:
208                                 try:
209                                         fv = eWindow.__dict__[f]
210                                         guiObject.setFlag(fv)
211                                 except KeyError:
212                                         print "illegal flag %s!" % f
213                 elif attrib == "backgroundColor":
214                         guiObject.setBackgroundColor(parseColor(value))
215                 elif attrib == "backgroundColorSelected":
216                         guiObject.setBackgroundColorSelected(parseColor(value))
217                 elif attrib == "foregroundColor":
218                         guiObject.setForegroundColor(parseColor(value))
219                 elif attrib == "foregroundColorSelected":
220                         guiObject.setForegroundColorSelected(parseColor(value))
221                 elif attrib == "shadowColor":
222                         guiObject.setShadowColor(parseColor(value))
223                 elif attrib == "selectionDisabled":
224                         guiObject.setSelectionEnable(0)
225                 elif attrib == "transparent":
226                         guiObject.setTransparent(int(value))
227                 elif attrib == "borderColor":
228                         guiObject.setBorderColor(parseColor(value))
229                 elif attrib == "borderWidth":
230                         guiObject.setBorderWidth(int(value))
231                 elif attrib == "scrollbarSliderBorderWidth":
232                         guiObject.setScrollbarSliderBorderWidth(int(value))
233                 elif attrib == "scrollbarWidth":
234                         guiObject.setScrollbarWidth(int(value))
235                 elif attrib == "scrollbarMode":
236                         guiObject.setScrollbarMode(
237                                 { "showOnDemand": guiObject.showOnDemand,
238                                         "showAlways": guiObject.showAlways,
239                                         "showNever": guiObject.showNever
240                                 }[value])
241                 elif attrib == "enableWrapAround":
242                         guiObject.setWrapAround(True)
243                 elif attrib == "backlogMode":
244                         guiObject.setBacklogMode(True)
245                 elif attrib == "pointer" or attrib == "seek_pointer":
246                         (name, pos) = value.split(':')
247                         pos = parsePosition(pos, scale)
248                         ptr = loadPixmap(name, desktop)
249                         guiObject.setPointer({"pointer": 0, "seek_pointer": 1}[attrib], ptr, pos)
250                 elif attrib == 'shadowOffset':
251                         guiObject.setShadowOffset(parsePosition(value, scale))
252                 elif attrib == 'noWrap':
253                         guiObject.setNoWrap(1)
254                 elif attrib == 'id':
255                         pass
256                 else:
257                         raise SkinError("unsupported attribute " + attrib + "=" + value)
258         except int:
259 # AttributeError:
260                 print "widget %s (%s) doesn't support attribute %s!" % ("", guiObject.__class__.__name__, attrib)
261
262 def applyAllAttributes(guiObject, desktop, attributes, scale):
263         for (attrib, value) in attributes:
264                 applySingleAttribute(guiObject, desktop, attrib, value, scale)
265
266 def loadSingleSkinData(desktop, skin, path_prefix):
267         """loads skin data like colors, windowstyle etc."""
268         assert skin.tag == "skin", "root element in skin must be 'skin'!"
269
270         #print "***SKIN: ", path_prefix
271
272         for c in skin.findall("output"):
273                 id = c.attrib.get('id')
274                 if id:
275                         id = int(id)
276                 else:
277                         id = 0
278                 if id == 0: # framebuffer
279                         for res in c.findall("resolution"):
280                                 get_attr = res.attrib.get
281                                 xres = get_attr("xres")
282                                 if xres:
283                                         xres = int(xres)
284                                 else:
285                                         xres = 720
286                                 yres = get_attr("yres")
287                                 if yres:
288                                         yres = int(yres)
289                                 else:
290                                         yres = 576
291                                 bpp = get_attr("bpp")
292                                 if bpp:
293                                         bpp = int(bpp)
294                                 else:
295                                         bpp = 32
296                                 #print "Resolution:", xres,yres,bpp
297                                 from enigma import gMainDC
298                                 gMainDC.getInstance().setResolution(xres, yres)
299                                 desktop.resize(eSize(xres, yres))
300                                 if bpp != 32:
301                                         # load palette (not yet implemented)
302                                         pass
303
304         for c in skin.findall("colors"):
305                 for color in c.findall("color"):
306                         get_attr = color.attrib.get
307                         name = get_attr("name")
308                         color = get_attr("value")
309                         if name and color:
310                                 colorNames[name] = parseColor(color)
311                                 #print "Color:", name, color
312                         else:
313                                 raise SkinError("need color and name, got %s %s" % (name, color))
314
315         for c in skin.findall("fonts"):
316                 for font in c.findall("font"):
317                         get_attr = font.attrib.get
318                         filename = get_attr("filename", "<NONAME>")
319                         name = get_attr("name", "Regular")
320                         scale = get_attr("scale")
321                         if scale:
322                                 scale = int(scale)
323                         else:
324                                 scale = 100
325                         is_replacement = get_attr("replacement") and True or False
326                         resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
327                         if not fileExists(resolved_font): #when font is not available look at current skin path
328                                 skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
329                                 if fileExists(skin_path):
330                                         resolved_font = skin_path
331                         addFont(resolved_font, name, scale, is_replacement)
332                         #print "Font: ", resolved_font, name, scale, is_replacement
333
334         for c in skin.findall("subtitles"):
335                 from enigma import eWidget, eSubtitleWidget
336                 scale = ((1,1),(1,1))
337                 for substyle in c.findall("sub"):
338                         get_attr = substyle.attrib.get
339                         font = parseFont(get_attr("font"), scale)
340                         col = get_attr("foregroundColor")
341                         if col:
342                                 foregroundColor = parseColor(col)
343                                 haveColor = 1
344                         else:
345                                 foregroundColor = gRGB(0xFFFFFF)
346                                 haveColor = 0
347                         col = get_attr("shadowColor")
348                         if col:
349                                 shadowColor = parseColor(col)
350                         else:
351                                 shadowColor = gRGB(0)
352                         shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
353                         face = eSubtitleWidget.__dict__[get_attr("name")]
354                         eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, shadowColor, shadowOffset)
355
356         for windowstyle in skin.findall("windowstyle"):
357                 style = eWindowStyleSkinned()
358                 id = windowstyle.attrib.get("id")
359                 if id:
360                         id = int(id)
361                 else:
362                         id = 0
363                 #print "windowstyle:", id
364
365                 # defaults
366                 font = gFont("Regular", 20)
367                 offset = eSize(20, 5)
368
369                 for title in windowstyle.findall("title"):
370                         get_attr = title.attrib.get
371                         offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
372                         font = parseFont(get_attr("font"), ((1,1),(1,1)))
373
374                 style.setTitleFont(font);
375                 style.setTitleOffset(offset)
376                 #print "  ", font, offset
377
378                 for borderset in windowstyle.findall("borderset"):
379                         bsName = str(borderset.attrib.get("name"))
380                         for pixmap in borderset.findall("pixmap"):
381                                 get_attr = pixmap.attrib.get
382                                 bpName = get_attr("pos")
383                                 filename = get_attr("filename")
384                                 if filename and bpName:
385                                         png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
386                                         style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
387                                 #print "  borderset:", bpName, filename
388
389                 for color in windowstyle.findall("color"):
390                         get_attr = color.attrib.get
391                         colorType = get_attr("name")
392                         color = parseColor(get_attr("color"))
393                         try:
394                                 style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
395                         except:
396                                 raise SkinError("Unknown color %s" % (colorType))
397                                 #pass
398
399                         #print "  color:", type, color
400
401                 x = eWindowStyleManager.getInstance()
402                 x.setStyle(id, style)
403
404 def loadSkinData(desktop):
405         skins = dom_skins[:]
406         skins.reverse()
407         for (path, dom_skin) in skins:
408                 loadSingleSkinData(desktop, dom_skin, path)
409
410 def lookupScreen(name, style_id):
411         for (path, skin) in dom_skins:
412                 # first, find the corresponding screen element
413                 for x in skin.findall("screen"):
414                         if x.attrib.get('name', '') == name:
415                                 screen_style_id = x.attrib.get('id', '-1')
416                                 if screen_style_id == '-1' and name.find('ummary') > 0:
417                                         screen_style_id = '1'
418                                 if (style_id != 2 and int(screen_style_id) == -1) or int(screen_style_id) == style_id:
419                                         return x, path
420         return None, None
421
422 class additionalWidget:
423         pass
424
425 def readSkin(screen, skin, names, desktop):
426         if not isinstance(names, list):
427                 names = [names]
428
429         name = "<embedded-in-'%s'>" % screen.__class__.__name__
430
431         style_id = desktop.getStyleID();
432
433         # try all skins, first existing one have priority
434         for n in names:
435                 myscreen, path = lookupScreen(n, style_id)
436                 if myscreen is not None:
437                         # use this name for debug output
438                         name = n
439                         break
440
441         # otherwise try embedded skin
442         if myscreen is None:
443                 myscreen = getattr(screen, "parsedSkin", None)
444
445         # try uncompiled embedded skin
446         if myscreen is None and getattr(screen, "skin", None):
447                 print "Looking for embedded skin"
448                 skin_tuple = screen.skin
449                 if not isinstance(skin_tuple, tuple):
450                         skin_tuple = (skin_tuple,)
451                 for sskin in skin_tuple:
452                         parsedSkin = xml.etree.cElementTree.fromstring(sskin)
453                         screen_style_id = parsedSkin.attrib.get('id', '-1')
454                         if (style_id != 2 and int(screen_style_id) == -1) or int(screen_style_id) == style_id:
455                                 myscreen = screen.parsedSkin = parsedSkin
456                                 break
457
458         #assert myscreen is not None, "no skin for screen '" + repr(names) + "' found!"
459         if myscreen is None:
460                 print "No skin to read..."
461                 emptySkin = "<screen></screen>"
462                 myscreen = screen.parsedSkin = xml.etree.cElementTree.fromstring(emptySkin)
463
464         screen.skinAttributes = [ ]
465
466         skin_path_prefix = getattr(screen, "skin_path", path)
467
468         collectAttributes(screen.skinAttributes, myscreen, skin_path_prefix, ignore=["name"])
469
470         screen.additionalWidgets = [ ]
471         screen.renderer = [ ]
472
473         visited_components = set()
474
475         # now walk all widgets
476         for widget in myscreen.findall("widget"):
477                 get_attr = widget.attrib.get
478                 # ok, we either have 1:1-mapped widgets ('old style'), or 1:n-mapped
479                 # widgets (source->renderer).
480
481                 wname = get_attr('name')
482                 wsource = get_attr('source')
483
484                 if wname is None and wsource is None:
485                         print "widget has no name and no source!"
486                         continue
487
488                 if wname:
489                         #print "Widget name=", wname
490                         visited_components.add(wname)
491
492                         # get corresponding 'gui' object
493                         try:
494                                 attributes = screen[wname].skinAttributes = [ ]
495                         except:
496                                 raise SkinError("component with name '" + wname + "' was not found in skin of screen '" + name + "'!")
497                                 #print "WARNING: component with name '" + wname + "' was not found in skin of screen '" + name + "'!"
498
499 #                       assert screen[wname] is not Source
500
501                         # and collect attributes for this
502                         collectAttributes(attributes, widget, skin_path_prefix, ignore=['name'])
503                 elif wsource:
504                         # get corresponding source
505                         #print "Widget source=", wsource
506
507                         while True: # until we found a non-obsolete source
508
509                                 # parse our current "wsource", which might specifiy a "related screen" before the dot,
510                                 # for example to reference a parent, global or session-global screen.
511                                 scr = screen
512
513                                 # resolve all path components
514                                 path = wsource.split('.')
515                                 while len(path) > 1:
516                                         scr = screen.getRelatedScreen(path[0])
517                                         if scr is None:
518                                                 #print wsource
519                                                 #print name
520                                                 raise SkinError("specified related screen '" + wsource + "' was not found in screen '" + name + "'!")
521                                         path = path[1:]
522
523                                 # resolve the source.
524                                 source = scr.get(path[0])
525                                 if isinstance(source, ObsoleteSource):
526                                         # however, if we found an "obsolete source", issue warning, and resolve the real source.
527                                         print "WARNING: SKIN '%s' USES OBSOLETE SOURCE '%s', USE '%s' INSTEAD!" % (name, wsource, source.new_source)
528                                         print "OBSOLETE SOURCE WILL BE REMOVED %s, PLEASE UPDATE!" % (source.removal_date)
529                                         if source.description:
530                                                 print source.description
531
532                                         wsource = source.new_source
533                                 else:
534                                         # otherwise, use that source.
535                                         break
536
537                         if source is None:
538                                 raise SkinError("source '" + wsource + "' was not found in screen '" + name + "'!")
539
540                         wrender = get_attr('render')
541
542                         if not wrender:
543                                 raise SkinError("you must define a renderer with render= for source '%s'" % (wsource))
544
545                         for converter in widget.findall("convert"):
546                                 ctype = converter.get('type')
547                                 assert ctype, "'convert'-tag needs a 'type'-attribute"
548                                 #print "Converter:", ctype
549                                 try:
550                                         parms = converter.text.strip()
551                                 except:
552                                         parms = ""
553                                 #print "Params:", parms
554                                 converter_class = my_import('.'.join(("Components", "Converter", ctype))).__dict__.get(ctype)
555
556                                 c = None
557
558                                 for i in source.downstream_elements:
559                                         if isinstance(i, converter_class) and i.converter_arguments == parms:
560                                                 c = i
561
562                                 if c is None:
563                                         print "allocating new converter!"
564                                         c = converter_class(parms)
565                                         c.connect(source)
566                                 else:
567                                         print "reused converter!"
568
569                                 source = c
570
571                         renderer_class = my_import('.'.join(("Components", "Renderer", wrender))).__dict__.get(wrender)
572
573                         renderer = renderer_class() # instantiate renderer
574
575                         renderer.connect(source) # connect to source
576                         attributes = renderer.skinAttributes = [ ]
577                         collectAttributes(attributes, widget, skin_path_prefix, ignore=['render', 'source'])
578
579                         screen.renderer.append(renderer)
580
581         from Components.GUIComponent import GUIComponent
582         nonvisited_components = [x for x in set(screen.keys()) - visited_components if isinstance(x, GUIComponent)]
583         assert not nonvisited_components, "the following components in %s don't have a skin entry: %s" % (name, ', '.join(nonvisited_components))
584
585         # now walk additional objects
586         for widget in myscreen.getchildren():
587                 w_tag = widget.tag
588
589                 if w_tag == "widget":
590                         continue
591
592                 if w_tag == "applet":
593                         try:
594                                 codeText = widget.text.strip()
595                         except:
596                                 codeText = ""
597
598                         #print "Found code:"
599                         #print codeText
600                         widgetType = widget.attrib.get('type')
601
602                         code = compile(codeText, "skin applet", "exec")
603
604                         if widgetType == "onLayoutFinish":
605                                 screen.onLayoutFinish.append(code)
606                                 #print "onLayoutFinish = ", codeText
607                         else:
608                                 raise SkinError("applet type '%s' unknown!" % widgetType)
609                                 #print "applet type '%s' unknown!" % type
610
611                         continue
612
613                 w = additionalWidget()
614
615                 if w_tag == "eLabel":
616                         w.widget = eLabel
617                 elif w_tag == "ePixmap":
618                         w.widget = ePixmap
619                 else:
620                         raise SkinError("unsupported stuff : %s" % w_tag)
621                         #print "unsupported stuff : %s" % widget.tag
622
623                 w.skinAttributes = [ ]
624                 collectAttributes(w.skinAttributes, widget, skin_path_prefix, ignore=['name'])
625
626                 # applyAttributes(guiObject, widget, desktop)
627                 # guiObject.thisown = 0
628                 screen.additionalWidgets.append(w)
629
630 class TemplatedColors():
631         def __init__(self, style_id = 0):
632                 from enigma import eWindowStyleManager, eWindowStyleSkinned, gRGB
633                 x = eWindowStyleManager.getInstance()
634                 style = x.getStyle(style_id)
635                 self.colors = {}
636                 for color_name in ("Background", "LabelForeground", "ListboxForeground", "ListboxSelectedForeground", "ListboxBackground", "ListboxSelectedBackground", "ListboxMarkedForeground", "ListboxMarkedAndSelectedForeground", "ListboxMarkedBackground", "ListboxMarkedAndSelectedBackground", "WindowTitleForeground", "WindowTitleBackground"):
637                         color = gRGB(0)
638                         style.getColor(eWindowStyleSkinned.__dict__["col"+color_name], color)
639                         self.colors[color_name] = color.argb()
640         
641         def __getitem__(self, color_name):
642                 return color_name in self.colors and self.colors[color_name] or 0x000000
643