VViews.st


ModelValueViewContainer subclass: #ItemViewContainer
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Vending Views'!

!ItemViewContainer methodsFor: 'view creation'!

buildViewOn: aDispensingHolder self addNameViewOn: aDispensingHolder. self addPriceViewOn: aDispensingHolder. self addSelectButtonOn: aDispensingHolder.! !

!ItemViewContainer methodsFor: 'view layout'!

addNameViewOn: aDispensingHolder | itemView itemArea | itemView := self makeDisplayBoxOn: aDispensingHolder for: #dispensableItemName. itemArea := self constraintFrame: 0 @ 0 corner: 2 / 3 @ (1 / 2). self addView: itemView in: itemArea!

addPriceViewOn: aDispensingHolder | itemView itemArea | itemView := self makeDisplayBoxOn: aDispensingHolder for: #dispensableItemPrice. itemArea := self constraintFrame: 0 @ (1 / 2) corner: 2 / 3 @ 1. self addView: itemView in: itemArea!

addSelectButtonOn: aDispensingHolder | button buttonArea | button := self makeButton: 'Select' on: aDispensingHolder for: #vendTheDispensableItem. buttonArea := self constraintFrame: 2 / 3 @ (1 / 2) corner: 1 @ 1. self addView: button in: buttonArea! !

!ItemViewContainer methodsFor: 'window opening'!

windowLabel ^'Items'!

windowSize ^200 @ 66 "pixels"! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

ItemViewContainer class instanceVariableNames: ''!

!ItemViewContainer class methodsFor: 'demos'!

vendingMachineDemoFor: dispensingHolders and: cashDevice | composite rowFraction window | composite := ModelValueViewContainer new. rowFraction := 1.0 / dispensingHolders size. 1 to: dispensingHolders size do: [:index | self viewFor: (dispensingHolders at: index) in: composite at: index - 1 * rowFraction to: index * rowFraction]. window := ScheduledWindow new. window component: composite. window minimumSize: 200 @ 200. window label: 'Vending Machine'. window open. CashDeviceViewContainer new openOn: cashDevice!

viewFor: dispenser in: composite at: topFraction to: bottomFraction | itemContainer frame | itemContainer := ItemViewContainer new buildViewOn: dispenser. frame := composite constraintFrame: 0 @ topFraction corner: 1 @ bottomFraction. composite addView: itemContainer in: frame! ! ModelValueViewContainer subclass: #CashDeviceViewContainer instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Vending Views'!

!CashDeviceViewContainer methodsFor: 'prototypes'!

class "Answer the object which is the receiver's class."

self primitiveFailed!

doesNotUnderstand: aMessage "The default behavior is to create a Notifier containing the appropriate message and to allow the user to open a Debugger. Subclasses can override this message in order to modify this behavior."

(Object canUnderstand: aMessage selector) ifTrue: [self class copy: aMessage selector from: Object. ^self perform: aMessage selector withArguments: aMessage arguments].

^Object messageNotUnderstoodSignal raiseRequestWith: aMessage errorString: 'Message not understood: ' , aMessage selector! !

!CashDeviceViewContainer methodsFor: 'view creation'!

buildViewOn: aMoneyDevice

self addValueViewOn: aMoneyDevice. self addIncrementButtonOn: aMoneyDevice. self addReturnButtonOn: aMoneyDevice.! !

!CashDeviceViewContainer methodsFor: 'view layout'!

addIncrementButtonOn: aCashDevice | button buttonArea | button := self makeButton: 'Add Cash' on: aCashDevice for: #addCash. buttonArea := self constraintFrame: 2 /3 @ 0 corner: 1 @ (1 / 2). self addView: button in: buttonArea!

addReturnButtonOn: aCashDevice | button buttonArea | button := self makeButton: 'Return' on: aCashDevice for: #return. buttonArea := self constraintFrame: 2 /3 @ (1 / 2) corner: 1 @ 1. self addView: button in: buttonArea!

addValueViewOn: aMoneyDevice | itemView itemArea | itemView := self makeDisplayBoxOn: aMoneyDevice for: #amountCollected. itemArea := self constraintFrame: 0 @ 1 / 3 corner: 2 / 3 @ 2 / 3. self addView: itemView in: itemArea! !

!CashDeviceViewContainer methodsFor: 'window opening'!

windowLabel ^'Cash Device'!

windowSize ^250 @ 50 "pixels"! !


News Page | CS2390 Sum'97 Home Page | MMC-CaMILE | STABLE
Questions/comments/concerns to guzdial@cc.gatech.edu
Page last updated 7/16/97; 10:16:57 AM