Mercurial > libervia-backend
annotate frontends/sortilege_old/boxsizer.py @ 584:1524c2c07256
Added tag SàT v0.3.0 for changeset df6b9b881f0e
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 09 Jan 2013 22:59:55 +0100 |
parents | 2a072735e459 |
children | 952322b1d490 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 sortilege: a SAT frontend | |
228 | 6 Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org) |
0 | 7 |
8 This program is free software: you can redistribute it and/or modify | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
9 it under the terms of the GNU Affero General Public License as published by |
0 | 10 the Free Software Foundation, either version 3 of the License, or |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
16 GNU Affero General Public License for more details. |
0 | 17 |
480
2a072735e459
Licence modification: the full project is now under AGPL v3+ instead of GPL v3+
Goffi <goffi@goffi.org>
parents:
228
diff
changeset
|
18 You should have received a copy of the GNU Affero General Public License |
0 | 19 along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 """ | |
21 | |
22 | |
23 from window import Window | |
24 import os,pdb | |
25 | |
26 class BoxSizer: | |
27 """This class manage the position of the window like boxes.""" | |
28 | |
29 | |
30 | |
31 def __init__(self, parent): | |
32 self.__parent=parent | |
33 self.boxes=[] | |
34 | |
35 | |
36 | |
37 def appendRow(self, win): | |
38 self.boxes.append([win]) | |
39 | |
40 def appendColum(self, index, win): | |
41 if len(self.boxes)<=index: | |
42 #TODO: throw an error here | |
43 return | |
44 self.boxes[index].append(win) | |
45 | |
46 def update(self): | |
47 """Resize boxes""" | |
48 oriY=0 | |
49 visible_row=[] | |
50 for row in self.boxes: | |
51 current_row=[] | |
52 oriX=0 | |
53 for win in row: | |
54 x=win.getOriX() | |
55 y=win.getOriY() | |
56 w=win.getOriWidth() | |
57 h=win.getOriHeight() | |
58 if win.isHidden(): | |
59 if len(current_row)>1 and win is row[-1]: | |
60 #if the last win is hidden, we expand previous visible one | |
61 current_row[-1][2] = current_row[-1][2] + (win.getX() - oriX)+win.getWidth() | |
62 else: | |
63 current_row.append([win, h+y-oriY, w+x-oriX, oriY, oriX]) | |
64 oriX=oriX+w | |
65 | |
66 if oriX!=0: | |
67 oriY=oriY+h | |
68 visible_row.append(current_row) | |
69 elif visible_row: | |
70 #if all the row is empty, we take the space | |
71 for box in visible_row[-1]: | |
72 box[1]=box[1]+h | |
73 oriY=oriY+h #this only happen if it's not the first visible row | |
74 | |
75 for row in visible_row: | |
76 for win in row: | |
77 win[0].resize(win[1], win[2], win[3], win[4]) |