author | Claus Gittinger <cg@exept.de> |
Thu, 09 Jan 1997 12:57:57 +0100 | |
changeset 275 | da88b7732dff |
parent 272 | 6c6466cd4ea1 |
child 278 | 4a22889a5730 |
permissions | -rw-r--r-- |
131 | 1 |
ComboView subclass:#ComboListView |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
2 |
instanceVariableNames:'useIndex' |
131 | 3 |
classVariableNames:'' |
4 |
poolDictionaries:'' |
|
5 |
category:'Views-Interactors' |
|
6 |
! |
|
7 |
||
270 | 8 |
!ComboListView class methodsFor:'documentation'! |
131 | 9 |
|
10 |
documentation |
|
11 |
" |
|
12 |
A ComboListView combines an label with a drop down list of default inputs; |
|
13 |
choosing any from the pulled list sets the string in the label. |
|
14 |
||
15 |
This is the same as a PopUpList or SelectionInListView, bit looks different. |
|
16 |
||
275 | 17 |
Not yet finished - it may need more protocol. |
18 |
||
19 |
[author:] |
|
20 |
Claus Gittinger |
|
21 |
||
22 |
[see also:] |
|
23 |
ComboView |
|
24 |
PopUpList SelectionInListView |
|
25 |
ComboBoxView |
|
26 |
PullDownMenu Label EntryField |
|
131 | 27 |
" |
28 |
! |
|
29 |
||
30 |
examples |
|
31 |
" |
|
181 | 32 |
[exBegin] |
131 | 33 |
|top b| |
34 |
||
35 |
top := StandardSystemView new. |
|
36 |
top extent:(300 @ 200). |
|
37 |
||
38 |
b := ComboListView in:top. |
|
39 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
40 |
b bottomInset:(b preferredExtent y negated). |
|
41 |
||
42 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
43 |
top open. |
|
181 | 44 |
[exEnd] |
131 | 45 |
|
46 |
||
47 |
||
48 |
model operation: |
|
181 | 49 |
[exBegin] |
131 | 50 |
|model top b| |
51 |
||
52 |
model := 'foo' asValue. |
|
53 |
||
54 |
top := StandardSystemView new. |
|
55 |
top extent:(300 @ 200). |
|
56 |
||
57 |
b := ComboListView in:top. |
|
58 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0). |
|
59 |
b bottomInset:(b preferredExtent y negated). |
|
60 |
||
61 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
62 |
b model:model. |
|
63 |
||
64 |
top openModal. |
|
184 | 65 |
Transcript showCR:('comboBox''s value: ' , model value). |
181 | 66 |
[exEnd] |
131 | 67 |
|
68 |
||
69 |
in a dialog: |
|
181 | 70 |
[exBegin] |
131 | 71 |
|model1 model2 dialog b| |
72 |
||
73 |
model1 := 'foo' asValue. |
|
74 |
model2 := 'bar' asValue. |
|
75 |
||
76 |
dialog := Dialog new. |
|
77 |
(dialog addTextLabel:'ComboList example:') adjust:#left. |
|
78 |
dialog addVerticalSpace. |
|
79 |
||
80 |
(b := dialog addComboListOn:model1 tabable:true). |
|
81 |
b list:#('fee' 'foe' 'foo'). |
|
82 |
dialog addVerticalSpace. |
|
83 |
||
84 |
(b := dialog addComboListOn:model2 tabable:true). |
|
85 |
b list:#('bar' 'baz' 'baloo'). |
|
86 |
dialog addVerticalSpace. |
|
87 |
||
88 |
dialog addOkButton. |
|
89 |
||
90 |
dialog open. |
|
91 |
||
184 | 92 |
Transcript showCR:('1st comboBox''s value: ' , model1 value). |
93 |
Transcript showCR:('2nd comboBox''s value: ' , model2 value). |
|
181 | 94 |
[exEnd] |
131 | 95 |
" |
96 |
! ! |
|
97 |
||
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
98 |
!ComboListView methodsFor:'accessing-behavior'! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
99 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
100 |
useIndex:aBoolean |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
101 |
"specify, if the selected components value or its index in the |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
102 |
list should be sent to the model. The default is its value." |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
103 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
104 |
useIndex := aBoolean. |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
105 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
106 |
"Created: 26.7.1996 / 17:44:18 / cg" |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
107 |
! ! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
108 |
|
131 | 109 |
!ComboListView methodsFor:'accessing-components'! |
110 |
||
111 |
label |
|
181 | 112 |
"return the label component" |
131 | 113 |
|
114 |
^ field |
|
115 |
||
116 |
"Modified: 28.2.1996 / 15:10:50 / cg" |
|
117 |
"Created: 28.2.1996 / 15:13:51 / cg" |
|
118 |
! ! |
|
119 |
||
215 | 120 |
!ComboListView methodsFor:'accessing-contents'! |
121 |
||
122 |
contents:something |
|
272 | 123 |
"set the current value - either in the fields model |
124 |
or directly" |
|
125 |
||
215 | 126 |
|m| |
127 |
||
128 |
(m := field model) notNil ifTrue:[ |
|
129 |
m value:something |
|
130 |
] ifFalse:[ |
|
131 |
field label:something |
|
132 |
] |
|
133 |
||
134 |
"Created: 15.7.1996 / 13:16:49 / cg" |
|
272 | 135 |
"Modified: 5.1.1997 / 00:05:04 / cg" |
215 | 136 |
! ! |
137 |
||
131 | 138 |
!ComboListView methodsFor:'initialization'! |
139 |
||
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
140 |
initialize |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
141 |
useIndex isNil ifTrue:[useIndex := false]. |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
142 |
super initialize. |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
143 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
144 |
"Created: 26.7.1996 / 17:44:57 / cg" |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
145 |
! |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
146 |
|
131 | 147 |
initializeField |
148 |
field := Label in:self. |
|
149 |
field level:-1. |
|
150 |
field adjust:#left. |
|
151 |
||
152 |
" |
|
153 |
|b| |
|
154 |
||
155 |
b := ComboListView new. |
|
156 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
157 |
b open |
|
158 |
" |
|
159 |
||
160 |
"Created: 28.2.1996 / 15:13:46 / cg" |
|
161 |
"Modified: 28.2.1996 / 15:18:40 / cg" |
|
162 |
! ! |
|
163 |
||
215 | 164 |
!ComboListView methodsFor:'private'! |
165 |
||
166 |
getValueFromModel |
|
232
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
167 |
|val| |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
168 |
|
215 | 169 |
model notNil ifTrue:[ |
170 |
(model respondsTo:#selection) ifTrue:[ |
|
232
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
171 |
"/ mhmh - looks like a selectionInList model |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
172 |
useIndex ifTrue:[ |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
173 |
val := list at:(model selectionIndex) |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
174 |
] ifFalse:[ |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
175 |
val := (model selection) |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
176 |
] |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
177 |
] ifFalse:[ |
232
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
178 |
"/ mhmh - looks like a valueHolder |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
179 |
useIndex ifTrue:[ |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
180 |
val := list at:(model value) |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
181 |
] ifFalse:[ |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
182 |
val := model value |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
183 |
]. |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
184 |
]. |
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
185 |
self contents:val |
215 | 186 |
]. |
187 |
||
188 |
"Created: 15.7.1996 / 12:28:53 / cg" |
|
232
23dd09b9fbdf
also care for #useIndex: when fetching values from the model
Claus Gittinger <cg@exept.de>
parents:
231
diff
changeset
|
189 |
"Modified: 26.7.1996 / 18:07:04 / cg" |
215 | 190 |
! ! |
191 |
||
131 | 192 |
!ComboListView methodsFor:'user interaction'! |
193 |
||
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
194 |
entryChanged:index |
270 | 195 |
|what changeArg| |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
196 |
|
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
197 |
what := list at:index. |
131 | 198 |
field label:what. |
238 | 199 |
|
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
200 |
model notNil ifTrue:[ |
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
201 |
useIndex ifTrue:[ |
270 | 202 |
changeArg := index |
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
203 |
] ifFalse:[ |
270 | 204 |
changeArg := what |
205 |
]. |
|
206 |
self sendChangeMessage:changeMsg with:changeArg |
|
231
3cb7dafa8cd2
allow index-passing (#useIndex:)
Claus Gittinger <cg@exept.de>
parents:
215
diff
changeset
|
207 |
]. |
131 | 208 |
pullDownButton turnOff. |
209 |
||
210 |
"Created: 28.2.1996 / 15:13:46 / cg" |
|
238 | 211 |
"Modified: 4.9.1996 / 22:38:57 / cg" |
131 | 212 |
! ! |
213 |
||
270 | 214 |
!ComboListView class methodsFor:'documentation'! |
131 | 215 |
|
216 |
version |
|
275 | 217 |
^ '$Header: /cvs/stx/stx/libwidg2/Attic/ComboListV.st,v 1.10 1997-01-09 11:57:57 cg Exp $' |
131 | 218 |
! ! |