annotate frontends/sortilege_old/boxsizer.py @ 668:7bb50096d225

plugin XEP_0071: first draft a new "xhtml" key is added in bridge newMessage's extra data when rich text is found.
author Goffi <goffi@goffi.org>
date Tue, 05 Nov 2013 22:41:45 +0100
parents 84a6e83157c2
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
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
goffi@necton2
parents:
diff changeset
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
goffi@necton2
parents:
diff changeset
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
goffi@necton2
parents:
diff changeset
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
goffi@necton2
parents:
diff changeset
19
goffi@necton2
parents:
diff changeset
20
goffi@necton2
parents:
diff changeset
21 from window import Window
goffi@necton2
parents:
diff changeset
22 import os,pdb
goffi@necton2
parents:
diff changeset
23
588
beaf6bec2fcd Remove every old-style class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 587
diff changeset
24 class BoxSizer(object):
0
goffi@necton2
parents:
diff changeset
25 """This class manage the position of the window like boxes."""
goffi@necton2
parents:
diff changeset
26
goffi@necton2
parents:
diff changeset
27
goffi@necton2
parents:
diff changeset
28
goffi@necton2
parents:
diff changeset
29 def __init__(self, parent):
goffi@necton2
parents:
diff changeset
30 self.__parent=parent
goffi@necton2
parents:
diff changeset
31 self.boxes=[]
goffi@necton2
parents:
diff changeset
32
goffi@necton2
parents:
diff changeset
33
goffi@necton2
parents:
diff changeset
34
goffi@necton2
parents:
diff changeset
35 def appendRow(self, win):
goffi@necton2
parents:
diff changeset
36 self.boxes.append([win])
goffi@necton2
parents:
diff changeset
37
goffi@necton2
parents:
diff changeset
38 def appendColum(self, index, win):
goffi@necton2
parents:
diff changeset
39 if len(self.boxes)<=index:
goffi@necton2
parents:
diff changeset
40 #TODO: throw an error here
goffi@necton2
parents:
diff changeset
41 return
goffi@necton2
parents:
diff changeset
42 self.boxes[index].append(win)
goffi@necton2
parents:
diff changeset
43
goffi@necton2
parents:
diff changeset
44 def update(self):
goffi@necton2
parents:
diff changeset
45 """Resize boxes"""
goffi@necton2
parents:
diff changeset
46 oriY=0
goffi@necton2
parents:
diff changeset
47 visible_row=[]
goffi@necton2
parents:
diff changeset
48 for row in self.boxes:
goffi@necton2
parents:
diff changeset
49 current_row=[]
goffi@necton2
parents:
diff changeset
50 oriX=0
goffi@necton2
parents:
diff changeset
51 for win in row:
goffi@necton2
parents:
diff changeset
52 x=win.getOriX()
goffi@necton2
parents:
diff changeset
53 y=win.getOriY()
goffi@necton2
parents:
diff changeset
54 w=win.getOriWidth()
goffi@necton2
parents:
diff changeset
55 h=win.getOriHeight()
goffi@necton2
parents:
diff changeset
56 if win.isHidden():
goffi@necton2
parents:
diff changeset
57 if len(current_row)>1 and win is row[-1]:
goffi@necton2
parents:
diff changeset
58 #if the last win is hidden, we expand previous visible one
goffi@necton2
parents:
diff changeset
59 current_row[-1][2] = current_row[-1][2] + (win.getX() - oriX)+win.getWidth()
goffi@necton2
parents:
diff changeset
60 else:
goffi@necton2
parents:
diff changeset
61 current_row.append([win, h+y-oriY, w+x-oriX, oriY, oriX])
goffi@necton2
parents:
diff changeset
62 oriX=oriX+w
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 480
diff changeset
63
0
goffi@necton2
parents:
diff changeset
64 if oriX!=0:
goffi@necton2
parents:
diff changeset
65 oriY=oriY+h
goffi@necton2
parents:
diff changeset
66 visible_row.append(current_row)
goffi@necton2
parents:
diff changeset
67 elif visible_row:
goffi@necton2
parents:
diff changeset
68 #if all the row is empty, we take the space
goffi@necton2
parents:
diff changeset
69 for box in visible_row[-1]:
goffi@necton2
parents:
diff changeset
70 box[1]=box[1]+h
goffi@necton2
parents:
diff changeset
71 oriY=oriY+h #this only happen if it's not the first visible row
goffi@necton2
parents:
diff changeset
72
goffi@necton2
parents:
diff changeset
73 for row in visible_row:
goffi@necton2
parents:
diff changeset
74 for win in row:
goffi@necton2
parents:
diff changeset
75 win[0].resize(win[1], win[2], win[3], win[4])