--- a/PopUpList.st Tue May 09 03:57:16 1995 +0200
+++ b/PopUpList.st Wed May 10 04:30:46 1995 +0200
@@ -10,10 +10,10 @@
hereby transferred.
"
-'From Smalltalk/X, Version:2.10.5 on 9-may-1995 at 12:04:16 pm'!
+'From Smalltalk/X, Version:2.10.5 on 9-may-1995 at 12:06:03 pm'!
Button subclass:#PopUpList
- instanceVariableNames:'menu menuAction values useIndex listMsg initialSelectionMsg'
+ instanceVariableNames:'menu menuAction values useIndex listMsg'
classVariableNames:''
poolDictionaries:''
category:'Views-Interactors'
@@ -23,7 +23,7 @@
COPYRIGHT (c) 1994 by Claus Gittinger
All Rights Reserved
-$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.12 1995-05-09 01:56:26 claus Exp $
+$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.13 1995-05-10 02:29:55 claus Exp $
'!
!PopUpList class methodsFor:'documentation'!
@@ -44,7 +44,7 @@
version
"
-$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.12 1995-05-09 01:56:26 claus Exp $
+$Header: /cvs/stx/stx/libwidg/PopUpList.st,v 1.13 1995-05-10 02:29:55 claus Exp $
"
!
@@ -78,10 +78,6 @@
listMsg <Symbol> message to aquire a new list from the
model. Default is #list.
-
-
- initialSelectionMsg <Symbol> message to aquire a new selection from the
- model. Default is #selection.
"
!
@@ -140,15 +136,15 @@
|p|
p := PopUpList label:'dummy'.
p list:#('apples' 'bananas' 'grape' 'lemon'
- '='
- 'margaritas' 'pina colada'
- '='
- 'smalltalk' 'c++' 'eiffel').
+ '='
+ 'margaritas' 'pina colada'
+ '='
+ 'smalltalk' 'c++' 'eiffel').
p values:#(apples bananas grape lemon
- nil
- 'mhmh - so good' 'makes headache'
- nil
- 'great' 'another headache' 'no bad').
+ nil
+ 'mhmh - so good' 'makes headache'
+ nil
+ 'great' 'another headache' 'no bad').
p selection:'apples'.
p action:[:what | Transcript show:'you selected: '; showCr:what].
p open
@@ -197,11 +193,13 @@
model selection:'apples'.
p := PopUpList on:model.
+ p useIndex:true; aspect:#selectionIndex; change:#selectionIndex:.
p open.
slv := SelectionInListView on:model.
slv open.
+ p inspect.
model selectionIndexHolder inspect
@@ -221,11 +219,11 @@
panel horizontalLayout:#fitSpace.
p := PopUpList label:'meals'.
- p model:model; listMessage:#meals; change:#eat:.
+ p model:model; listMessage:#meals; aspect:nil; change:#eat:.
panel add:p.
p := PopUpList label:'drinks'.
- p model:model; listMessage:#drinks; change:#drink:.
+ p model:model; listMessage:#drinks; aspect:nil; change:#drink:.
panel add:p.
top open
@@ -246,31 +244,13 @@
^ #selection:
! !
-!PopUpList methodsFor:'drawing'!
-
-drawWith:fgColor and:bgColor
- |mmH mmV mW mH|
-
- controller pressed ifTrue:[
- super drawWith:enteredFgColor and:enteredBgColor
- ] ifFalse:[
- super drawWith:fgColor and:bgColor.
- ].
- mmH := device horizontalPixelPerMillimeter rounded.
- mmV := device verticalPixelPerMillimeter rounded.
- mW := (device horizontalPixelPerMillimeter * 2.5) rounded.
- mH := (device verticalPixelPerMillimeter * 1.5) rounded.
-
- self drawEdgesForX:(width - mW - (hSpace*2)) y:(height - mmV // 2)
- width:mW height:mH level:2
-! !
-
!PopUpList methodsFor:'private'!
realize
super realize.
model notNil ifTrue:[
- self getListFromModel
+ self getListFromModel.
+ self getSelectionFromModel.
].
!
@@ -308,15 +288,6 @@
labelHeight := labelHeight max: (mmV * 2) rounded
!
-getSelectionFromModel
- "if I have a model and a listMsg, get my list from it"
-
- (model notNil
- and:[aspectMsg notNil]) ifTrue:[
- self selection:(model perform:aspectMsg).
- ].
-!
-
createMenuFor:aList
menu := PopUpMenu
labels:aList
@@ -324,15 +295,25 @@
args:(1 to:aList size)
receiver:self
for:self.
-!
+! !
-getListFromModel
- "if I have a model and a listMsg, get my list from it"
+!PopUpList methodsFor:'drawing'!
+
+drawWith:fgColor and:bgColor
+ |mmH mmV mW mH|
- (model notNil
- and:[listMsg notNil]) ifTrue:[
- self list:(model perform:listMsg).
+ controller pressed ifTrue:[
+ super drawWith:enteredFgColor and:enteredBgColor
+ ] ifFalse:[
+ super drawWith:fgColor and:bgColor.
].
+ mmH := device horizontalPixelPerMillimeter rounded.
+ mmV := device verticalPixelPerMillimeter rounded.
+ mW := (device horizontalPixelPerMillimeter * 2.5) rounded.
+ mH := (device verticalPixelPerMillimeter * 1.5) rounded.
+
+ self drawEdgesForX:(width - mW - (hSpace*2)) y:(height - mmV // 2)
+ width:mW height:mH level:2
! !
!PopUpList methodsFor:'event handling'!
@@ -469,6 +450,26 @@
p action:[:val | Transcript showCr:'selected: ' , val printString].
p open.
"
+! !
+
+!PopUpList methodsFor:'accessing-mvc'!
+
+getListFromModel
+ "if I have a model and a listMsg, get my list from it"
+
+ (model notNil
+ and:[listMsg notNil]) ifTrue:[
+ self list:(model perform:listMsg).
+ ].
+!
+
+getSelectionFromModel
+ "if I have a model and an aspectMsg, get my current value from it"
+
+ (model notNil
+ and:[aspectMsg notNil]) ifTrue:[
+ self selection:(model perform:aspectMsg).
+ ].
!
listMessage:aSelector
@@ -478,6 +479,13 @@
listMsg := aSelector
!
+addModelInterfaceTo:aDictionary
+ "see comment in View>>modelInterface"
+
+ super addModelInterfaceTo:aDictionary.
+ aDictionary at:#listMessage put:listMsg
+!
+
listMessage
"return the selector by which we ask the model for the list.
Default is #list."
@@ -489,11 +497,12 @@
initialize
super initialize.
+
controller beTriggerOnDown.
controller action:[self popMenu].
self adjust:#left.
useIndex := false.
-
+ self label:'popup'.
listMsg := self class defaultListMessage.
onLevel := offLevel.