author | Claus Gittinger <cg@exept.de> |
Tue, 12 Feb 2019 19:02:06 +0100 | |
changeset 5997 | dda46d10430a |
parent 5983 | 023c539cad97 |
child 6040 | a3296ee359af |
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:[ |
5661 | 393 |
self assert:(aList isNil or:[aList 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 |
|
400 |
"Modified: / 30.3.1999 / 14:17:38 / stefan" |
|
129 | 401 |
! ! |
402 |
||
853 | 403 |
!ComboView methodsFor:'accessing-look'! |
404 |
||
405 |
backgroundColor |
|
406 |
||
407 |
^field backgroundColor |
|
408 |
! |
|
409 |
||
410 |
backgroundColor:aColor |
|
411 |
||
412 |
field backgroundColor:aColor |
|
413 |
! |
|
414 |
||
415 |
font:aFont |
|
416 |
||
417 |
super font:aFont. |
|
1183
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
1126
diff
changeset
|
418 |
self setFieldsFont:aFont. |
853 | 419 |
! |
420 |
||
421 |
foregroundColor |
|
422 |
||
423 |
^field foregroundColor |
|
424 |
! |
|
425 |
||
426 |
foregroundColor:aColor |
|
427 |
||
428 |
field foregroundColor:aColor |
|
429 |
! ! |
|
430 |
||
214 | 431 |
!ComboView methodsFor:'accessing-mvc'! |
432 |
||
4187 | 433 |
comboMenuHolder |
434 |
^ comboMenuHolder |
|
435 |
! |
|
436 |
||
4225 | 437 |
comboMenuHolder:aMenuHolder |
438 |
"allows for arbitrary menus to be opened via the combo button" |
|
439 |
||
440 |
comboMenuHolder := aMenuHolder. |
|
441 |
! |
|
442 |
||
443 |
comboMenuHolder:aMenuHolder comboMenuMessage:aSelectorToTheHolder |
|
444 |
"allows for arbitrary menus to be opened via the combo button" |
|
445 |
||
446 |
comboMenuHolder := aMenuHolder. |
|
447 |
comboMenuMessage := aSelectorToTheHolder. |
|
4187 | 448 |
! |
449 |
||
450 |
comboMenuMessage |
|
451 |
^ comboMenuMessage |
|
452 |
! |
|
453 |
||
4225 | 454 |
comboMenuMessage:aSelectorToTheHolder |
455 |
"allows for arbitrary menus to be opened via the combo button" |
|
456 |
||
457 |
comboMenuMessage := aSelectorToTheHolder. |
|
4187 | 458 |
! |
459 |
||
5592 | 460 |
currentIndex |
461 |
^ currentIndex |
|
462 |
! |
|
463 |
||
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
464 |
listHolder:aValueHolder |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
465 |
"set the listHolder. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
466 |
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
|
467 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
468 |
listHolder notNil ifTrue:[ |
304 | 469 |
listHolder removeDependent:self. |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
470 |
]. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
471 |
listHolder := aValueHolder. |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
472 |
listHolder notNil ifTrue:[ |
304 | 473 |
aValueHolder addDependent:self. |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
474 |
]. |
3274
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
475 |
|
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
476 |
"/ cg: either fetch it here or when realized; |
5180 | 477 |
"/ (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
|
478 |
"/ realized ifTrue:[ |
304 | 479 |
self getListFromModel. |
3274
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
480 |
"/ ] |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
481 |
|
3274
e162e9218179
must fetch the lists value when the listHilder is set.
Claus Gittinger <cg@exept.de>
parents:
3247
diff
changeset
|
482 |
"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
|
483 |
! |
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 |
listMessage:aSymbol |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
486 |
"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
|
487 |
the list. If not defined, #list is used" |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
488 |
|
304 | 489 |
listMsg := aSymbol |
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
490 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
491 |
"Created: 14.2.1997 / 19:16:52 / cg" |
304 | 492 |
"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
|
493 |
! |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
494 |
|
214 | 495 |
model:aModel |
304 | 496 |
"set the model, which is supposed to provide the boxes value. |
497 |
If a listMessage was defined, it is also responsible for providing |
|
498 |
the list" |
|
499 |
||
214 | 500 |
super model:aModel. |
501 |
||
3596 | 502 |
listHolder isNil ifTrue:[ |
503 |
self getListFromModel. |
|
504 |
]. |
|
314
6ff49c930c71
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
312
diff
changeset
|
505 |
self getValueFromModel. |
304 | 506 |
|
314
6ff49c930c71
fetch models value when a model is assigned;
Claus Gittinger <cg@exept.de>
parents:
312
diff
changeset
|
507 |
"Modified: 28.2.1997 / 19:08:45 / cg" |
310 | 508 |
! ! |
509 |
||
510 |
!ComboView methodsFor:'change & update'! |
|
214 | 511 |
|
512 |
update:something with:aParameter from:changedObject |
|
1207 | 513 |
|
214 | 514 |
changedObject == model ifTrue:[ |
310 | 515 |
listHolder isNil ifTrue:[ |
516 |
self getListFromModel. |
|
517 |
]. |
|
518 |
self getValueFromModel. |
|
519 |
^ self |
|
214 | 520 |
]. |
310 | 521 |
changedObject == listHolder ifTrue:[ |
522 |
self getListFromModel. |
|
523 |
^ self |
|
524 |
]. |
|
525 |
||
214 | 526 |
super update:something with:aParameter from:changedObject |
527 |
||
1294 | 528 |
"Created: / 15.7.1996 / 12:26:49 / cg" |
529 |
"Modified: / 28.2.1997 / 13:48:51 / cg" |
|
530 |
"Modified: / 30.3.1999 / 14:17:55 / stefan" |
|
214 | 531 |
! ! |
532 |
||
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
533 |
!ComboView methodsFor:'event handling'! |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
534 |
|
1306
56e90a9e5da1
renambe #enableStateChange to #enableStateChanged
Claus Gittinger <cg@exept.de>
parents:
1301
diff
changeset
|
535 |
enableStateChanged |
1294 | 536 |
"the enable state has changed - pass this to my field and pullDownButton" |
537 |
||
538 |
|msg| |
|
539 |
||
540 |
(enableChannel isNil or:[enableChannel value]) ifTrue:[ |
|
541 |
msg := #enable |
|
542 |
] ifFalse:[ |
|
543 |
msg := #disable |
|
544 |
]. |
|
545 |
field perform:msg ifNotUnderstood:nil. |
|
546 |
||
3755 | 547 |
list isEmptyOrNil ifTrue:[ |
4186 | 548 |
"/ may only do this, if the list is static or a valueModel. |
549 |
"/ If it is a block, we do not know what value will be returned the next |
|
550 |
"/ time. |
|
551 |
listHolder isBlock ifFalse:[ |
|
552 |
msg := #disable |
|
553 |
]. |
|
1294 | 554 |
]. |
555 |
pullDownButton perform:msg ifNotUnderstood:nil. |
|
556 |
||
557 |
"Modified: / 22.2.1999 / 00:47:46 / cg" |
|
558 |
"Modified: / 30.3.1999 / 14:17:10 / stefan" |
|
559 |
! |
|
560 |
||
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
561 |
handlesMouseWheelMotion:event inView:aView |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
562 |
"we handle delegated mousewheel events" |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
563 |
|
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
564 |
^ true |
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 |
|
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
567 |
keyPress:key x:x y:y |
2868 | 568 |
"pull the menu on space and return keys" |
569 |
||
2025 | 570 |
<resource: #keyboard (#Return)> |
571 |
||
2868 | 572 |
(key == Character space or:[key == #Return]) ifTrue:[ |
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
573 |
self pullMenu. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
574 |
^ self. |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
575 |
]. |
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 |
^ super keyPress:key x:x y:y |
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 |
"Modified: / 21.4.1998 / 20:10:05 / cg" |
3236 | 580 |
! |
581 |
||
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
582 |
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
|
583 |
"scroll through the list items" |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
584 |
|
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
585 |
self enableChannel value ifFalse:[ |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
586 |
^ self. |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
587 |
]. |
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 |
list isNil ifTrue:[ |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
590 |
self getListFromModel. |
3365
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
591 |
list isEmptyOrNil ifTrue:[ |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
592 |
"nothing to scroll" |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
593 |
^ self |
06a46f12cb2e
changed #mouseWheelMotion:x:y:amount:deltaTime:view:
Stefan Vogel <sv@exept.de>
parents:
3327
diff
changeset
|
594 |
]. |
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
595 |
]. |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
596 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
597 |
self deltaSelect:amount sign negated. |
3312
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
598 |
! |
ad1dcdaa7ba7
Support for selection via mouse wheel
Stefan Vogel <sv@exept.de>
parents:
3290
diff
changeset
|
599 |
|
3236 | 600 |
processEvent:anEvent |
3290
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
601 |
|evView point x y button| |
3236 | 602 |
|
3495 | 603 |
"/ only care for buttonpress in my field... |
604 |
anEvent isButtonPressEvent ifFalse:[^ false]. |
|
605 |
evView := anEvent view. |
|
606 |
evView isNil ifTrue:[^ false]. |
|
607 |
||
3290
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
608 |
button := anEvent state. |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
609 |
((button == 1) or:[button == #select]) ifFalse:[ |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
610 |
^ false |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
611 |
]. |
d6fafe560ade
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3281
diff
changeset
|
612 |
|
3236 | 613 |
(field isNil or:[field shown not]) ifTrue:[ |
614 |
^ false |
|
615 |
]. |
|
616 |
(field isKeyboardConsumer and:[field isEnabled]) ifTrue:[ |
|
617 |
^ false |
|
618 |
]. |
|
619 |
||
3755 | 620 |
x := anEvent x. |
621 |
y := anEvent y. |
|
3236 | 622 |
|
623 |
evView ~~ field ifTrue:[ |
|
624 |
(evView isSameOrComponentOf:field) ifFalse:[ |
|
625 |
^ false |
|
626 |
]. |
|
3755 | 627 |
point := x @ y. |
4994 | 628 |
point := device translatePoint:point fromView:evView toView:field. |
3755 | 629 |
x := point x. |
630 |
y := point y. |
|
3236 | 631 |
]. |
632 |
(x between:0 and:field width) ifFalse:[^ false]. |
|
633 |
(y between:0 and:field height) ifFalse:[^ false]. |
|
634 |
||
3281 | 635 |
self pullMenu == false ifTrue:[ ^ false ]. |
3495 | 636 |
|
637 |
"/ although eaten, we still must care for the focus !! |
|
638 |
self wantsFocusWithButtonPress ifTrue:[ |
|
3503 | 639 |
self windowGroup notNil ifTrue:[ |
640 |
self windowGroup focusView:self. |
|
641 |
"/ Transcript showCR:self windowGroup focusCameByTab. |
|
642 |
] |
|
3495 | 643 |
]. |
3236 | 644 |
^ true |
869
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
645 |
! ! |
a1838cce9641
popup menu on space or return
Claus Gittinger <cg@exept.de>
parents:
853
diff
changeset
|
646 |
|
2499 | 647 |
!ComboView methodsFor:'initialization & release'! |
129 | 648 |
|
3236 | 649 |
destroy |
650 |
|wgrp| |
|
651 |
||
652 |
(wgrp := self windowGroup) notNil ifTrue:[ |
|
653 |
wgrp removePreEventHook:self. |
|
654 |
]. |
|
655 |
super destroy. |
|
656 |
! |
|
657 |
||
3825 | 658 |
initStyle |
659 |
super initStyle. |
|
660 |
||
661 |
self borderWidth:(EditField defaultBorderWidth). |
|
662 |
self borderColor:(EditField defaultBorderColor). |
|
663 |
! |
|
664 |
||
129 | 665 |
initialize |
2750 | 666 |
|prefExt leftInset rightInset prefWidth halfSpacing nm lvl| |
129 | 667 |
|
668 |
super initialize. |
|
308 | 669 |
|
304 | 670 |
listMsg := self class defaultListMessage. |
671 |
aspectMsg := self class defaultAspectMessage. |
|
672 |
changeMsg := self class defaultChangeMessage. |
|
129 | 673 |
|
674 |
self initializeField. |
|
3825 | 675 |
field origin:margin@margin corner:1.0@1.0. |
2136 | 676 |
self shadowColor:(field shadowColor). |
129 | 677 |
|
331 | 678 |
self initializeButton. |
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
679 |
pullDownButton pressAction:[self pullMenu]. |
280 | 680 |
prefExt := pullDownButton preferredExtent. |
681 |
prefWidth := prefExt x. |
|
682 |
||
129 | 683 |
pullDownButton origin:1.0@0.0 corner:1.0@1.0. |
217 | 684 |
styleSheet is3D ifTrue:[ |
280 | 685 |
halfSpacing := ViewSpacing // 2. |
5983 | 686 |
leftInset := rightInset := (prefWidth + halfSpacing). |
2750 | 687 |
(lvl := styleSheet at:#'comboView.level' default:nil) notNil ifTrue:[ |
688 |
self level:lvl. |
|
319 | 689 |
field level:0. |
690 |
field rightInset:margin. |
|
691 |
] ifFalse:[ |
|
692 |
pullDownButton rightInset:halfSpacing. |
|
693 |
field leftInset:halfSpacing |
|
694 |
]. |
|
217 | 695 |
] ifFalse:[ |
280 | 696 |
leftInset := prefWidth + pullDownButton borderWidth. |
697 |
rightInset := prefWidth. |
|
217 | 698 |
]. |
1125 | 699 |
|
3836 | 700 |
"/ what a hack... |
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
701 |
nm := styleSheet name. |
3836 | 702 |
(nm = #win95 or:[nm = #win98 or:[nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[ |
1125 | 703 |
field level:0. |
2750 | 704 |
lvl isNil ifTrue:[self level:-1]. |
1125 | 705 |
pullDownButton rightInset:0. |
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1633
diff
changeset
|
706 |
nm ~= #st80 ifTrue:[ |
3429
f2b4b84cd477
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3369
diff
changeset
|
707 |
leftInset := (ArrowButton new preferredWidth). |
1126 | 708 |
rightInset := leftInset. |
1125 | 709 |
]. |
710 |
field origin:0.0@0.0. |
|
2750 | 711 |
field leftInset:0. |
1125 | 712 |
"/ field topInset:1; bottomInset:1. |
2750 | 713 |
"/ nm = #winXP ifTrue:[ |
714 |
"/ self borderWidth:1. |
|
715 |
"/ self borderColor:(Color blue lightened). |
|
716 |
"/ ]. |
|
1125 | 717 |
]. |
1126 | 718 |
field rightInset:rightInset. |
280 | 719 |
pullDownButton leftInset:leftInset negated. |
5983 | 720 |
self initialHeight:(field preferredHeight + ViewSpacing). |
129 | 721 |
|
722 |
" |
|
723 |
|b| |
|
724 |
||
725 |
b := ComboBoxView new. |
|
726 |
b list:#('hello' 'world' 'this' 'is' 'st/x'). |
|
727 |
b open |
|
728 |
" |
|
729 |
||
5983 | 730 |
"Created: / 28-02-1996 / 15:03:17 / cg" |
731 |
"Modified: / 08-09-1998 / 20:33:22 / cg" |
|
732 |
"Modified: / 08-01-2019 / 14:16:03 / Claus Gittinger" |
|
331 | 733 |
! |
734 |
||
735 |
initializeButton |
|
2174
ab242e29da64
button init code made publicly available
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
736 |
pullDownButton := self class comboButtonFor:self. |
331 | 737 |
pullDownButton disable. |
738 |
! |
|
739 |
||
740 |
initializeField |
|
4972 | 741 |
"concrete subclass is responsible to instantiate |
742 |
a field widget here. |
|
743 |
For comboList, this will be a label; |
|
744 |
for comboBox, this will be an editfield" |
|
745 |
||
331 | 746 |
self subclassResponsibility |
747 |
||
748 |
"Created: 29.3.1997 / 11:17:14 / cg" |
|
2157 | 749 |
! |
750 |
||
3236 | 751 |
realize |
3238 | 752 |
|pullMenuIfClickedOnField wgrp| |
3236 | 753 |
|
754 |
super realize. |
|
755 |
||
3824 | 756 |
pullMenuIfClickedOnField := |
757 |
styleSheet |
|
758 |
at:#'comboView.pullMenuIfClickedOnField' |
|
759 |
default:[ OperatingSystem isMSWINDOWSlike ]. |
|
3236 | 760 |
|
761 |
pullMenuIfClickedOnField == true ifTrue:[ |
|
3238 | 762 |
wgrp := self windowGroup. |
763 |
wgrp notNil ifTrue:[ wgrp addPreEventHook:self ]. |
|
3236 | 764 |
]. |
765 |
! |
|
766 |
||
2157 | 767 |
release |
768 |
listHolder notNil ifTrue:[ |
|
769 |
listHolder removeDependent:self. |
|
770 |
listHolder := nil. |
|
771 |
]. |
|
772 |
super release |
|
129 | 773 |
! ! |
774 |
||
2406 | 775 |
!ComboView methodsFor:'menu interaction'! |
776 |
||
4564
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
777 |
createPullDownMenuForList:aList |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
778 |
"pull the menu - triggered from the button" |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
779 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
780 |
|menu index| |
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 |
comboMenuHolder notNil ifTrue:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
783 |
menu := (comboMenuHolder perform:comboMenuMessage ? #value). |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
784 |
(menu isKindOf:Menu) ifTrue:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
785 |
menu := MenuPanel new menu:menu. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
786 |
] |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
787 |
] ifFalse:[ |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
788 |
menu := MenuPanel new. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
789 |
menu doAccessCharacterTranslation:false. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
790 |
menu labels:aList. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
791 |
menu hideOnRelease:false. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
792 |
menu backgroundColor: field backgroundColor. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
793 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
794 |
index := 1. |
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 |
menu do:[:el | |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
797 |
el value:#select: argument:index. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
798 |
index := index + 1. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
799 |
]. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
800 |
menu receiver:self. |
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 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
803 |
menu font:self font. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
804 |
menu preferredWidth:self width. |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
805 |
|
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
806 |
^ menu |
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 |
"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
|
809 |
! |
be449e47ce4b
Fix in ComboView>>createPullDownMenuForList:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
4563
diff
changeset
|
810 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
811 |
deltaSelect:delta |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
812 |
"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
|
813 |
|
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
814 |
|newIndex| |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
815 |
|
3556
e7d87b5b3cf7
care for mouse-wheel deltaSelect: if list is empty
Claus Gittinger <cg@exept.de>
parents:
3503
diff
changeset
|
816 |
list size == 0 ifTrue:[^ self]. |
e7d87b5b3cf7
care for mouse-wheel deltaSelect: if list is empty
Claus Gittinger <cg@exept.de>
parents:
3503
diff
changeset
|
817 |
|
3369
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
818 |
newIndex := currentIndex + delta. |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
819 |
newIndex > list size ifTrue:[ |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
820 |
newIndex := 1. |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
821 |
] ifFalse:[ |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
822 |
newIndex <= 0 ifTrue:[ |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
823 |
newIndex := list size. |
9f8f7c5d328f
Correct selection behavior (start with line 1)
Stefan Vogel <sv@exept.de>
parents:
3365
diff
changeset
|
824 |
]. |
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 |
self select:newIndex. |
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 |
|
2406 | 830 |
pullMenu |
3281 | 831 |
"pull the menu - triggered from the button |
832 |
returns false if the menu cannot be opened" |
|
2406 | 833 |
|
3281 | 834 |
|menu origin opensMenu| |
2406 | 835 |
|
836 |
self getListFromModel. |
|
837 |
||
4227 | 838 |
opensMenu := ((list notEmptyOrNil or:[comboMenuHolder notNil]) |
839 |
and:[self enableChannel value]). |
|
3281 | 840 |
|
841 |
opensMenu ifTrue:[ |
|
2406 | 842 |
menu := self createPullDownMenuForList:list. |
4994 | 843 |
origin := device translatePoint:(0 @ self height) fromView:self toView:nil. |
4227 | 844 |
"/ menu extentChangedFlag:false. |
845 |
"/ menu originChangedFlag:false. |
|
846 |
menu showAt:origin resizing:false. |
|
2406 | 847 |
]. |
848 |
||
849 |
pullDownButton turnOff. |
|
3281 | 850 |
^ opensMenu |
2406 | 851 |
|
852 |
"Created: / 10.10.2001 / 14:47:25 / cg" |
|
853 |
"Modified: / 10.10.2001 / 15:04:44 / cg" |
|
854 |
! |
|
855 |
||
856 |
select:anIndex |
|
857 |
"sent from the popped menu, when an item was selected" |
|
858 |
||
859 |
self subclassResponsibility |
|
860 |
||
861 |
"Modified: 27.2.1997 / 15:19:07 / cg" |
|
862 |
! ! |
|
863 |
||
129 | 864 |
!ComboView methodsFor:'message delegation'! |
865 |
||
866 |
doesNotUnderstand:aMessage |
|
4824 | 867 |
"delegate to my field" |
868 |
||
129 | 869 |
(field respondsTo:aMessage selector) ifTrue:[ |
1207 | 870 |
^ aMessage sendTo:field |
129 | 871 |
]. |
872 |
^ super doesNotUnderstand:aMessage |
|
873 |
||
874 |
"Created: 28.2.1996 / 15:03:17 / cg" |
|
875 |
"Modified: 28.2.1996 / 15:06:09 / cg" |
|
166 | 876 |
! |
877 |
||
2300 | 878 |
flash |
4824 | 879 |
"delegate to my field" |
880 |
||
2300 | 881 |
field flash |
882 |
! |
|
883 |
||
5630 | 884 |
flash:messageOrNil withColor:flashColor |
4824 | 885 |
"delegate to my field" |
886 |
||
5630 | 887 |
field flash:messageOrNil withColor:flashColor |
888 |
||
889 |
"Modified (format): / 21-10-2017 / 23:13:39 / cg" |
|
4824 | 890 |
! |
891 |
||
166 | 892 |
respondsTo:aSymbol |
4824 | 893 |
"delegate to my field" |
894 |
||
166 | 895 |
^ (field respondsTo:aSymbol) or:[super respondsTo:aSymbol] |
896 |
||
897 |
"Created: 2.5.1996 / 16:57:34 / stefan" |
|
129 | 898 |
! ! |
899 |
||
214 | 900 |
!ComboView methodsFor:'private'! |
901 |
||
902 |
getListFromModel |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
903 |
"fetch the list - either from the listHolder, or |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
904 |
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
|
905 |
using #list." |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
906 |
|
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
907 |
listHolder notNil ifTrue:[ |
5352 | 908 |
"/ should blocks be evaluated when the pull-down list is actually needed? |
909 |
"/ listHolder isBlock ifFalse:[ |
|
910 |
self list:listHolder value |
|
911 |
"/ ] |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
912 |
] ifFalse:[ |
304 | 913 |
(model notNil and:[listMsg notNil]) ifTrue:[ |
914 |
(model respondsTo:listMsg) ifTrue:[ |
|
915 |
self list:(model perform:listMsg) |
|
277
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
916 |
] |
44eadbccc2b7
added support for a separate listHolder
Claus Gittinger <cg@exept.de>
parents:
276
diff
changeset
|
917 |
] |
214 | 918 |
]. |
919 |
||
920 |
"Created: 15.7.1996 / 12:22:56 / cg" |
|
304 | 921 |
"Modified: 26.2.1997 / 19:40:58 / cg" |
214 | 922 |
! |
923 |
||
924 |
getValueFromModel |
|
925 |
||
926 |
"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
|
927 |
! |
667132091c2f
ComboBox's inputField ought to use its default font.
Claus Gittinger <cg@exept.de>
parents:
1126
diff
changeset
|
928 |
|
1210
55f2c4209f94
oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
929 |
setFieldsFont:aFont |
55f2c4209f94
oops - only pull-button is disabled with empty list;
Claus Gittinger <cg@exept.de>
parents:
1207
diff
changeset
|
930 |
field font:aFont. |
214 | 931 |
! ! |
932 |
||
129 | 933 |
!ComboView methodsFor:'queries'! |
934 |
||
5949 | 935 |
computePreferredExtent |
285 | 936 |
"compute & return the boxes preferredExtent from the components' preferrences" |
937 |
||
683 | 938 |
|fieldPref buttonPref m menuPrefX menuPrefY w h| |
129 | 939 |
|
940 |
list isNil ifTrue:[ |
|
308 | 941 |
self getListFromModel |
942 |
]. |
|
943 |
||
944 |
list isNil ifTrue:[ |
|
683 | 945 |
menuPrefX := menuPrefY := 0 |
129 | 946 |
] ifFalse:[ |
4503 | 947 |
|graphicsDevice| |
948 |
||
4994 | 949 |
graphicsDevice := device ? Screen current. |
4503 | 950 |
m := (MenuView onDevice:graphicsDevice) labels:list. |
3429
f2b4b84cd477
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3369
diff
changeset
|
951 |
menuPrefX := m preferredWidth. |
1348 | 952 |
|
953 |
"/ the menuView returns rubbish ... |
|
954 |
"/ menuPrefY := (m preferredExtentForLines:1 cols:10) y |
|
955 |
||
956 |
"/ any non-strings ? |
|
957 |
menuPrefY := list |
|
958 |
inject:('X' heightOn:self) |
|
959 |
into:[:max :el | el isString ifTrue:[ |
|
960 |
max |
|
961 |
] ifFalse:[ |
|
962 |
max max:(el heightOn:self) |
|
963 |
] |
|
964 |
]. |
|
129 | 965 |
]. |
966 |
||
302
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
967 |
fieldPref := field preferredExtent. |
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
968 |
buttonPref := pullDownButton preferredExtent. |
8af5f51ce7a5
preferredExtent is sum of menu + button
Claus Gittinger <cg@exept.de>
parents:
285
diff
changeset
|
969 |
|
319 | 970 |
w := ((fieldPref x max:menuPrefX) max:50) + buttonPref x. |
971 |
w := w + margin + margin. |
|
683 | 972 |
h := (fieldPref y max:buttonPref y) max:menuPrefY. |
319 | 973 |
h := h + margin + margin. |
974 |
^ w @ h |
|
129 | 975 |
|
5949 | 976 |
"Created: / 09-11-2018 / 19:49:42 / Claus Gittinger" |
129 | 977 |
! ! |
978 |
||
4832 | 979 |
!ComboView methodsFor:'testing'! |
980 |
||
981 |
isComboView |
|
982 |
^ true |
|
983 |
! ! |
|
984 |
||
263
865b7d99d3f5
added an example for a menu-pull-hook
Claus Gittinger <cg@exept.de>
parents:
247
diff
changeset
|
985 |
!ComboView class methodsFor:'documentation'! |
129 | 986 |
|
987 |
version |
|
4824 | 988 |
^ '$Header$' |
3777
83c52227471d
changed: #createPullDownMenuForList:
Claus Gittinger <cg@exept.de>
parents:
3755
diff
changeset
|
989 |
! |
83c52227471d
changed: #createPullDownMenuForList:
Claus Gittinger <cg@exept.de>
parents:
3755
diff
changeset
|
990 |
|
83c52227471d
changed: #createPullDownMenuForList:
Claus Gittinger <cg@exept.de>
parents:
3755
diff
changeset
|
991 |
version_CVS |
4824 | 992 |
^ '$Header$' |
129 | 993 |
! ! |
4180 | 994 |