author | Claus Gittinger <cg@exept.de> |
Wed, 11 Sep 2019 15:30:17 +0200 | |
changeset 6143 | 3ed63f769dc5 |
parent 6109 | 03ab498eafa1 |
child 6147 | 486df069a8cd |
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. |
6087 | 761 |
menuButton leftInset:(menuButton rightInset) rightInset:rightInset. |
1179 | 762 |
|
1224 | 763 |
rightInset := menuField leftInset. |
764 |
menuField leftInset:(menuField rightInset). |
|
765 |
menuField rightInset:rightInset. |
|
766 |
]. |
|
6087 | 767 |
|
768 |
"Modified: / 16-07-2019 / 16:37:32 / Claus Gittinger" |
|
1179 | 769 |
! |
770 |
||
1224 | 771 |
font:aFont |
2899 | 772 |
"set the font of the menu field" |
773 |
||
1224 | 774 |
super font:aFont. |
775 |
menuField font:aFont. |
|
776 |
! ! |
|
777 |
||
2404 | 778 |
!ExtendedComboBox methodsFor:'accessing-scrollbars'! |
1272 | 779 |
|
780 |
autoHideScrollBars |
|
781 |
"set/clear the flag which controls if scrollBars should |
|
2899 | 782 |
be made invisible dynamically, when there is nothing to scroll |
783 |
(and shown if there is)" |
|
784 |
||
1272 | 785 |
^ autoHideScrollBars |
786 |
! |
|
787 |
||
788 |
autoHideScrollBars:aBoolean |
|
789 |
"set/clear the flag which controls if scrollBars should |
|
2899 | 790 |
be made invisible dynamically, when there is nothing to scroll |
791 |
(and shown if there is)" |
|
792 |
||
1272 | 793 |
autoHideScrollBars := aBoolean |
794 |
! |
|
795 |
||
796 |
hasHorizontalScrollBar |
|
2899 | 797 |
"return the horizontal scrollability. |
798 |
If disabled, the horizontal scrollBar is made invisible." |
|
799 |
||
1272 | 800 |
^ hasHorizontalScrollBar |
801 |
! |
|
802 |
||
803 |
hasHorizontalScrollBar:aBool |
|
804 |
"enable/disable horizontal scrollability. |
|
2899 | 805 |
If disabled, the horizontal scrollBar is made invisible." |
806 |
||
1272 | 807 |
hasHorizontalScrollBar := aBool |
808 |
! |
|
809 |
||
810 |
hasVerticalScrollBar |
|
2899 | 811 |
"return the vertical scrollability. |
812 |
If disabled, the vertical scrollBar is made invisible." |
|
813 |
||
1272 | 814 |
^ hasVerticalScrollBar |
815 |
! |
|
816 |
||
817 |
hasVerticalScrollBar:aBool |
|
818 |
"enable/disable vertical scrollability. |
|
2899 | 819 |
If disabled, the vertical scrollBar is made invisible." |
820 |
||
1272 | 821 |
hasVerticalScrollBar := aBool |
822 |
! |
|
823 |
||
824 |
miniScrollerHorizontal |
|
2899 | 825 |
"return the flag which controls if the horizontal scrollBar is either a miniScroller, |
826 |
or a full scrollBar." |
|
827 |
||
1272 | 828 |
^ miniScrollerHorizontal |
829 |
! |
|
830 |
||
831 |
miniScrollerHorizontal:aBool |
|
832 |
"control the horizontal scrollBar to be either a miniScroller, |
|
2899 | 833 |
or a full scrollBar." |
834 |
||
1272 | 835 |
miniScrollerHorizontal := aBool |
836 |
! |
|
837 |
||
838 |
miniScrollerVertical |
|
2899 | 839 |
"return the flag which controls if the vertical scrollBar is either a miniScroller, |
840 |
or a full scrollBar." |
|
841 |
||
1272 | 842 |
^ miniScrollerVertical |
843 |
! |
|
844 |
||
845 |
miniScrollerVertical:aBool |
|
846 |
"control the vertical scrollBar to be either a miniScroller, |
|
2899 | 847 |
or a full scrollBar." |
848 |
||
1272 | 849 |
miniScrollerVertical := aBool |
850 |
! ! |
|
851 |
||
2411 | 852 |
!ExtendedComboBox methodsFor:'change & update'! |
853 |
||
854 |
update:what with:aPara from:aModel |
|
2899 | 855 |
"one of my models changed" |
856 |
||
2411 | 857 |
aModel == self model ifTrue:[ |
858 |
closeOnSelect ifTrue:[ |
|
859 |
self closeMenu |
|
860 |
]. |
|
861 |
^ self |
|
862 |
]. |
|
863 |
aModel == self menuWidgetHolder ifTrue:[ |
|
864 |
self menuWidget:(aModel value). |
|
865 |
^ self |
|
866 |
]. |
|
867 |
super update:what with:aPara from:aModel |
|
868 |
! ! |
|
869 |
||
2903 | 870 |
!ExtendedComboBox methodsFor:'error handling'! |
1224 | 871 |
|
2890 | 872 |
doesNotUnderstand:aMessage |
2899 | 873 |
"delegate messages to the widget" |
2890 | 874 |
|
1272 | 875 |
menuWidget notNil ifTrue:[ |
876 |
^ aMessage sendTo:menuWidget |
|
877 |
]. |
|
878 |
^ super doesNotUnderstand:aMessage |
|
2903 | 879 |
! ! |
880 |
||
881 |
!ExtendedComboBox methodsFor:'event handling'! |
|
1224 | 882 |
|
883 |
keyPress:key x:x y:y |
|
2890 | 884 |
"handle a key press event" |
885 |
||
2026 | 886 |
<resource: #keyboard (#Return)> |
887 |
||
1224 | 888 |
(key == Character space or:[key == #Return]) ifTrue:[ |
889 |
self enabled ifTrue:[ |
|
6106 | 890 |
self openMenu. |
891 |
^ self |
|
1224 | 892 |
] |
893 |
] ifFalse:[ |
|
894 |
super keyPress:key x:x y:y |
|
895 |
] |
|
3235 | 896 |
! |
897 |
||
898 |
processEvent:anEvent |
|
4166 | 899 |
<resource: #keyboard (#Escape )> |
900 |
||
3289
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
901 |
|evView button point x y| |
3235 | 902 |
|
3844 | 903 |
anEvent isKeyPressEvent ifTrue:[ |
904 |
anEvent key == #Escape ifTrue:[ |
|
905 |
(menuWrapper notNil and:[menuWrapper realized]) ifTrue:[ |
|
906 |
self closeMenu. |
|
907 |
^ true. |
|
908 |
] |
|
909 |
] |
|
910 |
]. |
|
911 |
||
3235 | 912 |
anEvent isButtonPressEvent ifFalse:[ |
913 |
^ false |
|
914 |
]. |
|
3844 | 915 |
|
3289
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
916 |
button := anEvent state. |
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
917 |
((button == 1) or:[button == #select]) ifFalse:[ |
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
918 |
^ false |
7bf0ddb4df39
bugfix - processEvents should have a look for which button is pressed
ca
parents:
3285
diff
changeset
|
919 |
]. |
3235 | 920 |
(menuField notNil and:[menuField shown]) ifFalse:[ |
921 |
^ false |
|
922 |
]. |
|
923 |
(isReadOnly and:[self enabled]) ifFalse:[ |
|
924 |
^ false |
|
925 |
]. |
|
926 |
||
927 |
evView := anEvent view. |
|
928 |
evView isNil ifTrue:[^ false]. |
|
929 |
||
930 |
point := Point x:(anEvent x) y:(anEvent y). |
|
931 |
||
932 |
evView ~~ menuField ifTrue:[ |
|
933 |
(evView isSameOrComponentOf:menuField) ifFalse:[ |
|
934 |
^ false |
|
935 |
]. |
|
4992 | 936 |
point := device translatePoint:point fromView:evView toView:menuField. |
3235 | 937 |
]. |
938 |
x := point x. |
|
939 |
(x between:0 and:menuField width) ifFalse:[^ false]. |
|
940 |
||
941 |
y := point y. |
|
942 |
(y between:0 and:menuField height) ifFalse:[^ false]. |
|
943 |
||
944 |
self openMenu. |
|
945 |
^ true |
|
1179 | 946 |
! ! |
947 |
||
948 |
!ExtendedComboBox methodsFor:'initialization'! |
|
949 |
||
2462 | 950 |
createEditField |
4728 | 951 |
|nm fieldLevel| |
952 |
||
953 |
nm := styleSheet name. |
|
2462 | 954 |
|
3282 | 955 |
menuField isNil ifTrue:[ |
956 |
menuField := EditField in:self. |
|
3838 | 957 |
menuField borderWidth:0. |
3282 | 958 |
]. |
2462 | 959 |
menuField origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
960 |
||
961 |
styleSheet is3D ifTrue:[ |
|
4728 | 962 |
(styleSheet at:'comboView.level' default:nil) notNil ifTrue:[ |
963 |
fieldLevel := 0. |
|
2462 | 964 |
] ifFalse:[ |
965 |
menuField leftInset:(ViewSpacing // 2). |
|
966 |
] |
|
967 |
]. |
|
3285 | 968 |
|
3838 | 969 |
(nm = #win95 or:[nm = #win98 or:[ nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[ |
4728 | 970 |
fieldLevel := 0. |
2462 | 971 |
menuField leftInset:0. |
972 |
]. |
|
4728 | 973 |
fieldLevel := styleSheet at:'comboView.fieldLevel' default:fieldLevel. |
974 |
||
975 |
fieldLevel notNil ifTrue:[ |
|
976 |
menuField level:fieldLevel. |
|
977 |
]. |
|
978 |
||
3838 | 979 |
menuButton notNil ifTrue:[ menuField rightInset:(menuButton leftInset negated) ]. |
2462 | 980 |
|
981 |
menuField menuHolder:(self menuHolder). |
|
982 |
||
983 |
menuField model:model. |
|
4498 | 984 |
menuField font:self font. |
2462 | 985 |
self shown ifTrue:[ menuField realize ]. |
986 |
! |
|
987 |
||
2472 | 988 |
destroy |
3235 | 989 |
|wgrp| |
990 |
||
991 |
(wgrp := self windowGroup) notNil ifTrue:[ |
|
992 |
wgrp removePreEventHook:self. |
|
993 |
]. |
|
2472 | 994 |
menuWidget notNil ifTrue:[ |
995 |
menuWidget destroy. |
|
996 |
]. |
|
3828 | 997 |
self menuWidgetHolder:nil. |
2472 | 998 |
super destroy |
999 |
! |
|
1000 |
||
3838 | 1001 |
initStyle |
1002 |
super initStyle. |
|
1003 |
||
1004 |
self borderWidth:(EditField defaultBorderWidth). |
|
1005 |
self borderColor:(EditField defaultBorderColor). |
|
1006 |
! |
|
1007 |
||
1179 | 1008 |
initialize |
2899 | 1009 |
"setup defaults" |
1010 |
||
3285 | 1011 |
|prefExt prefWidth lvl rightInset leftInset halfSpacing nm| |
1179 | 1012 |
|
1013 |
super initialize. |
|
1224 | 1014 |
|
3285 | 1015 |
closeOnSelect := true. |
1016 |
||
3838 | 1017 |
menuField isNil ifTrue:[ |
1018 |
self createEditField. |
|
1019 |
]. |
|
1020 |
||
2173
41ed0651d789
use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1021 |
self initializeButton. |
1224 | 1022 |
menuButton pressAction:[self openMenu]. |
3285 | 1023 |
prefExt := menuButton preferredExtent. |
1024 |
prefWidth := prefExt x. |
|
1224 | 1025 |
|
3285 | 1026 |
menuButton origin:1.0@0.0 corner:1.0@1.0. |
1224 | 1027 |
styleSheet is3D ifTrue:[ |
1028 |
halfSpacing := ViewSpacing // 2. |
|
3285 | 1029 |
leftInset := rightInset := prefWidth + halfSpacing. |
1030 |
(lvl := styleSheet at:#'comboView.level' default:nil) notNil ifTrue:[ |
|
1031 |
self level:lvl. |
|
3838 | 1032 |
"/ menuField level:0. |
1033 |
"/ menuField rightInset:margin. |
|
1224 | 1034 |
] ifFalse:[ |
3285 | 1035 |
menuButton rightInset:halfSpacing. |
3838 | 1036 |
"/ menuField leftInset:margin. |
3285 | 1037 |
]. |
1224 | 1038 |
] ifFalse:[ |
3285 | 1039 |
leftInset := prefWidth + menuButton borderWidth. |
1040 |
rightInset := prefWidth. |
|
1224 | 1041 |
]. |
1042 |
||
3838 | 1043 |
"/ what a hack... |
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1648
diff
changeset
|
1044 |
nm := styleSheet name. |
3838 | 1045 |
(nm = #win95 or:[nm = #win98 or:[nm = #winXP or:[nm = #st80 or:[nm = #winVista]]]]) ifTrue:[ |
3285 | 1046 |
lvl isNil ifTrue:[self level:-1]. |
1047 |
menuButton rightInset:0. |
|
1696
f1bae6d68ffe
eliminated styleSheet name = win95 queries
Claus Gittinger <cg@exept.de>
parents:
1648
diff
changeset
|
1048 |
nm ~= #st80 ifTrue:[ |
3420
d112104710bb
added preferredWidth & preferredHeight
Claus Gittinger <cg@exept.de>
parents:
3289
diff
changeset
|
1049 |
leftInset := (ArrowButton new preferredWidth). |
3285 | 1050 |
rightInset := leftInset. |
1224 | 1051 |
]. |
1052 |
]. |
|
1053 |
menuButton leftInset:leftInset negated. |
|
1054 |
self model:nil. |
|
1055 |
||
1056 |
adjust := #right. |
|
1057 |
usePreferredWidthForMenu := false. |
|
1058 |
isReadOnly := false. |
|
1272 | 1059 |
|
1060 |
autoHideScrollBars := true. |
|
1061 |
hasHorizontalScrollBar := true. |
|
1062 |
hasVerticalScrollBar := true. |
|
1063 |
miniScrollerHorizontal := true. |
|
1868 | 1064 |
miniScrollerVertical := true. |
1272 | 1065 |
|
1224 | 1066 |
self readOnly:true. |
2173
41ed0651d789
use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1067 |
! |
1224 | 1068 |
|
2173
41ed0651d789
use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1069 |
initializeButton |
41ed0651d789
use same button init code as ComboView
Claus Gittinger <cg@exept.de>
parents:
2157
diff
changeset
|
1070 |
menuButton := ComboView comboButtonFor:self. |
2157 | 1071 |
! |
1072 |
||
3235 | 1073 |
realize |
3237 | 1074 |
|wgrp pullMenuIfClickedOnField| |
3235 | 1075 |
|
1076 |
super realize. |
|
1077 |
||
1078 |
pullMenuIfClickedOnField := styleSheet at:#'comboView.pullMenuIfClickedOnField' |
|
1079 |
default:[ OperatingSystem isMSWINDOWSlike ]. |
|
1080 |
||
1081 |
pullMenuIfClickedOnField == true ifTrue:[ |
|
3237 | 1082 |
wgrp := self windowGroup. |
1083 |
wgrp notNil ifTrue:[ wgrp addPreEventHook:self ]. |
|
3235 | 1084 |
]. |
1085 |
! |
|
1086 |
||
2157 | 1087 |
release |
2899 | 1088 |
"release dependencies" |
1089 |
||
3828 | 1090 |
self menuWidgetHolder:nil. |
2157 | 1091 |
super release. |
1224 | 1092 |
! ! |
1093 |
||
1272 | 1094 |
!ExtendedComboBox methodsFor:'queries'! |
1095 |
||
1096 |
menuIsScrollable |
|
2899 | 1097 |
"returns true if the menu is scrollable" |
1098 |
||
1272 | 1099 |
^ (self hasVerticalScrollBar or:[self hasHorizontalScrollBar]) |
1100 |
! ! |
|
1101 |
||
4831 | 1102 |
!ExtendedComboBox methodsFor:'testing'! |
1103 |
||
1104 |
isComboView |
|
1105 |
^ true |
|
1106 |
! ! |
|
1107 |
||
1890 | 1108 |
!ExtendedComboBox methodsFor:'user interaction'! |
1179 | 1109 |
|
1224 | 1110 |
closeMenu |
2899 | 1111 |
"close the menu" |
1112 |
||
1224 | 1113 |
|id| |
1114 |
||
1115 |
menuWrapper notNil ifTrue:[ |
|
1116 |
menuWrapper realized ifFalse:[ |
|
5916 | 1117 |
(id := menuWrapper drawableId) notNil ifTrue:[ |
4992 | 1118 |
device unmapWindow:id |
1224 | 1119 |
] |
1120 |
] ifTrue:[ |
|
1121 |
menuWrapper unmap |
|
1122 |
]. |
|
1273 | 1123 |
"/ menuWrapper windowGroup:nil. |
1124 |
"/ self windowGroup removeView:menuWrapper. |
|
1224 | 1125 |
]. |
1126 |
menuButton turnOff. |
|
5916 | 1127 |
|
1128 |
"Modified: / 01-10-2018 / 17:04:34 / Claus Gittinger" |
|
1179 | 1129 |
! |
1130 |
||
1224 | 1131 |
openMenu |
2899 | 1132 |
"pull the menu - triggered from the button" |
1133 |
||
4504 | 1134 |
|h w menuOrigin useableExt widgetPrfExt graphicsDevice| |
1179 | 1135 |
|
1274 | 1136 |
openAction notNil ifTrue:[ |
2069
7891c7d3af69
use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents:
2026
diff
changeset
|
1137 |
openAction valueWithOptionalArgument:menuWidget |
1274 | 1138 |
]. |
1224 | 1139 |
menuWrapper isNil ifTrue:[ |
1140 |
menuWidget isNil ifTrue:[^ self]. |
|
4992 | 1141 |
menuWrapper := MenuWrapper onDevice:(device ? Screen current). |
1272 | 1142 |
menuWrapper for:menuWidget in:self. |
1224 | 1143 |
]. |
1144 |
menuButton turnOn. |
|
1145 |
||
4992 | 1146 |
graphicsDevice := device. |
4504 | 1147 |
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
|
1148 |
"/ 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
|
1149 |
"/ 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
|
1150 |
"/ useableExt := device usableExtent. |
4504 | 1151 |
useableExt := graphicsDevice usableWidth @ (graphicsDevice usableHeightAt:menuOrigin). |
1179 | 1152 |
|
3134 | 1153 |
menuExtent notNil ifTrue:[ |
1154 |
widgetPrfExt := menuExtent. |
|
1155 |
] ifFalse:[ |
|
1156 |
widgetPrfExt := menuWrapper preferredExtent. |
|
1157 |
]. |
|
1224 | 1158 |
menuHeight isNil ifTrue:[ |
1392 | 1159 |
menuHeight := (5 + widgetPrfExt y) min:(useableExt y // 2). |
1224 | 1160 |
]. |
1179 | 1161 |
|
1224 | 1162 |
usePreferredWidthForMenu ifFalse:[ |
1868 | 1163 |
w := width. |
1224 | 1164 |
] ifTrue:[ |
1392 | 1165 |
(w := widgetPrfExt x+(menuWrapper borderWidth*2)) <= width ifTrue:[ |
4831 | 1166 |
"/ w := width |
1224 | 1167 |
] ifFalse:[ |
1168 |
(w + menuOrigin x) > useableExt x ifTrue:[ |
|
1169 |
menuOrigin x:((useableExt x - w) max:0) |
|
1170 |
] |
|
1171 |
] |
|
1172 |
]. |
|
1282
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1173 |
"/ 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
|
1174 |
"/ 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
|
1175 |
"/ (allows for geometry adjustments) |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1176 |
|
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1177 |
menuWrapper width:w. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1178 |
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
|
1179 |
menuWrapper height:h. |
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1180 |
|
4269f064951c
allow for menuHeight to be a block;
Claus Gittinger <cg@exept.de>
parents:
1281
diff
changeset
|
1181 |
menuWrapper origin:menuOrigin extent:(w@h). |
6106 | 1182 |
menuWrapper beUndecorated. |
1273 | 1183 |
menuWrapper openModal. |
2013
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
1184 |
menuWrapper notNil ifTrue:[ |
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
1185 |
menuWrapper realized ifTrue:[ |
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
1186 |
self closeMenu |
3f550c902871
care for someone setting menuWrapper to nil,
Claus Gittinger <cg@exept.de>
parents:
1944
diff
changeset
|
1187 |
]. |
1944 | 1188 |
]. |
2022
16e783eb5f2a
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1189 |
|
16e783eb5f2a
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1190 |
"Modified: / 10.10.2001 / 14:44:22 / cg" |
1179 | 1191 |
! ! |
1192 |
||
1630 | 1193 |
!ExtendedComboBox::MenuWrapper class methodsFor:'documentation'! |
1194 |
||
1195 |
documentation |
|
1196 |
" |
|
1197 |
problem: we have a grab - and get all events; |
|
1198 |
to simulate regular behaior inside, we have to synthetically simulate |
|
1199 |
focus control and implicit grab on buttonPress. |
|
1200 |
||
1201 |
[instance variables:] |
|
3134 | 1202 |
comboBox <ExtendedComboBox> |
1203 |
||
1204 |
widget <View> the widget which contains the menu |
|
1205 |
||
1630 | 1206 |
lastPointerView <View> view which contained the |
1207 |
mouse pointer. |
|
1208 |
used for enter/leave event generation. |
|
1209 |
||
1210 |
implicitGrabView <View> view in which button was pressed; |
|
1211 |
nilled when released (wherever). |
|
1212 |
If non-nil, all events are forwarded to this |
|
1213 |
one (for example to scroll with mouse outside the scrollbar) |
|
1214 |
||
3134 | 1215 |
eventHandler <OneArgBlock> if not nil, the block will |
1216 |
handle all inputEvents |
|
1217 |
||
1218 |
resizeCursor <Cursor> shown for resize handle |
|
1219 |
||
1220 |
restoreCursor <Cursor> default cursor |
|
1630 | 1221 |
" |
1222 |
! ! |
|
1223 |
||
1224 | 1224 |
!ExtendedComboBox::MenuWrapper methodsFor:'accessing'! |
1225 |
||
1226 |
application |
|
1227 |
"return the application, under which this view was opened, |
|
1228 |
or nil, if there is no application |
|
1229 |
" |
|
1230 |
^ comboBox application |
|
1231 |
||
1232 |
! |
|
1233 |
||
1630 | 1234 |
clearImplicitGrab |
1235 |
implicitGrabView := nil |
|
1236 |
! |
|
1237 |
||
5944 | 1238 |
computePreferredExtent |
1224 | 1239 |
"compute & return the preferredExtent from the components' preferrences |
1240 |
" |
|
1284 | 1241 |
^ (widget preferredExtent max:(widget widthOfContents @ widget heightOfContents)) |
1242 |
+ (margin * 2) + 8. |
|
5944 | 1243 |
|
1244 |
"Created: / 09-11-2018 / 19:52:27 / Claus Gittinger" |
|
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 |
||
4504 | 1258 |
|x y oldGrabber p graphicsDevice| |
1630 | 1259 |
|
3134 | 1260 |
eventHandler notNil ifTrue:[ |
1261 |
(eventHandler value:event) ifTrue:[^ self]. |
|
1262 |
]. |
|
1263 |
||
1830 | 1264 |
(event isInputEvent not |
1265 |
or:[event isPointerEnterLeaveEvent]) ifTrue:[ |
|
1630 | 1266 |
super dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate. |
2899 | 1267 |
^ self |
1630 | 1268 |
]. |
1269 |
||
3134 | 1270 |
event isButtonMotionEvent ifTrue:[ |
1271 |
implicitGrabView isNil ifTrue:[ |
|
1272 |
(self isEventAssignedToResizeArea:event) ifTrue:[ |
|
1273 |
self setupResizeEventHandler. |
|
1274 |
^ self. |
|
1275 |
]. |
|
1276 |
]. |
|
1277 |
]. |
|
1278 |
||
1630 | 1279 |
event isButtonPressEvent ifTrue:[ |
1280 |
x := event x. |
|
1281 |
y := event y. |
|
1179 | 1282 |
|
1630 | 1283 |
((0@0 extent:self extent) containsPoint:(x @ y)) ifFalse:[ |
1284 |
comboBox closeMenu. |
|
1285 |
"/ if I took the grab from someone else, this buttonEvent should |
|
1286 |
"/ also go to that one ...but not, if it falls into my own ext-comboBox (sigh) |
|
1287 |
"/ (example: a sub-ext-box in an ext-box, clicking on the outer boxes menuButton) |
|
4992 | 1288 |
graphicsDevice := device. |
4553
ed70817b44e8
Access graphicsDevice via method send instead of instVar access
Stefan Vogel <sv@exept.de>
parents:
4504
diff
changeset
|
1289 |
(oldGrabber := graphicsDevice activePointerGrab) notNil ifTrue:[ |
4504 | 1290 |
p := graphicsDevice translatePoint:(x@y) fromView:self toView:comboBox. |
1630 | 1291 |
((0@0 extent:comboBox extent) containsPoint:p) ifFalse:[ |
4504 | 1292 |
p := graphicsDevice translatePoint:(x@y) fromView:self toView:oldGrabber. |
1630 | 1293 |
event view:oldGrabber. |
1294 |
event x:p x. |
|
1295 |
event y:p y. |
|
1224 | 1296 |
|
1630 | 1297 |
"/ this is a hack |
1298 |
oldGrabber class == self class ifTrue:[ |
|
1299 |
oldGrabber clearImplicitGrab. |
|
1300 |
]. |
|
1301 |
oldGrabber dispatchEvent:event withFocusOn:focusViewOrNil delegate:doDelegate. |
|
1302 |
]. |
|
1303 |
]. |
|
1304 |
^ self. |
|
1305 |
] |
|
1306 |
]. |
|
1307 |
self forwardEvent:event withFocusOn:focusViewOrNil. |
|
1308 |
! |
|
1309 |
||
1310 |
forwardEvent:ev withFocusOn:focusView |
|
4729 | 1311 |
"handle an event |
1630 | 1312 |
" |
1313 |
|view x y p syntheticEvent| |
|
1314 |
||
1315 |
"/ situation: we get a buttonPress, set implicitGrab (for scrollbars etc.) |
|
1316 |
"/ but never get the buttonRelease, since someone else (a popUp) grabbed the |
|
1317 |
"/ pointer in the meantime, and has eaten the release event ... (double-sigh) |
|
1318 |
implicitGrabView notNil ifTrue:[ |
|
3134 | 1319 |
(ev isButtonReleaseEvent or:[self sensor leftButtonPressed]) ifFalse:[ |
1630 | 1320 |
implicitGrabView := nil. |
1179 | 1321 |
]. |
1322 |
]. |
|
1323 |
||
1630 | 1324 |
((x := ev x) isNil or:[(y := ev y) isNil]) ifTrue:[ |
1325 |
^ self |
|
1326 |
]. |
|
1179 | 1327 |
|
1630 | 1328 |
implicitGrabView notNil ifTrue:[ |
1329 |
ev isButtonEvent ifTrue:[ |
|
4992 | 1330 |
p := device translatePoint:(x@y) fromView:self toView:implicitGrabView. |
1630 | 1331 |
ev view:implicitGrabView. |
2899 | 1332 |
ev x:p x. |
1333 |
ev y:p y. |
|
1630 | 1334 |
implicitGrabView dispatchEvent:ev withFocusOn:focusView delegate:false. |
1224 | 1335 |
|
2900 | 1336 |
(ev isButtonReleaseEvent "or:[ev isButtonMultiPressEvent]") ifTrue:[ |
1630 | 1337 |
implicitGrabView := nil. |
1338 |
]. |
|
1339 |
^ self |
|
1179 | 1340 |
] |
1341 |
]. |
|
1342 |
||
4729 | 1343 |
ev isKeyPressEvent ifTrue:[ |
1344 |
ev key == #Escape ifTrue:[ |
|
1345 |
self hideRequest. |
|
1346 |
^ self. |
|
1347 |
]. |
|
1348 |
]. |
|
1349 |
||
1630 | 1350 |
view := self detectViewAtX:x y:y. |
1351 |
view isNil ifTrue:[ |
|
1352 |
^ super dispatchEvent:ev withFocusOn:focusView delegate:false |
|
1353 |
]. |
|
1179 | 1354 |
|
4992 | 1355 |
p := device translatePoint:(x@y) fromView:self toView:view. |
1224 | 1356 |
|
1630 | 1357 |
ev isButtonPressEvent ifTrue:[ |
1358 |
(view wantsFocusWithButtonPress) ifTrue:[ |
|
1359 |
view requestFocus. |
|
1360 |
]. |
|
1361 |
view ~~ self ifTrue:[ "/ can this ever be self ? |
|
1362 |
implicitGrabView := view. |
|
1179 | 1363 |
] |
1364 |
]. |
|
1224 | 1365 |
|
1630 | 1366 |
ev isButtonMotionEvent ifTrue:[ |
1367 |
lastPointerView ~~ view ifTrue:[ |
|
1368 |
"/ must generate enter/leave ... (sigh) |
|
1369 |
lastPointerView notNil ifTrue:[ |
|
2125 | 1370 |
"/ XXX: should be fixed |
1371 |
syntheticEvent := WindowEvent pointerLeave:0 view:lastPointerView. |
|
1630 | 1372 |
lastPointerView dispatchEvent:syntheticEvent withFocusOn:nil delegate:false. |
1373 |
]. |
|
1374 |
view notNil ifTrue:[ |
|
2125 | 1375 |
syntheticEvent := WindowEvent pointerEnter:0 x:x y:y view:view. |
1630 | 1376 |
view dispatchEvent:syntheticEvent withFocusOn:nil delegate:false. |
1377 |
]. |
|
1378 |
lastPointerView := view. |
|
1379 |
]. |
|
1179 | 1380 |
]. |
1381 |
||
1630 | 1382 |
ev view:view. |
1383 |
ev x:p x. |
|
1384 |
ev y:p y. |
|
1385 |
view dispatchEvent:ev withFocusOn:focusView delegate:false. |
|
2022
16e783eb5f2a
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1386 |
|
16e783eb5f2a
use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents:
2013
diff
changeset
|
1387 |
"Modified: / 10.10.2001 / 13:54:20 / cg" |
3134 | 1388 |
! |
1389 |
||
1390 |
setupResizeEventHandler |
|
1391 |
|clickExtent clickPoint| |
|
1392 |
||
1393 |
||
1394 |
self windowGroup showCursor:resizeCursor. |
|
1395 |
||
1396 |
eventHandler := [:ev| |
|
1397 |
ev isButtonEvent ifTrue:[ |
|
1398 |
clickPoint notNil ifTrue:[ |
|
3469 | 1399 |
ev isButtonMotionEvent ifTrue:[ |
1400 |
|offset extent| |
|
1401 |
||
3134 | 1402 |
offset := self sensor mousePoint - clickPoint. |
1403 |
extent := (clickExtent + offset) max:(comboBox width)@50. |
|
1404 |
self extent:extent. |
|
1405 |
] ifFalse:[ |
|
1406 |
ev isButtonReleaseEvent ifTrue:[ |
|
1407 |
comboBox menuExtent:self extent. |
|
1408 |
]. |
|
1409 |
clickPoint := clickExtent := nil. |
|
1410 |
]. |
|
1411 |
]. |
|
1412 |
||
1413 |
clickPoint isNil ifTrue:[ |
|
1414 |
ev isButtonMotionEvent ifTrue:[ |
|
1415 |
(self isEventAssignedToResizeArea:ev) ifFalse:[ |
|
1416 |
self windowGroup showCursor:restoreCursor. |
|
1417 |
clickPoint := clickExtent := eventHandler := nil. |
|
1418 |
]. |
|
1419 |
]. |
|
1420 |
ev isButtonPressEvent ifTrue:[ "/ start resize |
|
1421 |
clickPoint := self sensor mousePoint. |
|
1422 |
clickExtent := self extent. |
|
1423 |
]. |
|
1424 |
]. |
|
1425 |
]. |
|
1426 |
ev isInputEvent |
|
1427 |
]. |
|
1630 | 1428 |
! ! |
1429 |
||
1430 |
!ExtendedComboBox::MenuWrapper methodsFor:'focus handling'! |
|
1179 | 1431 |
|
1630 | 1432 |
wantsFocusWithButtonPress |
1433 |
"views which do not like to take the keyboard focus |
|
1434 |
with buttonPress can do so by redefining this |
|
1435 |
to return false" |
|
1436 |
||
1437 |
^ false |
|
1438 |
||
1439 |
||
1179 | 1440 |
! ! |
1441 |
||
1224 | 1442 |
!ExtendedComboBox::MenuWrapper methodsFor:'initialization'! |
1443 |
||
1444 |
for:aWidget in:aReceiver |
|
1445 |
"create a wrapper for a widget and the receiver, an extented comboBox |
|
1446 |
" |
|
3829
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1447 |
|hasScr isAdded| |
1272 | 1448 |
|
1224 | 1449 |
comboBox := aReceiver. |
1272 | 1450 |
widget := aWidget. |
1451 |
hasScr := aWidget isScrollWrapper. |
|
3829
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1452 |
isAdded := false. |
1179 | 1453 |
|
1272 | 1454 |
comboBox menuIsScrollable ifTrue:[ |
1455 |
hasScr ifFalse:[ |
|
3829
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1456 |
"/ 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
|
1457 |
"/ setting the scrolledView - application should |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1458 |
"/ derive from my comboBox (build within subCanvas) |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1459 |
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
|
1460 |
widget scrolledView:aWidget. |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1461 |
|
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1462 |
hasScr := isAdded := true. |
1272 | 1463 |
]. |
1464 |
widget horizontalScrollable:(comboBox hasHorizontalScrollBar). |
|
1465 |
widget verticalScrollable:(comboBox hasVerticalScrollBar). |
|
1466 |
widget horizontalMini:(comboBox miniScrollerHorizontal). |
|
1467 |
widget verticalMini:(comboBox miniScrollerVertical). |
|
1468 |
widget autoHideScrollBars:(comboBox autoHideScrollBars). |
|
1224 | 1469 |
]. |
1272 | 1470 |
|
3829
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1471 |
isAdded ifFalse:[ |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1472 |
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
|
1473 |
self add:widget. |
b408134570d5
MenuWrapper #for:in: care about application when creating a scrolled view
fm
parents:
3828
diff
changeset
|
1474 |
]. |
1272 | 1475 |
hasScr ifTrue:[ |
1868 | 1476 |
widget level:0. |
1272 | 1477 |
widget := widget scrolledView. |
1868 | 1478 |
]. |
1179 | 1479 |
! |
1480 |
||
1273 | 1481 |
hideRequest |
1482 |
"hide request from windowGroup (i.e. via Escape key). |
|
5313 | 1483 |
Can be redefined in subclasses which don't like this" |
1273 | 1484 |
|
3134 | 1485 |
eventHandler := nil. |
1486 |
comboBox closeMenu. |
|
1179 | 1487 |
! |
1488 |
||
1868 | 1489 |
initialize |
1490 |
super initialize. |
|
1491 |
super level:0. |
|
1492 |
super borderWidth:1. |
|
3134 | 1493 |
self enableMotionEvents. |
1868 | 1494 |
! |
1495 |
||
1496 |
level:aNumber |
|
1497 |
! |
|
1498 |
||
1179 | 1499 |
mapped |
1224 | 1500 |
"grab resources (mouse and keyboard) |
1501 |
" |
|
3134 | 1502 |
eventHandler := nil. |
1503 |
||
1504 |
resizeCursor isNil ifTrue:[ |
|
1505 |
restoreCursor := self cursor. |
|
4992 | 1506 |
resizeCursor := Cursor fourWay onDevice:device. |
3134 | 1507 |
]. |
1179 | 1508 |
super mapped. |
2709 | 1509 |
self assignInitialKeyboardFocus. |
1868 | 1510 |
widget notNil ifTrue:[widget level:0]. |
1179 | 1511 |
! ! |
1512 |
||
1224 | 1513 |
!ExtendedComboBox::MenuWrapper methodsFor:'queries'! |
1179 | 1514 |
|
3134 | 1515 |
isEventAssignedToResizeArea:ev |
1516 |
|x y| |
|
1517 |
||
1518 |
((x := ev x) notNil and:[(y := ev y) notNil]) ifTrue:[ |evView| |
|
1519 |
evView := ev view. |
|
1520 |
||
1521 |
evView ~~ self ifTrue:[ |p| |
|
4992 | 1522 |
p := device translatePoint:(x@y) fromView:evView toView:self. |
3134 | 1523 |
x := p x. |
1524 |
y := p y. |
|
1525 |
]. |
|
1526 |
||
1527 |
(x - width) abs <= 5 ifTrue:[ |
|
1528 |
(y - height) abs <= 5 ifTrue:[^ true]. |
|
1529 |
]. |
|
1530 |
]. |
|
1531 |
^ false |
|
1532 |
! |
|
1533 |
||
1224 | 1534 |
raiseDeiconified |
1535 |
^ self raise |
|
1536 |
||
1537 |
! |
|
1179 | 1538 |
|
1224 | 1539 |
type |
1540 |
^ nil. |
|
1179 | 1541 |
|
1224 | 1542 |
|
1179 | 1543 |
! ! |
1544 |
||
1224 | 1545 |
!ExtendedComboBox::MenuWrapper methodsFor:'searching'! |
1179 | 1546 |
|
1547 |
detectViewAtX:x y:y |
|
1224 | 1548 |
"detect view at x@y. if no view is detected or |
5518 | 1549 |
it is my view, nil is returned" |
1550 |
||
1179 | 1551 |
|v| |
1552 |
||
5518 | 1553 |
(x notNil and:[y notNil |
1554 |
and:[(x between:0 and:width) |
|
1555 |
and:[y between:0 and:height]]]) ifTrue:[ |
|
1556 |
v := self detectViewAt:x@y. |
|
1557 |
v ~~ self ifTrue:[ |
|
1558 |
^ v |
|
1559 |
]. |
|
1179 | 1560 |
]. |
1561 |
^ nil |
|
1562 |
||
5518 | 1563 |
"Modified (comment): / 15-03-2017 / 20:46:45 / stefan" |
1179 | 1564 |
! ! |
1565 |
||
1566 |
!ExtendedComboBox class methodsFor:'documentation'! |
|
1567 |
||
1568 |
version |
|
4831 | 1569 |
^ '$Header$' |
3828 | 1570 |
! |
1571 |
||
1572 |
version_CVS |
|
4831 | 1573 |
^ '$Header$' |
1179 | 1574 |
! ! |
4166 | 1575 |