129
|
1 |
View subclass:#ComboView
|
|
2 |
instanceVariableNames:'field pullDownButton list'
|
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Views-Interactors'
|
|
6 |
!
|
|
7 |
|
214
|
8 |
!ComboView class methodsFor:'documentation'!
|
129
|
9 |
|
|
10 |
documentation
|
|
11 |
"
|
|
12 |
A ComboView combines some field (typically an enterField or Label)
|
|
13 |
with a drop down list of default inputs;
|
|
14 |
ComboView is abstract, providing protocol common to ComboBoxView and
|
|
15 |
ComboListView. See documentation & examples there.
|
|
16 |
"
|
|
17 |
!
|
|
18 |
|
|
19 |
examples
|
|
20 |
"
|
|
21 |
|top b|
|
|
22 |
|
|
23 |
top := StandardSystemView new.
|
|
24 |
top extent:(300 @ 200).
|
|
25 |
|
|
26 |
b := ComboBoxView in:top.
|
|
27 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
|
|
28 |
b bottomInset:(b preferredExtent y negated).
|
|
29 |
|
|
30 |
b list:#('hello' 'world' 'this' 'is' 'st/x').
|
|
31 |
top open.
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
model operation:
|
|
36 |
|
|
37 |
|model top b|
|
|
38 |
|
|
39 |
model := 'foo' asValue.
|
|
40 |
|
|
41 |
top := StandardSystemView new.
|
|
42 |
top extent:(300 @ 200).
|
|
43 |
|
|
44 |
b := ComboBoxView in:top.
|
|
45 |
b origin:(0.0 @ 0.0) corner:(1.0 @ 0.0).
|
|
46 |
b bottomInset:(b preferredExtent y negated).
|
|
47 |
|
|
48 |
b list:#('hello' 'world' 'this' 'is' 'st/x').
|
|
49 |
b model:model.
|
|
50 |
|
|
51 |
top openModal.
|
184
|
52 |
Transcript showCR:('comboBox''s value: ' , model value).
|
129
|
53 |
|
|
54 |
|
|
55 |
in a dialog:
|
|
56 |
|
|
57 |
|model1 model2 dialog b|
|
|
58 |
|
|
59 |
model1 := 'foo' asValue.
|
|
60 |
model2 := 'bar' asValue.
|
|
61 |
|
|
62 |
dialog := Dialog new.
|
|
63 |
(dialog addTextLabel:'ComboBox example:') adjust:#left.
|
|
64 |
dialog addVerticalSpace.
|
|
65 |
|
|
66 |
(b := dialog addComboBoxOn:model1 tabable:true).
|
|
67 |
b list:#('fee' 'foe' 'foo').
|
|
68 |
dialog addVerticalSpace.
|
|
69 |
|
|
70 |
(b := dialog addComboBoxOn:model2 tabable:true).
|
|
71 |
b list:#('bar' 'baz' 'baloo').
|
|
72 |
dialog addVerticalSpace.
|
|
73 |
|
|
74 |
dialog addOkButton.
|
|
75 |
|
|
76 |
dialog open.
|
|
77 |
|
184
|
78 |
Transcript showCR:('1st comboBox''s value: ' , model1 value).
|
|
79 |
Transcript showCR:('2nd comboBox''s value: ' , model2 value).
|
129
|
80 |
"
|
|
81 |
! !
|
|
82 |
|
214
|
83 |
!ComboView class methodsFor:'defaults'!
|
129
|
84 |
|
|
85 |
buttonForm
|
|
86 |
|form|
|
|
87 |
|
|
88 |
form := Form fromFile:'ComboDn_win.xbm'.
|
|
89 |
^ form on:Display
|
|
90 |
! !
|
|
91 |
|
|
92 |
!ComboView methodsFor:'accessing-components'!
|
|
93 |
|
|
94 |
menuButton
|
|
95 |
"return the menuButton component"
|
|
96 |
|
|
97 |
^ pullDownButton
|
|
98 |
|
|
99 |
"Created: 28.2.1996 / 15:03:14 / cg"
|
|
100 |
! !
|
|
101 |
|
|
102 |
!ComboView methodsFor:'accessing-contents'!
|
|
103 |
|
181
|
104 |
contents
|
|
105 |
^ field model value
|
|
106 |
|
|
107 |
"Created: 14.5.1996 / 13:05:16 / cg"
|
|
108 |
"Modified: 14.5.1996 / 13:07:02 / cg"
|
|
109 |
!
|
|
110 |
|
|
111 |
contents:something
|
214
|
112 |
|m|
|
|
113 |
|
|
114 |
(m := field model) notNil ifTrue:[
|
|
115 |
m value:something
|
|
116 |
]
|
181
|
117 |
|
|
118 |
"Created: 14.5.1996 / 13:05:33 / cg"
|
214
|
119 |
"Modified: 15.7.1996 / 13:16:24 / cg"
|
181
|
120 |
!
|
|
121 |
|
129
|
122 |
list:aList
|
|
123 |
list := aList.
|
|
124 |
(list notNil and:[list notEmpty]) ifTrue:[
|
|
125 |
pullDownButton controller enable
|
|
126 |
] ifFalse:[
|
|
127 |
pullDownButton controller disable
|
|
128 |
].
|
|
129 |
|
|
130 |
"Modified: 9.2.1996 / 00:51:56 / cg"
|
|
131 |
"Created: 28.2.1996 / 15:03:14 / cg"
|
|
132 |
! !
|
|
133 |
|
214
|
134 |
!ComboView methodsFor:'accessing-mvc'!
|
|
135 |
|
|
136 |
model:aModel
|
|
137 |
super model:aModel.
|
|
138 |
self getListFromModel.
|
|
139 |
self getValueFromModel.
|
|
140 |
|
|
141 |
"Created: 15.7.1996 / 12:23:39 / cg"
|
|
142 |
"Modified: 15.7.1996 / 12:26:09 / cg"
|
|
143 |
!
|
|
144 |
|
|
145 |
update:something with:aParameter from:changedObject
|
|
146 |
changedObject == model ifTrue:[
|
|
147 |
self getListFromModel.
|
|
148 |
self getValueFromModel.
|
|
149 |
].
|
|
150 |
super update:something with:aParameter from:changedObject
|
|
151 |
|
|
152 |
"Created: 15.7.1996 / 12:26:49 / cg"
|
|
153 |
! !
|
|
154 |
|
129
|
155 |
!ComboView methodsFor:'initialization'!
|
|
156 |
|
|
157 |
initialize
|
|
158 |
|ext|
|
|
159 |
|
|
160 |
super initialize.
|
|
161 |
|
|
162 |
self initializeField.
|
|
163 |
field origin:0.0@0.0 corner:1.0@1.0.
|
|
164 |
|
|
165 |
pullDownButton := Toggle in:self.
|
|
166 |
pullDownButton label:(self class buttonForm).
|
|
167 |
pullDownButton showLamp:false.
|
|
168 |
pullDownButton activeLevel == pullDownButton passiveLevel ifTrue:[
|
|
169 |
pullDownButton activeLevel:0.
|
|
170 |
].
|
|
171 |
ext := pullDownButton preferredExtent.
|
|
172 |
pullDownButton origin:1.0@0.0 corner:1.0@1.0.
|
217
|
173 |
styleSheet is3D ifTrue:[
|
|
174 |
pullDownButton leftInset:(ext x "+ (ViewSpacing//2)") negated.
|
|
175 |
field rightInset:(ext x + (ViewSpacing//2)).
|
|
176 |
] ifFalse:[
|
|
177 |
pullDownButton leftInset:(ext x + pullDownButton borderWidth) negated.
|
|
178 |
field rightInset:(ext x).
|
|
179 |
].
|
129
|
180 |
|
|
181 |
pullDownButton disable.
|
|
182 |
pullDownButton pressAction:[self pullMenu].
|
|
183 |
|
|
184 |
self height:field preferredExtent y + ViewSpacing.
|
|
185 |
|
|
186 |
"
|
|
187 |
|b|
|
|
188 |
|
|
189 |
b := ComboBoxView new.
|
|
190 |
b list:#('hello' 'world' 'this' 'is' 'st/x').
|
|
191 |
b open
|
|
192 |
"
|
|
193 |
|
|
194 |
"Created: 28.2.1996 / 15:03:17 / cg"
|
217
|
195 |
"Modified: 17.7.1996 / 11:39:25 / cg"
|
129
|
196 |
! !
|
|
197 |
|
|
198 |
!ComboView methodsFor:'message delegation'!
|
|
199 |
|
|
200 |
doesNotUnderstand:aMessage
|
|
201 |
(field respondsTo:aMessage selector) ifTrue:[
|
|
202 |
^ aMessage sendTo:field
|
|
203 |
].
|
|
204 |
^ super doesNotUnderstand:aMessage
|
|
205 |
|
|
206 |
"Created: 28.2.1996 / 15:03:17 / cg"
|
|
207 |
"Modified: 28.2.1996 / 15:06:09 / cg"
|
166
|
208 |
!
|
|
209 |
|
|
210 |
respondsTo:aSymbol
|
|
211 |
^ (field respondsTo:aSymbol) or:[super respondsTo:aSymbol]
|
|
212 |
|
|
213 |
"Created: 2.5.1996 / 16:57:34 / stefan"
|
129
|
214 |
! !
|
|
215 |
|
214
|
216 |
!ComboView methodsFor:'private'!
|
|
217 |
|
|
218 |
getListFromModel
|
|
219 |
model notNil ifTrue:[
|
|
220 |
(model respondsTo:#list) ifTrue:[
|
|
221 |
self list:(model list)
|
|
222 |
]
|
|
223 |
].
|
|
224 |
|
|
225 |
"Created: 15.7.1996 / 12:22:56 / cg"
|
|
226 |
"Modified: 15.7.1996 / 12:24:58 / cg"
|
|
227 |
!
|
|
228 |
|
|
229 |
getValueFromModel
|
|
230 |
|
|
231 |
"Modified: 15.7.1996 / 12:28:59 / cg"
|
|
232 |
! !
|
|
233 |
|
129
|
234 |
!ComboView methodsFor:'queries'!
|
|
235 |
|
|
236 |
preferredExtent
|
|
237 |
|pref1 pref2 m mPrefX|
|
|
238 |
|
|
239 |
list isNil ifTrue:[
|
|
240 |
mPrefX := 0
|
|
241 |
] ifFalse:[
|
|
242 |
m := MenuView labels:list.
|
|
243 |
mPrefX := m preferredExtent x.
|
|
244 |
].
|
|
245 |
|
|
246 |
pref1 := field preferredExtent.
|
|
247 |
pref2 := pullDownButton preferredExtent.
|
|
248 |
^ ((pref1 x + pref2 x) max:mPrefX) @ (pref1 y max:pref2 y)
|
|
249 |
|
|
250 |
"Created: 28.2.1996 / 15:03:17 / cg"
|
|
251 |
"Modified: 28.2.1996 / 15:06:15 / cg"
|
|
252 |
! !
|
|
253 |
|
|
254 |
!ComboView methodsFor:'user interaction'!
|
|
255 |
|
|
256 |
entryChanged:what
|
|
257 |
field contents:what.
|
|
258 |
field accept.
|
|
259 |
pullDownButton turnOff.
|
|
260 |
|
|
261 |
"Created: 28.2.1996 / 15:03:17 / cg"
|
|
262 |
"Modified: 28.2.1996 / 15:06:24 / cg"
|
|
263 |
!
|
|
264 |
|
|
265 |
pullMenu
|
|
266 |
|m org|
|
|
267 |
|
214
|
268 |
self getListFromModel.
|
129
|
269 |
(list notNil and:[list notEmpty]) ifTrue:[
|
|
270 |
m := PopUpMenu
|
|
271 |
labels:list
|
|
272 |
selectors:#entryChanged:
|
|
273 |
args:list
|
|
274 |
receiver:self.
|
|
275 |
|
|
276 |
m menuView resize.
|
|
277 |
m menuView width:(self width).
|
|
278 |
m menuView sizeFixed:true.
|
|
279 |
m hideOnRelease:false.
|
|
280 |
|
|
281 |
org := device translatePoint:(0 @ self height)
|
|
282 |
from:(self id)
|
|
283 |
to:(device rootView id).
|
|
284 |
|
|
285 |
m showAt:org.
|
|
286 |
].
|
|
287 |
|
|
288 |
pullDownButton turnOff.
|
|
289 |
|
|
290 |
"Created: 28.2.1996 / 15:03:18 / cg"
|
214
|
291 |
"Modified: 15.7.1996 / 12:23:06 / cg"
|
129
|
292 |
! !
|
|
293 |
|
214
|
294 |
!ComboView class methodsFor:'documentation'!
|
129
|
295 |
|
|
296 |
version
|
217
|
297 |
^ '$Header: /cvs/stx/stx/libwidg2/ComboView.st,v 1.6 1996-07-17 12:22:32 cg Exp $'
|
129
|
298 |
! !
|