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