Mercurial > libervia-web
comparison browser_side/panels.py @ 264:2a93f8e6f989
browser_side: added class ToggleStackPanel
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 17 Nov 2013 17:41:54 +0100 |
parents | 3df0c3634c29 |
children | a76243c02074 |
comparison
equal
deleted
inserted
replaced
263:d3c734669577 | 264:2a93f8e6f989 |
---|---|
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.AbsolutePanel import AbsolutePanel | 24 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
25 from pyjamas.ui.VerticalPanel import VerticalPanel | 25 from pyjamas.ui.VerticalPanel import VerticalPanel |
26 from pyjamas.ui.HorizontalPanel import HorizontalPanel | 26 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
27 from pyjamas.ui.DialogBox import DialogBox | |
28 from pyjamas.ui.HTMLPanel import HTMLPanel | 27 from pyjamas.ui.HTMLPanel import HTMLPanel |
29 from pyjamas.ui.Frame import Frame | 28 from pyjamas.ui.Frame import Frame |
30 from pyjamas.ui.TextArea import TextArea | 29 from pyjamas.ui.TextArea import TextArea |
31 from pyjamas.ui.Label import Label | 30 from pyjamas.ui.Label import Label |
32 from pyjamas.ui.Button import Button | 31 from pyjamas.ui.Button import Button |
33 from pyjamas.ui.HTML import HTML | 32 from pyjamas.ui.HTML import HTML |
34 from pyjamas.ui.Image import Image | 33 from pyjamas.ui.Image import Image |
35 from pyjamas.ui.PopupPanel import PopupPanel | 34 from pyjamas.ui.PopupPanel import PopupPanel |
35 from pyjamas.ui.StackPanel import StackPanel | |
36 from pyjamas.ui.ClickListener import ClickHandler | 36 from pyjamas.ui.ClickListener import ClickHandler |
37 from pyjamas.ui.KeyboardListener import KEY_ENTER, KEY_UP, KEY_DOWN | 37 from pyjamas.ui.KeyboardListener import KEY_ENTER, KEY_UP, KEY_DOWN |
38 from pyjamas.ui.Event import BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT | 38 from pyjamas.ui.Event import BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT |
39 from pyjamas.ui.MouseListener import MouseHandler | 39 from pyjamas.ui.MouseListener import MouseHandler |
40 from pyjamas.Timer import Timer | 40 from pyjamas.Timer import Timer |
1054 def registerMiddleClickSender(self, sender): | 1054 def registerMiddleClickSender(self, sender): |
1055 self.registerClickSender(sender, BUTTON_MIDDLE) | 1055 self.registerClickSender(sender, BUTTON_MIDDLE) |
1056 | 1056 |
1057 def registerRightClickSender(self, sender): | 1057 def registerRightClickSender(self, sender): |
1058 self.registerClickSender(sender, BUTTON_RIGHT) | 1058 self.registerClickSender(sender, BUTTON_RIGHT) |
1059 | |
1060 | |
1061 class ToggleStackPanel(StackPanel): | |
1062 """This is a pyjamas.ui.StackPanel with modified behavior. All sub-panels ca be | |
1063 visible at the same time, clicking a sub-panel header will not display it and hide | |
1064 the others but only toggle its own visibility. The argument 'visibleStack' is ignored. | |
1065 Note that the argument 'visible' has been added to listener's 'onStackChanged' method. | |
1066 """ | |
1067 | |
1068 def __init__(self, **kwargs): | |
1069 StackPanel.__init__(self, **kwargs) | |
1070 | |
1071 def onBrowserEvent(self, event): | |
1072 if DOM.eventGetType(event) == "click": | |
1073 index = self.getDividerIndex(DOM.eventGetTarget(event)) | |
1074 if index != -1: | |
1075 self.toggleStack(index) | |
1076 | |
1077 def add(self, widget, stackText="", asHTML=False, visible=False): | |
1078 StackPanel.add(self, widget, stackText, asHTML) | |
1079 self.setStackVisible(self.getWidgetCount() - 1, visible) | |
1080 | |
1081 def toggleStack(self, index): | |
1082 if index >= self.getWidgetCount(): | |
1083 return | |
1084 visible = not self.getWidget(index).getVisible() | |
1085 self.setStackVisible(index, visible) | |
1086 for listener in self.stackListeners: | |
1087 listener.onStackChanged(self, index, visible) |