Mercurial > libervia-web
comparison browser_side/panels.py @ 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 | 9d8e79ac4c9c |
children | 447dc8ac181b |
comparison
equal
deleted
inserted
replaced
70:386d27dd3fbb | 71:c335675eef7c |
---|---|
30 from pyjamas.ui.HTMLPanel import HTMLPanel | 30 from pyjamas.ui.HTMLPanel import HTMLPanel |
31 from pyjamas.ui.Grid import Grid | 31 from pyjamas.ui.Grid import Grid |
32 from pyjamas.ui.DialogBox import DialogBox | 32 from pyjamas.ui.DialogBox import DialogBox |
33 from pyjamas.ui.AutoComplete import AutoCompleteTextBox | 33 from pyjamas.ui.AutoComplete import AutoCompleteTextBox |
34 from pyjamas.ui.MenuBar import MenuBar | 34 from pyjamas.ui.MenuBar import MenuBar |
35 from pyjamas.ui.MenuBarPopupPanel import MenuBarPopupPanel | |
35 from pyjamas.ui.MenuItem import MenuItem | 36 from pyjamas.ui.MenuItem import MenuItem |
36 from pyjamas.ui.ListBox import ListBox | 37 from pyjamas.ui.ListBox import ListBox |
37 from pyjamas.ui.Label import Label | 38 from pyjamas.ui.Label import Label |
38 from pyjamas.ui.TextBox import TextBox | 39 from pyjamas.ui.TextBox import TextBox |
39 from pyjamas.ui.Button import Button | 40 from pyjamas.ui.Button import Button |
65 | 66 |
66 def execute(self): | 67 def execute(self): |
67 handler = getattr(self._object, self._handler) | 68 handler = getattr(self._object, self._handler) |
68 handler() | 69 handler() |
69 | 70 |
71 class LiberviaMenuBar(MenuBar): | |
72 | |
73 def __init__(self): | |
74 MenuBar.__init__(self, vertical=False) | |
75 | |
76 def doItemAction(self, item, fireCommand): | |
77 MenuBar.doItemAction(self, item, fireCommand) | |
78 if item == self.items[-1] and self.popup: | |
79 print "DEBUG" | |
80 print self.popup.getOffsetWidth() | |
81 self.popup.setPopupPosition(Window.getClientWidth() - | |
82 self.popup.getOffsetWidth() - 22, | |
83 self.getAbsoluteTop() + | |
84 self.getOffsetHeight() - 1) | |
85 | |
86 | |
70 class Menu(SimplePanel): | 87 class Menu(SimplePanel): |
71 | 88 |
72 def __init__(self, host): | 89 def __init__(self, host): |
73 self.host = host | 90 self.host = host |
74 SimplePanel.__init__(self) | 91 SimplePanel.__init__(self) |
92 self.setStyleName('menuContainer') | |
75 | 93 |
76 menu_general = MenuBar(vertical=True) | 94 menu_general = MenuBar(vertical=True) |
77 menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract")) | 95 menu_general.addItem("Social contract", MenuCmd(self, "onSocialContract")) |
78 menu_general.addItem("About", MenuCmd(self, "onAbout")) | 96 menu_general.addItem("About", MenuCmd(self, "onAbout")) |
79 | 97 |
87 | 105 |
88 menu_games = MenuBar(vertical=True) | 106 menu_games = MenuBar(vertical=True) |
89 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame")) | 107 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame")) |
90 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame")) | 108 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame")) |
91 | 109 |
92 menubar = MenuBar(vertical=False) | 110 menubar = LiberviaMenuBar() |
93 menubar.addItem(MenuItem("General", menu_general)) | 111 menubar.addItem(MenuItem("General", menu_general)) |
94 menubar.addItem(MenuItem("Contacts", menu_contacts)) | 112 menubar.addItem(MenuItem("Contacts", menu_contacts)) |
95 menubar.addItem(MenuItem("Groups", menu_group)) | 113 menubar.addItem(MenuItem("Groups", menu_group)) |
114 _separator = MenuItem('', None) | |
115 _separator.setStyleName('menuSeparator') | |
116 menubar.addItem(_separator, None) | |
96 menubar.addItem(MenuItem("Games", True, menu_games)) | 117 menubar.addItem(MenuItem("Games", True, menu_games)) |
97 self.add(menubar) | 118 self.add(menubar) |
98 | 119 |
99 #General menu | 120 #General menu |
100 def onSocialContract(self): | 121 def onSocialContract(self): |