Mercurial > libervia-backend
comparison frontends/sortilege/boxsizer.py @ 0:c4bc297b82f0
sat:
- first public release, initial commit
author | goffi@necton2 |
---|---|
date | Sat, 29 Aug 2009 13:34:59 +0200 |
parents | |
children | a5b5fb5fc9fd |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c4bc297b82f0 |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 sortilege: a SAT frontend | |
6 Copyright (C) 2009 Jérôme Poisson (goffi@goffi.org) | |
7 | |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
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 | |
16 GNU General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
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 | |
27 def echo(message): | |
28 return | |
29 os.system('echo "'+str(message)+'" >> /tmp/toto') | |
30 | |
31 | |
32 class BoxSizer: | |
33 """This class manage the position of the window like boxes.""" | |
34 | |
35 | |
36 | |
37 def __init__(self, parent): | |
38 self.__parent=parent | |
39 self.boxes=[] | |
40 | |
41 | |
42 | |
43 def appendRow(self, win): | |
44 self.boxes.append([win]) | |
45 | |
46 def appendColum(self, index, win): | |
47 if len(self.boxes)<=index: | |
48 #TODO: throw an error here | |
49 return | |
50 self.boxes[index].append(win) | |
51 | |
52 def update(self): | |
53 """Resize boxes""" | |
54 oriY=0 | |
55 visible_row=[] | |
56 for row in self.boxes: | |
57 current_row=[] | |
58 oriX=0 | |
59 for win in row: | |
60 x=win.getOriX() | |
61 y=win.getOriY() | |
62 w=win.getOriWidth() | |
63 h=win.getOriHeight() | |
64 if win.isHidden(): | |
65 if len(current_row)>1 and win is row[-1]: | |
66 #if the last win is hidden, we expand previous visible one | |
67 current_row[-1][2] = current_row[-1][2] + (win.getX() - oriX)+win.getWidth() | |
68 else: | |
69 echo ("ajout de %s à current row" % (win.__class__.__name__)) | |
70 current_row.append([win, h+y-oriY, w+x-oriX, oriY, oriX]) | |
71 oriX=oriX+w | |
72 | |
73 if oriX!=0: | |
74 echo ("ligne visible (dernier: %s)" % win.__class__.__name__) | |
75 oriY=oriY+h | |
76 visible_row.append(current_row) | |
77 elif visible_row: | |
78 #if all the row is empty, we take the space | |
79 for box in visible_row[-1]: | |
80 echo ("on augmente %s de %d" % (box[0].__class__.__name__, h)) | |
81 box[1]=box[1]+h | |
82 oriY=oriY+h #this only happen if it's not the first visible row | |
83 else: | |
84 echo ("ligne invisible") | |
85 | |
86 for row in visible_row: | |
87 for win in row: | |
88 win[0].resize(win[1], win[2], win[3], win[4]) |