author | Claus Gittinger <cg@exept.de> |
Fri, 19 Jul 2019 10:42:36 +0200 | |
changeset 6088 | 1b000948eeda |
parent 6040 | a3296ee359af |
child 6089 | 22ddbc8a51d7 |
permissions | -rw-r--r-- |
5949 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1301
93a3ec8c339c
OOPS - stefan what happened to your checkin (garbage)
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
3 |
" |
332 | 4 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1884
bf33562ea53b
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
1696
diff
changeset
|
14 |
"{ Package: 'stx:libwidg2' }" |
bf33562ea53b
use rootWindowId (save a message send)
Claus Gittinger <cg@exept.de>
parents:
1696
diff
changeset
|
15 |
|
4824 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
129 | 18 |
View subclass:#ComboView |
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
19 |
instanceVariableNames:'field pullDownButton list listHolder listMsg action resizableMenu |
4187 | 20 |
currentIndex comboMenuHolder comboMenuMessage' |
2950 | 21 |
classVariableNames:'DefaultButtonForm ComboButtonForms' |
1306
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
22 |
poolDictionaries:'' |
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
23 |
category:'Views-Interactors' |
129 | 24 |
! |
25 |
||
263
865b7d99d3f5
added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
26 |
!ComboView class methodsFor:'documentation'! |
129 | 27 |
|
332 | 28 |
copyright |
29 |
" |
|
30 |
COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger |
|
31 |
All Rights Reserved |
|
32 |
||
33 |
This software is furnished under a license and may be used |
|
34 |
only in accordance with the terms of that license and with the |
|
35 |
inclusion of the above copyright notice. This software may not |
|
36 |
be provided or otherwise made available to, or used by, any |
|
37 |
other person. No title to or ownership of the software is |
|
38 |
hereby transferred. |
|
39 |
" |
|
40 |
||
41 |
||
42 |
! |
|
43 |
||
129 | 44 |
documentation |
45 |
" |
|
46 |
A ComboView combines some field (typically an enterField or Label) |
|
47 |
with a drop down list of default inputs; |
|
48 |
ComboView is abstract, providing protocol common to ComboBoxView and |
|
49 |
ComboListView. See documentation & examples there. |
|
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
50 |
|
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
51 |
[author:] |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
52 |
Claus Gittinger |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
53 |
|
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
54 |
[instance variables:] |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
55 |
currentIndex Integer index into the list, that is currently selected |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
56 |
|
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
57 |
[see also:] |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
58 |
PopUpList |
1281 | 59 |
ComboListView ComboBoxView ExtendedComboBox |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
60 |
PullDownMenu Label EntryField |
129 | 61 |
" |
62 |
! |
|
63 |
||
64 |
examples |
|
65 |
" |
|
308 | 66 |
see examples in ComboListView and ComboBoxView |
129 | 67 |
" |
68 |
! ! |
|
69 |
||
263
865b7d99d3f5
added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
70 |
!ComboView class methodsFor:'defaults'! |
129 | 71 |
|
5889 | 72 |
activeForm |
73 |
<resource: #style (#'comboView.activeDownForm' |
|
74 |
#'comboView.activeDownFormFile')> |
|
75 |
||
76 |
^ self formForKey:#activeLogo styleFormKey:#'comboView.activeDownForm' styleFilenameKey:#'comboView.activeDownFormFile' |
|
77 |
||
78 |
"Created: / 17-08-2018 / 17:21:52 / Claus Gittinger" |
|
79 |
! |
|
80 |
||
129 | 81 |
buttonForm |
282 | 82 |
"return the pull-buttons image" |
83 |
||
1344
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
84 |
<resource: #style (#'comboView.downForm' |
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
85 |
#'comboView.downFormFile')> |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
86 |
|
276
8f90ed6c37bc
allow either fileName or form to be given by styleSheet
Claus Gittinger <cg@exept.de>
parents:
274
diff
changeset
|
87 |
|fileName form| |
129 | 88 |
|
525 | 89 |
DefaultButtonForm notNil ifTrue:[ |
90 |
^ DefaultButtonForm |
|
91 |
]. |
|
92 |
||
1334 | 93 |
form := StyleSheet at:#'comboView.downForm'. |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
94 |
form isNil ifTrue:[ |
1334 | 95 |
fileName := StyleSheet at:#'comboView.downFormFile' "default:'ComboDn.14.xbm'". |
1622
ea4d9baf568f
try bitmaps in package directory
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
96 |
fileName notNil ifTrue:[ |
1633 | 97 |
form := Smalltalk imageFromFileNamed:fileName forClass:self. |
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
98 |
form isNil ifTrue:[ |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
99 |
form := Smalltalk imageFromFileNamed:fileName inPackage:'stx:libwidg'. |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
100 |
] |
1622
ea4d9baf568f
try bitmaps in package directory
Claus Gittinger <cg@exept.de>
parents:
1560
diff
changeset
|
101 |
]. |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
102 |
]. |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
103 |
form isNil ifTrue:[ |
5383 | 104 |
form := self defaultButtonForm. |
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
105 |
]. |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
106 |
form notNil ifTrue:[ |
525 | 107 |
form := DefaultButtonForm := form onDevice:Display. |
108 |
^ form |
|
274
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
109 |
]. |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
110 |
^ nil |
92b51554b1d7
allow form to be specified by styleSheet
Claus Gittinger <cg@exept.de>
parents:
269
diff
changeset
|
111 |
|
1344
100e4d309847
support for disabled-image in pull-button
Claus Gittinger <cg@exept.de>
parents:
1334
diff
changeset
|
112 |
"Modified: / 28.4.1999 / 12:49:42 / cg" |
304 | 113 |
! |
114 |
||
3839
d269a10c33c9
comment/format in: #comboButtonFor:
Claus Gittinger <cg@exept.de>
parents:
3836
diff
changeset
|
115 |
comboButtonFor:aComboView |
5889 | 116 |
<resource: #style (#'comboView.button.activeForegroundColor' |
2176 | 117 |
#'comboView.button.activeBackgroundColor' |
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
118 |
#'comboView.button.activeLevel' |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
119 |
#'comboView.button.passiveLevel' )> |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
120 |
|
5889 | 121 |
|pullDownButton logo disabledLogo activeLogo enteredLogo lvl clr| |
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
122 |
|
3839
d269a10c33c9
comment/format in: #comboButtonFor:
Claus Gittinger <cg@exept.de>
parents:
3836
diff
changeset
|
123 |
pullDownButton := ComboBoxButton in:aComboView. |
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
124 |
pullDownButton controller beTriggerOnDown. |
2785
3c705bdd5792
Do not use obsolete message #logo:
Stefan Vogel <sv@exept.de>
parents:
2750
diff
changeset
|
125 |
pullDownButton label:(logo := self buttonForm). |
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
126 |
|
2950 | 127 |
ComboButtonForms isNil ifTrue:[ |
128 |
ComboButtonForms := IdentityDictionary new. |
|
129 |
]. |
|
130 |
||
5889 | 131 |
disabledLogo := self disabledForm. |
132 |
activeLogo := self activeForm. |
|
133 |
enteredLogo := self enteredForm. |
|
2950 | 134 |
|
2176 | 135 |
disabledLogo notNil ifTrue:[ |
136 |
pullDownButton passiveLogo:logo. |
|
137 |
pullDownButton activeLogo:logo. |
|
138 |
pullDownButton disabledLogo:disabledLogo. |
|
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
139 |
]. |
2950 | 140 |
|
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
141 |
pullDownButton showLamp:false. |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
142 |
|
2176 | 143 |
activeLogo notNil ifTrue:[ |
144 |
pullDownButton activeLogo:activeLogo. |
|
145 |
pullDownButton passiveLogo:logo. |
|
2785
3c705bdd5792
Do not use obsolete message #logo:
Stefan Vogel <sv@exept.de>
parents:
2750
diff
changeset
|
146 |
pullDownButton label:logo. |
2176 | 147 |
]. |
148 |
||
149 |
enteredLogo notNil ifTrue:[ |
|
150 |
pullDownButton enteredLogo:enteredLogo. |
|
151 |
]. |
|
152 |
||
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
153 |
(lvl := StyleSheet at:#'comboView.button.activeLevel') notNil ifTrue:[ |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
154 |
pullDownButton activeLevel:lvl |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
155 |
]. |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
156 |
(lvl := StyleSheet at:#'comboView.button.passiveLevel') notNil ifTrue:[ |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
157 |
pullDownButton passiveLevel:lvl |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
158 |
]. |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
159 |
|
2176 | 160 |
(clr := StyleSheet colorAt:#'comboView.button.activeForegroundColor') notNil ifTrue:[ |
161 |
pullDownButton activeForegroundColor:clr |
|
162 |
]. |
|
163 |
(clr := StyleSheet colorAt:#'comboView.button.activeBackgroundColor') notNil ifTrue:[ |
|
164 |
pullDownButton activeBackgroundColor:clr |
|
165 |
]. |
|
166 |
||
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
167 |
pullDownButton activeLevel == pullDownButton passiveLevel ifTrue:[ |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
168 |
pullDownButton activeLevel:0. |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
169 |
]. |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
170 |
^ pullDownButton. |
5889 | 171 |
|
172 |
"Modified: / 17-08-2018 / 17:23:38 / Claus Gittinger" |
|
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
173 |
! |
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
174 |
|
415 | 175 |
defaultFont |
176 |
"/ for now - should come from the styleSheet |
|
177 |
||
4567 | 178 |
^ EditField defaultFont. |
179 |
"/ ^ SelectionInListView defaultFont. |
|
415 | 180 |
|
181 |
"Created: 4.6.1997 / 15:44:17 / cg" |
|
182 |
! |
|
183 |
||
304 | 184 |
defaultListMessage |
185 |
^ #list |
|
186 |
||
187 |
"Created: 26.2.1997 / 19:34:50 / cg" |
|
605 | 188 |
! |
189 |
||
5889 | 190 |
disabledForm |
191 |
<resource: #style (#'comboView.disabledDownForm' |
|
192 |
#'comboView.disabledDownFormFile')> |
|
193 |
||
194 |
^ self formForKey:#disabledLogo styleFormKey:#'comboView.disabledDownForm' styleFilenameKey:#'comboView.disabledDownFormFile' |
|
195 |
||
196 |
"Created: / 17-08-2018 / 17:20:34 / Claus Gittinger" |
|
197 |
! |
|
198 |
||
199 |
enteredForm |
|
200 |
<resource: #style (#'comboView.enteredDownForm' |
|
201 |
#'comboView.enteredDownFormFile')> |
|
202 |
||
203 |
^ self formForKey:#enteredLogo styleFormKey:#'comboView.enteredDownForm' styleFilenameKey:#'comboView.enteredDownFormFile' |
|
204 |
||
205 |
"Created: / 17-08-2018 / 17:22:43 / Claus Gittinger" |
|
206 |
! |
|
207 |
||
605 | 208 |
updateStyleCache |
3842 | 209 |
"flush the forms cache" |
210 |
||
2950 | 211 |
DefaultButtonForm := ComboButtonForms := nil. |
605 | 212 |
|
213 |
"Created: / 3.11.1997 / 15:28:48 / cg" |
|
304 | 214 |
! ! |
215 |
||
5383 | 216 |
!ComboView class methodsFor:'image specs'! |
217 |
||
218 |
defaultButtonForm |
|
219 |
"This resource specification was automatically generated |
|
220 |
by the ImageEditor of ST/X." |
|
221 |
||
222 |
"Do not manually edit this!! If it is corrupted, |
|
223 |
the ImageEditor may not be able to read the specification." |
|
224 |
||
225 |
" |
|
226 |
self defaultButtonForm inspect |
|
227 |
ImageEditor openOnClass:self andSelector:#defaultButtonForm |
|
228 |
Icon flushCachedIcons |
|
229 |
" |
|
230 |
||
231 |
<resource: #image> |
|
232 |
||
233 |
^Icon |
|
234 |
constantNamed:'ComboView class defaultButtonForm' |
|
235 |
ifAbsentPut:[(Depth1Image width:12 height:12) bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@') |
|
236 |
colorMapFromArray:#[0 0 0] |
|
237 |
mask:((ImageMask width:12 height:12) bits:(ByteArray fromPackedString:'@@<OC0<OC0=?;3?OG8<OC0XO@@=?;0@O'); yourself); yourself] |
|
238 |
! ! |
|
239 |
||
5889 | 240 |
!ComboView class methodsFor:'private'! |
241 |
||
242 |
formForKey:key styleFormKey:styleFormKey styleFilenameKey:styleFilenameKey |
|
243 |
ComboButtonForms isNil ifTrue:[ |
|
244 |
ComboButtonForms := IdentityDictionary new. |
|
245 |
]. |
|
246 |
||
247 |
^ ComboButtonForms |
|
248 |
at:key |
|
249 |
ifAbsentPut:[ |
|
250 |
|logo fn| |
|
251 |
logo := StyleSheet at:styleFormKey. |
|
252 |
logo isNil ifTrue:[ |
|
253 |
fn := StyleSheet at:styleFilenameKey. |
|
254 |
fn notNil ifTrue:[ |
|
255 |
logo := Smalltalk imageFromFileNamed:fn forClass:self. |
|
256 |
logo isNil ifTrue:[ |
|
257 |
logo := Smalltalk imageFromFileNamed:fn inPackage:'stx:libwidg'. |
|
258 |
] |
|
259 |
] |
|
260 |
]. |
|
261 |
logo |
|
262 |
]. |
|
263 |
||
264 |
"Created: / 17-08-2018 / 17:25:10 / Claus Gittinger" |
|
265 |
! ! |
|
266 |
||
4972 | 267 |
!ComboView class methodsFor:'queries'! |
268 |
||
269 |
isAbstract |
|
270 |
"Return if this class is an abstract class. |
|
271 |
True is returned here for myself only; false for subclasses. |
|
272 |
Abstract subclasses must redefine this again." |
|
273 |
||
274 |
^ self == ComboView. |
|
275 |
! ! |
|
276 |
||
304 | 277 |
!ComboView methodsFor:'accessing-behavior'! |
278 |
||
279 |
action:aBlock |
|
280 |
"specify, a block, which is evaluated when the lists selection changes. |
|
281 |
This is an additional hook - normally, you would communicate with the model |
|
282 |
alone" |
|
283 |
||
284 |
action := aBlock. |
|
285 |
||
286 |
"Created: 26.7.1996 / 17:44:18 / cg" |
|
287 |
"Modified: 26.2.1997 / 19:37:18 / cg" |
|
411 | 288 |
! |
289 |
||
290 |
enabled |
|
4663 | 291 |
"return true, if it is enabled" |
2892 | 292 |
|
1207 | 293 |
enableChannel isNil ifTrue:[^ true]. |
4663 | 294 |
^ enableChannel value ? true |
1294 | 295 |
! |
296 |
||
297 |
enabled:aBoolean |
|
298 |
"enable/disable components" |
|
299 |
||
300 |
self enableChannel value:aBoolean. |
|
301 |
||
302 |
"Modified: / 30.3.1999 / 14:56:18 / stefan" |
|
2892 | 303 |
! |
304 |
||
305 |
resizableMenu |
|
306 |
"return true, if the menu is to be resizable. |
|
307 |
This feature is as yet unimplemented." |
|
308 |
||
309 |
^ resizableMenu ? false |
|
310 |
! |
|
311 |
||
312 |
resizableMenu:aBoolean |
|
313 |
"enable/disable, if the menu is to be resizable. |
|
314 |
This feature is as yet unimplemented." |
|
315 |
||
316 |
resizableMenu := aBoolean |
|
411 | 317 |
! ! |
318 |
||
319 |
!ComboView methodsFor:'accessing-channels'! |
|
320 |
||
321 |
enableChannel |
|
2892 | 322 |
"return a valueHolder for enable/disable" |
323 |
||
1207 | 324 |
enableChannel isNil ifTrue:[ |
1294 | 325 |
self enableChannel:(true asValue). |
411 | 326 |
]. |
1207 | 327 |
^ enableChannel |
411 | 328 |
|
1294 | 329 |
"Modified: / 30.3.1999 / 16:20:25 / stefan" |
129 | 330 |
! ! |
331 |
||
332 |
!ComboView methodsFor:'accessing-components'! |
|
333 |
||
1560 | 334 |
field |
335 |
"return the field (input or label) component. |
|
336 |
For knowledgable users only." |
|
337 |
||
338 |
^ field |
|
339 |
||
340 |
"Created: / 26.9.1999 / 13:33:15 / cg" |
|
341 |
! |
|
342 |
||
129 | 343 |
menuButton |
344 |
"return the menuButton component" |
|
345 |
||
346 |
^ pullDownButton |
|
347 |
||
348 |
"Created: 28.2.1996 / 15:03:14 / cg" |
|
349 |
! ! |
|
350 |
||
351 |
!ComboView methodsFor:'accessing-contents'! |
|
352 |
||
181 | 353 |
contents |
304 | 354 |
"get the contents of my field" |
355 |
||
4115 | 356 |
|m| |
181 | 357 |
|
4115 | 358 |
(m := field model) isNil ifTrue:[ |
359 |
^ field contents |
|
360 |
]. |
|
361 |
^ m value |
|
362 |
||
363 |
"Created: / 14-05-1996 / 13:05:16 / cg" |
|
364 |
"Modified: / 21-03-2012 / 12:06:42 / cg" |
|
181 | 365 |
! |
366 |
||
367 |
contents:something |
|
304 | 368 |
"set the contents of my field; questionable" |
369 |
||
214 | 370 |
|m| |
371 |
||
372 |
(m := field model) notNil ifTrue:[ |
|
304 | 373 |
m value:something |
214 | 374 |
] |
181 | 375 |
|
376 |
"Created: 14.5.1996 / 13:05:33 / cg" |
|
304 | 377 |
"Modified: 26.2.1997 / 16:56:08 / cg" |
181 | 378 |
! |
379 |
||
889
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
380 |
list |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
381 |
"return the list" |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
382 |
|
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
383 |
^ list |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
384 |
|
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
385 |
"Created: / 18.5.1998 / 18:58:08 / cg" |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
386 |
! |
7879fffb4810
oops #list returned wrong list
Claus Gittinger <cg@exept.de>
parents:
869
diff
changeset
|
387 |
|
129 | 388 |
list:aList |
304 | 389 |
"set the list explicitely; used internally or |
390 |
to be send from the outside if no model/listHolder is used." |
|
391 |
||
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
392 |
list ~~ aList ifTrue:[ |
6040 | 393 |
self assert:(aList isNil or:[aList isOrdered "isSequenceable"]). |
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
394 |
currentIndex := 1. |
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
395 |
list := aList. |
2474 | 396 |
]. |
3315 | 397 |
"maybe some values have been added to / removed from list" |
398 |
self enableStateChanged. |
|
1294 | 399 |
|
6040 | 400 |
"Modified: / 30-03-1999 / 14:17:38 / stefan" |
401 |
"Modified: / 02-04-2019 / 18:01:15 / Claus Gittinger" |
|
129 | 402 |
! ! |
403 |
||
853 | 404 |
!ComboView methodsFor:'accessing-look'! |
405 |
||
406 |
backgroundColor |
|
407 |
||
408 |
^field backgroundColor |
|
409 |
! |
|
410 |
||
411 |
backgroundColor:aColor |
|
412 |
||
413 |
field backgroundColor:aColor |
|
414 |
! |
|
415 |
||
416 |
font:aFont |
|
417 |
||
418 |
super font:aFont. |
|
1183
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
1126
diff
changeset
|
419 |
self setFieldsFont:aFont. |
853 | 420 |
! |
421 |
||
422 |
foregroundColor |
|
423 |
||
424 |
^field foregroundColor |
|
425 |
! |
|
426 |
||
427 |
foregroundColor:aColor |
|
428 |
||
429 |
field foregroundColor:aColor |
|
430 |
! ! |
|
431 |
||
214 | 432 |
!ComboView methodsFor:'accessing-mvc'! |
433 |
||
4187 | 434 |
comboMenuHolder |
435 |
^ comboMenuHolder |
|
436 |
! |
|
437 |
||
4225 | 438 |
comboMenuHolder:aMenuHolder |
439 |
"allows for arbitrary menus to be opened via the combo button" |
|
440 |
||
441 |
comboMenuHolder := aMenuHolder. |
|
442 |
! |
|
443 |
||
444 |
comboMenuHolder:aMenuHolder comboMenuMessage:aSelectorToTheHolder |
|
445 |
"allows for arbitrary menus to be opened via the combo button" |
|
446 |
||
447 |
comboMenuHolder := aMenuHolder. |
|
448 |
comboMenuMessage := aSelectorToTheHolder. |
|
4187 | 449 |
! |
450 |
||
451 |
comboMenuMessage |
|
452 |
^ comboMenuMessage |
|
453 |
! |
|
454 |
||
4225 | 455 |
comboMenuMessage:aSelectorToTheHolder |
456 |
"allows for arbitrary menus to be opened via the combo button" |
|
457 |
||
458 |
comboMenuMessage := aSelectorToTheHolder. |
|
4187 | 459 |
! |
460 |
||
5592 | 461 |
currentIndex |
462 |
^ currentIndex |
|
463 |
! |
|
464 |
||
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
465 |
listHolder:aValueHolder |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
466 |
"set the listHolder. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
467 |
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
|
468 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
469 |
listHolder notNil ifTrue:[ |
304 | 470 |
listHolder removeDependent:self. |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
471 |
]. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
472 |
listHolder := aValueHolder. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
473 |
listHolder notNil ifTrue:[ |
304 | 474 |
aValueHolder addDependent:self. |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
475 |
]. |
3274
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
476 |
|
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
477 |
"/ cg: either fetch it here or when realized; |
5180 | 478 |
"/ (otherwise we'd never fetch the list if it won't change later) |
3274
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
479 |
"/ realized ifTrue:[ |
304 | 480 |
self getListFromModel. |
3274
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
481 |
"/ ] |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
482 |
|
3274
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
483 |
"Modified: / 09-11-2007 / 15:59:18 / cg" |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
484 |
! |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
485 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
486 |
listMessage:aSymbol |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
487 |
"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
|
488 |
the list. If not defined, #list is used" |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
489 |
|
304 | 490 |
listMsg := aSymbol |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
491 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
492 |
"Created: 14.2.1997 / 19:16:52 / cg" |
304 | 493 |
"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
|
494 |
! |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
495 |
|
214 | 496 |
model:aModel |
304 | 497 |
"set the model, which is supposed to provide the boxes value. |
498 |
If a listMessage was defined, it is also responsible for providing |
|
499 |
the list" |
|
500 |
||
214 | 501 |
super model:aModel. |
502 |
||
3596 | 503 |
listHolder isNil ifTrue:[ |
504 |
self getListFromModel. |
|
505 |
]. |
|
314
6ff49c930c71
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
312
diff
changeset
|
506 |
self getValueFromModel. |
304 | 507 |
|
314
6ff49c930c71
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
312
diff
changeset
|
508 |
"Modified: 28.2.1997 / 19:08:45 / cg" |
310 | 509 |
! ! |
510 |
||
511 |
!ComboView methodsFor:'change & update'! |
|
214 | 512 |
|
513 |
update:something with:aParameter from:changedObject |
|
1207 | 514 |
|
214 | 515 |
changedObject == model ifTrue:[ |
310 | 516 |
listHolder isNil ifTrue:[ |
517 |
self getListFromModel. |
|
518 |
]. |
|
519 |
self getValueFromModel. |
|
520 |
^ self |
|
214 | 521 |
]. |
310 | 522 |
changedObject == listHolder ifTrue:[ |
523 |
self getListFromModel. |
|
524 |
^ self |
|
525 |
]. |
|
526 |
||
214 | 527 |
super update:something with:aParameter from:changedObject |
528 |
||
1294 | 529 |
"Created: / 15.7.1996 / 12:26:49 / cg" |
530 |
"Modified: / 28.2.1997 / 13:48:51 / cg" |
|
531 |
"Modified: / 30.3.1999 / 14:17:55 / stefan" |
|
214 | 532 |
! ! |
533 |
||
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
534 |
!ComboView methodsFor:'event handling'! |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
535 |
|
1306
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
536 |
enableStateChanged |
1294 | 537 |
"the enable state has changed - pass this to my field and pullDownButton" |
538 |
||
539 |
|msg| |
|
540 |
||
6088 | 541 |
(self enabled) ifTrue:[ |
1294 | 542 |
msg := #enable |
543 |
] ifFalse:[ |
|
544 |
msg := #disable |
|
545 |
]. |
|
546 |
field perform:msg ifNotUnderstood:nil. |
|
547 |
||
3755 | 548 |
list isEmptyOrNil ifTrue:[ |
4186 | 549 |
"/ may only do this, if the list is static or a valueModel. |
550 |
"/ If it is a block, we do not know what value will be returned the next |
|
551 |
"/ time. |
|
552 |
listHolder isBlock ifFalse:[ |
|
553 |
msg := #disable |
|
554 |
]. |
|
1294 | 555 |
]. |
556 |
pullDownButton perform:msg ifNotUnderstood:nil. |
|
557 |
||
6088 | 558 |
"Modified: / 22-02-1999 / 00:47:46 / cg" |
559 |
"Modified: / 30-03-1999 / 14:17:10 / stefan" |
|
560 |
"Modified: / 19-07-2019 / 10:41:56 / Claus Gittinger" |
|
1294 | 561 |
! |
562 |
||
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
563 |
handlesMouseWheelMotion:event inView:aView |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
564 |
"we handle delegated mousewheel events" |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
565 |
|
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
566 |
^ true |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
567 |
! |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
568 |
|
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
569 |
keyPress:key x:x y:y |
2868 | 570 |
"pull the menu on space and return keys" |
571 |
||
2025 | 572 |
<resource: #keyboard (#Return)> |
573 |
||
2868 | 574 |
(key == Character space or:[key == #Return]) ifTrue:[ |
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
575 |
self pullMenu. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
576 |
^ self. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
577 |
]. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
578 |
|
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
579 |
^ super keyPress:key x:x y:y |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
580 |
|
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
581 |
"Modified: / 21.4.1998 / 20:10:05 / cg" |
3236 | 582 |
! |
583 |
||
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
584 |
mouseWheelMotion:buttonState x:x y:y amount:amount deltaTime:dTime view:delegatingView |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
585 |
"scroll through the list items" |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
586 |
|
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
587 |
self enableChannel value ifFalse:[ |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
588 |
^ self. |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
589 |
]. |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
590 |
|
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
591 |
list isNil ifTrue:[ |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
592 |
self getListFromModel. |
3365
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
593 |
list isEmptyOrNil ifTrue:[ |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
594 |
"nothing to scroll" |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
595 |
^ self |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
596 |
]. |
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
597 |
]. |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
598 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
599 |
self deltaSelect:amount sign negated. |
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
600 |
! |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
601 |
|
3236 | 602 |
processEvent:anEvent |
3290
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
603 |
|evView point x y button| |
3236 | 604 |
|
3495 | 605 |
"/ only care for buttonpress in my field... |
606 |
anEvent isButtonPressEvent ifFalse:[^ false]. |
|
607 |
evView := anEvent view. |
|
608 |
evView isNil ifTrue:[^ false]. |
|
609 |
||
3290
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
610 |
button := anEvent state. |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
611 |
((button == 1) or:[button == #select]) ifFalse:[ |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
612 |
^ false |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
613 |
]. |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
614 |
|
3236 | 615 |
(field isNil or:[field shown not]) ifTrue:[ |
616 |
^ false |
|
617 |
]. |
|
618 |
(field isKeyboardConsumer and:[field isEnabled]) ifTrue:[ |
|
619 |
^ false |
|
620 |
]. |
|
621 |
||
3755 | 622 |
x := anEvent x. |
623 |
y := anEvent y. |
|
3236 | 624 |
|
625 |
evView ~~ field ifTrue:[ |
|
626 |
(evView isSameOrComponentOf:field) ifFalse:[ |
|
627 |
^ false |
|
628 |
]. |
|
3755 | 629 |
point := x @ y. |
4994 | 630 |
point := device translatePoint:point fromView:evView toView:field. |
3755 | 631 |
x := point x. |
632 |
y := point y. |
|
3236 | 633 |
]. |
634 |
(x between:0 and:field width) ifFalse:[^ false]. |
|
635 |
(y between:0 and:field height) ifFalse:[^ false]. |
|
636 |
||
3281 | 637 |
self pullMenu == false ifTrue:[ ^ false ]. |
3495 | 638 |
|
639 |
"/ although eaten, we still must care for the focus !! |
|
640 |
self wantsFocusWithButtonPress ifTrue:[ |
|
3503 | 641 |
self windowGroup notNil ifTrue:[ |
642 |
self windowGroup focusView:self. |
|
643 |
"/ Transcript showCR:self windowGroup focusCameByTab. |
|
644 |
] |
|
3495 | 645 |
]. |
3236 | 646 |
^ true |
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
647 |
! ! |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
648 |
|
2499 | 649 |
!ComboView methodsFor:'initialization & release'! |
129 | 650 |
|
3236 | 651 |
destroy |
652 |
|wgrp| |
|
653 |
||
654 |
(wgrp := self windowGroup) notNil ifTrue:[ |
|
655 |
wgrp removePreEventHook:self. |
|
656 |
]. |
|
657 |
super destroy. |
|
658 |
! |
|
659 |
||
3825 | 660 |
initStyle |
661 |
super initStyle. |
|
662 |
||
663 |
self borderWidth:(EditField defaultBorderWidth). |
|
664 |
self borderColor:(EditField defaultBorderColor). |
|
665 |
! |
|
666 |
||
129 | 667 |
initialize |
2750 | 668 |
|prefExt leftInset rightInset prefWidth halfSpacing nm lvl| |
129 | 669 |
|
670 |
super initialize. |
|
308 | 671 |
|
304 | 672 |
listMsg := self class defaultListMessage. |
673 |
aspectMsg := self class defaultAspectMessage. |
|
674 |
changeMsg := self class defaultChangeMessage. |
|
129 | 675 |
|
676 |
self initializeField. |
|
3825 | 677 |
field origin:margin@margin corner:1.0@1.0. |
2136 | 678 |
self shadowColor:(field shadowColor). |
129 | 679 |
|
331 | 680 |
self initializeButton. |
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
681 |
pullDownButton pressAction:[self pullMenu]. |
280 | 682 |
prefExt := pullDownButton preferredExtent. |
683 |
prefWidth := prefExt x. |
|
684 |
||
129 | 685 |
pullDownButton origin:1.0@0.0 corner:1.0@1.0. |
217 | 686 |
styleSheet is3D ifTrue:[ |
280 | 687 |
halfSpacing := ViewSpacing // 2. |
5983 | 688 |
leftInset := rightInset := (prefWidth + halfSpacing). |
2750 | 689 |
(lvl := styleSheet at:#'comboView.level' default:nil) notNil ifTrue:[ |
690 |
self level:lvl. |
|
319 | 691 |
field level:0. |
692 |
field rightInset:margin. |
|
693 |
] ifFalse:[ |
|
694 |
pullDownButton rightInset:halfSpacing. |
|
695 |
field leftInset:halfSpacing |
|
696 |
]. |
|
217 | 697 |
] ifFalse:[ |
280 | 698 |
leftInset := prefWidth + pullDownButton borderWidth. |
699 |
rightInset := prefWidth. |
|
217 | 700 |
]. |
1125 | 701 |
|
3836 | 702 |
"/ what a hack... |
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
703 |
nm := styleSheet name. |
3836 | 704 |
(nm = #win95 or:[nm = #win98 or:[nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[ |
1125 | 705 |
field level:0. |
2750 | 706 |
lvl isNil ifTrue:[self level:-1]. |
1125 | 707 |
pullDownButton rightInset:0. |
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
708 |
nm ~= #st80 ifTrue:[ |
3429
f2b4b84cd477
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3369
diff
changeset
|
709 |
leftInset := (ArrowButton new preferredWidth). |
1126 | 710 |
rightInset := leftInset. |
1125 | 711 |
]. |
712 |
field origin:0.0@0.0. |
|
2750 | 713 |
field leftInset:0. |
1125 | 714 |
"/ field topInset:1; bottomInset:1. |
2750 | 715 |
"/ nm = #winXP ifTrue:[ |
716 |
"/ self borderWidth:1. |
|
717 |
"/ self borderColor:(Color blue lightened). |
|
718 |
"/ ]. |
|
1125 | 719 |
]. |
1126 | 720 |
field rightInset:rightInset. |
280 | 721 |
pullDownButton leftInset:leftInset negated. |
5983 | 722 |
self initialHeight:(field preferredHeight + ViewSpacing). |
129 | 723 |
|
724 |
" |
|
725 |
|b| |
|
726 |
||
727 |
b := ComboBoxView new. |
|
728 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
729 |
b open |
|
730 |
" |
|
731 |
||
5983 | 732 |
"Created: / 28-02-1996 / 15:03:17 / cg" |
733 |
"Modified: / 08-09-1998 / 20:33:22 / cg" |
|
734 |
"Modified: / 08-01-2019 / 14:16:03 / Claus Gittinger" |
|
331 | 735 |
! |
736 |
||
737 |
initializeButton |
|
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
738 |
pullDownButton := self class comboButtonFor:self. |
331 | 739 |
pullDownButton disable. |
740 |
! |
|
741 |
||
742 |
initializeField |
|
4972 | 743 |
"concrete subclass is responsible to instantiate |
744 |
a field widget here. |
|
745 |
For comboList, this will be a label; |
|
746 |
for comboBox, this will be an editfield" |
|
747 |
||
331 | 748 |
self subclassResponsibility |
749 |
||
750 |
"Created: 29.3.1997 / 11:17:14 / cg" |
|
2157 | 751 |
! |
752 |
||
3236 | 753 |
realize |
3238 | 754 |
|pullMenuIfClickedOnField wgrp| |
3236 | 755 |
|
756 |
super realize. |
|
757 |
||
3824 | 758 |
pullMenuIfClickedOnField := |
759 |
styleSheet |
|
760 |
at:#'comboView.pullMenuIfClickedOnField' |
|
761 |
default:[ OperatingSystem isMSWINDOWSlike ]. |
|
3236 | 762 |
|
763 |
pullMenuIfClickedOnField == true ifTrue:[ |
|
3238 | 764 |
wgrp := self windowGroup. |
765 |
wgrp notNil ifTrue:[ wgrp addPreEventHook:self ]. |
|
3236 | 766 |
]. |
767 |
! |
|
768 |
||
2157 | 769 |
release |
770 |
listHolder notNil ifTrue:[ |
|
771 |
listHolder removeDependent:self. |
|
772 |
listHolder := nil. |
|
773 |
]. |
|
774 |
super release |
|
129 | 775 |
! ! |
776 |
||
2406 | 777 |
!ComboView methodsFor:'menu interaction'! |
778 |
||
4564
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
779 |
createPullDownMenuForList:aList |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
780 |
"pull the menu - triggered from the button" |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
781 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
782 |
|menu index| |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
783 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
784 |
comboMenuHolder notNil ifTrue:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
785 |
menu := (comboMenuHolder perform:comboMenuMessage ? #value). |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
786 |
(menu isKindOf:Menu) ifTrue:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
787 |
menu := MenuPanel new menu:menu. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
788 |
] |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
789 |
] ifFalse:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
790 |
menu := MenuPanel new. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
791 |
menu doAccessCharacterTranslation:false. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
792 |
menu labels:aList. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
793 |
menu hideOnRelease:false. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
794 |
menu backgroundColor: field backgroundColor. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
795 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
796 |
index := 1. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
797 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
798 |
menu do:[:el | |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
799 |
el value:#select: argument:index. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
800 |
index := index + 1. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
801 |
]. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
802 |
menu receiver:self. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
803 |
]. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
804 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
805 |
menu font:self font. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
806 |
menu preferredWidth:self width. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
807 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
808 |
^ menu |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
809 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
810 |
"Modified: / 25-03-2014 / 01:21:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
811 |
! |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
812 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
813 |
deltaSelect:delta |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
814 |
"change selection by delta. Wrap at start/end" |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
815 |
|
6040 | 816 |
|listSize newIndex| |
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
817 |
|
6040 | 818 |
(listSize := list size) == 0 ifTrue:[^ self]. |
3556
e7d87b5b3cf7
care for mouse-wheel deltaSelect: if list is empty
Claus Gittinger <cg@exept.de>
parents:
3503
diff
changeset
|
819 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
820 |
newIndex := currentIndex + delta. |
6040 | 821 |
newIndex > listSize ifTrue:[ |
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
822 |
newIndex := 1. |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
823 |
] ifFalse:[ |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
824 |
newIndex <= 0 ifTrue:[ |
6040 | 825 |
newIndex := listSize. |
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
826 |
]. |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
827 |
]. |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
828 |
|
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
829 |
self select:newIndex. |
6040 | 830 |
|
831 |
"Modified: / 02-04-2019 / 17:59:42 / Claus Gittinger" |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
832 |
! |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
833 |
|
2406 | 834 |
pullMenu |
3281 | 835 |
"pull the menu - triggered from the button |
836 |
returns false if the menu cannot be opened" |
|
2406 | 837 |
|
3281 | 838 |
|menu origin opensMenu| |
2406 | 839 |
|
840 |
self getListFromModel. |
|
841 |
||
4227 | 842 |
opensMenu := ((list notEmptyOrNil or:[comboMenuHolder notNil]) |
843 |
and:[self enableChannel value]). |
|
3281 | 844 |
|
845 |
opensMenu ifTrue:[ |
|
2406 | 846 |
menu := self createPullDownMenuForList:list. |
4994 | 847 |
origin := device translatePoint:(0 @ self height) fromView:self toView:nil. |
4227 | 848 |
"/ menu extentChangedFlag:false. |
849 |
"/ menu originChangedFlag:false. |
|
850 |
menu showAt:origin resizing:false. |
|
2406 | 851 |
]. |
852 |
||
853 |
pullDownButton turnOff. |
|
3281 | 854 |
^ opensMenu |
2406 | 855 |
|
856 |
"Created: / 10.10.2001 / 14:47:25 / cg" |
|
857 |
"Modified: / 10.10.2001 / 15:04:44 / cg" |
|
858 |
! |
|
859 |
||
860 |
select:anIndex |
|
861 |
"sent from the popped menu, when an item was selected" |
|
862 |
||
863 |
self subclassResponsibility |
|
864 |
||
865 |
"Modified: 27.2.1997 / 15:19:07 / cg" |
|
866 |
! ! |
|
867 |
||
129 | 868 |
!ComboView methodsFor:'message delegation'! |
869 |
||
870 |
doesNotUnderstand:aMessage |
|
4824 | 871 |
"delegate to my field" |
872 |
||
129 | 873 |
(field respondsTo:aMessage selector) ifTrue:[ |
1207 | 874 |
^ aMessage sendTo:field |
129 | 875 |
]. |
876 |
^ super doesNotUnderstand:aMessage |
|
877 |
||
878 |
"Created: 28.2.1996 / 15:03:17 / cg" |
|
879 |
"Modified: 28.2.1996 / 15:06:09 / cg" |
|
166 | 880 |
! |
881 |
||
2300 | 882 |
flash |
4824 | 883 |
"delegate to my field" |
884 |
||
2300 | 885 |
field flash |
886 |
! |
|
887 |
||
5630 | 888 |
flash:messageOrNil withColor:flashColor |
4824 | 889 |
"delegate to my field" |
890 |
||
5630 | 891 |
field flash:messageOrNil withColor:flashColor |
892 |
||
893 |
"Modified (format): / 21-10-2017 / 23:13:39 / cg" |
|
4824 | 894 |
! |
895 |
||
166 | 896 |
respondsTo:aSymbol |
4824 | 897 |
"delegate to my field" |
898 |
||
166 | 899 |
^ (field respondsTo:aSymbol) or:[super respondsTo:aSymbol] |
900 |
||
901 |
"Created: 2.5.1996 / 16:57:34 / stefan" |
|
129 | 902 |
! ! |
903 |
||
214 | 904 |
!ComboView methodsFor:'private'! |
905 |
||
906 |
getListFromModel |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
907 |
"fetch the list - either from the listHolder, or |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
908 |
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
|
909 |
using #list." |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
910 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
911 |
listHolder notNil ifTrue:[ |
5352 | 912 |
"/ should blocks be evaluated when the pull-down list is actually needed? |
913 |
"/ listHolder isBlock ifFalse:[ |
|
914 |
self list:listHolder value |
|
915 |
"/ ] |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
916 |
] ifFalse:[ |
304 | 917 |
(model notNil and:[listMsg notNil]) ifTrue:[ |
918 |
(model respondsTo:listMsg) ifTrue:[ |
|
919 |
self list:(model perform:listMsg) |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
920 |
] |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
921 |
] |
214 | 922 |
]. |
923 |
||
924 |
"Created: 15.7.1996 / 12:22:56 / cg" |
|
304 | 925 |
"Modified: 26.2.1997 / 19:40:58 / cg" |
214 | 926 |
! |
927 |
||
928 |
getValueFromModel |
|
929 |
||
930 |
"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
|
931 |
! |
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
1126
diff
changeset
|
932 |
|
1210
55f2c4209f94
oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
933 |
setFieldsFont:aFont |
55f2c4209f94
oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
934 |
field font:aFont. |
214 | 935 |
! ! |
936 |
||
129 | 937 |
!ComboView methodsFor:'queries'! |
938 |
||
5949 | 939 |
computePreferredExtent |
285 | 940 |
"compute & return the boxes preferredExtent from the components' preferrences" |
941 |
||
683 | 942 |
|fieldPref buttonPref m menuPrefX menuPrefY w h| |
129 | 943 |
|
944 |
list isNil ifTrue:[ |
|
308 | 945 |
self getListFromModel |
946 |
]. |
|
947 |
||
948 |
list isNil ifTrue:[ |
|
683 | 949 |
menuPrefX := menuPrefY := 0 |
129 | 950 |
] ifFalse:[ |
4503 | 951 |
|graphicsDevice| |
952 |
||
4994 | 953 |
graphicsDevice := device ? Screen current. |
4503 | 954 |
m := (MenuView onDevice:graphicsDevice) labels:list. |
3429
f2b4b84cd477
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3369
diff
changeset
|
955 |
menuPrefX := m preferredWidth. |
1348 | 956 |
|
957 |
"/ the menuView returns rubbish ... |
|
958 |
"/ menuPrefY := (m preferredExtentForLines:1 cols:10) y |
|
959 |
||
960 |
"/ any non-strings ? |
|
961 |
menuPrefY := list |
|
962 |
inject:('X' heightOn:self) |
|
963 |
into:[:max :el | el isString ifTrue:[ |
|
964 |
max |
|
965 |
] ifFalse:[ |
|
966 |
max max:(el heightOn:self) |
|
967 |
] |
|
968 |
]. |
|
129 | 969 |
]. |
970 |
||
302
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
971 |
fieldPref := field preferredExtent. |
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
972 |
buttonPref := pullDownButton preferredExtent. |
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
973 |
|
319 | 974 |
w := ((fieldPref x max:menuPrefX) max:50) + buttonPref x. |
975 |
w := w + margin + margin. |
|
683 | 976 |
h := (fieldPref y max:buttonPref y) max:menuPrefY. |
319 | 977 |
h := h + margin + margin. |
978 |
^ w @ h |
|
129 | 979 |
|
5949 | 980 |
"Created: / 09-11-2018 / 19:49:42 / Claus Gittinger" |
129 | 981 |
! ! |
982 |
||
4832 | 983 |
!ComboView methodsFor:'testing'! |
984 |
||
985 |
isComboView |
|
986 |
^ true |
|
987 |
! ! |
|
988 |
||
263
865b7d99d3f5
added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
989 |
!ComboView class methodsFor:'documentation'! |
129 | 990 |
|
991 |
version |
|
4824 | 992 |
^ '$Header$' |
3777
83c52227471d
changed: #createPullDownMenuForList:
Claus Gittinger <cg@exept.de>
parents:
3755
diff
changeset
|
993 |
! |
83c52227471d
changed: #createPullDownMenuForList:
Claus Gittinger <cg@exept.de>
parents:
3755
diff
changeset
|
994 |
|
83c52227471d
changed: #createPullDownMenuForList:
Claus Gittinger <cg@exept.de>
parents:
3755
diff
changeset
|
995 |
version_CVS |
4824 | 996 |
^ '$Header$' |
129 | 997 |
! ! |
4180 | 998 |