'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 27 January 2009 at 12:53:13 pm'!
!classDefinition: #EntryField2LW category: #'LightWidgets-Kernel'!
LightWidget subclass: #EntryField2LW
	instanceVariableNames: 'font contents editor foreColor backColor selectedForeColor selectedBackColor crAction actionPending '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'LightWidgets-Kernel'!
!classDefinition: #ListItemLW category: #'LightWidgets-Kernel'!
ButtonLW subclass: #ListItemLW
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'LightWidgets-Kernel'!

!ListItemLW commentStamp: '<historical>' prior: 0!
A list item is much like a button.!

!classDefinition: #ListOldLW category: #'LightWidgets-Kernel'!
CompositeLW subclass: #ListOldLW
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'LightWidgets-Kernel'!
!classDefinition: #MenuListLW category: #'LightWidgets-Widgets'!
CompositeLW subclass: #MenuListLW
	instanceVariableNames: 'backColor scrollBarColor scrollThumbColor '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'LightWidgets-Widgets'!

!ButtonLW methodsFor: 'event handling' stamp: 'jmv 1/27/2009 10:37'!
keyDown: evt
	"Handle a key down event."
	
	evt keyValue = 13 ifTrue: [
		pressed _ true.
		self updateView ].
	super keyDown: evt! !

!ButtonLW methodsFor: 'event handling' stamp: 'jmv 1/27/2009 10:38'!
keyUp: evt
	"Handle a key up event."
	"Warning: action is carried out in #keystroke: and not here because LIRC does not send
	#keyDown: / #keyUp"
	
	evt keyValue = 13 ifTrue: [
		pressed _ false.
		self updateView ].
	super keyUp: evt! !


!EntryField2LW methodsFor: 'accessing' stamp: 'jmv 1/27/2009 11:02'!
updateFromContents

	| c |
	c _ editor string.
	c = contents ifFalse: [
		contents _ c.
		actionPending _ true.
		self changed ]! !

!EntryField2LW methodsFor: 'event handling' stamp: 'jmv 1/27/2009 11:03'!
keyboardFocusChange: aBoolean 
	aBoolean ifTrue: [
		"A hand is wanting to send us characters... Ensure editor."
		self editor.
		self changed ]
	ifFalse: [
		actionPending ifTrue: [
			self performActionWith: contents.
			actionPending _ false ].
		self updateView ]! !

!EntryField2LW methodsFor: 'initialization' stamp: 'jmv 1/27/2009 11:00'!
initialize
	super initialize.
"	target _ self.
	aspect _ #visible.
	action _ #visible:."
	bounds _ 10@10 extent: 200@30.
	contents _ 'Entry Field'.
	actionPending _ false.
	font _ (TextStyle named: 'Vera') fontNamed: 'Vera 12'.
	foreColor _ Color white.
	selectedForeColor _ Color white.
	backColor _ Color r: 0.32 g: 0.39 b: 0.63.
	selectedBackColor _ Color r: 0.42 g: 0.5 b: 0.81.! !

!EntryField2LW methodsFor: 'updating' stamp: 'jmv 1/27/2009 11:01'!
modelChanged

	contents _ self targetAspect.
	actionPending _ false.
	editor _ nil.
	super modelChanged! !


!ListItemLW methodsFor: 'accessing' stamp: 'jmv 1/27/2009 11:30'!
actionArgument
	^actionArgument! !

!ListItemLW methodsFor: 'initialization' stamp: 'jmv 1/27/2009 11:30'!
initialize
	super initialize.
	bounds _ 10@10 extent: 100@30.
	label _ 'item text'! !

!ListItemLW methodsFor: 'drawing' stamp: 'jmv 1/27/2009 11:30'!
drawOn: aCanvas
	aCanvas fillRectangle: bounds color: self backColor.
	aCanvas drawString: label at: bounds topLeft + (5@2) font: font color: self foreColor! !

!ListItemLW methodsFor: 'focus handling' stamp: 'jmv 1/27/2009 11:30'!
keyboardFocusChange: aBoolean

	aBoolean ifTrue: [
		owner focused: self ].
	self changed! !

!ListItemLW methodsFor: 'focus handling' stamp: 'jmv 1/27/2009 11:30'!
seizesNavigationFocus
	^false! !


!ListOldLW methodsFor: 'focus handling' stamp: 'jmv 1/26/2009 14:04'!
focused: aSubmorph
	"Default is to do nothing."
	
	| delta |
	delta _ aSubmorph bounds amountToTranslateWithin: bounds.
	delta = (0@0) ifFalse: [
		submorphs do: [ :m |
			m privateFullMoveBy: delta].
		self changed]! !

!ListOldLW methodsFor: 'submorphs-add/remove' stamp: 'jmv 1/26/2009 14:04'!
addItem: aString action: aSymbol

	^self addItem: aString height: nil font: nil target: owner action: aSymbol argument: nil! !

!ListOldLW methodsFor: 'submorphs-add/remove' stamp: 'jmv 1/26/2009 14:04'!
addItem: aString action: aSymbol argument: anotherObject

	^self
		addItem: aString 
		height: nil 
		font: nil 
		target: owner 
		action: aSymbol 
		argument: anotherObject! !

!ListOldLW methodsFor: 'submorphs-add/remove' stamp: 'jmv 1/26/2009 14:04'!
addItem: aString height: h font: f action: aSymbol

	^self addItem: aString height: h font: f target: owner action: aSymbol argument: nil! !

!ListOldLW methodsFor: 'submorphs-add/remove' stamp: 'jmv 1/26/2009 14:04'!
addItem: aString height: h font: f action: aSymbol argument: anObject

	^self addItem: aString height: h font: f target: owner action: aSymbol argument: anObject! !

!ListOldLW methodsFor: 'submorphs-add/remove' stamp: 'jmv 1/26/2009 14:04'!
addItem: aString height: h font: f target: anObject action: aSymbol argument: anotherObject

	| item |
	item _ self defaultItemClass 
		target: anObject action: aSymbol argument: anotherObject label: aString.
	f notNil ifTrue: [ item font: f ].
	h notNil ifTrue: [ item height: h ].
	item width: self itemWidth.
	self addMorph: item.
	^item! !

!ListOldLW methodsFor: 'submorphs-add/remove' stamp: 'jmv 1/26/2009 14:04'!
addItem: aString target: anObject action: aSymbol

	^self addItem: aString height: nil font: nil target: anObject action: aSymbol argument: nil! !

!ListOldLW methodsFor: 'submorphs-add/remove' stamp: 'jmv 1/26/2009 14:04'!
addItem: aString target: anObject action: aSymbol argument: anotherObject

	| item |
	item _ self defaultItemClass 
		target: anObject action: aSymbol argument: anotherObject label: aString.
	item width: self itemWidth.
	self addMorph: item.
	^item! !

!ListOldLW methodsFor: 'submorphs-add/remove' stamp: 'jmv 1/26/2009 14:04'!
addMorph: aMorph
	| p |
	p _ submorphs isEmpty 
		ifFalse: [submorphs last bounds bottomLeft]
		ifTrue: [bounds topLeft].
	self addMorphBack: aMorph.
	aMorph position: p! !

!ListOldLW methodsFor: 'accessing' stamp: 'jmv 1/27/2009 11:31'!
defaultItemClass
	^ListItemLW! !

!ListOldLW methodsFor: 'accessing' stamp: 'jmv 1/26/2009 14:04'!
itemWidth
	^self width-20! !

!ListOldLW methodsFor: 'geometry' stamp: 'jmv 1/26/2009 14:04'!
scrollInterval
	"Answer an interval to draw the proportional thumb of a scroll bar"

	| b top bottom subTop subBottom thumbTop thumbBottom scale |
	top _ bounds top.
	bottom _ bounds bottom.
	subTop _ top.
	subBottom _ bottom.
	self submorphsDo:[:m |
		b _ m bounds.
		subTop _ subTop min: b top.
		subBottom _ subBottom max: b bottom ].
	scale _ 1.0 /  (subBottom - subTop) * (bottom - top ).
	thumbTop _ 1.0 * top - subTop * scale + top.
	thumbBottom _ 1.0 * bottom - subTop * scale + top.
	^ Interval from: thumbTop rounded to: thumbBottom rounded! !


!OldOneLineEditorMorph methodsFor: 'accessing' stamp: 'jmv 1/26/2009 15:57'!
contents: newContents 
	contents := 	newContents isText
		ifTrue: 
			[emphasis := newContents emphasisAt: 1.
			 newContents string]
		ifFalse: 
			[contents = newContents ifTrue: [^self].	"no substantive change"
			newContents].
	editor _ nil.
	self fitContents! !

!OldOneLineEditorMorph methodsFor: 'initialization' stamp: 'jmv 1/26/2009 15:55'!
initialize
	super initialize.
	contents _ ''.
	font _ nil.
	emphasis _ 0! !

!classDefinition: #MenuListLW category: #'LightWidgets-Widgets'!
CompositeLW subclass: #MenuListLW
	instanceVariableNames: 'backColor scrollBarColor scrollThumbColor'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'LightWidgets-Widgets'!
!classDefinition: #EntryField2LW category: #'LightWidgets-Kernel'!
LightWidget subclass: #EntryField2LW
	instanceVariableNames: 'font contents editor foreColor backColor selectedForeColor selectedBackColor crAction actionPending'
	classVariableNames: ''
	poolDictionaries: ''
	category: 'LightWidgets-Kernel'!
