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