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