Newbie question: ConstantShapeMorph?

Bob Arning arning at charm.net
Mon Dec 30 20:48:30 UTC 2002


On Mon, 30 Dec 2002 12:15:13 -0800 Bill Spight <bspight at pacbell.net> wrote:
>How do you make a Morph that keeps its shape upon resizing? I would have
>thought that that would be a common thing to do, but I have not found
>anything in the documentation about how to do that.

Bill,

You could override the #extent: method to do something like:

extent: aPoint

	x _ aPoint x.
	y _ aPoint y.
	(y * aspectRatio) > x ifTrue: [
		x _ y * aspectRatio
	] ifFalse: [
		y _ x / aspectRatio
	].
	^super extent: (x at y) rounded


Where aspectRatio is an instance variable set to the desired x/y ratio.

Cheers,
Bob



More information about the Squeak-dev mailing list