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