changeset 71:c335675eef7c

browser side: menu separator + last popup menu hack to avoid it being shown out of the screen
author Goffi <goffi@goffi.org>
date Fri, 17 Jun 2011 22:38:48 +0200
parents 386d27dd3fbb
children dae64124ff24
files browser_side/panels.py
diffstat 1 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/panels.py	Fri Jun 17 22:37:54 2011 +0200
+++ b/browser_side/panels.py	Fri Jun 17 22:38:48 2011 +0200
@@ -32,6 +32,7 @@
 from pyjamas.ui.DialogBox import DialogBox
 from pyjamas.ui.AutoComplete import AutoCompleteTextBox
 from pyjamas.ui.MenuBar import MenuBar
+from pyjamas.ui.MenuBarPopupPanel import MenuBarPopupPanel
 from pyjamas.ui.MenuItem import MenuItem
 from pyjamas.ui.ListBox import ListBox
 from pyjamas.ui.Label import Label
@@ -67,11 +68,28 @@
         handler = getattr(self._object, self._handler)
         handler()
 
+class LiberviaMenuBar(MenuBar):
+
+    def __init__(self):
+        MenuBar.__init__(self, vertical=False)
+    
+    def doItemAction(self, item, fireCommand):
+        MenuBar.doItemAction(self, item, fireCommand)
+        if item == self.items[-1] and self.popup:
+            print "DEBUG"
+            print self.popup.getOffsetWidth()
+            self.popup.setPopupPosition(Window.getClientWidth() -
+               self.popup.getOffsetWidth() - 22,
+               self.getAbsoluteTop() +
+               self.getOffsetHeight() - 1)
+
+
 class Menu(SimplePanel):
 
     def __init__(self, host):
         self.host = host
         SimplePanel.__init__(self)
+        self.setStyleName('menuContainer')
 
         menu_general = MenuBar(vertical=True)
         menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract"))
@@ -89,10 +107,13 @@
         menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame"))
         menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame"))
 
-        menubar = MenuBar(vertical=False)
+        menubar = LiberviaMenuBar()
         menubar.addItem(MenuItem("General", menu_general))
         menubar.addItem(MenuItem("Contacts", menu_contacts))
         menubar.addItem(MenuItem("Groups", menu_group))
+        _separator = MenuItem('', None)
+        _separator.setStyleName('menuSeparator')
+        menubar.addItem(_separator, None)
         menubar.addItem(MenuItem("Games", True, menu_games))
         self.add(menubar)