2 from HTMLComponent import *
3 from GUIComponent import *
4 from enigma import eLabel, eWidget, eSlider, fontRenderClass, ePoint, eSize
6 class ScrollLabel(HTMLComponent, GUIComponent):
7 def __init__(self, text=""):
15 def applySkin(self, desktop):
16 skin.applyAllAttributes(self.long_text, desktop, self.skinAttributes)
17 s = self.long_text.size()
18 self.instance.move(self.long_text.position())
19 lineheight=fontRenderClass.getInstance().getLineHeight( self.long_text.getFont() )
20 lines = (int)(s.height() / lineheight)
21 self.pageHeight = (int)(lines * lineheight)
22 self.instance.resize(eSize(s.width(), self.pageHeight+(int)(lineheight/6)))
23 self.scrollbar.move(ePoint(s.width()-20,0))
24 self.scrollbar.resize(eSize(20,self.pageHeight+(int)(lineheight/6)))
25 self.scrollbar.setOrientation(eSlider.orVertical);
26 self.scrollbar.setRange(0,100)
27 self.scrollbar.setBorderWidth(1)
28 self.long_text.move(ePoint(0,0))
29 self.long_text.resize(eSize(s.width()-30, self.pageHeight*16))
30 self.setText(self.message)
32 def setText(self, text):
34 if self.long_text is not None:
35 self.long_text.move(ePoint(0,0))
36 self.long_text.setText(self.message)
37 text_height=self.long_text.calculateSize().height()
40 while total < text_height:
41 total=total+self.pageHeight
47 self.updateScrollbar()
53 def updateScrollbar(self):
54 start = -self.long_text.position().y() * 100 / self.total
55 vis = self.pageHeight * 100 / self.total;
56 self.scrollbar.setStartEnd(start, start+vis)
61 def GUIcreate(self, parent):
62 self.instance = eWidget(parent)
63 self.scrollbar = eSlider(self.instance)
64 self.long_text = eLabel(self.instance)
72 if self.total is not None:
73 curPos = self.long_text.position()
75 self.long_text.move( ePoint( curPos.x(), curPos.y() + self.pageHeight ) )
76 self.updateScrollbar()
79 if self.total is not None:
80 curPos = self.long_text.position()
81 if self.total-self.pageHeight >= abs( curPos.y() - self.pageHeight ):
82 self.long_text.move( ePoint( curPos.x(), curPos.y() - self.pageHeight ) )
83 self.updateScrollbar()
85 def produceHTML(self):