author | Claus Gittinger <cg@exept.de> |
Thu, 11 May 2006 19:34:03 +0200 | |
changeset 2957 | 21b7fc774154 |
parent 2738 | 0058a8de3a0e |
child 3165 | 0d595ec9b8b8 |
permissions | -rw-r--r-- |
36 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
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 |
" |
|
29 | 12 |
|
2001
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
13 |
"{ Package: 'stx:libwidg2' }" |
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
14 |
|
49 | 15 |
SimpleView subclass:#ViewScroller |
2120 | 16 |
instanceVariableNames:'frame scrolledView keepViewsChannel model verticalScrollStep |
17 |
horizontalScrollStep' |
|
186 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Views-Basic' |
|
29 | 21 |
! |
22 |
||
424 | 23 |
!ViewScroller class methodsFor:'documentation'! |
29 | 24 |
|
36 | 25 |
copyright |
26 |
" |
|
27 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
28 |
All Rights Reserved |
|
29 |
||
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
37 |
! |
|
38 |
||
39 |
documentation |
|
40 |
" |
|
187 | 41 |
This wrapper view allows scrolling of views (in contrast to scrolling |
42 |
of contents which can be done by any view). |
|
186 | 43 |
|
187 | 44 |
Normally, scrolling is done by putting a view into a ScrollableView (which |
45 |
simply wraps the scrollbars around) and have the scrollbars send scrollUp:/ |
|
46 |
scrollDown: etc. send to the scrolledView. |
|
47 |
The default implementation of scrolling (in View) modifies the transformation, |
|
48 |
and does a bit-copy of the contents with redraw of the exposed area. |
|
36 | 49 |
|
187 | 50 |
However, there are situations, where you want to scroll a view itself. |
51 |
For example, if you need many buttons in a panel, which do not fit. |
|
36 | 52 |
|
187 | 53 |
This class provides the basic mechanism to implement this. |
54 |
It is a wrapper, which implements scrolling by modifying the origin of its |
|
55 |
single subview when asked to scroll. Thus, it can be put into a ScrollableView |
|
56 |
like any other, but will move its subview when asked to scroll instead. |
|
57 |
(i.e. reimplement all scroll messages by manipulating its subviews origin |
|
58 |
instead of its contents' transformation offset) |
|
36 | 59 |
|
187 | 60 |
The subview should have a constant extent, which will be taken for the |
61 |
scrollbar position/height computation. |
|
62 |
Since the subview is represented directly by the underlying window systems view |
|
63 |
implementation, there may be a limit on the maximum size of that view. For |
|
64 |
example, in X, dimensions may not be larger than 32767 pixels. |
|
65 |
||
2120 | 66 |
[Instance variables:] |
67 |
model <ValueHolder> the model which keeps the current scrolledView. |
|
68 |
||
69 |
keepViewsChannel <ValueHolder> boolean holder; if the value is false (the default), |
|
70 |
the previous scrolled view is destroyed, whenever a |
|
71 |
new scrolled view is set. If true, it is unmapped and |
|
72 |
kept. |
|
73 |
Set this flag, if the application changes the scrolled |
|
74 |
view but wants them to be kept for fast switching. |
|
75 |
||
76 |
horizontalScrollStep <SmallInteger> amount to scroll when stepping left/right in pixels |
|
77 |
verticalScrollStep <SmallInteger> amount to scroll when stepping up/down in pixels |
|
78 |
||
79 |
frame <SimpleView> the one and only container of the visible scrolledView |
|
80 |
and all invisible scrolledViews if existant. |
|
81 |
||
82 |
scrolledView <SimpleView | nil> the current scrolled view or nil |
|
83 |
||
187 | 84 |
[see also:] |
85 |
ScrollableView HVScrollableView |
|
86 |
||
87 |
[author:] |
|
88 |
Claus Gittinger |
|
36 | 89 |
" |
90 |
! |
|
91 |
||
29 | 92 |
examples |
93 |
" |
|
94 |
scroll a panel of buttons: |
|
186 | 95 |
[exBegin] |
29 | 96 |
|top frame vscroller v panel| |
97 |
||
98 |
top := StandardSystemView new. |
|
99 |
top extent:100@400. |
|
100 |
||
101 |
frame := ScrollableView for:ViewScroller in:top. |
|
102 |
frame origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
103 |
||
104 |
vscroller := frame scrolledView. |
|
105 |
panel := VerticalPanelView new. |
|
106 |
panel horizontalLayout:#fit. |
|
107 |
1 to:100 do:[:i | |
|
186 | 108 |
Button label:(i printString) in:panel |
29 | 109 |
]. |
110 |
vscroller scrolledView:panel. |
|
111 |
top open. |
|
186 | 112 |
[exEnd] |
29 | 113 |
|
425 | 114 |
same, defining what a scroll step is: |
115 |
[exBegin] |
|
116 |
|top frame vscroller v panel| |
|
117 |
||
118 |
top := StandardSystemView new. |
|
119 |
top extent:100@400. |
|
120 |
||
121 |
frame := ScrollableView for:ViewScroller in:top. |
|
122 |
frame origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
123 |
||
124 |
vscroller := frame scrolledView. |
|
125 |
vscroller verticalScrollStep:20. |
|
126 |
panel := VerticalPanelView new. |
|
127 |
panel horizontalLayout:#fit. |
|
128 |
1 to:100 do:[:i | |
|
129 |
Button label:(i printString) in:panel |
|
130 |
]. |
|
131 |
vscroller scrolledView:panel. |
|
132 |
top open. |
|
133 |
[exEnd] |
|
134 |
||
187 | 135 |
|
29 | 136 |
same, horizontally. Also change layout in panel for nicer look |
137 |
and make panel adjust its height: |
|
36 | 138 |
(since the buttons are defined to fill vertically, the vertical |
139 |
scrollbar is useless here - its here as example; not for its function) |
|
186 | 140 |
[exBegin] |
29 | 141 |
|top frame vscroller v panel| |
142 |
||
143 |
top := StandardSystemView new. |
|
144 |
top extent:300@100. |
|
145 |
||
146 |
frame := HVScrollableView for:ViewScroller in:top. |
|
147 |
frame origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
148 |
||
149 |
vscroller := frame scrolledView. |
|
150 |
panel := HorizontalPanelView new. |
|
151 |
panel verticalLayout:#fit. |
|
152 |
panel horizontalLayout:#fit. |
|
153 |
1 to:100 do:[:i | |
|
186 | 154 |
Button label:(i printString) in:panel |
29 | 155 |
]. |
156 |
vscroller scrolledView:panel. |
|
157 |
panel height:1.0. |
|
158 |
top open. |
|
186 | 159 |
[exEnd] |
29 | 160 |
|
161 |
||
162 |
scroll a panel of buttons and other views: |
|
163 |
(not good looking, but a demo that it can be done ...) |
|
186 | 164 |
[exBegin] |
29 | 165 |
|top frame vscroller v panel textView1 textView2| |
166 |
||
167 |
top := StandardSystemView new. |
|
168 |
||
169 |
frame := HVScrollableView for:ViewScroller in:top. |
|
170 |
frame origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
|
171 |
||
172 |
vscroller := frame scrolledView. |
|
173 |
||
174 |
panel := VerticalPanelView new. |
|
175 |
panel horizontalLayout:#leftSpace. |
|
176 |
||
177 |
textView1 := ScrollableView for:EditTextView in:panel. |
|
187 | 178 |
textView1 extent:2000 @ 300. |
29 | 179 |
textView1 scrolledView contents:('Makefile' asFilename readStream contents). |
180 |
||
181 |
textView2 := ScrollableView for:EditTextView in:panel. |
|
187 | 182 |
textView2 extent:500 @ 300. |
29 | 183 |
textView2 scrolledView contents:('Make.proto' asFilename readStream contents). |
184 |
||
185 |
1 to:100 do:[:i | |
|
186 | 186 |
Button label:(i printString) in:panel |
29 | 187 |
]. |
188 |
vscroller scrolledView:panel. |
|
189 |
top open. |
|
186 | 190 |
[exEnd] |
29 | 191 |
" |
192 |
! ! |
|
193 |
||
186 | 194 |
!ViewScroller methodsFor:'accessing'! |
195 |
||
2120 | 196 |
destroyAllClientViews |
2957 | 197 |
"destroy all client views" |
198 |
||
2120 | 199 |
frame destroySubViews. |
200 |
||
201 |
scrolledView ifNotNil:[ |
|
202 |
scrolledView := nil. |
|
203 |
self sizeChanged:nil. |
|
204 |
]. |
|
205 |
model value:scrolledView. |
|
206 |
! |
|
425 | 207 |
|
2120 | 208 |
keepViews |
209 |
"returns the value of the boolean channel: keepViewsChannel. |
|
2957 | 210 |
for more information see: #keepViewsChannel" |
211 |
||
2120 | 212 |
^ keepViewsChannel value ? false |
213 |
! |
|
214 |
||
215 |
keepViews:aBool |
|
216 |
"set the value of the boolean channel: keepViewsChannel. |
|
217 |
for more information see: #keepViewsChannel: |
|
218 |
" |
|
219 |
keepViewsChannel value:aBool |
|
2001
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
220 |
! |
425 | 221 |
|
424 | 222 |
scrolledView |
223 |
"return the view which is scrolled" |
|
224 |
||
225 |
^ scrolledView |
|
226 |
! |
|
227 |
||
186 | 228 |
scrolledView:aView |
2120 | 229 |
"set a new scolled view; dependent on the #keepViewsChannel |
2957 | 230 |
the old scolled view will be destroyed or unmapped." |
231 |
||
2120 | 232 |
scrolledView ~~ aView ifTrue:[ |
233 |
scrolledView ifNotNil:[ |
|
234 |
self keepViews ifTrue:[ scrolledView beInvisible ] |
|
235 |
ifFalse:[ scrolledView destroy ]. |
|
236 |
]. |
|
237 |
scrolledView := aView. |
|
238 |
||
239 |
"test whether new scrolled view not nil and |
|
240 |
not already added to my subViews. |
|
241 |
" |
|
242 |
(scrolledView notNil and:[scrolledView superView ~~ frame]) ifTrue:[ |
|
243 |
|extent| |
|
186 | 244 |
|
2120 | 245 |
scrolledView borderWidth:0; level:0. |
246 |
extent := scrolledView preferredExtent. |
|
247 |
frame addSubView:scrolledView. |
|
248 |
||
249 |
"/ test whether the new view is a scrollWrapper. |
|
250 |
"/ in this case scrolling can be done by this view |
|
251 |
||
252 |
scrolledView isScrollWrapper ifTrue:[ |
|
253 |
scrolledView isHorizontalScrollable ifTrue:[ extent x:1.0 ]. |
|
254 |
scrolledView isVerticalScrollable ifTrue:[ extent y:1.0 ]. |
|
255 |
]. |
|
256 |
scrolledView extent:extent. |
|
257 |
]. |
|
258 |
||
259 |
realized ifTrue:[ |
|
260 |
scrolledView ifNotNil:[scrolledView beVisible]. |
|
261 |
self sizeChanged:nil. |
|
262 |
]. |
|
186 | 263 |
]. |
2120 | 264 |
model value:scrolledView. |
2124 | 265 |
! |
266 |
||
267 |
scrolledViews |
|
268 |
"Returns the collection of all scrolled views including the current scrolled view |
|
2957 | 269 |
and all unmapped scrolled views." |
270 |
||
2124 | 271 |
|subviews| |
272 |
||
273 |
frame ifNotNil:[ |
|
274 |
subviews := frame subViews. |
|
275 |
subviews ifNotNil:[ ^ subviews ] |
|
276 |
]. |
|
277 |
^ #() |
|
2120 | 278 |
! ! |
279 |
||
280 |
!ViewScroller methodsFor:'accessing-channels'! |
|
281 |
||
282 |
keepViewsChannel |
|
283 |
"boolean holder; if the value is false (the default), the previous scrolled view is |
|
284 |
destroyed, whenever a new scrolled view is set. if true, it is unmapped and kept. |
|
285 |
Set this flag, if the application changes the scrolled view but wants |
|
286 |
them to be kept for fast switching. |
|
287 |
" |
|
288 |
^ keepViewsChannel |
|
289 |
! |
|
290 |
||
291 |
keepViewsChannel:aHolder |
|
292 |
"boolean holder; if the value is false (the default), the previous scrolled view is |
|
293 |
destroyed, whenever a new scrolled view is set. if true, it is unmapped and kept. |
|
294 |
Set this flag, if the application changes the scrolled view but wants |
|
295 |
them to be kept for fast switching. |
|
296 |
" |
|
297 |
|oldValue| |
|
298 |
||
299 |
oldValue := keepViewsChannel value. |
|
300 |
keepViewsChannel removeDependent:self. |
|
301 |
||
302 |
(keepViewsChannel := aHolder) ifNil:[ |
|
303 |
keepViewsChannel := oldValue asValue. |
|
304 |
]. |
|
305 |
keepViewsChannel addDependent:self. |
|
306 |
self update:nil with:nil from:keepViewsChannel. |
|
307 |
! |
|
308 |
||
309 |
model |
|
310 |
"value holder, which keeps the current scrolledView or nil |
|
311 |
" |
|
312 |
^ model |
|
313 |
! |
|
314 |
||
315 |
model:aHolder |
|
316 |
"value holder, which keeps the current scrolledView or nil |
|
317 |
" |
|
318 |
model removeDependent:self. |
|
319 |
||
320 |
aHolder isNil ifTrue:[ model := nil asValue ] |
|
321 |
ifFalse:[ model := aHolder ]. |
|
322 |
||
323 |
model addDependent:self. |
|
324 |
self update:nil with:nil from:model. |
|
325 |
! ! |
|
326 |
||
327 |
!ViewScroller methodsFor:'accessing-look'! |
|
328 |
||
329 |
horizontalScrollStep:something |
|
330 |
"set the value of the instance variable 'horizontalScrollStep' (automatically generated)" |
|
331 |
||
332 |
horizontalScrollStep := something. |
|
425 | 333 |
! |
334 |
||
335 |
verticalScrollStep:something |
|
336 |
"set the value of the instance variable 'verticalScrollStep' (automatically generated)" |
|
337 |
||
2001
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
338 |
verticalScrollStep := something. |
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
339 |
! ! |
186 | 340 |
|
2120 | 341 |
!ViewScroller methodsFor:'change & update'! |
342 |
||
343 |
update:something with:aParameter from:changedObject |
|
344 |
changedObject == model ifTrue:[ |
|
345 |
self scrolledView:(model value). |
|
2478 | 346 |
^ self |
2120 | 347 |
]. |
348 |
||
349 |
changedObject == keepViewsChannel ifTrue:[ |
|
350 |
self keepViews ifFalse:[ |views| |
|
351 |
"destroy all client views other than the actuel scrolled view |
|
352 |
" |
|
353 |
views := frame subViews. |
|
354 |
views size ~~ 0 ifTrue:[ |
|
2478 | 355 |
views copy do:[:v | v ~~ scrolledView ifTrue:[ v destroy ] ]. |
2120 | 356 |
] |
357 |
]. |
|
358 |
^ self |
|
359 |
]. |
|
360 |
||
361 |
super update:something with:aParameter from:changedObject |
|
362 |
! ! |
|
363 |
||
186 | 364 |
!ViewScroller methodsFor:'event handling'! |
365 |
||
366 |
sizeChanged:how |
|
187 | 367 |
"reposition the scrolledView, if required" |
368 |
||
186 | 369 |
|newOrigin| |
370 |
||
371 |
super sizeChanged:how. |
|
372 |
self changed:#sizeOfContents. "update possible scrollers" |
|
373 |
||
374 |
" |
|
375 |
if we are beyond the end, scroll up a bit |
|
376 |
" |
|
377 |
((self viewOrigin y + self height) > self heightOfContents) ifTrue:[ |
|
378 |
newOrigin := self heightOfContents - self height. |
|
379 |
newOrigin < 0 ifTrue:[ |
|
380 |
newOrigin := 0 |
|
381 |
]. |
|
382 |
self scrollVerticalTo: newOrigin. |
|
383 |
]. |
|
384 |
" |
|
385 |
if we are right of the end, scroll left a bit |
|
386 |
" |
|
387 |
((self viewOrigin x + self width) > self widthOfContents) ifTrue:[ |
|
388 |
newOrigin := self widthOfContents - self width. |
|
389 |
newOrigin < 0 ifTrue:[ |
|
390 |
newOrigin := 0 |
|
391 |
]. |
|
392 |
self scrollHorizontalTo: newOrigin. |
|
393 |
]. |
|
394 |
||
187 | 395 |
"Modified: 24.5.1996 / 17:48:44 / cg" |
186 | 396 |
! ! |
397 |
||
2120 | 398 |
!ViewScroller methodsFor:'initialization & release'! |
399 |
||
400 |
initialize |
|
2738 | 401 |
"initialize all models of the view" |
402 |
||
2120 | 403 |
super initialize. |
404 |
||
405 |
frame := SimpleView origin:0.0@0.0 corner:1.0@1.0 in:self. |
|
406 |
frame borderWidth:0; level:0. |
|
407 |
||
408 |
keepViewsChannel := false asValue. |
|
409 |
keepViewsChannel addDependent:self. |
|
410 |
||
411 |
model := nil asValue. |
|
412 |
model addDependent:self. |
|
2156 | 413 |
! |
414 |
||
415 |
release |
|
2738 | 416 |
"release all dependencies" |
417 |
||
2156 | 418 |
keepViewsChannel removeDependent:self. |
419 |
model removeDependent:self. |
|
420 |
||
421 |
super release. |
|
2120 | 422 |
! ! |
423 |
||
29 | 424 |
!ViewScroller methodsFor:'queries-contents'! |
425 |
||
186 | 426 |
heightOfContents |
187 | 427 |
"return my contents' height; this is the scrolledViews height" |
186 | 428 |
|
424 | 429 |
scrolledView isNil ifTrue:[^ super heightOfContents]. |
186 | 430 |
^ scrolledView height |
431 |
||
187 | 432 |
"Modified: 24.5.1996 / 17:34:48 / cg" |
186 | 433 |
! |
434 |
||
29 | 435 |
viewOrigin |
187 | 436 |
"the viewOrigin (for scrollBars) is based upon the scrolledViews origin" |
186 | 437 |
|
424 | 438 |
scrolledView isNil ifTrue:[^ 0@0]. |
29 | 439 |
^ scrolledView origin negated |
186 | 440 |
|
187 | 441 |
"Modified: 24.5.1996 / 17:48:13 / cg" |
29 | 442 |
! |
443 |
||
444 |
widthOfContents |
|
187 | 445 |
"return my contents' width; this is the scrolledViews width" |
29 | 446 |
|
424 | 447 |
scrolledView isNil ifTrue:[^ super widthOfContents]. |
186 | 448 |
^ scrolledView width |
449 |
||
187 | 450 |
"Modified: 24.5.1996 / 17:34:56 / cg" |
29 | 451 |
! ! |
452 |
||
453 |
!ViewScroller methodsFor:'scrolling'! |
|
454 |
||
424 | 455 |
horizontalScrollStep |
456 |
"return the amount by which to step-scroll horizontally" |
|
457 |
||
425 | 458 |
^ horizontalScrollStep ? (self width // 2) |
424 | 459 |
! |
460 |
||
236
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
461 |
scrollTo:aPoint |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
462 |
"change origin of scrolledView to scroll to aPoint" |
29 | 463 |
|
236
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
464 |
|wCont hCont "{ Class:SmallInteger }" |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
465 |
iw ih "{ Class:SmallInteger }" |
2001
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
466 |
viewOrigin orgX orgY newX newY dX dY| |
29 | 467 |
|
424 | 468 |
scrolledView isNil ifTrue:[^ self]. |
469 |
||
29 | 470 |
viewOrigin := scrolledView origin. |
471 |
orgX := viewOrigin x negated. |
|
236
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
472 |
orgY := viewOrigin y negated. |
29 | 473 |
|
236
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
474 |
newX := aPoint x. |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
475 |
newY := aPoint y. |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
476 |
wCont := self widthOfContents. |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
477 |
hCont := self heightOfContents. |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
478 |
iw := self innerWidth. |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
479 |
ih := self innerHeight. |
29 | 480 |
|
236
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
481 |
((newX + iw) > wCont) ifTrue:[ |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
482 |
newX := wCont - iw |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
483 |
]. |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
484 |
(newX < 0) ifTrue:[ |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
485 |
newX := 0 |
29 | 486 |
]. |
236
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
487 |
((newY + ih) > hCont) ifTrue:[ |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
488 |
newY := hCont - ih |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
489 |
]. |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
490 |
(newY < 0) ifTrue:[ |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
491 |
newY := 0 |
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
492 |
]. |
2001
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
493 |
dX := newX-orgX. |
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
494 |
dY := newY-orgY. |
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
495 |
((dX ~= 0) or:[dY ~= 0]) ifTrue:[ |
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
496 |
self originWillChange. |
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
497 |
scrolledView origin:(newX negated @ newY negated). |
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
498 |
self originChanged:(dX negated @ dY negated). |
4fba7c3b5f53
dont scroll if scroll delta is 0
Claus Gittinger <cg@exept.de>
parents:
1466
diff
changeset
|
499 |
] |
42 | 500 |
|
236
20dba8483ad7
Make #scrollTo: the basic scrolling method.
Stefan Vogel <sv@exept.de>
parents:
187
diff
changeset
|
501 |
"Modified: 21.8.1996 / 09:17:49 / stefan" |
424 | 502 |
! |
503 |
||
504 |
verticalScrollStep |
|
505 |
"return the amount by which to step-scroll vertically" |
|
506 |
||
425 | 507 |
^ verticalScrollStep ? (self height // 2) |
42 | 508 |
! ! |
509 |
||
424 | 510 |
!ViewScroller class methodsFor:'documentation'! |
120 | 511 |
|
512 |
version |
|
2957 | 513 |
^ '$Header: /cvs/stx/stx/libwidg2/ViewScroller.st,v 1.21 2006-05-11 17:34:03 cg Exp $' |
120 | 514 |
! ! |