author | Claus Gittinger <cg@exept.de> |
Sun, 26 Sep 1999 13:36:16 +0200 | |
changeset 1560 | 8abb4de4f8f5 |
parent 1544 | d8290e5a0b05 |
child 1622 | ea4d9baf568f |
permissions | -rw-r--r-- |
1301
93a3ec8c339c
OOPS - stefan what happened to your checkin (garbage)
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
1 |
" |
332 | 2 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
14 |
||
129 | 15 |
View subclass:#ComboView |
1306
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
16 |
instanceVariableNames:'field pullDownButton list listHolder listMsg action' |
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
17 |
classVariableNames:'DefaultButtonForm' |
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
18 |
poolDictionaries:'' |
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
19 |
category:'Views-Interactors' |
129 | 20 |
! |
21 |
||
263
865b7d99d3f5
added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
22 |
!ComboView class methodsFor:'documentation'! |
129 | 23 |
|
332 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
37 |
||
38 |
! |
|
39 |
||
129 | 40 |
documentation |
41 |
" |
|
42 |
A ComboView combines some field (typically an enterField or Label) |
|
43 |
with a drop down list of default inputs; |
|
44 |
ComboView is abstract, providing protocol common to ComboBoxView and |
|
45 |
ComboListView. See documentation & examples there. |
|
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
46 |
|
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
47 |
[author:] |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
48 |
Claus Gittinger |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
49 |
|
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
50 |
[see also:] |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
51 |
PopUpList |
1281 | 52 |
ComboListView ComboBoxView ExtendedComboBox |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
53 |
PullDownMenu Label EntryField |
129 | 54 |
" |
55 |
! |
|
56 |
||
57 |
examples |
|
58 |
" |
|
308 | 59 |
see examples in ComboListView and ComboBoxView |
129 | 60 |
" |
61 |
! ! |
|
62 |
||
263
865b7d99d3f5
added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
63 |
!ComboView class methodsFor:'defaults'! |
129 | 64 |
|
65 |
buttonForm |
|
282 | 66 |
"return the pull-buttons image" |
67 |
||
1344
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
68 |
<resource: #style (#'comboView.downForm' |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
69 |
#'comboView.downFormFile')> |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
70 |
|
276
8f90ed6c37bc
allow either fileName or form to be given by styleSheet
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
71 |
|fileName form| |
129 | 72 |
|
525 | 73 |
DefaultButtonForm notNil ifTrue:[ |
74 |
^ DefaultButtonForm |
|
75 |
]. |
|
76 |
||
1334 | 77 |
form := StyleSheet at:#'comboView.downForm'. |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
78 |
form isNil ifTrue:[ |
1334 | 79 |
fileName := StyleSheet at:#'comboView.downFormFile' "default:'ComboDn.14.xbm'". |
605 | 80 |
fileName notNil ifTrue:[form := Image fromFile:fileName]. |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
81 |
]. |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
82 |
form isNil ifTrue:[ |
605 | 83 |
form := Form width:12 height:12 |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
84 |
fromArray:#[2r00000000 2r00000000 |
605 | 85 |
"/ 2r00001111 2r00000000 |
86 |
"/ 2r00001111 2r00000000 |
|
87 |
2r00001111 2r00000000 |
|
88 |
2r00001111 2r00000000 |
|
89 |
2r00001111 2r00000000 |
|
90 |
2r01111111 2r11100000 |
|
91 |
2r00111111 2r11000000 |
|
92 |
2r00011111 2r10000000 |
|
93 |
2r00001111 2r00000000 |
|
94 |
2r00000110 2r00000000 |
|
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
95 |
2r00000000 2r00000000 |
605 | 96 |
2r01111111 2r11100000 |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
97 |
2r00000000 2r00000000] |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
98 |
on:Display. |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
99 |
]. |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
100 |
form notNil ifTrue:[ |
525 | 101 |
form := DefaultButtonForm := form onDevice:Display. |
102 |
^ form |
|
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
103 |
]. |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
104 |
^ nil |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
105 |
|
1344
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
106 |
"Modified: / 28.4.1999 / 12:49:42 / cg" |
304 | 107 |
! |
108 |
||
415 | 109 |
defaultFont |
110 |
"/ for now - should come from the styleSheet |
|
111 |
||
112 |
^ SelectionInListView defaultFont. |
|
113 |
||
114 |
"Created: 4.6.1997 / 15:44:17 / cg" |
|
115 |
! |
|
116 |
||
304 | 117 |
defaultListMessage |
118 |
^ #list |
|
119 |
||
120 |
"Created: 26.2.1997 / 19:34:50 / cg" |
|
605 | 121 |
! |
122 |
||
123 |
updateStyleCache |
|
124 |
DefaultButtonForm := nil |
|
125 |
||
126 |
"Created: / 3.11.1997 / 15:28:48 / cg" |
|
304 | 127 |
! ! |
128 |
||
129 |
!ComboView methodsFor:'accessing-behavior'! |
|
130 |
||
131 |
action:aBlock |
|
132 |
"specify, a block, which is evaluated when the lists selection changes. |
|
133 |
This is an additional hook - normally, you would communicate with the model |
|
134 |
alone" |
|
135 |
||
136 |
action := aBlock. |
|
137 |
||
138 |
"Created: 26.7.1996 / 17:44:18 / cg" |
|
139 |
"Modified: 26.2.1997 / 19:37:18 / cg" |
|
411 | 140 |
! |
141 |
||
142 |
enabled |
|
143 |
"return true, if is enabled |
|
144 |
" |
|
1207 | 145 |
enableChannel isNil ifTrue:[^ true]. |
1294 | 146 |
^ enableChannel value |
147 |
! |
|
148 |
||
149 |
enabled:aBoolean |
|
150 |
"enable/disable components" |
|
151 |
||
152 |
self enableChannel value:aBoolean. |
|
153 |
||
154 |
"Modified: / 30.3.1999 / 14:56:18 / stefan" |
|
411 | 155 |
! ! |
156 |
||
157 |
!ComboView methodsFor:'accessing-channels'! |
|
158 |
||
159 |
enableChannel |
|
160 |
"return a valueHolder for enable/disable |
|
161 |
" |
|
1207 | 162 |
enableChannel isNil ifTrue:[ |
1294 | 163 |
self enableChannel:(true asValue). |
411 | 164 |
]. |
1207 | 165 |
^ enableChannel |
411 | 166 |
|
1294 | 167 |
"Modified: / 30.3.1999 / 16:20:25 / stefan" |
129 | 168 |
! ! |
169 |
||
170 |
!ComboView methodsFor:'accessing-components'! |
|
171 |
||
1560 | 172 |
field |
173 |
"return the field (input or label) component. |
|
174 |
For knowledgable users only." |
|
175 |
||
176 |
^ field |
|
177 |
||
178 |
"Created: / 26.9.1999 / 13:33:15 / cg" |
|
179 |
! |
|
180 |
||
129 | 181 |
menuButton |
182 |
"return the menuButton component" |
|
183 |
||
184 |
^ pullDownButton |
|
185 |
||
186 |
"Created: 28.2.1996 / 15:03:14 / cg" |
|
187 |
! ! |
|
188 |
||
189 |
!ComboView methodsFor:'accessing-contents'! |
|
190 |
||
181 | 191 |
contents |
304 | 192 |
"get the contents of my field" |
193 |
||
181 | 194 |
^ field model value |
195 |
||
196 |
"Created: 14.5.1996 / 13:05:16 / cg" |
|
304 | 197 |
"Modified: 26.2.1997 / 16:55:43 / cg" |
181 | 198 |
! |
199 |
||
200 |
contents:something |
|
304 | 201 |
"set the contents of my field; questionable" |
202 |
||
214 | 203 |
|m| |
204 |
||
205 |
(m := field model) notNil ifTrue:[ |
|
304 | 206 |
m value:something |
214 | 207 |
] |
181 | 208 |
|
209 |
"Created: 14.5.1996 / 13:05:33 / cg" |
|
304 | 210 |
"Modified: 26.2.1997 / 16:56:08 / cg" |
181 | 211 |
! |
212 |
||
889
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
213 |
list |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
214 |
"return the list" |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
215 |
|
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
216 |
^ list |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
217 |
|
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
218 |
"Created: / 18.5.1998 / 18:58:08 / cg" |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
219 |
! |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
220 |
|
129 | 221 |
list:aList |
304 | 222 |
"set the list explicitely; used internally or |
223 |
to be send from the outside if no model/listHolder is used." |
|
224 |
||
129 | 225 |
list := aList. |
1306
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
226 |
self enableStateChanged. |
1294 | 227 |
|
228 |
"Modified: / 30.3.1999 / 14:17:38 / stefan" |
|
129 | 229 |
! ! |
230 |
||
853 | 231 |
!ComboView methodsFor:'accessing-look'! |
232 |
||
233 |
backgroundColor |
|
234 |
||
235 |
^field backgroundColor |
|
236 |
! |
|
237 |
||
238 |
backgroundColor:aColor |
|
239 |
||
240 |
field backgroundColor:aColor |
|
241 |
! |
|
242 |
||
243 |
font:aFont |
|
244 |
||
245 |
super font:aFont. |
|
1183
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
1126
diff
changeset
|
246 |
self setFieldsFont:aFont. |
853 | 247 |
! |
248 |
||
249 |
foregroundColor |
|
250 |
||
251 |
^field foregroundColor |
|
252 |
! |
|
253 |
||
254 |
foregroundColor:aColor |
|
255 |
||
256 |
field foregroundColor:aColor |
|
257 |
! ! |
|
258 |
||
214 | 259 |
!ComboView methodsFor:'accessing-mvc'! |
260 |
||
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
261 |
listHolder:aValueHolder |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
262 |
"set the listHolder. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
263 |
If not set, the list is supposed to be set explicitely" |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
264 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
265 |
listHolder notNil ifTrue:[ |
304 | 266 |
listHolder removeDependent:self. |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
267 |
]. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
268 |
listHolder := aValueHolder. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
269 |
listHolder notNil ifTrue:[ |
304 | 270 |
aValueHolder addDependent:self. |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
271 |
]. |
304 | 272 |
realized ifTrue:[ |
273 |
self getListFromModel. |
|
274 |
] |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
275 |
|
304 | 276 |
"Modified: 26.2.1997 / 19:32:09 / cg" |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
277 |
! |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
278 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
279 |
listMessage:aSymbol |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
280 |
"define the message selector sent to the model, to fetch |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
281 |
the list. If not defined, #list is used" |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
282 |
|
304 | 283 |
listMsg := aSymbol |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
284 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
285 |
"Created: 14.2.1997 / 19:16:52 / cg" |
304 | 286 |
"Modified: 26.2.1997 / 19:33:09 / cg" |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
287 |
! |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
288 |
|
214 | 289 |
model:aModel |
304 | 290 |
"set the model, which is supposed to provide the boxes value. |
291 |
If a listMessage was defined, it is also responsible for providing |
|
292 |
the list" |
|
293 |
||
214 | 294 |
super model:aModel. |
295 |
||
314
6ff49c930c71
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
312
diff
changeset
|
296 |
self getListFromModel. |
6ff49c930c71
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
312
diff
changeset
|
297 |
self getValueFromModel. |
304 | 298 |
|
314
6ff49c930c71
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
312
diff
changeset
|
299 |
"Modified: 28.2.1997 / 19:08:45 / cg" |
310 | 300 |
! ! |
301 |
||
302 |
!ComboView methodsFor:'change & update'! |
|
214 | 303 |
|
304 |
update:something with:aParameter from:changedObject |
|
1207 | 305 |
|
214 | 306 |
changedObject == model ifTrue:[ |
310 | 307 |
listHolder isNil ifTrue:[ |
308 |
self getListFromModel. |
|
309 |
]. |
|
310 |
self getValueFromModel. |
|
311 |
^ self |
|
214 | 312 |
]. |
310 | 313 |
changedObject == listHolder ifTrue:[ |
314 |
self getListFromModel. |
|
315 |
^ self |
|
316 |
]. |
|
317 |
||
214 | 318 |
super update:something with:aParameter from:changedObject |
319 |
||
1294 | 320 |
"Created: / 15.7.1996 / 12:26:49 / cg" |
321 |
"Modified: / 28.2.1997 / 13:48:51 / cg" |
|
322 |
"Modified: / 30.3.1999 / 14:17:55 / stefan" |
|
214 | 323 |
! ! |
324 |
||
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
325 |
!ComboView methodsFor:'event handling'! |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
326 |
|
1306
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
327 |
enableStateChanged |
1294 | 328 |
"the enable state has changed - pass this to my field and pullDownButton" |
329 |
||
330 |
|msg| |
|
331 |
||
332 |
(enableChannel isNil or:[enableChannel value]) ifTrue:[ |
|
333 |
msg := #enable |
|
334 |
] ifFalse:[ |
|
335 |
msg := #disable |
|
336 |
]. |
|
337 |
field perform:msg ifNotUnderstood:nil. |
|
338 |
||
339 |
(list size == 0) ifTrue:[ |
|
340 |
msg := #disable |
|
341 |
]. |
|
342 |
pullDownButton perform:msg ifNotUnderstood:nil. |
|
343 |
||
344 |
"Modified: / 22.2.1999 / 00:47:46 / cg" |
|
345 |
"Modified: / 30.3.1999 / 14:17:10 / stefan" |
|
346 |
! |
|
347 |
||
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
348 |
keyPress:key x:x y:y |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
349 |
(key == Character space |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
350 |
or:[key == #Return]) ifTrue:[ |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
351 |
self pullMenu. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
352 |
^ self. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
353 |
]. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
354 |
|
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
355 |
^ super keyPress:key x:x y:y |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
356 |
|
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
357 |
"Modified: / 21.4.1998 / 20:10:05 / cg" |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
358 |
! ! |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
359 |
|
1325 | 360 |
!ComboView methodsFor:'initialize / release'! |
129 | 361 |
|
1207 | 362 |
destroy |
363 |
listHolder notNil ifTrue:[ |
|
364 |
listHolder removeDependent:self. |
|
365 |
listHolder := nil. |
|
366 |
]. |
|
367 |
super destroy |
|
368 |
||
369 |
||
370 |
! |
|
371 |
||
129 | 372 |
initialize |
331 | 373 |
|prefExt leftInset rightInset prefWidth halfSpacing l| |
129 | 374 |
|
375 |
super initialize. |
|
308 | 376 |
|
304 | 377 |
listMsg := self class defaultListMessage. |
378 |
aspectMsg := self class defaultAspectMessage. |
|
379 |
changeMsg := self class defaultChangeMessage. |
|
129 | 380 |
|
381 |
self initializeField. |
|
431 | 382 |
field origin:0@0 corner:1.0@1.0. |
129 | 383 |
|
331 | 384 |
self initializeButton. |
280 | 385 |
prefExt := pullDownButton preferredExtent. |
386 |
prefWidth := prefExt x. |
|
387 |
||
129 | 388 |
pullDownButton origin:1.0@0.0 corner:1.0@1.0. |
217 | 389 |
styleSheet is3D ifTrue:[ |
280 | 390 |
halfSpacing := ViewSpacing // 2. |
391 |
leftInset := rightInset := prefWidth + halfSpacing. |
|
1334 | 392 |
(l := styleSheet at:#'comboView.level' default:nil) notNil ifTrue:[ |
331 | 393 |
self level:l. |
319 | 394 |
field level:0. |
395 |
field rightInset:margin. |
|
396 |
] ifFalse:[ |
|
397 |
pullDownButton rightInset:halfSpacing. |
|
398 |
field leftInset:halfSpacing |
|
399 |
]. |
|
217 | 400 |
] ifFalse:[ |
280 | 401 |
leftInset := prefWidth + pullDownButton borderWidth. |
402 |
rightInset := prefWidth. |
|
217 | 403 |
]. |
1125 | 404 |
|
405 |
(styleSheet name = #win95 |
|
406 |
or:[styleSheet name = #st80]) ifTrue:[ |
|
407 |
field level:0. |
|
408 |
self level:-1. |
|
409 |
pullDownButton rightInset:0. |
|
410 |
styleSheet name = #win95 ifTrue:[ |
|
411 |
leftInset := (ArrowButton new preferredExtent x). |
|
1126 | 412 |
rightInset := leftInset. |
1125 | 413 |
]. |
414 |
field origin:0.0@0.0. |
|
415 |
field leftInset:0 |
|
416 |
"/ field topInset:1; bottomInset:1. |
|
417 |
]. |
|
1126 | 418 |
field rightInset:rightInset. |
280 | 419 |
pullDownButton leftInset:leftInset negated. |
129 | 420 |
|
247 | 421 |
self initialHeight:field preferredExtent y + ViewSpacing. |
129 | 422 |
|
423 |
" |
|
424 |
|b| |
|
425 |
||
426 |
b := ComboBoxView new. |
|
427 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
428 |
b open |
|
429 |
" |
|
430 |
||
1125 | 431 |
"Created: / 28.2.1996 / 15:03:17 / cg" |
432 |
"Modified: / 8.9.1998 / 20:33:22 / cg" |
|
331 | 433 |
! |
434 |
||
435 |
initializeButton |
|
1344
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
436 |
<resource: #style (#'comboView.disabledDownForm' |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
437 |
#'comboView.disabledDownFormFile')> |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
438 |
|
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
439 |
|l1 l2| |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
440 |
|
512
97beb6e8acbe
ST-80 compatible ComboBoxButton
Claus Gittinger <cg@exept.de>
parents:
437
diff
changeset
|
441 |
pullDownButton := ComboBoxButton in:self. |
331 | 442 |
pullDownButton controller beTriggerOnDown. |
1344
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
443 |
pullDownButton logo:(l1 := self class buttonForm). |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
444 |
|
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
445 |
l2 := styleSheet at:#'comboView.disabledDownFormFile'. |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
446 |
l2 notNil ifTrue:[ |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
447 |
l2 := Image fromFile:l2. |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
448 |
] ifFalse:[ |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
449 |
l2 := styleSheet at:#'comboView.disabledDownForm'. |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
450 |
]. |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
451 |
l2 notNil ifTrue:[ |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
452 |
pullDownButton passiveLogo:l1. |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
453 |
pullDownButton activeLogo:l1. |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
454 |
pullDownButton disabledLogo:l2. |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
455 |
]. |
331 | 456 |
pullDownButton showLamp:false. |
457 |
pullDownButton activeLevel == pullDownButton passiveLevel ifTrue:[ |
|
458 |
pullDownButton activeLevel:0. |
|
459 |
]. |
|
460 |
pullDownButton disable. |
|
461 |
pullDownButton pressAction:[self pullMenu]. |
|
462 |
||
1344
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
463 |
"Modified: / 28.4.1999 / 13:09:42 / cg" |
331 | 464 |
! |
465 |
||
466 |
initializeField |
|
467 |
self subclassResponsibility |
|
468 |
||
469 |
"Created: 29.3.1997 / 11:17:14 / cg" |
|
129 | 470 |
! ! |
471 |
||
472 |
!ComboView methodsFor:'message delegation'! |
|
473 |
||
474 |
doesNotUnderstand:aMessage |
|
475 |
(field respondsTo:aMessage selector) ifTrue:[ |
|
1207 | 476 |
^ aMessage sendTo:field |
129 | 477 |
]. |
478 |
^ super doesNotUnderstand:aMessage |
|
479 |
||
480 |
"Created: 28.2.1996 / 15:03:17 / cg" |
|
481 |
"Modified: 28.2.1996 / 15:06:09 / cg" |
|
166 | 482 |
! |
483 |
||
484 |
respondsTo:aSymbol |
|
485 |
^ (field respondsTo:aSymbol) or:[super respondsTo:aSymbol] |
|
486 |
||
487 |
"Created: 2.5.1996 / 16:57:34 / stefan" |
|
129 | 488 |
! ! |
489 |
||
214 | 490 |
!ComboView methodsFor:'private'! |
491 |
||
492 |
getListFromModel |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
493 |
"fetch the list - either from the listHolder, or |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
494 |
from the model. If no listMessage was defined, fetch it |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
495 |
using #list." |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
496 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
497 |
listHolder notNil ifTrue:[ |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
498 |
self list:listHolder value |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
499 |
] ifFalse:[ |
304 | 500 |
(model notNil and:[listMsg notNil]) ifTrue:[ |
501 |
(model respondsTo:listMsg) ifTrue:[ |
|
502 |
self list:(model perform:listMsg) |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
503 |
] |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
504 |
] |
214 | 505 |
]. |
506 |
||
507 |
"Created: 15.7.1996 / 12:22:56 / cg" |
|
304 | 508 |
"Modified: 26.2.1997 / 19:40:58 / cg" |
214 | 509 |
! |
510 |
||
511 |
getValueFromModel |
|
512 |
||
513 |
"Modified: 15.7.1996 / 12:28:59 / cg" |
|
1183
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
1126
diff
changeset
|
514 |
! |
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
1126
diff
changeset
|
515 |
|
1210
55f2c4209f94
oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
516 |
setFieldsFont:aFont |
55f2c4209f94
oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
517 |
field font:aFont. |
214 | 518 |
! ! |
519 |
||
129 | 520 |
!ComboView methodsFor:'queries'! |
521 |
||
522 |
preferredExtent |
|
285 | 523 |
"compute & return the boxes preferredExtent from the components' preferrences" |
524 |
||
683 | 525 |
|fieldPref buttonPref m menuPrefX menuPrefY w h| |
129 | 526 |
|
312 | 527 |
"/ If I have an explicit preferredExtent .. |
528 |
||
529 |
preferredExtent notNil ifTrue:[ |
|
530 |
^ preferredExtent |
|
531 |
]. |
|
532 |
||
129 | 533 |
list isNil ifTrue:[ |
308 | 534 |
self getListFromModel |
535 |
]. |
|
536 |
||
537 |
list isNil ifTrue:[ |
|
683 | 538 |
menuPrefX := menuPrefY := 0 |
129 | 539 |
] ifFalse:[ |
1544 | 540 |
m := (MenuView onDevice:device ? Screen current) labels:list. |
302
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
541 |
menuPrefX := m preferredExtent x. |
1348 | 542 |
|
543 |
"/ the menuView returns rubbish ... |
|
544 |
"/ menuPrefY := (m preferredExtentForLines:1 cols:10) y |
|
545 |
||
546 |
"/ any non-strings ? |
|
547 |
menuPrefY := list |
|
548 |
inject:('X' heightOn:self) |
|
549 |
into:[:max :el | el isString ifTrue:[ |
|
550 |
max |
|
551 |
] ifFalse:[ |
|
552 |
max max:(el heightOn:self) |
|
553 |
] |
|
554 |
]. |
|
129 | 555 |
]. |
556 |
||
302
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
557 |
fieldPref := field preferredExtent. |
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
558 |
buttonPref := pullDownButton preferredExtent. |
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
559 |
|
319 | 560 |
w := ((fieldPref x max:menuPrefX) max:50) + buttonPref x. |
561 |
w := w + margin + margin. |
|
683 | 562 |
h := (fieldPref y max:buttonPref y) max:menuPrefY. |
319 | 563 |
h := h + margin + margin. |
564 |
^ w @ h |
|
129 | 565 |
|
1348 | 566 |
"Created: / 28.2.1996 / 15:03:17 / cg" |
567 |
"Modified: / 29.4.1999 / 11:27:54 / cg" |
|
129 | 568 |
! ! |
569 |
||
570 |
!ComboView methodsFor:'user interaction'! |
|
571 |
||
572 |
pullMenu |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
573 |
"pull the menu - triggered from the button" |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
574 |
|
129 | 575 |
|m org| |
576 |
||
214 | 577 |
self getListFromModel. |
129 | 578 |
(list notNil and:[list notEmpty]) ifTrue:[ |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
579 |
m := PopUpMenu |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
580 |
labels:list |
308 | 581 |
selectors:#select: |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
582 |
args:(1 to:list size) |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
583 |
receiver:self. |
129 | 584 |
|
411 | 585 |
m font:font. |
586 |
m menuView font:font. |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
587 |
m menuView resize. |
411 | 588 |
m resize. |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
589 |
m menuView width:(self width). |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
590 |
m menuView sizeFixed:true. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
591 |
m hideOnRelease:false. |
411 | 592 |
m resize. |
129 | 593 |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
594 |
org := device translatePoint:(0 @ self height) |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
595 |
from:(self id) |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
596 |
to:(device rootView id). |
129 | 597 |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
598 |
m showAt:org. |
129 | 599 |
]. |
600 |
||
601 |
pullDownButton turnOff. |
|
602 |
||
603 |
"Created: 28.2.1996 / 15:03:18 / cg" |
|
308 | 604 |
"Modified: 27.2.1997 / 15:18:00 / cg" |
605 |
! |
|
606 |
||
607 |
select:anIndex |
|
608 |
"sent from the popped menu, when an item was selected" |
|
609 |
||
610 |
self subclassResponsibility |
|
611 |
||
612 |
"Modified: 27.2.1997 / 15:19:07 / cg" |
|
129 | 613 |
! ! |
614 |
||
263
865b7d99d3f5
added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
615 |
!ComboView class methodsFor:'documentation'! |
129 | 616 |
|
617 |
version |
|
1560 | 618 |
^ '$Header: /cvs/stx/stx/libwidg2/ComboView.st,v 1.56 1999-09-26 11:36:16 cg Exp $' |
129 | 619 |
! ! |