[Q] More morphic layout fun

Brian Brown rbb at techgame.net
Fri May 30 18:13:07 UTC 2003


G'day all,
	In the following code, I'm programmatically adding the contents of 
ImageImports to a Rectangle morph... the results aren't at all what I 
expect... the created IconicButtons are laid out in a nice 4x3 grid, but they 
extend outside the bounds of the Morph they are being added to, and their 
bounds are increasing as they are added... 

any ideas?

Brian


initialize
	| leftFrame leftTop leftBottom rightFrame  startx starty endx endy |
	window _ RectangleMorph newBounds: ((0 at 460) extent: (640 at 480)).
	window color: Color blue.
	window layoutPolicy: ProportionalLayout new.
	leftTop _ RectangleMorph new color: Color green.
	leftTop layoutPolicy: TableLayout new.
	leftTop addMorph: (SimpleButtonMorph new initializeWithLabel: 'Test Button').
	leftBottom _ RectangleMorph new color: Color red.
	rightFrame _ RectangleMorph new color: Color yellow.
	rightFrame layoutPolicy: ProportionalLayout new.
	startx := 0. starty := 0. endx := 0.25. endy := 0.33.
	ImageImports keysAndValuesDo: 
		[:key :val |
			(endy >= 1.0) ifFalse: [
			rightFrame addMorph: (IconicButton  new 
				initializeToShow: (SketchMorph new initializeWith: val) 
				withLabel: key 
				andSend: #confirm
				to: self)
				fullFrame: (LayoutFrame fractions: (startx at starty extent: endx at endy))
				].
			startx := startx + 0.25. endx := endx + 0.25.
			(startx > 0.75) ifTrue: [
				startx := 0. 
				endx := 0.25.
				starty := starty + 0.33.
				endy := endy + 0.33].
			].
	rightFrame layoutChanged.
	window addMorph: leftTop 
			fullFrame: (LayoutFrame fractions: (0 at 0 extent: 0.5 at 0.5)).
	window addMorph: leftBottom 
			fullFrame: (LayoutFrame fractions: (0 at 0.5 extent: 0.5 at 0.5)).
	window addMorph: rightFrame 
			fullFrame: (LayoutFrame fractions: (0.5 at 0 extent: 0.5 at 1)).



More information about the Squeak-dev mailing list