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