'From etoys2.2 of 24 September 2007 [latest update: #1665] on 25 September 2007 at 2:38:25 pm'! "Change Set: simpleSwitchMorph-apb Date: 3 May 2006 Author: Andrew P Black - Adapted 9/25/2007 for etoys/olpc use by sw, Mantis bug 3530 -- see http://bugs.squeak.org/print_bug_page.php?bug_id=3530 Provides compatibility support for examples in the book 'Squeak by Example' -- see http://www.iam.unibe.ch/~scg/SBE/ The only change from Andrew's SwitchMorphEnh.2.cs dated 5/3/06 is the removal of the SimpleSwitchMorphTest class, since SUnit is absent from the the squeakland and olpc end-user images. We will in due course manage to get this into the olpc etoys development image, which *does* have SUnit in it."! !SimpleSwitchMorph commentStamp: 'apb 5/3/2006 16:04' prior: 0! I represent a switch that can be either on or off. I chnage my state in response to a mouse click. When clicked, I also send my actionSelector to my target, just like a SimpleButtonMorph.! !SimpleButtonMorph class methodsFor: 'printing' stamp: 'apb 5/3/2006 14:37'! defaultNameStemForInstances ^ self = SimpleButtonMorph ifTrue: ['Button'] ifFalse: [^ super defaultNameStemForInstances]! ! !SimpleSwitchMorph methodsFor: 'initialization' stamp: 'apb 5/3/2006 15:51'! initializeWithLabel: labelString super initializeWithLabel: labelString. self borderWidth: 3. self extent: self extent + 2. onColor := Color r: 1.0 g: 0.6 b: 0.6. offColor := Color lightGray. color := offColor ! ! !SimpleSwitchMorph methodsFor: 'switching' stamp: 'apb 5/3/2006 15:45'! isOff ^ color ~= onColor! ! !SimpleSwitchMorph methodsFor: 'switching' stamp: 'apb 5/3/2006 15:45'! isOn ^ color = onColor! ! !SimpleSwitchMorph methodsFor: 'switching' stamp: 'apb 5/3/2006 15:46'! setSwitchState: aBoolean aBoolean ifTrue: [self turnOn] ifFalse: [self turnOff]. ! ! !SimpleSwitchMorph methodsFor: 'switching' stamp: 'apb 5/3/2006 16:11'! toggleState self isOn ifTrue: [self turnOff] ifFalse: [self turnOn]! ! !SimpleSwitchMorph methodsFor: 'switching' stamp: 'apb 5/3/2006 15:44'! turnOff self borderColor: #raised. self color: offColor! ! !SimpleSwitchMorph methodsFor: 'switching' stamp: 'apb 5/3/2006 15:44'! turnOn self borderColor: #inset. self color: onColor! !