'From Cuis 1.0 of 21 May 2009 [latest update: #204] on 2 July 2009 at 2:29:36 pm'!
!classDefinition: #ScrollPane category: #'Morphic-OldWindows'!
MorphWithModel subclass: #ScrollPane
	instanceVariableNames: 'scrollBar scroller retractableScrollBar scrollBarOnLeft getMenuSelector getMenuTitleSelector hasFocus hScrollBar hideScrollBars currentScrollRange'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Morphic-OldWindows'!

!ScrollPane methodsFor: 'geometry' stamp: 'jmv 7/2/2009 12:49'!
layoutChanged
	| t topLeft newScrollRange |
	super layoutChanged.
	
	hideScrollBars ifTrue: [^self].
	
	newScrollRange _ self hTotalScrollRange @ self vTotalScrollRange.
	currentScrollRange = newScrollRange ifFalse: [
		self setScrollDeltas.
		currentScrollRange _ newScrollRange ].
	
	t _ Preferences scrollbarThickness.

	topLeft _ scrollBarOnLeft ifTrue: [
		"scrollbarOnLeft => retractableScrollBar"
		bounds topLeft + (0-t @ borderWidth)]
	ifFalse: [
		retractableScrollBar 
			ifTrue: [bounds topRight + (0-borderWidth @ borderWidth)]
			ifFalse: [bounds topRight + (0-t-borderWidth @ borderWidth)]].
	scrollBar 
		bounds: (topLeft extent: t @ self vScrollBarHeight).

	topLeft _ retractableScrollBar
				ifTrue: [bounds bottomLeft + (borderWidth @ borderWidth negated)]
				ifFalse: [bounds bottomLeft + (borderWidth @ (t + borderWidth) negated)].
	hScrollBar bounds: (topLeft extent: self hScrollBarWidth@ t)! !

!ScrollPane methodsFor: 'geometry' stamp: 'jmv 7/2/2009 14:26'!
vLeftoverScrollRange
	"Return the entire scrolling range minus the currently viewed area."
	| h |

	scroller hasSubmorphs ifFalse:[^0].
	h _ self vScrollBarHeight.
	"In #hideOrShowScrollBars we add the vertical scrollbar first, without using the space that might later be assigned to the horizontal scrollbar"
	true "self hIsScrollbarShowing" ifTrue: [
		h _ h - Preferences scrollbarThickness ].
	^ (self vTotalScrollRange - h roundTo: self scrollDeltaHeight) max: 0
! !


!PluggableTextMorph methodsFor: 'geometry' stamp: 'jmv 7/2/2009 12:44'!
scrollDeltaHeight
	"Return the increment in pixels which this pane should be scrolled."
	scroller hasSubmorphs ifFalse: [ ^1].
	^ scroller firstSubmorph defaultLineHeight
! !


!SimpleHierarchicalListMorph methodsFor: 'geometry' stamp: 'jmv 7/2/2009 12:56'!
scrollDeltaHeight
	scroller hasSubmorphs ifFalse: [ ^1].
	^ scroller firstSubmorph height! !

