diff -r fd1b68b48422 -r 15a9291b9bd0 HVScrollableView.st --- a/HVScrollableView.st Sat Dec 11 02:41:07 1993 +0100 +++ b/HVScrollableView.st Sat Dec 11 02:51:34 1993 +0100 @@ -25,23 +25,23 @@ a view containing both horizontal and vertical scrollbars and some other (slave-)view -$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.3 1993-10-13 02:48:04 claus Exp $ +$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.4 1993-12-11 01:44:59 claus Exp $ written jan 91 by claus '! !HVScrollableView methodsFor:'initialization'! initializeFor:aViewClass - |negativeOffset halfMargin| + |negativeOffset halfMargin lock| + + hScrollBar := HorizontalScrollBar in:self. super initializeFor:aViewClass. negativeOffset := borderWidth negated. halfMargin := innerMargin // 2. - "create the horizontal scrollbar and change vertical scrollbars size" - - hScrollBar := HorizontalScrollBar in:self. + "change vertical scrollbars size" self is3D ifTrue:[ scrollBar extent:[scrollBar width @@ -49,12 +49,15 @@ (height - hScrollBar height - innerMargin) ] ] ifFalse:[ +" aViewClass isNil ifTrue:[ +" scrollBar extent:[scrollBar width @ (height - hScrollBar height - (1 * hScrollBar borderWidth)) ] +" ] ifFalse:[ scrollBar extent:[scrollBar width @ @@ -63,13 +66,10 @@ - scrolledView borderWidth) ] ] +" ]. hScrollBar thumbOrigin:0 thumbHeight:100. - hScrollBar scrollAction:[:position | - scrolledView scrollHorizontalToPercent:position]. - hScrollBar scrollLeftAction:[scrolledView scrollLeft]. - hScrollBar scrollRightAction:[scrolledView scrollRight]. self is3D ifTrue:[ hScrollBar origin:[(scrollBar origin x + scrollBar width + innerMargin) @ @@ -100,23 +100,18 @@ extent:[(width - scrollBar width - scrollBar borderWidth - - scrolledView borderWidth) + "- scrolledView borderWidth") @ (height - hScrollBar height - hScrollBar borderWidth - - scrolledView borderWidth) + "- scrolledView borderWidth") ] ]. ]. scrolledView notNil ifTrue:[ - scrolledView - originChangeAction:[:aView | scrollBar setThumbOriginFor:aView. - hScrollBar setThumbOriginFor:aView]. - scrolledView - contentsChangeAction:[:aView | scrollBar setThumbFor:aView. - hScrollBar setThumbFor:aView] + self setScrollActions ] ! @@ -125,9 +120,52 @@ hScrollBar setThumbFor:scrolledView ! ! +!HVScrollableView methodsFor:'private'! + +setScrollActions + |lock| + + lock := false. + + scrollBar scrollAction:[:position | + lock := true. + scrolledView scrollVerticalToPercent:position. + lock := false + ]. + scrollBar scrollUpAction:[scrolledView scrollUp]. + scrollBar scrollDownAction:[scrolledView scrollDown]. + + hScrollBar scrollAction:[:position | + lock := true. + scrolledView scrollHorizontalToPercent:position. + lock := false + ]. + hScrollBar scrollLeftAction:[scrolledView scrollLeft]. + hScrollBar scrollRightAction:[scrolledView scrollRight]. + + scrolledView originChangeAction:[:aView | + lock ifFalse:[ + scrollBar setThumbOriginFor:aView. + hScrollBar setThumbOriginFor:aView + ] + ]. + scrolledView contentsChangeAction:[:aView | + scrollBar setThumbFor:aView. + hScrollBar setThumbFor:aView + ] +! ! + !HVScrollableView methodsFor:'accessing'! +horizontalScrollBar + "return the horizontal scrollbar" + + ^ hScrollBar +! + scrolledView:aView + "set the scrolled view" + super scrolledView:aView. "redefine subviews size" @@ -145,12 +183,7 @@ ] ]. - scrolledView - originChangeAction:[:aView | scrollBar setThumbOriginFor:aView. - hScrollBar setThumbOriginFor:aView]. - scrolledView - contentsChangeAction:[:aView | scrollBar setThumbFor:aView. - hScrollBar setThumbFor:aView] + self setScrollActions ! ! !HVScrollableView methodsFor:'event processing'!