'From Squeak3.1alpha of 28 February 2001 [latest update: #4288] on 23 August 2001 at 9:39:56 pm'! "Change Set: EtoyLoginMorph-ar Date: 23 August 2001 Author: Andreas Raab Transfers the simple eToy login from the BJSqueak image."! AlignmentMorphBob1 subclass: #EtoyLoginMorph instanceVariableNames: 'theName theNameMorph actionBlock cancelBlock ' classVariableNames: '' poolDictionaries: '' category: 'Morphic-Experimental'! EtoyLoginMorph class instanceVariableNames: ''! !EtoyLoginMorph methodsFor: 'initialize' stamp: 'ar 8/23/2001 21:36'! initialize | fs | super initialize. self beSticky. fs _ GradientFillStyle ramp: {0.0 -> (Color r: 0.5 g: 0.5 b: 1.0). 1.0 -> (Color r: 0.8 g: 0.8 b: 1.0) }. self vResizing: #shrinkWrap. self hResizing: #shrinkWrap. color _ Color paleYellow. borderWidth _ 8. borderColor _ color darker. self layoutInset: 4. self useRoundedCorners. self rebuild. fs origin: bounds origin. fs direction: 0@self fullBounds height. self fillStyle: fs.! ! !EtoyLoginMorph methodsFor: 'initialize' stamp: 'ar 9/24/2000 00:09'! name: aString actionBlock: aBlock cancelBlock: altBlock theName _ aString. actionBlock _ aBlock. cancelBlock _ altBlock. theNameMorph contentsWrapped: theName. theNameMorph editor selectAll.! ! !EtoyLoginMorph methodsFor: 'initialize' stamp: 'ar 9/23/2000 14:13'! openInWorld: aWorld super openInWorld: aWorld. aWorld primaryHand newKeyboardFocus: theNameMorph.! ! !EtoyLoginMorph methodsFor: 'initialize' stamp: 'ar 9/23/2000 23:52'! rebuild self removeAllMorphs. self addARow: { (StringMorph contents:'') lock }. self addARow: { (StringMorph contents: 'Please enter your Squeak login name' font: self myFont) lock. }. (self addARow: { (theNameMorph _ TextMorph new beAllFont: self myFont; crAction: (MessageSend receiver: self selector: #doOK); extent: 300@20; contentsWrapped: 'the old name'; setBalloonText: 'Enter your name and avoid the following characters: : < > | / \ ? * "' ). }) color: Color white; borderColor: Color black; borderWidth: 1. self addARow: { self okButton. self cancelButton. }. self addARow: { (StringMorph contents:'') lock }. ! ! !EtoyLoginMorph methodsFor: 'actions' stamp: 'ar 9/24/2000 00:08'! doCancel self delete. cancelBlock ifNotNil:[cancelBlock value].! ! !EtoyLoginMorph methodsFor: 'actions' stamp: 'ar 9/25/2000 13:38'! doOK | proposed | proposed _ theNameMorph contents string. proposed size = 0 ifTrue: [^self inform: 'Please enter your login name']. proposed size > 24 ifTrue: [^self inform: 'Please make the name 24 characters or less']. (Project isBadNameForStoring: proposed) ifTrue: [ ^self inform: 'Please remove any funny characters' ]. (actionBlock value: proposed) ifTrue:[self delete].! ! !EtoyLoginMorph methodsFor: 'building' stamp: 'ar 9/23/2000 13:48'! buttonColor ^color darker! ! !EtoyLoginMorph methodsFor: 'building' stamp: 'ar 9/23/2000 13:48'! buttonNamed: aString action: aSymbol color: aColor help: helpString | f col | f _ SimpleButtonMorph new target: self; label: aString font: self myFont; color: aColor; actionSelector: aSymbol; setBalloonText: helpString. col _ (self inAColumn: {f}) hResizing: #spaceFill. ^col! ! !EtoyLoginMorph methodsFor: 'building' stamp: 'ar 9/23/2000 13:49'! cancelButton ^self buttonNamed: 'Cancel' action: #doCancel color: self buttonColor help: 'Cancel this login operation.'! ! !EtoyLoginMorph methodsFor: 'building' stamp: 'ar 9/23/2000 13:48'! myFont ^(TextStyle named: #ComicBold) fontOfSize: 16! ! !EtoyLoginMorph methodsFor: 'building' stamp: 'ar 9/23/2000 13:50'! okButton ^self buttonNamed: 'OK' action: #doOK color: self buttonColor help: 'Login into Squeak'! ! !EtoyLoginMorph class methodsFor: 'instance creation' stamp: 'ar 8/23/2001 21:37'! loginAndDo: aBlock ifCanceled: cancelBlock "EtoyLoginMorph loginAndDo:[:n| true] ifCanceled:[]" | me | (me _ self new) name: 'your name' actionBlock: aBlock cancelBlock: cancelBlock; fullBounds; position: Display extent - me extent // 2; openInWorld. me position: me position + (0@40).! !