def applySkin(self, desktop, parent): attribs = [] for (attrib, value) in self.skinAttributes: if attrib == "numEvents": self.numEvents = int(value) elif attrib == "maxDescriptionLines": self.numDescLines = int(value) elif attrib == "font": self.used_font = parseFont(value, ((1, 1), (1, 1))) elif attrib == "foregroundColor": self.fcolor = parseColor(value) elif attrib == "foregroundColorTime": self.timecolor = parseColor(value) elif attrib == "backgroundColor": self.bcolor = parseColor(value) elif attrib == "foregroundColorDescription": self.fdcolor = parseColor(value) elif attrib == "fontDescription": self.desc_font = parseFont(value, ((1, 1), (1, 1))) else: attribs.append((attrib, value)) self.skinAttributes = attribs self.testSizeLabel.setFont(self.used_font) self.testSizeLabel.resize(eSize(self.W + 500, 20)) self.testSizeLabel.setVAlign(eLabel.alignTop) self.testSizeLabel.setHAlign(eLabel.alignLeft) self.testSizeLabel.setNoWrap(1) tmp = int(fontRenderClass.getInstance().getLineHeight(self.used_font) or self.used_font.pointSize / 6 + self.used_font.pointSize) self.testSizeLabel.setText("WQq") self.lineHeight = self.testSizeLabel.calculateSize().height() if tmp > self.lineHeight: self.lineHeight = tmp self.testSizeLabel.setText("59:59 ") self.timeWidth = self.testSizeLabel.calculateSize().width() + 10 self.testSizeLabel.setText("") self.testSizeLabel.setFont(self.desc_font) tmp = int(fontRenderClass.getInstance().getLineHeight(self.desc_font) or self.desc_font.pointSize / 6 + self.desc_font.pointSize) self.testSizeLabel.setText("WQq") self.lineHeight_desc = self.testSizeLabel.calculateSize().height() if tmp > self.testSizeLabel.calculateSize().height(): self.lineHeight_desc = tmp self.lineHeight_desc *= self.numDescLines self.testSizeLabel.setText("") self.testSizeLabel.resize(eSize(self.W - 10, 1000)) self.testSizeLabel.setHAlign(eLabel.alignBlock) self.testSizeLabel.setNoWrap(0) return Renderer.applySkin(self, desktop, parent)
def changed(self, what): if what[0] == self.CHANGED_CLEAR: if self.long_text is not None: self.long_text.move(ePoint(0, 0)) self.long_text.setText('') self.long_text.resize(self.instance.size()) self.updateTimer.stop() else: if self.long_text is not None: self.long_text.move(ePoint(0, 0)) if self.source.text is None: self.long_text.setText('') else: self.long_text.setText(self.source.text) self.page_height = int(self.instance.size().height()) self.text_height = int( self.long_text.calculateSize().height() + fontRenderClass.getInstance().getLineHeight( self.long_text.getFont())) self.long_text.resize( eSize(self.instance.size().width(), self.text_height)) if self.text_height > self.page_height: self.updateTimer.start(self.startdelay) else: self.updateTimer.stop() return
def resizeAndSet(self, newText, height): s = self.instance.size() textSize = (s.width(), s.height()) textSize = (textSize[0], textSize[1] - height) self.instance.resize(eSize(*textSize)) p = self.instance.position() pos = (p.x(), p.y() + height) self.instance.move(ePoint(pos[0], pos[1])) self.long_text.resize(eSize(*textSize)) self.long_text.move(ePoint(pos[0], pos[1])) s = self.long_text.size() lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont()) lines = int(s.height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.resize( eSize(s.width(), self.pageHeight + int(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 20, 0)) self.scrollbar.resize(eSize(20, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0, 0)) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 16)) self.setText(newText)
def applySkin(self, desktop, parent): ret = False if self.skinAttributes is not None: widget_attribs = [] scrollbar_attribs = [] for (attrib, value) in self.skinAttributes: if "borderColor" in attrib or "borderWidth" in attrib: scrollbar_attribs.append((attrib, value)) if "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib, value)) if "split" in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) if "colposition" in attrib: self.column = int(value) if "dividechar" in attrib: self.splitchar = value if self.split: skin.applyAllAttributes( self.long_text, desktop, self.skinAttributes + [("halign", "left")], parent.scale) skin.applyAllAttributes( self.right_text, desktop, self.skinAttributes + [("transparent", "1"), ("halign", "left" and self.column or "right")], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont()) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize( eSize(s.width(), self.pageHeight + (int)(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 20, 0)) self.scrollbar.resize( eSize(20, self.pageHeight + (int)(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0, 0)) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 16)) if self.split: self.right_text.move(ePoint(self.column, 0)) self.right_text.resize( eSize(s.width() - self.column - 30, self.pageHeight * 16)) self.setText(self.message) return ret
def layoutFinished(self): font = gFont("Console", applySkinFactor(16)) if not int(fontRenderClass.getInstance().getLineHeight(font)): font = gFont("Regular", applySkinFactor(16)) self["list"].instance.setFont(font) fontwidth = getTextBoundarySize(self.instance, font, self["list"].instance.size(), _(" ")).width() listwidth = int(self["list"].instance.size().width() / fontwidth) - 2 if path.exists(self.logfile): for line in open(self.logfile).readlines(): line = line.replace("\t", " " * 9) if len(line) > listwidth: pos = 0 offset = 0 readyline = True while readyline: a = " " * offset + line[pos:pos + listwidth - offset] self.log.append(a) if len(line[pos + listwidth - offset:]): pos += listwidth - offset offset = 19 else: readyline = False else: self.log.append(line) else: self.log = [_("file can not displayed - file not found")] self["list"].setList(self.log)
def go(self): if len(self.subtitle) == 0: printDEBUG("Subtitles not loaded, timer disabled.") else: printDEBUG("Enable loaded %d subtitles" % len(self.subtitle)) self.enablesubtitle = True self.timer = eTimer() self.timer.callback.append(self.timerEvent) self.timer.start(200, False) printDEBUG("Playing: " + str(self.rootID) + ":0:0:0:0:0:0:0:0:0:" + self.openmovie) root = eServiceReference(self.rootID, 0, self.openmovie) root.setName (self.movieTitle) self.session.nav.playService(root) myConfig.PlayerOn.value = True self.stateplay = "Play" self["afpSubtitles"].instance.move(ePoint(0,self.fontpos)) self["afpSubtitles"].instance.setForegroundColor(parseColor(self.fontcolor_list[self.fontcolor_nr])) self["afpSubtitles"].instance.setBackgroundColor(parseColor(self.backgroundcolor_list[self.fontbackground_nr])) self["afpSubtitles"].instance.setFont(gFont(self.fonttype_list[self.fonttype_nr], self.fontsize)) self.SubtitleLineHeight = int(fontRenderClass.getInstance().getLineHeight(self["afpSubtitles"].instance.getFont())) if self.SubtitleLineHeight > self.fontsize: printDEBUG("SubtitleLineHeight calculated: %d" % self.SubtitleLineHeight) else: self.SubtitleLineHeight = int(self.fontsize * 1.1) printDEBUG("SubtitleLineHeight assumed: %d" % self.SubtitleLineHeight) self.ToggleInfobar()
def layoutFinished(self): screenwidth = getDesktop(0).size().width() if screenwidth and screenwidth < 1920: f = 1 elif screenwidth and screenwidth < 3840: f = 1.5 else: f = 3 font = gFont("Console", int(16*f)) if not int(fontRenderClass.getInstance().getLineHeight(font)): font = gFont("Regular", int(16*f)) self["list"].instance.setFont(font) fontwidth = getTextBoundarySize(self.instance, font, self["list"].instance.size(), _(" ")).width() listwidth = int(self["list"].instance.size().width() / fontwidth) - 2 if path.exists(self.logfile): for line in file(self.logfile ).readlines(): line = line.replace('\t',' '*9) if len(line) > listwidth: pos = 0 offset = 0 readyline = True while readyline: a = " " * offset + line[pos:pos+listwidth-offset] self.log.append(a) if len(line[pos+listwidth-offset:]): pos += listwidth-offset offset = 19 else: readyline = False else: self.log.append(line) else: self.log = [_("file can not displayed - file not found")] self["list"].setList(self.log)
def applySkin(self, desktop, parent): ret = False if self.skinAttributes is not None: widget_attribs = [] scrollbar_attribs = [] for attrib, value in self.skinAttributes: if 'borderColor' in attrib or 'borderWidth' in attrib: scrollbar_attribs.append((attrib, value)) if 'transparent' in attrib or 'backgroundColor' in attrib: widget_attribs.append((attrib, value)) if 'split' in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) if 'colposition' in attrib: self.column = int(value) if 'dividechar' in attrib: self.splitchar = value if self.split: skin.applyAllAttributes( self.long_text, desktop, self.skinAttributes + [('halign', 'left')], parent.scale) skin.applyAllAttributes( self.right_text, desktop, self.skinAttributes + [('transparent', '1'), ('halign', 'left' and self.column or 'right')], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont()) if not lineheight: lineheight = 30 lines = int(s.height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.resize( eSize(s.width(), self.pageHeight + int(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 10, 0)) self.scrollbar.resize(eSize(10, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0, 0)) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 40)) if self.split: self.right_text.move(ePoint(self.column, 0)) self.right_text.resize( eSize(s.width() - self.column - 30, self.pageHeight * 40)) self.setText(self.message) return ret
def applySkin(self, desktop, parent): scrollbarWidth = 20 scrollbarBorderWidth = 1 ret = False if self.skinAttributes: widget_attribs = [] scrollbar_attribs = [] for (attrib, value) in self.skinAttributes: if "borderColor" in attrib or "borderWidth" in attrib: scrollbar_attribs.append((attrib,value)) if "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib,value)) if "scrollbarSliderForegroundColor" in attrib: scrollbar_attribs.append((attrib,value)) self.skinAttributes.remove((attrib, value)) if "scrollbarSliderBorderColor" in attrib: scrollbar_attribs.append((attrib,value)) self.skinAttributes.remove((attrib, value)) if "scrollbarSliderPicture" in attrib: scrollbar_attribs.append((attrib,value)) self.skinAttributes.remove((attrib, value)) if "scrollbarBackgroundPicture" in attrib: scrollbar_attribs.append((attrib,value)) self.skinAttributes.remove((attrib, value)) if "scrollbarWidth" in attrib: scrollbarWidth = int(value) self.skinAttributes.remove((attrib, value)) if "scrollbarSliderBorderWidth" in attrib: scrollbarBorderWidth = int(value) self.skinAttributes.remove((attrib, value)) if "split" in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) self.skinAttributes.remove((attrib, value)) if "colposition" in attrib: self.column = int(value) if "dividechar" in attrib: self.splitchar = value if self.split: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes + [("halign", "left")], parent.scale) skin.applyAllAttributes(self.right_text, desktop, self.skinAttributes + [("transparent", "1"), ("halign", "left" if self.column else "right")], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True self.pageWidth = self.long_text.size().width() lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) or 30 # assume a random lineheight if nothing is visible lines = int(self.long_text.size().height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.move(self.long_text.position()) self.instance.resize(eSize(self.pageWidth, self.pageHeight + int(lineheight/6))) self.scrollbar.move(ePoint(self.pageWidth - scrollbarWidth, 0)) self.scrollbar.resize(eSize(scrollbarWidth, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.setText(self.message) return ret
def applySkin(self, desktop, parent): ret = False if self.skinAttributes is not None: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) widget_attribs = [ ] scrollbar_attribs = [ ] for (attrib, value) in self.skinAttributes: if "borderColor" in attrib or "borderWidth" in attrib: scrollbar_attribs.append((attrib,value)) if "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib,value)) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs+widget_attribs, parent.scale) ret = True s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight+(int)(lineheight/6))) self.scrollbar.move(ePoint(s.width()-20,0)) self.scrollbar.resize(eSize(20,self.pageHeight+(int)(lineheight/6))) self.scrollbar.setOrientation(eSlider.orVertical); self.scrollbar.setRange(0,100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0,0)) self.long_text.resize(eSize(s.width()-30, self.pageHeight*50)) self.setText(self.message) return ret
def applySkin(self, desktop, parent): scrollbarWidth = 20 scrollbarBorderWidth = 1 ret = False if self.skinAttributes: widget_attribs = [] scrollbar_attribs = [] scrollbarAttrib = ["borderColor", "borderWidth", "scrollbarSliderForegroundColor", "scrollbarSliderBorderColor"] for (attrib, value) in self.skinAttributes[:]: if attrib in scrollbarAttrib: scrollbar_attribs.append((attrib, value)) self.skinAttributes.remove((attrib, value)) elif attrib in ("scrollbarSliderPicture", "sliderPixmap"): self.scrollbar.setPixmap(loadPixmap(value, desktop)) self.skinAttributes.remove((attrib, value)) elif attrib in ("scrollbarBackgroundPicture", "scrollbarbackgroundPixmap"): self.scrollbar.setBackgroundPixmap(loadPixmap(value, desktop)) self.skinAttributes.remove((attrib, value)) elif "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib, value)) elif "scrollbarWidth" in attrib: scrollbarWidth = int(value) self.skinAttributes.remove((attrib, value)) elif "scrollbarSliderBorderWidth" in attrib: scrollbarBorderWidth = int(value) self.skinAttributes.remove((attrib, value)) elif "split" in attrib: self.split = 1 if value.lower() in ("1", "enabled", "on", "split", "true", "yes") else 0 if self.split: self.right_text = eLabel(self.instance) self.skinAttributes.remove((attrib, value)) elif "colposition" in attrib or "colPosition" in attrib: self.column = int(value) elif "dividechar" in attrib or "divideChar" in attrib: self.splitchar = value if self.split: applyAllAttributes(self.long_text, desktop, self.skinAttributes + [("halign", "left")], parent.scale) applyAllAttributes(self.right_text, desktop, self.skinAttributes + [("transparent", "1"), ("halign", "left" if self.column else "right")], parent.scale) else: applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True self.pageWidth = self.long_text.size().width() lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) or 30 # assume a random lineheight if nothing is visible lines = int(self.long_text.size().height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.move(self.long_text.position()) self.instance.resize(eSize(self.pageWidth, self.pageHeight + int(lineheight / 6))) self.long_text.resize(eSize(self.pageWidth - 30, self.pageHeight + int(lineheight / 6))) self.scrollbar.move(ePoint(self.pageWidth - scrollbarWidth, 0)) self.scrollbar.resize(eSize(scrollbarWidth, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.setText(self.message) return ret
def changed(self, what): if what[0] == self.CHANGED_CLEAR: if self.long_text is not None: self.long_text.move(ePoint(0, 0)) if self.animationScreen and self.astartdelay != 0: self.aupdateTimer.stop() self.instance.move(self._position) self.resize(self._size) self.long_text.hide() self.scrollbar.hide() self.hide() self.message = '' self.long_text.setText('') self.long_text.resize(self.instance.size()) self.updateTimer.stop() elif self.long_text is not None: if self.source.text is None: self.message = '' self.long_text.setText('') self.long_text.hide() self.scrollbar.hide() self.hide() else: if self.message == self.source.text: return self.message = self.source.text self.long_text.setText(self.source.text) self.long_text.show() self.show() if self.animationScreen and self.astartdelay != 0: self.aupdateTimer.stop() self.instance.move(self._position) self.resize(self._size) self.page_height = int(self.instance.size().height()) self.text_height = int(self.long_text.calculateSize().height() + fontRenderClass.getInstance().getLineHeight( self.long_text.getFont())) if self.text_height > self.page_height: self.long_text.resize( eSize(self.instance.size().width(), self.text_height)) if self.autoScroll: self.long_text.move(ePoint(0, 0)) if self.animationScreen and self.astartdelay != 0: self.aupdateTimer.start(self.astartdelay, True) else: self.updateTimer.start(self.startdelay) elif self.valignbottom: self.long_text.move( ePoint(0, self.page_height - self.text_height)) else: self.long_text.move(ePoint(0, 0)) self.long_text.resize( eSize(self.instance.size().width(), self.instance.size().height())) self.updateTimer.stop() self.updateScrollbar()
def setFontSize(self, fontSize): if self.opensubtitle == '': return self.fontsize = self.fontsize + fontSize if self.fontsize < 10: self.fontsize = 10 elif self.fontsize > 80: self.fontsize = 80 self["afpSubtitles"].instance.setFont(gFont(self.fonttype_list[self.fonttype_nr], self.fontsize)) self.SubtitleLineHeight= int(fontRenderClass.getInstance().getLineHeight(self["afpSubtitles"].instance.getFont())) self.setTextForAllLInes(_("Font %s\nSize %s\nLine3") % (self.fonttype_list[self.fonttype_nr],self.fontsize))
def applySkin(self, desktop, parent): scrollbarWidth = 20 scrollbarBorderWidth = 1 ret = False if self.skinAttributes is not None: scrollbar_attribs = [ ] widget_attribs = [ ] remove_attribs = [ ] for (attrib, value) in self.skinAttributes: if attrib.find("borderColor") != -1 or attrib.find("borderWidth") != -1: scrollbar_attribs.append((attrib,value)) if attrib.find("transparent") != -1 or attrib.find("backgroundColor") != -1: widget_attribs.append((attrib,value)) if attrib.find("scrollbarSliderForegroundColor") != -1: scrollbar_attribs.append((attrib,value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderBorderColor") != -1: scrollbar_attribs.append((attrib,value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderPicture") != -1: scrollbar_attribs.append((attrib,value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarBackgroundPicture") != -1: scrollbar_attribs.append((attrib,value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarWidth") != -1: scrollbarWidth = int(value) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderBorderWidth") != -1: scrollbarBorderWidth = int(value) remove_attribs.append((attrib, value)) for (attrib, value) in remove_attribs: self.skinAttributes.remove((attrib, value)) skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs+widget_attribs, parent.scale) ret = True s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight+(int)(lineheight/6))) self.scrollbar.move(ePoint(s.width() - scrollbarWidth,0)) self.scrollbar.resize(eSize(scrollbarWidth,self.pageHeight+(int)(lineheight/6))) self.scrollbar.setOrientation(eSlider.orVertical); self.scrollbar.setRange(0,100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.long_text.move(ePoint(0,0)) self.long_text.resize(eSize(s.width()-30, self.pageHeight*16)) self.setText(self.message) return ret
def resize(self, s): lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight + (int)(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 20, 0)) self.scrollbar.resize(eSize(20, self.pageHeight + (int)(lineheight / 6))) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 16)) self.setText(self.message)
def resize(self, s): lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight+(int)(lineheight/6))) self.scrollbar.move(ePoint(s.width()-20,0)) self.scrollbar.resize(eSize(20,self.pageHeight+(int)(lineheight/6))) self.long_text.resize(eSize(s.width()-30, self.pageHeight*16)) self.setText(self.message)
def applySkin(self, desktop): skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes) s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) lines = int(s.height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight + int(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 20, 0)) self.scrollbar.resize(eSize(20, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0, 0)) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 16)) self.setText(self.message)
def applySkin(self, desktop, parent): ret = False if self.skinAttributes is not None: widget_attribs = [] scrollbar_attribs = [] for attrib, value in self.skinAttributes: if 'borderColor' in attrib or 'borderWidth' in attrib: scrollbar_attribs.append((attrib, value)) if 'transparent' in attrib or 'backgroundColor' in attrib: widget_attribs.append((attrib, value)) if 'split' in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) if 'colposition' in attrib: self.column = int(value) if 'dividechar' in attrib: self.splitchar = value if self.split: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes + [('halign', 'left')], parent.scale) skin.applyAllAttributes(self.right_text, desktop, self.skinAttributes + [('transparent', '1'), ('halign', 'left' and self.column or 'right')], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) if not lineheight: lineheight = 30 lines = int(s.height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight + int(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 10, 0)) self.scrollbar.resize(eSize(10, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0, 0)) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 40)) if self.split: self.right_text.move(ePoint(self.column, 0)) self.right_text.resize(eSize(s.width() - self.column - 30, self.pageHeight * 40)) self.setText(self.message) return ret
def applySkin(self, desktop, parent): if self.skinAttributes is None: return False skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) widget_attribs = [] scrollbar_attribs = [] for (attrib, value) in self.skinAttributes: if attrib.find("borderColor") != -1 or attrib.find( "borderWidth") != -1: scrollbar_attribs.append((attrib, value)) if attrib.find("transparent") != -1 or attrib.find( "backgroundColor") != -1: widget_attribs.append((attrib, value)) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont()) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize( eSize(s.width(), self.pageHeight + (int)(lineheight / 6))) scrollbarwidth, scrollbarborderwidth = self.scrollbar.updateScrollLabelProperties( 20, 1) self.scrollbar.move(ePoint(s.width() - scrollbarwidth, 0)) self.scrollbar.resize( eSize(scrollbarwidth, self.pageHeight + (int)(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarborderwidth) self.long_text.move(ePoint(0, 0)) self.long_text.resize( eSize(s.width() - scrollbarwidth - 10, self.pageHeight * 16)) self.setText(self.message) return True
def changed(self, what): if what[0] == self.CHANGED_CLEAR: if self.long_text is not None: self.long_text.move(ePoint(0, 0)) self.long_text.setText('') self.long_text.resize(self.instance.size()) self.updateTimer.stop() elif self.long_text is not None: self.long_text.move(ePoint(0, 0)) if self.source.text is None: self.long_text.setText('') else: self.long_text.setText(self.source.text) self.page_height = int(self.instance.size().height()) self.text_height = int(self.long_text.calculateSize().height() + fontRenderClass.getInstance().getLineHeight(self.long_text.getFont())) self.long_text.resize(eSize(self.instance.size().width(), self.text_height)) if self.text_height > self.page_height: self.updateTimer.start(self.startdelay) else: self.updateTimer.stop()
def ShowJump(self, seconds, subtitlesSeek = False): self.showJumpNumber += seconds #seconds can be positiove or negative if self.showJumpNumber != 0: if subtitlesSeek: text = "%ss | %ss" % (self.showJumpNumber,self.seeksubtitle) else: text = "%02d:%02d" % divmod(self.showJumpNumber,60) #w = self["showJump"].instance.size().width() self["showJump"].setText(text) height = self["showJump"].instance.size().height() width = int(int(fontRenderClass.getInstance().getLineHeight(self["showJump"].instance.getFont())) * len(text) * 0.7) #self["showJump"].instance.resize(eSize(width, linesNO * self.SubtitleLineHeight) ) self["showJump"].instance.resize( eSize(width, height) ) self["showJump"].show() self.ShowJumpTimer.stop() #in case ff/rf pressed several timwes self.ShowJumpTimer.start(1000 * int(myConfig.InfobarTime.value), True) # singleshot else: self["showJump"].setText("") self["showJump"].hide() self.showJumpNumber = 0
def resizeAndSet(self, newText, height): s = self.instance.size() textSize = (s.width(), s.height()) textSize = (textSize[0], textSize[1] - height) self.instance.resize(eSize(*textSize)) p = self.instance.position() pos = (p.x(), p.y() + height) self.instance.move(ePoint(pos[0], pos[1])) self.long_text.resize(eSize(*textSize)) self.long_text.move(ePoint(pos[0], pos[1])) s = self.long_text.size() lineheight = fontRenderClass.getInstance().getLineHeight(self.long_text.getFont()) lines = int(s.height() / lineheight) self.pageHeight = int(lines * lineheight) self.instance.resize(eSize(s.width(), self.pageHeight + int(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - 20, 0)) self.scrollbar.resize(eSize(20, self.pageHeight + int(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(1) self.long_text.move(ePoint(0, 0)) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 16)) self.setText(newText)
def _animationEnd(self): if self.autoScroll: self.page_height = int(self.instance.size().height()) self.text_height = int(self.long_text.calculateSize().height() + fontRenderClass.getInstance().getLineHeight( self.long_text.getFont())) self.long_text.resize( eSize(self.instance.size().width(), self.text_height)) self.updateScrollbar() if self.text_height > self.page_height: self.updateTimer.start(self.startdelay) else: self.updateTimer.stop() elif self.animationLongText: self.updateScrollbar() self.animationLongText = False curPos = self.long_text.position() if curPos.y() > 0: newPos = ePoint(curPos.x(), 0) self.long_text.startMoveAnimation(newPos, 5, 1, 1) elif curPos.y() + self.text_height < self.page_height: newPos = ePoint(curPos.x(), self.page_height - self.text_height) self.long_text.startMoveAnimation(newPos, 5, 1, 1)
def applySkin(self, desktop, parent): scrollLabelDefaults = (("scrollbarBorderWidth", eListbox.DefaultScrollBarBorderWidth), ("scrollbarMode", eListbox.showOnDemand), ("scrollbarOffset", eListbox.DefaultScrollBarOffset), ("scrollbarScroll", eListbox.DefaultScrollBarScroll), ("scrollbarWidth", eListbox.DefaultScrollBarWidth)) for attribute, default in scrollLabelDefaults: if attribute not in scrollLabelStyle: scrollLabelStyle[attribute] = default splitMargin = 0 splitPosition = 0 splitSeparated = False sliderBorderWidth = scrollLabelStyle["scrollbarBorderWidth"] sliderMode = scrollLabelStyle["scrollbarMode"] sliderScroll = scrollLabelStyle["scrollbarScroll"] sliderOffset = scrollLabelStyle["scrollbarOffset"] sliderWidth = scrollLabelStyle["scrollbarWidth"] if self.skinAttributes: sliderProperties = ("scrollbarBorderColor", "scrollbarBorderWidth", "scrollbarBackgroundColor", "scrollbarForegroundColor", "scrollbarBackgroundPixmap", "scrollbarForegroundPixmap") widgetAttributes = [] leftLabelAttributes = [("transparent", "1")] rightLabelAttributes = [("transparent", "1")] sliderAttributes = [("transparent", "1")] leftAlign = "left" rightAlign = "left" for attribute, value in self.skinAttributes: if attribute in sliderProperties: sliderAttributes.append((attribute, value)) else: if attribute in ("backgroundColor", "transparent"): widgetAttributes.append((attribute, value)) continue if attribute in ("leftColumnAlignment", "leftColAlign"): leftAlign = parseHorizontalAlignment( value ) # The parser is used to check if the value is valid, an exception is raised if it isn't! elif attribute in ("rightColumnAlignment", "rightColAlign"): rightAlign = parseHorizontalAlignment( value ) # The parser is used to check if the value is valid, an exception is raised if it isn't! self.split = True elif attribute == "split": self.split = parseBoolean("split", value) elif attribute in ("splitCharacter", "divideChar", "dividechar"): self.splitCharacter = value self.split = True elif attribute == "splitMargin": splitMargin = parseInteger(value) elif attribute in ("splitPosition", "colPosition", "colposition"): splitPosition = parseInteger(value) self.split = True elif attribute == "splitSeparated": splitSeparated = parseBoolean("splitSeparated", value) self.split = True elif attribute == "splitTrim": self.splitTrim = parseBoolean("splitTrim", value) elif attribute == "scrollbarBorderWidth": sliderBorderWidth = parseInteger( value, eListbox.DefaultScrollBarBorderWidth) elif attribute == "scrollbarMode": sliderMode = parseScrollbarMode(value) elif attribute == "scrollbarScroll": sliderScroll = parseScrollbarScroll(value) elif attribute == "scrollbarOffset": sliderOffset = parseInteger( value, eListbox.DefaultScrollBarOffset) elif attribute == "scrollbarWidth": sliderWidth = parseInteger( value, eListbox.DefaultScrollBarWidth) else: leftLabelAttributes.append((attribute, value)) rightLabelAttributes.append((attribute, value)) if self.split: for attribute, value in leftLabelAttributes[:]: if attribute == "noWrap": # Remove "noWrap" attribute so it can be set later. leftLabelAttributes.remove((attribute, value)) break for attribute, value in rightLabelAttributes[:]: if attribute == "noWrap": # Remove "noWrap" attribute so it can be set later. rightLabelAttributes.remove((attribute, value)) break if not splitSeparated: leftAlign = "left" # If columns are used and not separated then left column needs to be "left" aligned to avoid overlapping text. leftLabelAttributes.extend([ ("horizontalAlignment", leftAlign), ("noWrap", "1") ]) # Set "noWrap" to keep lines synchronized. rightLabelAttributes.extend([ ("horizontalAlignment", rightAlign), ("noWrap", "1") ]) # Set "noWrap" to keep lines synchronized. applyAllAttributes(self.instance, desktop, widgetAttributes, parent.scale) applyAllAttributes(self.leftText, desktop, leftLabelAttributes, parent.scale) applyAllAttributes(self.rightText, desktop, rightLabelAttributes, parent.scale) applyAllAttributes(self.slider, desktop, sliderAttributes, parent.scale) retVal = True else: retVal = False lineHeight = int( fontRenderClass.getInstance().getLineHeight( self.leftText.getFont()) or 25) # Assume a random line height if nothing is visible. self.pageWidth = self.leftText.size().width() self.pageHeight = (self.leftText.size().height() // lineHeight) * lineHeight self.instance.move(self.leftText.position()) self.instance.resize(eSize(self.pageWidth, self.pageHeight)) self.sliderWidth = sliderOffset + sliderWidth if self.split and sliderMode != eListbox.showNever: # Check that there is space for the scrollbar in the split. if abs(splitPosition) < self.sliderWidth: splitPosition = None elif abs(self.pageWidth - splitPosition) < self.sliderWidth: splitPosition = None splitPosition = self.pageWidth // 2 if splitPosition is None else splitPosition self.leftWidth = (splitPosition - splitMargin) if splitSeparated else self.pageWidth self.rightColX = splitPosition + splitMargin self.rightWidth = self.pageWidth - splitPosition - splitMargin self.splitSeparated = splitSeparated self.leftText.move(ePoint(0, 0)) self.rightText.move(ePoint(self.rightColX, 0)) self.slider.move( ePoint( 0 if sliderMode in (eListbox.showLeftOnDemand, eListbox.showLeftAlways) else (self.pageWidth - sliderWidth), 0)) self.slider.resize(eSize(sliderWidth, self.pageHeight)) self.slider.setOrientation(eSlider.orVertical) self.slider.setRange(0, 1000) self.slider.setBorderWidth(sliderBorderWidth) self.sliderMode = sliderMode self.sliderScroll = lineHeight if sliderScroll else self.pageHeight self.setText(self.msgText) return retVal
def applySkin(self, desktop, screen): def retValue(val, limit, default, Min=False): try: if Min: x = min(limit, int(val)) else: x = max(limit, int(val)) except: x = default return x def setWrapFlag(attrib, value): if (attrib.lower() == "wrap" and value == "0") or \ (attrib.lower() == "nowrap" and value != "0"): self.txtflags &= ~RT_WRAP else: self.txtflags |= RT_WRAP self.halign = valign = eLabel.alignLeft if self.skinAttributes: attribs = [ ] for (attrib, value) in self.skinAttributes: if attrib == "font": self.txfont = parseFont(value, ((1,1),(1,1))) elif attrib == "foregroundColor": self.scroll_label.setForegroundColor(parseColor(value)) elif attrib in ("shadowColor","borderColor"): # fake for openpli-enigma2 self.scroll_label.setShadowColor(parseColor(value)) elif attrib == "shadowOffset": x, y = value.split(',') self.soffset = (int(x),int(y)) self.scroll_label.setShadowOffset(ePoint(self.soffset)) elif attrib == "borderWidth": # fake for openpli-enigma2 self.soffset = (-int(value),-int(value)) elif attrib == "valign" and value in ("top","center","bottom"): valign = { "top": eLabel.alignTop, "center": eLabel.alignCenter, "bottom": eLabel.alignBottom }[value] self.txtflags |= { "top": RT_VALIGN_TOP, "center": RT_VALIGN_CENTER, "bottom": RT_VALIGN_BOTTOM }[value] elif attrib == "halign" and value in ("left","center","right","block"): self.halign = { "left": eLabel.alignLeft, "center": eLabel.alignCenter, "right": eLabel.alignRight, "block": eLabel.alignBlock }[value] self.txtflags |= { "left": RT_HALIGN_LEFT, "center": RT_HALIGN_CENTER, "right": RT_HALIGN_RIGHT, "block": RT_HALIGN_BLOCK }[value] elif attrib == "noWrap": setWrapFlag(attrib, value) elif attrib == "options": options = value.split(',') for o in options: if o.find('=') != -1: opt, val = (x.strip() for x in o.split('=', 1)) else: opt, val = o.strip(), "" if opt == "": continue elif opt in ("wrap", "nowrap"): setWrapFlag(opt, val) elif opt == "movetype" and val in ("none","running","swimming"): self.type = {"none": NONE, "running": RUNNING, "swimming": SWIMMING}[val] elif opt =="direction" and val in ("left","right","top","bottom"): self.direction = { "left": LEFT, "right": RIGHT, "top": TOP, "bottom": BOTTOM }[val] elif opt == "step" and val: self.mStep = retValue(val, 1, self.mStep) elif opt == "steptime" and val: self.mStepTimeout = retValue(val, 25, self.mStepTimeout) elif opt == "startdelay" and val: self.mStartDelay = retValue(val, 0, self.mStartDelay) elif opt == "pause" and val: self.mLoopTimeout = retValue(val, 0, self.mLoopTimeout) elif opt == "oneshot" and val: self.mOneShot = retValue(val, 0, self.mOneShot) elif opt =="repeat" and val: self.mRepeat = retValue(val, 0, self.mRepeat) elif opt =="always" and val: self.mAlways = retValue(val, 0, self.mAlways) elif opt =="startpoint" and val: self.mStartPoint = int(val) elif opt == "pagedelay" and val: self.mPageDelay = retValue(val, 0, self.mPageDelay) elif opt == "pagelength" and val: self.mPageLength = retValue(val, 0, self.mPageLength) else: attribs.append((attrib,value)) if attrib == "backgroundColor": self.scroll_label.setBackgroundColor(parseColor(value)) elif attrib == "transparent": self.scroll_label.setTransparent(int(value)) self.skinAttributes = attribs ret = Renderer.applySkin(self, desktop, screen) if self.mOneShot: self.mOneShot = max(self.mStepTimeout, self.mOneShot) if self.mLoopTimeout: self.mLoopTimeout = max(self.mStepTimeout, self.mLoopTimeout) if self.mPageDelay: self.mPageDelay = max(self.mStepTimeout, self.mPageDelay) self.scroll_label.setFont(self.txfont) if not (self.txtflags & RT_WRAP): self.scroll_label.setNoWrap(1) self.scroll_label.setVAlign(valign) self.scroll_label.setHAlign(self.halign) self.scroll_label.move( ePoint(0,0) ) self.scroll_label.resize( eSize(self.W,self.H) ) # test for auto correction text height: if self.direction in (TOP,BOTTOM): from enigma import fontRenderClass flh = int(fontRenderClass.getInstance().getLineHeight(self.txfont) or self.txfont.pointSize/6 + self.txfont.pointSize) self.scroll_label.setText("WQq") if flh > self.scroll_label.calculateSize().height(): self.lineHeight = flh self.scroll_label.setText("") return ret
def applySkin(self, desktop, screen): def retValue(val, limit, default, Min=False): try: if Min: x = min(limit, int(val)) else: x = max(limit, int(val)) except: x = default return x def setWrapFlag(attrib, value): if (attrib.lower() == "wrap" and value == "0") or \ (attrib.lower() == "nowrap" and value != "0"): self.txtflags &= ~RT_WRAP else: self.txtflags |= RT_WRAP self.halign = valign = eLabel.alignLeft if self.skinAttributes: attribs = [ ] for (attrib, value) in self.skinAttributes: if attrib == "font": self.txfont = parseFont(value, ((1,1),(1,1))) elif attrib == "foregroundColor": self.scroll_label.setForegroundColor(parseColor(value)) elif attrib in ("shadowColor","borderColor"): # fake for openpli-enigma2 self.scroll_label.setShadowColor(parseColor(value)) elif attrib == "shadowOffset": x, y = value.split(',') self.soffset = (int(x),int(y)) self.scroll_label.setShadowOffset(ePoint(self.soffset)) elif attrib == "borderWidth": # fake for openpli-enigma2 self.soffset = (-int(value),-int(value)) elif attrib == "valign" and value in ("top","center","bottom"): valign = { "top": eLabel.alignTop, "center": eLabel.alignCenter, "bottom": eLabel.alignBottom }[value] self.txtflags |= { "top": RT_VALIGN_TOP, "center": RT_VALIGN_CENTER, "bottom": RT_VALIGN_BOTTOM }[value] elif attrib == "halign" and value in ("left","center","right","block"): self.halign = { "left": eLabel.alignLeft, "center": eLabel.alignCenter, "right": eLabel.alignRight, "block": eLabel.alignBlock }[value] self.txtflags |= { "left": RT_HALIGN_LEFT, "center": RT_HALIGN_CENTER, "right": RT_HALIGN_RIGHT, "block": RT_HALIGN_BLOCK }[value] elif attrib == "noWrap": setWrapFlag(attrib, value) elif attrib == "options": options = value.split(',') for o in options: if '=' in o: opt, val = (x.strip() for x in o.split('=', 1)) else: opt, val = o.strip(), "" if opt == "": continue elif opt in ("wrap", "nowrap"): setWrapFlag(opt, val) elif opt == "movetype" and val in ("none","running","swimming"): self.type = {"none": NONE, "running": RUNNING, "swimming": SWIMMING}[val] elif opt =="direction" and val in ("left","right","top","bottom"): self.direction = { "left": LEFT, "right": RIGHT, "top": TOP, "bottom": BOTTOM }[val] elif opt == "step" and val: self.mStep = retValue(val, 1, self.mStep) elif opt == "steptime" and val: self.mStepTimeout = retValue(val, 25, self.mStepTimeout) elif opt == "startdelay" and val: self.mStartDelay = retValue(val, 0, self.mStartDelay) elif opt == "pause" and val: self.mLoopTimeout = retValue(val, 0, self.mLoopTimeout) elif opt == "oneshot" and val: self.mOneShot = retValue(val, 0, self.mOneShot) elif opt =="repeat" and val: self.mRepeat = retValue(val, 0, self.mRepeat) elif opt =="always" and val: self.mAlways = retValue(val, 0, self.mAlways) elif opt =="startpoint" and val: self.mStartPoint = int(val) elif opt == "pagedelay" and val: self.mPageDelay = retValue(val, 0, self.mPageDelay) elif opt == "pagelength" and val: self.mPageLength = retValue(val, 0, self.mPageLength) else: attribs.append((attrib,value)) if attrib == "backgroundColor": self.scroll_label.setBackgroundColor(parseColor(value)) elif attrib == "transparent": self.scroll_label.setTransparent(int(value)) self.skinAttributes = attribs ret = Renderer.applySkin(self, desktop, screen) if self.mOneShot: self.mOneShot = max(self.mStepTimeout, self.mOneShot) if self.mLoopTimeout: self.mLoopTimeout = max(self.mStepTimeout, self.mLoopTimeout) if self.mPageDelay: self.mPageDelay = max(self.mStepTimeout, self.mPageDelay) self.scroll_label.setFont(self.txfont) if not (self.txtflags & RT_WRAP): self.scroll_label.setNoWrap(1) self.scroll_label.setVAlign(valign) self.scroll_label.setHAlign(self.halign) self.scroll_label.move( ePoint(0,0) ) self.scroll_label.resize( eSize(self.W,self.H) ) # test for auto correction text height: if self.direction in (TOP,BOTTOM): from enigma import fontRenderClass flh = int(fontRenderClass.getInstance().getLineHeight(self.txfont) or self.txfont.pointSize/6 + self.txfont.pointSize) self.scroll_label.setText("WQq") if flh > self.scroll_label.calculateSize().height(): self.lineHeight = flh self.scroll_label.setText("") return ret
def applySkin(self, desktop, parent): scrollbarWidth = 20 scrollbarBorderWidth = 1 ret = False if self.skinAttributes is not None: scrollbar_attribs = [] widget_attribs = [] remove_attribs = [] for (attrib, value) in self.skinAttributes: if attrib.find("borderColor") != -1 or attrib.find( "borderWidth") != -1: scrollbar_attribs.append((attrib, value)) if attrib.find("transparent") != -1 or attrib.find( "backgroundColor") != -1: widget_attribs.append((attrib, value)) if attrib.find("scrollbarSliderForegroundColor") != -1: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderBorderColor") != -1: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderPicture") != -1: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarBackgroundPicture") != -1: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if attrib.find("scrollbarWidth") != -1: scrollbarWidth = int(value) remove_attribs.append((attrib, value)) if attrib.find("scrollbarSliderBorderWidth") != -1: scrollbarBorderWidth = int(value) remove_attribs.append((attrib, value)) for (attrib, value) in remove_attribs: self.skinAttributes.remove((attrib, value)) skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont()) if not lineheight: lineheight = 30 # assume a random lineheight if nothing is visible lines = (int)(s.height() / lineheight) self.pageHeight = (int)(lines * lineheight) self.instance.resize( eSize(s.width(), self.pageHeight + (int)(lineheight / 6))) self.scrollbar.move(ePoint(s.width() - scrollbarWidth, 0)) self.scrollbar.resize( eSize(scrollbarWidth, self.pageHeight + (int)(lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.long_text.move(ePoint(0, 0)) self.long_text.resize(eSize(s.width() - 30, self.pageHeight * 16)) self.setText(self.message) return ret
def applySkin(self, desktop, parent): scrollbarWidth = 10 itemHeight = 30 scrollbarBorderWidth = 1 ret = False if self.skinAttributes: widget_attribs = [] scrollbar_attribs = [] remove_attribs = [] for attrib, value in self.skinAttributes: if 'itemHeight' in attrib: itemHeight = int(value) remove_attribs.append((attrib, value)) if 'scrollbarMode' in attrib: self.scrollbarmode = value remove_attribs.append((attrib, value)) if 'borderColor' in attrib or 'borderWidth' in attrib: scrollbar_attribs.append((attrib, value)) if 'transparent' in attrib or 'backgroundColor' in attrib: widget_attribs.append((attrib, value)) if 'scrollbarSliderForegroundColor' in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if 'scrollbarSliderBorderColor' in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if 'scrollbarSliderPicture' in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if 'scrollbarBackgroundPicture' in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if 'scrollbarWidth' in attrib: scrollbarWidth = int(value) remove_attribs.append((attrib, value)) if 'scrollbarSliderBorderWidth' in attrib: scrollbarBorderWidth = int(value) remove_attribs.append((attrib, value)) if 'split' in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) self.skinAttributes.remove((attrib, value)) if 'colposition' in attrib: self.column = int(value) if 'dividechar' in attrib: self.splitchar = value for attrib, value in remove_attribs: self.skinAttributes.remove((attrib, value)) if self.split: skin.applyAllAttributes( self.long_text, desktop, self.skinAttributes + [('halign', 'left')], parent.scale) skin.applyAllAttributes( self.right_text, desktop, self.skinAttributes + [('transparent', '1'), ('halign', 'left' if self.column else 'right')], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True self.pageWidth = self.long_text.size().width() self.lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont()) or itemHeight lines = int(self.long_text.size().height() / self.lineheight) self.pageHeight = int(lines * self.lineheight) self.instance.move(self.long_text.position()) self.instance.resize( eSize(self.pageWidth, self.pageHeight + int(self.lineheight / 6))) self.scrollbar.move(ePoint(self.pageWidth - scrollbarWidth, 0)) self.scrollbar.resize( eSize(scrollbarWidth, self.pageHeight + int(self.lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.setText(self.message) return ret
def applySkin(self, desktop, screen): def retValue(val, limit, default, Min = False): try: if Min: x = min(limit, int(val)) else: x = max(limit, int(val)) except: x = default return x def setWrapFlag(attrib, value): if attrib.lower() == 'wrap' and value == '0' or attrib.lower() == 'nowrap' and value != '0': self.txtflags &= ~RT_WRAP else: self.txtflags |= RT_WRAP self.halign = valign = eLabel.alignLeft if self.skinAttributes: attribs = [] for attrib, value in self.skinAttributes: if attrib == 'font': self.txfont = parseFont(value, ((1, 1), (1, 1))) elif attrib == 'foregroundColor': self.scroll_label.setForegroundColor(parseColor(value)) elif attrib in ('shadowColor', 'borderColor'): self.scroll_label.setShadowColor(parseColor(value)) elif attrib == 'shadowOffset': x, y = value.split(',') self.soffset = (int(x), int(y)) self.scroll_label.setShadowOffset(ePoint(self.soffset)) elif attrib == 'borderWidth': self.soffset = (-int(value), -int(value)) elif attrib == 'valign' and value in ('top', 'center', 'bottom'): valign = {'top': eLabel.alignTop, 'center': eLabel.alignCenter, 'bottom': eLabel.alignBottom}[value] self.txtflags |= {'top': RT_VALIGN_TOP, 'center': RT_VALIGN_CENTER, 'bottom': RT_VALIGN_BOTTOM}[value] elif attrib == 'halign' and value in ('left', 'center', 'right', 'block'): self.halign = {'left': eLabel.alignLeft, 'center': eLabel.alignCenter, 'right': eLabel.alignRight, 'block': eLabel.alignBlock}[value] self.txtflags |= {'left': RT_HALIGN_LEFT, 'center': RT_HALIGN_CENTER, 'right': RT_HALIGN_RIGHT, 'block': RT_HALIGN_BLOCK}[value] elif attrib == 'noWrap': setWrapFlag(attrib, value) elif attrib == 'options': options = value.split(',') for o in options: if '=' in o: opt, val = (x.strip() for x in o.split('=', 1)) else: opt, val = o.strip(), '' if opt == '': continue elif opt in ('wrap', 'nowrap'): setWrapFlag(opt, val) elif opt == 'movetype' and val in ('none', 'running', 'swimming'): self.type = {'none': NONE, 'running': RUNNING, 'swimming': SWIMMING}[val] elif opt == 'direction' and val in ('left', 'right', 'top', 'bottom'): self.direction = {'left': LEFT, 'right': RIGHT, 'top': TOP, 'bottom': BOTTOM}[val] elif opt == 'step' and val: self.mStep = retValue(val, 1, self.mStep) elif opt == 'steptime' and val: self.mStepTimeout = retValue(val, 25, self.mStepTimeout) elif opt == 'startdelay' and val: self.mStartDelay = retValue(val, 0, self.mStartDelay) elif opt == 'pause' and val: self.mLoopTimeout = retValue(val, 0, self.mLoopTimeout) elif opt == 'oneshot' and val: self.mOneShot = retValue(val, 0, self.mOneShot) elif opt == 'repeat' and val: self.mRepeat = retValue(val, 0, self.mRepeat) elif opt == 'always' and val: self.mAlways = retValue(val, 0, self.mAlways) elif opt == 'startpoint' and val: self.mStartPoint = int(val) elif opt == 'pagedelay' and val: self.mPageDelay = retValue(val, 0, self.mPageDelay) elif opt == 'pagelength' and val: self.mPageLength = retValue(val, 0, self.mPageLength) else: attribs.append((attrib, value)) if attrib == 'backgroundColor': self.scroll_label.setBackgroundColor(parseColor(value)) elif attrib == 'transparent': self.scroll_label.setTransparent(int(value)) self.skinAttributes = attribs ret = Renderer.applySkin(self, desktop, screen) if self.mOneShot: self.mOneShot = max(self.mStepTimeout, self.mOneShot) if self.mLoopTimeout: self.mLoopTimeout = max(self.mStepTimeout, self.mLoopTimeout) if self.mPageDelay: self.mPageDelay = max(self.mStepTimeout, self.mPageDelay) self.scroll_label.setFont(self.txfont) if not self.txtflags & RT_WRAP: self.scroll_label.setNoWrap(1) self.scroll_label.setVAlign(valign) self.scroll_label.setHAlign(self.halign) self.scroll_label.move(ePoint(0, 0)) self.scroll_label.resize(eSize(self.W, self.H)) if self.direction in (TOP, BOTTOM): from enigma import fontRenderClass flh = int(fontRenderClass.getInstance().getLineHeight(self.txfont) or self.txfont.pointSize / 6 + self.txfont.pointSize) self.scroll_label.setText('WQq') if flh > self.scroll_label.calculateSize().height(): self.lineHeight = flh self.scroll_label.setText('') return ret
def applySkin(self, desktop, screen): def retValue(val, limit, default, Min=False): try: if Min: x = min(limit, int(val)) else: x = max(limit, int(val)) except: x = default return x def setWrapFlag(attrib, value): if attrib.lower() == 'wrap' and value == '0' or attrib.lower( ) == 'nowrap' and value != '0': self.txtflags &= ~RT_WRAP else: self.txtflags |= RT_WRAP self.halign = valign = eLabel.alignLeft if self.skinAttributes: attribs = [] for attrib, value in self.skinAttributes: if attrib == 'font': self.txfont = parseFont(value, ((1, 1), (1, 1))) elif attrib == 'foregroundColor': self.scroll_label.setForegroundColor(parseColor(value)) elif attrib in ('shadowColor', 'borderColor'): self.scroll_label.setShadowColor(parseColor(value)) elif attrib == 'shadowOffset': x, y = value.split(',') self.soffset = (int(x), int(y)) self.scroll_label.setShadowOffset(ePoint(self.soffset)) elif attrib == 'borderWidth': self.soffset = (-int(value), -int(value)) elif attrib == 'valign' and value in ('top', 'center', 'bottom'): valign = { 'top': eLabel.alignTop, 'center': eLabel.alignCenter, 'bottom': eLabel.alignBottom }[value] self.txtflags |= { 'top': RT_VALIGN_TOP, 'center': RT_VALIGN_CENTER, 'bottom': RT_VALIGN_BOTTOM }[value] elif attrib == 'halign' and value in ('left', 'center', 'right', 'block'): self.halign = { 'left': eLabel.alignLeft, 'center': eLabel.alignCenter, 'right': eLabel.alignRight, 'block': eLabel.alignBlock }[value] self.txtflags |= { 'left': RT_HALIGN_LEFT, 'center': RT_HALIGN_CENTER, 'right': RT_HALIGN_RIGHT, 'block': RT_HALIGN_BLOCK }[value] elif attrib == 'noWrap': setWrapFlag(attrib, value) elif attrib == 'options': options = value.split(',') for o in options: if o.find('=') != -1: opt, val = (x.strip() for x in o.split('=', 1)) else: opt, val = o.strip(), '' if opt == '': continue elif opt in ('wrap', 'nowrap'): setWrapFlag(opt, val) elif opt == 'movetype' and val in ('none', 'running', 'swimming'): self.type = { 'none': NONE, 'running': RUNNING, 'swimming': SWIMMING }[val] elif opt == 'direction' and val in ('left', 'right', 'top', 'bottom'): self.direction = { 'left': LEFT, 'right': RIGHT, 'top': TOP, 'bottom': BOTTOM }[val] elif opt == 'step' and val: self.mStep = retValue(val, 1, self.mStep) elif opt == 'steptime' and val: self.mStepTimeout = retValue( val, 25, self.mStepTimeout) elif opt == 'startdelay' and val: self.mStartDelay = retValue( val, 0, self.mStartDelay) elif opt == 'pause' and val: self.mLoopTimeout = retValue( val, 0, self.mLoopTimeout) elif opt == 'oneshot' and val: self.mOneShot = retValue(val, 0, self.mOneShot) elif opt == 'repeat' and val: self.mRepeat = retValue(val, 0, self.mRepeat) elif opt == 'always' and val: self.mAlways = retValue(val, 0, self.mAlways) elif opt == 'startpoint' and val: self.mStartPoint = int(val) elif opt == 'pagedelay' and val: self.mPageDelay = retValue(val, 0, self.mPageDelay) elif opt == 'pagelength' and val: self.mPageLength = retValue( val, 0, self.mPageLength) else: attribs.append((attrib, value)) if attrib == 'backgroundColor': self.scroll_label.setBackgroundColor(parseColor(value)) elif attrib == 'transparent': self.scroll_label.setTransparent(int(value)) self.skinAttributes = attribs ret = Renderer.applySkin(self, desktop, screen) if self.mOneShot: self.mOneShot = max(self.mStepTimeout, self.mOneShot) if self.mLoopTimeout: self.mLoopTimeout = max(self.mStepTimeout, self.mLoopTimeout) if self.mPageDelay: self.mPageDelay = max(self.mStepTimeout, self.mPageDelay) self.scroll_label.setFont(self.txfont) if not self.txtflags & RT_WRAP: self.scroll_label.setNoWrap(1) self.scroll_label.setVAlign(valign) self.scroll_label.setHAlign(self.halign) self.scroll_label.move(ePoint(0, 0)) self.scroll_label.resize(eSize(self.W, self.H)) if self.direction in (TOP, BOTTOM): from enigma import fontRenderClass flh = int(fontRenderClass.getInstance().getLineHeight(self.txfont) or self.txfont.pointSize / 6 + self.txfont.pointSize) self.scroll_label.setText('WQq') if flh > self.scroll_label.calculateSize().height(): self.lineHeight = flh self.scroll_label.setText('') return ret
def applySkin(self, desktop, parent): scrollbarWidth = 10 itemHeight = 30 scrollbarBorderWidth = 1 ret = False if self.skinAttributes: widget_attribs = [] scrollbar_attribs = [] remove_attribs = [] for (attrib, value) in self.skinAttributes: if "itemHeight" in attrib: itemHeight = int(value) remove_attribs.append((attrib, value)) if "scrollbarMode" in attrib: self.scrollbarmode = value remove_attribs.append((attrib, value)) if "borderColor" in attrib or "borderWidth" in attrib: scrollbar_attribs.append((attrib, value)) if "transparent" in attrib or "backgroundColor" in attrib: widget_attribs.append((attrib, value)) if "scrollbarSliderForegroundColor" in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if "scrollbarSliderBorderColor" in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if "scrollbarSliderPicture" in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if "scrollbarBackgroundPicture" in attrib: scrollbar_attribs.append((attrib, value)) remove_attribs.append((attrib, value)) if "scrollbarWidth" in attrib: scrollbarWidth = int(value) remove_attribs.append((attrib, value)) if "scrollbarSliderBorderWidth" in attrib: scrollbarBorderWidth = int(value) remove_attribs.append((attrib, value)) if "split" in attrib: self.split = int(value) if self.split: self.right_text = eLabel(self.instance) self.skinAttributes.remove((attrib, value)) if "colposition" in attrib: self.column = int(value) if "dividechar" in attrib: self.splitchar = value for (attrib, value) in remove_attribs: self.skinAttributes.remove((attrib, value)) if self.split: skin.applyAllAttributes( self.long_text, desktop, self.skinAttributes + [("halign", "left")], parent.scale) skin.applyAllAttributes( self.right_text, desktop, self.skinAttributes + [("transparent", "1"), ("halign", "left" if self.column else "right")], parent.scale) else: skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes, parent.scale) skin.applyAllAttributes(self.instance, desktop, widget_attribs, parent.scale) skin.applyAllAttributes(self.scrollbar, desktop, scrollbar_attribs + widget_attribs, parent.scale) ret = True self.pageWidth = self.long_text.size().width() self.lineheight = fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) or itemHeight # assume a random lineheight if nothing is visible lines = int(self.long_text.size().height() / self.lineheight) self.pageHeight = int(lines * self.lineheight) self.instance.move(self.long_text.position()) self.instance.resize( eSize(self.pageWidth, self.pageHeight + int(self.lineheight / 6))) self.scrollbar.move(ePoint(self.pageWidth - scrollbarWidth, 0)) self.scrollbar.resize( eSize(scrollbarWidth, self.pageHeight + int(self.lineheight / 6))) self.scrollbar.setOrientation(eSlider.orVertical) self.scrollbar.setRange(0, 100) self.scrollbar.setBorderWidth(scrollbarBorderWidth) self.setText(self.message) return ret