author | Claus Gittinger <cg@exept.de> |
Fri, 15 Jun 2018 10:54:35 +0200 | |
changeset 5816 | 7876c07931a7 |
parent 5634 | 9fb149cbc61e |
child 5946 | 454fc5b536b1 |
permissions | -rw-r--r-- |
790 | 1 |
" |
2 |
COPYRIGHT (c) 1998 by Andreas Vogel / eXept Software AG |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1877
3b415fa4710f
only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents:
1519
diff
changeset
|
12 |
"{ Package: 'stx:libwidg2' }" |
3b415fa4710f
only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents:
1519
diff
changeset
|
13 |
|
5303 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
721 | 16 |
PanelView subclass:#GridBagLayoutView |
17 |
instanceVariableNames:'columnWidths rowHeights columnWeights rowWeights layoutInfo' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Layout' |
|
21 |
! |
|
22 |
||
23 |
!GridBagLayoutView class methodsFor:'documentation'! |
|
24 |
||
790 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1998 by Andreas Vogel / eXept Software AG |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
||
38 |
||
39 |
||
40 |
! |
|
41 |
||
721 | 42 |
documentation |
43 |
" |
|
44 |
GridBagLayout is a flexible layout manager that aligns components vertically and horizontally, |
|
45 |
without requiring that the components be the same size. Each GridBagLayout uses a dynamic rectangular |
|
46 |
grid of cells, with each component occupying one or more cells (called its display area). |
|
47 |
Each component managed by a GridBagLayout is associated with a GridBagConstraints instance that |
|
48 |
specifies how the component is laid out within its display area. How a GridBagLayout places a set of |
|
49 |
components depends on each component's GridBagConstraints and minimum size, as well as the preferred |
|
50 |
size of the components' container. |
|
51 |
||
52 |
To use a GridBagLayout effectively, you must customize one or more of its components' GridBagConstraints. |
|
53 |
You customize a GridBagConstraints object by setting one or more of its instance variables: |
|
54 |
||
55 |
gridX |
|
56 |
gridY |
|
57 |
Specifies the cell at the upper left of the component's display area, where the |
|
58 |
upper-left-most cell has address gridX=0, gridY=0. Use #RELATIVE (the default value) |
|
59 |
to specify that the component be just placed just to the right of (for gridX) |
|
60 |
or just below (for gridY) the component that was added to the container just before |
|
61 |
this component was added. |
|
62 |
||
63 |
gridWidth |
|
64 |
gridHeight |
|
65 |
Specifies the number of cells in a row (for gridWidth) or column (for gridHeight) |
|
66 |
in the component's display area. The default value is 1. Use #REMAINDER to specify |
|
67 |
that the component be the last one in its row (for gridWidth) or column (for gridHeight). |
|
68 |
Use #RELATIVE to specify that the component be the next to last one in its row |
|
69 |
(for gridWidth) or column (for gridHeight). |
|
70 |
||
71 |
fill |
|
72 |
Used when the component's display area is larger than the component's requested size |
|
73 |
to determine whether (and how) to resize the component. |
|
74 |
Valid values are |
|
75 |
#NONE |
|
76 |
(the default), |
|
77 |
#HORIZONTAL |
|
78 |
(make the component wide enough to fill its display area |
|
79 |
horizontally, but don't change its height), |
|
80 |
#VERTICAL |
|
81 |
(make the component tall enough to fill its display area |
|
82 |
vertically, but don't change its width), and |
|
83 |
#BOTH |
|
84 |
(make the component fill its display area entirely). |
|
85 |
||
86 |
ipadX |
|
87 |
ipadY |
|
88 |
Specifies the internal padding: how much to add to the minimum size of the component. |
|
89 |
The width of the component will be at least its minimum width plus ipadX*2 pixels |
|
90 |
(since the padding applies to both sides of the component). Similarly, the height of |
|
91 |
the component will be at least the minimum height plus ipadY*2 pixels. |
|
92 |
||
93 |
insets |
|
94 |
Specifies the external padding of the component -- the minimum amount of space between |
|
95 |
the component and the edges of its display area. |
|
96 |
||
97 |
anchor |
|
98 |
Used when the component is smaller than its display area to determine where (within the area) |
|
99 |
to place the component. |
|
100 |
Valid values are |
|
101 |
#CENTER (the default), |
|
102 |
#NORTH, |
|
103 |
#NORTHEAST, |
|
104 |
#EAST, |
|
105 |
#SOUTHEAST, |
|
106 |
#SOUTH, |
|
107 |
#SOUTHWEST, |
|
108 |
#WEST, |
|
109 |
#NORTHWEST. |
|
110 |
||
111 |
weightX |
|
112 |
weightY |
|
113 |
Used to determine how to distribute space; this is important for specifying resizing |
|
114 |
behavior. Unless you specify a weight for at least one component in a row (weightX) |
|
115 |
and column (weightY), all the components clump together in the center of their container. |
|
116 |
This is because when the weight is zero (the default), the GridBagLayout puts any extra |
|
117 |
space between its grid of cells and the edges of the container. |
|
118 |
||
119 |
||
120 |
[see also:] |
|
121 |
GridBagConstraints |
|
122 |
GridBagLayoutInfo |
|
123 |
Insets |
|
124 |
||
125 |
[author:] |
|
126 |
Andreas Vogel |
|
127 |
" |
|
128 |
! |
|
129 |
||
130 |
examples |
|
131 |
" |
|
132 |
This example is taken from the java source and should produce the same layout. Check the file |
|
133 |
Grid*.gif in the java distribution. |
|
134 |
||
135 |
[exBegin] |
|
136 |
| v p c | |
|
137 |
c := #( |
|
138 |
#( fill: #BOTH weightX: 1.0 ) |
|
139 |
#( fill: #BOTH weightX: 1.0 ) |
|
140 |
#( fill: #BOTH weightX: 1.0 ) |
|
141 |
#( fill: #BOTH weightX: 1.0 gridWidth: #REMAINDER ) |
|
142 |
#( fill: #BOTH gridWidth: #REMAINDER ) |
|
143 |
#( fill: #BOTH gridWidth: #RELATIVE ) |
|
144 |
#( fill: #BOTH gridWidth: #REMAINDER ) |
|
145 |
#( fill: #BOTH weightY: 1.0 gridHeight: 2 ) |
|
146 |
#( fill: #BOTH gridWidth: #REMAINDER ) |
|
147 |
#( fill: #BOTH gridWidth: #REMAINDER ) |
|
148 |
). |
|
149 |
v := StandardSystemView new. v label:'GridBagLayoutView: Example 1'. |
|
150 |
p := GridBagLayoutView in:v. p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
151 |
1 to: c size do:[ :i | | b | |
|
152 |
b := Button label:('Button ',(i displayString)) in:p. |
|
153 |
b objectAttributeAt:#GridBagConstraints put:((#(GridBagConstraints) , (c at:i)) decodeAsLiteralArray). |
|
154 |
]. |
|
155 |
v extent:(p preferredExtent). v open. |
|
156 |
[exEnd] |
|
157 |
||
158 |
||
159 |
[exBegin] |
|
160 |
| v p c | |
|
161 |
c := #( |
|
162 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 ) |
|
163 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 ) |
|
164 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 ) |
|
165 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH weightX: 1.0 gridWidth: #REMAINDER ) |
|
166 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER ) |
|
167 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #RELATIVE ) |
|
168 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER ) |
|
169 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH weightY: 1.0 gridHeight: 2 ) |
|
170 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER ) |
|
171 |
#( insets: #(Insets 2 2 2 2) fill: #BOTH gridWidth: #REMAINDER ) |
|
172 |
). |
|
173 |
v := StandardSystemView new. v label:'GridBagLayoutView: Example 2'. |
|
174 |
p := GridBagLayoutView in:v. p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0). |
|
175 |
1 to: c size do:[ :i | | b | |
|
176 |
b := Button label:('Button ',(i displayString)) in:p. |
|
177 |
b objectAttributeAt:#GridBagConstraints put:((#(GridBagConstraints) , (c at:i)) decodeAsLiteralArray). |
|
178 |
]. |
|
179 |
v extent:(p preferredExtent). v open. |
|
180 |
[exEnd] |
|
181 |
||
182 |
||
183 |
||
184 |
" |
|
185 |
! ! |
|
186 |
||
187 |
!GridBagLayoutView class methodsFor:'instance creation'! |
|
188 |
||
189 |
new |
|
190 |
"Create a new instance of my class and do explizit initialization of it." |
|
191 |
||
2840 | 192 |
^ self basicNew initialize |
721 | 193 |
|
194 |
"Created: / 19.1.1998 / 13:53:11 / av" |
|
195 |
"Modified: / 1.2.1998 / 13:02:59 / av" |
|
196 |
! ! |
|
197 |
||
2840 | 198 |
!GridBagLayoutView methodsFor:'initialization'! |
199 |
||
200 |
initialize |
|
201 |
"Initialize the instance. Mainly set our instance variables to required values." |
|
202 |
||
203 |
super initialize. |
|
204 |
||
205 |
columnWidths := IdentityDictionaryWithDefault newWithDefaultValue:0. |
|
206 |
rowHeights := IdentityDictionaryWithDefault newWithDefaultValue:0. |
|
207 |
||
208 |
columnWeights := IdentityDictionaryWithDefault newWithDefaultValue:0.0. |
|
209 |
rowWeights := IdentityDictionaryWithDefault newWithDefaultValue:0.0. |
|
210 |
||
211 |
layoutInfo := nil. |
|
212 |
||
213 |
"Created: / 19.1.1998 / 13:53:59 / av" |
|
214 |
"Modified: / 1.2.1998 / 12:57:05 / av" |
|
215 |
! ! |
|
216 |
||
721 | 217 |
!GridBagLayoutView methodsFor:'layout'! |
218 |
||
219 |
setChildPositions |
|
5634 | 220 |
"(re)compute position of every child whenever children are added or my size has changed" |
721 | 221 |
|
222 |
self arrangeGrid. |
|
223 |
||
5634 | 224 |
"Modified: / 01-02-1998 / 12:52:22 / av" |
225 |
"Modified (comment): / 09-11-2017 / 10:43:16 / mawalch" |
|
721 | 226 |
! ! |
227 |
||
228 |
!GridBagLayoutView methodsFor:'private'! |
|
229 |
||
230 |
adjustForGravity:c in:r |
|
231 |
||
5303 | 232 |
|insets fill anchor diffx diffy add | |
721 | 233 |
|
5303 | 234 |
insets := c insets. |
235 |
fill := c fill. |
|
236 |
anchor := c anchor. |
|
237 |
||
238 |
r setLeft: ((r left) + (insets left)). |
|
239 |
r width: ((r width) - ((insets left) + (insets right))). |
|
240 |
r setTop: ((r top) + (insets top)). |
|
241 |
r height: ((r height) - ((insets top) + (insets bottom))). |
|
721 | 242 |
|
243 |
diffx := 0. |
|
5303 | 244 |
(fill ~~ #HORIZONTAL and:[(fill ~~ #BOTH) and:[(r width) > (add := (c minWidth) + (c ipadX))]]) ifTrue:[ |
245 |
diffx := (r width) - add. |
|
246 |
r width:add. |
|
721 | 247 |
]. |
248 |
||
249 |
diffy := 0. |
|
5303 | 250 |
(fill ~~ #VERTICAL and:[(fill ~~ #BOTH) and:[(r height) > (add := (c minHeight) + (c ipadY))]]) ifTrue:[ |
251 |
diffy := (r height) - add. |
|
252 |
r height:add. |
|
721 | 253 |
]. |
254 |
||
5303 | 255 |
(anchor == #CENTER) ifTrue:[ |
256 |
r setLeft:((r left) + (diffx / 2)). |
|
257 |
r setTop:((r top) + (diffy / 2)). |
|
721 | 258 |
]. |
5303 | 259 |
(anchor == #NORTH) ifTrue:[ |
260 |
r setLeft:((r left) + (diffx / 2)). |
|
721 | 261 |
]. |
5303 | 262 |
(anchor == #NORTHEAST) ifTrue:[ |
263 |
r setLeft:((r left) + diffx). |
|
721 | 264 |
]. |
5303 | 265 |
(anchor == #EAST) ifTrue:[ |
266 |
r setLeft:((r left) + diffx). |
|
267 |
r setTop:((r top) + (diffy / 2)). |
|
721 | 268 |
]. |
5303 | 269 |
(anchor == #SOUTHEAST) ifTrue:[ |
270 |
r setLeft:((r left) + diffx). |
|
271 |
r setTop:((r top) + diffy). |
|
721 | 272 |
]. |
5303 | 273 |
(anchor == #SOUTH) ifTrue:[ |
274 |
r setLeft:((r left) + (diffx / 2)). |
|
275 |
r setTop:((r top) + diffy). |
|
721 | 276 |
]. |
5303 | 277 |
(anchor == #SOUTHWEST) ifTrue:[ |
278 |
r setTop:((r top) + diffy). |
|
721 | 279 |
]. |
5303 | 280 |
(anchor == #WEST) ifTrue:[ |
281 |
r setTop:((r top) + (diffy / 2)). |
|
721 | 282 |
]. |
5303 | 283 |
(anchor == #NORTHWEST) ifTrue:[ |
721 | 284 |
]. |
285 |
||
286 |
r setLeft: ((r left) asInteger). |
|
287 |
r setTop: ((r top) asInteger). |
|
288 |
r width: ((r width) asInteger). |
|
289 |
r height: ((r height) asInteger). |
|
290 |
||
291 |
^ r |
|
292 |
||
293 |
"Modified: / 22.1.1998 / 09:50:01 / av" |
|
294 |
! |
|
295 |
||
296 |
arrangeGrid |
|
297 |
" Lay out the grid." |
|
298 |
||
299 |
| insets subViews info ext d r c diffw diffh weight | |
|
300 |
||
301 |
insets := Insets new. |
|
302 |
||
303 |
"/ If the parent has no slaves anymore, then don't do anything |
|
304 |
"/ at all: just leave the parent's size as-is. |
|
305 |
(((subViews := self subViews) size) == 0) ifTrue:[^ self]. |
|
306 |
||
3245 | 307 |
"/ self extentChangedFlag ifTrue:[ |
308 |
"/ ext := self computeExtent. |
|
309 |
"/ width := ext x. |
|
310 |
"/ height := ext y. |
|
311 |
"/ ]. |
|
721 | 312 |
|
313 |
"/ Pass #1: scan all the slaves to figure out the total amount |
|
314 |
"/ of space needed. |
|
315 |
||
316 |
info := self getLayoutInfo:#PREFERRED_SIZE. |
|
317 |
d := self getMinSize:info. |
|
318 |
||
319 |
((width < (d width)) or:[(height < (d height))]) ifTrue:[ |
|
1519 | 320 |
info := self getLayoutInfo:#MINIMUM_SIZE. |
321 |
d := self getMinSize:info. |
|
721 | 322 |
]. |
323 |
||
324 |
layoutInfo := info. |
|
325 |
r := Rectangle origin:0@0 extent:((d width) @ (d height)). |
|
326 |
||
327 |
"/ If the current dimensions of the window don't match the desired |
|
328 |
"/ dimensions, then adjust the minWidth and minHeight arrays |
|
329 |
"/ according to the weights. |
|
330 |
||
331 |
diffw := width - (r width). |
|
332 |
(diffw ~~ 0) ifTrue:[ |
|
1519 | 333 |
weight := 0.0. |
334 |
0 to:((info width) - 1) do:[ :i | |
|
335 |
weight := weight + ((info weightX) at:(i + 1)). |
|
336 |
]. |
|
337 |
(weight > 0.0) ifTrue:[ |
|
338 |
0 to:((info width) - 1) do:[ :i | |
|
339 |
| dx | |
|
340 |
dx := ((diffw * ((info weightX) at:(i + 1))) / weight) asInteger. |
|
341 |
(info minWidth) at:(i + 1) put:(((info minWidth) at:(i + 1)) + dx). |
|
342 |
r width:((r width) + dx). |
|
343 |
(((info minWidth) at:(i + 1)) < 0) ifTrue:[ |
|
344 |
r width:((r width) - ((info minWidth) at:(i + 1))). |
|
345 |
(info minWidth) at:(i + 1) put:0. |
|
346 |
]. |
|
347 |
]. |
|
348 |
]. |
|
349 |
diffw := width - (r width). |
|
721 | 350 |
] ifFalse:[ |
1519 | 351 |
diffw := 0. |
721 | 352 |
]. |
353 |
||
354 |
diffh := height - (r height). |
|
355 |
(diffh ~~ 0) ifTrue:[ |
|
1519 | 356 |
weight := 0.0. |
357 |
0 to:((info height) - 1) do:[ :i | |
|
358 |
weight := weight + ((info weightY) at:(i + 1)). |
|
359 |
]. |
|
360 |
(weight > 0.0) ifTrue:[ |
|
361 |
0 to:((info height) - 1) do:[ :i | |
|
362 |
| dy | |
|
363 |
dy := ((diffh * ((info weightY) at:(i + 1))) / weight) asInteger. |
|
364 |
(info minHeight) at:(i + 1) put:(((info minHeight) at:(i + 1)) + dy). |
|
365 |
r height:((r height) + dy). |
|
366 |
(((info minHeight) at:(i + 1)) < 0) ifTrue:[ |
|
367 |
r height:((r height) - ((info minHeight) at:(i + 1))). |
|
368 |
(info minHeight) at:(i + 1) put:0. |
|
369 |
]. |
|
370 |
]. |
|
371 |
]. |
|
372 |
diffh := height - (r height). |
|
721 | 373 |
] ifFalse:[ |
1519 | 374 |
diffh := 0. |
721 | 375 |
]. |
376 |
||
377 |
"/ Now do the actual layout of the slaves using the layout information |
|
378 |
"/ that has been collected. |
|
379 |
||
380 |
info startX:(((diffw / 2) + (insets left)) asInteger). |
|
381 |
info startY:(((diffh / 2) + (insets top)) asInteger). |
|
382 |
||
383 |
subViews do:[ :child | |
|
2955 | 384 |
|rW rH minWidth minHeight| |
721 | 385 |
|
1519 | 386 |
c := self constraints:child. |
2955 | 387 |
minWidth := info minWidth. |
388 |
minHeight := info minHeight. |
|
1519 | 389 |
|
390 |
r setLeft:(info startX). |
|
2955 | 391 |
0 to:((c tempX) - 1) do:[ :i | r setLeft:((r left) + (minWidth at:(i + 1))). ]. |
721 | 392 |
|
1519 | 393 |
r setTop:(info startY). |
2955 | 394 |
0 to:((c tempY) - 1) do:[ :i | r setTop:((r top) + (minHeight at:(i + 1))). ]. |
721 | 395 |
|
1519 | 396 |
r width:0. |
397 |
(c tempX) to:((c tempX) + (c tempWidth) - 1) do:[ :i | |
|
2955 | 398 |
r width:((r width) + (minWidth at:(i + 1))). |
1519 | 399 |
]. |
721 | 400 |
|
1519 | 401 |
r height:0. |
402 |
(c tempY) to:((c tempY) + (c tempHeight) - 1) do:[ :i | |
|
2955 | 403 |
r height:((r height) + (minHeight at:(i + 1))). |
1519 | 404 |
]. |
721 | 405 |
|
1519 | 406 |
self adjustForGravity:c in:r. |
721 | 407 |
|
1519 | 408 |
"/ If the window is too small to be interesting then |
409 |
"/ unmap it. Otherwise configure it and then make sure |
|
410 |
"/ its mapped. |
|
411 |
rW := r width. |
|
412 |
rH := r height. |
|
721 | 413 |
|
1519 | 414 |
((rW <= 0) or:[rH <= 0]) ifTrue:[ |
415 |
child origin:(0@0) ; width:0 height:0. |
|
416 |
] ifFalse:[ |
|
417 |
child origin:((r left) @ (r top)). |
|
418 |
child width:rW. |
|
419 |
child height:rH. |
|
420 |
]. |
|
721 | 421 |
]. |
422 |
||
423 |
"Modified: / 1.2.1998 / 12:53:37 / av" |
|
424 |
! |
|
425 |
||
426 |
constraints:anObject |
|
427 |
" Get the GridBag constraints for an object. As a fallback create new constraints for objects |
|
428 |
which don't have any constraints yet." |
|
429 |
||
430 |
| c | |
|
431 |
||
432 |
c := anObject objectAttributeAt:#GridBagConstraints. |
|
433 |
c isNil ifTrue:[ |
|
434 |
anObject objectAttributeAt:#GridBagConstraints put:(c := GridBagConstraints new) |
|
435 |
]. |
|
436 |
^ c. |
|
437 |
||
438 |
"Created: / 21.1.1998 / 00:24:34 / av" |
|
439 |
"Modified: / 1.2.1998 / 12:55:23 / av" |
|
440 |
! |
|
441 |
||
442 |
getLayoutInfo:which |
|
443 |
"return a good extent, one that makes subviews fit" |
|
444 |
||
445 |
| |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
446 |
MAX_INT_VAL subViews |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
447 |
r i k px py pixelsDiff weightDiff weight nextSize c |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
448 |
curX curY curWidth curHeight curRow curCol xMax yMax |
721 | 449 |
| |
450 |
||
451 |
MAX_INT_VAL := 9999999999. |
|
452 |
subViews := (self subViews). |
|
453 |
||
454 |
r := GridBagLayoutInfo new. |
|
455 |
r width:0. |
|
456 |
r height:0. |
|
457 |
||
458 |
xMax := IdentityDictionaryWithDefault newWithDefaultValue:0. |
|
459 |
yMax := IdentityDictionaryWithDefault newWithDefaultValue:0. |
|
460 |
curRow := curCol := -1. |
|
461 |
||
462 |
"/ Pass #1 |
|
463 |
"/ |
|
464 |
"/ Figure out the dimensions of the layout grid (use a value of 1 for |
|
465 |
"/ zero or negative widths and heights). |
|
466 |
||
467 |
subViews do:[ :child | |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
468 |
c := self constraints:child. |
721 | 469 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
470 |
curX := c gridX. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
471 |
curY := c gridY. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
472 |
((curWidth := c gridWidth) <= 0) ifTrue:[ curWidth := 1. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
473 |
((curHeight := c gridHeight) <= 0) ifTrue:[ curHeight := 1. ]. |
721 | 474 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
475 |
"/ If x or y is negative, then use relative positioning: |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
476 |
((curX < 0) and:[ curY < 0 ]) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
477 |
ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
478 |
(curRow >= 0) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
479 |
ifTrue: [ curY := curRow. ] |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
480 |
ifFalse:[ (curCol >= 0) ifTrue:[ curX := curCol. ] ifFalse: [ curY := 0. ]]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
481 |
]. |
721 | 482 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
483 |
(curX < 0) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
484 |
ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
485 |
px := 0. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
486 |
curY to:(curY + curHeight - 1) do: [ :i | |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
487 |
px := px max:(xMax at:(i + 1)). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
488 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
489 |
((curX := px - curX - 1) < 0) ifTrue:[ curX := 0. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
490 |
] |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
491 |
ifFalse:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
492 |
(curY < 0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
493 |
py := 0. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
494 |
curX to: (curX + curWidth - 1) do: [ :i | |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
495 |
py := py max: (yMax at:(i + 1)). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
496 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
497 |
((curY := py - curY - 1) < 0) ifTrue:[ curY := 0. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
498 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
499 |
]. |
721 | 500 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
501 |
"/ Adjust the grid width and height |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
502 |
px := curX + curWidth. [ (r width) < px ] whileTrue:[ r width:((r width) + 1). ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
503 |
py := curY + curHeight. [ (r height) < py ] whileTrue:[ r height:((r height) + 1). ]. |
721 | 504 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
505 |
"/ Adjust the xMax and yMax arrays |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
506 |
curX to:(curX + curWidth - 1) do:[ :i | yMax at:(i + 1) put:py. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
507 |
curY to:(curY + curHeight - 1) do:[ :i | xMax at:(i + 1) put:px. ]. |
721 | 508 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
509 |
c minWidth:(child preferredWidth). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
510 |
c minHeight:(child preferredHeight). |
721 | 511 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
512 |
"/ Zero width and height must mean that this is the last item (or |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
513 |
"/ else something is wrong). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
514 |
(((c gridHeight) == 0) and:[ (c gridWidth) == 0 ]) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
515 |
curRow := curCol := -1. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
516 |
]. |
721 | 517 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
518 |
"/ Zero width starts a new row |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
519 |
(((c gridHeight) == 0) and:[ curRow < 0 ]) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
520 |
ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
521 |
curCol := curX + curWidth. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
522 |
] |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
523 |
ifFalse:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
524 |
((c gridWidth) == 0 and:[ curCol < 0 ]) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
525 |
curRow := curY + curHeight. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
526 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
527 |
]. |
721 | 528 |
]. |
529 |
||
530 |
"/ |
|
531 |
"/ Apply minimum row/column dimensions |
|
532 |
"/ |
|
533 |
((r width) < (columnWidths size)) ifTrue:[ r width:(columnWidths size). ]. |
|
534 |
((r height) < (rowHeights size)) ifTrue:[ r height:(rowHeights size). ]. |
|
535 |
||
536 |
"/ |
|
537 |
"/ Pass #2 |
|
538 |
"/ |
|
539 |
"/ Negative values for gridX are filled in with the current x value. |
|
540 |
"/ Negative values for gridY are filled in with the current y value. |
|
541 |
"/ Negative or zero values for gridWidth and gridHeight end the current |
|
542 |
"/ row or column, respectively. |
|
543 |
"/ |
|
544 |
||
545 |
curRow := curCol := -1. |
|
546 |
xMax := IdentityDictionaryWithDefault newWithDefaultValue:0. |
|
547 |
yMax := IdentityDictionaryWithDefault newWithDefaultValue:0. |
|
548 |
||
549 |
subViews do:[ :child | |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
550 |
c := self constraints:child. |
721 | 551 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
552 |
curX := c gridX. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
553 |
curY := c gridY. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
554 |
curWidth := c gridWidth. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
555 |
curHeight := c gridHeight. |
721 | 556 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
557 |
"/ If x or y is negative, then use relative positioning: |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
558 |
((curX < 0) and:[ curY < 0 ]) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
559 |
ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
560 |
(curRow >= 0) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
561 |
ifTrue: [ curY := curRow. ] |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
562 |
ifFalse:[ (curCol >= 0) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
563 |
ifTrue: [ curX := curCol. ] |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
564 |
ifFalse: [ curY := 0. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
565 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
566 |
]. |
721 | 567 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
568 |
(curX < 0) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
569 |
ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
570 |
(curHeight <= 0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
571 |
curHeight := curHeight + (r height) - curY. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
572 |
(curHeight < 1) ifTrue:[ curHeight := 1. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
573 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
574 |
px := 0. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
575 |
curY to:(curY + curHeight - 1) do: [ :i | px := px max:(xMax at:(i + 1)). ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
576 |
((curX := px - curX - 1) < 0) ifTrue:[ curX := 0. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
577 |
] |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
578 |
ifFalse:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
579 |
(curY < 0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
580 |
(curWidth <= 0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
581 |
curWidth := curWidth + (r width) - curX. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
582 |
(curWidth < 1) ifTrue:[ curWidth := 1. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
583 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
584 |
py := 0. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
585 |
curX to:(curX + curWidth - 1) do: [ :i | py := py max:(yMax at:(i + 1)). ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
586 |
((curY := py - curY - 1) < 0) ifTrue:[ curY := 0. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
587 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
588 |
]. |
721 | 589 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
590 |
(curWidth <= 0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
591 |
curWidth := curWidth + (r width) - curX. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
592 |
(curWidth < 1) ifTrue:[ curWidth := 1. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
593 |
]. |
721 | 594 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
595 |
(curHeight <= 0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
596 |
curHeight := curHeight + (r height) - curY. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
597 |
(curHeight < 1) ifTrue:[ curHeight := 1. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
598 |
]. |
721 | 599 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
600 |
px := curX + curWidth. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
601 |
py := curY + curHeight. |
721 | 602 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
603 |
"/ Adjust the xMax and yMax arrays |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
604 |
curX to: (curX + curWidth - 1) do:[ :i | yMax at:(i + 1) put:py. ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
605 |
curY to: (curY + curHeight - 1) do:[ :i | xMax at:(i + 1) put:px. ]. |
721 | 606 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
607 |
"/ Zero width and height must mean that this is the last item (or |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
608 |
"/ else something is wrong). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
609 |
((c gridHeight) == 0 and:[ (c gridWidth) == 0 ]) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
610 |
curRow := curCol := -1. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
611 |
]. |
721 | 612 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
613 |
"/ Zero width starts a new row |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
614 |
((c gridHeight) == 0 and:[ curRow < 0 ]) |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
615 |
ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
616 |
curCol := curX + curWidth. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
617 |
] |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
618 |
ifFalse:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
619 |
((c gridWidth) == 0 and:[ curCol < 0 ]) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
620 |
curRow := curY + curHeight. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
621 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
622 |
]. |
721 | 623 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
624 |
"/ Assign the new values to the gridbag slave */ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
625 |
c tempX:curX. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
626 |
c tempY:curY. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
627 |
c tempWidth:curWidth. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
628 |
c tempHeight:curHeight. |
721 | 629 |
]. |
630 |
||
631 |
"/ |
|
632 |
"/ Apply minimum row/column dimensions and weights |
|
633 |
"/ |
|
634 |
r minWidth: (columnWidths copy). |
|
635 |
r minHeight: (rowHeights copy). |
|
636 |
r weightX: (columnWeights copy). |
|
637 |
r weightY: (rowWeights copy). |
|
638 |
||
639 |
"/ |
|
640 |
"/ Pass #3 |
|
641 |
"/ |
|
642 |
"/ Distribute the minimun widths and weights: |
|
643 |
"/ |
|
644 |
nextSize := MAX_INT_VAL. |
|
645 |
||
646 |
i := 1. [ i ~~ MAX_INT_VAL ] whileTrue:[ |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
647 |
subViews do:[ :child | |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
648 |
c := self constraints:child. |
721 | 649 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
650 |
((c tempWidth) == i) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
651 |
px := (c tempX) + (c tempWidth). |
721 | 652 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
653 |
"/ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
654 |
"/ Figure out if we should use this slaves weight. If the weight |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
655 |
"/ is less than the total weight spanned by the width of the cell, |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
656 |
"/ then discard the weight. Otherwise split the difference |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
657 |
"/ according to the existing weights. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
658 |
"/ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
659 |
weightDiff := (c weightX) asFloat. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
660 |
(c tempX) to:(px - 1) do:[ :k | weightDiff := weightDiff - ((r weightX) at:(k + 1)) ]. |
721 | 661 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
662 |
(weightDiff > 0.0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
663 |
weight := 0.0. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
664 |
(c tempX) to:(px - 1) do:[ :k | weight := weight + ((r weightX) at:(k + 1)). ]. |
721 | 665 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
666 |
k := c tempX. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
667 |
[ (weight > 0.0) and:[k < px] ] whileTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
668 |
| wt dx | |
721 | 669 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
670 |
wt := ((r weightX) at:(k + 1)) asFloat. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
671 |
dx := (wt * weightDiff) / weight. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
672 |
wt at:(k + 1) put:(wt + dx). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
673 |
weightDiff := weightDiff - dx. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
674 |
weight := weight - wt. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
675 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
676 |
(r weightX) at:(px - 1 + 1) put:(((r weightX) at:(px - 1 + 1)) + weightDiff). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
677 |
]. |
721 | 678 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
679 |
"/ Calculate the minWidth array values. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
680 |
"/ First, figure out how wide the current slave needs to be. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
681 |
"/ Then, see if it will fit within the current minWidth values. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
682 |
"/ If it will not fit, add the difference according to the |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
683 |
"/ weightX array. |
721 | 684 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
685 |
pixelsDiff := (c minWidth) + (c ipadX) + (c insets left) + (c insets right). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
686 |
(c tempX) to:(px - 1) do:[ :k | |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
687 |
pixelsDiff := pixelsDiff - ((r minWidth) at:(k + 1)). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
688 |
]. |
721 | 689 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
690 |
(pixelsDiff > 0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
691 |
weight := 0.0. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
692 |
(c tempX) to:(px - 1) do:[ :k | weight := weight + ((r weightX) at:(k + 1)). ]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
693 |
k := c tempX. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
694 |
[ (weight > 0.0) and:[k < px] ] whileTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
695 |
| wt dx | |
721 | 696 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
697 |
wt := ((r weightX) at:(k + 1)) asFloat. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
698 |
dx := ((wt * pixelsDiff) / weight) asInteger. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
699 |
(r minWidth) at:(k + 1) put:(((r minWidth) at:(k + 1)) + dx). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
700 |
pixelsDiff := pixelsDiff - dx. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
701 |
weight := weight - wt. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
702 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
703 |
(r minWidth) at:(px - 1 + 1) put:(((r minWidth) at:(px - 1 + 1)) + pixelsDiff). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
704 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
705 |
] ifFalse:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
706 |
(((c tempWidth) > i) and:[ (c tempWidth) < nextSize ]) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
707 |
nextSize := c tempWidth. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
708 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
709 |
]. |
721 | 710 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
711 |
"/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
721 | 712 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
713 |
((c tempHeight) == i) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
714 |
py := (c tempY) + (c tempHeight). |
721 | 715 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
716 |
"/ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
717 |
"/ Figure out if we should use this slaves weight. If the weight |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
718 |
"/ is less than the total weight spanned by the width of the cell, |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
719 |
"/ then discard the weight. Otherwise split the difference |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
720 |
"/ according to the existing weights. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
721 |
"/ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
722 |
weightDiff := (c weightY) asFloat. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
723 |
(c tempY) to:(py - 1) do:[ :k | weightDiff := weightDiff - ((r weightY) at:(k + 1)) ]. |
721 | 724 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
725 |
(weightDiff > 0.0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
726 |
weight := 0.0. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
727 |
(c tempY) to:(py - 1) do:[ :k | weight := weight + ((r weightY) at:(k + 1)). ]. |
721 | 728 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
729 |
k := c tempY. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
730 |
[ (weight > 0.0) and:[k < py] ] whileTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
731 |
| wt dy | |
721 | 732 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
733 |
wt := ((r weightY) at:(k + 1)) asFloat. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
734 |
dy := (wt * weightDiff) / weight. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
735 |
wt at:(k + 1) put:(wt + dy). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
736 |
weightDiff := weightDiff - dy. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
737 |
weight := weight - wt. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
738 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
739 |
(r weightY) at:(py - 1 + 1) put:(((r weightY) at:(py - 1 + 1)) + weightDiff). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
740 |
]. |
721 | 741 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
742 |
"/ Calculate the minWidth array values. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
743 |
"/ First, figure out how wide the current slave needs to be. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
744 |
"/ Then, see if it will fit within the current minWidth values. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
745 |
"/ If it will not fit, add the difference according to the |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
746 |
"/ weightX array. |
721 | 747 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
748 |
pixelsDiff := (c minHeight) + (c ipadY) + (c insets top) + (c insets bottom). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
749 |
(c tempY) to:(py - 1) do:[ :k | |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
750 |
pixelsDiff := pixelsDiff - ((r minHeight) at:(k + 1)). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
751 |
]. |
721 | 752 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
753 |
(pixelsDiff > 0) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
754 |
weight := 0.0. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
755 |
(c tempY) to:(py - 1) do:[ :k | |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
756 |
weight := weight + ((r weightY) at:(k + 1)). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
757 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
758 |
k := c tempY. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
759 |
[ (weight > 0.0) and:[k < py] ] whileTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
760 |
| wt dy | |
721 | 761 |
|
3422
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
762 |
wt := ((r weightY) at:(k + 1)) asFloat. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
763 |
dy := ((wt * pixelsDiff) / weight) asInteger. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
764 |
(r minHeight) at:(k + 1) put:(((r minHeight) at:(k + 1)) + dy). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
765 |
pixelsDiff := pixelsDiff - dy. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
766 |
weight := weight - wt. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
767 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
768 |
(r minHeight) at:(py - 1 + 1) put:(((r minHeight) at:(py - 1 + 1)) + pixelsDiff). |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
769 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
770 |
] ifFalse:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
771 |
(((c tempHeight) > i) and:[ (c tempHeight) < nextSize ]) ifTrue:[ |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
772 |
nextSize := c tempHeight. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
773 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
774 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
775 |
]. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
776 |
i := nextSize. |
01087101a82b
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3245
diff
changeset
|
777 |
nextSize := MAX_INT_VAL. |
721 | 778 |
]. |
779 |
||
780 |
^ r |
|
781 |
||
782 |
"Modified: / 29.3.1997 / 11:06:45 / cg" |
|
783 |
"Created: / 19.1.1998 / 17:24:26 / av" |
|
784 |
"Modified: / 21.1.1998 / 18:40:38 / av" |
|
785 |
! |
|
786 |
||
787 |
getMinSize:info |
|
788 |
"Figure out the minimum size of the master based on the information from getLayoutInfo. The |
|
789 |
result will be returned as a rectangle with width and height set to the minimum size." |
|
790 |
||
791 |
| d insets t | |
|
792 |
||
793 |
insets := Insets new. |
|
794 |
||
795 |
d := Rectangle origin:0@0 extent:0@0. |
|
796 |
||
797 |
t := 0. |
|
798 |
1 to:(info width) do:[ :i | t := t + ((info minWidth) at:i). ]. |
|
799 |
d width:(t + (insets left) + (insets right)). |
|
800 |
||
801 |
t := 0. |
|
802 |
1 to:(info height) do:[ :i | t := t + ((info minHeight) at:i). ]. |
|
803 |
d height:(t + (insets top) + (insets bottom)). |
|
804 |
||
805 |
^ d |
|
806 |
||
807 |
"Modified: / 1.2.1998 / 12:59:00 / av" |
|
808 |
! |
|
809 |
||
810 |
minimumLayoutSize |
|
811 |
"Return our minimum layout size. The width and height of the returned rectangle gives the minimum |
|
812 |
layout size." |
|
813 |
||
814 |
| info | |
|
815 |
||
816 |
info := self getLayoutInfo:#MINIMUM_SIZE. |
|
817 |
^ self getMinSize:info |
|
818 |
||
819 |
"Created: / 19.1.1998 / 17:25:01 / av" |
|
820 |
"Modified: / 1.2.1998 / 12:59:38 / av" |
|
821 |
! |
|
822 |
||
823 |
preferredLayoutSize |
|
824 |
"Return our preffered layout size. The width and height of the returned rectangle gives the |
|
825 |
preferred layout size." |
|
826 |
||
827 |
| info | |
|
828 |
||
829 |
info := self getLayoutInfo:#PREFFERED_SIZE. |
|
830 |
^ self getMinSize:info |
|
831 |
||
832 |
"Created: / 19.1.1998 / 17:23:37 / av" |
|
833 |
"Modified: / 1.2.1998 / 13:00:04 / av" |
|
834 |
! ! |
|
835 |
||
836 |
!GridBagLayoutView methodsFor:'queries'! |
|
837 |
||
838 |
preferredExtent |
|
839 |
"Return a good extent, one that makes subviews fit. Return the the preferred extent as a point |
|
840 |
where x and y represents the width and height of the extent." |
|
841 |
||
3570
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
842 |
"/ If I have an explicit preferredExtent.. |
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
843 |
explicitExtent notNil ifTrue:[ |
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
844 |
^ explicitExtent |
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
845 |
]. |
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
846 |
|
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
847 |
"/ If I have a cached preferredExtent value.. |
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
848 |
preferredExtent notNil ifTrue:[ |
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
849 |
^ preferredExtent |
a8243f6c0b1f
changed #preferredExtent - use explicitExtent instvar
Stefan Vogel <sv@exept.de>
parents:
3422
diff
changeset
|
850 |
]. |
721 | 851 |
|
3673 | 852 |
self subViews isNil ifTrue:[ |
853 |
^ super preferredExtent. |
|
854 |
]. |
|
721 | 855 |
|
3673 | 856 |
^ self preferredLayoutSize extent. |
721 | 857 |
|
858 |
"Created: / 17.1.1998 / 00:11:46 / av" |
|
859 |
"Modified: / 1.2.1998 / 13:01:46 / av" |
|
860 |
! ! |
|
861 |
||
862 |
!GridBagLayoutView class methodsFor:'documentation'! |
|
863 |
||
864 |
version |
|
5303 | 865 |
^ '$Header$' |
721 | 866 |
! ! |
5303 | 867 |