1431
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1998 by Andreas Vogel
|
|
3 |
COPYRIGHT (c) 1998 by eXept Software AG
|
|
4 |
All Rights Reserved
|
|
5 |
|
|
6 |
This software is furnished under a license and may be used
|
|
7 |
only in accordance with the terms of that license and with the
|
|
8 |
inclusion of the above copyright notice. This software may not
|
|
9 |
be provided or otherwise made available to, or used by, any
|
|
10 |
other person. No title to or ownership of the software is
|
|
11 |
hereby transferred.
|
|
12 |
"
|
|
13 |
|
|
14 |
|
2840
|
15 |
"{ Package: 'stx:libwidg2' }"
|
|
16 |
|
721
|
17 |
Object subclass:#GridBagConstraints
|
|
18 |
instanceVariableNames:'insets gridX gridY gridWidth gridHeight weightX weightY anchor
|
|
19 |
fill ipadX ipadY tempX tempY tempWidth tempHeight minWidth
|
|
20 |
minHeight'
|
|
21 |
classVariableNames:''
|
|
22 |
poolDictionaries:''
|
|
23 |
category:'Views-Support'
|
|
24 |
!
|
|
25 |
|
|
26 |
!GridBagConstraints class methodsFor:'documentation'!
|
|
27 |
|
1431
|
28 |
copyright
|
|
29 |
"
|
|
30 |
COPYRIGHT (c) 1998 by Andreas Vogel
|
|
31 |
COPYRIGHT (c) 1998 by eXept Software AG
|
|
32 |
All Rights Reserved
|
|
33 |
|
|
34 |
This software is furnished under a license and may be used
|
|
35 |
only in accordance with the terms of that license and with the
|
|
36 |
inclusion of the above copyright notice. This software may not
|
|
37 |
be provided or otherwise made available to, or used by, any
|
|
38 |
other person. No title to or ownership of the software is
|
|
39 |
hereby transferred.
|
|
40 |
"
|
|
41 |
|
|
42 |
!
|
|
43 |
|
721
|
44 |
documentation
|
|
45 |
"
|
|
46 |
The GridBagConstraints class holds the constraints for each child under control of the layouter
|
|
47 |
GridBagLayoutView. In addition to just be a placeholder for the constraints and some
|
|
48 |
temporary information during the layout process, the GridBagConstraints class also supports
|
|
49 |
the decoding and encoding its instance information from and into a literal array. This is
|
|
50 |
necessary in order to be used as a winSpec element.
|
|
51 |
|
|
52 |
For the valid values of each public instance variable see the documentation of the GridBagLayoutView.
|
|
53 |
|
|
54 |
[see also:]
|
|
55 |
GridBagLayoutView
|
|
56 |
|
|
57 |
[author:]
|
|
58 |
Andreas Vogel
|
|
59 |
"
|
|
60 |
! !
|
|
61 |
|
|
62 |
!GridBagConstraints class methodsFor:'instance creation'!
|
|
63 |
|
|
64 |
new
|
|
65 |
"Create an initialized instance of myself."
|
|
66 |
|
2840
|
67 |
^ self basicNew initialize
|
721
|
68 |
|
|
69 |
"Created: / 19.1.1998 / 13:37:27 / av"
|
|
70 |
"Modified: / 1.2.1998 / 13:09:17 / av"
|
|
71 |
! !
|
|
72 |
|
|
73 |
!GridBagConstraints methodsFor:'accessing'!
|
|
74 |
|
|
75 |
anchor
|
|
76 |
^ anchor
|
|
77 |
|
|
78 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
79 |
!
|
|
80 |
|
|
81 |
anchor:something
|
|
82 |
anchor := something.
|
|
83 |
|
|
84 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
85 |
!
|
|
86 |
|
|
87 |
fill
|
|
88 |
^ fill
|
|
89 |
|
|
90 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
91 |
!
|
|
92 |
|
|
93 |
fill:something
|
|
94 |
fill := something.
|
|
95 |
|
|
96 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
97 |
!
|
|
98 |
|
|
99 |
gridHeight
|
|
100 |
^ gridHeight
|
|
101 |
|
|
102 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
103 |
!
|
|
104 |
|
|
105 |
gridHeight:something
|
|
106 |
"set the value of the instance variable 'gridHeight'"
|
|
107 |
|
|
108 |
| val |
|
|
109 |
|
|
110 |
((val := something) == #REMAINDER)
|
|
111 |
ifTrue: [ val := 0. ]
|
|
112 |
ifFalse:[ (val == #RELATIVE) ifTrue:[ val := -1. ]].
|
|
113 |
|
|
114 |
gridHeight := val.
|
|
115 |
|
|
116 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
117 |
"Modified: / 20.1.1998 / 22:10:17 / av"
|
|
118 |
!
|
|
119 |
|
|
120 |
gridWidth
|
|
121 |
^ gridWidth
|
|
122 |
|
|
123 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
124 |
!
|
|
125 |
|
|
126 |
gridWidth:something
|
|
127 |
"set the value of the instance variable 'gridWidth'"
|
|
128 |
|
|
129 |
| val |
|
|
130 |
|
|
131 |
((val := something) == #REMAINDER)
|
|
132 |
ifTrue: [ val := 0. ]
|
|
133 |
ifFalse:[ (val == #RELATIVE) ifTrue:[ val := -1. ]].
|
|
134 |
|
|
135 |
gridWidth := val.
|
|
136 |
|
|
137 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
138 |
"Modified: / 20.1.1998 / 22:08:53 / av"
|
|
139 |
!
|
|
140 |
|
|
141 |
gridX
|
|
142 |
^ gridX
|
|
143 |
|
|
144 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
145 |
!
|
|
146 |
|
|
147 |
gridX:something
|
|
148 |
"set the value of the instance variable 'gridX'"
|
|
149 |
|
|
150 |
(something == #RELATIVE) ifTrue:[ gridX := -1. ] ifFalse:[ gridX := something. ].
|
|
151 |
|
|
152 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
153 |
"Modified: / 20.1.1998 / 22:12:40 / av"
|
|
154 |
!
|
|
155 |
|
|
156 |
gridY
|
|
157 |
^ gridY
|
|
158 |
|
|
159 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
160 |
!
|
|
161 |
|
|
162 |
gridY:something
|
|
163 |
"set the value of the instance variable 'gridY'"
|
|
164 |
|
|
165 |
(something == #RELATIVE) ifTrue:[ gridY := -1. ] ifFalse:[ gridY := something. ].
|
|
166 |
|
|
167 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
168 |
"Modified: / 20.1.1998 / 22:45:48 / av"
|
|
169 |
!
|
|
170 |
|
|
171 |
insets
|
|
172 |
^ insets
|
|
173 |
|
|
174 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
175 |
!
|
|
176 |
|
|
177 |
insets:something
|
|
178 |
insets := something.
|
|
179 |
|
|
180 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
181 |
!
|
|
182 |
|
|
183 |
ipadX
|
|
184 |
^ ipadX
|
|
185 |
|
|
186 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
187 |
!
|
|
188 |
|
|
189 |
ipadX:something
|
|
190 |
ipadX := something.
|
|
191 |
|
|
192 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
193 |
!
|
|
194 |
|
|
195 |
ipadY
|
|
196 |
^ ipadY
|
|
197 |
|
|
198 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
199 |
!
|
|
200 |
|
|
201 |
ipadY:something
|
|
202 |
ipadY := something.
|
|
203 |
|
|
204 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
205 |
!
|
|
206 |
|
|
207 |
minHeight
|
|
208 |
^ minHeight
|
|
209 |
|
|
210 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
211 |
!
|
|
212 |
|
|
213 |
minHeight:something
|
|
214 |
minHeight := something.
|
|
215 |
|
|
216 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
217 |
!
|
|
218 |
|
|
219 |
minWidth
|
|
220 |
^ minWidth
|
|
221 |
|
|
222 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
223 |
!
|
|
224 |
|
|
225 |
minWidth:something
|
|
226 |
minWidth := something.
|
|
227 |
|
|
228 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
229 |
!
|
|
230 |
|
|
231 |
tempHeight
|
|
232 |
^ tempHeight
|
|
233 |
|
|
234 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
235 |
!
|
|
236 |
|
|
237 |
tempHeight:something
|
|
238 |
tempHeight := something.
|
|
239 |
|
|
240 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
241 |
!
|
|
242 |
|
|
243 |
tempWidth
|
|
244 |
^ tempWidth
|
|
245 |
|
|
246 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
247 |
!
|
|
248 |
|
|
249 |
tempWidth:something
|
|
250 |
tempWidth := something.
|
|
251 |
|
|
252 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
253 |
!
|
|
254 |
|
|
255 |
tempX
|
|
256 |
^ tempX
|
|
257 |
|
|
258 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
259 |
!
|
|
260 |
|
|
261 |
tempX:something
|
|
262 |
tempX := something.
|
|
263 |
|
|
264 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
265 |
!
|
|
266 |
|
|
267 |
tempY
|
|
268 |
^ tempY
|
|
269 |
|
|
270 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
271 |
!
|
|
272 |
|
|
273 |
tempY:something
|
|
274 |
tempY := something.
|
|
275 |
|
|
276 |
"Created: / 19.1.1998 / 19:58:21 / av"
|
|
277 |
!
|
|
278 |
|
|
279 |
weightX
|
|
280 |
^ weightX
|
|
281 |
|
|
282 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
283 |
!
|
|
284 |
|
|
285 |
weightX:something
|
|
286 |
weightX := something.
|
|
287 |
|
|
288 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
289 |
!
|
|
290 |
|
|
291 |
weightY
|
|
292 |
^ weightY
|
|
293 |
|
|
294 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
295 |
!
|
|
296 |
|
|
297 |
weightY:something
|
|
298 |
weightY := something.
|
|
299 |
|
|
300 |
"Created: / 19.1.1998 / 19:58:20 / av"
|
|
301 |
! !
|
|
302 |
|
|
303 |
!GridBagConstraints methodsFor:'converting'!
|
|
304 |
|
|
305 |
fromLiteralArrayEncoding:encoding
|
|
306 |
"Read my values from an encoding. The encoding is supposed to be of the form:
|
|
307 |
(GridBagConstraints
|
|
308 |
insets: (Insets left: 1 right: 1 top: 1 bottom: 1)
|
|
309 |
gridX: 1 gridY: 1 gridWidth: 1 gridHeight: 1
|
|
310 |
weightX: 1.0 weightY: 1.0 ipadX: 1 ipadY: 1 anchor: #CENTER fill: #BOTH
|
|
311 |
)
|
|
312 |
This is the reverse to literalArrayEncoding."
|
|
313 |
|
|
314 |
| stop sel |
|
|
315 |
|
|
316 |
self initialize.
|
|
317 |
insets := nil.
|
|
318 |
stop := encoding size.
|
|
319 |
|
|
320 |
2 to:stop by:2 do:[ :i |
|
|
321 |
sel := encoding at:i.
|
|
322 |
(self respondsTo:sel) ifTrue:[
|
|
323 |
self perform:sel with:(encoding at:i+1)
|
|
324 |
]
|
|
325 |
].
|
|
326 |
|
|
327 |
insets notNil
|
|
328 |
ifTrue: [ insets := insets decodeAsLiteralArray ]
|
|
329 |
ifFalse: [ insets := Insets new ].
|
|
330 |
|
|
331 |
"
|
|
332 |
GridBagConstraints new fromLiteralArrayEncoding:#(GridBagConstraints
|
|
333 |
insets: #(Insets 96 97 98 99)
|
|
334 |
gridX: 101
|
|
335 |
)
|
|
336 |
|
|
337 |
#(#GridBagConstraints anchor: #CENTER fill: #BOTH) decodeAsLiteralArray
|
|
338 |
"
|
|
339 |
|
|
340 |
"Created: / 21.1.1998 / 20:10:26 / av"
|
|
341 |
"Modified: / 1.2.1998 / 13:14:03 / av"
|
|
342 |
!
|
|
343 |
|
|
344 |
fromLiteralArrayEncodingOld:encoding
|
|
345 |
"Read my values from an encoding. This is the reverse to literalArrayEncoding."
|
|
346 |
|
|
347 |
insets := encoding at:2.
|
|
348 |
gridX := encoding at:3.
|
|
349 |
gridY := encoding at:4.
|
|
350 |
gridWidth := encoding at:5.
|
|
351 |
gridHeight := encoding at:6.
|
|
352 |
weightX := encoding at:7.
|
|
353 |
weightY := encoding at:8.
|
|
354 |
ipadX := encoding at:9.
|
|
355 |
ipadY := encoding at:10.
|
|
356 |
anchor := encoding at:11.
|
|
357 |
fill := encoding at:12.
|
|
358 |
|
|
359 |
insets notNil ifTrue:[ insets := insets decodeAsLiteralArray ].
|
|
360 |
|
|
361 |
"
|
|
362 |
GridBagConstraints new fromLiteralArrayEncoding:#(#GridBagConstraints
|
|
363 |
#(Insets 50 60 70 80) 10 20 30 40 50.0 60.0 70 80 #CENTER #BOTH )
|
|
364 |
|
|
365 |
#(#GridBagConstraints
|
|
366 |
#(Insets 50 60 70 80) 10 20 30 40 50.0 60.0 70 80 #CENTER #BOTH ) decodeAsLiteralArray
|
|
367 |
"
|
|
368 |
|
|
369 |
"Created: / 21.1.1998 / 20:08:15 / av"
|
|
370 |
"Modified: / 1.2.1998 / 13:14:13 / av"
|
|
371 |
!
|
|
372 |
|
|
373 |
literalArrayEncoding
|
|
374 |
"Encode myself as an array, from which a copy of the receiver can be
|
|
375 |
reconstructed with #decodeAsLiteralArray."
|
|
376 |
|
|
377 |
| coll |
|
|
378 |
|
|
379 |
coll := OrderedCollection new.
|
|
380 |
|
|
381 |
coll add:#GridBagConstraints.
|
|
382 |
coll add:#'insets:' ; add:(insets literalArrayEncoding).
|
|
383 |
coll add:#'gridX:' ; add:gridX.
|
|
384 |
coll add:#'gridY:' ; add:gridY.
|
|
385 |
coll add:#'gridWidth:' ; add:gridWidth.
|
|
386 |
coll add:#'gridHeight:' ; add:gridHeight.
|
|
387 |
coll add:#'weightX:' ; add:weightX.
|
|
388 |
coll add:#'weightY:' ; add:weightY.
|
|
389 |
coll add:#'ipadX:' ; add:ipadX.
|
|
390 |
coll add:#'ipadY:' ; add:ipadY.
|
|
391 |
coll add:#'anchor:' ; add:anchor.
|
|
392 |
coll add:#'fill:' ; add:fill.
|
|
393 |
|
|
394 |
^ coll asArray
|
|
395 |
|
|
396 |
"
|
|
397 |
GridBagConstraints new literalArrayEncoding
|
|
398 |
"
|
|
399 |
|
|
400 |
"Created: / 21.1.1998 / 20:13:48 / av"
|
|
401 |
"Modified: / 1.2.1998 / 13:14:56 / av"
|
|
402 |
!
|
|
403 |
|
|
404 |
literalArrayEncodingOld
|
|
405 |
"Encode myself as an array, from which a copy of the receiver can be
|
|
406 |
reconstructed with #decodeAsLiteralArray.
|
|
407 |
The encoding is:
|
|
408 |
(GridBagConstraints
|
|
409 |
#( Insets left right top bottom )
|
|
410 |
gridX gridY gridWidth gridHeight weightX weightY ipadX ipadY anchor fill
|
|
411 |
)
|
|
412 |
"
|
|
413 |
|
|
414 |
| coll |
|
|
415 |
|
|
416 |
coll := OrderedCollection new.
|
|
417 |
|
|
418 |
coll add: #GridBagConstraints.
|
|
419 |
coll add: (insets literalArrayEncoding).
|
|
420 |
coll add: gridX.
|
|
421 |
coll add: gridY.
|
|
422 |
coll add: gridWidth.
|
|
423 |
coll add: gridHeight.
|
|
424 |
coll add: weightX.
|
|
425 |
coll add: weightY.
|
|
426 |
coll add: ipadX.
|
|
427 |
coll add: ipadY.
|
|
428 |
coll add: anchor.
|
|
429 |
coll add: fill.
|
|
430 |
|
|
431 |
^ coll asArray
|
|
432 |
|
|
433 |
"
|
|
434 |
GridBagConstraints new literalArrayEncoding
|
|
435 |
"
|
|
436 |
|
|
437 |
"Created: / 21.1.1998 / 20:13:33 / av"
|
|
438 |
"Modified: / 1.2.1998 / 13:14:49 / av"
|
|
439 |
! !
|
|
440 |
|
2840
|
441 |
!GridBagConstraints methodsFor:'initialization'!
|
721
|
442 |
|
|
443 |
initialize
|
|
444 |
"Set all non-temporary instance variables to default values.
|
|
445 |
Warning: no application should depend on this default settings and should always initilize
|
|
446 |
the constraints themselves."
|
|
447 |
|
|
448 |
gridX := -1.
|
|
449 |
gridY := -1.
|
|
450 |
gridWidth := 1.
|
|
451 |
gridHeight := 1.
|
|
452 |
|
|
453 |
weightX := 0.
|
|
454 |
weightY := 0.
|
|
455 |
|
|
456 |
anchor := #CENTER.
|
|
457 |
fill := #NONE.
|
|
458 |
|
|
459 |
ipadX := 0.
|
|
460 |
ipadY := 0.
|
|
461 |
|
|
462 |
insets := Insets new.
|
|
463 |
|
|
464 |
"Modified: / 1.2.1998 / 13:18:01 / av"
|
|
465 |
! !
|
|
466 |
|
|
467 |
!GridBagConstraints class methodsFor:'documentation'!
|
|
468 |
|
|
469 |
version
|
2939
|
470 |
^ '$Header: /cvs/stx/stx/libwidg2/GridBagConstraints.st,v 1.4 2006-03-13 15:55:25 cg Exp $'
|
721
|
471 |
! !
|