X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/4374783e912d1a9385a41d7649d33f19e8eb96b3..994845aaa96600b2834471fa5593b8e1419e2d3d:/lib/python/Components/ScrollLabel.py diff --git a/lib/python/Components/ScrollLabel.py b/lib/python/Components/ScrollLabel.py index 62f64b1d..d5924b88 100644 --- a/lib/python/Components/ScrollLabel.py +++ b/lib/python/Components/ScrollLabel.py @@ -1,10 +1,11 @@ import skin -from HTMLComponent import * -from GUIComponent import * +from HTMLComponent import HTMLComponent +from GUIComponent import GUIComponent from enigma import eLabel, eWidget, eSlider, fontRenderClass, ePoint, eSize class ScrollLabel(HTMLComponent, GUIComponent): def __init__(self, text=""): + GUIComponent.__init__(self) self.message = text self.instance = None self.long_text = None @@ -13,7 +14,10 @@ class ScrollLabel(HTMLComponent, GUIComponent): self.total = None def applySkin(self, desktop): - skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes) + ret = False + if self.skinAttributes is not None: + skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes) + ret = True s = self.long_text.size() self.instance.move(self.long_text.position()) lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() ) @@ -28,10 +32,11 @@ class ScrollLabel(HTMLComponent, GUIComponent): 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 setText(self, text): self.message = text - if self.long_text is not None: + if self.long_text is not None and self.pageHeight: self.long_text.move(ePoint(0,0)) self.long_text.setText(self.message) text_height=self.long_text.calculateSize().height() @@ -50,6 +55,30 @@ class ScrollLabel(HTMLComponent, GUIComponent): self.total = None self.pages = None + def appendText(self, text): + old_text = self.getText() + if len(str(old_text)) >0: + self.message += text + else: + self.message = text + if self.long_text is not None: + self.long_text.setText(self.message) + text_height=self.long_text.calculateSize().height() + total=self.pageHeight + pages=1 + while total < text_height: + total=total+self.pageHeight + pages=pages+1 + if pages > 1: + self.scrollbar.show() + self.total = total + self.pages = pages + self.updateScrollbar() + else: + self.scrollbar.hide() + self.total = None + self.pages = None + def updateScrollbar(self): start = -self.long_text.position().y() * 100 / self.total vis = self.pageHeight * 100 / self.total; @@ -82,5 +111,12 @@ class ScrollLabel(HTMLComponent, GUIComponent): self.long_text.move( ePoint( curPos.x(), curPos.y() - self.pageHeight ) ) self.updateScrollbar() + def lastPage(self): + i=1 + while i < self.pages: + self.pageDown() + i += 1 + self.updateScrollbar() + def produceHTML(self): return self.getText()