author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 17:23:54 +0100 | |
changeset 174 | d80a6cc3f9b2 |
parent 164 | 5ab02ff0d9ae |
child 175 | bb91e76dae76 |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1991 by Claus Gittinger |
59 | 3 |
All Rights Reserved |
0 | 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 |
" |
|
12 |
||
105 | 13 |
'From Smalltalk/X, Version:2.10.5 on 14-mar-1995 at 11:10:57 am'! |
99 | 14 |
|
119 | 15 |
SimpleView subclass:#VariableVerticalPanel |
105 | 16 |
instanceVariableNames:'barHeight barWidth separatingLine shadowForm lightForm showHandle |
116 | 17 |
handlePosition handleColor handleStyle noColor trackLine |
18 |
redrawLocked' |
|
59 | 19 |
classVariableNames:'DefaultShowHandle DefaultHandleStyle DefaultHandlePosition |
116 | 20 |
DefaultTrackingLine DefaultSeparatingLine DefaultHandleColor |
21 |
DefaultCursor' |
|
59 | 22 |
poolDictionaries:'' |
23 |
category:'Views-Layout' |
|
0 | 24 |
! |
25 |
||
38 | 26 |
!VariableVerticalPanel class methodsFor:'documentation'! |
27 |
||
28 |
copyright |
|
29 |
" |
|
30 |
COPYRIGHT (c) 1991 by Claus Gittinger |
|
59 | 31 |
All Rights Reserved |
38 | 32 |
|
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
! |
|
41 |
||
42 |
version |
|
174
d80a6cc3f9b2
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
164
diff
changeset
|
43 |
^ '$Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.21 1995-11-11 16:23:43 cg Exp $' |
38 | 44 |
! |
45 |
||
46 |
documentation |
|
47 |
" |
|
48 |
a View to separate its subviews vertically by a movable bar; |
|
49 |
the size-ratios of the subviews can be changed by moving this bar. |
|
50 |
||
51 |
The bar-handle is either an exposed knob (style == #motif) |
|
52 |
or the forms defined in Scroller (style ~~ #motif) |
|
53 |
or nothing. |
|
54 |
||
55 |
The subvies dimensions MUST be given as relative sizes; |
|
56 |
typically creation is done as: |
|
0 | 57 |
|
59 | 58 |
p := VariableVerticalPanel in:superView. |
59 |
v1 := <someViewClass> origin:0.0 @ 0.0 |
|
60 |
corner:1.0 @ 0.5 |
|
61 |
in:p. |
|
62 |
v2 := <someViewClass> origin:0.0 @ 0.5 |
|
63 |
corner:1.0 @ 0.8 |
|
64 |
in:p. |
|
65 |
v3 := <someViewClass> origin:0.0 @ 0.8 |
|
66 |
corner:1.0 @ 1.0 |
|
67 |
in:p. |
|
38 | 68 |
|
63 | 69 |
" |
70 |
! |
|
71 |
||
72 |
examples |
|
73 |
" |
|
38 | 74 |
example: |
59 | 75 |
|top p v1 v2 v3| |
38 | 76 |
|
59 | 77 |
top := StandardSystemView new. |
78 |
top extent:300@300. |
|
0 | 79 |
|
59 | 80 |
p := VariableVerticalPanel |
81 |
origin:0.0 @ 0.0 |
|
82 |
corner:1.0 @ 1.0 |
|
83 |
in:top. |
|
84 |
v1 := ScrollableView for:SelectionInListView in:p. |
|
79 | 85 |
v1 origin:0.0 @ 0.0 corner:1.0 @ 0.5. |
59 | 86 |
v1 list:(FileDirectory directoryNamed:'/etc') contents. |
87 |
v1 action:[:selNr | |
|
88 |
|fullName stream text| |
|
89 |
fullName := '/etc/' , v1 selectionValue. |
|
90 |
stream := fullName asFilename readStream. |
|
91 |
stream notNil ifTrue:[ |
|
92 |
text := stream contents. |
|
93 |
v2 contents:text. |
|
94 |
v3 contents:text |
|
95 |
] |
|
96 |
]. |
|
0 | 97 |
|
59 | 98 |
v2 := TextView |
79 | 99 |
origin:0.0 @ 0.5 corner:1.0 @ 0.8 in:p. |
100 |
||
59 | 101 |
v3 := ScrollableView |
79 | 102 |
for:TextView |
59 | 103 |
in:p. |
79 | 104 |
v3 origin:0.0 @ 0.8 corner:1.0 @ 1.0. |
59 | 105 |
top open |
38 | 106 |
" |
107 |
! ! |
|
0 | 108 |
|
109 |
!VariableVerticalPanel class methodsFor:'defaults'! |
|
110 |
||
59 | 111 |
updateStyleCache |
112 |
DefaultShowHandle := StyleSheet at:'variablePanelShowHandle' default:true. |
|
113 |
DefaultHandleStyle := StyleSheet at:'variablePanelHandleStyle'. |
|
114 |
DefaultHandlePosition := StyleSheet at:'variablePanelHandlePosition' default:#right. |
|
115 |
DefaultTrackingLine := StyleSheet at:'variablePanelTrackingLine' default:false. |
|
116 |
DefaultSeparatingLine := StyleSheet at:'variablePanelSeparatingLine' default:false. |
|
60 | 117 |
DefaultHandleColor := StyleSheet colorAt:'variablePanelHandleColor' default:Black. |
0 | 118 |
! |
119 |
||
105 | 120 |
shadowFormOn:aDisplay |
121 |
"use same handle as Scroller" |
|
122 |
||
123 |
^ Scroller handleShadowFormOn:aDisplay |
|
124 |
! |
|
125 |
||
99 | 126 |
lightFormOn:aDisplay |
127 |
"use same handle as Scroller" |
|
59 | 128 |
|
99 | 129 |
^ Scroller handleLightFormOn:aDisplay |
0 | 130 |
! ! |
131 |
||
99 | 132 |
!VariableVerticalPanel methodsFor:'drawing'! |
0 | 133 |
|
134 |
drawHandleAtX:hx y:hy |
|
79 | 135 |
"draw a single handle at hx/hy" |
136 |
||
0 | 137 |
|h y m| |
138 |
||
59 | 139 |
shadowForm notNil ifTrue:[ |
140 |
h := shadowForm height |
|
0 | 141 |
] ifFalse:[ |
59 | 142 |
h := barHeight - 4 |
0 | 143 |
]. |
144 |
||
164 | 145 |
self paint:viewBackground. |
146 |
self fillRectangleX:margin y:hy |
|
147 |
width:(width - margin - margin) |
|
148 |
height:barHeight. |
|
0 | 149 |
|
59 | 150 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
151 |
m := (barHeight - h) // 2. |
|
152 |
shadowForm isNil ifTrue:[ |
|
153 |
y := hy + (barHeight // 2). |
|
154 |
separatingLine ifTrue:[ |
|
155 |
self paint:shadowColor. |
|
156 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
157 |
y := y + 1. |
|
158 |
self paint:lightColor. |
|
159 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
160 |
]. |
|
161 |
self paint:viewBackground. |
|
162 |
self fillRectangleX:(hx - barWidth) y:hy |
|
163 |
width:(barWidth + barWidth) |
|
164 |
height:h. |
|
0 | 165 |
|
59 | 166 |
y := hy. |
167 |
handleStyle == #st80 ifTrue:[ |
|
168 |
y := y - 1 |
|
169 |
]. |
|
170 |
self drawEdgesForX:(hx - barWidth) |
|
171 |
y:(y + m) |
|
172 |
width:(barWidth + barWidth) |
|
173 |
height:h |
|
60 | 174 |
level:2. |
175 |
handleStyle == #iris ifTrue:[ |
|
63 | 176 |
self paint:handleColor. |
60 | 177 |
self fillDeviceRectangleX:(hx - barWidth + 2) |
178 |
y:(y + m + 2) |
|
179 |
width:(barWidth + barWidth - 4) |
|
180 |
height:h - 4 |
|
181 |
] |
|
59 | 182 |
] ifFalse:[ |
183 |
y := hy. |
|
184 |
self drawHandleFormAtX:hx y:(y + m) |
|
185 |
]. |
|
186 |
handleStyle == #st80 ifTrue:[ |
|
187 |
y := hy - 1. |
|
188 |
self paint:lightColor. |
|
189 |
self displayLineFromX:margin y:y toX:(width - margin - margin - 1) y:y. |
|
190 |
self displayLineFromX:0 y:hy toX:0 y:(hy + barHeight - 1). |
|
191 |
y := hy + barHeight - 2. |
|
192 |
self paint:shadowColor. |
|
193 |
self displayLineFromX:margin y:y toX:(width - margin) y:y. |
|
194 |
"uncomment the -1 if you dont like the notch at the right end" |
|
195 |
" VVV" |
|
196 |
self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + barHeight - 1). |
|
197 |
]. |
|
0 | 198 |
] ifFalse:[ |
59 | 199 |
y := hy + barHeight - 1. |
200 |
self paint:handleColor. |
|
201 |
separatingLine ifTrue:[ |
|
202 |
self displayLineFromX:0 y:hy+1 toX:width y:hy+1. |
|
203 |
self displayLineFromX:0 y:y toX:width y:y. |
|
204 |
]. |
|
63 | 205 |
self fillRectangleX:hx y:hy width:barWidth height:barHeight |
0 | 206 |
] |
207 |
! |
|
208 |
||
105 | 209 |
redrawHandlesFrom:start to:stop |
210 |
"redraw some handles" |
|
211 |
||
212 |
subViews notNil ifTrue:[ |
|
213 |
showHandle ifTrue:[ |
|
214 |
self handleOriginsFrom:start to:stop do:[:hPoint | |
|
215 |
self drawHandleAtX:(hPoint x) y:(hPoint y) |
|
216 |
]. |
|
217 |
] |
|
218 |
] |
|
219 |
! |
|
220 |
||
99 | 221 |
lockRedraw |
222 |
redrawLocked := true |
|
223 |
! |
|
224 |
||
225 |
unlockRedraw |
|
226 |
redrawLocked := false |
|
227 |
! |
|
228 |
||
105 | 229 |
redraw |
230 |
"redraw all of the handles" |
|
231 |
||
232 |
redrawLocked ~~ true ifTrue:[ |
|
233 |
self redrawHandlesFrom:1 to:(subViews size) |
|
234 |
] |
|
235 |
! |
|
236 |
||
99 | 237 |
invertHandleBarAtX:hx y:hy |
238 |
self noClipByChildren. |
|
239 |
self xoring:[ |
|
240 |
|y| |
|
241 |
||
242 |
trackLine ifTrue:[ |
|
243 |
y := hy + (barHeight // 2). |
|
244 |
self displayLineFromX:0 y:y toX:width y:y. |
|
245 |
] ifFalse:[ |
|
246 |
self fillRectangleX:0 y:hy width:width height:barHeight |
|
247 |
] |
|
248 |
]. |
|
249 |
self clipByChildren. |
|
250 |
! |
|
251 |
||
252 |
drawHandleFormAtX:hx y:hy |
|
253 |
"draw a handles bitmap at hx/hy" |
|
254 |
||
255 |
self paint:shadowColor. |
|
256 |
self displayForm:shadowForm x:hx y:hy. |
|
257 |
self paint:lightColor. |
|
258 |
self displayForm:lightForm x:hx y:hy. |
|
259 |
self paint:viewBackground |
|
260 |
! ! |
|
0 | 261 |
|
99 | 262 |
!VariableVerticalPanel methodsFor:'accessing'! |
263 |
||
264 |
barHeight:nPixel |
|
265 |
"set the height of the separating bar" |
|
266 |
||
267 |
barHeight := nPixel. |
|
79 | 268 |
|
99 | 269 |
"if screen is very low-res, make certain bar is visible and catchable" |
270 |
(barHeight < 4) ifTrue:[ |
|
271 |
barHeight := 4 |
|
272 |
]. |
|
273 |
||
274 |
"make it even so spacing is equally spreadable among subviews" |
|
275 |
barHeight odd ifTrue:[ |
|
276 |
barHeight := barHeight + 1 |
|
277 |
] |
|
278 |
! |
|
279 |
||
105 | 280 |
barHeight |
281 |
"return the height of the separating bar" |
|
282 |
||
283 |
^ barHeight |
|
284 |
! |
|
285 |
||
99 | 286 |
add:aView |
287 |
"a view is added; make its size relative (if not already done)" |
|
288 |
||
289 |
"obsolete" self halt. |
|
290 |
||
291 |
super add:aView. |
|
292 |
shown ifTrue:[ |
|
293 |
(superView isNil or:[superView shown]) ifTrue:[ |
|
294 |
self setupSubviewSizes |
|
59 | 295 |
] |
0 | 296 |
] |
297 |
! |
|
298 |
||
99 | 299 |
removeSubView:aView |
300 |
"a view is removed; adjust other subviews sizes" |
|
0 | 301 |
|
99 | 302 |
super removeSubView:aView. |
7 | 303 |
shown ifTrue:[ |
99 | 304 |
(superView isNil or:[superView shown]) ifTrue:[ |
305 |
self setupSubviewSizes |
|
59 | 306 |
] |
0 | 307 |
] |
308 |
! |
|
309 |
||
99 | 310 |
handlePosition:aSymbol |
311 |
"define the position of the handle; the argument aSymbol |
|
312 |
may be one of #left, #right or #center" |
|
0 | 313 |
|
99 | 314 |
handlePosition := aSymbol |
315 |
! |
|
0 | 316 |
|
99 | 317 |
handlePosition |
318 |
"return the position of the handle" |
|
319 |
||
320 |
^ handlePosition |
|
321 |
! |
|
322 |
||
323 |
style:styleSymbol |
|
324 |
"define the style of the handle; |
|
325 |
styleSymbol may be #motif to draw a little knob or |
|
326 |
anything else to draw scrollBars handleForm" |
|
0 | 327 |
|
99 | 328 |
(styleSymbol ~~ handleStyle) ifTrue:[ |
329 |
handleStyle := styleSymbol. |
|
330 |
handleStyle == #next ifTrue:[ |
|
331 |
shadowForm := self class shadowFormOn:device. |
|
332 |
lightForm := self class lightFormOn:device. |
|
333 |
] ifFalse:[ |
|
334 |
shadowForm := lightForm := nil |
|
335 |
]. |
|
79 | 336 |
|
99 | 337 |
shadowForm notNil ifTrue:[ |
338 |
(self is3D and:[handleStyle ~~ #motif]) ifTrue:[ |
|
339 |
self barHeight:(shadowForm height + 2). |
|
340 |
barWidth := shadowForm width |
|
341 |
] |
|
59 | 342 |
]. |
99 | 343 |
shown ifTrue:[ |
344 |
self resizeSubviewsFrom:1 to:(subViews size). |
|
345 |
self redraw |
|
346 |
] |
|
347 |
] |
|
348 |
! ! |
|
349 |
||
350 |
!VariableVerticalPanel methodsFor:'initializing'! |
|
351 |
||
352 |
fixSize |
|
353 |
extentChanged ifTrue:[ |
|
354 |
super fixSize. |
|
355 |
self resizeSubviewsFrom:1 to:(subViews size) |
|
0 | 356 |
] ifFalse:[ |
99 | 357 |
super fixSize |
0 | 358 |
] |
359 |
! |
|
360 |
||
105 | 361 |
initialize |
362 |
super initialize. |
|
363 |
noColor := Color noColor. |
|
364 |
! |
|
365 |
||
99 | 366 |
initStyle |
367 |
|mm| |
|
0 | 368 |
|
99 | 369 |
super initStyle. |
0 | 370 |
|
99 | 371 |
handleColor := DefaultHandleColor on:device. |
0 | 372 |
|
99 | 373 |
showHandle := DefaultShowHandle. |
63 | 374 |
|
99 | 375 |
DefaultHandleStyle isNil ifTrue:[ |
130 | 376 |
handleStyle := styleSheet name |
99 | 377 |
] ifFalse:[ |
378 |
handleStyle := DefaultHandleStyle |
|
379 |
]. |
|
380 |
handleStyle == #next ifTrue:[ |
|
381 |
shadowForm := self class shadowFormOn:device. |
|
382 |
lightForm := self class lightFormOn:device. |
|
63 | 383 |
|
99 | 384 |
self barHeight:(shadowForm height + 2). |
385 |
barWidth := shadowForm width. |
|
0 | 386 |
] ifFalse:[ |
99 | 387 |
shadowForm := lightForm := nil. |
0 | 388 |
]. |
389 |
||
99 | 390 |
handlePosition := DefaultHandlePosition. |
391 |
trackLine := DefaultTrackingLine. |
|
392 |
separatingLine := DefaultSeparatingLine. |
|
79 | 393 |
|
99 | 394 |
mm := device verticalPixelPerMillimeter. |
395 |
self is3D ifTrue:[ |
|
396 |
self barHeight:(3 * mm) rounded |
|
397 |
] ifFalse:[ |
|
398 |
self barHeight:(2 * mm) rounded |
|
0 | 399 |
]. |
99 | 400 |
barWidth := (2 * mm) rounded. "motif style width" |
401 |
handleStyle == #mswindows ifTrue:[ |
|
402 |
barWidth := (ArrowButton new direction:#up) width + 1 |
|
403 |
]. |
|
404 |
! |
|
405 |
||
105 | 406 |
defaultControllerClass |
407 |
^ VariableVerticalPanelController |
|
408 |
||
409 |
||
0 | 410 |
! |
411 |
||
99 | 412 |
initCursor |
413 |
"set the cursor - a double arrow" |
|
0 | 414 |
|
99 | 415 |
DefaultCursor notNil ifTrue:[ |
416 |
cursor := DefaultCursor |
|
417 |
] ifFalse:[ |
|
418 |
cursor := Cursor sourceForm:(Form fromFile:'VVPanel.xbm') |
|
419 |
maskForm:(Form fromFile:'VVPanel_m.xbm') |
|
420 |
hotX:8 |
|
421 |
hotY:8. |
|
422 |
" |
|
423 |
if bitmaps are not available, use a standard cursor |
|
424 |
" |
|
425 |
cursor isNil ifTrue:[ |
|
426 |
"which one looks better ?" |
|
427 |
cursor := Cursor upDownArrow |
|
428 |
"cursor := Cursor upLimitArrow" |
|
429 |
]. |
|
430 |
DefaultCursor := cursor |
|
431 |
] |
|
0 | 432 |
! ! |
433 |
||
434 |
!VariableVerticalPanel methodsFor:'private'! |
|
435 |
||
99 | 436 |
handleOriginsFrom:start to:stop do:aBlock |
437 |
"evaluate the argument block for some handle-origins" |
|
0 | 438 |
|
132 | 439 |
|x hw hDelta |
440 |
first "{ Class: SmallInteger }" |
|
441 |
last "{ Class: SmallInteger }"| |
|
0 | 442 |
|
99 | 443 |
subViews notNil ifTrue:[ |
116 | 444 |
shadowForm notNil ifTrue:[ |
445 |
hw := shadowForm width |
|
446 |
] ifFalse:[ |
|
447 |
hw := barWidth |
|
448 |
]. |
|
449 |
(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[ |
|
450 |
hDelta := barWidth // 2. |
|
451 |
] ifFalse:[ |
|
452 |
hDelta := 0 |
|
453 |
]. |
|
454 |
(handlePosition == #left) ifTrue:[ |
|
455 |
x := hDelta |
|
456 |
] ifFalse:[ |
|
457 |
(handlePosition == #right) ifTrue:[ |
|
458 |
x := width - (1 "2" * hw) - margin - hDelta. |
|
459 |
] ifFalse:[ |
|
460 |
x := width - barWidth // 2 |
|
461 |
] |
|
462 |
]. |
|
132 | 463 |
first := start + 1. |
464 |
last := stop. |
|
465 |
first to:last do:[:index | |
|
116 | 466 |
|view y| |
0 | 467 |
|
116 | 468 |
view := subViews at:index. |
469 |
y := view top "origin y" - barHeight + 1. |
|
470 |
aBlock value:(x @ y) |
|
471 |
] |
|
0 | 472 |
] |
473 |
! |
|
474 |
||
475 |
resizeSubviewsFrom:start to:stop |
|
476 |
"readjust size of some subviews" |
|
477 |
||
478 |
|step nSubviews| |
|
479 |
||
480 |
subViews notNil ifTrue:[ |
|
116 | 481 |
(start <= stop) ifTrue:[ |
482 |
step := 1 |
|
483 |
] ifFalse:[ |
|
484 |
step := -1 |
|
485 |
]. |
|
486 |
nSubviews := subViews size. |
|
487 |
start to:stop by:step do:[:index | |
|
488 |
|bw view o1 o2 relOrg relCorner newOrg newCorner newExt| |
|
0 | 489 |
|
116 | 490 |
view := subViews at:index. |
491 |
bw := view borderWidth. |
|
0 | 492 |
|
116 | 493 |
index == 1 ifTrue:[ |
494 |
o1 := 0. |
|
495 |
] ifFalse:[ |
|
496 |
o1 := barHeight // 2 - bw |
|
497 |
]. |
|
498 |
index == nSubviews ifTrue:[ |
|
499 |
o2 := 0. |
|
500 |
] ifFalse:[ |
|
501 |
o2 := barHeight // 2 - bw |
|
502 |
]. |
|
0 | 503 |
|
105 | 504 |
" |
116 | 505 |
relCorner := view relativeCorner. |
506 |
relCorner isNil ifTrue:[ |
|
507 |
self error:'subview must have relative corner' |
|
508 |
]. |
|
509 |
newCorner := view cornerFromRelativeCorner. |
|
510 |
newCorner notNil ifTrue:[ |
|
511 |
newCorner y:(newCorner y - o2) |
|
512 |
]. |
|
0 | 513 |
|
116 | 514 |
relOrg := view relativeOrigin. |
515 |
relOrg isNil ifTrue:[ |
|
516 |
self error:'subview must have relative origin' |
|
517 |
]. |
|
518 |
newOrg := view originFromRelativeOrigin. |
|
519 |
newOrg notNil ifTrue:[ |
|
520 |
(index ~~ 1) ifTrue:[ |
|
521 |
newOrg y:(newOrg y + o1) |
|
522 |
]. |
|
523 |
]. |
|
524 |
view pixelOrigin:newOrg corner:newCorner |
|
105 | 525 |
" |
116 | 526 |
newOrg := view computeOrigin. |
527 |
newOrg notNil ifTrue:[ |
|
528 |
(index ~~ 1) ifTrue:[ |
|
529 |
newOrg y:(newOrg y + o1) |
|
530 |
]. |
|
531 |
]. |
|
532 |
newExt := view computeExtent. |
|
533 |
newExt notNil ifTrue:[ |
|
534 |
newExt y:(newExt y - o2 - o1) |
|
535 |
]. |
|
536 |
view pixelOrigin:newOrg extent:newExt. |
|
537 |
] |
|
0 | 538 |
] |
539 |
! |
|
540 |
||
105 | 541 |
handleOriginsDo:aBlock |
542 |
"evaluate the argument block for every handle-origin" |
|
543 |
||
544 |
self handleOriginsFrom:1 to:(subViews size) do:aBlock |
|
545 |
! |
|
546 |
||
99 | 547 |
anyNonRelativeSubviews |
548 |
"return true, if any of my subviews has no relative origin/extent" |
|
549 |
||
550 |
1 to:(subViews size) do:[:index | |
|
551 |
|view| |
|
0 | 552 |
|
99 | 553 |
view := subViews at:index. |
554 |
view relativeExtent isNil ifTrue:[^ true]. |
|
555 |
view relativeOrigin isNil ifTrue:[^ true] |
|
556 |
]. |
|
557 |
^ false |
|
558 |
! |
|
0 | 559 |
|
99 | 560 |
setupSubviewSizes |
561 |
"setup subviews sizes (in case of non-relative sizes)" |
|
562 |
||
563 |
|y h| |
|
564 |
||
565 |
self anyNonRelativeSubviews ifTrue:[ |
|
566 |
"there is at least one subview without |
|
567 |
relative origin/extent - setup all subviews |
|
568 |
to spread evenly ..." |
|
569 |
||
570 |
y := 0.0. |
|
571 |
h := 1.0 / (subViews size). |
|
572 |
||
573 |
1 to:(subViews size) do:[:index | |
|
574 |
|view| |
|
0 | 575 |
|
59 | 576 |
view := subViews at:index. |
99 | 577 |
index == subViews size ifTrue:[ |
578 |
view origin:(0.0 @ y) corner:(1.0 @ 1.0) |
|
579 |
] ifFalse:[ |
|
580 |
view origin:(0.0 @ y) corner:(1.0 @ (y + h)) |
|
581 |
]. |
|
582 |
y := y + h |
|
59 | 583 |
] |
0 | 584 |
] |
99 | 585 |
! ! |
586 |
||
587 |
!VariableVerticalPanel methodsFor:'event handling'! |
|
588 |
||
589 |
sizeChanged:how |
|
590 |
"tell subviews if I change size" |
|
0 | 591 |
|
99 | 592 |
shown ifTrue:[ |
116 | 593 |
(how == #smaller) ifTrue:[ |
594 |
self resizeSubviewsFrom:1 to:(subViews size) |
|
595 |
] ifFalse:[ |
|
596 |
self resizeSubviewsFrom:(subViews size) to:1 |
|
597 |
] |
|
105 | 598 |
]. |
599 |
self changed:#sizeOfView with:how. |
|
99 | 600 |
! ! |