2 from HTMLComponent import HTMLComponent
3 from GUIComponent import GUIComponent
4 from enigma import eLabel, eWidget, eSlider, fontRenderClass, ePoint, eSize
6 class ScrollLabel(HTMLComponent, GUIComponent):
7 def __init__(self, text=""):
8 GUIComponent.__init__(self)
16 def applySkin(self, desktop):
18 if self.skinAttributes is not None:
19 skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes)
21 s = self.long_text.size()
22 self.instance.move(self.long_text.position())
23 lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() )
24 lines = (int)(s.height() / lineheight)
25 self.pageHeight = (int)(lines * lineheight)
26 self.instance.resize(eSize(s.width(), self.pageHeight+(int)(lineheight/6)))
27 self.scrollbar.move(ePoint(s.width()-20,0))
28 self.scrollbar.resize(eSize(20,self.pageHeight+(int)(lineheight/6)))
29 self.scrollbar.setOrientation(eSlider.orVertical);
30 self.scrollbar.setRange(0,100)
31 self.scrollbar.setBorderWidth(1)
32 self.long_text.move(ePoint(0,0))
33 self.long_text.resize(eSize(s.width()-30, self.pageHeight*16))
34 self.setText(self.message)
37 def setText(self, text):
39 if self.long_text is not None and self.pageHeight:
40 self.long_text.move(ePoint(0,0))
41 self.long_text.setText(self.message)
42 text_height=self.long_text.calculateSize().height()
45 while total < text_height:
46 total=total+self.pageHeight
52 self.updateScrollbar()
58 def appendText(self, text):
59 old_text = self.getText()
60 if len(str(old_text)) >0:
64 if self.long_text is not None:
65 self.long_text.setText(self.message)
66 text_height=self.long_text.calculateSize().height()
69 while total < text_height:
70 total=total+self.pageHeight
76 self.updateScrollbar()
82 def updateScrollbar(self):
83 start = -self.long_text.position().y() * 100 / self.total
84 vis = self.pageHeight * 100 / self.total;
85 self.scrollbar.setStartEnd(start, start+vis)
90 def GUIcreate(self, parent):
91 self.instance = eWidget(parent)
92 self.scrollbar = eSlider(self.instance)
93 self.long_text = eLabel(self.instance)
101 if self.total is not None:
102 curPos = self.long_text.position()
104 self.long_text.move( ePoint( curPos.x(), curPos.y() + self.pageHeight ) )
105 self.updateScrollbar()
108 if self.total is not None:
109 curPos = self.long_text.position()
110 if self.total-self.pageHeight >= abs( curPos.y() - self.pageHeight ):
111 self.long_text.move( ePoint( curPos.x(), curPos.y() - self.pageHeight ) )
112 self.updateScrollbar()
116 while i < self.pages:
119 self.updateScrollbar()
121 def produceHTML(self):
122 return self.getText()