annotate frontends/sortilege/boxsizer.py @ 70:8f2ed279784b

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