changeset 23:0ce2a57b34ca

added tab panel
author Goffi <goffi@goffi.org>
date Wed, 20 Apr 2011 02:47:22 +0200
parents 586f69e85559
children 28e203f13144
files browser_side/panels.py libervia.py public/libervia.css
diffstat 3 files changed, 87 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/panels.py	Sun Apr 17 00:38:33 2011 +0200
+++ b/browser_side/panels.py	Wed Apr 20 02:47:22 2011 +0200
@@ -24,6 +24,7 @@
 from pyjamas.ui.VerticalPanel import VerticalPanel
 from pyjamas.ui.HorizontalPanel import HorizontalPanel
 from pyjamas.ui.ScrollPanel import ScrollPanel
+from pyjamas.ui.TabPanel import TabPanel
 from pyjamas.ui.HTMLPanel import HTMLPanel
 from pyjamas.ui.Grid import Grid
 from pyjamas.ui.MenuBar import MenuBar
@@ -53,7 +54,8 @@
 
 class Menu(SimplePanel):
 
-    def __init__(self):
+    def __init__(self, host):
+        self.host = host
         SimplePanel.__init__(self)
 
         menu_general = MenuBar(vertical=True)
@@ -72,7 +74,8 @@
         Window.alert("Properties selected")
 
     def onTarotGame(self):
-        Window.alert("Tarot selected")
+        #Window.alert("Tarot selected")
+        self.host.tab_panel.add(EmptyPanel(self.host), "Tarot")
 
     def onXiangqiGame(self):
         Window.alert("Xiangqi selected")
@@ -298,7 +301,7 @@
             return"""
         self.content.add(ChatText(timestamp, nick, mymess, msg))
 
-class MiddlePannel(HorizontalPanel):
+class MainDiscussionPannel(HorizontalPanel):
     
     def __init__(self, host):
         self.host=host
@@ -316,6 +319,18 @@
     def changePanel(self, idx, panel):
         self._right.setWidget(0,idx,panel)
 
+class MainTabPannel(TabPanel):
+
+    def __init__(self, host):
+        self.host=host
+        TabPanel.__init__(self)
+        self.tabBar.setVisible(False)
+
+    def add(self, widget, tabText=None, asHTML=False):
+        TabPanel.add(self, widget, tabText, asHTML)
+        if self.getWidgetCount()>1:
+            self.tabBar.setVisible(True)
+        
 class MainPanel(VerticalPanel):
 
     def __init__(self, host):
@@ -325,23 +340,29 @@
         self.setHorizontalAlignment(HasAlignment.ALIGN_LEFT)
         self.setVerticalAlignment(HasAlignment.ALIGN_TOP)
 
-        menu = Menu()
+        menu = Menu(host)
         uni_box = host.uniBox
         status = host.statusPanel
-        self.middle_panel = MiddlePannel(self.host)
-        self.middle_panel.setWidth('100%')
+        self.tab_panel = MainTabPannel(self)
+        self.tab_panel.setWidth('100%')
+        self.tab_panel.setHeight('100%')
+        self.discuss_panel = MainDiscussionPannel(self.host)
+        self.discuss_panel.setWidth('100%')
+        self.discuss_panel.setHeight('100%')
+        self.tab_panel.add(self.discuss_panel, "Discussions")
+        self.tab_panel.selectTab(0)
 
         self.add(menu)
         self.add(uni_box)
         self.add(status)
-        self.add(self.middle_panel)
+        self.add(self.tab_panel)
         
         self.setCellHeight(menu, "5%")
         self.setCellHeight(uni_box, "5%")
         self.setCellVerticalAlignment(uni_box, HasAlignment.ALIGN_CENTER)
         self.setCellHorizontalAlignment(uni_box, HasAlignment.ALIGN_CENTER)
-        self.setCellHeight(self.middle_panel, "90%")
-        self.setCellWidth(self.middle_panel, "100%")
+        self.setCellHeight(self.tab_panel, "90%")
+        self.setCellWidth(self.tab_panel, "100%")
 
         self.setWidth("100%")
         self.setHeight("100%")
--- a/libervia.py	Sun Apr 17 00:38:33 2011 +0200
+++ b/libervia.py	Wed Apr 20 02:47:22 2011 +0200
@@ -124,8 +124,8 @@
     def _timeCb(self, timer):
         if self._popup:
             self._popup.hide()
-        del self._popup
-        self._popup = None
+            del self._popup
+            self._popup = None
 
     def _getTarget(self, txt):
         """Say who will receive the messsage
@@ -160,8 +160,7 @@
         else:
             _target = self._getTarget(_txt)
             if _target != self._popup.target_data:
-                self._popup.hide()
-                del self._popup
+                self._timeCb(None) #we remove the popup
                 self.showWarning(_target)
 
         self._timer.schedule(2000)
@@ -176,6 +175,7 @@
                     _chat = self.host.selected
                     self.host.bridge.call('sendMessage', None, str(_chat.target), _txt, '', 'chat')
             self.setText('')
+            self._timeCb(None) #we remove the popup
 
     def complete(self):
         #self.visible=False #XXX: self.visible is not unset in pyjamas when ENTER is pressed and a completion is done
@@ -194,11 +194,12 @@
         self.statusPanel = StatusPanel(self)
         self.contactPanel = ContactPanel(self)
         self.panel = MainPanel(self)
-        self.middle_panel = self.panel.middle_panel
+        self.discuss_panel = self.panel.discuss_panel
+        self.tab_panel = self.panel.tab_panel 
         self.mpanels = [EmptyPanel(self), MicroblogPanel(self, accept_all=True), EmptyPanel(self)]
-        self.middle_panel.changePanel(0,self.mpanels[0])
-        self.middle_panel.changePanel(1,self.mpanels[1])
-        self.middle_panel.changePanel(2,self.mpanels[2])
+        self.discuss_panel.changePanel(0,self.mpanels[0])
+        self.discuss_panel.changePanel(1,self.mpanels[1])
+        self.discuss_panel.changePanel(2,self.mpanels[2])
         self._dialog = None
         RootPanel().add(self.panel)
         self._register = RegisterCall()
--- a/public/libervia.css	Sun Apr 17 00:38:33 2011 +0200
+++ b/public/libervia.css	Wed Apr 20 02:47:22 2011 +0200
@@ -178,6 +178,7 @@
 .microblogPanel {
     margin: auto;
     width: 90%;
+    overflow: scroll;
 }
 
 .mb_panel_header{
@@ -222,6 +223,10 @@
 
 /* Chat */
 
+.chatPanel {
+    overflow: scroll;
+}
+
 .chatText {
   /* font-size: smaller; */
 }
@@ -273,6 +278,49 @@
 .targetStatus {
 }
 
+/* Tab panel */
+ .gwt-TabPanel {
+        }
+
+.gwt-TabPanelBottom {
+    height: 100%;
+}
+
+.gwt-TabBar {
+  /*background-color: #C3D9FF;*/
+  position: fixed;
+  bottom: 0;
+  font-size: small;
+}
+
+.gwt-TabBar .gwt-TabBarFirst {
+  height: 100%;
+  padding-left: 3px;
+}
+
+.gwt-TabBar .gwt-TabBarRest {
+  padding-right: 3px;
+}
+
+.gwt-TabBar .gwt-TabBarItem {
+  border-top: 1px solid #C3D9FF;
+  border-bottom: 1px solid #C3D9FF;
+  padding: 2px;
+  cursor: pointer;
+}
+
+.gwt-TabBar .gwt-TabBarItem-selected {
+  font-weight: bold;
+  background-color: #E8EEF7;
+  border-top: 1px solid #87B3FF;
+  border-left: 1px solid #87B3FF;
+  border-right: 1px solid #87B3FF;
+  border-bottom: 1px solid #E8EEF7;
+  padding: 2px;
+  cursor: default;
+}
+
+
 /* Misc */
 
 .selected_widget {