'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 12 May 2008 at 1:25:06 pm'!

!EntryFieldLW methodsFor: 'drawing' stamp: 'jmv 5/12/2008 13:23'!
drawOn: aCanvas
	| string leftX w cColor borderWidth  stringBounds font xOffset xExtent selectionBounds orig ext cursorBounds str |
	borderWidth _ self borderWidth.
	aCanvas frameAndFillRectangle: bounds fillColor: self backgroundColor borderWidth: borderWidth borderColor: self borderColor.

	self isValid ifFalse:[aCanvas fillRectangle: bounds  color: (Color red alpha:0.4)].
 
	string _ self value.
	stringBounds _ self stringPosition extent: bounds extent - (2* borderWidth). 
	hideValue ifTrue:[ str _ string collect:[:char| $*]] ifFalse:[ str_ string].
	aCanvas drawString: str in: stringBounds font: self font color: color.

	self hasSelection
		ifTrue:[ 
			font _ self font.
			xOffset _ 0.
			(1 to: selection first - 1) do:[:i| xOffset _  xOffset + (font widthOf: (string at:i))].
			xExtent _ 0.
			 selection do:[:i|  xExtent _ xExtent + (font widthOf: (string at:i))]. 
			selectionBounds _  (stringBounds origin +(xOffset@0) ) extent: (xExtent@ stringBounds extent y).
			aCanvas fillRectangle: selectionBounds color: (Color green lighter alpha:0.5)]. 
	
	
	xOffset _ 0. 
	font _ self font.
	(string notNil and:[string notEmpty ])
		ifTrue:[	
				cursorPosition _ cursorPosition min: string size.
				(0 to: cursorPosition -2 ) do:[:i|  xOffset _ xOffset + (font widthOf: (string at:i+1))]].	
	orig _ self stringPosition + (xOffset@0).
	ext _  2@ stringBounds extent y.
	cursorBounds _ orig extent: ext.
	leftX _ cursorBounds origin x + (cursorBounds extent x / 2).
	w := 4.
	cColor :=  self cursorColor.
	1 to: w
		do: 
			[:i | 
				aCanvas fillRectangle: ((leftX - w + i - 1) @ (cursorBounds origin y + i - 1) 
								extent: ((w - i) * 2 + 3) @ 1)
						color: cColor.
					aCanvas fillRectangle: ((leftX - w + i - 1) @ (cursorBounds origin y + cursorBounds extent y - i) 
								extent: ((w - i) * 2 + 3) @ 1)
						color: cColor].
			aCanvas fillRectangle: cursorBounds color: cColor
	
			
	! !


!PersonView methodsFor: 'initialization' stamp: 'jmv 5/12/2008 13:17'!
initialize
	"initialize the state of the receiver"
	| n b a  g |
	super initialize.
	bounds _ 10@10 extent: 450@400.
	
	n _ LabelLW label:  'Name:'.
	n bounds: ((10@20) extent: 90@40).
	nameLW _ EntryFieldLW new
		aspect: #name;
		action: #name:;
		bounds: (115 @20 extent: 200@40).
	hide _ false.
	hideNameLW _ ButtonLW  target: self action:#toogleHideName label:'Hide name'.	
	hideNameLW bounds: ((115+205) @20 extent: 120@40).
	
	b _ LabelLW label:  'Birthday:'.
	b bounds: ((10@65) extent: 100@40).
	birthdayLW _ EntryFieldLW new
		aspect: #birthday adaptor: #mmddyyyy action: #birthday: adaptor: #asDate;
		bounds: (115@65 extent: 200@40).
	
	a _ LabelLW label:  'Age:'.
	a bounds: ((10@115) extent: 50@40).
	ageLW _ EntryFieldLW new
		aspect: #age adaptor: #asString action: #age: adaptor: #asNumber;
		bounds: (115@115 extent: 200@40).
	sliderLW _ SliderLW new
		target: target aspect:#age action: #age:;
		bounds:( 115@160 extent: 200@40).
	 
	g _ LabelLW label:  'Gender:'.
	g bounds: ((10@210) extent: 100@40).
	genderLW_ ListLW new.
	genderLW
		bounds: (115@255 extent: 200@55);	
		addItem: 'Male' action: #male;
		addItem: 'Female' action: #female.
	self 
		addMorphBack: n; addMorphBack: nameLW;
		addMorphBack:b; addMorphBack: birthdayLW;addMorphBack: hideNameLW;
		addMorphBack: a; addMorphBack: ageLW;addMorphBack: sliderLW;
		addMorphBack: g; addMorphBack: genderLW.
	
	ActiveHand navigationFocus: nameLW! !

