PageRenderTime 22ms CodeModel.GetById 2ms app.highlight 15ms RepoModel.GetById 2ms app.codeStats 0ms

/examples/mail/MailDetail.py

http://pyjamas.googlecode.com/
Python | 56 lines | 46 code | 10 blank | 0 comment | 2 complexity | 08c4ef4b2deb8e61a15c24f6900abe01 MD5 | raw file
 1from ui import Composite, DockPanel, HTML, ScrollPanel, VerticalPanel
 2from Logger import Logger
 3
 4class MailDetail(Composite):
 5    def __init__(self):
 6        panel = VerticalPanel()
 7        headerPanel = VerticalPanel()
 8        self.subject = HTML()
 9        self.sender = HTML()
10        self.recipient = HTML()
11        self.body = HTML()
12        self.scroller = ScrollPanel(self.body)
13
14        self.body.setWordWrap(True)
15
16        headerPanel.add(self.subject)
17        headerPanel.add(self.sender)
18        headerPanel.add(self.recipient)
19        headerPanel.setWidth("100%")
20
21        innerPanel = DockPanel()
22        innerPanel.add(headerPanel, DockPanel.NORTH)
23        innerPanel.add(self.scroller, DockPanel.CENTER)
24
25        innerPanel.setCellHeight(self.scroller, "100%")
26        panel.add(innerPanel)
27        innerPanel.setSize("100%", "100%")
28        self.scroller.setSize("100%", "100%")
29        self.initWidget(panel)
30
31        self.setStyleName("mail-Detail")
32        headerPanel.setStyleName("mail-DetailHeader")
33        innerPanel.setStyleName("mail-DetailInner")
34        self.subject.setStyleName("mail-DetailSubject")
35        self.sender.setStyleName("mail-DetailSender")
36        self.recipient.setStyleName("mail-DetailRecipient")
37        self.body.setStyleName("mail-DetailBody")
38        Logger("Mail detail", " ")
39
40    def setItem(self, item):
41        self.subject.setHTML(item.subject)
42        self.sender.setHTML("<b>From:</b>&nbsp;" + item.sender)
43        self.recipient.setHTML("<b>To:</b>&nbsp;foo@example.com")
44        self.body.setHTML(item.body)
45        
46    def adjustSize(self, windowWidth, windowHeight):
47        scrollWidth = windowWidth - self.scroller.getAbsoluteLeft() - 9
48        if (scrollWidth < 1):
49            scrollWidth = 1
50
51        scrollHeight = windowHeight - self.scroller.getAbsoluteTop() - 9
52        if (scrollHeight < 1):
53            scrollHeight = 1
54
55        self.scroller.setSize("" + scrollWidth, "" + scrollHeight)
56