diff browser_side/panels.py @ 90:9729ed7171a6

browser side: Widgets' setting (col & row span can be changed
author Goffi <goffi@goffi.org>
date Tue, 28 Jun 2011 01:54:36 +0200
parents 8d2c7be09eef
children dd54bc13ac81
line wrap: on
line diff
--- a/browser_side/panels.py	Mon Jun 27 20:10:29 2011 +0200
+++ b/browser_side/panels.py	Tue Jun 28 01:54:36 2011 +0200
@@ -167,17 +167,38 @@
         if self.__selectable:
             self.addClickListener(self)
         self.host.registerWidget(self)
+
+    def _getWidgetsPanel(self):
+        return self.getParent().getParent().getParent() 
     
     def onClick(self, sender):
         self.host.select(self)
 
     def onClose(self, sender):
         print "onClose:", sender
-        _widgetspanel = self.getParent().getParent().getParent()
+        _widgetspanel = self._getWidgetsPanel()
         _widgetspanel.removeWidget(self)
 
     def onSetting(self, sender):
-        Window.alert('settings')
+        widpanel = self._getWidgetsPanel()
+        row, col = widpanel.getIndex(self)
+        body = VerticalPanel()
+        colspan = widpanel.getColSpan(row, col)
+        rowspan = widpanel.getRowSpan(row, col)
+        def onColSpanChange(value):
+            widpanel.setColSpan(row, col, value) 
+        def onRowSpanChange(value):
+            widpanel.setRowSpan(row, col, value) 
+        colspan_setter = dialog.IntSetter("Columns span", colspan)
+        colspan_setter.addValueChangeListener(onColSpanChange)
+        colspan_setter.setWidth('100%')
+        rowspan_setter = dialog.IntSetter("Rows span", rowspan)
+        rowspan_setter.addValueChangeListener(onRowSpanChange)
+        rowspan_setter.setWidth('100%')
+        body.add(colspan_setter)
+        body.add(rowspan_setter)
+        _dialog = dialog.GenericDialog("Widget setting", body)
+        _dialog.show()
 
     def setTitle(self, text):
         """change the title in the header of the widget
@@ -750,6 +771,25 @@
             self._max_cols = _max_cols
             self._sizesAdjust()
 
+    def getIndex(self, wid):
+        return self.flextable.getIndex(wid)
+
+    def getColSpan(self, row, col):
+        cellFormatter = self.flextable.getFlexCellFormatter()
+        return cellFormatter.getColSpan(row, col)
+    
+    def setColSpan(self, row, col, value):
+        cellFormatter = self.flextable.getFlexCellFormatter()
+        return cellFormatter.setColSpan(row, col, value)
+    
+    def getRowSpan(self, row, col):
+        cellFormatter = self.flextable.getFlexCellFormatter()
+        return cellFormatter.getRowSpan(row, col)
+    
+    def setRowSpan(self, row, col, value):
+        cellFormatter = self.flextable.getFlexCellFormatter()
+        return cellFormatter.setRowSpan(row, col, value)
+
 class MainDiscussionPanel(HorizontalPanel):
     
     def __init__(self, host):