'From Cuis 2.0 of 24 February 2010 [latest update: #440] on 5 March 2010 at 10:02:42 am'!

!SystemWindow methodsFor: 'resize/collapse' stamp: 'jmv 3/3/2010 10:45'!
spawnOffsetReframeHandle: event divider: divider
	"The mouse has crossed a secondary (fixed-height) pane divider.  Spawn a reframe handle."
	"Only supports vertical adjustments."

	| siblings topAdjustees bottomAdjustees topOnly bottomOnly resizer pt delta minY maxY cursor minFreeHeight |
	owner ifNil: [^self	"Spurious mouseLeave due to delete"].
	self isCollapsed ifTrue: [^self].
	((self world ifNil: [^self]) firstSubmorph isKindOf: NewHandleMorph) 
		ifTrue: [^self	"Prevent multiple handles"].
	divider layoutFrame ifNil: [^self].
	(#(#top #bottom) includes: divider resizingEdge) ifFalse: [^self].
	siblings _ divider owner submorphs select: [:m | m layoutFrame notNil].
	divider resizingEdge = #bottom 
		ifTrue: 
			[cursor _ Cursor resizeTop.
			topAdjustees _ siblings select: 
							[:m | 
							m layoutFrame topFraction = divider layoutFrame bottomFraction 
								and: [m layoutFrame topOffset >= divider layoutFrame topOffset]].
			bottomAdjustees _ siblings select: 
							[:m | 
							m layoutFrame bottomFraction = divider layoutFrame topFraction 
								and: [m layoutFrame bottomOffset >= divider layoutFrame topOffset]]].
	divider resizingEdge = #top 
		ifTrue: 
			[cursor _ Cursor resizeBottom.
			topAdjustees _ siblings select: 
							[:m | 
							m layoutFrame topFraction = divider layoutFrame bottomFraction 
								and: [m layoutFrame topOffset <= divider layoutFrame bottomOffset]].
			bottomAdjustees _ siblings select: 
							[:m | 
							m layoutFrame bottomFraction = divider layoutFrame topFraction 
								and: [m layoutFrame bottomOffset <= divider layoutFrame bottomOffset]]].
	topOnly _ topAdjustees copyWithoutAll: bottomAdjustees.
	bottomOnly _ bottomAdjustees copyWithoutAll: topAdjustees.
	(topOnly isEmpty or: [bottomOnly isEmpty]) ifTrue: [^self].
	minFreeHeight _ StrikeFont default height + 6.
	minY _ bottomOnly inject: -9999 into: [ :y :m |
		y max: m top - m bottom + minFreeHeight + divider bottom ].
	maxY _ topOnly inject: 9999 into: [ :y :m | 
		y min: m bottom - m top - minFreeHeight  + divider top].
	pt _ event cursorPoint.
	resizer _ NewHandleMorph new 
				followHand: event hand
				forEachPointDo: 
					[:p | 
					delta _ (p y min: maxY max: minY) - pt y.
					topAdjustees 
						do: [:m | m layoutFrame topOffset: m layoutFrame topOffset + delta].
					bottomAdjustees 
						do: [:m | m layoutFrame bottomOffset: m layoutFrame bottomOffset + delta].
					divider layoutChanged.
					pt _ pt + delta]
				lastPointDo: [:p | ]
				withCursor: cursor.
	event hand world addMorphInLayer: resizer.
	resizer startStepping! !

