PageRenderTime 373ms CodeModel.GetById 356ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/mail/Mail.py

http://pyjamas.googlecode.com/
Python | 90 lines | 50 code | 17 blank | 23 comment | 1 complexity | 33c0b92bb884da35fafb37b59103fa35 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. # import com.google.gwt.core.client.EntryPoint;
  2. # import com.google.gwt.user.client.Command;
  3. # import com.google.gwt.user.client.DeferredCommand;
  4. import Window
  5. # import com.google.gwt.user.client.WindowResizeListener;
  6. from DeferredCommand import DeferredCommand
  7. from ui import DockPanel, RootPanel, VerticalPanel
  8. from MailDetail import MailDetail
  9. from Shortcuts import Shortcuts
  10. from MailList import MailList
  11. from TopPanel import TopPanel
  12. from Logger import Logger
  13. class Mail:
  14. def get(self):
  15. return self.singleton
  16. def onModuleLoad(self):
  17. self.singleton = self
  18. topPanel = TopPanel()
  19. rightPanel = VerticalPanel()
  20. self.mailDetail = MailDetail()
  21. self.shortcuts = Shortcuts()
  22. topPanel.setWidth("100%")
  23. # MailList uses Mail.get() in its constructor, so initialize it after
  24. # 'singleton'.
  25. mailList = MailList(self.singleton)
  26. mailList.setWidth("100%")
  27. # Create the right panel, containing the email list & details.
  28. rightPanel.add(mailList)
  29. rightPanel.add(self.mailDetail)
  30. mailList.setWidth("100%")
  31. self.mailDetail.setWidth("100%")
  32. # Create a dock panel that will contain the menu bar at the top,
  33. # the shortcuts to the left, and the mail list & details taking the rest.
  34. outer = DockPanel()
  35. outer.add(topPanel, DockPanel.NORTH)
  36. outer.add(self.shortcuts, DockPanel.WEST)
  37. outer.add(rightPanel, DockPanel.CENTER)
  38. outer.setWidth("100%")
  39. outer.setSpacing(4)
  40. outer.setCellWidth(rightPanel, "100%")
  41. # Hook the window resize event, so that we can adjust the UI.
  42. #FIXME need implementation # Window.addWindowResizeListener(this)
  43. #Window.addWindowResizeListener(self)
  44. # Get rid of scrollbars, and clear out the window's built-in margin,
  45. # because we want to take advantage of the entire client area.
  46. Window.enableScrolling(False)
  47. Window.setMargin("0px")
  48. # Finally, add the outer panel to the RootPanel, so that it will be
  49. # displayed.
  50. #RootPanel.get().add(outer) # FIXME get#
  51. RootPanel().add(outer)
  52. RootPanel().add(Logger())
  53. # Call the window resized handler to get the initial sizes setup. Doing
  54. # this in a deferred command causes it to occur after all widgets' sizes
  55. # have been computed by the browser.
  56. DeferredCommand().add(self)
  57. def execute(self):
  58. self.onWindowResized(Window.getClientWidth(), Window.getClientHeight())
  59. def onWindowResized(self, width, height):
  60. # Adjust the shortcut panel and detail area to take up the available room
  61. # in the window.
  62. #Logger("Window resized", "width: " + width+ ", height: " + height)
  63. shortcutHeight = height - self.shortcuts.getAbsoluteTop() - 8
  64. if (shortcutHeight < 1):
  65. shortcutHeight = 1
  66. self.shortcuts.setHeight("" + shortcutHeight)
  67. # Give the mail detail widget a chance to resize itself as well.
  68. self.mailDetail.adjustSize(width, height)
  69. def displayItem(self, item):
  70. self.mailDetail.setItem(item)