author | Claus Gittinger <cg@exept.de> |
Sat, 18 Jan 2020 15:37:54 +0100 | |
changeset 6209 | 76d74a400d6b |
parent 6178 | 4227070538b7 |
child 6237 | 12ad20ee2671 |
permissions | -rw-r--r-- |
6154 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1281 | 3 |
" |
4 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
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 |
" |
|
1830 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
4728 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
1224 | 18 |
View subclass:#ExtendedComboBox |
3134 | 19 |
instanceVariableNames:'menuButton menuField menuWrapper adjust menuWidgetHolder |
20 |
menuWidget menuHeight openAction isReadOnly closeOnSelect |
|
21 |
menuExtent usePreferredWidthForMenu hasHorizontalScrollBar |
|
22 |
hasVerticalScrollBar miniScrollerHorizontal miniScrollerVertical |
|
23 |
autoHideScrollBars' |
|
24 |
classVariableNames:'' |
|
25 |
poolDictionaries:'' |
|
26 |
category:'Views-Interactors' |
|
1179 | 27 |
! |
28 |
||
1273 | 29 |
PopUpView subclass:#MenuWrapper |
3134 | 30 |
instanceVariableNames:'comboBox widget lastPointerView implicitGrabView eventHandler |
31 |
resizeCursor restoreCursor' |
|
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
privateIn:ExtendedComboBox |
|
1179 | 35 |
! |
36 |
||
1224 | 37 |
!ExtendedComboBox class methodsFor:'documentation'! |
38 |
||
1281 | 39 |
copyright |
40 |
" |
|
41 |
COPYRIGHT (c) 1998 by eXept Software AG |
|
42 |
All Rights Reserved |
|
43 |
||
44 |
This software is furnished under a license and may be used |
|
45 |
only in accordance with the terms of that license and with the |
|
46 |
inclusion of the above copyright notice. This software may not |
|
47 |
be provided or otherwise made available to, or used by, any |
|
48 |
other person. No title to or ownership of the software is |
|
49 |
hereby transferred. |
|
50 |
" |
|
51 |
||
52 |
||
53 |
! |
|
54 |
||
55 |
documentation |
|
56 |
" |
|
57 |
An ExtendedComboBox looks much like a ComboBox, but allows for any view |
|
5443 | 58 |
to be popped up |
59 |
(in contrast to a ComboBox, which has a hardWired selectionInListmenu). |
|
60 |
||
1281 | 61 |
The popped view may optionally be decorated with scrollBars. |
62 |
As a side effect, an ExtendedComboBox with a SelectionInListView or Menu |
|
63 |
can now be used as a replacement for ComboBoxes when long-lists are to be shown, |
|
5443 | 64 |
since those can now be scrolled or defined as hierarchical lists. |
1281 | 65 |
|
66 |
[author:] |
|
67 |
Claus Atzkern |
|
68 |
||
69 |
[see also:] |
|
70 |
ComboBox ComboView |
|
71 |
PopUpList SelectionInListView |
|
72 |
ComboListView |
|
73 |
PullDownMenu Label EntryField |
|
74 |
" |
|
75 |
! |
|
76 |
||
1224 | 77 |
examples |
78 |
" |
|
6178 | 79 |
example: SelectionInListView |
1224 | 80 |
[exBegin] |
81 |
|top menu widget list sidx| |
|
82 |
||
83 |
top := StandardSystemView extent:200@35. |
|
84 |
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top. |
|
85 |
list := #('foo' 'bar' 'baz' 'hjh' 'kk' 'claus' 'gjhj'). |
|
86 |
sidx := 4. |
|
87 |
menu bottomInset:(menu preferredExtent y negated). |
|
88 |
menu contents:(list at:sidx). |
|
89 |
||
90 |
widget := SelectionInListView new. |
|
91 |
widget list:list. |
|
92 |
widget doubleClickAction:[:i| menu contents:(widget at:i) ]. |
|
93 |
widget selection:sidx. |
|
94 |
menu menuWidget:widget. |
|
95 |
top open. |
|
96 |
[exEnd] |
|
97 |
||
98 |
||
99 |
||
6178 | 100 |
example: FileSelectionTree |
1224 | 101 |
[exBegin] |
102 |
|top menu widget| |
|
103 |
||
104 |
top := StandardSystemView extent:200@35. |
|
105 |
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top. |
|
106 |
menu bottomInset:(menu preferredExtent y negated). |
|
107 |
||
108 |
widget := FileSelectionTree new. |
|
109 |
widget directory:(Filename homeDirectory). |
|
110 |
||
111 |
widget doubleClickAction:[:i||n| |
|
112 |
n := widget selectedNode. |
|
113 |
n isDirectory ifFalse:[menu contents:(n pathName)] |
|
114 |
]. |
|
115 |
menu menuHeight:400. |
|
116 |
menu menuWidget:widget. |
|
117 |
top open. |
|
118 |
[exEnd] |
|
119 |
||
120 |
||
121 |
||
6178 | 122 |
example: SelectionInTreeView |
1224 | 123 |
[exBegin] |
124 |
|top menu widget| |
|
125 |
||
126 |
top := StandardSystemView extent:200@35. |
|
127 |
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top. |
|
128 |
menu bottomInset:(menu preferredExtent y negated). |
|
129 |
menu contents:'foo'. |
|
130 |
||
131 |
widget := SelectionInTreeView new. |
|
132 |
widget root:(TreeItem newAsTreeFromSmalltalkClass:Object). |
|
133 |
||
134 |
widget doubleClickAction:[:i||n| |
|
135 |
n := widget selectedNode. |
|
136 |
n hasChildren ifFalse:[menu contents:(n name)] |
|
137 |
]. |
|
138 |
menu menuHeight:300. |
|
139 |
menu menuWidget:widget. |
|
140 |
top open. |
|
141 |
[exEnd] |
|
142 |
||
6178 | 143 |
example: a menu from elsewhere |
144 |
[exBegin] |
|
145 |
|top menu widget models| |
|
146 |
||
147 |
models := Expecco::Browser openBrowsers |
|
148 |
collectAll:[:b | b project |
|
149 |
ifNil:[#()] |
|
150 |
ifNotNil:[:p | p allBlockDescriptions]]. |
|
151 |
||
152 |
top := StandardSystemView extent:250@35. |
|
153 |
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top. |
|
154 |
menu bottomInset:(menu preferredExtent y negated). |
|
155 |
menu contents:'lets do the timeWarp again...'. |
|
156 |
||
157 |
widget := Workflow::AbstractEditor |
|
158 |
dataTypeMenuFor:models receiver:nil selector:[:type | menu contents:type] |
|
159 |
editorSelector:nil |
|
160 |
withTemplateTypes:false |
|
161 |
withUserTypeDefinition:false |
|
162 |
forFreeze:false. |
|
163 |
menu menuWidget:widget. |
|
164 |
top open. |
|
165 |
[exEnd] |
|
166 |
||
167 |
||
168 |
example: Funny |
|
1282
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
169 |
[exBegin] |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
170 |
|top menu widget| |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
171 |
|
5443 | 172 |
Smalltalk loadPackage:'stx:libwidg3'. |
1282
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
173 |
top := StandardSystemView extent:250@35. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
174 |
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
175 |
menu bottomInset:(menu preferredExtent y negated). |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
176 |
menu contents:'lets do the timeWarp again...'. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
177 |
|
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
178 |
widget := ClockView new. |
6178 | 179 |
menu menuHeight:[menu width]. |
1282
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
180 |
menu menuWidget:widget. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
181 |
top open. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
182 |
[exEnd] |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
183 |
|
1285
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
184 |
|
6178 | 185 |
example: Funny - again |
1285
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
186 |
(use widgets pref-width; even if the combo-box is smaller) |
1282
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
187 |
[exBegin] |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
188 |
|top menu widget| |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
189 |
|
1284 | 190 |
top := StandardSystemView extent:80@35. |
1282
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
191 |
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
192 |
menu bottomInset:(menu preferredExtent y negated). |
1284 | 193 |
menu contents:'time...'. |
1282
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
194 |
|
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
195 |
widget := ClockView new. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
196 |
menu menuWidget:widget. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
197 |
menu usePreferredWidthForMenu:true. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
198 |
top open. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
199 |
[exEnd] |
1224 | 200 |
|
1285
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
201 |
|
6178 | 202 |
example: Funny - again |
1285
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
203 |
(use widgets pref-width; even if the combo-box is smaller, |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
204 |
adjust the height for the width) |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
205 |
[exBegin] |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
206 |
|top menu widget| |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
207 |
|
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
208 |
top := StandardSystemView extent:80@35. |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
209 |
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top. |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
210 |
menu bottomInset:(menu preferredExtent y negated). |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
211 |
menu contents:'time...'. |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
212 |
|
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
213 |
widget := ClockView new. |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
214 |
menu menuWidget:widget. |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
215 |
menu usePreferredWidthForMenu:true. |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
216 |
menu menuHeight:[widget width]. |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
217 |
top open. |
839acde3f42c
fixed width when usePrefWidgetWidth is true
Claus Gittinger <cg@exept.de>
parents:
1284
diff
changeset
|
218 |
[exEnd] |
1406 | 219 |
|
6178 | 220 |
example: Subcanvas with a spec |
1406 | 221 |
[exBegin] |
222 |
|top menu widget list sidx spec| |
|
223 |
||
224 |
spec := #(#FullSpec |
|
225 |
#window: |
|
226 |
#(#WindowSpec |
|
227 |
#name: 'Define Color' |
|
228 |
#layout: #(#LayoutFrame 13 0 29 0 352 0 159 0) |
|
229 |
#label: 'Define Color' |
|
230 |
#min: #(#Point 340 110) |
|
231 |
#max: #(#Point 1152 900) |
|
232 |
#bounds: #(#Rectangle 13 29 353 160) |
|
233 |
#usePreferredExtent: false |
|
234 |
) |
|
235 |
#component: |
|
236 |
#(#SpecCollection |
|
237 |
#collection: |
|
238 |
#( |
|
239 |
#(#VerticalPanelViewSpec |
|
240 |
#name: 'VerticalPanel1' |
|
241 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 58 0 -40 1.0) |
|
242 |
#component: |
|
243 |
#(#SpecCollection |
|
244 |
#collection: |
|
245 |
#( |
|
246 |
#(#LabelSpec |
|
247 |
#name: 'RedLabel' |
|
248 |
#label: 'Red:' |
|
249 |
#translateLabel: true |
|
250 |
#adjust: #right |
|
251 |
#extent: #(#Point 58 26) |
|
252 |
) |
|
253 |
#(#LabelSpec |
|
254 |
#name: 'GreenLabel' |
|
255 |
#label: 'Green:' |
|
256 |
#translateLabel: true |
|
257 |
#adjust: #right |
|
258 |
#extent: #(#Point 58 27) |
|
259 |
) |
|
260 |
#(#LabelSpec |
|
261 |
#name: 'BlueLabel' |
|
262 |
#label: 'Blue:' |
|
263 |
#translateLabel: true |
|
264 |
#adjust: #right |
|
265 |
#extent: #(#Point 58 26) |
|
266 |
) |
|
267 |
) |
|
268 |
) |
|
269 |
#horizontalLayout: #fit |
|
270 |
#verticalLayout: #fitSpace |
|
271 |
#horizontalSpace: 3 |
|
272 |
#verticalSpace: 3 |
|
273 |
) |
|
274 |
#(#VerticalPanelViewSpec |
|
275 |
#name: 'VerticalPanel2' |
|
276 |
#layout: #(#LayoutFrame 60 0 0 0.0 -160 1.0 -40 1.0) |
|
277 |
#component: |
|
278 |
#(#SpecCollection |
|
279 |
#collection: |
|
280 |
#( |
|
281 |
#(#SliderSpec |
|
282 |
#name: 'RedSlider' |
|
283 |
#tabable: true |
|
284 |
#model: #red |
|
285 |
#orientation: #horizontal |
|
286 |
#stop: 255 |
|
287 |
#step: 1 |
|
288 |
#backgroundColor: #(#Color 100.0 0.0 0.0) |
|
289 |
#extent: #(#Point 118 16) |
|
290 |
) |
|
291 |
#(#SliderSpec |
|
292 |
#name: 'GreenSlider' |
|
293 |
#tabable: true |
|
294 |
#model: #green |
|
295 |
#orientation: #horizontal |
|
296 |
#stop: 255 |
|
297 |
#step: 1 |
|
298 |
#backgroundColor: #(#Color 0.0 100.0 0.0) |
|
299 |
#extent: #(#Point 118 16) |
|
300 |
) |
|
301 |
#(#SliderSpec |
|
302 |
#name: 'BlueSlider' |
|
303 |
#tabable: true |
|
304 |
#model: #blue |
|
305 |
#orientation: #horizontal |
|
306 |
#stop: 255 |
|
307 |
#step: 1 |
|
308 |
#backgroundColor: #(#Color 0.0 0.0 100.0) |
|
309 |
#extent: #(#Point 118 16) |
|
310 |
) |
|
311 |
) |
|
312 |
) |
|
313 |
#horizontalLayout: #fit |
|
314 |
#verticalLayout: #spreadSpace |
|
315 |
#horizontalSpace: 3 |
|
316 |
#verticalSpace: 3 |
|
317 |
) |
|
318 |
#(#VerticalPanelViewSpec |
|
319 |
#name: 'VerticalPanel3' |
|
320 |
#layout: #(#LayoutFrame -158 1 0 0.0 -120 1 -40 1.0) |
|
321 |
#component: |
|
322 |
#(#SpecCollection |
|
323 |
#collection: |
|
324 |
#( |
|
325 |
#(#InputFieldSpec |
|
326 |
#name: 'RedField' |
|
327 |
#model: #red |
|
328 |
#type: #numberInRange |
|
329 |
#numChars: 3 |
|
330 |
#minValue: 0 |
|
331 |
#maxValue: 255 |
|
332 |
#extent: #(#Point 38 20) |
|
333 |
) |
|
334 |
#(#InputFieldSpec |
|
335 |
#name: 'GreenField' |
|
336 |
#model: #green |
|
337 |
#type: #numberInRange |
|
338 |
#numChars: 3 |
|
339 |
#minValue: 0 |
|
340 |
#maxValue: 255 |
|
341 |
#extent: #(#Point 38 20) |
|
342 |
) |
|
343 |
#(#InputFieldSpec |
|
344 |
#name: 'BlueField' |
|
345 |
#model: #blue |
|
346 |
#type: #numberInRange |
|
347 |
#numChars: 3 |
|
348 |
#minValue: 0 |
|
349 |
#maxValue: 255 |
|
350 |
#extent: #(#Point 38 20) |
|
351 |
) |
|
352 |
) |
|
353 |
) |
|
354 |
#horizontalLayout: #fit |
|
355 |
#verticalLayout: #spreadSpace |
|
356 |
#horizontalSpace: 3 |
|
357 |
#verticalSpace: 3 |
|
358 |
) |
|
359 |
#(#LabelSpec |
|
360 |
#name: 'PreviewBox' |
|
361 |
#layout: #(#LayoutFrame -116 1 0 0.0 -2 1.0 -40 1.0) |
|
362 |
#label: 'Preview' |
|
363 |
#translateLabel: true |
|
364 |
#level: -1 |
|
365 |
) |
|
366 |
#(#HorizontalPanelViewSpec |
|
367 |
#name: 'HorizontalPanel1' |
|
368 |
#layout: #(#LayoutFrame 0 0.0 -32 1 0 1.0 0 1.0) |
|
369 |
#component: |
|
370 |
#(#SpecCollection |
|
371 |
#collection: |
|
372 |
#( |
|
373 |
#(#ActionButtonSpec |
|
374 |
#name: 'CancelButton' |
|
375 |
#label: 'Cancel' |
|
376 |
#translateLabel: true |
|
4729 | 377 |
#model: #doCancel |
1406 | 378 |
#extent: #(#Point 165 26) |
379 |
) |
|
380 |
#(#ActionButtonSpec |
|
381 |
#name: 'OKButton' |
|
382 |
#label: 'OK' |
|
383 |
#translateLabel: true |
|
4729 | 384 |
#model: #doAccept |
1406 | 385 |
#extent: #(#Point 166 26) |
386 |
) |
|
387 |
) |
|
388 |
) |
|
389 |
#horizontalLayout: #fitSpace |
|
390 |
#verticalLayout: #centerMax |
|
391 |
#horizontalSpace: 3 |
|
392 |
#verticalSpace: 3 |
|
393 |
) |
|
394 |
) |
|
395 |
) |
|
396 |
). |
|
397 |
||
398 |
top := StandardSystemView extent:200@35. |
|
399 |
menu := ExtendedComboBox origin:5 @ 5 corner:1.0 @ 0.0 in:top. |
|
400 |
list := #('foo' 'bar' 'baz' 'hjh' 'kk' 'claus' 'gjhj'). |
|
401 |
sidx := 4. |
|
402 |
menu bottomInset:(menu preferredExtent y negated). |
|
403 |
menu contents:(list at:sidx). |
|
404 |
||
405 |
widget := SubCanvas new. |
|
4729 | 406 |
widget client:(SimpleDialog new). |
1406 | 407 |
widget spec:spec. |
408 |
menu menuWidget:widget. |
|
409 |
top open. |
|
410 |
[exEnd] |
|
411 |
||
412 |
||
413 |
||
414 |
||
1224 | 415 |
" |
416 |
! ! |
|
1179 | 417 |
|
418 |
!ExtendedComboBox methodsFor:'accessing'! |
|
419 |
||
1224 | 420 |
contents |
4833 | 421 |
"return the value of the field (the model's value)" |
2899 | 422 |
|
4833 | 423 |
model isNil ifTrue:[ |
424 |
^ menuField contents |
|
425 |
]. |
|
1224 | 426 |
^ model value |
427 |
! |
|
1179 | 428 |
|
1224 | 429 |
contents:aValue |
2899 | 430 |
"set the value of the field (the models value)" |
431 |
||
3629 | 432 |
model notNil ifTrue:[ |
433 |
model value:aValue. |
|
434 |
] |
|
1224 | 435 |
! |
1179 | 436 |
|
3134 | 437 |
menuExtent |
438 |
^ menuExtent |
|
439 |
! |
|
440 |
||
441 |
menuExtent:anExtent |
|
442 |
menuExtent := anExtent. |
|
443 |
||
444 |
anExtent notNil ifTrue:[ |
|
445 |
menuHeight := nil. |
|
446 |
] ifFalse:[ |
|
447 |
menuHeight := anExtent y max:50. |
|
448 |
]. |
|
449 |
usePreferredWidthForMenu := true. |
|
450 |
! |
|
451 |
||
1224 | 452 |
menuWidget |
2899 | 453 |
"get the menu widget or nil" |
454 |
||
1224 | 455 |
^ menuWidget |
1179 | 456 |
! |
457 |
||
2903 | 458 |
menuWidget:aWidgetOrFilenameOrSequenceableCollectionOrNil |
6178 | 459 |
"set the menu widget or nil. |
460 |
In addition (this is a hack), a fileName, seqCollection or menu |
|
461 |
can be given. In those cases, a corresponding widget is created on the fly and set." |
|
2899 | 462 |
|
2903 | 463 |
menuWidget ~~ aWidgetOrFilenameOrSequenceableCollectionOrNil ifTrue:[ |
1224 | 464 |
menuWrapper notNil ifTrue:[ |
465 |
self closeMenu. |
|
466 |
menuWrapper destroy. |
|
467 |
menuWrapper := nil. |
|
468 |
]. |
|
2903 | 469 |
aWidgetOrFilenameOrSequenceableCollectionOrNil isView ifTrue:[ |
470 |
menuWidget := aWidgetOrFilenameOrSequenceableCollectionOrNil. |
|
2013
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
471 |
^ self |
1868 | 472 |
]. |
2903 | 473 |
aWidgetOrFilenameOrSequenceableCollectionOrNil isFilename ifTrue:[ |
474 |
self setupMenuWidgetForDirectory:aWidgetOrFilenameOrSequenceableCollectionOrNil. |
|
475 |
^ self |
|
1868 | 476 |
]. |
2903 | 477 |
aWidgetOrFilenameOrSequenceableCollectionOrNil isSequenceable ifTrue:[ |
478 |
self setupMenuWidgetForList:aWidgetOrFilenameOrSequenceableCollectionOrNil. |
|
479 |
^ self |
|
480 |
]. |
|
6178 | 481 |
(aWidgetOrFilenameOrSequenceableCollectionOrNil isKindOf:Menu) ifTrue:[ |
482 |
self setupMenuWidgetForMenu:aWidgetOrFilenameOrSequenceableCollectionOrNil. |
|
483 |
^ self |
|
484 |
]. |
|
2904 | 485 |
|
486 |
aWidgetOrFilenameOrSequenceableCollectionOrNil isNil ifTrue:[ |
|
487 |
menuWidget := aWidgetOrFilenameOrSequenceableCollectionOrNil. |
|
488 |
^ self |
|
489 |
]. |
|
2903 | 490 |
self error:'invalid menuWidget' |
1224 | 491 |
]. |
492 |
! ! |
|
493 |
||
1274 | 494 |
!ExtendedComboBox methodsFor:'accessing-actions'! |
1179 | 495 |
|
1274 | 496 |
openAction |
2899 | 497 |
"returns the action, called before opening the pulldown menu" |
498 |
||
1274 | 499 |
^ openAction |
1179 | 500 |
! |
501 |
||
1274 | 502 |
openAction:aOneArgBlock |
2899 | 503 |
"set the action, called before opening the pulldown menu; |
504 |
the argument to the action is the menu widget" |
|
505 |
||
1274 | 506 |
openAction := aOneArgBlock |
1224 | 507 |
! ! |
508 |
||
509 |
!ExtendedComboBox methodsFor:'accessing-behavior'! |
|
1179 | 510 |
|
2411 | 511 |
closeOnSelect |
2899 | 512 |
"if true, then the comboList is closed when the model value/selection changed" |
513 |
||
2411 | 514 |
^ closeOnSelect |
515 |
! |
|
516 |
||
517 |
closeOnSelect:aBoolean |
|
2899 | 518 |
"if true, then the comboList is closed when the model value/selection changed" |
519 |
||
2411 | 520 |
closeOnSelect := aBoolean. |
521 |
! |
|
522 |
||
1224 | 523 |
disable |
2899 | 524 |
"disable me and my components" |
525 |
||
1224 | 526 |
self closeMenu. |
527 |
||
2461 | 528 |
menuField disable. |
529 |
menuButton disable. |
|
1224 | 530 |
! |
1179 | 531 |
|
1224 | 532 |
enable |
2899 | 533 |
"enable me and my components" |
534 |
||
2461 | 535 |
menuField enable. |
1224 | 536 |
menuButton enable |
1179 | 537 |
! |
538 |
||
1224 | 539 |
enabled |
2899 | 540 |
"returns true, if enabled" |
541 |
||
1224 | 542 |
^ menuButton enabled |
2462 | 543 |
! |
544 |
||
545 |
readOnly |
|
2899 | 546 |
"returns true if the menuField is readonly" |
547 |
||
2462 | 548 |
^ isReadOnly |
549 |
! |
|
550 |
||
551 |
readOnly:aBoolean |
|
2899 | 552 |
"set the menuField to be readonly or writable" |
553 |
||
2462 | 554 |
isReadOnly == aBoolean ifTrue:[ ^ self ]. |
555 |
||
556 |
isReadOnly := aBoolean. |
|
557 |
||
558 |
menuField isNil ifTrue:[ |
|
559 |
self createEditField. |
|
560 |
]. |
|
561 |
||
562 |
menuField readOnly:aBoolean. |
|
1224 | 563 |
! ! |
564 |
||
2903 | 565 |
!ExtendedComboBox methodsFor:'accessing-bg & border'! |
566 |
||
567 |
backgroundColor |
|
568 |
"get the background color of the menu field" |
|
569 |
||
570 |
^ menuField backgroundColor |
|
571 |
! |
|
572 |
||
573 |
backgroundColor:aColor |
|
574 |
"set the background color of the menu field" |
|
575 |
||
576 |
menuField backgroundColor:aColor |
|
577 |
! |
|
578 |
||
579 |
foregroundColor |
|
580 |
"return the foreground color of the menu field" |
|
581 |
||
582 |
^ menuField foregroundColor |
|
583 |
! |
|
584 |
||
585 |
foregroundColor:aColor |
|
586 |
"set the foreground color of the menu field" |
|
587 |
||
588 |
menuField foregroundColor:aColor |
|
589 |
! ! |
|
590 |
||
1224 | 591 |
!ExtendedComboBox methodsFor:'accessing-channels'! |
592 |
||
593 |
enableChannel |
|
2899 | 594 |
"return a valueHolder for enable/disable" |
595 |
||
1224 | 596 |
^ menuButton enableChannel |
597 |
! |
|
598 |
||
599 |
enableChannel:aValueHolder |
|
2899 | 600 |
"set a valueHolder for enable/disable" |
601 |
||
2461 | 602 |
menuField enableChannel:aValueHolder. |
1224 | 603 |
menuButton enableChannel:aValueHolder. |
604 |
! |
|
1179 | 605 |
|
1224 | 606 |
menuWidgetHolder |
2899 | 607 |
"returns the menu widget or nil" |
608 |
||
1224 | 609 |
^ menuWidgetHolder |
610 |
! |
|
611 |
||
612 |
menuWidgetHolder:aHolder |
|
2899 | 613 |
"returns the menu widget or nil" |
614 |
||
1224 | 615 |
menuWidgetHolder notNil ifTrue:[ |
616 |
menuWidgetHolder removeDependent:self |
|
617 |
]. |
|
2903 | 618 |
menuWidgetHolder := aHolder. |
619 |
menuWidgetHolder notNil ifTrue:[ |
|
1224 | 620 |
menuWidgetHolder addDependent:self |
621 |
]. |
|
2903 | 622 |
|
1224 | 623 |
self menuWidget:(menuWidgetHolder value). |
624 |
! |
|
625 |
||
626 |
model:aModel |
|
2899 | 627 |
"set the model" |
628 |
||
1224 | 629 |
super model:(aModel ? ValueHolder new). |
630 |
menuField notNil ifTrue:[ menuField model:model ]. |
|
1179 | 631 |
! ! |
632 |
||
1848 | 633 |
!ExtendedComboBox methodsFor:'accessing-components'! |
634 |
||
2461 | 635 |
editor |
636 |
^ menuField |
|
637 |
! |
|
638 |
||
5575 | 639 |
menuButton |
640 |
"return the menuButton component" |
|
641 |
||
642 |
^ menuButton |
|
643 |
||
644 |
"Created: 28.2.1996 / 15:03:14 / cg" |
|
645 |
! |
|
646 |
||
1848 | 647 |
menuField |
2707 | 648 |
<resource: #obsolete> |
2899 | 649 |
|
2461 | 650 |
self obsoleteMethodWarning:'Use #editor for ComboBox compatibility'. |
1848 | 651 |
^ menuField |
1857 | 652 |
! |
653 |
||
654 |
menuHolder:anObject |
|
655 |
"change the one that provides the menu (via menuMsg)." |
|
656 |
||
657 |
super menuHolder:anObject. |
|
2461 | 658 |
menuField notNil ifTrue:[ |
1857 | 659 |
menuField menuHolder:anObject |
660 |
] |
|
1848 | 661 |
! ! |
662 |
||
1274 | 663 |
!ExtendedComboBox methodsFor:'accessing-default menus'! |
664 |
||
665 |
directory:aDirectory |
|
3646 | 666 |
<resource: #obsolete> |
2903 | 667 |
"creates a FileSelectionTree as menuWidget - menu, setting the root to the directory" |
668 |
||
669 |
self obsoleteMethodWarning:'use #setupMenuWidgetForDirectory:'. |
|
670 |
self setupMenuWidgetForDirectory:aDirectory |
|
671 |
! |
|
672 |
||
673 |
list:aList |
|
3646 | 674 |
<resource: #obsolete> |
2903 | 675 |
"creates a SelectionInListView as menuWidget - menu setting the list" |
676 |
||
677 |
self obsoleteMethodWarning:'use #setupMenuWidgetForList:'. |
|
678 |
self setupMenuWidgetForList:aList |
|
679 |
! |
|
680 |
||
681 |
setupMenuWidgetForDirectory:aDirectory |
|
682 |
"creates a FileSelectionTree as menuWidget - setting the root to the directory" |
|
2899 | 683 |
|
1274 | 684 |
menuWidget isNil ifTrue:[ |
685 |
self autoHideScrollBars:false. |
|
686 |
menuWidget := FileSelectionTree new. |
|
687 |
||
688 |
menuWidget doubleClickAction:[:aDummy||node| |
|
689 |
node := menuWidget selectedNode. |
|
690 |
||
691 |
node isDirectory ifFalse:[ |
|
692 |
self contents:(node pathName) |
|
693 |
] |
|
694 |
] |
|
695 |
]. |
|
696 |
self menuHeight:400. |
|
697 |
menuWidget directory:aDirectory. |
|
698 |
! |
|
699 |
||
2903 | 700 |
setupMenuWidgetForList:aList |
701 |
"creates a SelectionInListView as menuWidget - menu setting the list" |
|
2899 | 702 |
|
1274 | 703 |
menuWidget isNil ifTrue:[ |
4992 | 704 |
menuWidget := SelectionInListView onDevice:(device ? Screen current). |
1274 | 705 |
|
706 |
menuWidget doubleClickAction:[:anIndex| |
|
707 |
self contents:(menuWidget at:anIndex) |
|
708 |
] |
|
709 |
]. |
|
710 |
menuWidget list:aList |
|
6178 | 711 |
! |
712 |
||
713 |
setupMenuWidgetForMenu:aMenu |
|
714 |
"creates a MenuView as menuWidget" |
|
715 |
||
716 |
menuWidget isNil ifTrue:[ |
|
717 |
menuWidget := MenuPanel new. |
|
718 |
menuWidget verticalLayout:true. |
|
719 |
"/ menuWidget doubleClickAction:[:anIndex| |
|
720 |
"/ self contents:(menuWidget at:anIndex) |
|
721 |
"/ ] |
|
722 |
]. |
|
723 |
menuWidget menu:aMenu |
|
1274 | 724 |
! ! |
725 |
||
1179 | 726 |
!ExtendedComboBox methodsFor:'accessing-dimension'! |
727 |
||
5944 | 728 |
computePreferredExtent |
2899 | 729 |
"compute & return the preferredExtent from the components' preferrences" |
730 |
||
1224 | 731 |
|fieldPref buttonPref m w h f| |
1179 | 732 |
|
1224 | 733 |
fieldPref := menuField preferredExtent. |
734 |
buttonPref := menuButton preferredExtent. |
|
4498 | 735 |
f := 2 + gc font maxHeight + (gc font maxDescent * 2) + (menuField margin * 2). |
1224 | 736 |
h := (fieldPref y max:f) max:buttonPref y. |
737 |
m := margin max:1. |
|
738 |
h := h + m + m. |
|
1179 | 739 |
|
1224 | 740 |
w := (fieldPref x max:100) + buttonPref x. |
1179 | 741 |
|
1224 | 742 |
menuWidget notNil ifTrue:[ |
3420
d112104710bb
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3289
diff
changeset
|
743 |
f := menuWidget preferredWidth "widthOfContents" + buttonPref x + 20. |
1224 | 744 |
w := f max:w |
1179 | 745 |
]. |
1224 | 746 |
w := w + margin + margin. |
1179 | 747 |
|
1224 | 748 |
^ w @ h |
5944 | 749 |
|
750 |
"Created: / 09-11-2018 / 19:52:16 / Claus Gittinger" |
|
751 |
! |
|
752 |
||
753 |
menuHeight |
|
754 |
"get the maximum height of the menu widget or nil" |
|
755 |
||
756 |
^ menuHeight |
|
757 |
! |
|
758 |
||
759 |
menuHeight:aHeight |
|
760 |
"set the maximum height of the menu widget or nil" |
|
761 |
||
762 |
menuHeight := aHeight. |
|
1179 | 763 |
! |
764 |
||
1224 | 765 |
usePreferredWidthForMenu |
2899 | 766 |
"returns true if the menu is to be opened with its menu preferred width" |
767 |
||
1224 | 768 |
^ usePreferredWidthForMenu |
1179 | 769 |
! |
770 |
||
1224 | 771 |
usePreferredWidthForMenu:aBoolean |
2899 | 772 |
"open the menu with its preferred width" |
773 |
||
1224 | 774 |
usePreferredWidthForMenu := aBoolean |
1179 | 775 |
! ! |
776 |
||
1224 | 777 |
!ExtendedComboBox methodsFor:'accessing-look'! |
1179 | 778 |
|
1224 | 779 |
adjust |
2899 | 780 |
"returns the button-adjust symbol, which is one of |
781 |
#left -> left adjust |
|
782 |
#right -> right adjust" |
|
783 |
||
1272 | 784 |
^ adjust ? #right |
1179 | 785 |
! |
786 |
||
1224 | 787 |
adjust:how |
2899 | 788 |
"set the button-adjust, which must be one of |
789 |
#left -> left adjust |
|
790 |
#right -> right adjust" |
|
791 |
||
1224 | 792 |
|rightInset| |
1179 | 793 |
|
1224 | 794 |
(adjust ~~ how and:[(how == #left or:[how == #right])]) ifTrue:[ |
795 |
(adjust := how) == #left ifTrue:[ |
|
796 |
menuButton origin:0.0@0.0 corner:0.0@1.0 |
|
797 |
] ifFalse:[ |
|
798 |
menuButton origin:1.0@0.0 corner:1.0@1.0 |
|
799 |
]. |
|
1179 | 800 |
|
1224 | 801 |
rightInset := menuButton leftInset. |
6087 | 802 |
menuButton leftInset:(menuButton rightInset) rightInset:rightInset. |
1179 | 803 |
|
1224 | 804 |
rightInset := menuField leftInset. |
805 |
menuField leftInset:(menuField rightInset). |
|
806 |
menuField rightInset:rightInset. |
|
807 |
]. |
|
6087 | 808 |
|
809 |
"Modified: / 16-07-2019 / 16:37:32 / Claus Gittinger" |
|
1179 | 810 |
! |
811 |
||
1224 | 812 |
font:aFont |
2899 | 813 |
"set the font of the menu field" |
814 |
||
1224 | 815 |
super font:aFont. |
816 |
menuField font:aFont. |
|
817 |
! ! |
|
818 |
||
2404 | 819 |
!ExtendedComboBox methodsFor:'accessing-scrollbars'! |
1272 | 820 |
|
821 |
autoHideScrollBars |
|
822 |
"set/clear the flag which controls if scrollBars should |
|
2899 | 823 |
be made invisible dynamically, when there is nothing to scroll |
824 |
(and shown if there is)" |
|
825 |
||
1272 | 826 |
^ autoHideScrollBars |
827 |
! |
|
828 |
||
829 |
autoHideScrollBars:aBoolean |
|
830 |
"set/clear the flag which controls if scrollBars should |
|
2899 | 831 |
be made invisible dynamically, when there is nothing to scroll |
832 |
(and shown if there is)" |
|
833 |
||
1272 | 834 |
autoHideScrollBars := aBoolean |
835 |
! |
|
836 |
||
837 |
hasHorizontalScrollBar |
|
2899 | 838 |
"return the horizontal scrollability. |
839 |
If disabled, the horizontal scrollBar is made invisible." |
|
840 |
||
1272 | 841 |
^ hasHorizontalScrollBar |
842 |
! |
|
843 |
||
844 |
hasHorizontalScrollBar:aBool |
|
845 |
"enable/disable horizontal scrollability. |
|
2899 | 846 |
If disabled, the horizontal scrollBar is made invisible." |
847 |
||
1272 | 848 |
hasHorizontalScrollBar := aBool |
849 |
! |
|
850 |
||
851 |
hasVerticalScrollBar |
|
2899 | 852 |
"return the vertical scrollability. |
853 |
If disabled, the vertical scrollBar is made invisible." |
|
854 |
||
1272 | 855 |
^ hasVerticalScrollBar |
856 |
! |
|
857 |
||
858 |
hasVerticalScrollBar:aBool |
|
859 |
"enable/disable vertical scrollability. |
|
2899 | 860 |
If disabled, the vertical scrollBar is made invisible." |
861 |
||
1272 | 862 |
hasVerticalScrollBar := aBool |
863 |
! |
|
864 |
||
865 |
miniScrollerHorizontal |
|
2899 | 866 |
"return the flag which controls if the horizontal scrollBar is either a miniScroller, |
867 |
or a full scrollBar." |
|
868 |
||
1272 | 869 |
^ miniScrollerHorizontal |
870 |
! |
|
871 |
||
872 |
miniScrollerHorizontal:aBool |
|
873 |
"control the horizontal scrollBar to be either a miniScroller, |
|
2899 | 874 |
or a full scrollBar." |
875 |
||
1272 | 876 |
miniScrollerHorizontal := aBool |
877 |
! |
|
878 |
||
879 |
miniScrollerVertical |
|
2899 | 880 |
"return the flag which controls if the vertical scrollBar is either a miniScroller, |
881 |
or a full scrollBar." |
|
882 |
||
1272 | 883 |
^ miniScrollerVertical |
884 |
! |
|
885 |
||
886 |
miniScrollerVertical:aBool |
|
887 |
"control the vertical scrollBar to be either a miniScroller, |
|
2899 | 888 |
or a full scrollBar." |
889 |
||
1272 | 890 |
miniScrollerVertical := aBool |
891 |
! ! |
|
892 |
||
2411 | 893 |
!ExtendedComboBox methodsFor:'change & update'! |
894 |
||
895 |
update:what with:aPara from:aModel |
|
2899 | 896 |
"one of my models changed" |
897 |
||
2411 | 898 |
aModel == self model ifTrue:[ |
899 |
closeOnSelect ifTrue:[ |
|
900 |
self closeMenu |
|
901 |
]. |
|
902 |
^ self |
|
903 |
]. |
|
904 |
aModel == self menuWidgetHolder ifTrue:[ |
|
905 |
self menuWidget:(aModel value). |
|
906 |
^ self |
|
907 |
]. |
|
908 |
super update:what with:aPara from:aModel |
|
909 |
! ! |
|
910 |
||
2903 | 911 |
!ExtendedComboBox methodsFor:'error handling'! |
1224 | 912 |
|
2890 | 913 |
doesNotUnderstand:aMessage |
2899 | 914 |
"delegate messages to the widget" |
2890 | 915 |
|
1272 | 916 |
menuWidget notNil ifTrue:[ |
917 |
^ aMessage sendTo:menuWidget |
|
918 |
]. |
|
919 |
^ super doesNotUnderstand:aMessage |
|
2903 | 920 |
! ! |
921 |
||
922 |
!ExtendedComboBox methodsFor:'event handling'! |
|
1224 | 923 |
|
924 |
keyPress:key x:x y:y |
|
2890 | 925 |
"handle a key press event" |
926 |
||
2026 | 927 |
<resource: #keyboard (#Return)> |
928 |
||
1224 | 929 |
(key == Character space or:[key == #Return]) ifTrue:[ |
930 |
self enabled ifTrue:[ |
|
6106 | 931 |
self openMenu. |
932 |
^ self |
|
1224 | 933 |
] |
934 |
] ifFalse:[ |
|
935 |
super keyPress:key x:x y:y |
|
936 |
] |
|
3235 | 937 |
! |
938 |
||
939 |
processEvent:anEvent |
|
6154 | 940 |
"return true, if I have consumed the event" |
941 |
||
4166 | 942 |
<resource: #keyboard (#Escape )> |
943 |
||
3289
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
944 |
|evView button point x y| |
3235 | 945 |
|
3844 | 946 |
anEvent isKeyPressEvent ifTrue:[ |
947 |
anEvent key == #Escape ifTrue:[ |
|
948 |
(menuWrapper notNil and:[menuWrapper realized]) ifTrue:[ |
|
949 |
self closeMenu. |
|
950 |
^ true. |
|
951 |
] |
|
952 |
] |
|
953 |
]. |
|
954 |
||
3235 | 955 |
anEvent isButtonPressEvent ifFalse:[ |
956 |
^ false |
|
957 |
]. |
|
3844 | 958 |
|
6154 | 959 |
"/ a buttonPress |
3289
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
960 |
button := anEvent state. |
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
961 |
((button == 1) or:[button == #select]) ifFalse:[ |
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
962 |
^ false |
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
963 |
]. |
3235 | 964 |
(menuField notNil and:[menuField shown]) ifFalse:[ |
965 |
^ false |
|
966 |
]. |
|
967 |
(isReadOnly and:[self enabled]) ifFalse:[ |
|
968 |
^ false |
|
969 |
]. |
|
970 |
||
971 |
evView := anEvent view. |
|
972 |
evView isNil ifTrue:[^ false]. |
|
973 |
||
974 |
point := Point x:(anEvent x) y:(anEvent y). |
|
975 |
||
976 |
evView ~~ menuField ifTrue:[ |
|
977 |
(evView isSameOrComponentOf:menuField) ifFalse:[ |
|
978 |
^ false |
|
979 |
]. |
|
4992 | 980 |
point := device translatePoint:point fromView:evView toView:menuField. |
3235 | 981 |
]. |
982 |
x := point x. |
|
983 |
(x between:0 and:menuField width) ifFalse:[^ false]. |
|
984 |
||
985 |
y := point y. |
|
986 |
(y between:0 and:menuField height) ifFalse:[^ false]. |
|
987 |
||
988 |
self openMenu. |
|
989 |
^ true |
|
1179 | 990 |
! ! |
991 |
||
992 |
!ExtendedComboBox methodsFor:'initialization'! |
|
993 |
||
2462 | 994 |
createEditField |
4728 | 995 |
|nm fieldLevel| |
996 |
||
997 |
nm := styleSheet name. |
|
2462 | 998 |
|
3282 | 999 |
menuField isNil ifTrue:[ |
1000 |
menuField := EditField in:self. |
|
3838 | 1001 |
menuField borderWidth:0. |
3282 | 1002 |
]. |
2462 | 1003 |
menuField origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
1004 |
||
1005 |
styleSheet is3D ifTrue:[ |
|
4728 | 1006 |
(styleSheet at:'comboView.level' default:nil) notNil ifTrue:[ |
1007 |
fieldLevel := 0. |
|
2462 | 1008 |
] ifFalse:[ |
1009 |
menuField leftInset:(ViewSpacing // 2). |
|
1010 |
] |
|
1011 |
]. |
|
3285 | 1012 |
|
3838 | 1013 |
(nm = #win95 or:[nm = #win98 or:[ nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[ |
4728 | 1014 |
fieldLevel := 0. |
2462 | 1015 |
menuField leftInset:0. |
1016 |
]. |
|
4728 | 1017 |
fieldLevel := styleSheet at:'comboView.fieldLevel' default:fieldLevel. |
1018 |
||
1019 |
fieldLevel notNil ifTrue:[ |
|
1020 |
menuField level:fieldLevel. |
|
1021 |
]. |
|
1022 |
||
3838 | 1023 |
menuButton notNil ifTrue:[ menuField rightInset:(menuButton leftInset negated) ]. |
2462 | 1024 |
|
1025 |
menuField menuHolder:(self menuHolder). |
|
1026 |
||
1027 |
menuField model:model. |
|
4498 | 1028 |
menuField font:self font. |
2462 | 1029 |
self shown ifTrue:[ menuField realize ]. |
1030 |
! |
|
1031 |
||
2472 | 1032 |
destroy |
3235 | 1033 |
|wgrp| |
1034 |
||
1035 |
(wgrp := self windowGroup) notNil ifTrue:[ |
|
1036 |
wgrp removePreEventHook:self. |
|
1037 |
]. |
|
2472 | 1038 |
menuWidget notNil ifTrue:[ |
1039 |
menuWidget destroy. |
|
1040 |
]. |
|
3828 | 1041 |
self menuWidgetHolder:nil. |
2472 | 1042 |
super destroy |
1043 |
! |
|
1044 |
||
3838 | 1045 |
initStyle |
1046 |
super initStyle. |
|
1047 |
||
1048 |
self borderWidth:(EditField defaultBorderWidth). |
|
1049 |
self borderColor:(EditField defaultBorderColor). |
|
1050 |
! |
|
1051 |
||
1179 | 1052 |
initialize |
2899 | 1053 |
"setup defaults" |
1054 |
||
3285 | 1055 |
|prefExt prefWidth lvl rightInset leftInset halfSpacing nm| |
1179 | 1056 |
|
1057 |
super initialize. |
|
1224 | 1058 |
|
3285 | 1059 |
closeOnSelect := true. |
1060 |
||
3838 | 1061 |
menuField isNil ifTrue:[ |
1062 |
self createEditField. |
|
1063 |
]. |
|
1064 |
||
2173
41ed0651d789
use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1065 |
self initializeButton. |
1224 | 1066 |
menuButton pressAction:[self openMenu]. |
3285 | 1067 |
prefExt := menuButton preferredExtent. |
1068 |
prefWidth := prefExt x. |
|
1224 | 1069 |
|
3285 | 1070 |
menuButton origin:1.0@0.0 corner:1.0@1.0. |
1224 | 1071 |
styleSheet is3D ifTrue:[ |
1072 |
halfSpacing := ViewSpacing // 2. |
|
3285 | 1073 |
leftInset := rightInset := prefWidth + halfSpacing. |
1074 |
(lvl := styleSheet at:#'comboView.level' default:nil) notNil ifTrue:[ |
|
1075 |
self level:lvl. |
|
3838 | 1076 |
"/ menuField level:0. |
1077 |
"/ menuField rightInset:margin. |
|
1224 | 1078 |
] ifFalse:[ |
3285 | 1079 |
menuButton rightInset:halfSpacing. |
3838 | 1080 |
"/ menuField leftInset:margin. |
3285 | 1081 |
]. |
1224 | 1082 |
] ifFalse:[ |
3285 | 1083 |
leftInset := prefWidth + menuButton borderWidth. |
1084 |
rightInset := prefWidth. |
|
1224 | 1085 |
]. |
1086 |
||
3838 | 1087 |
"/ what a hack... |
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1648
diff
changeset
|
1088 |
nm := styleSheet name. |
3838 | 1089 |
(nm = #win95 or:[nm = #win98 or:[nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[ |
3285 | 1090 |
lvl isNil ifTrue:[self level:-1]. |
1091 |
menuButton rightInset:0. |
|
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1648
diff
changeset
|
1092 |
nm ~= #st80 ifTrue:[ |
3420
d112104710bb
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3289
diff
changeset
|
1093 |
leftInset := (ArrowButton new preferredWidth). |
3285 | 1094 |
rightInset := leftInset. |
1224 | 1095 |
]. |
1096 |
]. |
|
1097 |
menuButton leftInset:leftInset negated. |
|
1098 |
self model:nil. |
|
1099 |
||
1100 |
adjust := #right. |
|
1101 |
usePreferredWidthForMenu := false. |
|
1102 |
isReadOnly := false. |
|
1272 | 1103 |
|
1104 |
autoHideScrollBars := true. |
|
1105 |
hasHorizontalScrollBar := true. |
|
1106 |
hasVerticalScrollBar := true. |
|
1107 |
miniScrollerHorizontal := true. |
|
1868 | 1108 |
miniScrollerVertical := true. |
1272 | 1109 |
|
1224 | 1110 |
self readOnly:true. |
2173
41ed0651d789
use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1111 |
! |
1224 | 1112 |
|
2173
41ed0651d789
use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1113 |
initializeButton |
41ed0651d789
use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1114 |
menuButton := ComboView comboButtonFor:self. |
2157 | 1115 |
! |
1116 |
||
3235 | 1117 |
realize |
3237 | 1118 |
|wgrp pullMenuIfClickedOnField| |
3235 | 1119 |
|
1120 |
super realize. |
|
1121 |
||
1122 |
pullMenuIfClickedOnField := styleSheet at:#'comboView.pullMenuIfClickedOnField' |
|
1123 |
default:[ OperatingSystem isMSWINDOWSlike ]. |
|
1124 |
||
1125 |
pullMenuIfClickedOnField == true ifTrue:[ |
|
3237 | 1126 |
wgrp := self windowGroup. |
1127 |
wgrp notNil ifTrue:[ wgrp addPreEventHook:self ]. |
|
3235 | 1128 |
]. |
1129 |
! |
|
1130 |
||
2157 | 1131 |
release |
2899 | 1132 |
"release dependencies" |
1133 |
||
3828 | 1134 |
self menuWidgetHolder:nil. |
2157 | 1135 |
super release. |
1224 | 1136 |
! ! |
1137 |
||
1272 | 1138 |
!ExtendedComboBox methodsFor:'queries'! |
1139 |
||
1140 |
menuIsScrollable |
|
2899 | 1141 |
"returns true if the menu is scrollable" |
1142 |
||
1272 | 1143 |
^ (self hasVerticalScrollBar or:[self hasHorizontalScrollBar]) |
1144 |
! ! |
|
1145 |
||
4831 | 1146 |
!ExtendedComboBox methodsFor:'testing'! |
1147 |
||
1148 |
isComboView |
|
1149 |
^ true |
|
1150 |
! ! |
|
1151 |
||
1890 | 1152 |
!ExtendedComboBox methodsFor:'user interaction'! |
1179 | 1153 |
|
1224 | 1154 |
closeMenu |
2899 | 1155 |
"close the menu" |
1156 |
||
1224 | 1157 |
|id| |
1158 |
||
1159 |
menuWrapper notNil ifTrue:[ |
|
1160 |
menuWrapper realized ifFalse:[ |
|
5916 | 1161 |
(id := menuWrapper drawableId) notNil ifTrue:[ |
4992 | 1162 |
device unmapWindow:id |
1224 | 1163 |
] |
1164 |
] ifTrue:[ |
|
1165 |
menuWrapper unmap |
|
1166 |
]. |
|
1273 | 1167 |
"/ menuWrapper windowGroup:nil. |
1168 |
"/ self windowGroup removeView:menuWrapper. |
|
1224 | 1169 |
]. |
1170 |
menuButton turnOff. |
|
5916 | 1171 |
|
1172 |
"Modified: / 01-10-2018 / 17:04:34 / Claus Gittinger" |
|
1179 | 1173 |
! |
1174 |
||
1224 | 1175 |
openMenu |
2899 | 1176 |
"pull the menu - triggered from the button" |
1177 |
||
4504 | 1178 |
|h w menuOrigin useableExt widgetPrfExt graphicsDevice| |
1179 | 1179 |
|
1274 | 1180 |
openAction notNil ifTrue:[ |
2069
7891c7d3af69
use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
1181 |
openAction valueWithOptionalArgument:menuWidget |
1274 | 1182 |
]. |
1224 | 1183 |
menuWrapper isNil ifTrue:[ |
1184 |
menuWidget isNil ifTrue:[^ self]. |
|
4992 | 1185 |
menuWrapper := MenuWrapper onDevice:(device ? Screen current). |
1272 | 1186 |
menuWrapper for:menuWidget in:self. |
1224 | 1187 |
]. |
1188 |
menuButton turnOn. |
|
1189 |
||
4992 | 1190 |
graphicsDevice := device. |
4504 | 1191 |
menuOrigin := graphicsDevice translatePoint:(0@height) fromView:self toView:nil. |
3879
4bd5dba1e6a5
fixed: #openMenu for multiple screen systems with varying heights
Claus Gittinger <cg@exept.de>
parents:
3844
diff
changeset
|
1192 |
"/ notice, the position-dependent query: if there is a higher secondary screen, |
4bd5dba1e6a5
fixed: #openMenu for multiple screen systems with varying heights
Claus Gittinger <cg@exept.de>
parents:
3844
diff
changeset
|
1193 |
"/ this makes a difference in where a popUpMenu is allowed... |
4bd5dba1e6a5
fixed: #openMenu for multiple screen systems with varying heights
Claus Gittinger <cg@exept.de>
parents:
3844
diff
changeset
|
1194 |
"/ useableExt := device usableExtent. |
4504 | 1195 |
useableExt := graphicsDevice usableWidth @ (graphicsDevice usableHeightAt:menuOrigin). |
1179 | 1196 |
|
3134 | 1197 |
menuExtent notNil ifTrue:[ |
1198 |
widgetPrfExt := menuExtent. |
|
1199 |
] ifFalse:[ |
|
1200 |
widgetPrfExt := menuWrapper preferredExtent. |
|
1201 |
]. |
|
1224 | 1202 |
menuHeight isNil ifTrue:[ |
1392 | 1203 |
menuHeight := (5 + widgetPrfExt y) min:(useableExt y // 2). |
1224 | 1204 |
]. |
1179 | 1205 |
|
1224 | 1206 |
usePreferredWidthForMenu ifFalse:[ |
1868 | 1207 |
w := width. |
1224 | 1208 |
] ifTrue:[ |
1392 | 1209 |
(w := widgetPrfExt x+(menuWrapper borderWidth*2)) <= width ifTrue:[ |
4831 | 1210 |
"/ w := width |
1224 | 1211 |
] ifFalse:[ |
1212 |
(w + menuOrigin x) > useableExt x ifTrue:[ |
|
1213 |
menuOrigin x:((useableExt x - w) max:0) |
|
1214 |
] |
|
1215 |
] |
|
1216 |
]. |
|
1282
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1217 |
"/ nice side-effect; set width first, to allow menuHeight |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1218 |
"/ to be a block computing the height based upon the width. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1219 |
"/ (allows for geometry adjustments) |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1220 |
|
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1221 |
menuWrapper width:w. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1222 |
h := (useableExt y - menuOrigin y - 4) min:(menuHeight value). |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1223 |
menuWrapper height:h. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1224 |
|
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1225 |
menuWrapper origin:menuOrigin extent:(w@h). |
6106 | 1226 |
menuWrapper beUndecorated. |
1273 | 1227 |
menuWrapper openModal. |
2013
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
1228 |
menuWrapper notNil ifTrue:[ |
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
1229 |
menuWrapper realized ifTrue:[ |
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
1230 |
self closeMenu |
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
1231 |
]. |
1944 | 1232 |
]. |
2022
16e783eb5f2a
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1233 |
|
16e783eb5f2a
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1234 |
"Modified: / 10.10.2001 / 14:44:22 / cg" |
1179 | 1235 |
! ! |
1236 |
||
1630 | 1237 |
!ExtendedComboBox::MenuWrapper class methodsFor:'documentation'! |
1238 |
||
1239 |
documentation |
|
1240 |
" |
|
1241 |
problem: we have a grab - and get all events; |
|
1242 |
to simulate regular behaior inside, we have to synthetically simulate |
|
1243 |
focus control and implicit grab on buttonPress. |
|
1244 |
||
1245 |
[instance variables:] |
|
3134 | 1246 |
comboBox <ExtendedComboBox> |
1247 |
||
1248 |
widget <View> the widget which contains the menu |
|
1249 |
||
1630 | 1250 |
lastPointerView <View> view which contained the |
1251 |
mouse pointer. |
|
1252 |
used for enter/leave event generation. |
|
1253 |
||
1254 |
implicitGrabView <View> view in which button was pressed; |
|
1255 |
nilled when released (wherever). |
|
1256 |
If non-nil, all events are forwarded to this |
|
1257 |
one (for example to scroll with mouse outside the scrollbar) |
|
1258 |
||
3134 | 1259 |
eventHandler <OneArgBlock> if not nil, the block will |
1260 |
handle all inputEvents |
|
1261 |
||
1262 |
resizeCursor <Cursor> shown for resize handle |
|
1263 |
||
1264 |
restoreCursor <Cursor> default cursor |
|
1630 | 1265 |
" |
1266 |
! ! |
|
1267 |
||
1224 | 1268 |
!ExtendedComboBox::MenuWrapper methodsFor:'accessing'! |
1269 |
||
1270 |
application |
|
1271 |
"return the application, under which this view was opened, |
|
1272 |
or nil, if there is no application |
|
1273 |
" |
|
1274 |
^ comboBox application |
|
1275 |
||
1276 |
! |
|
1277 |
||
1630 | 1278 |
clearImplicitGrab |
1279 |
implicitGrabView := nil |
|
1280 |
! |
|
1281 |
||
5944 | 1282 |
computePreferredExtent |
1224 | 1283 |
"compute & return the preferredExtent from the components' preferrences |
1284 |
" |
|
1284 | 1285 |
^ (widget preferredExtent max:(widget widthOfContents @ widget heightOfContents)) |
1286 |
+ (margin * 2) + 8. |
|
5944 | 1287 |
|
1288 |
"Created: / 09-11-2018 / 19:52:27 / Claus Gittinger" |
|
1224 | 1289 |
! |
1290 |
||
1291 |
widget |
|
1292 |
"returns the widget wrapped by the menuView |
|
1293 |
" |
|
1294 |
^ widget |
|
1295 |
! ! |
|
1296 |
||
1297 |
!ExtendedComboBox::MenuWrapper methodsFor:'event handling'! |
|
1179 | 1298 |
|
1630 | 1299 |
dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate |
1300 |
"dispatch the event" |
|
1301 |
||
4504 | 1302 |
|x y oldGrabber p graphicsDevice| |
1630 | 1303 |
|
3134 | 1304 |
eventHandler notNil ifTrue:[ |
1305 |
(eventHandler value:event) ifTrue:[^ self]. |
|
1306 |
]. |
|
1307 |
||
1830 | 1308 |
(event isInputEvent not |
1309 |
or:[event isPointerEnterLeaveEvent]) ifTrue:[ |
|
1630 | 1310 |
super dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate. |
2899 | 1311 |
^ self |
1630 | 1312 |
]. |
1313 |
||
3134 | 1314 |
event isButtonMotionEvent ifTrue:[ |
1315 |
implicitGrabView isNil ifTrue:[ |
|
1316 |
(self isEventAssignedToResizeArea:event) ifTrue:[ |
|
1317 |
self setupResizeEventHandler. |
|
1318 |
^ self. |
|
1319 |
]. |
|
1320 |
]. |
|
1321 |
]. |
|
1322 |
||
1630 | 1323 |
event isButtonPressEvent ifTrue:[ |
1324 |
x := event x. |
|
1325 |
y := event y. |
|
1179 | 1326 |
|
1630 | 1327 |
((0@0 extent:self extent) containsPoint:(x @ y)) ifFalse:[ |
1328 |
comboBox closeMenu. |
|
1329 |
"/ if I took the grab from someone else, this buttonEvent should |
|
1330 |
"/ also go to that one ...but not, if it falls into my own ext-comboBox (sigh) |
|
1331 |
"/ (example: a sub-ext-box in an ext-box, clicking on the outer boxes menuButton) |
|
4992 | 1332 |
graphicsDevice := device. |
4553
ed70817b44e8
Access graphicsDevice via method send instead of instVar access
Stefan Vogel <sv@exept.de>
parents:
4504
diff
changeset
|
1333 |
(oldGrabber := graphicsDevice activePointerGrab) notNil ifTrue:[ |
4504 | 1334 |
p := graphicsDevice translatePoint:(x@y) fromView:self toView:comboBox. |
1630 | 1335 |
((0@0 extent:comboBox extent) containsPoint:p) ifFalse:[ |
4504 | 1336 |
p := graphicsDevice translatePoint:(x@y) fromView:self toView:oldGrabber. |
1630 | 1337 |
event view:oldGrabber. |
1338 |
event x:p x. |
|
1339 |
event y:p y. |
|
1224 | 1340 |
|
1630 | 1341 |
"/ this is a hack |
1342 |
oldGrabber class == self class ifTrue:[ |
|
1343 |
oldGrabber clearImplicitGrab. |
|
1344 |
]. |
|
1345 |
oldGrabber dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate. |
|
1346 |
]. |
|
1347 |
]. |
|
1348 |
^ self. |
|
1349 |
] |
|
1350 |
]. |
|
1351 |
self forwardEvent:event withFocusOn:focusViewOrNil. |
|
1352 |
! |
|
1353 |
||
1354 |
forwardEvent:ev withFocusOn:focusView |
|
4729 | 1355 |
"handle an event |
1630 | 1356 |
" |
1357 |
|view x y p syntheticEvent| |
|
1358 |
||
1359 |
"/ situation: we get a buttonPress, set implicitGrab (for scrollbars etc.) |
|
1360 |
"/ but never get the buttonRelease, since someone else (a popUp) grabbed the |
|
1361 |
"/ pointer in the meantime, and has eaten the release event ... (double-sigh) |
|
1362 |
implicitGrabView notNil ifTrue:[ |
|
3134 | 1363 |
(ev isButtonReleaseEvent or:[self sensor leftButtonPressed]) ifFalse:[ |
1630 | 1364 |
implicitGrabView := nil. |
1179 | 1365 |
]. |
1366 |
]. |
|
1367 |
||
1630 | 1368 |
((x := ev x) isNil or:[(y := ev y) isNil]) ifTrue:[ |
1369 |
^ self |
|
1370 |
]. |
|
1179 | 1371 |
|
1630 | 1372 |
implicitGrabView notNil ifTrue:[ |
1373 |
ev isButtonEvent ifTrue:[ |
|
4992 | 1374 |
p := device translatePoint:(x@y) fromView:self toView:implicitGrabView. |
1630 | 1375 |
ev view:implicitGrabView. |
2899 | 1376 |
ev x:p x. |
1377 |
ev y:p y. |
|
1630 | 1378 |
implicitGrabView dispatchEvent:ev withFocusOn:focusView delegate:false. |
1224 | 1379 |
|
2900 | 1380 |
(ev isButtonReleaseEvent "or:[ev isButtonMultiPressEvent]") ifTrue:[ |
1630 | 1381 |
implicitGrabView := nil. |
1382 |
]. |
|
1383 |
^ self |
|
1179 | 1384 |
] |
1385 |
]. |
|
1386 |
||
4729 | 1387 |
ev isKeyPressEvent ifTrue:[ |
1388 |
ev key == #Escape ifTrue:[ |
|
1389 |
self hideRequest. |
|
1390 |
^ self. |
|
1391 |
]. |
|
1392 |
]. |
|
1393 |
||
1630 | 1394 |
view := self detectViewAtX:x y:y. |
1395 |
view isNil ifTrue:[ |
|
1396 |
^ super dispatchEvent:ev withFocusOn:focusView delegate:false |
|
1397 |
]. |
|
1179 | 1398 |
|
4992 | 1399 |
p := device translatePoint:(x@y) fromView:self toView:view. |
1224 | 1400 |
|
1630 | 1401 |
ev isButtonPressEvent ifTrue:[ |
1402 |
(view wantsFocusWithButtonPress) ifTrue:[ |
|
1403 |
view requestFocus. |
|
1404 |
]. |
|
1405 |
view ~~ self ifTrue:[ "/ can this ever be self ? |
|
1406 |
implicitGrabView := view. |
|
1179 | 1407 |
] |
1408 |
]. |
|
1224 | 1409 |
|
1630 | 1410 |
ev isButtonMotionEvent ifTrue:[ |
1411 |
lastPointerView ~~ view ifTrue:[ |
|
1412 |
"/ must generate enter/leave ... (sigh) |
|
1413 |
lastPointerView notNil ifTrue:[ |
|
2125 | 1414 |
"/ XXX: should be fixed |
6147 | 1415 |
syntheticEvent := WindowEvent pointerLeave:0 view:lastPointerView. |
1416 |
syntheticEvent delegatedFrom:self. |
|
1630 | 1417 |
lastPointerView dispatchEvent:syntheticEvent withFocusOn:nil delegate:false. |
1418 |
]. |
|
1419 |
view notNil ifTrue:[ |
|
2125 | 1420 |
syntheticEvent := WindowEvent pointerEnter:0 x:x y:y view:view. |
6147 | 1421 |
syntheticEvent delegatedFrom:self. |
1630 | 1422 |
view dispatchEvent:syntheticEvent withFocusOn:nil delegate:false. |
1423 |
]. |
|
1424 |
lastPointerView := view. |
|
1425 |
]. |
|
1179 | 1426 |
]. |
1427 |
||
1630 | 1428 |
ev view:view. |
1429 |
ev x:p x. |
|
1430 |
ev y:p y. |
|
1431 |
view dispatchEvent:ev withFocusOn:focusView delegate:false. |
|
2022
16e783eb5f2a
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1432 |
|
16e783eb5f2a
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1433 |
"Modified: / 10.10.2001 / 13:54:20 / cg" |
3134 | 1434 |
! |
1435 |
||
1436 |
setupResizeEventHandler |
|
1437 |
|clickExtent clickPoint| |
|
1438 |
||
1439 |
||
1440 |
self windowGroup showCursor:resizeCursor. |
|
1441 |
||
1442 |
eventHandler := [:ev| |
|
1443 |
ev isButtonEvent ifTrue:[ |
|
1444 |
clickPoint notNil ifTrue:[ |
|
3469 | 1445 |
ev isButtonMotionEvent ifTrue:[ |
1446 |
|offset extent| |
|
1447 |
||
3134 | 1448 |
offset := self sensor mousePoint - clickPoint. |
1449 |
extent := (clickExtent + offset) max:(comboBox width)@50. |
|
1450 |
self extent:extent. |
|
1451 |
] ifFalse:[ |
|
1452 |
ev isButtonReleaseEvent ifTrue:[ |
|
1453 |
comboBox menuExtent:self extent. |
|
1454 |
]. |
|
1455 |
clickPoint := clickExtent := nil. |
|
1456 |
]. |
|
1457 |
]. |
|
1458 |
||
1459 |
clickPoint isNil ifTrue:[ |
|
1460 |
ev isButtonMotionEvent ifTrue:[ |
|
1461 |
(self isEventAssignedToResizeArea:ev) ifFalse:[ |
|
1462 |
self windowGroup showCursor:restoreCursor. |
|
1463 |
clickPoint := clickExtent := eventHandler := nil. |
|
1464 |
]. |
|
1465 |
]. |
|
1466 |
ev isButtonPressEvent ifTrue:[ "/ start resize |
|
1467 |
clickPoint := self sensor mousePoint. |
|
1468 |
clickExtent := self extent. |
|
1469 |
]. |
|
1470 |
]. |
|
1471 |
]. |
|
1472 |
ev isInputEvent |
|
1473 |
]. |
|
1630 | 1474 |
! ! |
1475 |
||
1476 |
!ExtendedComboBox::MenuWrapper methodsFor:'focus handling'! |
|
1179 | 1477 |
|
1630 | 1478 |
wantsFocusWithButtonPress |
1479 |
"views which do not like to take the keyboard focus |
|
1480 |
with buttonPress can do so by redefining this |
|
1481 |
to return false" |
|
1482 |
||
1483 |
^ false |
|
1484 |
||
1485 |
||
1179 | 1486 |
! ! |
1487 |
||
1224 | 1488 |
!ExtendedComboBox::MenuWrapper methodsFor:'initialization'! |
1489 |
||
1490 |
for:aWidget in:aReceiver |
|
1491 |
"create a wrapper for a widget and the receiver, an extented comboBox |
|
1492 |
" |
|
3829
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1493 |
|hasScr isAdded| |
1272 | 1494 |
|
1224 | 1495 |
comboBox := aReceiver. |
1272 | 1496 |
widget := aWidget. |
1497 |
hasScr := aWidget isScrollWrapper. |
|
3829
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1498 |
isAdded := false. |
1179 | 1499 |
|
1272 | 1500 |
comboBox menuIsScrollable ifTrue:[ |
1501 |
hasScr ifFalse:[ |
|
3829
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1502 |
"/ we have to add the scrooledView to self before |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1503 |
"/ setting the scrolledView - application should |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1504 |
"/ derive from my comboBox (build within subCanvas) |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1505 |
widget := ScrollableView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:self. |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1506 |
widget scrolledView:aWidget. |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1507 |
|
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1508 |
hasScr := isAdded := true. |
1272 | 1509 |
]. |
1510 |
widget horizontalScrollable:(comboBox hasHorizontalScrollBar). |
|
1511 |
widget verticalScrollable:(comboBox hasVerticalScrollBar). |
|
1512 |
widget horizontalMini:(comboBox miniScrollerHorizontal). |
|
1513 |
widget verticalMini:(comboBox miniScrollerVertical). |
|
1514 |
widget autoHideScrollBars:(comboBox autoHideScrollBars). |
|
1224 | 1515 |
]. |
1272 | 1516 |
|
3829
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1517 |
isAdded ifFalse:[ |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1518 |
widget origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1519 |
self add:widget. |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1520 |
]. |
1272 | 1521 |
hasScr ifTrue:[ |
1868 | 1522 |
widget level:0. |
1272 | 1523 |
widget := widget scrolledView. |
1868 | 1524 |
]. |
1179 | 1525 |
! |
1526 |
||
1273 | 1527 |
hideRequest |
1528 |
"hide request from windowGroup (i.e. via Escape key). |
|
5313 | 1529 |
Can be redefined in subclasses which don't like this" |
1273 | 1530 |
|
3134 | 1531 |
eventHandler := nil. |
1532 |
comboBox closeMenu. |
|
1179 | 1533 |
! |
1534 |
||
1868 | 1535 |
initialize |
1536 |
super initialize. |
|
1537 |
super level:0. |
|
1538 |
super borderWidth:1. |
|
3134 | 1539 |
self enableMotionEvents. |
1868 | 1540 |
! |
1541 |
||
1542 |
level:aNumber |
|
1543 |
! |
|
1544 |
||
1179 | 1545 |
mapped |
1224 | 1546 |
"grab resources (mouse and keyboard) |
1547 |
" |
|
3134 | 1548 |
eventHandler := nil. |
1549 |
||
1550 |
resizeCursor isNil ifTrue:[ |
|
1551 |
restoreCursor := self cursor. |
|
4992 | 1552 |
resizeCursor := Cursor fourWay onDevice:device. |
3134 | 1553 |
]. |
1179 | 1554 |
super mapped. |
2709 | 1555 |
self assignInitialKeyboardFocus. |
1868 | 1556 |
widget notNil ifTrue:[widget level:0]. |
1179 | 1557 |
! ! |
1558 |
||
1224 | 1559 |
!ExtendedComboBox::MenuWrapper methodsFor:'queries'! |
1179 | 1560 |
|
3134 | 1561 |
isEventAssignedToResizeArea:ev |
1562 |
|x y| |
|
1563 |
||
1564 |
((x := ev x) notNil and:[(y := ev y) notNil]) ifTrue:[ |evView| |
|
1565 |
evView := ev view. |
|
1566 |
||
1567 |
evView ~~ self ifTrue:[ |p| |
|
4992 | 1568 |
p := device translatePoint:(x@y) fromView:evView toView:self. |
3134 | 1569 |
x := p x. |
1570 |
y := p y. |
|
1571 |
]. |
|
1572 |
||
1573 |
(x - width) abs <= 5 ifTrue:[ |
|
1574 |
(y - height) abs <= 5 ifTrue:[^ true]. |
|
1575 |
]. |
|
1576 |
]. |
|
1577 |
^ false |
|
1578 |
! |
|
1579 |
||
1224 | 1580 |
raiseDeiconified |
1581 |
^ self raise |
|
1582 |
||
1583 |
! |
|
1179 | 1584 |
|
1224 | 1585 |
type |
1586 |
^ nil. |
|
1179 | 1587 |
|
1224 | 1588 |
|
1179 | 1589 |
! ! |
1590 |
||
1224 | 1591 |
!ExtendedComboBox::MenuWrapper methodsFor:'searching'! |
1179 | 1592 |
|
1593 |
detectViewAtX:x y:y |
|
1224 | 1594 |
"detect view at x@y. if no view is detected or |
5518 | 1595 |
it is my view, nil is returned" |
1596 |
||
1179 | 1597 |
|v| |
1598 |
||
5518 | 1599 |
(x notNil and:[y notNil |
1600 |
and:[(x between:0 and:width) |
|
1601 |
and:[y between:0 and:height]]]) ifTrue:[ |
|
1602 |
v := self detectViewAt:x@y. |
|
1603 |
v ~~ self ifTrue:[ |
|
1604 |
^ v |
|
1605 |
]. |
|
1179 | 1606 |
]. |
1607 |
^ nil |
|
1608 |
||
5518 | 1609 |
"Modified (comment): / 15-03-2017 / 20:46:45 / stefan" |
1179 | 1610 |
! ! |
1611 |
||
1612 |
!ExtendedComboBox class methodsFor:'documentation'! |
|
1613 |
||
1614 |
version |
|
4831 | 1615 |
^ '$Header$' |
3828 | 1616 |
! |
1617 |
||
1618 |
version_CVS |
|
4831 | 1619 |
^ '$Header$' |
1179 | 1620 |
! ! |
4166 | 1621 |