comparison browser_side/panels.py @ 23:0ce2a57b34ca

added tab panel
author Goffi <goffi@goffi.org>
date Wed, 20 Apr 2011 02:47:22 +0200
parents 586f69e85559
children d89982865c57
comparison
equal deleted inserted replaced
22:586f69e85559 23:0ce2a57b34ca
22 import pyjd # this is dummy in pyjs 22 import pyjd # this is dummy in pyjs
23 from pyjamas.ui.SimplePanel import SimplePanel 23 from pyjamas.ui.SimplePanel import SimplePanel
24 from pyjamas.ui.VerticalPanel import VerticalPanel 24 from pyjamas.ui.VerticalPanel import VerticalPanel
25 from pyjamas.ui.HorizontalPanel import HorizontalPanel 25 from pyjamas.ui.HorizontalPanel import HorizontalPanel
26 from pyjamas.ui.ScrollPanel import ScrollPanel 26 from pyjamas.ui.ScrollPanel import ScrollPanel
27 from pyjamas.ui.TabPanel import TabPanel
27 from pyjamas.ui.HTMLPanel import HTMLPanel 28 from pyjamas.ui.HTMLPanel import HTMLPanel
28 from pyjamas.ui.Grid import Grid 29 from pyjamas.ui.Grid import Grid
29 from pyjamas.ui.MenuBar import MenuBar 30 from pyjamas.ui.MenuBar import MenuBar
30 from pyjamas.ui.MenuItem import MenuItem 31 from pyjamas.ui.MenuItem import MenuItem
31 from pyjamas.ui.Label import Label 32 from pyjamas.ui.Label import Label
51 handler = getattr(self._object, self._handler) 52 handler = getattr(self._object, self._handler)
52 handler() 53 handler()
53 54
54 class Menu(SimplePanel): 55 class Menu(SimplePanel):
55 56
56 def __init__(self): 57 def __init__(self, host):
58 self.host = host
57 SimplePanel.__init__(self) 59 SimplePanel.__init__(self)
58 60
59 menu_general = MenuBar(vertical=True) 61 menu_general = MenuBar(vertical=True)
60 menu_general.addItem("Properties", MenuCmd(self, "onProperties")) 62 menu_general.addItem("Properties", MenuCmd(self, "onProperties"))
61 63
70 72
71 def onProperties(self): 73 def onProperties(self):
72 Window.alert("Properties selected") 74 Window.alert("Properties selected")
73 75
74 def onTarotGame(self): 76 def onTarotGame(self):
75 Window.alert("Tarot selected") 77 #Window.alert("Tarot selected")
78 self.host.tab_panel.add(EmptyPanel(self.host), "Tarot")
76 79
77 def onXiangqiGame(self): 80 def onXiangqiGame(self):
78 Window.alert("Xiangqi selected") 81 Window.alert("Xiangqi selected")
79 82
80 class DropCell(DropWidget): 83 class DropCell(DropWidget):
296 """if msg.startswith('/me '): 299 """if msg.startswith('/me '):
297 self.printInfo('* %s %s' % (nick, msg[4:]),type='me') 300 self.printInfo('* %s %s' % (nick, msg[4:]),type='me')
298 return""" 301 return"""
299 self.content.add(ChatText(timestamp, nick, mymess, msg)) 302 self.content.add(ChatText(timestamp, nick, mymess, msg))
300 303
301 class MiddlePannel(HorizontalPanel): 304 class MainDiscussionPannel(HorizontalPanel):
302 305
303 def __init__(self, host): 306 def __init__(self, host):
304 self.host=host 307 self.host=host
305 HorizontalPanel.__init__(self) 308 HorizontalPanel.__init__(self)
306 self._left = self.host.contactPanel 309 self._left = self.host.contactPanel
314 self.setHeight('100%') 317 self.setHeight('100%')
315 318
316 def changePanel(self, idx, panel): 319 def changePanel(self, idx, panel):
317 self._right.setWidget(0,idx,panel) 320 self._right.setWidget(0,idx,panel)
318 321
322 class MainTabPannel(TabPanel):
323
324 def __init__(self, host):
325 self.host=host
326 TabPanel.__init__(self)
327 self.tabBar.setVisible(False)
328
329 def add(self, widget, tabText=None, asHTML=False):
330 TabPanel.add(self, widget, tabText, asHTML)
331 if self.getWidgetCount()>1:
332 self.tabBar.setVisible(True)
333
319 class MainPanel(VerticalPanel): 334 class MainPanel(VerticalPanel):
320 335
321 def __init__(self, host): 336 def __init__(self, host):
322 self.host=host 337 self.host=host
323 VerticalPanel.__init__(self) 338 VerticalPanel.__init__(self)
324 339
325 self.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) 340 self.setHorizontalAlignment(HasAlignment.ALIGN_LEFT)
326 self.setVerticalAlignment(HasAlignment.ALIGN_TOP) 341 self.setVerticalAlignment(HasAlignment.ALIGN_TOP)
327 342
328 menu = Menu() 343 menu = Menu(host)
329 uni_box = host.uniBox 344 uni_box = host.uniBox
330 status = host.statusPanel 345 status = host.statusPanel
331 self.middle_panel = MiddlePannel(self.host) 346 self.tab_panel = MainTabPannel(self)
332 self.middle_panel.setWidth('100%') 347 self.tab_panel.setWidth('100%')
348 self.tab_panel.setHeight('100%')
349 self.discuss_panel = MainDiscussionPannel(self.host)
350 self.discuss_panel.setWidth('100%')
351 self.discuss_panel.setHeight('100%')
352 self.tab_panel.add(self.discuss_panel, "Discussions")
353 self.tab_panel.selectTab(0)
333 354
334 self.add(menu) 355 self.add(menu)
335 self.add(uni_box) 356 self.add(uni_box)
336 self.add(status) 357 self.add(status)
337 self.add(self.middle_panel) 358 self.add(self.tab_panel)
338 359
339 self.setCellHeight(menu, "5%") 360 self.setCellHeight(menu, "5%")
340 self.setCellHeight(uni_box, "5%") 361 self.setCellHeight(uni_box, "5%")
341 self.setCellVerticalAlignment(uni_box, HasAlignment.ALIGN_CENTER) 362 self.setCellVerticalAlignment(uni_box, HasAlignment.ALIGN_CENTER)
342 self.setCellHorizontalAlignment(uni_box, HasAlignment.ALIGN_CENTER) 363 self.setCellHorizontalAlignment(uni_box, HasAlignment.ALIGN_CENTER)
343 self.setCellHeight(self.middle_panel, "90%") 364 self.setCellHeight(self.tab_panel, "90%")
344 self.setCellWidth(self.middle_panel, "100%") 365 self.setCellWidth(self.tab_panel, "100%")
345 366
346 self.setWidth("100%") 367 self.setWidth("100%")
347 self.setHeight("100%") 368 self.setHeight("100%")