Edit Rename Changes History Upload Download Back to Top

scrollfix

From VisualWorks®, Release 3.0 of 25. Februar 1998 on 13. September 2000 at 11:11:09'!



!ScrollWrapper methodsFor: 'bounds accessing'!

offsetOrigin
	"^ 'self translation negated' minus this point is the amount we have scrolled the component"

	^component preferredBounds origin grid: self scrollGrid ! !

!ScrollWrapper methodsFor: 'access - scrollbars'!

scroll: aPoint
 "Scroll the receiver by aPoint."


	| maximumAmount minimumAmount amount |
	maximumAmount := self scrollOffset + origin extraSpace origin
		max: 0@0. "amount to scroll to the upper left side is positive (?-see below)"
 	minimumAmount := self scrollOffset + self visibleExtent - self scrollableExtent
		min: 0@0. "amount to scroll to the lower right side is negative (?-see below) "
	amount := (aPoint min: maximumAmount) max: minimumAmount.
 	amount ~= (0@0) ifTrue: [self scrollBy: amount negated "ah!!" ] ! !

!ScrollWrapper methodsFor: 'private - scrolling'!

scrollableExtent
 "Answer the extent of the receiver's display object bounding box."

 "^(component preferredBounds expandedBy: origin extraSpace) extent max:
(1@1)"
 ^(component preferredBounds expandedBy: (Rectangle origin: 0@0 corner:
(origin extraSpace corner))) extent max: (1@1)! !

!ScrollWrapper methodsFor: 'private - scrolling'!

scrollBy: point
 "Scroll the receiver by the point."

	| width grid height |
	grid := self scrollGrid.
	width := (point x max: (self scrollOffset negated x - origin extraSpace origin x)).
	(width abs between: 0 and: grid x)
 		ifTrue: [width := width sign * grid x]
		ifFalse: [width := width roundTo: grid x].
	height := (point y max: (self scrollOffset negated y - origin extraSpace origin y)).
	(height abs between: 0 and: grid y)
		ifTrue: [height := height sign * grid y]
		ifFalse: [height := height roundTo: grid y].
	self setOrigin: self translation - (width@height).
	self	scrollBy: width@height
		on: self graphicsContext
		grid: grid.
	self updateControls.
	self updateSpot: #scroll! !

!ScrollWrapper methodsFor: 'access - scrollbars'!

scrollOffset
	"Answer the offset the receiver has scrolled."

	^self translation negated - self offsetOrigin! !

!ScrollWrapper methodsFor: 'private - scrolling'!

validateScrollPosition: aPoint
	"Make sure that this is a legal scroll offset for us to occupy"

	| p |
	p := aPoint negated min: (self scrollableExtent - self visibleExtent).
	p := p max: self offsetOrigin - origin extraSpace origin.
	p := p grid: self scrollGrid.
	^p negated! !

!AutoScrollingView methodsFor: 'private'!

validateScrollPosition: aPoint
	"Make sure that this is a legal scroll offset for us to occupy"

	| p |
	p := aPoint negated min: self scrollableExtent - self visibleExtent.
	p := p max: self preferredBounds origin - scrollOffset extraSpace origin.
	p := p grid: scrollOffset grid.
	^p negated! !

!ScrollingView methodsFor: 'private'!

validateScrollPosition: aPoint
	"Make sure that this is a legal scroll offset for us to occupy"

	| p |
	p := aPoint negated min: self scrollableExtent - self visibleExtent.
	p := p max: self preferredBounds origin - scrollOffset extraSpace origin.
	p := p grid: scrollOffset grid.
	^p negated! !

!TableView methodsFor: 'private'!

validateScrollPosition: aPoint
	"Make sure that this is a legal scroll offset for us to occupy"

	| p bounds |
	bounds := self preferredBounds.
	p := aPoint negated min: bounds corner + scrollOffset grid + scrollOffset extraSpace corner - self bounds extent.
	p := p max: bounds origin - scrollOffset extraSpace origin.
	p := p grid: scrollOffset grid.
	^p negated! !


Edit Rename Changes History Upload Download Back to Top