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