annotate Lib/lib-stdwin/FormSplit.py @ 6719:faebc1940432 legacy-trunk

Understand -Xlinker option.
author Guido van Rossum <guido@python.org>
date Tue, 02 Dec 1997 20:38:11 +0000
parents 1d06b1499eb9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
195
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # A FormSplit lets you place its children exactly where you want them
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 # (including silly places!).
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # It does no explicit geometry management except moving its children
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # when it is moved.
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 # The interface to place children is as follows.
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 # Before you add a child, you may specify its (left, top) position
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 # relative to the FormSplit. If you don't specify a position for
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 # a child, it goes right below the previous child; the first child
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 # goes to (0, 0) by default.
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 # NB: This places data attributes named form_* on its children.
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 # XXX Yes, I know, there should be options to do all sorts of relative
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 # placement, but for now this will do.
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 from Split import Split
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
531
8331076cfe15 New class syntax.
Guido van Rossum <guido@python.org>
parents: 349
diff changeset
16 class FormSplit(Split):
195
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 #
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 def create(self, parent):
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 self.next_left = self.next_top = 0
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 self.last_child = None
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 return Split.create(self, parent)
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 #
1110
1d06b1499eb9 * Got entirely rid of path.py.
Guido van Rossum <guido@python.org>
parents: 531
diff changeset
23 def getminsize(self, m, sugg_size):
195
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 max_width, max_height = 0, 0
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 for c in self.children:
349
6e5cbd9cd5f9 minsize --> getminsize
Guido van Rossum <guido@python.org>
parents: 195
diff changeset
26 c.form_width, c.form_height = c.getminsize(m, (0, 0))
195
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 max_width = max(max_width, c.form_width + c.form_left)
349
6e5cbd9cd5f9 minsize --> getminsize
Guido van Rossum <guido@python.org>
parents: 195
diff changeset
28 max_height = max(max_height, \
6e5cbd9cd5f9 minsize --> getminsize
Guido van Rossum <guido@python.org>
parents: 195
diff changeset
29 c.form_height + c.form_top)
195
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 return max_width, max_height
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 #
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 def getbounds(self):
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 return self.bounds
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 #
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 def setbounds(self, bounds):
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 self.bounds = bounds
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 fleft, ftop = bounds[0]
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 for c in self.children:
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 left, top = c.form_left + fleft, c.form_top + ftop
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 right, bottom = left + c.form_width, top + c.form_height
1110
1d06b1499eb9 * Got entirely rid of path.py.
Guido van Rossum <guido@python.org>
parents: 531
diff changeset
41 c.setbounds(((left, top), (right, bottom)))
195
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 #
1110
1d06b1499eb9 * Got entirely rid of path.py.
Guido van Rossum <guido@python.org>
parents: 531
diff changeset
43 def placenext(self, left, top):
195
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 self.next_left = left
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 self.next_top = top
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 self.last_child = None
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 #
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 def addchild(self, child):
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 if self.last_child:
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 width, height = \
349
6e5cbd9cd5f9 minsize --> getminsize
Guido van Rossum <guido@python.org>
parents: 195
diff changeset
51 self.last_child.getminsize(self.beginmeasuring(), \
6e5cbd9cd5f9 minsize --> getminsize
Guido van Rossum <guido@python.org>
parents: 195
diff changeset
52 (0, 0))
195
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 self.next_top = self.next_top + height
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 child.form_left = self.next_left
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 child.form_top = self.next_top
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 Split.addchild(self, child)
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 self.last_child = child
45f43f755e5c Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 #