Make #scrollTo: the basic scrolling method.
--- a/ViewScroller.st Thu Aug 15 20:17:02 1996 +0200
+++ b/ViewScroller.st Wed Aug 21 10:15:42 1996 +0200
@@ -17,7 +17,7 @@
category:'Views-Basic'
!
-!ViewScroller class methodsFor:'documentation'!
+!ViewScroller class methodsFor:'documentation'!
copyright
"
@@ -228,104 +228,46 @@
!ViewScroller methodsFor:'scrolling'!
-scrollDown:nPixels
- "change origin of scrolledView to scroll down some pixels"
-
- |count "{ Class:SmallInteger }"
- hCont "{ Class:SmallInteger }"
- ih "{ Class:SmallInteger }"
- viewOrigin orgY|
-
- viewOrigin := scrolledView origin.
- orgY := viewOrigin y negated.
-
- count := nPixels.
- hCont := self heightOfContents.
- ih := self innerHeight.
+scrollTo:aPoint
+ "change origin of scrolledView to scroll to aPoint"
- ((orgY + nPixels + ih) > hCont) ifTrue:[
- count := hCont - orgY - ih
- ].
- (count <= 0) ifTrue:[^ self].
-
- self originWillChange.
- viewOrigin := viewOrigin x @ (orgY negated - count).
- scrolledView origin:viewOrigin.
-
- self originChanged:(0 @ count).
-!
-
-scrollLeft:nPixels
- "change origin of the scrolledView to scroll left (towards the origin) by some pixels"
-
- |count "{ Class:SmallInteger }"
- viewOrigin
- orgX "{ Class:SmallInteger }"|
+ |wCont hCont "{ Class:SmallInteger }"
+ iw ih "{ Class:SmallInteger }"
+ viewOrigin orgX orgY newX newY|
viewOrigin := scrolledView origin.
orgX := viewOrigin x negated.
-
- count := nPixels.
- (count > orgX) ifTrue:[
- count := orgX
- ].
- (count <= 0) ifTrue:[^ self].
+ orgY := viewOrigin y negated.
- self originWillChange.
- scrolledView origin:((orgX negated + count) @ viewOrigin y).
- self originChanged:(count negated @ 0).
-!
-
-scrollRight:nPixels
- "change origin of scrolledView to scroll right some pixels"
+ newX := aPoint x.
+ newY := aPoint y.
+ wCont := self widthOfContents.
+ hCont := self heightOfContents.
+ iw := self innerWidth.
+ ih := self innerHeight.
- |count "{ Class:SmallInteger }"
- wCont "{ Class:SmallInteger }"
- iw "{ Class:SmallInteger }"
- viewOrigin orgX|
-
- viewOrigin := scrolledView origin.
- orgX := viewOrigin x negated.
-
- count := nPixels.
- wCont := self widthOfContents.
- iw := self innerWidth.
-
- ((orgX + nPixels + iw) > wCont) ifTrue:[
- count := wCont - orgX - iw
+ ((newX + iw) > wCont) ifTrue:[
+ newX := wCont - iw
+ ].
+ (newX < 0) ifTrue:[
+ newX := 0
].
- (count <= 0) ifTrue:[^ self].
+ ((newY + ih) > hCont) ifTrue:[
+ newY := hCont - ih
+ ].
+ (newY < 0) ifTrue:[
+ newY := 0
+ ].
self originWillChange.
- viewOrigin := (orgX negated - count) @ viewOrigin y.
- scrolledView origin:viewOrigin.
-
- self originChanged:(count @ 0).
-!
-
-scrollUp:nPixels
- "change origin of the scrolledView to scroll up (towards the origin) by some pixels"
-
- |count "{ Class:SmallInteger }"
- viewOrigin
- orgY "{ Class:SmallInteger }"|
+ scrolledView origin:(newX negated @ newY negated).
+ self originChanged:((newX-orgX) negated @ (newY-orgY) negated).
- viewOrigin := scrolledView origin.
- orgY := viewOrigin y negated.
-
- count := nPixels.
- (count > orgY) ifTrue:[
- count := orgY
- ].
- (count <= 0) ifTrue:[^ self].
-
- self originWillChange.
- scrolledView origin:(viewOrigin x @ (orgY negated + count)).
- self originChanged:(0 @ count negated).
+ "Modified: 21.8.1996 / 09:17:49 / stefan"
! !
-!ViewScroller class methodsFor:'documentation'!
+!ViewScroller class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/ViewScroller.st,v 1.9 1996-05-24 16:46:50 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/ViewScroller.st,v 1.10 1996-08-21 08:15:42 stefan Exp $'
! !