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