Mercurial > libervia-backend
annotate frontends/sortilege_old/boxsizer.py @ 802:9007bb133009
core, frontends: XMLUI refactoring:
- XMLUI now use objects with 2 main classes: widgets (button, label, etc), and container which contain widgets according to a layout
- widgets and containers classes are found through introspection, thereby it's really easy to add a new one
- there is still the AddWidgetName helper, for example AddText('jid', 'test@example.net') will add a StringWidget with name "jid" and default value "test@example.net"
- container can be inside other containers. changeContainer change the first parent container
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 04 Feb 2014 18:19:00 +0100 |
parents | 84a6e83157c2 |
children |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
4 # sortilege: a SAT frontend |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
5 # Copyright (C) 2009, 2010, 2011 Jérôme Poisson (goffi@goffi.org) |
0 | 6 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
10 # (at your option) any later version. |
0 | 11 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
15 # GNU Affero General Public License for more details. |
0 | 16 |
609
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
84a6e83157c2
fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents:
588
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0 | 19 |
20 | |
21 from window import Window | |
22 import os,pdb | |
23 | |
588
beaf6bec2fcd
Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
587
diff
changeset
|
24 class BoxSizer(object): |
0 | 25 """This class manage the position of the window like boxes.""" |
26 | |
27 | |
28 | |
29 def __init__(self, parent): | |
30 self.__parent=parent | |
31 self.boxes=[] | |
32 | |
33 | |
34 | |
35 def appendRow(self, win): | |
36 self.boxes.append([win]) | |
37 | |
38 def appendColum(self, index, win): | |
39 if len(self.boxes)<=index: | |
40 #TODO: throw an error here | |
41 return | |
42 self.boxes[index].append(win) | |
43 | |
44 def update(self): | |
45 """Resize boxes""" | |
46 oriY=0 | |
47 visible_row=[] | |
48 for row in self.boxes: | |
49 current_row=[] | |
50 oriX=0 | |
51 for win in row: | |
52 x=win.getOriX() | |
53 y=win.getOriY() | |
54 w=win.getOriWidth() | |
55 h=win.getOriHeight() | |
56 if win.isHidden(): | |
57 if len(current_row)>1 and win is row[-1]: | |
58 #if the last win is hidden, we expand previous visible one | |
59 current_row[-1][2] = current_row[-1][2] + (win.getX() - oriX)+win.getWidth() | |
60 else: | |
61 current_row.append([win, h+y-oriY, w+x-oriX, oriY, oriX]) | |
62 oriX=oriX+w | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
480
diff
changeset
|
63 |
0 | 64 if oriX!=0: |
65 oriY=oriY+h | |
66 visible_row.append(current_row) | |
67 elif visible_row: | |
68 #if all the row is empty, we take the space | |
69 for box in visible_row[-1]: | |
70 box[1]=box[1]+h | |
71 oriY=oriY+h #this only happen if it's not the first visible row | |
72 | |
73 for row in visible_row: | |
74 for win in row: | |
75 win[0].resize(win[1], win[2], win[3], win[4]) |