Object subclass: #Box instanceVariableNames: 'size pen ' classVariableNames: '' poolDictionaries: '' category: 'Boxes'! !Box methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:55'! draw self drawColor: (Color black). (Delay forSeconds: (1/30)) wait. ! ! !Box methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:47'! drawColor: color pen color: color. 4 timesRepeat: [pen go: size; turn: 90]. ! ! !Box methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:36'! grow: increment self undraw. size _ size + increment. "This stays the same" self draw. ! ! !Box methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:27'! move: pointIncrement self undraw. pen place: (pen location) + pointIncrement. self draw. ! ! !Box methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:26'! moveTo: aPoint self undraw. pen place: aPoint. self draw. ! ! !Box methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:28'! turn: degrees self undraw. pen turn: degrees. self draw. ! ! !Box methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:26'! undraw self drawColor: (Color white). ! ! !Box methodsFor: 'initialization' stamp: 'mjg 9/13/1999 13:25'! initialize pen _ Pen new. "Put a pen in an instance variable." pen place: 50@50. size _ 50. self draw. ! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Box class instanceVariableNames: ''! !Box class methodsFor: 'initialization' stamp: 'mjg 3/27/98 21:54'! clearWorld (Form extent: 600@200) fillWhite display! ! !Box class methodsFor: 'initialization' stamp: 'mjg 3/27/98 21:55'! new ^super new initialize! ! Box subclass: #NamedBox instanceVariableNames: 'name ' classVariableNames: '' poolDictionaries: '' category: 'Boxes'! !NamedBox methodsFor: 'access' stamp: 'mjg 3/30/98 15:17'! name ^name! ! !NamedBox methodsFor: 'access' stamp: 'mjg 3/30/98 15:16'! name: aName name _ aName! ! !NamedBox methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:21'! draw super draw. self drawNameColor: (Color black).! ! !NamedBox methodsFor: 'drawing' stamp: 'mjg 9/13/1999 13:28'! drawNameColor: aColor | displayName | (name isNil) ifTrue: [name _ 'Unnamed']. displayName _ name asDisplayText. displayName foregroundColor: aColor backgroundColor: (Color white). displayName displayAt: (pen location). ! ! !NamedBox methodsFor: 'drawing' stamp: 'mjg 3/30/98 15:54'! undraw super undraw. self drawNameColor: (Color white).! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! NamedBox class instanceVariableNames: ''! !NamedBox class methodsFor: 'initialization' stamp: 'mjg 3/30/98 15:19'! named: aName | newBox | newBox _ super new. newBox undraw. newBox name: aName. newBox draw. ^newBox! !