Пример #1
0
 def _assign_boxes(self, box):
     if self.fixed:
         all_stacks = self.stack_list
     else:
         all_stacks = [s for s in self.stack_list if not s.empty]
     curw = 0
     if self.vertical:
         rstart = start = box.x
         totalpx = box.width
     else:
         rstart = start = box.y
         totalpx = box.height
     totpx = sum((s.size or s.min_size) for s in all_stacks)
     totw = sum(s.weight for s in all_stacks if s.size is None)
     skip_pixels = totpx > totalpx or (not totw and totpx != totalpx)
     if skip_pixels:
         totw = sum(s.weight for s in all_stacks)
     else:
         totalpx -= sum(s.size for s in all_stacks if s.size is not None)
     pxoff = 0
     for s in all_stacks:
         if s.size is not None and not skip_pixels:
             end = start + s.size
             pxoff += s.size
         else:
             curw += s.weight
             end = rstart + pxoff + int(floor(curw / totw * totalpx))
         if self.vertical:
             s.box = Rectangle(start, box.y, end - start, box.height)
         else:
             s.box = Rectangle(box.x, start, box.width, end - start)
         start = end
Пример #2
0
 def create_window(self):
     self.window = di(self).inject(
         ClientMessageWindow(
             self.xcore.create_toplevel(
                 Rectangle(0, 0, 1, 1),
                 klass=self.xcore.WindowClass.InputOnly,
                 params={}), self.systray_message))
     self.window.show()
     self.dispatcher.register_window(self.window)
     self.xcore.raw.SetSelectionOwner(
         owner=self.window.wid,
         selection=self.xcore.atom._NET_SYSTEM_TRAY_S0,
         time=0,
     )
     self.xcore.send_event('ClientMessage',
                           self.xcore.EventMask.StructureNotify,
                           self.xcore.root_window,
                           window=self.xcore.root_window,
                           type=self.xcore.atom.MANAGER,
                           format=32,
                           data=struct.pack(
                               '<LLL',
                               0,
                               self.xcore.atom._NET_SYSTEM_TRAY_S0,
                               self.window.wid,
                           ))
Пример #3
0
 def layout(self):
     vc = len(self.windows)
     if self.vertical:
         rstart = start = self.box.y
     else:
         rstart = start = self.box.x
     for n, w in enumerate(self.windows, 1):
         if self.vertical:
             end = rstart + int(floor(n / vc * self.box.height))
             w.set_bounds(
                 Rectangle(self.box.x, start, self.box.width, end - start))
         else:
             end = rstart + int(floor(n / vc * self.box.width))
             w.set_bounds(
                 Rectangle(start, self.box.y, end - start, self.box.height))
         w.show()
         start = end
Пример #4
0
 def testOnlyPixels(self, event):
     from tilenol.layout import Split, Stack, TileStack
     class Tile(Split):
         class left(TileStack):
             size = 2
             limit = 1
         class right(TileStack):
             size = 3
     lay = Tile()
     lay.set_bounds(Rectangle(0, 0, 800, 600))
     w1 = self.wmock()
     lay.add(w1)
     w2 = self.wmock()
     lay.add(w2)
     lay.layout()
     w1.set_bounds.assert_called_with(Rectangle(0, 0, 400, 600))
     w2.set_bounds.assert_called_with(Rectangle(400, 0, 400, 600))
Пример #5
0
 def draw(self, canvas, l, r):
     l = int(l)
     r = int(r)
     t = self.padding.top
     h = self.bar.height - self.padding.bottom - t
     if self.right:
         r -= self.padding.right
         for i in reversed(self.icons):
             i.set_bounds(Rectangle(r - h, t, h, h))
             r -= h + self.spacing
         r += self.spacing
         r -= self.padding.left
     else:
         l += self.padding.left
         for i in self.icons:
             i.set_bounds(Rectangle(l, t, h, h))
             l += h + self.spacing
         l -= self.spacing
         l += self.padding.right
     return l, r
Пример #6
0
 def __zorro_di_done__(self):
     wid = self.xcore.create_toplevel(
         Rectangle(0, 0, 1, 1),
         klass=self.xcore.WindowClass.InputOutput,
         params={
             self.xcore.CW.BackPixel: self.theme.menu.background,
             self.xcore.CW.OverrideRedirect: True,
             self.xcore.CW.EventMask: self.xcore.EventMask.Exposure,
         })
     self.window = di(self).inject(DisplayWindow(wid, self.paint))
     self.dispatcher.all_windows[wid] = self.window
     self.window.show()
     if self.screen.group:
         self._group_hook()
     self.commander.events['window'].listen(self._check_redraw)
     Window.any_window_changed.listen(self._check_redraw)
Пример #7
0
 def __zorro_di_done__(self):
     self.window = Window(
         self.xcore.create_toplevel(Rectangle(0, 0, 1, 1),
                                    klass=self.xcore.WindowClass.InputOnly,
                                    params={}))
     di(self).inject(self.window)
     self.xcore.raw.ChangeProperty(
         window=self.xcore.root_window,
         mode=self.xcore.PropMode.Replace,
         property=self.xcore.atom._NET_SUPPORTING_WM_CHECK,
         type=self.xcore.atom.WINDOW,
         format=32,
         data_len=1,
         data=struct.pack('<L', self.window))
     self.window.set_property('_NET_SUPPORTING_WM_CHECK', self.window)
     self.window.set_property('_NET_WM_NAME', 'tilenol')
Пример #8
0
 def testTile(self, event):
     from tilenol.layout.examples import Tile
     lay = Tile()
     lay.set_bounds(Rectangle(0, 0, 800, 600))
     w1 = self.wmock()
     lay.add(w1)
     lay.layout()
     w1.set_bounds.assert_called_with(Rectangle(0, 0, 800, 600))
     w1.reset_mock()
     w2 = self.wmock()
     lay.add(w2)
     lay.layout()
     w1.set_bounds.assert_called_with(Rectangle(0, 0, 600, 600))
     w2.set_bounds.assert_called_with(Rectangle(600, 0, 200, 600))
     w1.reset_mock()
     w2.reset_mock()
     w3 = self.wmock()
     lay.add(w3)
     lay.layout()
     w1.set_bounds.assert_called_with(Rectangle(0, 0, 600, 600))
     w2.set_bounds.assert_called_with(Rectangle(600, 0, 200, 300))
     w3.set_bounds.assert_called_with(Rectangle(600, 300, 200, 300))
Пример #9
0
 def testPixels(self, event):
     from tilenol.layout import Split, Stack, TileStack
     class Tile(Split):
         class left(TileStack):
             size = 128
             limit = 1
         class right(TileStack):
             weight = 2
             min_size = 300
     lay = Tile()
     lay.set_bounds(Rectangle(0, 0, 800, 600))
     w1 = self.wmock()
     lay.add(w1)
     w2 = self.wmock()
     lay.add(w2)
     lay.layout()
     w1.set_bounds.assert_called_with(Rectangle(0, 0, 128, 600))
     w2.set_bounds.assert_called_with(Rectangle(128, 0, 672, 600))
     lay.set_bounds(Rectangle(0, 0, 400, 300))
     lay.layout()
     w1.set_bounds.assert_called_with(Rectangle(0, 0, 133, 300))
     w2.set_bounds.assert_called_with(Rectangle(133, 0, 267, 300))
Пример #10
0
 def __init__(self, parent):
     self.parent = parent
     self.windows = []
     self.box = Rectangle(0, 0, 100, 100)