Mercurial > libervia-web
annotate browser_side/panels.py @ 109:5c363b638127
browser side: grouped header panel in a global Absolute panel
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 29 Jun 2011 20:24:09 +0200 |
parents | ad0696615768 |
children | c64b00f31461 |
rev | line source |
---|---|
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
4 """ |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 Libervia: a Salut à Toi frontend |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
6 Copyright (C) 2011 Jérôme Poisson <goffi@goffi.org> |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 This program is free software: you can redistribute it and/or modify |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 it under the terms of the GNU Affero General Public License as published by |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 (at your option) any later version. |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 This program is distributed in the hope that it will be useful, |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 GNU Affero General Public License for more details. |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU Affero General Public License |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 """ |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
22 import pyjd # this is dummy in pyjs |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
23 from pyjamas.ui.SimplePanel import SimplePanel |
33 | 24 from pyjamas.ui.AbsolutePanel import AbsolutePanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 from pyjamas.ui.VerticalPanel import VerticalPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from pyjamas.ui.ScrollPanel import ScrollPanel |
23 | 28 from pyjamas.ui.TabPanel import TabPanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 from pyjamas.ui.HTMLPanel import HTMLPanel |
83 | 30 from pyjamas.ui.FlexTable import FlexTable |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 from pyjamas.ui.Grid import Grid |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
32 from pyjamas.ui.TextArea import TextArea |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 from pyjamas.ui.Label import Label |
83 | 34 from pyjamas.ui.Button import Button |
33 | 35 from pyjamas.ui.HTML import HTML |
83 | 36 from pyjamas.ui.Image import Image |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 from pyjamas.ui.DropWidget import DropWidget |
19 | 38 from pyjamas.ui.ClickListener import ClickHandler |
33 | 39 from pyjamas.ui.KeyboardListener import KEY_ENTER |
83 | 40 from pyjamas.ui import HasAlignment |
33 | 41 from pyjamas.Timer import Timer |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 from pyjamas import Window |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 from pyjamas import DOM |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
44 from card_game import CardPanel |
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
45 from menu import Menu |
19 | 46 from jid import JID |
33 | 47 from tools import html_sanitize |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 from datetime import datetime |
19 | 49 from time import time |
48
153de5d461a4
added Social Contract \o. (in French only so far)
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
50 import dialog |
78
12680e220b35
browser side: refactoring: menu is now in its own module
Goffi <goffi@goffi.org>
parents:
75
diff
changeset
|
51 from __pyjamas__ import doc |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 class DropCell(DropWidget): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 """Cell in the middle grid which replace itself with the dropped widget on DnD""" |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
56 def __init__(self, host): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
57 DropWidget.__init__(self) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
58 self.host = host |
83 | 59 self.setStyleName('dropCell') |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 def onDragEnter(self, event): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 self.addStyleName('dragover') |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 DOM.eventPreventDefault(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 def onDragLeave(self, event): |
33 | 66 if event.clientX <= self.getAbsoluteLeft() or event.clientY <= self.getAbsoluteTop() or\ |
67 event.clientX >= self.getAbsoluteLeft() + self.getOffsetWidth()-1 or event.clientY >= self.getAbsoluteTop() + self.getOffsetHeight()-1: | |
68 #We check that we are inside widget's box, and we don't remove the style in this case because | |
69 #if the mouse is over a widget inside the DropWidget, if will leave the DropWidget, and we | |
70 #don't want that | |
71 self.removeStyleName('dragover') | |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 def onDragOver(self, event): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 DOM.eventPreventDefault(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 def _getCellAndRow(self, grid, event): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 """Return cell and row index where the event is occuring""" |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 cell = grid.getEventTargetCell(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 row = DOM.getParent(cell) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 return (row.rowIndex, cell.cellIndex) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 def onDrop(self, event): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 dt = event.dataTransfer |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 #'text', 'text/plain', and 'Text' are equivalent. |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 try: |
62 | 87 item, item_type = dt.getData("text/plain").split('\n') #Workaround for webkit, only text/plain seems to be managed |
88 if item_type and item_type[-1] == '\0': #Workaround for what looks like a pyjamas bug: the \0 should not be there, and | |
89 item_type = item_type[:-1] # .strip('\0') and .replace('\0','') don't work. TODO: check this and fill a bug report | |
90 #item_type = dt.getData("type") | |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 print "message: %s" % item |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 print "type: %s" % item_type |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 except: |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 print "no message found" |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 item=' ' |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 item_type = None |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 DOM.eventPreventDefault(event) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 if item_type=="GROUP": |
19 | 99 _new_panel = MicroblogPanel(self.host, item) |
100 _new_panel.setAcceptedGroup(item) | |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
101 self.host.FillMicroblogPanel(_new_panel) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 elif item_type=="CONTACT": |
19 | 103 _contact = JID(item) |
62 | 104 self.host.contact_panel.setContactMessageWaiting(_contact.bare, False) |
19 | 105 _new_panel = ChatPanel(self.host, _contact) |
106 _new_panel.historyPrint() | |
107 elif item_type=="CONTACT_TITLE": | |
108 _new_panel = MicroblogPanel(self.host, accept_all=True) | |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
109 self.host.FillMicroblogPanel(_new_panel) |
39
305e81c7a32c
Tarot game: a game can now be finished
Goffi <goffi@goffi.org>
parents:
38
diff
changeset
|
110 else: |
84 | 111 return False |
112 if isinstance(self, LiberviaWidget): | |
113 self.host.unregisterWidget(self) | |
114 if not isinstance(_new_panel, LiberviaWidget): | |
115 print ('WARNING: droping an object which is not a class of LiberviaWidget') | |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
116 _flextable = self.getParent() |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
117 _widgetspanel = _flextable.getParent().getParent() |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
118 row_idx, cell_idx = self._getCellAndRow(_flextable, event) |
19 | 119 if self.host.selected == self: |
120 self.host.select(None) | |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
121 _widgetspanel.changeWidget(row_idx, cell_idx, _new_panel) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
122 """_unempty_panels = filter(lambda wid:not isinstance(wid,EmptyWidget),list(_flextable)) |
34 | 123 _width = 90/float(len(_unempty_panels) or 1) |
124 #now we resize all the cell of the column | |
125 for panel in _unempty_panels: | |
126 td_elt = panel.getElement().parentNode | |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
127 DOM.setStyleAttribute(td_elt, "width", "%s%%" % _width)""" |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 #FIXME: delete object ? Check the right way with pyjamas |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 |
84 | 130 class LiberviaWidget(DropCell, VerticalPanel, ClickHandler): |
83 | 131 """Libervia's widget which can replace itself with a dropped widget on DnD""" |
132 | |
84 | 133 def __init__(self, host, title='', selectable=False): |
134 """Init the widget | |
135 @param host: SatWebFrontend object | |
136 @param title: title show in the header of the widget | |
137 @param selectable: True is widget can be selected by user""" | |
83 | 138 VerticalPanel.__init__(self) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
139 DropCell.__init__(self, host) |
84 | 140 ClickHandler.__init__(self) |
141 self.__selectable = selectable | |
142 self.__title_id = HTMLPanel.createUniqueId() | |
143 self.__setting_button_id = HTMLPanel.createUniqueId() | |
144 self.__close_button_id = HTMLPanel.createUniqueId() | |
83 | 145 header = AbsolutePanel() |
84 | 146 self.__title = Label(title) |
147 self.__title.setStyleName('widgetHeader_title') | |
148 header.add(self.__title) | |
83 | 149 button_group_wrapper = SimplePanel() |
150 button_group_wrapper.setStyleName('widgetHeader_buttonsWrapper') | |
151 button_group = HorizontalPanel() | |
152 button_group.setStyleName('widgetHeader_buttonGroup') | |
153 setting_button = Image("media/icons/misc/settings.png") | |
154 setting_button.setStyleName('widgetHeader_settingButton') | |
89
8d2c7be09eef
browser side: CSS: removed useless z-indexes, and replaced tabs by spaces
Goffi <goffi@goffi.org>
parents:
88
diff
changeset
|
155 setting_button.addClickListener(self.onSetting) |
83 | 156 close_button = Image("media/icons/misc/close.png") |
157 close_button.setStyleName('widgetHeader_closeButton') | |
89
8d2c7be09eef
browser side: CSS: removed useless z-indexes, and replaced tabs by spaces
Goffi <goffi@goffi.org>
parents:
88
diff
changeset
|
158 close_button.addClickListener(self.onClose) |
83 | 159 button_group.add(setting_button) |
160 button_group.add(close_button) | |
161 button_group_wrapper.setWidget(button_group) | |
162 header.add(button_group_wrapper) | |
163 self.add(header) | |
164 header.addStyleName('widgetHeader') | |
165 self.setSize('100%', '100%') | |
166 self.addStyleName('widget') | |
84 | 167 if self.__selectable: |
168 self.addClickListener(self) | |
169 self.host.registerWidget(self) | |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
170 |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
171 def _getWidgetsPanel(self): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
172 return self.getParent().getParent().getParent() |
84 | 173 |
174 def onClick(self, sender): | |
175 self.host.select(self) | |
83 | 176 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
177 def onClose(self, sender): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
178 print "onClose:", sender |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
179 _widgetspanel = self._getWidgetsPanel() |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
180 _widgetspanel.removeWidget(self) |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
181 |
89
8d2c7be09eef
browser side: CSS: removed useless z-indexes, and replaced tabs by spaces
Goffi <goffi@goffi.org>
parents:
88
diff
changeset
|
182 def onSetting(self, sender): |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
183 widpanel = self._getWidgetsPanel() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
184 row, col = widpanel.getIndex(self) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
185 body = VerticalPanel() |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
186 |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
187 #colspan & rowspan |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
188 colspan = widpanel.getColSpan(row, col) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
189 rowspan = widpanel.getRowSpan(row, col) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
190 def onColSpanChange(value): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
191 widpanel.setColSpan(row, col, value) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
192 def onRowSpanChange(value): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
193 widpanel.setRowSpan(row, col, value) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
194 colspan_setter = dialog.IntSetter("Columns span", colspan) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
195 colspan_setter.addValueChangeListener(onColSpanChange) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
196 colspan_setter.setWidth('100%') |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
197 rowspan_setter = dialog.IntSetter("Rows span", rowspan) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
198 rowspan_setter.addValueChangeListener(onRowSpanChange) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
199 rowspan_setter.setWidth('100%') |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
200 body.add(colspan_setter) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
201 body.add(rowspan_setter) |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
202 |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
203 #size |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
204 width_str = self.getWidth() |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
205 if width_str.endswith('px'): |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
206 width=int(width_str[:-2]) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
207 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
208 width = 0 |
97
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
209 height_str = self.getHeight() |
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
210 if height_str.endswith('px'): |
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
211 height=int(height_str[:-2]) |
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
212 else: |
3cbbe5c05aa5
browser side: widgets' setting: height detection fix
Goffi <goffi@goffi.org>
parents:
96
diff
changeset
|
213 height = 0 |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
214 def onWidthChange(value): |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
215 if not value: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
216 self.setWidth('100%') |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
217 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
218 self.setWidth('%dpx' % value) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
219 def onHeightChange(value): |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
220 if not value: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
221 self.setHeight('100%') |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
222 else: |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
223 self.setHeight('%dpx' % value) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
224 width_setter = dialog.IntSetter("width (0=auto)", width) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
225 width_setter.addValueChangeListener(onWidthChange) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
226 width_setter.setWidth('100%') |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
227 height_setter = dialog.IntSetter("height (0=auto)", height) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
228 height_setter.addValueChangeListener(onHeightChange) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
229 height_setter.setHeight('100%') |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
230 body.add(width_setter) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
231 body.add(height_setter) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
232 |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
233 #reset |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
234 def onReset(sender): |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
235 colspan_setter.setValue(1) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
236 rowspan_setter.setValue(1) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
237 width_setter.setValue(0) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
238 height_setter.setValue(0) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
239 |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
240 reset_bt = Button("Reset", onReset) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
241 body.add(reset_bt) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
242 body.setCellHorizontalAlignment(reset_bt, HasAlignment.ALIGN_CENTER) |
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
243 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
244 _dialog = dialog.GenericDialog("Widget setting", body) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
245 _dialog.show() |
89
8d2c7be09eef
browser side: CSS: removed useless z-indexes, and replaced tabs by spaces
Goffi <goffi@goffi.org>
parents:
88
diff
changeset
|
246 |
83 | 247 def setTitle(self, text): |
248 """change the title in the header of the widget | |
249 @param text: text of the new title""" | |
84 | 250 self.__title.setText(text) |
251 | |
252 def isSelectable(self): | |
253 return self.__selectable | |
254 | |
255 def setSelectable(self, selectable): | |
256 if not self.__selectable: | |
257 try: | |
258 self.removeClickListener(self) | |
259 except ValueError: | |
260 pass | |
261 if self.selectable and not self in self._clickListeners: | |
262 self.addClickListener(self) | |
263 self.__selectable = selectable | |
83 | 264 |
265 def setWidget(self, widget, scrollable=True): | |
266 """Set the widget that will be in the body of the LiberviaWidget | |
267 @param widget: widget to put in the body | |
268 @param scrollable: if true, the widget will be in a ScrollPanelWrapper""" | |
269 if scrollable: | |
270 _scrollpanelwrapper = ScrollPanelWrapper() | |
271 _scrollpanelwrapper.setStyleName('widgetBody') | |
272 _scrollpanelwrapper.setWidget(widget) | |
273 body_wid = _scrollpanelwrapper | |
274 else: | |
275 body_wid = widget | |
276 self.add(body_wid) | |
277 self.setCellHeight(body_wid, '100%') | |
278 | |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
279 def doDetachChildren(self): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
280 #We need to force the use of a panel subclass method here, |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
281 #for the same reason as doAttachChildren |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
282 VerticalPanel.doDetachChildren(self) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
283 |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
284 def doAttachChildren(self): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
285 #We need to force the use of a panel subclass method here, else |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
286 #the event will not propagate to children |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
287 VerticalPanel.doAttachChildren(self) |
83 | 288 |
34 | 289 class ScrollPanelWrapper(SimplePanel): |
290 """Scroll Panel like component, wich use the full available space | |
291 to work around percent size issue, it use some of the ideas found | |
292 here: http://code.google.com/p/google-web-toolkit/issues/detail?id=316 | |
293 specially in code given at comment #46, thanks to Stefan Bachert""" | |
294 | |
295 def __init__(self, *args, **kwargs): | |
296 SimplePanel.__init__(self) | |
297 self.spanel = ScrollPanel(*args, **kwargs) | |
298 SimplePanel.setWidget(self, self.spanel) | |
299 DOM.setStyleAttribute(self.getElement(), "position", "relative") | |
300 DOM.setStyleAttribute(self.getElement(), "top", "0px") | |
301 DOM.setStyleAttribute(self.getElement(), "left", "0px") | |
302 DOM.setStyleAttribute(self.getElement(), "width", "100%") | |
303 DOM.setStyleAttribute(self.getElement(), "height", "100%") | |
304 DOM.setStyleAttribute(self.spanel.getElement(), "position", "absolute") | |
305 DOM.setStyleAttribute(self.spanel.getElement(), "width", "100%") | |
306 DOM.setStyleAttribute(self.spanel.getElement(), "height", "100%") | |
307 | |
308 def setWidget(self, widget): | |
309 self.spanel.setWidget(widget) | |
310 | |
311 def setScrollPosition(self, position): | |
312 self.spanel.setScrollPosition(position) | |
313 | |
314 def scrollToBottom(self): | |
315 self.setScrollPosition(self.spanel.getElement().scrollHeight) | |
316 | |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
317 class EmptyWidget(DropCell, SimplePanel): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
318 """Empty dropable panel""" |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
319 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
320 def __init__(self, host): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
321 SimplePanel.__init__(self) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
322 DropCell.__init__(self, host) |
96
d7a4bbaddfb0
browser side: removed in EmptyPanel
Goffi <goffi@goffi.org>
parents:
92
diff
changeset
|
323 #self.setWidget(HTML('')) |
83 | 324 self.setSize('100%','100%') |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
325 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
326 class BorderWidget(EmptyWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
327 def __init__(self, host): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
328 EmptyWidget.__init__(self, host) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
329 self.addStyleName('borderPanel') |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
330 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
331 class LeftBorderWidget(BorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
332 def __init__(self, host): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
333 BorderWidget.__init__(self, host) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
334 self.addStyleName('leftBorderWidget') |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
335 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
336 class RightBorderWidget(BorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
337 def __init__(self, host): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
338 BorderWidget.__init__(self, host) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
339 self.addStyleName('rightBorderWidget') |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
340 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
341 class BottomBorderWidget(BorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
342 def __init__(self, host): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
343 BorderWidget.__init__(self, host) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
344 self.addStyleName('bottomBorderWidget') |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
345 |
33 | 346 class UniBoxPanel(SimplePanel): |
347 """Panel containing the UniBox""" | |
348 | |
349 def __init__(self, host): | |
350 SimplePanel.__init__(self) | |
351 self.setStyleName('uniBoxPanel') | |
352 self.unibox = UniBox(host) | |
353 self.unibox.setWidth('100%') | |
354 self.add(self.unibox) | |
355 | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
356 class UniBox(TextArea): #AutoCompleteTextBox): |
33 | 357 """This text box is used as a main typing point, for message, microblog, etc""" |
358 | |
359 def __init__(self, host): | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
360 TextArea.__init__(self) |
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
361 #AutoCompleteTextBox.__init__(self) |
33 | 362 self._popup = None |
363 self._timer = Timer(notify=self._timeCb) | |
364 self.host = host | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
365 self.setStyleName('uniBox') |
83 | 366 self.addKeyboardListener(self) |
33 | 367 |
368 def addKey(self, key): | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
369 return |
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
370 #self.getCompletionItems().completions.append(key) |
33 | 371 |
55
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
372 def removeKey(self, key): |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
373 try: |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
374 self.getCompletionItems().completions.remove(key) |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
375 except KeyError: |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
376 print "WARNING: trying to remove an unknown key" |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
377 |
d5266c41ca24
Roster list update, contact deletion + some refactoring
Goffi <goffi@goffi.org>
parents:
54
diff
changeset
|
378 |
33 | 379 def showWarning(self, target_data): |
380 type, target = target_data | |
381 if type == "PUBLIC": | |
382 msg = "This message will be PUBLIC and everybody will be able to see it, even people you don't know" | |
383 style = "targetPublic" | |
384 elif type == "GROUP": | |
385 msg = "This message will be published for all the people of the group <span class='warningTarget'>%s</span>" % (target or '') | |
386 style = "targetGroup" | |
387 elif type == "STATUS": | |
388 msg = "This will be your new status message" | |
389 style = "targetStatus" | |
390 elif type == "ONE2ONE": | |
391 msg = "This message will be sent to your contact <span class='warningTarget'>%s</span>" % target | |
392 style = "targetOne2One" | |
393 else: | |
394 print "WARNING: undetermined target for this message" | |
395 return | |
396 contents = HTML(msg) | |
397 | |
48
153de5d461a4
added Social Contract \o. (in French only so far)
Goffi <goffi@goffi.org>
parents:
43
diff
changeset
|
398 self._popup = dialog.PopupPanelWrapper(autoHide=False, modal=False) |
33 | 399 self._popup.target_data = target_data |
400 self._popup.add(contents) | |
401 self._popup.setStyleName("warningPopup") | |
402 if style: | |
403 self._popup.addStyleName(style) | |
404 | |
405 left = 0 | |
406 top = 0 #max(0, self.getAbsoluteTop() - contents.getOffsetHeight() - 2) | |
407 self._popup.setPopupPosition(left, top) | |
408 self._popup.setPopupPosition(left, top) | |
409 self._popup.show() | |
410 | |
411 def _timeCb(self, timer): | |
412 if self._popup: | |
413 self._popup.hide() | |
414 del self._popup | |
415 self._popup = None | |
416 | |
417 def _getTarget(self, txt): | |
418 """Say who will receive the messsage | |
419 Return a tuple (target_type, target info)""" | |
420 type = None | |
421 target = None | |
422 if txt.startswith('@@: '): | |
423 type = "PUBLIC" | |
424 elif txt.startswith('@'): | |
425 type = "GROUP" | |
426 _end = txt.find(': ') | |
427 if _end == -1: | |
428 type = "STATUS" | |
429 else: | |
430 target = txt[1:_end] #only one target group is managed for the moment | |
431 if not target in self.host.contact_panel.getGroups(): | |
432 target = None | |
433 elif self.host.selected == None: | |
434 type = "STATUS" | |
435 elif isinstance(self.host.selected, ChatPanel): | |
436 type = "ONE2ONE" | |
437 target = str(self.host.selected.target) | |
438 else: | |
62 | 439 print "Unknown selected host:",self.host.selected |
33 | 440 type = "UNKNOWN" |
441 return (type, target) | |
442 | |
443 def onKeyPress(self, sender, keycode, modifiers): | |
444 _txt = self.getText() | |
445 if not self._popup: | |
446 self.showWarning(self._getTarget(_txt)) | |
447 else: | |
448 _target = self._getTarget(_txt) | |
449 if _target != self._popup.target_data: | |
450 self._timeCb(None) #we remove the popup | |
451 self.showWarning(_target) | |
452 | |
453 self._timer.schedule(2000) | |
454 | |
83 | 455 #if keycode == KEY_ENTER and not self.visible: |
456 if keycode == KEY_ENTER: | |
33 | 457 if _txt: |
458 if _txt.startswith('@'): | |
459 self.host.bridge.call('sendMblog', None, self.getText()) | |
460 elif self.host.selected == None: | |
461 self.host.bridge.call('setStatus', None, _txt) | |
462 elif isinstance(self.host.selected, ChatPanel): | |
463 _chat = self.host.selected | |
464 mess_type = "groupchat" if _chat.type=='group' else "chat" | |
465 self.host.bridge.call('sendMessage', None, str(_chat.target), _txt, '', mess_type) | |
466 self.setText('') | |
467 self._timeCb(None) #we remove the popup | |
468 | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
469 """def complete(self): |
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
470 |
33 | 471 #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done |
472 #XXX: fixed directly on pyjamas, if the patch is accepted, no need to walk around this | |
73
447dc8ac181b
Adrien's uniBox design integration + lastPopup style
Goffi <goffi@goffi.org>
parents:
71
diff
changeset
|
473 return AutoCompleteTextBox.complete(self)""" |
33 | 474 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
475 class MicroblogEntry(SimplePanel): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
476 |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
477 def __init__(self, mblog_entry): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
478 SimplePanel.__init__(self) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
479 |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
480 _datetime = datetime.fromtimestamp(mblog_entry.timestamp) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
481 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
482 panel = HTMLPanel("<div class='mb_entry_header'><span class='mb_entry_author'>%(author)s</span> on <span class='mb_entry_timestamp'>%(timestamp)s</span></div><div class='mb_entry_body'>%(body)s</div>" % |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
483 {"author": html_sanitize(mblog_entry.author), |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
484 "timestamp": _datetime, |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
485 "body": html_sanitize(mblog_entry.content)} |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
486 ) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
487 panel.setStyleName('microblogEntry') |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
488 self.add(panel) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
489 |
83 | 490 class MicroblogPanel(LiberviaWidget): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
491 |
83 | 492 def __init__(self, host, title='', accept_all=False): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
493 """Panel used to show microblog |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
494 @param title: title of the panel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
495 @param accept_all: if true, show every message, without filtering jids""" |
84 | 496 LiberviaWidget.__init__(self, host, title) |
83 | 497 #ScrollPanelWrapper.__init__(self) |
498 #DropCell.__init__(self) | |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
499 self.accept_all = accept_all |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
500 self.accepted_groups = [] |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
501 self.entries = {} |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
502 self.vpanel = VerticalPanel() |
83 | 503 self.vpanel.setStyleName('microblogPanel') |
34 | 504 self.setWidget(self.vpanel) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
505 |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
506 def addEntry(self, mblog_entry): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
507 """Add an entry to the panel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
508 @param text: main text of the entry |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
509 @param id: unique id of the entry |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
510 @param author: who wrote the entry |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
511 @param date: when the entry was written""" |
58
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
512 if mblog_entry.id in self.entries: |
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
513 return |
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
514 _entry = MicroblogEntry(mblog_entry) |
4fa3d57f72f8
browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents:
57
diff
changeset
|
515 self.entries[mblog_entry.id] = _entry |
83 | 516 self.vpanel.insert(_entry,0) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
517 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
518 def setAcceptedGroup(self, group): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
519 """Set the group which can be displayed in this panel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
520 @param group: string of the group, or list of string |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
521 """ |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
522 if isinstance(group, list): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
523 self.accepted_groups.extend(group) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
524 else: |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
525 self.accepted_groups.append(group) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
526 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
527 def isJidAccepted(self, jid): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
528 """Tell if a jid is actepted and show in this panel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
529 @param jid: jid |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
530 @return: True if the jid is accepted""" |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
531 if self.accept_all: |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
532 return True |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
533 for group in self.accepted_groups: |
27
d89982865c57
browser side: ContactsChooser is now used to ask for 3 others players when tarot game is launched + names refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
534 if self.host.contact_panel.isContactInGroup(group, jid): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
535 return True |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
536 return False |
19 | 537 |
20 | 538 class StatusPanel(HTMLPanel, ClickHandler): |
539 def __init__(self, host, status=''): | |
540 self.host = host | |
541 self.status = status or ' ' | |
19 | 542 HTMLPanel.__init__(self, self.__getContent()) |
20 | 543 self.setStyleName('statusPanel') |
544 ClickHandler.__init__(self) | |
545 self.addClickListener(self) | |
19 | 546 |
547 def __getContent(self): | |
51 | 548 return "<span class='status'>%(status)s</span>" % {'status':html_sanitize(self.status)} |
19 | 549 |
550 def changeStatus(self, new_status): | |
20 | 551 self.status = new_status or ' ' |
19 | 552 self.setHTML(self.__getContent()) |
553 | |
62 | 554 def onClick(self, sender): |
20 | 555 #As status is the default target of uniBar, we don't want to select anything if click on it |
556 self.host.select(None) | |
557 | |
19 | 558 class ChatText(HTMLPanel): |
559 | |
560 def __init__(self, timestamp, nick, mymess, msg): | |
561 _date = datetime.fromtimestamp(float(timestamp or time())) | |
562 _msg_class = ["chat_text_msg"] | |
563 if mymess: | |
564 _msg_class.append("chat_text_mymess") | |
565 HTMLPanel.__init__(self, "<span class='chat_text_timestamp'>%(timestamp)s</span> <span class='chat_text_nick'>%(nick)s</span> <span class='%(msg_class)s'>%(msg)s</span>" % | |
566 {"timestamp": _date.strftime("%H:%M"), | |
51 | 567 "nick": "[%s]" % html_sanitize(nick), |
19 | 568 "msg_class": ' '.join(_msg_class), |
51 | 569 "msg": html_sanitize(msg)} |
19 | 570 ) |
571 self.setStyleName('chatText') | |
33 | 572 |
573 class Occupant(HTML): | |
574 """Occupant of a MUC room""" | |
575 | |
576 def __init__(self, nick): | |
577 self.nick = nick | |
35 | 578 HTML.__init__(self, "<div class='occupant'>%s</div>" % html_sanitize(nick)) |
579 | |
580 def __str__(self): | |
581 return nick | |
33 | 582 |
583 class OccupantsList(AbsolutePanel): | |
584 """Panel user to show occupants of a room""" | |
585 | |
586 def __init__(self): | |
587 AbsolutePanel.__init__(self) | |
35 | 588 self.occupants_list = {} |
33 | 589 self.setStyleName('occupantsList') |
590 | |
591 def addOccupant(self, nick): | |
35 | 592 _occupant = Occupant(nick) |
593 self.occupants_list[nick] = _occupant | |
594 self.add(_occupant) | |
33 | 595 |
35 | 596 def removeOccupant(self, nick): |
597 try: | |
598 self.remove(self.occupants_list[nick]) | |
599 except KeyError: | |
600 print "ERROR: trying to remove an unexisting nick" | |
601 | |
602 def clear(self): | |
603 self.occupants_list.clear() | |
604 AbsolutePanel.clear(self) | |
605 | |
84 | 606 class ChatPanel(LiberviaWidget): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
607 |
19 | 608 def __init__(self, host, target, type='one2one'): |
609 """Panel used for conversation (one 2 one or group chat) | |
610 @param host: SatWebFrontend instance | |
611 @param target: entity (JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room) | |
612 @param type: one2one for simple conversation, group for MUC""" | |
84 | 613 LiberviaWidget.__init__(self, host, target.bare, selectable = True) |
34 | 614 self.vpanel = VerticalPanel() |
615 self.vpanel.setSize('100%','100%') | |
33 | 616 self.type = type |
617 self.nick = None | |
19 | 618 if not target: |
619 print "ERROR: Empty target !" | |
620 return | |
621 self.target = target | |
84 | 622 self.__body = AbsolutePanel() |
623 self.__body.setStyleName('chatPanel_body') | |
33 | 624 chat_area = HorizontalPanel() |
625 chat_area.setStyleName('chatArea') | |
626 if type == 'group': | |
627 self.occupants_list = OccupantsList() | |
628 chat_area.add(self.occupants_list) | |
84 | 629 self.__body.add(chat_area) |
33 | 630 self.content = AbsolutePanel() |
631 self.content.setStyleName('chatContent') | |
34 | 632 self.content_scroll = ScrollPanelWrapper(self.content) |
633 chat_area.add(self.content_scroll) | |
634 chat_area.setCellWidth(self.content_scroll, '100%') | |
84 | 635 self.vpanel.add(self.__body) |
636 self.addStyleName('chatPanel') | |
34 | 637 self.setWidget(self.vpanel) |
19 | 638 |
84 | 639 """def doDetachChildren(self): |
38
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
640 #We need to force the use of a panel subclass method here, |
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
641 #for the same reason as doAttachChildren |
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
642 ScrollPanelWrapper.doDetachChildren(self) |
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
643 |
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
644 def doAttachChildren(self): |
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
645 #We need to force the use of a panel subclass method here, else |
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
646 #the event will not propagate to children |
84 | 647 ScrollPanelWrapper.doAttachChildren(self)""" |
38
7bea2ae0c4fb
Tarot game: center_panel layout + chien can now be showed + fixed click event inheritance + card selection first draft
Goffi <goffi@goffi.org>
parents:
37
diff
changeset
|
648 |
19 | 649 def setUserNick(self, nick): |
650 """Set the nick of the user, usefull for e.g. change the color of the user""" | |
651 self.nick = nick | |
33 | 652 |
653 def setPresents(self, nicks): | |
654 """Set the users presents in this room | |
655 @param occupants: list of nicks (string)""" | |
35 | 656 self.occupants_list.clear() |
33 | 657 for nick in nicks: |
658 self.occupants_list.addOccupant(nick) | |
659 | |
35 | 660 def userJoined(self, nick, data): |
661 self.occupants_list.addOccupant(nick) | |
662 self.printInfo("=> %s has joined the room" % nick) | |
663 | |
664 def userLeft(self, nick, data): | |
665 self.occupants_list.removeOccupant(nick) | |
666 self.printInfo("<= %s has left the room" % nick) | |
667 | |
19 | 668 def historyPrint(self, size=20): |
669 """Print the initial history""" | |
670 def getHistoryCB(history): | |
671 stamps=history.keys() | |
672 stamps.sort() | |
33 | 673 for stamp in stamps: |
19 | 674 self.printMessage(history[stamp][0], history[stamp][1], stamp) |
62 | 675 self.host.bridge.call('getHistory', getHistoryCB, self.host.whoami.bare, self.target.bare, 20) |
35 | 676 |
677 def printInfo(self, msg, type='normal'): | |
678 """Print general info | |
679 @param msg: message to print | |
680 @type: one of: | |
681 normal: general info like "toto has joined the room" | |
682 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" | |
683 """ | |
54
f25c4077f6b9
addind contact + subscription management + misc
Goffi <goffi@goffi.org>
parents:
52
diff
changeset
|
684 _wid = Label(msg) |
35 | 685 if type == 'normal': |
686 _wid.setStyleName('chatTextInfo') | |
687 elif type == 'me': | |
688 _wid.setStyleName('chatTextMe') | |
689 else: | |
690 _wid.setStyleName('chatTextInfo') | |
691 self.content.add(_wid) | |
692 | |
693 | |
19 | 694 def printMessage(self, from_jid, msg, timestamp=None): |
695 """Print message in chat window. Must be implemented by child class""" | |
84 | 696 print "print message:",msg |
19 | 697 _jid=JID(from_jid) |
33 | 698 nick = _jid.node if self.type=='one2one' else _jid.resource |
699 mymess = _jid.resource == self.nick if self.type == "group" else _jid.bare == self.host.whoami.bare #mymess = True if message comes from local user | |
35 | 700 if msg.startswith('/me '): |
19 | 701 self.printInfo('* %s %s' % (nick, msg[4:]),type='me') |
35 | 702 return |
19 | 703 self.content.add(ChatText(timestamp, nick, mymess, msg)) |
34 | 704 self.content_scroll.scrollToBottom() |
36 | 705 |
706 def startGame(self, game_type, referee, players): | |
707 """Configure the chat window to start a game""" | |
708 if game_type=="Tarot": | |
709 self.tarot_panel = CardPanel(self, referee, players, self.nick) | |
92
dd54bc13ac81
browser side: widgets' width and height can now be fixed + tarot game position fix
Goffi <goffi@goffi.org>
parents:
90
diff
changeset
|
710 self.vpanel.insert(self.tarot_panel, 0) |
36 | 711 self.vpanel.setCellHeight(self.tarot_panel, self.tarot_panel.getHeight()) |
37
b306aa090438
Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
712 |
b306aa090438
Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
713 def getGame(self, game_type): |
b306aa090438
Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
714 """Return class managing the game type""" |
b306aa090438
Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
715 #TODO: check that the game is launched, and manage errors |
b306aa090438
Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
716 if game_type=="Tarot": |
b306aa090438
Tarot game: game launching (first hand showed), and contract selection
Goffi <goffi@goffi.org>
parents:
36
diff
changeset
|
717 return self.tarot_panel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
718 |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
719 class WidgetsPanel(ScrollPanelWrapper): |
83 | 720 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
721 def __init__(self, host): |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
722 ScrollPanelWrapper.__init__(self) |
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
723 self.setSize('100%', '100%') |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
724 self.host = host |
83 | 725 self.flextable = FlexTable() |
726 self.flextable.setSize('100%','100%') | |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
727 self.setWidget(self.flextable) |
83 | 728 self.setStyleName('widgetsPanel') |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
729 _bottom = BottomBorderWidget(self.host) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
730 self.flextable.setWidget(0, 0, _bottom) #There will be always an Empty widget on the last row, |
101
ad0696615768
browser side: bottomBorderWidget size fix (for webkit)
Goffi <goffi@goffi.org>
parents:
97
diff
changeset
|
731 #dropping a widget there will add a new row |
ad0696615768
browser side: bottomBorderWidget size fix (for webkit)
Goffi <goffi@goffi.org>
parents:
97
diff
changeset
|
732 td_elt = _bottom.getElement().parentNode |
ad0696615768
browser side: bottomBorderWidget size fix (for webkit)
Goffi <goffi@goffi.org>
parents:
97
diff
changeset
|
733 DOM.setStyleAttribute(td_elt, "height", "1px") #needed so the cell adapt to the size of the border (specially in webkit) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
734 self._max_cols = 1 #give the maximum number of columns i a raw |
83 | 735 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
736 def changeWidget(self, row, col, wid): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
737 """Change the widget in the given location, add row or columns when necessary""" |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
738 print "changing widget:", wid, row, col |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
739 last_row = max(0, self.flextable.getRowCount()-1) |
83 | 740 try: |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
741 prev_wid = self.flextable.getWidget(row, col) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
742 except: |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
743 print "ERROR: Trying to change an unexisting widget !" |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
744 return |
88
50b480fd0605
browser side: widgetsPanel is now scrollable when there are too many widgets, and widgets have a minimum size
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
745 |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
746 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
747 cellFormatter = self.flextable.getFlexCellFormatter() |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
748 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
749 if isinstance(prev_wid, BorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
750 #We are on a border, we must create a row and/or columns |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
751 print "BORDER WIDGET" |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
752 prev_wid.removeStyleName('dragover') |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
753 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
754 if isinstance(prev_wid, BottomBorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
755 #We are on the bottom border, we create a new row |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
756 self.flextable.insertRow(last_row) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
757 self.flextable.setWidget(last_row, 0, LeftBorderWidget(self.host)) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
758 self.flextable.setWidget(last_row, 1, wid) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
759 self.flextable.setWidget(last_row, 2, RightBorderWidget(self.host)) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
760 cellFormatter.setHorizontalAlignment(last_row, 2, HasAlignment.ALIGN_RIGHT) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
761 row = last_row |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
762 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
763 elif isinstance(prev_wid, LeftBorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
764 if col!=0: |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
765 print "ERROR: LeftBorderWidget must be on the first column !" |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
766 return |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
767 self.flextable.insertCell(row, col+1) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
768 self.flextable.setWidget(row, 1, wid) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
769 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
770 elif isinstance(prev_wid, RightBorderWidget): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
771 if col!=self.flextable.getCellCount(row)-1: |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
772 print "ERROR: RightBorderWidget must be on the last column !" |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
773 return |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
774 self.flextable.insertCell(row, col) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
775 self.flextable.setWidget(row, col, wid) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
776 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
777 else: |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
778 prev_wid.removeFromParent() |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
779 self.flextable.setWidget(row, col, wid) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
780 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
781 _max_cols = max(self._max_cols, self.flextable.getCellCount(row)) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
782 if _max_cols != self._max_cols: |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
783 self._max_cols = _max_cols |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
784 self._sizesAdjust() |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
785 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
786 def _sizesAdjust(self): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
787 cellFormatter = self.flextable.getFlexCellFormatter() |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
788 width = 100.0/max(1, self._max_cols-2) #we don't count the borders |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
789 |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
790 for row_idx in xrange(self.flextable.getRowCount()): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
791 for col_idx in xrange(self.flextable.getCellCount(row_idx)): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
792 _widget = self.flextable.getWidget(row_idx, col_idx) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
793 if not isinstance(_widget, BorderWidget): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
794 td_elt = _widget.getElement().parentNode |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
795 DOM.setStyleAttribute(td_elt, "width", "%.2f%%" % width) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
796 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
797 last_row = max(0, self.flextable.getRowCount()-1) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
798 cellFormatter.setColSpan(last_row, 0, self._max_cols) |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
799 |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
800 def addWidget(self, wid): |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
801 """Add a widget to a new cell on the next to last row""" |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
802 last_row = max(0, self.flextable.getRowCount()-1) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
803 print "putting widget %s at %d, %d" % (wid, last_row, 0) |
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
804 self.changeWidget(last_row, 0, wid) |
83 | 805 |
86
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
806 def removeWidget(self, wid): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
807 """Remove a widget and the cell where it is""" |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
808 _row, _col = self.flextable.getIndex(wid) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
809 self.flextable.remove(wid) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
810 self.flextable.removeCell(_row, _col) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
811 if self.flextable.getCellCount(_row) == 2: #we have only the borders left, we remove the row |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
812 self.flextable.removeRow(_row) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
813 _max_cols = 1 |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
814 for row_idx in xrange(self.flextable.getRowCount()): |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
815 _max_cols = max(_max_cols, self.flextable.getCellCount(row_idx)) |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
816 if _max_cols != self._max_cols: |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
817 self._max_cols = _max_cols |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
818 self._sizesAdjust() |
6c3b3254605f
browser side: widget removing is now managed
Goffi <goffi@goffi.org>
parents:
85
diff
changeset
|
819 |
90
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
820 def getIndex(self, wid): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
821 return self.flextable.getIndex(wid) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
822 |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
823 def getColSpan(self, row, col): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
824 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
825 return cellFormatter.getColSpan(row, col) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
826 |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
827 def setColSpan(self, row, col, value): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
828 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
829 return cellFormatter.setColSpan(row, col, value) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
830 |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
831 def getRowSpan(self, row, col): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
832 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
833 return cellFormatter.getRowSpan(row, col) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
834 |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
835 def setRowSpan(self, row, col, value): |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
836 cellFormatter = self.flextable.getFlexCellFormatter() |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
837 return cellFormatter.setRowSpan(row, col, value) |
9729ed7171a6
browser side: Widgets' setting (col & row span can be changed
Goffi <goffi@goffi.org>
parents:
89
diff
changeset
|
838 |
34 | 839 class MainDiscussionPanel(HorizontalPanel): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
840 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
841 def __init__(self, host): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
842 self.host=host |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
843 HorizontalPanel.__init__(self) |
27
d89982865c57
browser side: ContactsChooser is now used to ask for 3 others players when tarot game is launched + names refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
844 self._left = self.host.contact_panel |
85
a8f027738c16
browser side: widgets cells can now be added by putting a widget on a border
Goffi <goffi@goffi.org>
parents:
84
diff
changeset
|
845 self._right = WidgetsPanel(host) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
846 self._right.setWidth('100%') |
34 | 847 self._right.setHeight('100%') |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
848 self.add(self._left) |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
849 self.add(self._right) |
83 | 850 self.setCellWidth(self._right, "100%") |
851 | |
852 def addWidget(self, wid): | |
853 """Add a widget to the WidgetsPanel""" | |
854 print "main addWidget", wid | |
855 self._right.addWidget(wid) | |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
856 |
34 | 857 class MainTabPanel(TabPanel): |
23 | 858 |
859 def __init__(self, host): | |
33 | 860 TabPanel.__init__(self) |
23 | 861 self.host=host |
862 self.tabBar.setVisible(False) | |
66
9d8e79ac4c9c
Login/Register box: integration of Adrien Vigneron's design
Goffi <goffi@goffi.org>
parents:
62
diff
changeset
|
863 self.setStyleName('mainTabPanel') |
33 | 864 Window.addWindowResizeListener(self) |
865 | |
866 def onWindowResized(self, width, height): | |
867 tab_panel_elt = self.getElement() | |
868 _elts = doc().getElementsByClassName('gwt-TabBar') | |
869 if not _elts.length: | |
870 print ("ERROR: not TabBar found, it should exist !") | |
871 tab_bar_h = 0 | |
872 else: | |
873 tab_bar_h = _elts.item(0).offsetHeight | |
874 ideal_height = Window.getClientHeight() - tab_panel_elt.offsetTop - tab_bar_h - 5 | |
875 self.setWidth("%s%s" % (width-5, "px")); | |
876 self.setHeight("%s%s" % (ideal_height, "px")); | |
23 | 877 |
878 def add(self, widget, tabText=None, asHTML=False): | |
879 TabPanel.add(self, widget, tabText, asHTML) | |
880 if self.getWidgetCount()>1: | |
881 self.tabBar.setVisible(True) | |
33 | 882 self.host.resize() |
23 | 883 |
33 | 884 class MainPanel(AbsolutePanel): |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
885 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
886 def __init__(self, host): |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
887 self.host=host |
33 | 888 AbsolutePanel.__init__(self) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
889 |
23 | 890 menu = Menu(host) |
33 | 891 unibox_panel = UniBoxPanel(host) |
892 self.host.setUniBox(unibox_panel.unibox) | |
27
d89982865c57
browser side: ContactsChooser is now used to ask for 3 others players when tarot game is launched + names refactoring
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
893 status = host.status_panel |
34 | 894 self.tab_panel = MainTabPanel(host) |
895 self.discuss_panel = MainDiscussionPanel(self.host) | |
23 | 896 self.tab_panel.add(self.discuss_panel, "Discussions") |
897 self.tab_panel.selectTab(0) | |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
898 |
109
5c363b638127
browser side: grouped header panel in a global Absolute panel
Goffi <goffi@goffi.org>
parents:
101
diff
changeset
|
899 header=AbsolutePanel() |
5c363b638127
browser side: grouped header panel in a global Absolute panel
Goffi <goffi@goffi.org>
parents:
101
diff
changeset
|
900 header.add(menu) |
5c363b638127
browser side: grouped header panel in a global Absolute panel
Goffi <goffi@goffi.org>
parents:
101
diff
changeset
|
901 header.add(unibox_panel) |
5c363b638127
browser side: grouped header panel in a global Absolute panel
Goffi <goffi@goffi.org>
parents:
101
diff
changeset
|
902 header.add(status) |
5c363b638127
browser side: grouped header panel in a global Absolute panel
Goffi <goffi@goffi.org>
parents:
101
diff
changeset
|
903 header.setStyleName('header') |
5c363b638127
browser side: grouped header panel in a global Absolute panel
Goffi <goffi@goffi.org>
parents:
101
diff
changeset
|
904 self.add(header) |
23 | 905 self.add(self.tab_panel) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
906 |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
907 self.setWidth("100%") |
33 | 908 Window.addWindowResizeListener(self) |
909 | |
910 def onWindowResized(self, width, height): | |
911 _elts = doc().getElementsByClassName('gwt-TabBar') | |
912 if not _elts.length: | |
913 tab_bar_h = 0 | |
914 else: | |
915 tab_bar_h = _elts.item(0).offsetHeight | |
916 ideal_height = Window.getClientHeight() - tab_bar_h | |
917 self.setHeight("%s%s" % (ideal_height, "px")); | |
918 |