# HG changeset patch # User Goffi # Date 1308343128 -7200 # Node ID c335675eef7cb343ae9665adcbbeebc10aa70650 # Parent 386d27dd3fbbcdc458c185d7210cc2aa69dee5e0 browser side: menu separator + last popup menu hack to avoid it being shown out of the screen diff -r 386d27dd3fbb -r c335675eef7c browser_side/panels.py --- 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)