Exemplo n.º 1
0
   def keyOK(self):
       if self["config"].instance is None:
           return
       if self.reorderingEnabled:
           if not self.reorderingMode:
               self["config"].instance.setForegroundColorSelected(gRGB(0xFF0505))
               self.reorderingMode = True
           else:
               self["config"].instance.setForegroundColorSelected(gRGB(0xFFFFFF))
               self.reorderingMode = False
           self.runSetup()
           return
 
       curIndex = self["config"].getCurrentIndex()
       currItem = self["config"].list[curIndex][1]
       if curIndex < len(self.listOfHostsNames):
           hostName = self.listOfHostsNames[curIndex]
           if self.hostsConfigsAvailableList[curIndex] and IsHostEnabled(hostName):
               addConf = False
               try:
                   self.host = __import__('Plugins.Extensions.IPTVPlayer.hosts.host' + hostName, globals(), locals(), ['GetConfigList'], -1)
                   if( len(self.host.GetConfigList()) < 1 ):
                       printDBG('ConfigMenu host "%s" does not have additional configs' % hostName)
                   else:
                       self.session.open(ConfigHostMenu, hostName = hostName)
                       addConf = True
               except:
                   printExc('ConfigMenu host "%s" does not have method GetConfigList' % hostName)
               if not addConf:
                   self.hostsConfigsAvailableList[curIndex] = False
                   self.onSelectionChanged()
                   self.session.open(MessageBox, _("Service [%s] has no additional settings.") % hostName, type=MessageBox.TYPE_INFO, timeout=5)
       else:
           ConfigBaseWidget.keyOK(self)
 def _changeMode(self):
         if not self.reorderingMode:
             self["list"].instance.setForegroundColorSelected(gRGB(0xFF0505))
             self.reorderingMode = True
         else:
             self["list"].instance.setForegroundColorSelected(gRGB(0xFFFFFF))
             self.reorderingMode = False
         self.displayList()
Exemplo n.º 3
0
 def __init__(self):
     Renderer.__init__(self)
     self.fColor = gRGB(255, 255, 255, 0)
     self.fColors = gRGB(255, 0, 0, 0)
     self.fColorm = gRGB(255, 0, 0, 0)
     self.fColorh = gRGB(255, 255, 255, 0)
     self.bColor = gRGB(0, 0, 0, 255)
     self.forend = -1
     self.linewidth = 1
Exemplo n.º 4
0
	def draw(self, list):
		for l in list:
			if l[0] == 1:
				self.instance.fillRect(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]))
			elif l[0] == 2:
				self.instance.writeText(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]), gRGB(l[6]), l[7], l[8], l[9])
			else:
				print "drawlist entry:", l
				raise RuntimeError("invalid drawlist entry")
Exemplo n.º 5
0
	def __init__(self):
		Renderer.__init__(self)
		self.fColor = gRGB(255, 255, 255, 0)
		self.fColors = gRGB(255, 0, 0, 0)
		self.fColorm = gRGB(255, 0, 0, 0)
		self.fColorh = gRGB(255, 255, 255, 0)
		self.bColor = gRGB(0, 0, 0, 255)
		self.forend = -1
		self.linewidth = 1
Exemplo n.º 6
0
 def __init__(self):
     Renderer.__init__(self)
     self.fColor = gRGB(255, 255, 255, 0)
     self.fColors = gRGB(255, 0, 0, 0)
     self.fColorm = gRGB(255, 0, 0, 0)
     self.fColorh = gRGB(255, 255, 255, 0)
     self.bColor = gRGB(0, 0, 0, 255)
     self.forend = -1
     self.linewidth = 1
     self.positionheight = 1
     self.positionwidth = 1
     self.linesize = 1
Exemplo n.º 7
0
 def __init__(self):
     Renderer.__init__(self)
     self.fColor = gRGB(255, 255, 255, 0)
     self.fColors = gRGB(255, 0, 0, 0)
     self.fColorm = gRGB(255, 0, 0, 0)
     self.fColorh = gRGB(255, 255, 255, 0)
     self.bColor = gRGB(0, 0, 0, 255)
     self.forend = -1
     self.linewidth = 1
     self.positionheight = 1
     self.positionwidth = 1
     self.linesize = 1
Exemplo n.º 8
0
 def draw(self, list):
     for l in list:
         if l[0] == 1:
             self.instance.fillRect(eRect(l[1], l[2], l[3], l[4]),
                                    gRGB(l[5]))
         elif l[0] == 2:
             self.instance.writeText(eRect(l[1], l[2], l[3], l[4]),
                                     gRGB(l[5]), gRGB(l[6]), l[7], l[8],
                                     l[9])
         else:
             print("drawlist entry:", l)
             raise RuntimeError("invalid drawlist entry")
Exemplo n.º 9
0
 def draw(self, list):
     for l in list:
         if l[0] == 1:
             self.instance.fillRect(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]))
         elif l[0] == 2:
             self.instance.writeText(eRect(l[1], l[2], l[3], l[4]), gRGB(l[5]), gRGB(l[6]), l[7], l[8], l[9])
         elif l[0] == 3:
             self.instance.drawLine(l[1], l[2], l[3], l[4], gRGB(l[5]))
         elif l[0] == 4:
             self.instance.drawRotatedLine(l[1], l[2], l[3], l[4], l[5], l[6], l[7], l[8], gRGB(l[9]))
         else:
             print 'drawlist entry:', l
             raise RuntimeError('invalid drawlist entry')
 def __init__(self):
     Renderer.__init__(self)
     self.EPGcache = eEPGCache.getInstance()
     self.numEvents = 4
     self.numDescLines = 1
     self.testSizeLabel = None
     self.fcolor = gRGB(255, 255, 255)
     self.bcolor = gRGB(0, 0, 0)
     self.fdcolor = gRGB(255, 255, 255)
     self.timecolor = gRGB(255, 255, 255)
     self.used_font = gFont("Regular", 16)
     self.desc_font = gFont("Regular", 14)
     self.W = self.H = 0
     self.lineHeight = self.lineHeight_desc = self.timeWidth = 0
Exemplo n.º 11
0
    def keyOK(self):
        if self["config"].instance is None:
            return
        if self.reorderingEnabled:
            if not self.reorderingMode:
                self["config"].instance.setForegroundColorSelected(
                    gRGB(0xFF0505))
                self.reorderingMode = True
            else:
                self["config"].instance.setForegroundColorSelected(
                    gRGB(0xFFFFFF))
                self.reorderingMode = False
            self.runSetup()
            return

        curIndex = self["config"].getCurrentIndex()
        currItem = self["config"].list[curIndex][1]
        if curIndex < len(self.listOfHostsNames):
            hostName = self.listOfHostsNames[curIndex]
            if self.hostsConfigsAvailableList[curIndex] and IsHostEnabled(
                    hostName):
                addConf = False
                try:
                    self.host = __import__(
                        'Plugins.Extensions.IPTVPlayer.hosts.host' + hostName,
                        globals(), locals(), ['GetConfigList'], -1)
                    if (len(self.host.GetConfigList()) < 1):
                        printDBG(
                            'ConfigMenu host "%s" does not have additional configs'
                            % hostName)
                    else:
                        self.session.open(ConfigHostMenu, hostName=hostName)
                        addConf = True
                except:
                    printExc(
                        'ConfigMenu host "%s" does not have method GetConfigList'
                        % hostName)
                if not addConf:
                    self.hostsConfigsAvailableList[curIndex] = False
                    self.onSelectionChanged()
                    self.session.open(
                        MessageBox,
                        _("Service [%s] has no additional settings.") %
                        hostName,
                        type=MessageBox.TYPE_INFO,
                        timeout=5)
        else:
            ConfigBaseWidget.keyOK(self)
Exemplo n.º 12
0
def parseColor(s):
	if s[0] != '#':
		try:
			return colorNames[s]
		except:
			raise SkinError("[Skin] color '%s' must be #aarrggbb or valid named color" % s)
	return gRGB(int(s[1:], 0x10))
Exemplo n.º 13
0
def parseColor(s):
	if s[0] != "#":
		try:
			return colors[s]
		except KeyError:
			raise SkinError("Color '%s' must be #aarrggbb or valid named color" % s)
	return gRGB(int(s[1:], 0x10))
Exemplo n.º 14
0
def parseColor(str):
	if str[0] != '#':
		try:
			return colorNames[str]
		except:
			raise SkinError("color '%s' must be #aarrggbb or valid named color" % (str))
	return gRGB(int(str[1:], 0x10))
Exemplo n.º 15
0
def parseColor(s):
	if s[0] != '#':
		try:
			return colorNames[s]
		except:
			raise SkinError("color '%s' must be #aarrggbb or valid named color" % (s))
	return gRGB(int(s[1:], 0x10))
Exemplo n.º 16
0
	def __init__(self, style_id = 0):
		x = eWindowStyleManager.getInstance()
		style = x.getStyle(style_id)
		self.colors = {}
		for color_name in ("Background", "LabelForeground", "ListboxForeground", "ListboxSelectedForeground", "ListboxBackground", "ListboxSelectedBackground", "ListboxMarkedForeground", "ListboxMarkedAndSelectedForeground", "ListboxMarkedBackground", "ListboxMarkedAndSelectedBackground", "WindowTitleForeground", "WindowTitleBackground"):
			color = gRGB(0)
			style.getColor(eWindowStyleSkinned.__dict__["col"+color_name], color)
			self.colors[color_name] = color
Exemplo n.º 17
0
Arquivo: skin.py Projeto: popazerty/12
	def __init__(self, style_id = 0):
		x = eWindowStyleManager.getInstance()
		style = x.getStyle(style_id)
		self.colors = {}
		for color_name in ("Background", "LabelForeground", "ListboxForeground", "ListboxSelectedForeground", "ListboxBackground", "ListboxSelectedBackground", "ListboxMarkedForeground", "ListboxMarkedAndSelectedForeground", "ListboxMarkedBackground", "ListboxMarkedAndSelectedBackground", "WindowTitleForeground", "WindowTitleBackground"):
			color = gRGB(0)
			style.getColor(eWindowStyleSkinned.__dict__["col"+color_name], color)
			self.colors[color_name] = color
Exemplo n.º 18
0
def parseColor(str):
    if str[0] != '#':
        try:
            return colorNames[str]
        except:
            raise SkinError("color '%s' must be #aarrggbb or valid named color" % str)

    return gRGB(int(str[1:], 16))
Exemplo n.º 19
0
def parseColor(s):
	if s[0] != '#':
		if(1==1):
#		try:
			return colorNames[s]
#		except:
#			raise SkinError("color '%s' must be #aarrggbb or valid named color" % s)
	return gRGB(int(s[1:], 0x10))
Exemplo n.º 20
0
 def draw(self, list):
     for l in list:
         if l[0] == 1:
             self.instance.fillRect(eRect(l[1], l[2], l[3], l[4]),
                                    gRGB(l[5]))
         elif l[0] == 2:
             self.instance.writeText(eRect(l[1], l[2], l[3], l[4]),
                                     gRGB(l[5]), gRGB(l[6]), l[7], l[8],
                                     l[9])
         elif l[0] == 3:
             self.instance.drawLine(l[1], l[2], l[3], l[4], gRGB(l[5]))
         elif l[0] == 4:
             self.instance.drawRotatedLine(l[1], l[2], l[3], l[4], l[5],
                                           l[6], l[7], l[8], gRGB(l[9]))
         else:
             print 'drawlist entry:', l
             raise RuntimeError('invalid drawlist entry')
Exemplo n.º 21
0
	def __init__(self):
		Renderer.__init__(self)
		self.type     = NONE
		self.txfont   = gFont("Regular", 14)
		self.fcolor   = gRGB(RGB(255,255,255))
		self.bcolor   = gRGB(RGB(0,0,0))
		self.scolor   = None
		self.soffset  = (0,0)
		self.txtflags = 0 #RT_WRAP
		self.txtext   = ""
		self.test_label = self.mTimer = self.mStartPoint = None
		self.X = self.Y = self.W = self.H = self.mStartDelay = 0
		self.mAlways = 1	# always move text
		self.mStep = 1		# moving step: 1 pixel per 1 time
		self.mStepTimeout = 5000	# step timeout: 1 step per 50 milliseconds ( speed: 20 pixel per second )
		self.direction = LEFT
		self.mLoopTimeout = self.mOneShot = 0
		self.mRepeat = 0
Exemplo n.º 22
0
 def __init__(self):
     Renderer.__init__(self)
     self.type = NONE
     self.txfont = gFont("Regular", 14)
     self.fcolor = gRGB(RGB(255, 255, 255))
     self.bcolor = gRGB(RGB(0, 0, 0))
     self.scolor = None
     self.soffset = (0, 0)
     self.txtflags = 0  #RT_WRAP
     self.txtext = ""
     self.test_label = self.mTimer = self.mStartPoint = None
     self.X = self.Y = self.W = self.H = self.mStartDelay = 0
     self.mAlways = 1  # always move text
     self.mStep = 1  # moving step: 1 pixel per 1 time
     self.mStepTimeout = 5000  # step timeout: 1 step per 50 milliseconds ( speed: 20 pixel per second )
     self.direction = LEFT
     self.mLoopTimeout = self.mOneShot = 0
     self.mRepeat = 0
Exemplo n.º 23
0
 def _changeMode(self, ret):
     if ret:
         if ret[1] == "REORDERING_ENABLED": 
             self.reorderingEnabled = True
         elif ret[1] == "REORDERING_DISABLED":
             self.reorderingEnabled = False
         if not self.reorderingEnabled:
             self.reorderingMode = False
             self["config"].instance.setForegroundColorSelected(gRGB(0xFFFFFF))
             self.runSetup()
         self.setOKLabel()
Exemplo n.º 24
0
 def _changeMode(self, ret):
     if ret:
         if ret[1] == "REORDERING_ENABLED":
             self.reorderingEnabled = True
         elif ret[1] == "REORDERING_DISABLED":
             self.reorderingEnabled = False
         if not self.reorderingEnabled:
             self.reorderingMode = False
             self["config"].instance.setForegroundColorSelected(gRGB(0xFFFFFF))
             self.runSetup()
         self.setOKLabel()
Exemplo n.º 25
0
	def __init__(self):
		Renderer.__init__(self)
		self.bgColor = gRGB(0, 0, 0, 255)
		self.allColors = {
     "0" : "#00A501FE", "5" : "#00A501FE", "10" : "#00A501FE", "15" : "#00A501FE", "20" : "#00A501FE", "25" : "#007F01FE",
     "30" : "#004D01FE", "35" : "#000166FE", "40" : "#0001A5FE", "45" : "#0001D8FE", "50" : "#0001FEE4", "55" : "#0001FEA5",
     "60" : "#0003FC41", "65" : "#0040FE01", "70" : "#00B2FE01", "75" : "#00F1FE01", "80" : "#00FED801", "85" : "#00FEB201",
     "90" : "#00FE8C01", "95" : "#00FF7300", "100" : "#00FF0000"
     }
		self.start = False                     		
		self.vTimer = eTimer()
		self.vTimer.callback.append(self.changed)
Exemplo n.º 26
0
def reloadSkins():
	domScreens.clear()
	colors.clear()
	colors = {
		"key_back": gRGB(0x00313131),
		"key_blue": gRGB(0x0018188b),
		"key_green": gRGB(0x001f771f),
		"key_red": gRGB(0x009f1313),
		"key_text": gRGB(0x00ffffff),
		"key_yellow": gRGB(0x00a08500)
	}
	fonts.clear()
	fonts = {
		"Body": ("Regular", 18, 22, 16),
		"ChoiceList": ("Regular", 20, 24, 18)
	}
	menus.clear()
	parameters.clear()
	setups.clear()
	switchPixmap.clear()
	InitSkins()
Exemplo n.º 27
0
def loadSingleSkinData(desktop, screenID, domSkin, pathSkin, scope=SCOPE_CURRENT_SKIN):
	"""Loads skin data like colors, windowstyle etc."""
	assert domSkin.tag == "skin", "root element in skin must be 'skin'!"
	global colors, fonts, menus, parameters, setups, switchPixmap
	for tag in domSkin.findall("output"):
		id = tag.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = GUI_SKIN_ID
		if id == GUI_SKIN_ID:
			for res in tag.findall("resolution"):
				xres = res.attrib.get("xres")
				xres = int(xres) if xres else 720
				yres = res.attrib.get("yres")
				yres = int(yres) if yres else 576
				bpp = res.attrib.get("bpp")
				bpp = int(bpp) if bpp else 32
				# print "[Skin] DEBUG: Resolution xres=%d, yres=%d, bpp=%d." % (xres, yres, bpp)
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					pass  # Load palette (Not yet implemented!)
	for tag in domSkin.findall("include"):
		filename = tag.attrib.get("filename")
		if filename:
			filename = resolveFilename(scope, filename, path_prefix=pathSkin)
			if isfile(filename):
				loadSkin(filename, scope=scope, desktop=desktop, screenID=screenID)
			else:
				raise SkinError("Included file '%s' not found" % filename)
	for tag in domSkin.findall("switchpixmap"):
		for pixmap in tag.findall("pixmap"):
			name = pixmap.attrib.get("name")
			if not name:
				raise SkinError("Pixmap needs name attribute")
			filename = pixmap.attrib.get("filename")
			if not filename:
				raise SkinError("Pixmap needs filename attribute")
			resolved = resolveFilename(scope, filename, path_prefix=pathSkin)
			if isfile(resolved):
				switchPixmap[name] = LoadPixmap(resolved, cached=True)
			else:
				raise SkinError("The switchpixmap pixmap filename='%s' (%s) not found" % (filename, resolved))
	for tag in domSkin.findall("colors"):
		for color in tag.findall("color"):
			name = color.attrib.get("name")
			color = color.attrib.get("value")
			if name and color:
				colors[name] = parseColor(color)
				# print "[Skin] DEBUG: Color name='%s', color='%s'." % (name, color)
			else:
				raise SkinError("Tag 'color' needs a name and color, got name='%s' and color='%s'" % (name, color))
	for tag in domSkin.findall("fonts"):
		for font in tag.findall("font"):
			filename = font.attrib.get("filename", "<NONAME>")
			name = font.attrib.get("name", "Regular")
			scale = font.attrib.get("scale")
			scale = int(scale) if scale else 100
			isReplacement = font.attrib.get("replacement") and True or False
			render = font.attrib.get("render")
			if render:
				render = int(render)
			else:
				render = 0
			filename = resolveFilename(SCOPE_FONTS, filename, path_prefix=pathSkin)
			if isfile(filename):
				addFont(filename, name, scale, isReplacement, render)
				# Log provided by C++ addFont code.
				# print "[Skin] Add font: Font path='%s', name='%s', scale=%d, isReplacement=%s, render=%d." % (filename, name, scale, isReplacement, render)
			else:
				raise SkinError("Font file '%s' not found" % filename)
		fallbackFont = resolveFilename(SCOPE_FONTS, "fallback.font", path_prefix=pathSkin)
		if isfile(fallbackFont):
			addFont(fallbackFont, "Fallback", 100, -1, 0)
		# else:  # As this is optional don't raise an error.
		# 	raise SkinError("Fallback font '%s' not found" % fallbackFont)
		for alias in tag.findall("alias"):
			try:
				name = alias.attrib.get("name")
				font = alias.attrib.get("font")
				size = int(alias.attrib.get("size"))
				height = int(alias.attrib.get("height", size))  # To be calculated some day.
				width = int(alias.attrib.get("width", size))
				fonts[name] = (font, size, height, width)
				# print "[Skin] Add font alias: name='%s', font='%s', size=%d, height=%s, width=%d." % (name, font, size, height, width)
			except Exception as err:
				raise SkinError("Bad font alias: '%s'" % str(err))
	for tag in domSkin.findall("parameters"):
		for parameter in tag.findall("parameter"):
			try:
				name = parameter.attrib.get("name")
				value = parameter.attrib.get("value")
				parameters[name] = map(parseParameter, [x.strip() for x in value.split(",")]) if "," in value else parseParameter(value)
			except Exception as err:
				raise SkinError("Bad parameter: '%s'" % str(err))
	for tag in domSkin.findall("menus"):
		for setup in tag.findall("menu"):
			key = setup.attrib.get("key")
			image = setup.attrib.get("image")
			if key and image:
				menus[key] = image
				# print "[Skin] DEBUG: Menu key='%s', image='%s'." % (key, image)
			else:
				raise SkinError("Tag menu needs key and image, got key='%s' and image='%s'" % (key, image))
	for tag in domSkin.findall("setups"):
		for setup in tag.findall("setup"):
			key = setup.attrib.get("key")
			image = setup.attrib.get("image")
			if key and image:
				setups[key] = image
				# print "[Skin] DEBUG: Setup key='%s', image='%s'." % (key, image)
			else:
				raise SkinError("Tag setup needs key and image, got key='%s' and image='%s'" % (key, image))
	for tag in domSkin.findall("constant-widgets"):
		for constant_widget in tag.findall("constant-widget"):
			name = constant_widget.attrib.get("name")
			if name:
				constantWidgets[name] = constant_widget
	for tag in domSkin.findall("variables"):
		for parameter in tag.findall("variable"):
			name = parameter.attrib.get("name")
			value = parameter.attrib.get("value")
			x, y = value.split(",")
			if value and name:
				variables[name] = "%s,%s" % (str(x), str(y))
	for tag in domSkin.findall("subtitles"):
		from enigma import eSubtitleWidget
		scale = ((1, 1), (1, 1))
		for substyle in tag.findall("sub"):
			font = parseFont(substyle.attrib.get("font"), scale)
			col = substyle.attrib.get("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = substyle.attrib.get("borderColor")
			if col:
				borderColor = parseColor(col)
			else:
				borderColor = gRGB(0)
			borderwidth = substyle.attrib.get("borderWidth")
			if borderwidth is None:
				borderWidth = 3  # Default: Use a subtitle border.
			else:
				borderWidth = int(borderwidth)
			face = eSubtitleWidget.__dict__[substyle.attrib.get("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)
	for tag in domSkin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		styleId = tag.attrib.get("id")
		if styleId:
			styleId = int(styleId)
		else:
			styleId = GUI_SKIN_ID
		font = gFont("Regular", 20)  # Default
		offset = eSize(20, 5)  # Default
		for title in tag.findall("title"):
			offset = parseSize(title.attrib.get("offset"), ((1, 1), (1, 1)))
			font = parseFont(title.attrib.get("font"), ((1, 1), (1, 1)))
		style.setTitleFont(font)
		style.setTitleOffset(offset)
		# print "[Skin] DEBUG: WindowStyle font, offset -", font, offset
		for borderset in tag.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				bpName = pixmap.attrib.get("pos")
				filename = pixmap.attrib.get("filename")
				if filename and bpName:
					png = loadPixmap(resolveFilename(scope, filename, path_prefix=pathSkin), desktop)
					try:
						style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
					except Exception:
						pass
				# print "[Skin] DEBUG: WindowStyle borderset name, filename -", bpName, filename
		for color in tag.findall("color"):
			colorType = color.attrib.get("name")
			color = parseColor(color.attrib.get("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except Exception:
				raise SkinError("Unknown color type '%s'" % colorType)
			# print "[Skin] DEBUG: WindowStyle color type, color -", type, color
		x = eWindowStyleManager.getInstance()
		x.setStyle(styleId, style)
	for tag in domSkin.findall("margin"):
		styleId = tag.attrib.get("id")
		if styleId:
			styleId = int(styleId)
		else:
			styleId = GUI_SKIN_ID
		r = eRect(0, 0, 0, 0)
		v = tag.attrib.get("left")
		if v:
			r.setLeft(int(v))
		v = tag.attrib.get("top")
		if v:
			r.setTop(int(v))
		v = tag.attrib.get("right")
		if v:
			r.setRight(int(v))
		v = tag.attrib.get("bottom")
		if v:
			r.setBottom(int(v))
		# The "desktop" parameter is hard-coded to the GUI screen, so we must ask
		# for the one that this actually applies to.
		getDesktop(styleId).setMargins(r)
Exemplo n.º 28
0
Arquivo: skin.py Projeto: popazerty/12
	def __getitem__(self, color_name):
		return color_name in self.colors and self.colors[color_name] or gRGB(0)
Exemplo n.º 29
0
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall('output'):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall('resolution'):
                get_attr = res.attrib.get
                xres = get_attr('xres')
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr('yres')
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr('bpp')
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for c in skin.findall('colors'):
        for color in c.findall('color'):
            get_attr = color.attrib.get
            name = get_attr('name')
            color = get_attr('value')
            if name and color:
                colorNames[name] = parseColor(color)
                if color[0] != '#':
                    for key in colorNames:
                        if key == color:
                            colorNamesHuman[name] = colorNamesHuman[key]
                            break

                else:
                    humancolor = color[1:]
                    if len(humancolor) >= 6:
                        colorNamesHuman[name] = int(humancolor, 16)
            else:
                raise SkinError('need color and name, got %s %s' %
                                (name, color))

    for c in skin.findall('fonts'):
        for font in c.findall('font'):
            get_attr = font.attrib.get
            filename = get_attr('filename', '<NONAME>')
            name = get_attr('name', 'Regular')
            scale = get_attr('scale')
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr('replacement') and True or False
            resolved_font = resolveFilename(SCOPE_FONTS,
                                            filename,
                                            path_prefix=path_prefix)
            if not fileExists(resolved_font):
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement)

    for c in skin.findall('parameters'):
        for parameter in c.findall('parameter'):
            get = parameter.attrib.get
            try:
                name = get('name')
                value = get('value')
                if name.find('Font') != -1:
                    font = value.split(';')
                    if isinstance(font, list) and len(font) == 2:
                        parameters[name] = (str(font[0]), int(font[1]))
                else:
                    parameters[name] = map(int, value.split(','))
            except Exception as ex:
                print '[SKIN] bad parameter', ex

    for c in skin.findall('constant-widgets'):
        for constant_widget in c.findall('constant-widget'):
            get = constant_widget.attrib.get
            name = get('name')
            if name:
                constant_widgets[name] = constant_widget

    for c in skin.findall('variables'):
        for parameter in c.findall('variable'):
            get = parameter.attrib.get
            name = get('name')
            value = get('value')
            x, y = value.split(',')
            if value and name:
                variables[name] = str(x) + ',' + str(y)

    for c in skin.findall('subtitles'):
        from enigma import eWidget, eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall('sub'):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr('font'), scale)
            col = get_attr('foregroundColor')
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr('borderColor')
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr('borderWidth')
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr('name')]
            eSubtitleWidget.setFontStyle(face, font, haveColor,
                                         foregroundColor, borderColor,
                                         borderWidth)

    for windowstyle in skin.findall('windowstyle'):
        style = eWindowStyleSkinned()
        id = windowstyle.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        font = gFont('Regular', 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall('title'):
            get_attr = title.attrib.get
            offset = parseSize(get_attr('offset'), ((1, 1), (1, 1)))
            font = parseFont(get_attr('font'), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall('borderset'):
            bsName = str(borderset.attrib.get('name'))
            for pixmap in borderset.findall('pixmap'):
                get_attr = pixmap.attrib.get
                bpName = get_attr('pos')
                filename = get_attr('filename')
                if filename and bpName:
                    png = loadPixmap(
                        resolveFilename(SCOPE_SKIN_IMAGE,
                                        filename,
                                        path_prefix=path_prefix), desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName],
                                    eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall('color'):
            get_attr = color.attrib.get
            colorType = get_attr('name')
            color = parseColor(get_attr('color'))
            try:
                style.setColor(eWindowStyleSkinned.__dict__['col' + colorType],
                               color)
            except:
                raise SkinError('Unknown color %s' % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)
Exemplo n.º 30
0
from Tools.Import import my_import
from Tools.LoadPixmap import LoadPixmap

DEFAULT_SKIN = "MetrixHD/skin.xml"
EMERGENCY_SKIN = "skin_default.xml"
DEFAULT_DISPLAY_SKIN = "skin_display_grautec.xml" if SystemInfo["grautec"] else "skin_display.xml"
USER_SKIN = "skin_user.xml"
USER_SKIN_TEMPLATE = "skin_user_%s.xml"
SUBTITLE_SKIN = "skin_subtitles.xml"

GUI_SKIN_ID = 0  # Main frame-buffer.
DISPLAY_SKIN_ID = 2 if getBoxType().startswith("dm") else 1  # Front panel / display / LCD.

domScreens = {}  # Dictionary of skin based screens.
colors = {  # Dictionary of skin color names.
	"key_back": gRGB(0x00313131),
	"key_blue": gRGB(0x0018188b),
	"key_green": gRGB(0x001f771f),
	"key_red": gRGB(0x009f1313),
	"key_text": gRGB(0x00ffffff),
	"key_yellow": gRGB(0x00a08500)
}
fonts = {  # Dictionary of predefined and skin defined font aliases.
	"Body": ("Regular", 18, 22, 16),
	"ChoiceList": ("Regular", 20, 24, 18)
}
menus = {}  # Dictionary of images associated with menu entries.
parameters = {}  # Dictionary of skin parameters used to modify code behavior.
setups = {}  # Dictionary of images associated with setup menus.
switchPixmap = {}  # Dictionary of switch images.
windowStyles = {}  # Dictionary of window styles for each screen ID.
Exemplo n.º 31
0
Arquivo: skin.py Projeto: mi49/enigma2
                    parseParameter, value.split(",")) or parseParameter(value)
            except Exception, ex:
                print "[Skin] Bad parameter", ex

    for c in skin.findall("subtitles"):
        from enigma import eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall("sub"):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr("font"), scale)
            col = get_attr("foregroundColor")
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(0xFFFFFF)
                haveColor = 0
            col = get_attr("borderColor")
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr("borderWidth")
            if borderwidth is None:
                # default: use a subtitle border
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr("name")]
            eSubtitleWidget.setFontStyle(face, font, haveColor,
                                         foregroundColor, borderColor,
Exemplo n.º 32
0
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall('output'):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall('resolution'):
                get_attr = res.attrib.get
                xres = get_attr('xres')
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr('yres')
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr('bpp')
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for c in skin.findall('colors'):
        for color in c.findall('color'):
            get_attr = color.attrib.get
            name = get_attr('name')
            color = get_attr('value')
            if name and color:
                colorNames[name] = parseColor(color)
                if color[0] != '#':
                    for key in colorNames:
                        if key == color:
                            colorNamesHuman[name] = colorNamesHuman[key]
                            break

                else:
                    humancolor = color[1:]
                    if len(humancolor) >= 6:
                        colorNamesHuman[name] = int(humancolor, 16)
            else:
                raise SkinError('need color and name, got %s %s' % (name, color))

    for c in skin.findall('fonts'):
        for font in c.findall('font'):
            get_attr = font.attrib.get
            filename = get_attr('filename', '<NONAME>')
            name = get_attr('name', 'Regular')
            scale = get_attr('scale')
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr('replacement') and True or False
            resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
            if not fileExists(resolved_font):
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement)

    for c in skin.findall('parameters'):
        for parameter in c.findall('parameter'):
            get = parameter.attrib.get
            try:
                name = get('name')
                value = get('value')
                if name.find('Font') != -1:
                    font = value.split(';')
                    if isinstance(font, list) and len(font) == 2:
                        parameters[name] = (str(font[0]), int(font[1]))
                else:
                    parameters[name] = map(int, value.split(','))
            except Exception as ex:
                print '[SKIN] bad parameter', ex

    for c in skin.findall('constant-widgets'):
        for constant_widget in c.findall('constant-widget'):
            get = constant_widget.attrib.get
            name = get('name')
            if name:
                constant_widgets[name] = constant_widget

    for c in skin.findall('variables'):
        for parameter in c.findall('variable'):
            get = parameter.attrib.get
            name = get('name')
            value = get('value')
            x, y = value.split(',')
            if value and name:
                variables[name] = str(x) + ',' + str(y)

    for c in skin.findall('subtitles'):
        from enigma import eWidget, eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall('sub'):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr('font'), scale)
            col = get_attr('foregroundColor')
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr('borderColor')
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr('borderWidth')
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr('name')]
            eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

    for windowstyle in skin.findall('windowstyle'):
        style = eWindowStyleSkinned()
        id = windowstyle.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        font = gFont('Regular', 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall('title'):
            get_attr = title.attrib.get
            offset = parseSize(get_attr('offset'), ((1, 1), (1, 1)))
            font = parseFont(get_attr('font'), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall('borderset'):
            bsName = str(borderset.attrib.get('name'))
            for pixmap in borderset.findall('pixmap'):
                get_attr = pixmap.attrib.get
                bpName = get_attr('pos')
                filename = get_attr('filename')
                if filename and bpName:
                    png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall('color'):
            get_attr = color.attrib.get
            colorType = get_attr('name')
            color = parseColor(get_attr('color'))
            try:
                style.setColor(eWindowStyleSkinned.__dict__['col' + colorType], color)
            except:
                raise SkinError('Unknown color %s' % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)
Exemplo n.º 33
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			render = get_attr("render")
			if render:
				render = int(render)
			else:
				render = 0
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if fileExists(skin_path):
					resolved_font = skin_path
			addFont(resolved_font, name, scale, is_replacement, render)
			#print "Font: ", resolved_font, name, scale, is_replacement

	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("borderColor")
			if col:
				borderColor = parseColor(col)
			else:
				borderColor = gRGB(0)
			borderwidth = get_attr("borderWidth")
			if borderwidth is None:
				# default: use a subtitle border
				borderWidth = 3
			else:
				borderWidth = int(borderwidth)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

	for windowstyle in skin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		id = windowstyle.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = 0
		#print "windowstyle:", id

		# defaults
		font = gFont("Regular", 20)
		offset = eSize(20, 5)

		for title in windowstyle.findall("title"):
			get_attr = title.attrib.get
			offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
			font = parseFont(get_attr("font"), ((1,1),(1,1)))

		style.setTitleFont(font);
		style.setTitleOffset(offset)
		#print "  ", font, offset

		for borderset in windowstyle.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				get_attr = pixmap.attrib.get
				bpName = get_attr("pos")
				filename = get_attr("filename")
				if filename and bpName:
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
				#print "  borderset:", bpName, filename

		for color in windowstyle.findall("color"):
			get_attr = color.attrib.get
			colorType = get_attr("name")
			color = parseColor(get_attr("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except:
				raise SkinError("Unknown color %s" % (colorType))
				#pass

			#print "  color:", type, color

		x = eWindowStyleManager.getInstance()
		x.setStyle(id, style)
Exemplo n.º 34
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"
	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for skininclude in skin.findall("include"):
		filename = skininclude.attrib.get("filename")
		if filename:
			skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
			if not fileExists(skinfile):
				skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
			if fileExists(skinfile):
				print("[SKIN] loading include:", skinfile)
				loadSkin(skinfile)

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("parameters"):
		for parameter in c.findall("parameter"):
			get = parameter.attrib.get
			try:
				name = get("name")
				value = get("value")
				if name.find('Font') != -1:
					font = value.split(";")
					if isinstance(font, list) and len(font) == 2:
						parameters[name] = (str(font[0]), int(font[1]))
				else:
					parameters[name] = list(map(int, value.split(",")))
			except Exception as ex:
			 	print("[SKIN] bad parameter", ex)

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			render = get_attr("render")
			if render:
				render = int(render)
			else:
				render = 0
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename)
				if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)):
					resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)):
					resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)
			addFont(resolved_font, name, scale, is_replacement, render)
			#print "Font: ", resolved_font, name, scale, is_replacement
		for alias in c.findall("alias"):
			get = alias.attrib.get
			try:
				name = get("name")
				font = get("font")
				size = int(get("size"))
				height = int(get("height", size)) # to be calculated some day
				width = int(get("width", size))
				global fonts
				fonts[name] = (font, size, height, width)
			except Exception as ex:
				print("[SKIN] bad font alias", ex)


	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("borderColor")
			if col:
				borderColor = parseColor(col)
			else:
				borderColor = gRGB(0)
			borderwidth = get_attr("borderWidth")
			if borderwidth is None:
				# default: use a subtitle border
				borderWidth = 3
			else:
				borderWidth = int(borderwidth)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

	for windowstyle in skin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		style_id = windowstyle.attrib.get("id")
		if style_id:
			style_id = int(style_id)
		else:
			style_id = 0
		# defaults
		font = gFont("Regular", 20)
		offset = eSize(20, 5)
		for title in windowstyle.findall("title"):
			get_attr = title.attrib.get
			offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
			font = parseFont(get_attr("font"), ((1,1),(1,1)))

		style.setTitleFont(font)
		style.setTitleOffset(offset)
		#print "  ", font, offset
		for borderset in windowstyle.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				get_attr = pixmap.attrib.get
				bpName = get_attr("pos")
				filename = get_attr("filename")
				if filename and bpName:
					pngfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
					if fileExists(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)):
						pngfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
					png = loadPixmap(pngfile, desktop)
					try:
						style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
					except:
						pass
				#print "  borderset:", bpName, filename
		for color in windowstyle.findall("color"):
			get_attr = color.attrib.get
			colorType = get_attr("name")
			color = parseColor(get_attr("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except:
				raise SkinError("Unknown color %s" % colorType)
				#pass
			#print "  color:", type, color
		x = eWindowStyleManager.getInstance()
		x.setStyle(style_id, style)
	for margin in skin.findall("margin"):
		style_id = margin.attrib.get("id")
		if style_id:
			style_id = int(style_id)
		else:
			style_id = 0
		r = eRect(0,0,0,0)
		v = margin.attrib.get("left")
		if v:
			r.setLeft(int(v))
		v = margin.attrib.get("top")
		if v:
			r.setTop(int(v))
		v = margin.attrib.get("right")
		if v:
			r.setRight(int(v))
		v = margin.attrib.get("bottom")
		if v:
			r.setBottom(int(v))
		# the "desktop" parameter is hardcoded to the UI screen, so we must ask
		# for the one that this actually applies to.
		getDesktop(style_id).setMargins(r)
Exemplo n.º 35
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"

	#print "***SKIN: ", path_prefix

	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if fileExists(skin_path):
					resolved_font = skin_path
			addFont(resolved_font, name, scale, is_replacement)
			#print "Font: ", resolved_font, name, scale, is_replacement

	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("shadowColor")
			if col:
				shadowColor = parseColor(col)
			else:
				shadowColor = gRGB(0)
			shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, shadowColor, shadowOffset)

	for windowstyle in skin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		id = windowstyle.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = 0
		#print "windowstyle:", id

		# defaults
		font = gFont("Regular", 20)
		offset = eSize(20, 5)

		for title in windowstyle.findall("title"):
			get_attr = title.attrib.get
			offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
			font = parseFont(get_attr("font"), ((1,1),(1,1)))

		style.setTitleFont(font);
		style.setTitleOffset(offset)
		#print "  ", font, offset

		for borderset in windowstyle.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				get_attr = pixmap.attrib.get
				bpName = get_attr("pos")
				filename = get_attr("filename")
				if filename and bpName:
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
				#print "  borderset:", bpName, filename

		for color in windowstyle.findall("color"):
			get_attr = color.attrib.get
			colorType = get_attr("name")
			color = parseColor(get_attr("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except:
				raise SkinError("Unknown color %s" % (colorType))
				#pass

			#print "  color:", type, color

		x = eWindowStyleManager.getInstance()
		x.setStyle(id, style)
Exemplo n.º 36
0
def loadSingleSkinData(desktop, screenID, domSkin, pathSkin, scope=SCOPE_CURRENT_SKIN):
	"""Loads skin data like colors, windowstyle etc."""
	assert domSkin.tag == "skin", "root element in skin must be 'skin'!"
	global colors, fonts, menus, parameters, setups, switchPixmap
	for tag in domSkin.findall("output"):
		scrnID = int(tag.attrib.get("id", GUI_SKIN_ID))
		if scrnID == GUI_SKIN_ID:
			for res in tag.findall("resolution"):
				xres = res.attrib.get("xres")
				xres = int(xres) if xres else 720
				yres = res.attrib.get("yres")
				yres = int(yres) if yres else 576
				bpp = res.attrib.get("bpp")
				bpp = int(bpp) if bpp else 32
				# print("[Skin] DEBUG: Resolution xres=%d, yres=%d, bpp=%d." % (xres, yres, bpp))
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					pass  # Load palette (Not yet implemented!)
				if yres >= 1080:
					parameters["AboutHddSplit"] = 1
					parameters["AutotimerListChannels"] = (2, 60, 4, 32)
					parameters["AutotimerListDays"] = (1, 40, 5, 25)
					parameters["AutotimerListHasTimespan"] = (154, 4, 150, 25)
					parameters["AutotimerListIcon"] = (3, -1, 36, 36)
					parameters["AutotimerListRectypeicon"] = (39, 4, 30, 30)
					parameters["AutotimerListTimerName"] = (76, 4, 26, 32)
					parameters["AutotimerListTimespan"] = (2, 40, 5, 25)
					parameters["ChoicelistDash"] = (0, 3, 1000, 30)
					parameters["ChoicelistIcon"] = (7, 0, 52, 38)
					parameters["ChoicelistName"] = (68, 3, 1000, 32)
					parameters["ChoicelistNameSingle"] = (7, 3, 1000, 32)
					parameters["ConfigListSeperator"] = 500
					parameters["DreamexplorerIcon"] = (15, 4, 30, 30)
					parameters["DreamexplorerName"] = (62, 0, 1200, 38)
					parameters["FileListIcon"] = (7, 4, 52, 37)
					parameters["FileListMultiIcon"] = (45, 4, 30, 30)
					parameters["FileListMultiLock"] = (2, 0, 36, 36)
					parameters["FileListMultiName"] = (90, 3, 1000, 32)
					parameters["FileListName"] = (68, 4, 1000, 34)
					parameters["HelpMenuListExtHlp0"] = (0, 0, 900, 39)
					parameters["HelpMenuListExtHlp1"] = (0, 42, 900, 30)
					parameters["HelpMenuListHlp"] = (0, 0, 900, 42)
					parameters["PartnerBoxBouquetListName"] = (0, 0, 45)
					parameters["PartnerBoxChannelListName"] = (0, 0, 45)
					parameters["PartnerBoxChannelListTime"] = (0, 78, 225, 30)
					parameters["PartnerBoxChannelListTitle"] = (0, 42, 30)
					parameters["PartnerBoxE1TimerState"] = (255, 78, 255, 30)
					parameters["PartnerBoxE1TimerTime"] = (0, 78, 255, 30)
					parameters["PartnerBoxE2TimerIcon"] = (1050, 8, 20, 20)
					parameters["PartnerBoxE2TimerIconRepeat"] = (1050, 38, 20, 20)
					parameters["PartnerBoxE2TimerState"] = (225, 78, 225, 30)
					parameters["PartnerBoxE2TimerTime"] = (0, 78, 225, 30)
					parameters["PartnerBoxEntryListIP"] = (180, 2, 225, 38)
					parameters["PartnerBoxEntryListName"] = (8, 2, 225, 38)
					parameters["PartnerBoxEntryListPort"] = (405, 2, 150, 38)
					parameters["PartnerBoxEntryListType"] = (615, 2, 150, 38)
					parameters["PartnerBoxTimerName"] = (0, 42, 30)
					parameters["PartnerBoxTimerServicename"] = (0, 0, 45)
					parameters["PicturePlayerThumb"] = (30, 285, 45, 300, 30, 25)
					parameters["PlayListIcon"] = (7, 7, 24, 24)
					parameters["PlayListName"] = (38, 2, 1000, 34)
					parameters["PluginBrowserDescr"] = (180, 42, 25)
					parameters["PluginBrowserDownloadDescr"] = (120, 42, 25)
					parameters["PluginBrowserDownloadIcon"] = (15, 0, 90, 76)
					parameters["PluginBrowserDownloadName"] = (120, 8, 38)
					parameters["PluginBrowserIcon"] = (15, 8, 150, 60)
					parameters["PluginBrowserName"] = (180, 8, 38)
					parameters["SHOUTcastListItem"] = (30, 27, 35, 96, 35, 33, 60, 32)
					parameters["SelectionListDescr"] = (45, 6, 1000, 45)
					parameters["SelectionListLock"] = (0, 2, 36, 36)
					parameters["ServiceInfoLeft"] = (0, 0, 450, 45)
					parameters["ServiceInfoRight"] = (450, 0, 1000, 45)
					parameters["VirtualKeyBoard"] = (68, 68)
					parameters["VirtualKeyBoardAlignment"] = (0, 0)
					parameters["VirtualKeyBoardPadding"] = (7, 7)
					parameters["VirtualKeyBoardShiftColors"] = (0x00ffffff, 0x00ffffff, 0x0000ffff, 0x00ff00ff)
	for tag in domSkin.findall("include"):
		filename = tag.attrib.get("filename")
		if filename:
			filename = resolveFilename(scope, filename, path_prefix=pathSkin)
			if isfile(filename):
				loadSkin(filename, scope=scope, desktop=desktop, screenID=screenID)
			else:
				raise SkinError("Included file '%s' not found" % filename)
	for tag in domSkin.findall("switchpixmap"):
		for pixmap in tag.findall("pixmap"):
			name = pixmap.attrib.get("name")
			if not name:
				raise SkinError("Pixmap needs name attribute")
			filename = pixmap.attrib.get("filename")
			if not filename:
				raise SkinError("Pixmap needs filename attribute")
			resolved = resolveFilename(scope, filename, path_prefix=pathSkin)
			if isfile(resolved):
				switchPixmap[name] = LoadPixmap(resolved, cached=True)
			else:
				raise SkinError("The switchpixmap pixmap filename='%s' (%s) not found" % (filename, resolved))
	for tag in domSkin.findall("colors"):
		for color in tag.findall("color"):
			name = color.attrib.get("name")
			color = color.attrib.get("value")
			if name and color:
				colors[name] = parseColor(color)
				# print("[Skin] DEBUG: Color name='%s', color='%s'." % (name, color))
			else:
				raise SkinError("Tag 'color' needs a name and color, got name='%s' and color='%s'" % (name, color))
	for tag in domSkin.findall("fonts"):
		for font in tag.findall("font"):
			filename = font.attrib.get("filename", "<NONAME>")
			name = font.attrib.get("name", "Regular")
			scale = font.attrib.get("scale")
			scale = int(scale) if scale else 100
			isReplacement = font.attrib.get("replacement") and True or False
			render = font.attrib.get("render")
			if render:
				render = int(render)
			else:
				render = 0
			filename = resolveFilename(SCOPE_FONTS, filename, path_prefix=pathSkin)
			# Log provided by C++ addFont code.
			# print("[Skin] Add font: Font path='%s', name='%s', scale=%d, isReplacement=%s, render=%d." % (filename, name, scale, isReplacement, render))
			if not fileExists(filename): # When font is not available look at current skin path
				filename = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if not fileExists(filename) and fileExists(resolveFilename(SCOPE_CURRENT_LCDSKIN, filename)):
					filename = resolveFilename(SCOPE_CURRENT_LCDSKIN, filename)
			addFont(filename, name, scale, isReplacement, render)
		fallbackFont = resolveFilename(SCOPE_FONTS, "fallback.font", path_prefix=pathSkin)
		if isfile(fallbackFont):
			addFont(fallbackFont, "Fallback", 100, -1, 0)
		# else:  # As this is optional don't raise an error.
		# 	raise SkinError("Fallback font '%s' not found" % fallbackFont)
		for alias in tag.findall("alias"):
			try:
				name = alias.attrib.get("name")
				font = alias.attrib.get("font")
				size = int(alias.attrib.get("size"))
				height = int(alias.attrib.get("height", size))  # To be calculated some day.
				width = int(alias.attrib.get("width", size))
				fonts[name] = (font, size, height, width)
				# print("[Skin] Add font alias: name='%s', font='%s', size=%d, height=%s, width=%d." % (name, font, size, height, width))
			except Exception as err:
				raise SkinError("Bad font alias: '%s'" % str(err))
	for tag in domSkin.findall("parameters"):
		for parameter in tag.findall("parameter"):
			try:
				name = parameter.attrib.get("name")
				value = parameter.attrib.get("value")
				parameters[name] = list(map(parseParameter, [x.strip() for x in value.split(",")]) if "," in value else parseParameter(value))
			except Exception as err:
				raise SkinError("Bad parameter: '%s'" % str(err))
	for tag in domSkin.findall("menus"):
		for setup in tag.findall("menu"):
			key = setup.attrib.get("key")
			image = setup.attrib.get("image")
			if key and image:
				menus[key] = image
				# print("[Skin] DEBUG: Menu key='%s', image='%s'." % (key, image))
			else:
				raise SkinError("Tag menu needs key and image, got key='%s' and image='%s'" % (key, image))
	for tag in domSkin.findall("setups"):
		for setup in tag.findall("setup"):
			key = setup.attrib.get("key")
			image = setup.attrib.get("image")
			if key and image:
				setups[key] = image
				# print("[Skin] DEBUG: Setup key='%s', image='%s'." % (key, image))
			else:
				raise SkinError("Tag setup needs key and image, got key='%s' and image='%s'" % (key, image))
	for tag in domSkin.findall("subtitles"):
		from enigma import eSubtitleWidget
		scale = ((1, 1), (1, 1))
		for substyle in tag.findall("sub"):
			font = parseFont(substyle.attrib.get("font"), scale)
			col = substyle.attrib.get("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = substyle.attrib.get("borderColor" and "shadowColor")
			if col:
				borderColor = shadowColor = parseColor(col)
			else:
				borderColor = shadowColor = gRGB(0)
			borderwidth = substyle.attrib.get("borderWidth")
			if borderwidth is None:
				borderWidth = 3  # Default: Use a subtitle border.
			else:
				borderWidth = int(borderwidth)
			face = eSubtitleWidget.__dict__[substyle.attrib.get("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)
	for tag in domSkin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		scrnID = int(tag.attrib.get("id", GUI_SKIN_ID))
		font = gFont("Regular", 20)  # Default
		offset = eSize(20, 5)  # Default
		for title in tag.findall("title"):
			offset = parseSize(title.attrib.get("offset"), ((1, 1), (1, 1)))
			font = parseFont(title.attrib.get("font"), ((1, 1), (1, 1)))
		style.setTitleFont(font)
		style.setTitleOffset(offset)
		# print("[Skin] DEBUG: WindowStyle font, offset - '%s' '%s'." % (str(font), str(offset)))
		for borderset in tag.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				bpName = pixmap.attrib.get("pos")
				filename = pixmap.attrib.get("filename")
				if filename and bpName:
					png = loadPixmap(resolveFilename(scope, filename, path_prefix=pathSkin), desktop)
					try:
						style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
					except Exception:
						pass
				# print("[Skin] DEBUG: WindowStyle borderset name, filename - '%s' '%s'." % (bpName, filename))
		for color in tag.findall("color"):
			colorType = color.attrib.get("name")
			color = parseColor(color.attrib.get("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except Exception:
				raise SkinError("Unknown color type '%s'" % colorType)
			# print("[Skin] DEBUG: WindowStyle color type, color -" % (colorType, str(color)))
		x = eWindowStyleManager.getInstance()
		x.setStyle(scrnID, style)
	for tag in domSkin.findall("margin"):
		scrnID = int(tag.attrib.get("id", GUI_SKIN_ID))
		r = eRect(0, 0, 0, 0)
		v = tag.attrib.get("left")
		if v:
			r.setLeft(int(v))
		v = tag.attrib.get("top")
		if v:
			r.setTop(int(v))
		v = tag.attrib.get("right")
		if v:
			r.setRight(int(v))
		v = tag.attrib.get("bottom")
		if v:
			r.setBottom(int(v))
		# The "desktop" parameter is hard-coded to the GUI screen, so we must ask
		# for the one that this actually applies to.
		getDesktop(scrnID).setMargins(r)
Exemplo n.º 37
0
def loadSingleSkinData(desktop, skin, path_prefix):
	"""loads skin data like colors, windowstyle etc."""
	assert skin.tag == "skin", "root element in skin must be 'skin'!"

	#print "***SKIN: ", path_prefix

	for c in skin.findall("output"):
		id = c.attrib.get('id')
		if id:
			id = int(id)
		else:
			id = 0
		if id == 0: # framebuffer
			for res in c.findall("resolution"):
				get_attr = res.attrib.get
				xres = get_attr("xres")
				if xres:
					xres = int(xres)
				else:
					xres = 720
				yres = get_attr("yres")
				if yres:
					yres = int(yres)
				else:
					yres = 576
				bpp = get_attr("bpp")
				if bpp:
					bpp = int(bpp)
				else:
					bpp = 32
				#print "Resolution:", xres,yres,bpp
				from enigma import gMainDC
				gMainDC.getInstance().setResolution(xres, yres)
				desktop.resize(eSize(xres, yres))
				if bpp != 32:
					# load palette (not yet implemented)
					pass

	for c in skin.findall("colors"):
		for color in c.findall("color"):
			get_attr = color.attrib.get
			name = get_attr("name")
			color = get_attr("value")
			if name and color:
				colorNames[name] = parseColor(color)
				#print "Color:", name, color
			else:
				raise SkinError("need color and name, got %s %s" % (name, color))

	for c in skin.findall("listboxcontent"):
		for offset in c.findall("offset"):
			get_attr = offset.attrib.get
			name = get_attr("name")
			value = get_attr("value")
			if name and value:
				if name == "left":
					eListboxPythonStringContent.setLeftOffset(parseValue(value))
				elif name == "right":
					eListboxPythonStringContent.setRightOffset(parseValue(value))
				else:
					raise SkinError("got listboxcontent offset '%s'' but 'left' or 'right' is allowed only" % name)
		for font in c.findall("font"):
			get_attr = font.attrib.get
			name = get_attr("name")
			font = get_attr("font")
			if name and font:
				if name == "string":
					eListboxPythonStringContent.setFont(parseFont(font, ((1,1),(1,1))))
				elif name == "config_description":
					eListboxPythonConfigContent.setDescriptionFont(parseFont(font, ((1,1),(1,1))))
				elif name == "config_value":
					eListboxPythonConfigContent.setValueFont(parseFont(font, ((1,1),(1,1))))
				else:
					raise SkinError("got listboxcontent font '%s' but 'string', 'config_description' or 'config_value' is allowed only" % name)
		for value in c.findall("value"):
			get_attr = value.attrib.get
			name = get_attr("name")
			value = get_attr("value")
			if name and value:
				if name == "string_item_height":
					eListboxPythonStringContent.setItemHeight(parseValue(value))
				elif name == "config_item_height":
					eListboxPythonConfigContent.setItemHeight(parseValue(value))
				else:
					raise SkinError("got listboxcontent value '%s' but 'string_item_height' or 'config_item_height' is allowed only" % name)

	for c in skin.findall("fonts"):
		for font in c.findall("font"):
			get_attr = font.attrib.get
			filename = get_attr("filename", "<NONAME>")
			name = get_attr("name", "Regular")
			scale = get_attr("scale")
			if scale:
				scale = int(scale)
			else:
				scale = 100
			is_replacement = get_attr("replacement") and True or False
			resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
			if not fileExists(resolved_font): #when font is not available look at current skin path
				skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
				if fileExists(skin_path):
					resolved_font = skin_path
			addFont(resolved_font, name, scale, is_replacement)
			#print "Font: ", resolved_font, name, scale, is_replacement

	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("shadowColor")
			if col:
				shadowColor = parseColor(col)
			else:
				shadowColor = gRGB(0)
			shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, shadowColor, shadowOffset)

	for windowstyle in skin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		id = windowstyle.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = 0
		#print "windowstyle:", id

		# defaults
		font = gFont("Regular", 20)
		offset = eSize(20, 5)

		for title in windowstyle.findall("title"):
			get_attr = title.attrib.get
			offset = parseSize(get_attr("offset"), ((1,1),(1,1)))
			font = parseFont(get_attr("font"), ((1,1),(1,1)))

		style.setTitleFont(font);
		style.setTitleOffset(offset)
		#print "  ", font, offset

		for borderset in windowstyle.findall("borderset"):
			bsName = str(borderset.attrib.get("name"))
			for pixmap in borderset.findall("pixmap"):
				get_attr = pixmap.attrib.get
				bpName = get_attr("pos")
				filename = get_attr("filename")
				if filename and bpName:
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)
				#print "  borderset:", bpName, filename

		for color in windowstyle.findall("color"):
			get_attr = color.attrib.get
			colorType = get_attr("name")
			color = parseColor(get_attr("color"))
			try:
				style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
			except:
				raise SkinError("Unknown color %s" % (colorType))
				#pass

			#print "  color:", type, color

		x = eWindowStyleManager.getInstance()
		x.setStyle(id, style)

	for windowstylescrollbar in skin.findall("windowstylescrollbar"):
		style = eWindowStyleScrollbar()
		id = windowstylescrollbar.attrib.get("id")
		if id:
			id = int(id)
		else:
			id = 4
		for value in windowstylescrollbar.findall("value"):
			get_attr = value.attrib.get
			vType = get_attr("name")
			v = get_attr("value")
			if vType == "BackgroundPixmapTopHeight":
				style.setBackgroundPixmapTopHeight(int(v))
			elif vType == "BackgroundPixmapBottomHeight":
				style.setBackgroundPixmapBottomHeight(int(v))
			elif vType == "ValuePixmapTopHeight":
				style.setValuePixmapTopHeight(int(v))
			elif vType == "ValuePixmapBottomHeight":
				style.setValuePixmapBottomHeight(int(v))
			elif vType == "ScrollbarWidth":
				style.setScrollbarWidth(int(v))
			elif vType == "ScrollbarBorderWidth":
				style.setScrollbarBorderWidth(int(v))
		for pixmap in windowstylescrollbar.findall("pixmap"):
			get_attr = pixmap.attrib.get
			vType = get_attr("name")
			filename = get_attr("filename")
			if filename:
				if vType == "BackgroundPixmap":
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setBackgroundPixmap(png)
				elif vType == "ValuePixmap":
					png = loadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix), desktop)
					style.setValuePixmap(png)
		x = eWindowStyleManager.getInstance()
		x.setStyle(id, style)
Exemplo n.º 38
0
 def __getitem__(self, color_name):
     return color_name in self.colors and self.colors[color_name] or gRGB(0)
Exemplo n.º 39
0
def loadSingleSkinData(desktop, skin, path_prefix):
    """loads skin data like colors, windowstyle etc."""
    assert skin.tag == "skin", "root element in skin must be 'skin'!"

    #print "***SKIN: ", path_prefix

    for c in skin.findall("output"):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:  # framebuffer
            for res in c.findall("resolution"):
                xres = int(res.get("xres", "720"))
                yres = int(res.get("yres", "576"))
                bpp = int(res.get("bpp", "32"))
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres, bpp)
                desktop.resize(eSize(xres, yres))
                break

    for c in skin.findall("colors"):
        for color in c.findall("color"):
            get_attr = color.attrib.get
            name = get_attr("name")
            color = get_attr("value")
            if name and color:
                colorNames[name] = parseColor(color)
                #print "Color:", name, color
            else:
                raise SkinError("need color and name, got %s %s" %
                                (name, color))

    for c in skin.findall("listboxcontent"):
        for offset in c.findall("offset"):
            get_attr = offset.attrib.get
            name = get_attr("name")
            value = get_attr("value")
            if name and value:
                if name == "left":
                    eListboxPythonStringContent.setLeftOffset(
                        parseValue(value))
                elif name == "right":
                    eListboxPythonStringContent.setRightOffset(
                        parseValue(value))
                else:
                    raise SkinError(
                        "got listboxcontent offset '%s'' but 'left' or 'right' is allowed only"
                        % name)
        for font in c.findall("font"):
            get_attr = font.attrib.get
            name = get_attr("name")
            font = get_attr("font")
            if name and font:
                if name == "string":
                    eListboxPythonStringContent.setFont(
                        parseFont(font, ((1, 1), (1, 1))))
                elif name == "config_description":
                    eListboxPythonConfigContent.setDescriptionFont(
                        parseFont(font, ((1, 1), (1, 1))))
                elif name == "config_value":
                    eListboxPythonConfigContent.setValueFont(
                        parseFont(font, ((1, 1), (1, 1))))
                else:
                    raise SkinError(
                        "got listboxcontent font '%s' but 'string', 'config_description' or 'config_value' is allowed only"
                        % name)
        for value in c.findall("value"):
            get_attr = value.attrib.get
            name = get_attr("name")
            value = get_attr("value")
            if name and value:
                if name == "string_item_height":
                    eListboxPythonStringContent.setItemHeight(
                        parseValue(value))
                elif name == "config_item_height":
                    eListboxPythonConfigContent.setItemHeight(
                        parseValue(value))
                else:
                    raise SkinError(
                        "got listboxcontent value '%s' but 'string_item_height' or 'config_item_height' is allowed only"
                        % name)
        for cfgpm in c.findall("config"):
            onPath = cfgpm.attrib.get("onPixmap")
            if not fileExists(onPath):
                onPath = resolveFilename(SCOPE_CURRENT_SKIN, onPath)
            offPath = cfgpm.attrib.get("offPixmap")
            if not fileExists(offPath):
                offPath = resolveFilename(SCOPE_CURRENT_SKIN, offPath)
            pixmapSize = cfgpm.attrib.get("size")
            if pixmapSize:
                pixmapSize = parseSize(pixmapSize, ((1, 1), (1, 1)))
            else:
                pixmapSize = eSize()
            ConfigBoolean.setOnOffPixmaps(
                loadPixmap(onPath, desktop, pixmapSize),
                loadPixmap(offPath, desktop, pixmapSize))
    for c in skin.findall("fonts"):
        for font in c.findall("font"):
            get_attr = font.attrib.get
            filename = get_attr("filename", "<NONAME>")
            name = get_attr("name", "Regular")
            scale = get_attr("scale")
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr("replacement") and True or False
            resolved_font = resolveFilename(SCOPE_FONTS,
                                            filename,
                                            path_prefix=path_prefix)
            if not fileExists(
                    resolved_font
            ):  #when font is not available look at current skin path
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement)
            #print "Font: ", resolved_font, name, scale, is_replacement

    for c in skin.findall("subtitles"):
        from enigma import eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall("sub"):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr("font"), scale)
            col = get_attr("foregroundColor")
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(0xFFFFFF)
                haveColor = 0
            col = get_attr("shadowColor")
            if col:
                shadowColor = parseColor(col)
            else:
                shadowColor = gRGB(0)
            shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
            face = eSubtitleWidget.__dict__[get_attr("name")]
            eSubtitleWidget.setFontStyle(face, font, haveColor,
                                         foregroundColor, shadowColor,
                                         shadowOffset)

    for windowstyle in skin.findall("windowstyle"):
        style = eWindowStyleSkinned()
        id = windowstyle.attrib.get("id")
        if id:
            id = int(id)
        else:
            id = 0
        #print "windowstyle:", id

        # defaults
        font = gFont("Regular", 20)
        offset = eSize(20, 5)

        for title in windowstyle.findall("title"):
            get_attr = title.attrib.get
            offset = parseSize(get_attr("offset"), ((1, 1), (1, 1)))
            font = parseFont(get_attr("font"), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        #print "  ", font, offset

        for borderset in windowstyle.findall("borderset"):
            bsName = str(borderset.attrib.get("name"))
            for pixmap in borderset.findall("pixmap"):
                get_attr = pixmap.attrib.get
                bpName = get_attr("pos")
                if "filename" in pixmap.attrib:
                    filename = get_attr("filename")
                    if filename and bpName:
                        png = loadPixmap(
                            resolveFilename(SCOPE_SKIN_IMAGE,
                                            filename,
                                            path_prefix=path_prefix), desktop)
                        style.setPixmap(eWindowStyleSkinned.__dict__[bsName],
                                        eWindowStyleSkinned.__dict__[bpName],
                                        png)
                elif "color" in pixmap.attrib:
                    color = parseColor(get_attr("color"))
                    size = int(get_attr("size"))
                    Log.w("%s: %s @ %s" % (bpName, color.argb(), size))
                    style.setColorBorder(eWindowStyleSkinned.__dict__[bsName],
                                         eWindowStyleSkinned.__dict__[bpName],
                                         color, size)

        for color in windowstyle.findall("color"):
            get_attr = color.attrib.get
            colorType = get_attr("name")
            color = parseColor(get_attr("color"))
            try:
                style.setColor(eWindowStyleSkinned.__dict__["col" + colorType],
                               color)
            except:
                raise SkinError("Unknown color %s" % (colorType))

        for listfont in windowstyle.findall("listfont"):
            get_attr = listfont.attrib.get
            fontType = get_attr("type")
            fontSize = int(get_attr("size"))
            fontFace = get_attr("font")
            try:
                Log.i("########### ADDING %s: %s" % (fontType, fontSize))
                style.setListFont(
                    eWindowStyleSkinned.__dict__["listFont" + fontType],
                    fontSize, fontFace)
            except:
                raise SkinError("Unknown listFont %s" % (fontType))

        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)

    for windowstylescrollbar in skin.findall("windowstylescrollbar"):
        style = eWindowStyleScrollbar()
        id = windowstylescrollbar.attrib.get("id")
        if id:
            id = int(id)
        else:
            id = 4
        for value in windowstylescrollbar.findall("value"):
            get_attr = value.attrib.get
            vType = get_attr("name")
            v = get_attr("value")
            if vType in ("BackgroundPixmapTopHeight",
                         "BackgroundPixmapBeginSize"):
                style.setBackgroundPixmapTopHeight(int(v))
            elif vType in ("BackgroundPixmapBottomHeight",
                           "BackgroundPixmapEndSize"):
                style.setBackgroundPixmapBottomHeight(int(v))
            elif vType in ("ValuePixmapTopHeight", "ValuePixmapBeginSize"):
                style.setValuePixmapTopHeight(int(v))
            elif vType in ("ValuePixmapBottomHeight", "ValuePixmapEndSize"):
                style.setValuePixmapBottomHeight(int(v))
            elif vType == "ScrollbarWidth":
                style.setScrollbarWidth(int(v))
            elif vType == "ScrollbarBorderWidth":
                style.setScrollbarBorderWidth(int(v))
        for pixmap in windowstylescrollbar.findall("pixmap"):
            get_attr = pixmap.attrib.get
            vType = get_attr("name")
            filename = get_attr("filename")
            if filename:
                if vType == "BackgroundPixmap":
                    png = loadPixmap(
                        resolveFilename(SCOPE_SKIN_IMAGE,
                                        filename,
                                        path_prefix=path_prefix), desktop)
                    style.setBackgroundPixmap(png)
                elif vType == "ValuePixmap":
                    png = loadPixmap(
                        resolveFilename(SCOPE_SKIN_IMAGE,
                                        filename,
                                        path_prefix=path_prefix), desktop)
                    style.setValuePixmap(png)
        x = eWindowStyleManager.getInstance()
        x.setStyle(id, style)

    for g in skin.findall("globals"):
        for value in g.findall("value"):
            Log.i("Global skin value : %s" % (value.attrib, ))
            skinGlobals[value.attrib["name"]] = value.attrib["value"]

    for components in skin.findall("components"):
        for component in components.findall("component"):
            componentSizes.apply(component.attrib)
            for template in component.findall("template"):
                componentSizes.addTemplate(component.attrib, template.text)

    for l in skin.findall("layouts"):
        for layout in l.findall("layout"):
            layouts.apply(layout)
Exemplo n.º 40
0
				parameters[name] = map(int, value.split(","))
			except Exception, ex:
				print "[SKIN] bad parameter", ex

	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("shadowColor")
			if col:
				shadowColor = parseColor(col)
			else:
				shadowColor = gRGB(0)
			shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, shadowColor, shadowOffset)

	for windowstyle in skin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		id = windowstyle.attrib.get("id")
		if id:
			id = int(id)
Exemplo n.º 41
0
def parseColor(s):
    return gRGB(int(s[1:], 0x10))
Exemplo n.º 42
0
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall("output"):
        id = c.attrib.get("id")
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall("resolution"):
                get_attr = res.attrib.get
                xres = get_attr("xres")
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr("yres")
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr("bpp")
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC

                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for skininclude in skin.findall("include"):
        filename = skininclude.attrib.get("filename")
        if filename:
            skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
            if not fileExists(skinfile):
                skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
            if fileExists(skinfile):
                print "[SKIN] loading include:", skinfile
                loadSkin(skinfile)

    for c in skin.findall("colors"):
        for color in c.findall("color"):
            get_attr = color.attrib.get
            name = get_attr("name")
            color = get_attr("value")
            if name and color:
                colorNames[name] = parseColor(color)
            else:
                raise SkinError("need color and name, got %s %s" % (name, color))

    for c in skin.findall("fonts"):
        for font in c.findall("font"):
            get_attr = font.attrib.get
            filename = get_attr("filename", "<NONAME>")
            name = get_attr("name", "Regular")
            scale = get_attr("scale")
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr("replacement") and True or False
            render = get_attr("render")
            if render:
                render = int(render)
            else:
                render = 0
            resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
            if not fileExists(resolved_font):
                resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename)
                if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)):
                    resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)):
                    resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)
            addFont(resolved_font, name, scale, is_replacement, render)

        for alias in c.findall("alias"):
            get = alias.attrib.get
            try:
                name = get("name")
                font = get("font")
                size = int(get("size"))
                height = int(get("height", size))
                width = int(get("width", size))
                fonts[name] = (font, size, height, width)
            except Exception as ex:
                print "[SKIN] bad font alias", ex

    for c in skin.findall("parameters"):
        for parameter in c.findall("parameter"):
            get = parameter.attrib.get
            try:
                name = get("name")
                value = get("value")
                parameters[name] = map(int, value.split(","))
            except Exception as ex:
                print "[SKIN] bad parameter", ex

    for c in skin.findall("subtitles"):
        from enigma import eSubtitleWidget

        scale = ((1, 1), (1, 1))
        for substyle in c.findall("sub"):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr("font"), scale)
            col = get_attr("foregroundColor")
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr("borderColor")
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr("borderWidth")
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr("name")]
            eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

    for windowstyle in skin.findall("windowstyle"):
        style = eWindowStyleSkinned()
        style_id = windowstyle.attrib.get("id")
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        font = gFont("Regular", 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall("title"):
            get_attr = title.attrib.get
            offset = parseSize(get_attr("offset"), ((1, 1), (1, 1)))
            font = parseFont(get_attr("font"), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall("borderset"):
            bsName = str(borderset.attrib.get("name"))
            for pixmap in borderset.findall("pixmap"):
                get_attr = pixmap.attrib.get
                bpName = get_attr("pos")
                filename = get_attr("filename")
                if filename and bpName:
                    pngfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
                    if fileExists(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)):
                        pngfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
                    png = loadPixmap(pngfile, desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall("color"):
            get_attr = color.attrib.get
            colorType = get_attr("name")
            color = parseColor(get_attr("color"))
            try:
                style.setColor(eWindowStyleSkinned.__dict__["col" + colorType], color)
            except:
                raise SkinError("Unknown color %s" % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(style_id, style)

    for margin in skin.findall("margin"):
        style_id = margin.attrib.get("id")
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        r = eRect(0, 0, 0, 0)
        v = margin.attrib.get("left")
        if v:
            r.setLeft(int(v))
        v = margin.attrib.get("top")
        if v:
            r.setTop(int(v))
        v = margin.attrib.get("right")
        if v:
            r.setRight(int(v))
        v = margin.attrib.get("bottom")
        if v:
            r.setBottom(int(v))
        getDesktop(style_id).setMargins(r)

    return
Exemplo n.º 43
0
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall('output'):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall('resolution'):
                get_attr = res.attrib.get
                xres = get_attr('xres')
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr('yres')
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr('bpp')
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for skininclude in skin.findall('include'):
        filename = skininclude.attrib.get('filename')
        if filename:
            skinfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
            if not fileExists(skinfile):
                skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
            if fileExists(skinfile):
                print '[SKIN] loading include:', skinfile
                loadSkin(skinfile)

    for c in skin.findall('colors'):
        for color in c.findall('color'):
            get_attr = color.attrib.get
            name = get_attr('name')
            color = get_attr('value')
            if name and color:
                colorNames[name] = parseColor(color)
            else:
                raise SkinError('need color and name, got %s %s' % (name, color))

    for c in skin.findall('fonts'):
        for font in c.findall('font'):
            get_attr = font.attrib.get
            filename = get_attr('filename', '<NONAME>')
            name = get_attr('name', 'Regular')
            scale = get_attr('scale')
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr('replacement') and True or False
            render = get_attr('render')
            if render:
                render = int(render)
            else:
                render = 0
            resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
            if not fileExists(resolved_font):
                resolved_font = resolveFilename(SCOPE_ACTIVE_SKIN, filename)
                if fileExists(resolveFilename(SCOPE_CURRENT_SKIN, filename)):
                    resolved_font = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                elif fileExists(resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)):
                    resolved_font = resolveFilename(SCOPE_ACTIVE_LCDSKIN, filename)
            addFont(resolved_font, name, scale, is_replacement, render)

        for alias in c.findall('alias'):
            get = alias.attrib.get
            try:
                name = get('name')
                font = get('font')
                size = int(get('size'))
                height = int(get('height', size))
                width = int(get('width', size))
                fonts[name] = (font,
                 size,
                 height,
                 width)
            except Exception as ex:
                print '[SKIN] bad font alias', ex

    for c in skin.findall('parameters'):
        for parameter in c.findall('parameter'):
            get = parameter.attrib.get
            try:
                name = get('name')
                value = get('value')
                parameters[name] = map(int, value.split(','))
            except Exception as ex:
                print '[SKIN] bad parameter', ex

    for c in skin.findall('subtitles'):
        from enigma import eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall('sub'):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr('font'), scale)
            col = get_attr('foregroundColor')
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr('borderColor')
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr('borderWidth')
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr('name')]
            eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

    for windowstyle in skin.findall('windowstyle'):
        style = eWindowStyleSkinned()
        style_id = windowstyle.attrib.get('id')
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        font = gFont('Regular', 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall('title'):
            get_attr = title.attrib.get
            offset = parseSize(get_attr('offset'), ((1, 1), (1, 1)))
            font = parseFont(get_attr('font'), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall('borderset'):
            bsName = str(borderset.attrib.get('name'))
            for pixmap in borderset.findall('pixmap'):
                get_attr = pixmap.attrib.get
                bpName = get_attr('pos')
                filename = get_attr('filename')
                if filename and bpName:
                    pngfile = resolveFilename(SCOPE_ACTIVE_SKIN, filename, path_prefix=path_prefix)
                    if fileExists(resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)):
                        pngfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
                    png = loadPixmap(pngfile, desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall('color'):
            get_attr = color.attrib.get
            colorType = get_attr('name')
            color = parseColor(get_attr('color'))
            try:
                style.setColor(eWindowStyleSkinned.__dict__['col' + colorType], color)
            except:
                raise SkinError('Unknown color %s' % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(style_id, style)

    for margin in skin.findall('margin'):
        style_id = margin.attrib.get('id')
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        r = eRect(0, 0, 0, 0)
        v = margin.attrib.get('left')
        if v:
            r.setLeft(int(v))
        v = margin.attrib.get('top')
        if v:
            r.setTop(int(v))
        v = margin.attrib.get('right')
        if v:
            r.setRight(int(v))
        v = margin.attrib.get('bottom')
        if v:
            r.setBottom(int(v))
        getDesktop(style_id).setMargins(r)
Exemplo n.º 44
0
			except Exception, ex:
				print "[SKIN] bad font alias", ex


	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("borderColor")
			if col:
				borderColor = parseColor(col)
			else:
				borderColor = gRGB(0)
			borderwidth = get_attr("borderWidth")
			if borderwidth is None:
				# default: use a subtitle border
				borderWidth = 3
			else:
				borderWidth = int(borderwidth)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)
Exemplo n.º 45
0
def loadSingleSkinData(desktop, skin, path_prefix):
    for c in skin.findall('output'):
        id = c.attrib.get('id')
        if id:
            id = int(id)
        else:
            id = 0
        if id == 0:
            for res in c.findall('resolution'):
                get_attr = res.attrib.get
                xres = get_attr('xres')
                if xres:
                    xres = int(xres)
                else:
                    xres = 720
                yres = get_attr('yres')
                if yres:
                    yres = int(yres)
                else:
                    yres = 576
                bpp = get_attr('bpp')
                if bpp:
                    bpp = int(bpp)
                else:
                    bpp = 32
                from enigma import gMainDC
                gMainDC.getInstance().setResolution(xres, yres)
                desktop.resize(eSize(xres, yres))
                if bpp != 32:
                    pass

    for skininclude in skin.findall('include'):
        filename = skininclude.attrib.get('filename')
        if filename:
            skinfile = resolveFilename(SCOPE_CURRENT_SKIN, filename, path_prefix=path_prefix)
            if not fileExists(skinfile):
                skinfile = resolveFilename(SCOPE_SKIN_IMAGE, filename, path_prefix=path_prefix)
            if fileExists(skinfile):
                print '[SKIN] loading include:', skinfile
                loadSkin(skinfile)

    for c in skin.findall('colors'):
        for color in c.findall('color'):
            get_attr = color.attrib.get
            name = get_attr('name')
            color = get_attr('value')
            if name and color:
                colorNames[name] = parseColor(color)
            else:
                raise SkinError('need color and name, got %s %s' % (name, color))

    for c in skin.findall('fonts'):
        for font in c.findall('font'):
            get_attr = font.attrib.get
            filename = get_attr('filename', '<NONAME>')
            name = get_attr('name', 'Regular')
            scale = get_attr('scale')
            if scale:
                scale = int(scale)
            else:
                scale = 100
            is_replacement = get_attr('replacement') and True or False
            render = get_attr('render')
            if render:
                render = int(render)
            else:
                render = 0
            resolved_font = resolveFilename(SCOPE_FONTS, filename, path_prefix=path_prefix)
            if not fileExists(resolved_font):
                skin_path = resolveFilename(SCOPE_CURRENT_SKIN, filename)
                if fileExists(skin_path):
                    resolved_font = skin_path
            addFont(resolved_font, name, scale, is_replacement, render)

        for alias in c.findall('alias'):
            get = alias.attrib.get
            try:
                name = get('name')
                font = get('font')
                size = int(get('size'))
                height = int(get('height', size))
                width = int(get('width', size))
                fonts[name] = (font,
                 size,
                 height,
                 width)
            except Exception as ex:
                print '[SKIN] bad font alias', ex

    for c in skin.findall('parameters'):
        for parameter in c.findall('parameter'):
            get = parameter.attrib.get
            try:
                name = get('name')
                value = get('value')
                parameters[name] = map(int, value.split(','))
            except Exception as ex:
                print '[SKIN] bad parameter', ex

    for c in skin.findall('subtitles'):
        from enigma import eWidget, eSubtitleWidget
        scale = ((1, 1), (1, 1))
        for substyle in c.findall('sub'):
            get_attr = substyle.attrib.get
            font = parseFont(get_attr('font'), scale)
            col = get_attr('foregroundColor')
            if col:
                foregroundColor = parseColor(col)
                haveColor = 1
            else:
                foregroundColor = gRGB(16777215)
                haveColor = 0
            col = get_attr('borderColor')
            if col:
                borderColor = parseColor(col)
            else:
                borderColor = gRGB(0)
            borderwidth = get_attr('borderWidth')
            if borderwidth is None:
                borderWidth = 3
            else:
                borderWidth = int(borderwidth)
            face = eSubtitleWidget.__dict__[get_attr('name')]
            eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, borderColor, borderWidth)

    for windowstyle in skin.findall('windowstyle'):
        style = eWindowStyleSkinned()
        style_id = windowstyle.attrib.get('id')
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        font = gFont('Regular', 20)
        offset = eSize(20, 5)
        for title in windowstyle.findall('title'):
            get_attr = title.attrib.get
            offset = parseSize(get_attr('offset'), ((1, 1), (1, 1)))
            font = parseFont(get_attr('font'), ((1, 1), (1, 1)))

        style.setTitleFont(font)
        style.setTitleOffset(offset)
        for borderset in windowstyle.findall('borderset'):
            bsName = str(borderset.attrib.get('name'))
            for pixmap in borderset.findall('pixmap'):
                get_attr = pixmap.attrib.get
                bpName = get_attr('pos')
                filename = get_attr('filename')
                if filename and bpName:
                    png = loadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, filename, path_prefix=path_prefix), desktop)
                    style.setPixmap(eWindowStyleSkinned.__dict__[bsName], eWindowStyleSkinned.__dict__[bpName], png)

        for color in windowstyle.findall('color'):
            get_attr = color.attrib.get
            colorType = get_attr('name')
            color = parseColor(get_attr('color'))
            try:
                style.setColor(eWindowStyleSkinned.__dict__['col' + colorType], color)
            except:
                raise SkinError('Unknown color %s' % colorType)

        x = eWindowStyleManager.getInstance()
        x.setStyle(style_id, style)

    for margin in skin.findall('margin'):
        style_id = margin.attrib.get('id')
        if style_id:
            style_id = int(style_id)
        else:
            style_id = 0
        r = eRect(0, 0, 0, 0)
        v = margin.attrib.get('left')
        if v:
            r.setLeft(int(v))
        v = margin.attrib.get('top')
        if v:
            r.setTop(int(v))
        v = margin.attrib.get('right')
        if v:
            r.setRight(int(v))
        v = margin.attrib.get('bottom')
        if v:
            r.setBottom(int(v))
        getDesktop(style_id).setMargins(r)
Exemplo n.º 46
0
 def __init__(self):
     Renderer.__init__(self)
     self.fColor = gRGB(255, 255, 255, 0)
     self.bColor = gRGB(0, 0, 0, 255)
     self.numval = -1
Exemplo n.º 47
0
    def __init__(self, session, title="", text="", additionalParams={}):
        self.session = session

        # autocomplete engine
        self.autocomplete = additionalParams.get('autocomplete')
        self.isAutocompleteEnabled = False

        self.searchHistory = additionalParams.get('search_history', [])

        self.skin = self.prepareSkin()

        Screen.__init__(self, session)
        self.onLayoutFinish.append(self.setGraphics)
        self.onShown.append(self.onWindowShow)
        self.onClose.append(self.__onClose)

        self["actions"] = NumberActionMap(["WizardActions", "DirectionActions", "ColorActions", "E2iPlayerVKActions", "KeyboardInputActions", "InputBoxActions", "InputAsciiActions"],
        {
            "gotAsciiCode": self.keyGotAscii,
            "ok": self.keyOK,
            "ok_repeat": self.keyOK,
            "back": self.keyBack,
            "left": self.keyLeft,
            "right": self.keyRight,
            "up": self.keyUp,
            "down": self.keyDown,
            "red": self.keyRed,
            "red_repeat": self.keyRed,
            "green": self.keyGreen,
            "yellow": self.keyYellow,
            "blue": self.keyBlue,
            "deleteBackward": self.backClicked,
            "deleteForward": self.forwardClicked,
            "pageUp": self.cursorRight,
            "pageDown": self.cursorLeft,
            "1": self.keyNumberGlobal,
            "2": self.keyNumberGlobal,
            "3": self.keyNumberGlobal,
            "4": self.keyNumberGlobal,
            "5": self.keyNumberGlobal,
            "6": self.keyNumberGlobal,
            "7": self.keyNumberGlobal,
            "8": self.keyNumberGlobal,
            "9": self.keyNumberGlobal,
            "0": self.keyNumberGlobal,
        }, -2)

        # Left list
        self['left_header'] = Label(" ")
        self['left_list'] = E2iVKSelectionList()

        # Right list
        if self.autocomplete:
            self['right_header'] = Label(" ")
            self['right_list'] = E2iVKSelectionList(False)
        self.isSuggestionVisible = None

        self.graphics = {}
        for key in ['pb', 'pr', 'pg', 'py', 'l', 'b', 'e', 'e_m', 'k', 'k_m', 'k_s', 'k2_m', 'k2_s', 'k3', 'k3_m']:
            self.graphics[key] = LoadPixmap(GetIconDir('e2ivk_hd/%s.png' if self.fullHD else 'e2ivk/%s.png') % key)

        for i in range(0, 63):
            self[str(i)] = Cover3()

        for key in ['l', 'b', 'e_m', 'k_m', 'k2_m', 'k3_m']:
            self[key] = Cover3()

        for i in range(1, 63):
            self['_%s' % i] = Label(" ")

        for m in range(6):
            self['m_%d' % m] = Label(" ")

        self.graphicsMap = {'0': 'e', '1': 'k_s', '15': 'k_s', '29': 'k_s', '57': 'k_s', '58': 'k_s', '60': 'k_s', '61': 'k_s', '62': 'k_s', '59': 'k3',
                            '16': 'k2_s', '30': 'k2_s', '42': 'k2_s', '43': 'k2_s', '55': 'k2_s', '56': 'k2_s'}

        self.markerMap = {'0': 'e_m', '59': 'k3_m', '16': 'k2_m', '30': 'k2_m', '42': 'k2_m', '43': 'k2_m', '55': 'k2_m', '56': 'k2_m'}

        self.header = title if title else _('Enter the text')
        self.startText = text

        self["text"] = E2iInput(text="")
        self["header"] = Label(" ")

        self.colMax = len(self.KEYIDMAP[0])
        self.rowMax = len(self.KEYIDMAP)

        self.rowIdx = 0
        self.colIdx = 0

        self.colors = {'normal': gRGB(int('ffffff', 0x10)), 'selected': gRGB(int('39b54a', 0x10)), 'deadkey': gRGB(int('0275a0', 0x10)), 'ligature': gRGB(int('ed1c24', 0x10)), 'inactive': gRGB(int('979697', 0x10))}

        self.specialKeyState = self.SK_NONE
        self.currentVKLayout = self.DEFAULT_VK_LAYOUT
        self.selectedVKLayoutId = config.plugins.iptvplayer.osk_layout.value
        self.vkRequestedId = additionalParams.get('vk_layout_id', '')
        self.deadKey = u''
        self.focus = self.FOCUS_KEYBOARD
Exemplo n.º 48
0
 def __init__(self):
     Renderer.__init__(self)
     self.fColor = gRGB(255, 255, 255, 0)
     self.bColor = gRGB(0, 0, 0, 255)
     self.numval = -1
Exemplo n.º 49
0
				fonts[name] = (font, size, height, width)
			except Exception, ex:
				print "[SKIN] bad font alias", ex

	for c in skin.findall("subtitles"):
		from enigma import eWidget, eSubtitleWidget
		scale = ((1,1),(1,1))
		for substyle in c.findall("sub"):
			get_attr = substyle.attrib.get
			font = parseFont(get_attr("font"), scale)
			col = get_attr("foregroundColor")
			if col:
				foregroundColor = parseColor(col)
				haveColor = 1
			else:
				foregroundColor = gRGB(0xFFFFFF)
				haveColor = 0
			col = get_attr("shadowColor")
			if col:
				shadowColor = parseColor(col)
			else:
				shadowColor = gRGB(0)
			shadowOffset = parsePosition(get_attr("shadowOffset"), scale)
			face = eSubtitleWidget.__dict__[get_attr("name")]
			eSubtitleWidget.setFontStyle(face, font, haveColor, foregroundColor, shadowColor, shadowOffset)

	for windowstyle in skin.findall("windowstyle"):
		style = eWindowStyleSkinned()
		id = windowstyle.attrib.get("id")
		if id:
			id = int(id)