author | Claus Gittinger <cg@exept.de> |
Tue, 02 Apr 2019 18:02:15 +0200 | |
changeset 6040 | a3296ee359af |
parent 5983 | 023c539cad97 |
child 6088 | 1b000948eeda |
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 |
||
541 |
(enableChannel isNil or:[enableChannel value]) ifTrue:[ |
|
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 |
||
558 |
"Modified: / 22.2.1999 / 00:47:46 / cg" |
|
559 |
"Modified: / 30.3.1999 / 14:17:10 / stefan" |
|
560 |
! |
|
561 |
||
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
562 |
handlesMouseWheelMotion:event inView:aView |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
563 |
"we handle delegated mousewheel events" |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
564 |
|
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
565 |
^ true |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
566 |
! |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
567 |
|
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
568 |
keyPress:key x:x y:y |
2868 | 569 |
"pull the menu on space and return keys" |
570 |
||
2025 | 571 |
<resource: #keyboard (#Return)> |
572 |
||
2868 | 573 |
(key == Character space or:[key == #Return]) ifTrue:[ |
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
574 |
self pullMenu. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
575 |
^ self. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
576 |
]. |
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 |
^ super keyPress:key x:x y:y |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
579 |
|
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
580 |
"Modified: / 21.4.1998 / 20:10:05 / cg" |
3236 | 581 |
! |
582 |
||
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
583 |
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
|
584 |
"scroll through the list items" |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
585 |
|
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
586 |
self enableChannel value ifFalse:[ |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
587 |
^ self. |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
588 |
]. |
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 |
list isNil ifTrue:[ |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
591 |
self getListFromModel. |
3365
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
592 |
list isEmptyOrNil ifTrue:[ |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
593 |
"nothing to scroll" |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
594 |
^ self |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
595 |
]. |
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
596 |
]. |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
597 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
598 |
self deltaSelect:amount sign negated. |
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
599 |
! |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
600 |
|
3236 | 601 |
processEvent:anEvent |
3290
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
602 |
|evView point x y button| |
3236 | 603 |
|
3495 | 604 |
"/ only care for buttonpress in my field... |
605 |
anEvent isButtonPressEvent ifFalse:[^ false]. |
|
606 |
evView := anEvent view. |
|
607 |
evView isNil ifTrue:[^ false]. |
|
608 |
||
3290
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
609 |
button := anEvent state. |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
610 |
((button == 1) or:[button == #select]) ifFalse:[ |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
611 |
^ false |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
612 |
]. |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
613 |
|
3236 | 614 |
(field isNil or:[field shown not]) ifTrue:[ |
615 |
^ false |
|
616 |
]. |
|
617 |
(field isKeyboardConsumer and:[field isEnabled]) ifTrue:[ |
|
618 |
^ false |
|
619 |
]. |
|
620 |
||
3755 | 621 |
x := anEvent x. |
622 |
y := anEvent y. |
|
3236 | 623 |
|
624 |
evView ~~ field ifTrue:[ |
|
625 |
(evView isSameOrComponentOf:field) ifFalse:[ |
|
626 |
^ false |
|
627 |
]. |
|
3755 | 628 |
point := x @ y. |
4994 | 629 |
point := device translatePoint:point fromView:evView toView:field. |
3755 | 630 |
x := point x. |
631 |
y := point y. |
|
3236 | 632 |
]. |
633 |
(x between:0 and:field width) ifFalse:[^ false]. |
|
634 |
(y between:0 and:field height) ifFalse:[^ false]. |
|
635 |
||
3281 | 636 |
self pullMenu == false ifTrue:[ ^ false ]. |
3495 | 637 |
|
638 |
"/ although eaten, we still must care for the focus !! |
|
639 |
self wantsFocusWithButtonPress ifTrue:[ |
|
3503 | 640 |
self windowGroup notNil ifTrue:[ |
641 |
self windowGroup focusView:self. |
|
642 |
"/ Transcript showCR:self windowGroup focusCameByTab. |
|
643 |
] |
|
3495 | 644 |
]. |
3236 | 645 |
^ true |
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
646 |
! ! |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
647 |
|
2499 | 648 |
!ComboView methodsFor:'initialization & release'! |
129 | 649 |
|
3236 | 650 |
destroy |
651 |
|wgrp| |
|
652 |
||
653 |
(wgrp := self windowGroup) notNil ifTrue:[ |
|
654 |
wgrp removePreEventHook:self. |
|
655 |
]. |
|
656 |
super destroy. |
|
657 |
! |
|
658 |
||
3825 | 659 |
initStyle |
660 |
super initStyle. |
|
661 |
||
662 |
self borderWidth:(EditField defaultBorderWidth). |
|
663 |
self borderColor:(EditField defaultBorderColor). |
|
664 |
! |
|
665 |
||
129 | 666 |
initialize |
2750 | 667 |
|prefExt leftInset rightInset prefWidth halfSpacing nm lvl| |
129 | 668 |
|
669 |
super initialize. |
|
308 | 670 |
|
304 | 671 |
listMsg := self class defaultListMessage. |
672 |
aspectMsg := self class defaultAspectMessage. |
|
673 |
changeMsg := self class defaultChangeMessage. |
|
129 | 674 |
|
675 |
self initializeField. |
|
3825 | 676 |
field origin:margin@margin corner:1.0@1.0. |
2136 | 677 |
self shadowColor:(field shadowColor). |
129 | 678 |
|
331 | 679 |
self initializeButton. |
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
680 |
pullDownButton pressAction:[self pullMenu]. |
280 | 681 |
prefExt := pullDownButton preferredExtent. |
682 |
prefWidth := prefExt x. |
|
683 |
||
129 | 684 |
pullDownButton origin:1.0@0.0 corner:1.0@1.0. |
217 | 685 |
styleSheet is3D ifTrue:[ |
280 | 686 |
halfSpacing := ViewSpacing // 2. |
5983 | 687 |
leftInset := rightInset := (prefWidth + halfSpacing). |
2750 | 688 |
(lvl := styleSheet at:#'comboView.level' default:nil) notNil ifTrue:[ |
689 |
self level:lvl. |
|
319 | 690 |
field level:0. |
691 |
field rightInset:margin. |
|
692 |
] ifFalse:[ |
|
693 |
pullDownButton rightInset:halfSpacing. |
|
694 |
field leftInset:halfSpacing |
|
695 |
]. |
|
217 | 696 |
] ifFalse:[ |
280 | 697 |
leftInset := prefWidth + pullDownButton borderWidth. |
698 |
rightInset := prefWidth. |
|
217 | 699 |
]. |
1125 | 700 |
|
3836 | 701 |
"/ what a hack... |
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
702 |
nm := styleSheet name. |
3836 | 703 |
(nm = #win95 or:[nm = #win98 or:[nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[ |
1125 | 704 |
field level:0. |
2750 | 705 |
lvl isNil ifTrue:[self level:-1]. |
1125 | 706 |
pullDownButton rightInset:0. |
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
707 |
nm ~= #st80 ifTrue:[ |
3429
f2b4b84cd477
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3369
diff
changeset
|
708 |
leftInset := (ArrowButton new preferredWidth). |
1126 | 709 |
rightInset := leftInset. |
1125 | 710 |
]. |
711 |
field origin:0.0@0.0. |
|
2750 | 712 |
field leftInset:0. |
1125 | 713 |
"/ field topInset:1; bottomInset:1. |
2750 | 714 |
"/ nm = #winXP ifTrue:[ |
715 |
"/ self borderWidth:1. |
|
716 |
"/ self borderColor:(Color blue lightened). |
|
717 |
"/ ]. |
|
1125 | 718 |
]. |
1126 | 719 |
field rightInset:rightInset. |
280 | 720 |
pullDownButton leftInset:leftInset negated. |
5983 | 721 |
self initialHeight:(field preferredHeight + ViewSpacing). |
129 | 722 |
|
723 |
" |
|
724 |
|b| |
|
725 |
||
726 |
b := ComboBoxView new. |
|
727 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
728 |
b open |
|
729 |
" |
|
730 |
||
5983 | 731 |
"Created: / 28-02-1996 / 15:03:17 / cg" |
732 |
"Modified: / 08-09-1998 / 20:33:22 / cg" |
|
733 |
"Modified: / 08-01-2019 / 14:16:03 / Claus Gittinger" |
|
331 | 734 |
! |
735 |
||
736 |
initializeButton |
|
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
737 |
pullDownButton := self class comboButtonFor:self. |
331 | 738 |
pullDownButton disable. |
739 |
! |
|
740 |
||
741 |
initializeField |
|
4972 | 742 |
"concrete subclass is responsible to instantiate |
743 |
a field widget here. |
|
744 |
For comboList, this will be a label; |
|
745 |
for comboBox, this will be an editfield" |
|
746 |
||
331 | 747 |
self subclassResponsibility |
748 |
||
749 |
"Created: 29.3.1997 / 11:17:14 / cg" |
|
2157 | 750 |
! |
751 |
||
3236 | 752 |
realize |
3238 | 753 |
|pullMenuIfClickedOnField wgrp| |
3236 | 754 |
|
755 |
super realize. |
|
756 |
||
3824 | 757 |
pullMenuIfClickedOnField := |
758 |
styleSheet |
|
759 |
at:#'comboView.pullMenuIfClickedOnField' |
|
760 |
default:[ OperatingSystem isMSWINDOWSlike ]. |
|
3236 | 761 |
|
762 |
pullMenuIfClickedOnField == true ifTrue:[ |
|
3238 | 763 |
wgrp := self windowGroup. |
764 |
wgrp notNil ifTrue:[ wgrp addPreEventHook:self ]. |
|
3236 | 765 |
]. |
766 |
! |
|
767 |
||
2157 | 768 |
release |
769 |
listHolder notNil ifTrue:[ |
|
770 |
listHolder removeDependent:self. |
|
771 |
listHolder := nil. |
|
772 |
]. |
|
773 |
super release |
|
129 | 774 |
! ! |
775 |
||
2406 | 776 |
!ComboView methodsFor:'menu interaction'! |
777 |
||
4564
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
778 |
createPullDownMenuForList:aList |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
779 |
"pull the menu - triggered from the button" |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
780 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
781 |
|menu index| |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
782 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
783 |
comboMenuHolder notNil ifTrue:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
784 |
menu := (comboMenuHolder perform:comboMenuMessage ? #value). |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
785 |
(menu isKindOf:Menu) ifTrue:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
786 |
menu := MenuPanel new menu:menu. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
787 |
] |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
788 |
] ifFalse:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
789 |
menu := MenuPanel new. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
790 |
menu doAccessCharacterTranslation:false. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
791 |
menu labels:aList. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
792 |
menu hideOnRelease:false. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
793 |
menu backgroundColor: field backgroundColor. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
794 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
795 |
index := 1. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
796 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
797 |
menu do:[:el | |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
798 |
el value:#select: argument:index. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
799 |
index := index + 1. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
800 |
]. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
801 |
menu receiver:self. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
802 |
]. |
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 |
menu font:self font. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
805 |
menu preferredWidth:self width. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
806 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
807 |
^ menu |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
808 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
809 |
"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
|
810 |
! |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
811 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
812 |
deltaSelect:delta |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
813 |
"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
|
814 |
|
6040 | 815 |
|listSize newIndex| |
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
816 |
|
6040 | 817 |
(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
|
818 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
819 |
newIndex := currentIndex + delta. |
6040 | 820 |
newIndex > listSize ifTrue:[ |
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
821 |
newIndex := 1. |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
822 |
] ifFalse:[ |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
823 |
newIndex <= 0 ifTrue:[ |
6040 | 824 |
newIndex := listSize. |
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
825 |
]. |
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 |
self select:newIndex. |
6040 | 829 |
|
830 |
"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
|
831 |
! |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
832 |
|
2406 | 833 |
pullMenu |
3281 | 834 |
"pull the menu - triggered from the button |
835 |
returns false if the menu cannot be opened" |
|
2406 | 836 |
|
3281 | 837 |
|menu origin opensMenu| |
2406 | 838 |
|
839 |
self getListFromModel. |
|
840 |
||
4227 | 841 |
opensMenu := ((list notEmptyOrNil or:[comboMenuHolder notNil]) |
842 |
and:[self enableChannel value]). |
|
3281 | 843 |
|
844 |
opensMenu ifTrue:[ |
|
2406 | 845 |
menu := self createPullDownMenuForList:list. |
4994 | 846 |
origin := device translatePoint:(0 @ self height) fromView:self toView:nil. |
4227 | 847 |
"/ menu extentChangedFlag:false. |
848 |
"/ menu originChangedFlag:false. |
|
849 |
menu showAt:origin resizing:false. |
|
2406 | 850 |
]. |
851 |
||
852 |
pullDownButton turnOff. |
|
3281 | 853 |
^ opensMenu |
2406 | 854 |
|
855 |
"Created: / 10.10.2001 / 14:47:25 / cg" |
|
856 |
"Modified: / 10.10.2001 / 15:04:44 / cg" |
|
857 |
! |
|
858 |
||
859 |
select:anIndex |
|
860 |
"sent from the popped menu, when an item was selected" |
|
861 |
||
862 |
self subclassResponsibility |
|
863 |
||
864 |
"Modified: 27.2.1997 / 15:19:07 / cg" |
|
865 |
! ! |
|
866 |
||
129 | 867 |
!ComboView methodsFor:'message delegation'! |
868 |
||
869 |
doesNotUnderstand:aMessage |
|
4824 | 870 |
"delegate to my field" |
871 |
||
129 | 872 |
(field respondsTo:aMessage selector) ifTrue:[ |
1207 | 873 |
^ aMessage sendTo:field |
129 | 874 |
]. |
875 |
^ super doesNotUnderstand:aMessage |
|
876 |
||
877 |
"Created: 28.2.1996 / 15:03:17 / cg" |
|
878 |
"Modified: 28.2.1996 / 15:06:09 / cg" |
|
166 | 879 |
! |
880 |
||
2300 | 881 |
flash |
4824 | 882 |
"delegate to my field" |
883 |
||
2300 | 884 |
field flash |
885 |
! |
|
886 |
||
5630 | 887 |
flash:messageOrNil withColor:flashColor |
4824 | 888 |
"delegate to my field" |
889 |
||
5630 | 890 |
field flash:messageOrNil withColor:flashColor |
891 |
||
892 |
"Modified (format): / 21-10-2017 / 23:13:39 / cg" |
|
4824 | 893 |
! |
894 |
||
166 | 895 |
respondsTo:aSymbol |
4824 | 896 |
"delegate to my field" |
897 |
||
166 | 898 |
^ (field respondsTo:aSymbol) or:[super respondsTo:aSymbol] |
899 |
||
900 |
"Created: 2.5.1996 / 16:57:34 / stefan" |
|
129 | 901 |
! ! |
902 |
||
214 | 903 |
!ComboView methodsFor:'private'! |
904 |
||
905 |
getListFromModel |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
906 |
"fetch the list - either from the listHolder, or |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
907 |
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
|
908 |
using #list." |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
909 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
910 |
listHolder notNil ifTrue:[ |
5352 | 911 |
"/ should blocks be evaluated when the pull-down list is actually needed? |
912 |
"/ listHolder isBlock ifFalse:[ |
|
913 |
self list:listHolder value |
|
914 |
"/ ] |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
915 |
] ifFalse:[ |
304 | 916 |
(model notNil and:[listMsg notNil]) ifTrue:[ |
917 |
(model respondsTo:listMsg) ifTrue:[ |
|
918 |
self list:(model perform:listMsg) |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
919 |
] |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
920 |
] |
214 | 921 |
]. |
922 |
||
923 |
"Created: 15.7.1996 / 12:22:56 / cg" |
|
304 | 924 |
"Modified: 26.2.1997 / 19:40:58 / cg" |
214 | 925 |
! |
926 |
||
927 |
getValueFromModel |
|
928 |
||
929 |
"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
|
930 |
! |
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
1126
diff
changeset
|
931 |
|
1210
55f2c4209f94
oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
932 |
setFieldsFont:aFont |
55f2c4209f94
oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
933 |
field font:aFont. |
214 | 934 |
! ! |
935 |
||
129 | 936 |
!ComboView methodsFor:'queries'! |
937 |
||
5949 | 938 |
computePreferredExtent |
285 | 939 |
"compute & return the boxes preferredExtent from the components' preferrences" |
940 |
||
683 | 941 |
|fieldPref buttonPref m menuPrefX menuPrefY w h| |
129 | 942 |
|
943 |
list isNil ifTrue:[ |
|
308 | 944 |
self getListFromModel |
945 |
]. |
|
946 |
||
947 |
list isNil ifTrue:[ |
|
683 | 948 |
menuPrefX := menuPrefY := 0 |
129 | 949 |
] ifFalse:[ |
4503 | 950 |
|graphicsDevice| |
951 |
||
4994 | 952 |
graphicsDevice := device ? Screen current. |
4503 | 953 |
m := (MenuView onDevice:graphicsDevice) labels:list. |
3429
f2b4b84cd477
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3369
diff
changeset
|
954 |
menuPrefX := m preferredWidth. |
1348 | 955 |
|
956 |
"/ the menuView returns rubbish ... |
|
957 |
"/ menuPrefY := (m preferredExtentForLines:1 cols:10) y |
|
958 |
||
959 |
"/ any non-strings ? |
|
960 |
menuPrefY := list |
|
961 |
inject:('X' heightOn:self) |
|
962 |
into:[:max :el | el isString ifTrue:[ |
|
963 |
max |
|
964 |
] ifFalse:[ |
|
965 |
max max:(el heightOn:self) |
|
966 |
] |
|
967 |
]. |
|
129 | 968 |
]. |
969 |
||
302
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
970 |
fieldPref := field preferredExtent. |
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
971 |
buttonPref := pullDownButton preferredExtent. |
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
972 |
|
319 | 973 |
w := ((fieldPref x max:menuPrefX) max:50) + buttonPref x. |
974 |
w := w + margin + margin. |
|
683 | 975 |
h := (fieldPref y max:buttonPref y) max:menuPrefY. |
319 | 976 |
h := h + margin + margin. |
977 |
^ w @ h |
|
129 | 978 |
|
5949 | 979 |
"Created: / 09-11-2018 / 19:49:42 / Claus Gittinger" |
129 | 980 |
! ! |
981 |
||
4832 | 982 |
!ComboView methodsFor:'testing'! |
983 |
||
984 |
isComboView |
|
985 |
^ true |
|
986 |
! ! |
|
987 |
||
263
865b7d99d3f5
added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
988 |
!ComboView class methodsFor:'documentation'! |
129 | 989 |
|
990 |
version |
|
4824 | 991 |
^ '$Header$' |
3777
83c52227471d
changed: #createPullDownMenuForList:
Claus Gittinger <cg@exept.de>
parents:
3755
diff
changeset
|
992 |
! |
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 |
version_CVS |
4824 | 995 |
^ '$Header$' |
129 | 996 |
! ! |
4180 | 997 |