Commits

Henning Schröder committed 6ec1e6d

started work on TGridLayout

Comments (0)

Files changed (1)

             width = col
         self._width = width
         self._height = height
+
+
+class TGridLayout(TLayout):
+
+    class GridFullError(Exception):
+        pass
+
+    def __init__(self, parent=None, **kwargs):
+        self._grid_size = TSize(1, 1)
+        self._grid = {}
+        super(TLayout, self).__init__(parent, **kwargs)
+
+    def gridSize(self):
+        return self._grid_size
+
+    def setGridSize(self, grid_size):
+        self._grid_size = grid_size
+
+    GridSize = Property()
+
+    def _next_empty(self):
+        size = self.gridSize()
+        for row in range(size.height):
+            for col in range(size.width):
+                key = (row, col)
+                if key not in self._grid:
+                    return key
+        raise TGridLayout.GridFullError()
+
+    #def addWidget(self, widget):
+    #    pos = self._next_empty()
+    #    self._grid[pos] = widget
+
+    def addWidget(self, row, col, widget):
+        if row == -1 or col == -1:
+            (row, col) = self._next_empty()
+        self._grid[(row, col)] = widget
+
+    def invalidate(self, start_col=0, start_row=0):
+        size = self.gridSize()
+        for row in range(size.height):
+            for col in range(size.width):
+                pass