Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
BookPageSorterMorph
Last updated at 12:27 am UTC on 30 August 2016
A Morph used to sort pages of a BookMorph. It is a subclass of AlignmentMorph

An example of classic Morphic programming.


Implementation notes


aBookLikeMorph sortpages>>

BookPageSorterMorph new
		book: self morphsToSort: self morphsForPageSorter.



After new the method #initialize is called.
A PasteUpMorph is added and aBookPageSorterMorph addControls another AlignmentMorph instance is added.

initialize
	"initialize the state of the receiver"
	super initialize.
	""
	self extent: Display extent - 100;
		 listDirection: #topToBottom;
		 wrapCentering: #topLeft;
		 hResizing: #shrinkWrap;
		 vResizing: #shrinkWrap;
layoutInset: 3.
	pageHolder := PasteUpMorph new behaveLikeHolder extent: self extent -self borderWidth.
	pageHolder hResizing: #shrinkWrap.
	"pageHolder cursor: 0."
	"causes a walkback as of 5/25/2000"
	self addControls.
	self addMorphBack: pageHolder



and then

book: aBookMorph morphsToSort: morphList
	| innerBounds |
	book := aBookMorph.
	pageHolder removeAllMorphs.
	pageHolder addAllMorphs: morphList.
	pageHolder extent: pageHolder width@pageHolder fullBounds height.
	innerBounds := Rectangle merging: (morphList collect: [:m | m bounds]).
	pageHolder extent: innerBounds extent + pageHolder borderWidth + 6.