0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 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:#Scroller
|
|
14 |
instanceVariableNames:'thumbOrigin thumbHeight thumbColor thumbFrameColor
|
59
|
15 |
scrollAction moveDirection
|
|
16 |
thumbFrame thumbLevel
|
|
17 |
scrolling pressOffset
|
|
18 |
synchronousOperation
|
|
19 |
shadowForm lightForm inset
|
|
20 |
thumbShadowColor thumbLightColor
|
|
21 |
thumbSoftEdge
|
|
22 |
thumbHalfShadowColor thumbHalfLightColor
|
|
23 |
thumbFrameSizeDifference
|
|
24 |
tallyLevel tallyMarks
|
|
25 |
fixThumbHeight'
|
|
26 |
classVariableNames: 'HandleShadowForm HandleLightForm
|
|
27 |
DefaultViewBackground
|
|
28 |
DefaultThumbColor DefaultTallyMarks DefaultTallyLevel
|
|
29 |
DefaultLevel DefaultBorderWidth DefaultThumbLevel
|
|
30 |
DefaultInset DefaultThumbFrameColor
|
|
31 |
DefaultFixThumbHeight DefaultSoftEdge'
|
0
|
32 |
poolDictionaries:''
|
|
33 |
category:'Views-Interactors'
|
|
34 |
!
|
|
35 |
|
|
36 |
Scroller comment:'
|
5
|
37 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
38 |
All Rights Reserved
|
0
|
39 |
|
60
|
40 |
$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.9 1994-10-28 03:25:23 claus Exp $
|
3
|
41 |
'!
|
|
42 |
|
|
43 |
!Scroller class methodsFor:'documentation'!
|
|
44 |
|
38
|
45 |
copyright
|
|
46 |
"
|
|
47 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
48 |
All Rights Reserved
|
38
|
49 |
|
|
50 |
This software is furnished under a license and may be used
|
|
51 |
only in accordance with the terms of that license and with the
|
|
52 |
inclusion of the above copyright notice. This software may not
|
|
53 |
be provided or otherwise made available to, or used by, any
|
|
54 |
other person. No title to or ownership of the software is
|
|
55 |
hereby transferred.
|
|
56 |
"
|
|
57 |
!
|
|
58 |
|
|
59 |
version
|
|
60 |
"
|
60
|
61 |
$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.9 1994-10-28 03:25:23 claus Exp $
|
38
|
62 |
"
|
|
63 |
!
|
|
64 |
|
3
|
65 |
documentation
|
|
66 |
"
|
38
|
67 |
this class implements the scroller for scrollbars.
|
|
68 |
it can also be used by itself for scrollbars without step-buttons.
|
|
69 |
When moved, a predefined action is performed.
|
|
70 |
Beside the obvious 3D rectangle, a scroller may draw a know-form
|
|
71 |
(as in NeXT) or little tally marks (as on SGI) in itself.
|
|
72 |
These are controlled by the shadowForm, lightForm, tallyLevel and tallyMarks
|
|
73 |
instance variables.
|
|
74 |
The scroller can work synchronous (i.e. every move leads to an immediate evaluation
|
|
75 |
of the action, or asynchronous (i.e. perform action on end-of move).
|
|
76 |
By default, scrollers are synchronous - asynchronous makes sense, if the scroll
|
|
77 |
operation (redraw) is expensive.
|
0
|
78 |
|
38
|
79 |
Instance variables:
|
0
|
80 |
|
38
|
81 |
thumbOrigin <Number> origin of thumb (in percent)
|
|
82 |
thumbHeight <Number> height of thumb (in percent)
|
|
83 |
thumbColor <Color> color of thumb
|
|
84 |
thumbFrameColor <Color> color of the frame around the thumb
|
|
85 |
scrollAction <Block> 1 arg block to be evaluated when scrolled
|
59
|
86 |
(arg is position in percent)
|
38
|
87 |
moveDirection <Symbol> #x or #y
|
|
88 |
thumbFrame <Rectangle> frame of thumb in pixels (cached)
|
|
89 |
thumbLevel <Number> level of thumb if 3d
|
|
90 |
scrolling <Boolean> true during scroll
|
|
91 |
pressOffset <Number> temporary (offset into frame when move started)
|
|
92 |
synchronousOperation <Boolean> true if synchronous (i.e. dont wait till release
|
59
|
93 |
to perform action)
|
38
|
94 |
shadowForm <Form> bitmap of knob if any (shadow part)
|
|
95 |
lightForm <Form> bitmap of knob if any (light part)
|
|
96 |
inset <Integer> number of pixels to inset thumb from view borders
|
|
97 |
thumbShadowColor <Color> color do draw dark parts of thumb
|
|
98 |
thumblightColor <Color> color to draw light parts of thumb
|
|
99 |
thumbSoftEdge <Boolean> true if edges of thumb are to appear smooth
|
|
100 |
thumbHalfShadowColor <Color> used to draw smooth edges
|
|
101 |
thumbHalfLightColor <Color> used to draw smooth edges
|
|
102 |
thumbFrameSizeDifference <Integer> number of pixels the thumb is larger than
|
59
|
103 |
it should be (can be negative for mswin-style)
|
38
|
104 |
tallyLevel <Integer> if not zero, specifies if tally-marks should
|
59
|
105 |
go into or out of the display (actually only <0/>0 is checked)
|
|
106 |
I dont know of a better word for these ...
|
38
|
107 |
tallyMarks <Integer> number of tally marks
|
|
108 |
fixThumbHeight <Boolean> perform 'wrong' height computation a la mswindows
|
|
109 |
|
|
110 |
notice: for mswindows style, we force a WRONG thumb-frame
|
|
111 |
computation, to make the thumb have constant size;
|
|
112 |
if you dont like that (I do not :-), set fixThumbHeight to false (in initStyle).
|
3
|
113 |
"
|
|
114 |
! !
|
0
|
115 |
|
|
116 |
!Scroller class methodsFor:'defaults'!
|
|
117 |
|
59
|
118 |
updateStyleCache
|
60
|
119 |
DefaultViewBackground := StyleSheet colorAt:'scrollerViewBackground'.
|
|
120 |
DefaultThumbColor := StyleSheet colorAt:'scrollerThumbColor'.
|
|
121 |
DefaultThumbFrameColor := StyleSheet colorAt:'scrollerThumbFrameColor'.
|
59
|
122 |
DefaultTallyMarks := StyleSheet at:'scrollerNTallyMarks' default:0.
|
|
123 |
DefaultTallyLevel := 0.
|
|
124 |
DefaultTallyMarks ~~ 0 ifTrue:[
|
|
125 |
DefaultTallyLevel := StyleSheet at:'scrollerTallyLevel' default:1.
|
|
126 |
].
|
|
127 |
DefaultLevel := StyleSheet at:'scrollerLevel' default:0.
|
|
128 |
DefaultBorderWidth := StyleSheet at:'scrollerBorderWidth' default:(StyleSheet at:'borderWidth').
|
|
129 |
DefaultThumbLevel := StyleSheet at:'scrollerThumbLevel' default:0.
|
|
130 |
DefaultInset := StyleSheet at:'scrollerThumbInset' default:0.
|
|
131 |
DefaultFixThumbHeight := StyleSheet at:'scrollerThumbFixHeight' default:false.
|
|
132 |
DefaultSoftEdge := StyleSheet at:'scrollerThumbSoftEdge' default:false.
|
|
133 |
!
|
|
134 |
|
0
|
135 |
handleShadowFormOn:aDisplay
|
|
136 |
"answer the form used for the handles shadow area;
|
|
137 |
cache the one for Display for the next round"
|
|
138 |
|
|
139 |
|f|
|
|
140 |
|
22
|
141 |
((aDisplay == Display) and:[HandleShadowForm notNil]) ifTrue:[
|
59
|
142 |
^ HandleShadowForm
|
0
|
143 |
].
|
|
144 |
f := Form fromFile:'HandleShadow.xbm' resolution:100 on:aDisplay.
|
|
145 |
f isNil ifTrue:[
|
59
|
146 |
f := Form width:8 height:8 fromArray:#[2r00111100
|
|
147 |
2r01100000
|
|
148 |
2r11000000
|
|
149 |
2r11000000
|
|
150 |
2r11000000
|
|
151 |
2r11000000
|
|
152 |
2r01000000
|
|
153 |
2r00000000]
|
|
154 |
on:aDisplay
|
0
|
155 |
].
|
|
156 |
(aDisplay == Display) ifTrue:[
|
59
|
157 |
HandleShadowForm := f
|
0
|
158 |
].
|
|
159 |
^ f
|
|
160 |
!
|
|
161 |
|
|
162 |
handleLightFormOn:aDisplay
|
|
163 |
"answer the form used for the handles light area;
|
|
164 |
cache the one for Display for the next round"
|
|
165 |
|
|
166 |
|f|
|
|
167 |
|
22
|
168 |
((aDisplay == Display) and:[HandleLightForm notNil]) ifTrue:[
|
59
|
169 |
^ HandleLightForm
|
0
|
170 |
].
|
|
171 |
f := Form fromFile:'HandleLight.xbm' resolution:100 on:aDisplay.
|
|
172 |
f isNil ifTrue:[
|
59
|
173 |
f := Form width:8 height:8 fromArray:#[2r00000000
|
|
174 |
2r00000010
|
|
175 |
2r00000011
|
|
176 |
2r00000011
|
|
177 |
2r00000011
|
|
178 |
2r00000011
|
|
179 |
2r00000110
|
|
180 |
2r00111100]
|
|
181 |
on:aDisplay
|
0
|
182 |
].
|
|
183 |
(aDisplay == Display) ifTrue:[
|
59
|
184 |
HandleLightForm := f
|
0
|
185 |
].
|
|
186 |
^ f
|
|
187 |
! !
|
|
188 |
|
|
189 |
!Scroller methodsFor:'initialization'!
|
|
190 |
|
|
191 |
initialize
|
|
192 |
"initialize - setup instvars from defaults"
|
|
193 |
|
|
194 |
super initialize.
|
38
|
195 |
self computeInitialExtent.
|
0
|
196 |
moveDirection := #y.
|
|
197 |
|
|
198 |
scrolling := false.
|
|
199 |
synchronousOperation := true.
|
|
200 |
|
|
201 |
thumbOrigin := 0.
|
|
202 |
thumbHeight := 100.
|
38
|
203 |
thumbFrameSizeDifference := 0.
|
0
|
204 |
|
38
|
205 |
"/ inset := 1.
|
0
|
206 |
|
38
|
207 |
"/ self computeThumbFrame
|
|
208 |
!
|
|
209 |
|
|
210 |
computeInitialExtent
|
|
211 |
^ self
|
0
|
212 |
!
|
|
213 |
|
|
214 |
initStyle
|
|
215 |
"initialize style dep. stuff"
|
|
216 |
|
|
217 |
super initStyle.
|
|
218 |
|
59
|
219 |
DefaultViewBackground notNil ifTrue:[
|
|
220 |
viewBackground := DefaultViewBackground on:device.
|
|
221 |
].
|
38
|
222 |
|
59
|
223 |
tallyMarks := DefaultTallyMarks.
|
|
224 |
tallyLevel := DefaultTallyLevel.
|
|
225 |
DefaultLevel ~~ level ifTrue:[
|
|
226 |
self level:DefaultLevel.
|
38
|
227 |
].
|
59
|
228 |
DefaultBorderWidth ~~ borderWidth ifTrue:[
|
|
229 |
self borderWidth:DefaultBorderWidth.
|
0
|
230 |
].
|
59
|
231 |
thumbLevel := DefaultThumbLevel.
|
|
232 |
inset := DefaultInset.
|
|
233 |
fixThumbHeight := DefaultFixThumbHeight.
|
|
234 |
thumbSoftEdge := DefaultSoftEdge.
|
0
|
235 |
|
|
236 |
thumbShadowColor := shadowColor.
|
|
237 |
thumbLightColor := lightColor.
|
|
238 |
thumbSoftEdge ifTrue:[
|
59
|
239 |
device hasGreyscales ifTrue:[
|
|
240 |
thumbHalfShadowColor := halfShadowColor.
|
|
241 |
thumbHalfLightColor := halfLightColor
|
|
242 |
] ifFalse:[
|
|
243 |
thumbHalfShadowColor := Color darkGrey.
|
|
244 |
thumbHalfLightColor := White
|
|
245 |
]
|
0
|
246 |
].
|
|
247 |
device hasGreyscales ifFalse:[
|
59
|
248 |
thumbShadowColor := Black.
|
|
249 |
"/ thumbLightColor := White.
|
|
250 |
StyleSheet name = #motif ifTrue:[
|
|
251 |
DefaultThumbColor isNil ifTrue:[
|
|
252 |
thumbColor := White "Color grey".
|
|
253 |
].
|
|
254 |
]
|
0
|
255 |
].
|
|
256 |
|
59
|
257 |
DefaultThumbColor notNil ifTrue:[
|
|
258 |
thumbColor := DefaultThumbColor on:device
|
|
259 |
] ifFalse:[
|
|
260 |
thumbColor := White.
|
|
261 |
StyleSheet name ~= #normal ifTrue:[
|
|
262 |
device hasGreyscales ifFalse:[
|
|
263 |
thumbColor := Color grey
|
|
264 |
].
|
|
265 |
].
|
|
266 |
].
|
0
|
267 |
|
59
|
268 |
DefaultThumbFrameColor notNil ifTrue:[
|
60
|
269 |
thumbFrameColor := DefaultThumbFrameColor on:device.
|
59
|
270 |
].
|
|
271 |
|
|
272 |
StyleSheet name = #next ifTrue:[
|
|
273 |
shadowForm := self class handleShadowFormOn:device.
|
|
274 |
lightForm := self class handleLightFormOn:device
|
22
|
275 |
] ifFalse:[
|
59
|
276 |
shadowForm := lightForm := nil
|
0
|
277 |
].
|
|
278 |
|
|
279 |
drawableId notNil ifTrue:[
|
59
|
280 |
self computeThumbFrame
|
0
|
281 |
]
|
|
282 |
!
|
|
283 |
|
|
284 |
initCursor
|
|
285 |
"set the cursor - a hand"
|
|
286 |
|
|
287 |
cursor := Cursor hand
|
|
288 |
!
|
|
289 |
|
|
290 |
initEvents
|
|
291 |
self enableButtonEvents.
|
|
292 |
self enableButtonMotionEvents
|
|
293 |
! !
|
|
294 |
|
|
295 |
!Scroller methodsFor:'accessing'!
|
|
296 |
|
|
297 |
is3D
|
59
|
298 |
StyleSheet name = #mswindows ifTrue:[^ true].
|
0
|
299 |
^ super is3D
|
|
300 |
!
|
|
301 |
|
|
302 |
asynchronousOperation
|
|
303 |
"set scroll-mode to be asynchronous - scroll action is performed after
|
|
304 |
scrolling, when mouse-button is finally released"
|
|
305 |
|
|
306 |
synchronousOperation := false
|
|
307 |
!
|
|
308 |
|
|
309 |
synchronousOperation
|
|
310 |
"set scroll-mode to be synchronous - scroll action is performed for
|
|
311 |
every movement of thumb"
|
|
312 |
|
|
313 |
synchronousOperation := true
|
|
314 |
!
|
|
315 |
|
|
316 |
scrollAction:aBlock
|
|
317 |
"set the scroll action, aBlock which is evaluated when scrolled"
|
|
318 |
|
|
319 |
scrollAction := aBlock
|
|
320 |
!
|
|
321 |
|
|
322 |
scrollAction
|
|
323 |
"answer the scroll action block"
|
|
324 |
|
|
325 |
^ scrollAction
|
|
326 |
!
|
|
327 |
|
38
|
328 |
scrollDownAction:aBlock
|
|
329 |
"ignored -
|
|
330 |
but implemented, so that scroller can be used in place of a scrollbar"
|
|
331 |
!
|
|
332 |
|
|
333 |
scrollUpAction:aBlock
|
|
334 |
"ignored -
|
|
335 |
but implemented, so that scroller can be used in place of a scrollbar"
|
|
336 |
!
|
|
337 |
|
0
|
338 |
thumbOrigin
|
|
339 |
"answer the thumbs origin (in percent)"
|
|
340 |
|
|
341 |
^ thumbOrigin
|
|
342 |
!
|
|
343 |
|
|
344 |
thumbOrigin:newOrigin
|
|
345 |
"set the thumbs origin (in percent)"
|
|
346 |
|
|
347 |
|realNewOrigin oldFrame oldTop oldBot thumbTop thumbBot
|
|
348 |
tH "{ Class: SmallInteger }"
|
|
349 |
tW delta left|
|
|
350 |
|
|
351 |
((newOrigin + thumbHeight) > 100) ifTrue:[
|
59
|
352 |
realNewOrigin := 100 - thumbHeight
|
0
|
353 |
] ifFalse: [
|
59
|
354 |
realNewOrigin := newOrigin
|
0
|
355 |
].
|
|
356 |
(realNewOrigin > 100) ifTrue:[
|
59
|
357 |
realNewOrigin := 100
|
0
|
358 |
] ifFalse: [
|
59
|
359 |
(realNewOrigin < 0) ifTrue:[
|
|
360 |
realNewOrigin := 0
|
|
361 |
]
|
0
|
362 |
].
|
38
|
363 |
((realNewOrigin ~= thumbOrigin) or:[thumbFrame isNil]) ifTrue:[
|
59
|
364 |
thumbOrigin := realNewOrigin.
|
0
|
365 |
|
59
|
366 |
shown ifTrue:[
|
|
367 |
oldFrame := thumbFrame.
|
|
368 |
self computeThumbFrame.
|
|
369 |
(thumbHeight = 100) ifTrue:[^ self].
|
38
|
370 |
|
59
|
371 |
(thumbFrame ~~ oldFrame) ifTrue:[
|
|
372 |
oldFrame isNil ifTrue:[
|
|
373 |
self drawThumb.
|
|
374 |
^ self
|
|
375 |
].
|
|
376 |
tH := thumbFrame height.
|
|
377 |
tW := thumbFrame width.
|
|
378 |
oldTop := oldFrame top.
|
|
379 |
oldBot := oldTop + tH.
|
0
|
380 |
|
59
|
381 |
thumbTop := thumbFrame top.
|
|
382 |
thumbBot := thumbTop + tH.
|
0
|
383 |
|
59
|
384 |
left := thumbFrame left.
|
0
|
385 |
|
59
|
386 |
(oldBot >= height) ifTrue:[
|
|
387 |
"cannot copy - thumb was below end"
|
|
388 |
self drawThumbBackgroundInX:left y:oldTop
|
|
389 |
width:tW height:(height - oldTop).
|
|
390 |
self drawThumb.
|
|
391 |
^ self
|
|
392 |
].
|
0
|
393 |
|
59
|
394 |
self catchExpose.
|
|
395 |
self copyFrom:self x:left y:oldTop
|
|
396 |
toX:left y:thumbTop
|
|
397 |
width:tW height:tH.
|
0
|
398 |
|
38
|
399 |
"/ self catchExpose.
|
24
|
400 |
|
59
|
401 |
oldTop > thumbTop ifTrue:[
|
|
402 |
delta := oldTop - thumbTop.
|
|
403 |
oldTop > thumbBot ifTrue:[
|
|
404 |
self drawThumbBackgroundInX:left y:oldTop
|
|
405 |
width:tW height:(tH + 1)
|
|
406 |
] ifFalse:[
|
|
407 |
self drawThumbBackgroundInX:left y:thumbBot
|
|
408 |
width:tW height:delta
|
|
409 |
]
|
|
410 |
] ifFalse:[
|
|
411 |
delta := thumbTop - oldTop.
|
|
412 |
oldBot < thumbTop ifTrue:[
|
|
413 |
self drawThumbBackgroundInX:left y:oldTop
|
|
414 |
width:tW height:(tH + 1)
|
|
415 |
] ifFalse:[
|
|
416 |
self drawThumbBackgroundInX:left y:oldTop
|
|
417 |
width:tW height:delta
|
|
418 |
]
|
|
419 |
].
|
|
420 |
self waitForExpose
|
|
421 |
]
|
|
422 |
]
|
0
|
423 |
]
|
|
424 |
!
|
|
425 |
|
|
426 |
thumbHeight
|
|
427 |
"answer the thumbs height (in percent)"
|
|
428 |
|
|
429 |
^ thumbHeight
|
|
430 |
!
|
|
431 |
|
|
432 |
thumbHeight:newHeight
|
|
433 |
"set the thumbs height (in percent)"
|
|
434 |
|
|
435 |
|realNewHeight oldFrame|
|
|
436 |
|
|
437 |
(newHeight > 100) ifTrue:[
|
59
|
438 |
realNewHeight := 100
|
0
|
439 |
] ifFalse:[
|
59
|
440 |
realNewHeight := newHeight
|
0
|
441 |
].
|
38
|
442 |
((realNewHeight ~= thumbHeight) or:[thumbFrame isNil]) ifTrue:[
|
59
|
443 |
thumbHeight := realNewHeight.
|
|
444 |
shown ifTrue:[
|
|
445 |
oldFrame := thumbFrame.
|
|
446 |
self computeThumbFrame.
|
|
447 |
(fixThumbHeight or:[oldFrame ~~ thumbFrame]) ifTrue:[
|
|
448 |
oldFrame notNil ifTrue:[
|
|
449 |
self drawThumbBackgroundInX:(oldFrame left)
|
|
450 |
y:(oldFrame top)
|
|
451 |
width:(oldFrame width)
|
|
452 |
height:(oldFrame height).
|
|
453 |
].
|
|
454 |
self drawThumb
|
|
455 |
]
|
|
456 |
]
|
0
|
457 |
]
|
|
458 |
!
|
|
459 |
|
|
460 |
thumbOrigin:newOrigin thumbHeight:newHeight
|
|
461 |
"set both thumbs height and origin (in percent)"
|
|
462 |
|
38
|
463 |
|realNewOrigin realNewHeight old new changed|
|
0
|
464 |
|
|
465 |
(newHeight > 100) ifTrue:[
|
59
|
466 |
realNewHeight := 100
|
0
|
467 |
] ifFalse:[
|
59
|
468 |
realNewHeight := newHeight
|
0
|
469 |
].
|
|
470 |
((newOrigin + realNewHeight) > 100) ifTrue:[
|
59
|
471 |
realNewOrigin := 100 - realNewHeight
|
0
|
472 |
] ifFalse: [
|
59
|
473 |
realNewOrigin := newOrigin
|
0
|
474 |
].
|
|
475 |
(realNewOrigin < 0) ifTrue: [
|
59
|
476 |
realNewOrigin := 0
|
0
|
477 |
].
|
|
478 |
|
38
|
479 |
changed := (realNewHeight ~= thumbHeight) or:[realNewOrigin ~= thumbOrigin].
|
|
480 |
(changed or:[thumbFrame isNil]) ifTrue:[
|
59
|
481 |
old := self absFromPercent:thumbOrigin.
|
|
482 |
new := self absFromPercent:realNewOrigin.
|
|
483 |
changed := old ~~ new.
|
|
484 |
changed ifFalse:[
|
|
485 |
old := self absFromPercent:thumbHeight.
|
|
486 |
new := self absFromPercent:realNewHeight.
|
|
487 |
changed := (old ~~ new)
|
|
488 |
].
|
|
489 |
(changed or:[thumbFrame isNil]) ifTrue:[
|
|
490 |
thumbOrigin := realNewOrigin.
|
|
491 |
thumbHeight := realNewHeight.
|
|
492 |
shown ifTrue:[
|
|
493 |
thumbFrame notNil ifTrue:[
|
|
494 |
self drawThumbBackgroundInX:(thumbFrame left)
|
|
495 |
y:(thumbFrame top)
|
|
496 |
width:(thumbFrame width)
|
|
497 |
height:(thumbFrame height).
|
|
498 |
].
|
|
499 |
self computeThumbFrame.
|
|
500 |
self drawThumb
|
|
501 |
]
|
|
502 |
]
|
0
|
503 |
]
|
|
504 |
!
|
|
505 |
|
|
506 |
setThumbFor:aView
|
|
507 |
"get contents and size info from aView and adjust thumb"
|
|
508 |
|
38
|
509 |
|percentSize percentOrigin contentsSize contentsPosition viewsSize|
|
0
|
510 |
|
38
|
511 |
"
|
|
512 |
get the content's size
|
|
513 |
"
|
0
|
514 |
aView isNil ifTrue:[
|
59
|
515 |
contentsSize := 0
|
0
|
516 |
] ifFalse:[
|
59
|
517 |
moveDirection == #y ifTrue:[
|
|
518 |
contentsSize := aView heightOfContents
|
|
519 |
] ifFalse:[
|
|
520 |
contentsSize := aView widthOfContents
|
|
521 |
]
|
0
|
522 |
].
|
38
|
523 |
|
|
524 |
(contentsSize = 0) ifTrue:[
|
59
|
525 |
percentSize := 100.
|
|
526 |
percentOrigin := 100
|
0
|
527 |
] ifFalse:[
|
59
|
528 |
viewsSize := (moveDirection == #y) ifTrue:[aView innerHeight] ifFalse:[aView innerWidth].
|
|
529 |
contentsPosition := (moveDirection == #y) ifTrue:[aView yOriginOfContents] ifFalse:[aView xOriginOfContents].
|
38
|
530 |
|
|
531 |
|
59
|
532 |
percentSize := viewsSize * 100.0 / contentsSize.
|
|
533 |
percentOrigin := contentsPosition * 100.0 / contentsSize.
|
|
534 |
percentOrigin + percentSize > 100.0 ifTrue:[
|
|
535 |
"actually showing stuff below contents of view"
|
7
|
536 |
"
|
59
|
537 |
contentsSize := contentsPosition + aView innerHeight.
|
|
538 |
percentSize := viewsSize * 100.0 / contentsSize.
|
|
539 |
percentOrigin := contentsPosition * 100.0 / contentsSize
|
7
|
540 |
"
|
59
|
541 |
]
|
0
|
542 |
].
|
|
543 |
(percentSize = thumbHeight) ifTrue:[
|
59
|
544 |
self thumbOrigin:percentOrigin
|
0
|
545 |
] ifFalse:[
|
59
|
546 |
(percentOrigin = thumbOrigin) ifTrue:[
|
|
547 |
self thumbHeight:percentSize
|
|
548 |
] ifFalse:[
|
|
549 |
self thumbOrigin:percentOrigin thumbHeight:percentSize
|
|
550 |
]
|
0
|
551 |
]
|
|
552 |
!
|
|
553 |
|
|
554 |
setThumbHeightFor:aView
|
|
555 |
"get contents and size info from aView and adjust thumb height"
|
|
556 |
|
38
|
557 |
|percent totalHeight viewsSize|
|
0
|
558 |
|
38
|
559 |
totalHeight := (moveDirection == #y) ifTrue:[aView heightOfContents]
|
59
|
560 |
ifFalse:[aView widthOfContents].
|
0
|
561 |
(totalHeight = 0) ifTrue:[
|
59
|
562 |
percent := 100
|
0
|
563 |
] ifFalse:[
|
59
|
564 |
viewsSize := (moveDirection == #y) ifTrue:[aView innerHeight]
|
|
565 |
ifFalse:[aView innerWidth].
|
|
566 |
percent := viewsSize * 100.0 / totalHeight
|
0
|
567 |
].
|
|
568 |
self thumbHeight:percent
|
|
569 |
!
|
|
570 |
|
|
571 |
setThumbOriginFor:aView
|
|
572 |
"get contents and size info from aView and adjust thumb origin"
|
|
573 |
|
38
|
574 |
|percent totalHeight contentsPosition|
|
0
|
575 |
|
38
|
576 |
totalHeight := (moveDirection == #y) ifTrue:[aView heightOfContents]
|
59
|
577 |
ifFalse:[aView widthOfContents].
|
0
|
578 |
(totalHeight = 0) ifTrue:[
|
59
|
579 |
percent := 100
|
0
|
580 |
] ifFalse:[
|
59
|
581 |
contentsPosition := (moveDirection == #y) ifTrue:[aView yOriginOfContents]
|
|
582 |
ifFalse:[aView xOriginOfContents].
|
|
583 |
percent := contentsPosition * 100.0 / totalHeight
|
0
|
584 |
].
|
|
585 |
self thumbOrigin:percent
|
|
586 |
!
|
|
587 |
|
|
588 |
thumbColor:aColor
|
|
589 |
"change the color of the thumb"
|
|
590 |
|
|
591 |
thumbColor := aColor on:device.
|
38
|
592 |
(style ~~ #normal) ifTrue:[
|
59
|
593 |
thumbShadowColor := aColor darkened on:device.
|
|
594 |
thumbLightColor := aColor lightened on:device.
|
|
595 |
thumbHalfShadowColor := thumbShadowColor darkened on:device.
|
|
596 |
thumbHalfLightColor := thumbLightColor lightened on:device.
|
0
|
597 |
].
|
|
598 |
shown ifTrue:[
|
59
|
599 |
self redraw
|
0
|
600 |
]
|
|
601 |
!
|
|
602 |
|
38
|
603 |
thumbColor
|
|
604 |
"return the thumbs color"
|
|
605 |
|
|
606 |
^ thumbColor
|
|
607 |
!
|
|
608 |
|
0
|
609 |
thumbFrame
|
|
610 |
"return the area used by the thumbFrame (in device coordinates).
|
7
|
611 |
Allows access to the thumbs physical screen position, for
|
0
|
612 |
example to position a label below (see Slider-Examples)"
|
|
613 |
|
59
|
614 |
thumbFrame isNil ifTrue:[ self computeThumbFrame].
|
0
|
615 |
^ thumbFrame
|
|
616 |
! !
|
|
617 |
|
|
618 |
!Scroller methodsFor:'private'!
|
|
619 |
|
|
620 |
absFromPercent:percent
|
|
621 |
"given a percentage, compute number of pixels"
|
|
622 |
|
|
623 |
|fullSize|
|
|
624 |
|
|
625 |
(moveDirection == #y) ifTrue:[
|
59
|
626 |
fullSize := height
|
0
|
627 |
] ifFalse:[
|
59
|
628 |
fullSize := width
|
0
|
629 |
].
|
38
|
630 |
"/ ^ ((percent * (fullSize - (margin * 2))) / 100) rounded
|
|
631 |
"/ 20-apr-94
|
|
632 |
^ ((percent * (fullSize - thumbFrameSizeDifference- (margin * 2))) / 100) rounded
|
0
|
633 |
!
|
|
634 |
|
|
635 |
percentFromAbs:absValue
|
|
636 |
"given a number of pixels, compute percentage"
|
|
637 |
|
|
638 |
|fullSize val|
|
|
639 |
|
|
640 |
(moveDirection == #y) ifTrue:[
|
59
|
641 |
fullSize := height
|
0
|
642 |
] ifFalse:[
|
59
|
643 |
fullSize := width
|
0
|
644 |
].
|
|
645 |
|
7
|
646 |
val := absValue / (fullSize - thumbFrameSizeDifference - (margin * 2)) * 100.
|
0
|
647 |
val < 0 ifTrue:[^ 0].
|
|
648 |
val > 100 ifTrue:[^ 100].
|
|
649 |
^ val
|
|
650 |
!
|
|
651 |
|
|
652 |
computeThumbFrame
|
38
|
653 |
"compute the thumbs frame (a rectangle) whenever thumb is moved,
|
|
654 |
changed height or the scrollers size has changed.
|
|
655 |
We take care, that the thumb will not become too small (i.e.
|
|
656 |
invisible or uncatchable).
|
|
657 |
Also, for mswindows style, its height/width is constant."
|
0
|
658 |
|
38
|
659 |
|newPos1 newPos2 newSize1 newSize2 nh nw ny nx
|
|
660 |
computedSize minSz sz1 sz2|
|
0
|
661 |
|
38
|
662 |
"compute position & size"
|
|
663 |
newPos1 := (self absFromPercent:thumbOrigin) + margin.
|
|
664 |
newSize1 := computedSize := self absFromPercent:thumbHeight.
|
0
|
665 |
(moveDirection == #y) ifTrue:[
|
59
|
666 |
sz1 := height.
|
|
667 |
sz2 := width
|
0
|
668 |
] ifFalse:[
|
59
|
669 |
sz1 := width.
|
|
670 |
sz2 := height
|
0
|
671 |
].
|
38
|
672 |
|
|
673 |
"
|
|
674 |
do we have to adjust the computed size ?
|
|
675 |
"
|
|
676 |
newPos2 := margin + inset.
|
|
677 |
newSize2 := sz2 - (2 * newPos2).
|
59
|
678 |
"/ (style ~~ #normal) ifTrue:[
|
|
679 |
thumbLevel ~~ 0 ifTrue:[
|
|
680 |
"
|
|
681 |
do not make thumb too small (for handle & to be catchable)
|
|
682 |
"
|
|
683 |
minSz := 10 + (2 * thumbLevel)
|
0
|
684 |
] ifFalse:[
|
59
|
685 |
"
|
|
686 |
do not make thumb too small (uncatchable)
|
|
687 |
"
|
|
688 |
minSz := 4
|
38
|
689 |
].
|
|
690 |
|
|
691 |
(newSize1 < minSz) ifTrue:[
|
59
|
692 |
newSize1 := minSz.
|
|
693 |
thumbFrameSizeDifference := newSize1 - computedSize
|
38
|
694 |
] ifFalse:[
|
59
|
695 |
thumbFrameSizeDifference := 0.
|
0
|
696 |
].
|
38
|
697 |
|
|
698 |
fixThumbHeight ifTrue:[
|
59
|
699 |
"have a fix-size thumb (i.e. mswindows style)"
|
38
|
700 |
|
59
|
701 |
newSize1 := sz2 - (2 * inset). "make it square"
|
|
702 |
thumbFrameSizeDifference := newSize1 - computedSize.
|
38
|
703 |
].
|
|
704 |
|
0
|
705 |
"
|
38
|
706 |
oops - if height does not relect real visibible area, we have to adjust the origin
|
0
|
707 |
"
|
7
|
708 |
(thumbFrameSizeDifference == 0) ifFalse:[
|
59
|
709 |
newPos1 := (self absFromPercent:thumbOrigin) + margin.
|
38
|
710 |
"/ newPos1 := ((thumbOrigin * (sz1 - thumbFrameSizeDifference - (margin * 2))) / 100) rounded + margin
|
0
|
711 |
].
|
|
712 |
|
|
713 |
(moveDirection == #y) ifTrue:[
|
59
|
714 |
ny := newPos1.
|
|
715 |
nx := newPos2.
|
|
716 |
nh := newSize1.
|
|
717 |
nw := newSize2.
|
|
718 |
ny + nh + margin > height ifTrue:[
|
|
719 |
ny := height - margin - nh
|
|
720 |
]
|
0
|
721 |
] ifFalse:[
|
59
|
722 |
nx := newPos1.
|
|
723 |
ny := newPos2.
|
|
724 |
nw := newSize1.
|
|
725 |
nh := newSize2.
|
|
726 |
nx + nw + margin > width ifTrue:[
|
|
727 |
nx := width - margin - nw
|
|
728 |
]
|
0
|
729 |
].
|
|
730 |
|
|
731 |
"
|
|
732 |
do not create new Rectangle if its the same anyway
|
|
733 |
"
|
|
734 |
thumbFrame notNil ifTrue:[
|
59
|
735 |
(ny == thumbFrame top) ifTrue:[
|
|
736 |
(nx == thumbFrame left) ifTrue:[
|
|
737 |
(nh == thumbFrame height) ifTrue:[
|
|
738 |
(nw == thumbFrame width) ifTrue:[ ^ self]
|
|
739 |
]
|
|
740 |
]
|
|
741 |
]
|
0
|
742 |
].
|
|
743 |
thumbFrame := Rectangle left:nx top:ny width:nw height:nh
|
|
744 |
! !
|
|
745 |
|
|
746 |
!Scroller methodsFor:'drawing'!
|
|
747 |
|
|
748 |
drawHandleFormAtX:x y:y
|
3
|
749 |
thumbShadowColor := thumbShadowColor on:device.
|
|
750 |
thumbLightColor := thumbLightColor on:device.
|
|
751 |
|
59
|
752 |
self paint:thumbShadowColor.
|
|
753 |
self displayForm:shadowForm x:x y:y.
|
|
754 |
self paint:thumbLightColor.
|
|
755 |
self displayForm:lightForm x:x y:y.
|
0
|
756 |
!
|
|
757 |
|
|
758 |
drawThumbBackgroundInX:x y:y width:w height:h
|
|
759 |
"draw part of the thumbs background; defined as a separate
|
38
|
760 |
method, to allow drawing of arbitrary patterns under thumb (see ColorSlider)."
|
0
|
761 |
|
|
762 |
self clearRectangleX:x y:y width:w height:h.
|
|
763 |
!
|
|
764 |
|
|
765 |
drawThumb
|
|
766 |
"draw the thumb"
|
|
767 |
|
|
768 |
|handleX handleY l t
|
|
769 |
w "{ Class: SmallInteger }"
|
|
770 |
h "{ Class: SmallInteger }"
|
|
771 |
x "{ Class: SmallInteger }"
|
|
772 |
y "{ Class: SmallInteger }"
|
22
|
773 |
mm xL xR yT yB color1 color2 savEdge|
|
0
|
774 |
|
38
|
775 |
(thumbHeight >= 100) ifTrue:[^ self].
|
|
776 |
moveDirection == #y ifTrue:[
|
59
|
777 |
thumbFrame height >= height ifTrue:[^ self].
|
38
|
778 |
] ifFalse:[
|
59
|
779 |
thumbFrame width >= width ifTrue:[^ self].
|
38
|
780 |
].
|
0
|
781 |
|
|
782 |
l := thumbFrame left.
|
|
783 |
t := thumbFrame top.
|
|
784 |
w := thumbFrame width.
|
|
785 |
h := thumbFrame height.
|
|
786 |
self paint:thumbColor.
|
38
|
787 |
self fillRectangleX:l y:t width:w-1 height:h.
|
0
|
788 |
|
59
|
789 |
thumbLevel == 0 ifTrue:[
|
|
790 |
thumbFrameColor notNil ifTrue:[
|
|
791 |
self paint:thumbFrameColor.
|
|
792 |
self displayRectangle:thumbFrame.
|
|
793 |
].
|
|
794 |
^ self
|
0
|
795 |
].
|
|
796 |
|
22
|
797 |
"what a kludge - must be a parameter to drawEdge..."
|
|
798 |
savEdge := softEdge.
|
|
799 |
softEdge := thumbSoftEdge.
|
0
|
800 |
self drawEdgesForX:l y:t width:w height:h level:thumbLevel
|
59
|
801 |
shadow:thumbShadowColor light:thumbLightColor
|
|
802 |
halfShadow:thumbHalfShadowColor halfLight:thumbHalfLightColor.
|
22
|
803 |
softEdge := savEdge.
|
0
|
804 |
|
59
|
805 |
thumbFrameColor notNil ifTrue:[
|
|
806 |
self paint:thumbFrameColor.
|
|
807 |
moveDirection == #y ifTrue:[
|
|
808 |
self displayRectangleX:l y:t width:w"-1" height:h.
|
|
809 |
] ifFalse:[
|
|
810 |
self displayRectangleX:l y:t width:w height:h"-1".
|
|
811 |
]
|
38
|
812 |
].
|
|
813 |
|
22
|
814 |
(tallyLevel == 0 or:[tallyMarks == 0]) ifTrue:[
|
59
|
815 |
shadowForm notNil ifTrue:[
|
|
816 |
handleX := l + ((w - 8) // 2).
|
|
817 |
handleY := t + ((h - 8) // 2).
|
|
818 |
self drawHandleFormAtX:handleX y:handleY
|
|
819 |
].
|
|
820 |
^ self
|
0
|
821 |
].
|
|
822 |
|
22
|
823 |
"iris style - draw tallys"
|
|
824 |
|
|
825 |
tallyLevel > 0 ifTrue:[
|
59
|
826 |
color1 := thumbLightColor.
|
|
827 |
color2 := thumbShadowColor.
|
22
|
828 |
] ifFalse:[
|
59
|
829 |
color1 := thumbShadowColor.
|
|
830 |
color2 := thumbLightColor.
|
22
|
831 |
].
|
|
832 |
|
|
833 |
"draw tally marks"
|
|
834 |
|
0
|
835 |
(moveDirection == #y) ifTrue:[
|
59
|
836 |
self paint:color1.
|
|
837 |
y := t + (h // 2) - 1.
|
|
838 |
xL := l + thumbLevel - 1.
|
|
839 |
xR := l + w - thumbLevel "+ 1".
|
|
840 |
self displayLineFromX:xL y:y toX:xR y:y.
|
|
841 |
y := y + 1.
|
|
842 |
self paint:color2.
|
|
843 |
self displayLineFromX:xL y:y toX:xR y:y.
|
0
|
844 |
|
59
|
845 |
tallyMarks > 1 ifTrue:[
|
|
846 |
"dont draw other marks if there is not enough space"
|
0
|
847 |
|
59
|
848 |
mm := device verticalPixelPerMillimeter rounded.
|
|
849 |
h > (mm * (tallyMarks * 2)) ifTrue:[
|
|
850 |
y := y - 1 - mm.
|
|
851 |
self paint:color1.
|
|
852 |
self displayLineFromX:xL y:y toX:xR y:y.
|
|
853 |
y := y + 1.
|
|
854 |
self paint:color2.
|
|
855 |
self displayLineFromX:xL y:y toX:xR y:y.
|
0
|
856 |
|
59
|
857 |
y := y - 1 + mm + mm.
|
|
858 |
self paint:color1.
|
|
859 |
self displayLineFromX:xL y:y toX:xR y:y.
|
|
860 |
y := y + 1.
|
|
861 |
self paint:color2.
|
|
862 |
self displayLineFromX:xL y:y toX:xR y:y
|
|
863 |
]
|
|
864 |
]
|
0
|
865 |
] ifFalse:[
|
59
|
866 |
x := l + (w // 2) - 1.
|
|
867 |
yT := t + thumbLevel - 1.
|
|
868 |
yB := t + h - thumbLevel "+ 1".
|
|
869 |
self paint:color1.
|
|
870 |
self displayLineFromX:x y:yT toX:x y:yB.
|
|
871 |
self paint:color2.
|
|
872 |
x := x + 1.
|
|
873 |
self displayLineFromX:x y:yT toX:x y:yB.
|
0
|
874 |
|
59
|
875 |
tallyMarks > 1 ifTrue:[
|
|
876 |
"dont draw other marks if there is not enough space"
|
0
|
877 |
|
59
|
878 |
mm := device horizontalPixelPerMillimeter rounded.
|
|
879 |
w > (mm * (tallyMarks * 2)) ifTrue:[
|
|
880 |
x := x - 1 - mm.
|
|
881 |
self paint:color1.
|
|
882 |
self displayLineFromX:x y:yT toX:x y:yB.
|
|
883 |
x := x + 1.
|
|
884 |
self paint:color2.
|
|
885 |
self displayLineFromX:x y:yT toX:x y:yB.
|
22
|
886 |
|
59
|
887 |
x := x - 1 + mm + mm.
|
|
888 |
self paint:color1.
|
|
889 |
self displayLineFromX:x y:yT toX:x y:yB.
|
|
890 |
x := x + 1.
|
|
891 |
self paint:color2.
|
|
892 |
self displayLineFromX:x y:yT toX:x y:yB
|
|
893 |
]
|
|
894 |
]
|
0
|
895 |
]
|
|
896 |
! !
|
|
897 |
|
38
|
898 |
!Scroller methodsFor:'forced scroll'!
|
|
899 |
|
|
900 |
pageUp
|
|
901 |
"page up/left"
|
|
902 |
|
|
903 |
self thumbOrigin:(thumbOrigin - thumbHeight).
|
|
904 |
scrollAction notNil ifTrue:[
|
59
|
905 |
scrollAction value:thumbOrigin
|
38
|
906 |
]
|
|
907 |
!
|
|
908 |
|
|
909 |
pageDown
|
|
910 |
"page down/right"
|
|
911 |
|
|
912 |
self thumbOrigin:(thumbOrigin + thumbHeight).
|
|
913 |
scrollAction notNil ifTrue:[
|
59
|
914 |
scrollAction value:thumbOrigin
|
38
|
915 |
]
|
|
916 |
! !
|
|
917 |
|
0
|
918 |
!Scroller methodsFor:'events'!
|
|
919 |
|
|
920 |
redrawX:x y:y width:w height:h
|
59
|
921 |
shown ifTrue:[
|
|
922 |
thumbFrame isNil ifTrue:[self computeThumbFrame].
|
|
923 |
self drawThumbBackgroundInX:x y:y width:w height:h.
|
|
924 |
(y > thumbFrame bottom) ifTrue:[
|
|
925 |
^ self
|
|
926 |
].
|
|
927 |
((y + h) < thumbFrame top) ifTrue:[
|
|
928 |
^ self
|
|
929 |
].
|
|
930 |
self drawThumb
|
|
931 |
]
|
0
|
932 |
!
|
|
933 |
|
|
934 |
redraw
|
|
935 |
"redraw"
|
|
936 |
|
|
937 |
shown ifTrue:[
|
59
|
938 |
thumbFrame isNil ifTrue:[self computeThumbFrame].
|
|
939 |
self drawThumbBackgroundInX:0 y:0 width:width height:height.
|
|
940 |
self drawThumb
|
0
|
941 |
]
|
|
942 |
!
|
|
943 |
|
|
944 |
sizeChanged:how
|
|
945 |
"size of scroller changed - recompute thumbs frame and redraw it"
|
|
946 |
|
38
|
947 |
shown ifTrue:[
|
59
|
948 |
self computeThumbFrame.
|
|
949 |
self redraw
|
38
|
950 |
]
|
0
|
951 |
!
|
|
952 |
|
|
953 |
buttonPress:button x:x y:y
|
|
954 |
"button was pressed - if above thumb, page up; if below thumb, page down;
|
|
955 |
otherwise start scrolling"
|
|
956 |
|
|
957 |
|curr limit1 limit2|
|
|
958 |
|
|
959 |
(moveDirection == #y) ifTrue:[
|
59
|
960 |
curr := y.
|
|
961 |
limit1 := thumbFrame top.
|
|
962 |
limit2 := thumbFrame bottom
|
0
|
963 |
] ifFalse:[
|
59
|
964 |
curr := x.
|
|
965 |
limit1 := thumbFrame left.
|
|
966 |
limit2 := thumbFrame right
|
0
|
967 |
].
|
|
968 |
|
|
969 |
(curr < limit1) ifTrue:[
|
59
|
970 |
"page up/left"
|
|
971 |
self pageUp
|
0
|
972 |
] ifFalse:[
|
59
|
973 |
(curr > limit2) ifTrue:[
|
|
974 |
"page down/right"
|
|
975 |
self pageDown
|
|
976 |
] ifFalse:[
|
|
977 |
pressOffset := curr - limit1.
|
|
978 |
scrolling := true
|
|
979 |
]
|
0
|
980 |
]
|
|
981 |
!
|
|
982 |
|
|
983 |
buttonMultiPress:button x:x y:y
|
|
984 |
^ self buttonPress:button x:x y:y
|
|
985 |
!
|
|
986 |
|
|
987 |
buttonShiftPress:button x:x y:y
|
|
988 |
"mouse-click with shift - jump to position"
|
|
989 |
|
|
990 |
|pos newThumbOrigin curr limit org|
|
|
991 |
|
|
992 |
(moveDirection == #y) ifTrue:[
|
59
|
993 |
curr := y.
|
|
994 |
limit := height.
|
|
995 |
org := thumbFrame top
|
0
|
996 |
] ifFalse:[
|
59
|
997 |
curr := x.
|
|
998 |
limit := width.
|
|
999 |
org := thumbFrame left
|
0
|
1000 |
].
|
|
1001 |
|
|
1002 |
(curr < 0) ifTrue:[ "check against limits"
|
59
|
1003 |
pos := 0
|
0
|
1004 |
] ifFalse:[
|
59
|
1005 |
(curr > limit) ifTrue:[
|
|
1006 |
pos := limit
|
|
1007 |
] ifFalse:[
|
|
1008 |
pos := curr
|
|
1009 |
]
|
0
|
1010 |
].
|
|
1011 |
|
|
1012 |
newThumbOrigin := self percentFromAbs:pos.
|
|
1013 |
self thumbOrigin:newThumbOrigin.
|
|
1014 |
scrollAction notNil ifTrue:[
|
59
|
1015 |
scrollAction value:thumbOrigin
|
0
|
1016 |
].
|
|
1017 |
pressOffset := curr - org.
|
|
1018 |
scrolling := true
|
|
1019 |
!
|
|
1020 |
|
|
1021 |
buttonMotion:button x:x y:y
|
|
1022 |
"mouse-button was moved while pressed;
|
|
1023 |
redraw thumb at its new position and, if scroll-mode is asynchronous,
|
|
1024 |
the scroll action is performed"
|
|
1025 |
|
|
1026 |
|pos newThumbOrigin curr limit|
|
|
1027 |
|
|
1028 |
scrolling ifFalse: [ ^ self ]. "should not happen"
|
|
1029 |
|
|
1030 |
(moveDirection == #y) ifTrue:[
|
59
|
1031 |
curr := y.
|
|
1032 |
limit := height
|
0
|
1033 |
] ifFalse:[
|
59
|
1034 |
curr := x.
|
|
1035 |
limit := width
|
0
|
1036 |
].
|
|
1037 |
|
|
1038 |
(curr < 0) ifTrue:[ "check against limits"
|
59
|
1039 |
pos := 0
|
0
|
1040 |
] ifFalse:[
|
59
|
1041 |
(curr > limit) ifTrue:[
|
|
1042 |
pos := limit
|
|
1043 |
] ifFalse:[
|
|
1044 |
pos := curr
|
|
1045 |
]
|
0
|
1046 |
].
|
|
1047 |
|
|
1048 |
newThumbOrigin := self percentFromAbs:(pos - pressOffset).
|
|
1049 |
|
|
1050 |
self thumbOrigin:newThumbOrigin.
|
|
1051 |
synchronousOperation ifTrue: [
|
59
|
1052 |
scrollAction notNil ifTrue:[
|
|
1053 |
scrollAction value:thumbOrigin
|
|
1054 |
]
|
0
|
1055 |
]
|
|
1056 |
!
|
|
1057 |
|
|
1058 |
buttonRelease:button x:x y:y
|
|
1059 |
"mouse-button was released - if scroll-mode is asynchronous, the scroll
|
|
1060 |
action is now performed"
|
|
1061 |
|
|
1062 |
scrolling ifTrue:[
|
59
|
1063 |
scrolling := false.
|
|
1064 |
synchronousOperation ifFalse: [
|
|
1065 |
scrollAction notNil ifTrue:[
|
|
1066 |
scrollAction value:thumbOrigin
|
|
1067 |
]
|
|
1068 |
]
|
0
|
1069 |
]
|
|
1070 |
! !
|