0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
View subclass:#PullDownMenu
|
|
14 |
instanceVariableNames:'menus titles activeMenuNumber
|
59
|
15 |
showSeparatingLines topMargin
|
|
16 |
fgColor bgColor activeFgColor activeBgColor
|
|
17 |
onLevel offLevel
|
|
18 |
keepMenu'
|
|
19 |
classVariableNames:'DefaultFont
|
|
20 |
DefaultViewBackground
|
|
21 |
DefaultForegroundColor
|
|
22 |
DefaultBackgroundColor
|
|
23 |
DefaultHilightForegroundColor
|
|
24 |
DefaultHilightBackgroundColor
|
|
25 |
DefaultLevel DefaultHilightLevel
|
|
26 |
DefaultShadowColor DefaultLightColor'
|
0
|
27 |
poolDictionaries:''
|
|
28 |
category:'Views-Menus'
|
|
29 |
!
|
|
30 |
|
|
31 |
PullDownMenu comment:'
|
5
|
32 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
33 |
All Rights Reserved
|
0
|
34 |
|
59
|
35 |
$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.6 1994-10-10 03:02:41 claus Exp $
|
3
|
36 |
'!
|
0
|
37 |
|
3
|
38 |
!PullDownMenu class methodsFor:'documentation'!
|
|
39 |
|
38
|
40 |
copyright
|
|
41 |
"
|
|
42 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
43 |
All Rights Reserved
|
38
|
44 |
|
|
45 |
This software is furnished under a license and may be used
|
|
46 |
only in accordance with the terms of that license and with the
|
|
47 |
inclusion of the above copyright notice. This software may not
|
|
48 |
be provided or otherwise made available to, or used by, any
|
|
49 |
other person. No title to or ownership of the software is
|
|
50 |
hereby transferred.
|
|
51 |
"
|
|
52 |
!
|
|
53 |
|
|
54 |
version
|
|
55 |
"
|
59
|
56 |
$Header: /cvs/stx/stx/libwidg/PullDownMenu.st,v 1.6 1994-10-10 03:02:41 claus Exp $
|
38
|
57 |
"
|
|
58 |
!
|
|
59 |
|
3
|
60 |
documentation
|
|
61 |
"
|
38
|
62 |
PullDown menu provides the top (always visible) part of these menus.
|
|
63 |
It controls display of its menus, which become visible when one of the
|
|
64 |
PullDownMenus entries is pressed.
|
0
|
65 |
|
38
|
66 |
Instance variables:
|
0
|
67 |
|
38
|
68 |
menus <aCollection> the sub menus
|
|
69 |
titles <aCollection> the strings in the menu
|
|
70 |
activeMenuNumber <Number> the index of the currently active menu
|
|
71 |
showSeparatingLines <Boolean> show separating lines between my menu-strings
|
|
72 |
topMargin <Number> number of pixels at top
|
|
73 |
fgColor <Color> color to draw passive menu-titles
|
|
74 |
bgColor <Color> color to draw passive menu-titles
|
|
75 |
activeFgColor <Color> color to draw activated menu-titles
|
|
76 |
activeBgColor <Color> color to draw activated menu-titles
|
|
77 |
onLevel <Integer> level of entry-buttons when pressed
|
|
78 |
offLevel <Integer> level of entry-buttons when released
|
|
79 |
keepmenu <Boolean> if on, pulled menu stays on click,
|
59
|
80 |
till clicked again (motif & windows behavior)
|
3
|
81 |
"
|
|
82 |
! !
|
0
|
83 |
|
59
|
84 |
!PullDownMenu class methodsFor:'defaults'!
|
|
85 |
|
|
86 |
updateStyleCache
|
|
87 |
DefaultViewBackground := StyleSheet at:'pullDownMenuViewBackground'.
|
|
88 |
DefaultForegroundColor := StyleSheet at:'pullDownMenuForegroundColor' default:Black.
|
|
89 |
DefaultBackgroundColor := StyleSheet at:'pullDownMenuBackgroundColor'.
|
|
90 |
DefaultHilightForegroundColor := StyleSheet at:'pullDownMenuHilightForegroundColor'.
|
|
91 |
DefaultHilightBackgroundColor := StyleSheet at:'pullDownMenuHilightBackgroundColor'.
|
|
92 |
DefaultHilightLevel := StyleSheet at:'pullDownMenuHilightLevel' default:-1.
|
|
93 |
DefaultLevel := StyleSheet at:'pullDownMenuLevel' default:1.
|
|
94 |
DefaultFont := StyleSheet at:'pullDownMenuFont'.
|
|
95 |
|
|
96 |
DefaultForegroundColor notNil ifTrue:[
|
|
97 |
DefaultForegroundColor := DefaultForegroundColor on:Display
|
|
98 |
].
|
|
99 |
DefaultBackgroundColor notNil ifTrue:[
|
|
100 |
DefaultBackgroundColor := DefaultBackgroundColor on:Display
|
|
101 |
].
|
|
102 |
DefaultShadowColor notNil ifTrue:[
|
|
103 |
DefaultShadowColor := DefaultShadowColor on:Display
|
|
104 |
].
|
|
105 |
DefaultLightColor notNil ifTrue:[
|
|
106 |
DefaultLightColor := DefaultLightColor on:Display
|
|
107 |
].
|
|
108 |
DefaultHilightForegroundColor notNil ifTrue:[
|
|
109 |
DefaultHilightForegroundColor := DefaultHilightForegroundColor on:Display
|
|
110 |
].
|
|
111 |
DefaultHilightBackgroundColor notNil ifTrue:[
|
|
112 |
DefaultHilightBackgroundColor := DefaultHilightBackgroundColor on:Display
|
|
113 |
].
|
|
114 |
DefaultFont notNil ifTrue:[
|
|
115 |
DefaultFont := DefaultFont on:Display
|
|
116 |
].
|
|
117 |
! !
|
|
118 |
|
0
|
119 |
!PullDownMenu class methodsFor:'instance creation'!
|
|
120 |
|
|
121 |
labels:titleArray
|
|
122 |
"create and return a new PullDownMenu"
|
|
123 |
|
|
124 |
^ self new labels:titleArray
|
|
125 |
! !
|
|
126 |
|
|
127 |
!PullDownMenu methodsFor:'initialization'!
|
|
128 |
|
|
129 |
initialize
|
|
130 |
super initialize.
|
|
131 |
|
|
132 |
font := font on:device.
|
|
133 |
self origin:(0.0 @ 0.0)
|
59
|
134 |
extent:(1.0 @ (font height + (font descent * 2) + topMargin)).
|
0
|
135 |
!
|
|
136 |
|
|
137 |
initStyle
|
|
138 |
super initStyle.
|
|
139 |
|
|
140 |
showSeparatingLines := false.
|
59
|
141 |
DefaultViewBackground notNil ifTrue:[
|
|
142 |
viewBackground := DefaultViewBackground
|
|
143 |
].
|
|
144 |
|
|
145 |
DefaultForegroundColor notNil ifTrue:[
|
|
146 |
fgColor := DefaultForegroundColor
|
|
147 |
] ifFalse:[
|
|
148 |
fgColor := Black.
|
|
149 |
].
|
|
150 |
DefaultBackgroundColor notNil ifTrue:[
|
|
151 |
bgColor := DefaultBackgroundColor
|
|
152 |
] ifFalse:[
|
|
153 |
bgColor := viewBackground.
|
|
154 |
].
|
|
155 |
onLevel := DefaultHilightLevel.
|
|
156 |
offLevel := DefaultLevel.
|
21
|
157 |
|
0
|
158 |
self is3D ifTrue:[
|
59
|
159 |
device hasColors ifTrue:[
|
|
160 |
activeFgColor := Color name:'yellow'
|
|
161 |
] ifFalse:[
|
|
162 |
activeFgColor := White
|
|
163 |
].
|
|
164 |
device hasGreyscales ifTrue:[
|
|
165 |
activeBgColor := bgColor.
|
|
166 |
] ifFalse:[
|
|
167 |
activeBgColor := fgColor.
|
|
168 |
].
|
|
169 |
topMargin := 2.
|
21
|
170 |
|
59
|
171 |
((style == #iris) or:[style == #motif]) ifTrue:[
|
|
172 |
self level:2.
|
|
173 |
softEdge := true.
|
|
174 |
onLevel := 2.
|
|
175 |
offLevel := 0.
|
|
176 |
activeFgColor := fgColor
|
|
177 |
]
|
0
|
178 |
] ifFalse:[
|
59
|
179 |
activeFgColor := bgColor.
|
|
180 |
activeBgColor := fgColor.
|
|
181 |
topMargin := 0
|
|
182 |
].
|
|
183 |
|
|
184 |
DefaultHilightForegroundColor notNil ifTrue:[
|
|
185 |
activeFgColor := DefaultHilightForegroundColor
|
|
186 |
].
|
|
187 |
DefaultHilightBackgroundColor notNil ifTrue:[
|
|
188 |
activeBgColor := DefaultHilightBackgroundColor
|
0
|
189 |
].
|
59
|
190 |
DefaultShadowColor notNil ifTrue:[
|
|
191 |
shadowColor := DefaultShadowColor on:device
|
|
192 |
].
|
|
193 |
DefaultLightColor notNil ifTrue:[
|
|
194 |
lightColor := DefaultLightColor on:device
|
|
195 |
].
|
|
196 |
|
|
197 |
bgColor := bgColor on:device.
|
|
198 |
fgColor := fgColor on:device.
|
|
199 |
activeBgColor := activeBgColor on:device.
|
|
200 |
activeFgColor := activeFgColor on:device.
|
|
201 |
|
38
|
202 |
keepMenu := (style == #motif) or:[(style == #iris) or:[style == #mswindows]].
|
0
|
203 |
!
|
|
204 |
|
|
205 |
initEvents
|
|
206 |
self enableButtonMotionEvents.
|
|
207 |
self enableButtonEvents
|
|
208 |
!
|
|
209 |
|
|
210 |
recreate
|
|
211 |
super create.
|
|
212 |
self setMenuOrigins
|
|
213 |
!
|
|
214 |
|
|
215 |
create
|
|
216 |
super create.
|
|
217 |
self setMenuOrigins
|
|
218 |
! !
|
|
219 |
|
|
220 |
!PullDownMenu methodsFor:'accessing'!
|
|
221 |
|
|
222 |
showSeparatingLines:aBoolean
|
|
223 |
"turn on/off drawing of separating lines"
|
|
224 |
|
|
225 |
showSeparatingLines := aBoolean.
|
|
226 |
shown ifTrue:[
|
59
|
227 |
self redraw
|
0
|
228 |
]
|
|
229 |
!
|
|
230 |
|
|
231 |
numberOfTitles:n
|
|
232 |
"setup blank title-space to be filled in later"
|
|
233 |
|
|
234 |
menus := Array new:n.
|
|
235 |
titles := Array new:n
|
|
236 |
!
|
|
237 |
|
|
238 |
labels:titleArray
|
|
239 |
"define the menu-titles (group-headers)"
|
|
240 |
|
|
241 |
|numberOfLabels|
|
|
242 |
|
|
243 |
numberOfLabels := titleArray size.
|
|
244 |
menus := Array new:numberOfLabels.
|
|
245 |
titles := Array new:numberOfLabels.
|
|
246 |
1 to:numberOfLabels do:[:index |
|
59
|
247 |
titles at:index put:(titleArray at:index) printString
|
0
|
248 |
].
|
|
249 |
shown ifTrue:[
|
59
|
250 |
self clear.
|
|
251 |
self redraw
|
0
|
252 |
]
|
|
253 |
!
|
|
254 |
|
|
255 |
labels
|
|
256 |
"return the menu-titles (group-headers)"
|
|
257 |
|
|
258 |
^ titles
|
|
259 |
!
|
|
260 |
|
|
261 |
font:aFont
|
|
262 |
"adjust menu-origins when font changes"
|
|
263 |
|
3
|
264 |
super font:(aFont on:device).
|
|
265 |
self height:(font height + (font descent * 2)).
|
0
|
266 |
self setMenuOrigins
|
|
267 |
!
|
|
268 |
|
|
269 |
menuAt:string
|
|
270 |
"return the menu with the title; return nil if not found"
|
|
271 |
|
|
272 |
|index|
|
|
273 |
|
|
274 |
index := self indexOf:string.
|
|
275 |
(index == 0) ifTrue:[^ nil].
|
|
276 |
^ menus at:index
|
|
277 |
!
|
|
278 |
|
|
279 |
at:aString putMenu:aMenu
|
|
280 |
"set the menu under the title, aString"
|
|
281 |
|
|
282 |
|index|
|
|
283 |
|
|
284 |
index := self indexOf:aString.
|
|
285 |
(index == 0) ifTrue:[^ nil].
|
|
286 |
aMenu origin:((left + (self titleLenUpTo:index))
|
59
|
287 |
@
|
|
288 |
(height + aMenu borderWidth)).
|
0
|
289 |
aMenu hidden:true.
|
|
290 |
menus at:index put:aMenu
|
|
291 |
!
|
|
292 |
|
|
293 |
at:aString putLabels:labels selectors:selectors args:args receiver:anObject
|
|
294 |
"create and set the menu under the title, aString"
|
|
295 |
|
|
296 |
|menuView|
|
|
297 |
|
|
298 |
menuView := MenuView labels:labels
|
59
|
299 |
selectors:selectors
|
|
300 |
args:args
|
|
301 |
receiver:anObject
|
|
302 |
for:self.
|
0
|
303 |
self at:aString putMenu:menuView
|
|
304 |
!
|
|
305 |
|
|
306 |
at:aString putLabels:labels selector:selector args:args receiver:anObject
|
|
307 |
"create and set the menu under the title, aString"
|
|
308 |
|
|
309 |
|menuView|
|
|
310 |
|
|
311 |
menuView := MenuView labels:labels
|
59
|
312 |
selector:selector
|
|
313 |
args:args
|
|
314 |
receiver:anObject
|
|
315 |
for:self.
|
0
|
316 |
self at:aString putMenu:menuView
|
|
317 |
!
|
|
318 |
|
|
319 |
at:aString putLabels:labels selectors:selectors receiver:anObject
|
|
320 |
"create and set the menu under the title, aString"
|
|
321 |
|
|
322 |
|menuView|
|
|
323 |
|
|
324 |
menuView := MenuView labels:labels
|
59
|
325 |
selectors:selectors
|
|
326 |
receiver:anObject
|
|
327 |
for:self.
|
0
|
328 |
self at:aString putMenu:menuView
|
|
329 |
! !
|
|
330 |
|
|
331 |
!PullDownMenu methodsFor:'private'!
|
|
332 |
|
|
333 |
titleLenUpTo:index
|
|
334 |
"answer len of all title-strings up-to (but excluding) title-index"
|
|
335 |
|
|
336 |
|len "{ Class: SmallInteger }" |
|
|
337 |
|
|
338 |
(index <= 1) ifTrue:[^ 0].
|
|
339 |
len := 0.
|
|
340 |
titles from:1 to:(index - 1) do:[:string |
|
59
|
341 |
len := len + (font widthOf:(' ' , string , ' ')).
|
|
342 |
showSeparatingLines ifTrue:[
|
|
343 |
self is3D ifTrue:[
|
|
344 |
len := len + 2
|
|
345 |
] ifFalse:[
|
|
346 |
len := len + 1
|
|
347 |
]
|
|
348 |
]
|
0
|
349 |
].
|
|
350 |
^ len
|
|
351 |
!
|
|
352 |
|
|
353 |
indexOf:stringOrNumber
|
|
354 |
"return the index of the menu with title; return 0 if not found"
|
|
355 |
|
|
356 |
(stringOrNumber isMemberOf:SmallInteger) ifTrue:[
|
59
|
357 |
^ stringOrNumber
|
0
|
358 |
].
|
|
359 |
^ titles indexOf:stringOrNumber
|
|
360 |
!
|
|
361 |
|
|
362 |
setMenuOrigins
|
|
363 |
"adjust origins of menus when font changes"
|
|
364 |
|
|
365 |
|index|
|
|
366 |
|
|
367 |
(font device == device) ifTrue:[
|
59
|
368 |
index := 1.
|
|
369 |
menus do:[:aMenu |
|
|
370 |
aMenu notNil ifTrue:[
|
|
371 |
aMenu origin:((left + (self titleLenUpTo:index))
|
|
372 |
@
|
|
373 |
(height + aMenu borderWidth))
|
|
374 |
].
|
|
375 |
index := index + 1
|
|
376 |
]
|
0
|
377 |
]
|
|
378 |
! !
|
|
379 |
|
|
380 |
!PullDownMenu methodsFor:'hiding/showing menus'!
|
|
381 |
|
|
382 |
drawTitle:string x:x selected:selected
|
|
383 |
|yText w|
|
|
384 |
|
3
|
385 |
yText := ((height - (font height)) // 2) + (font ascent) "+ topMargin".
|
0
|
386 |
w := font widthOf:string.
|
|
387 |
selected ifTrue:[
|
59
|
388 |
self paint:activeBgColor
|
0
|
389 |
] ifFalse:[
|
59
|
390 |
self paint:bgColor
|
0
|
391 |
].
|
|
392 |
self fillRectangleX:x y:0 width:w height:height.
|
|
393 |
|
|
394 |
self is3D ifTrue:[
|
59
|
395 |
self drawEdgesForX:x y:0
|
|
396 |
width:w
|
|
397 |
height:height
|
|
398 |
level:(selected ifTrue:[onLevel] ifFalse:[offLevel])
|
0
|
399 |
].
|
|
400 |
selected ifTrue:[
|
59
|
401 |
self paint:activeFgColor
|
0
|
402 |
] ifFalse:[
|
59
|
403 |
self paint:fgColor
|
0
|
404 |
].
|
|
405 |
self displayString:string x:x y:yText
|
|
406 |
!
|
|
407 |
|
|
408 |
highlightActiveTitle
|
|
409 |
|x string|
|
|
410 |
activeMenuNumber notNil ifTrue:[
|
59
|
411 |
x := self titleLenUpTo:activeMenuNumber.
|
|
412 |
string := ' ' , (titles at:activeMenuNumber) , ' '.
|
|
413 |
self drawTitle:string x:x selected:true
|
0
|
414 |
]
|
|
415 |
!
|
|
416 |
|
|
417 |
unHighlightActiveTitle
|
|
418 |
|x string|
|
|
419 |
activeMenuNumber notNil ifTrue:[
|
59
|
420 |
x := self titleLenUpTo:activeMenuNumber.
|
|
421 |
string := ' ' , (titles at:activeMenuNumber) , ' '.
|
|
422 |
self drawTitle:string x:x selected:false
|
0
|
423 |
]
|
|
424 |
!
|
|
425 |
|
38
|
426 |
hideActiveMenuRelease:aBoolean
|
0
|
427 |
activeMenuNumber notNil ifTrue:[
|
59
|
428 |
(menus at:activeMenuNumber) unrealize.
|
|
429 |
self unHighlightActiveTitle.
|
|
430 |
aBoolean ifTrue:[device ungrabPointer. self cursor:Cursor normal].
|
|
431 |
activeMenuNumber := nil
|
0
|
432 |
]
|
|
433 |
!
|
|
434 |
|
38
|
435 |
hideActiveMenu
|
|
436 |
^ self hideActiveMenuRelease:true
|
|
437 |
!
|
|
438 |
|
0
|
439 |
pullMenu:aNumber
|
|
440 |
"activate a menu"
|
|
441 |
|
|
442 |
|subMenu|
|
|
443 |
|
38
|
444 |
activeMenuNumber notNil ifTrue:[self hideActiveMenuRelease:false].
|
0
|
445 |
subMenu := menus at:aNumber.
|
|
446 |
subMenu notNil ifTrue:[
|
59
|
447 |
activeMenuNumber := aNumber.
|
|
448 |
self highlightActiveTitle.
|
|
449 |
subMenu deselect.
|
|
450 |
subMenu create.
|
|
451 |
subMenu saveUnder:true.
|
|
452 |
subMenu raise show
|
0
|
453 |
]
|
|
454 |
! !
|
|
455 |
|
|
456 |
!PullDownMenu methodsFor:'events'!
|
|
457 |
|
|
458 |
redraw
|
|
459 |
|string
|
|
460 |
x "{ Class: SmallInteger }"
|
|
461 |
y "{ Class: SmallInteger }"
|
|
462 |
index "{ Class: SmallInteger }" |
|
|
463 |
|
|
464 |
shown ifFalse: [ ^ self ].
|
|
465 |
titles isNil ifTrue:[^ self].
|
|
466 |
x := 0.
|
|
467 |
y := height "- 1".
|
|
468 |
index := 0.
|
|
469 |
titles do:[:title |
|
59
|
470 |
string := ' ' , title , ' '.
|
|
471 |
self drawTitle:string x:x selected:(index == activeMenuNumber).
|
|
472 |
x := x + (font widthOf:string).
|
|
473 |
showSeparatingLines ifTrue:[
|
|
474 |
self is3D ifTrue:[
|
|
475 |
self paint:shadowColor.
|
|
476 |
self displayLineFromX:x y:0 toX:x y:y.
|
|
477 |
x := x + 1.
|
|
478 |
self paint:lightColor.
|
|
479 |
self displayLineFromX:x y:0 toX:x y:y
|
|
480 |
] ifFalse:[
|
|
481 |
self paint:fgColor.
|
|
482 |
self displayLineFromX:x y:0 toX:x y:y
|
|
483 |
].
|
|
484 |
x := x + 1
|
|
485 |
].
|
|
486 |
index := index + 1
|
0
|
487 |
]
|
|
488 |
!
|
|
489 |
|
|
490 |
titleIndexForX:x
|
|
491 |
"given a click x-position, return index in title or nil"
|
|
492 |
|
|
493 |
|string
|
|
494 |
xstart "{ Class: SmallInteger }"
|
|
495 |
xend "{ Class: SmallInteger }" |
|
|
496 |
|
|
497 |
xstart := 0.
|
|
498 |
1 to:(titles size) do:[:index |
|
59
|
499 |
string := ' ' , (titles at:index) , ' '.
|
|
500 |
xend := xstart + (font widthOf:string).
|
|
501 |
showSeparatingLines ifTrue:[
|
|
502 |
self is3D ifTrue:[
|
|
503 |
xend := xend + 2
|
|
504 |
] ifFalse:[
|
|
505 |
xend := xend + 1
|
|
506 |
]
|
|
507 |
].
|
|
508 |
(x between:xstart and:xend) ifTrue:[^ index].
|
|
509 |
xstart := xend
|
0
|
510 |
].
|
|
511 |
^ nil
|
|
512 |
!
|
|
513 |
|
|
514 |
buttonPress:button x:x y:y
|
38
|
515 |
|titleIndex activeMenu activeLeft activeTop|
|
|
516 |
|
|
517 |
(y between:0 and:height) ifTrue:[
|
59
|
518 |
titleIndex := self titleIndexForX:x.
|
38
|
519 |
].
|
0
|
520 |
|
38
|
521 |
"
|
|
522 |
now, titleIndex is non-nil if pressed within myself
|
|
523 |
"
|
|
524 |
(titleIndex notNil and:[titleIndex ~~ activeMenuNumber]) ifTrue:[
|
59
|
525 |
self pullMenu:titleIndex.
|
|
526 |
keepMenu ifTrue:[
|
|
527 |
device grabPointerIn:self id.
|
|
528 |
self cursor:Cursor upRightArrow
|
|
529 |
]
|
38
|
530 |
] ifFalse:[
|
59
|
531 |
keepMenu ifTrue:[
|
|
532 |
titleIndex == activeMenuNumber ifTrue:[
|
|
533 |
"same pressed again ... stay"
|
|
534 |
^ self
|
|
535 |
].
|
|
536 |
"moving around below"
|
|
537 |
activeMenuNumber isNil ifTrue:[^self].
|
|
538 |
activeMenu := menus at:activeMenuNumber.
|
|
539 |
activeLeft := activeMenu left.
|
|
540 |
(x between:activeLeft and:(activeMenu right)) ifTrue:[
|
|
541 |
activeTop := activeMenu top.
|
|
542 |
(y between:activeTop and:(activeMenu bottom)) ifTrue:[
|
|
543 |
"moving around in menu"
|
|
544 |
activeMenu buttonPress:button
|
|
545 |
x:(x - activeLeft)
|
|
546 |
y:(y - activeTop).
|
|
547 |
^ self
|
|
548 |
]
|
|
549 |
].
|
|
550 |
].
|
|
551 |
self hideActiveMenu
|
0
|
552 |
]
|
|
553 |
!
|
|
554 |
|
|
555 |
buttonMotion:button x:x y:y
|
|
556 |
|titleIndex activeMenu activeLeft activeTop|
|
|
557 |
|
|
558 |
(y < height) ifTrue:[
|
59
|
559 |
"moving around in title line"
|
|
560 |
activeMenuNumber notNil ifTrue:[
|
|
561 |
(menus at:activeMenuNumber) selection:nil
|
|
562 |
].
|
|
563 |
titleIndex := self titleIndexForX:x.
|
|
564 |
titleIndex notNil ifTrue:[
|
|
565 |
(titleIndex ~~ activeMenuNumber) ifTrue:[
|
|
566 |
self pullMenu:titleIndex
|
|
567 |
]
|
|
568 |
]
|
0
|
569 |
] ifFalse:[
|
59
|
570 |
"moving around below"
|
|
571 |
activeMenuNumber isNil ifTrue:[^self].
|
|
572 |
activeMenu := menus at:activeMenuNumber.
|
|
573 |
activeLeft := activeMenu left.
|
|
574 |
(x between:activeLeft and:(activeMenu right)) ifTrue:[
|
|
575 |
activeTop := activeMenu top.
|
|
576 |
(y between:activeTop and:(activeMenu bottom)) ifTrue:[
|
|
577 |
"moving around in menu"
|
|
578 |
activeMenu buttonMotion:button
|
|
579 |
x:(x - activeLeft)
|
|
580 |
y:(y - activeTop).
|
|
581 |
^ self
|
|
582 |
]
|
|
583 |
].
|
|
584 |
"moved outside menu"
|
|
585 |
activeMenu selection:nil
|
0
|
586 |
]
|
|
587 |
!
|
|
588 |
|
|
589 |
buttonRelease:button x:x y:y
|
38
|
590 |
|activeMenu activeLeft activeTop hideMenu|
|
0
|
591 |
|
38
|
592 |
hideMenu := false.
|
0
|
593 |
(y >= height) ifTrue:[
|
59
|
594 |
"release below title-line"
|
|
595 |
activeMenuNumber isNil ifTrue:[^self].
|
|
596 |
activeMenu := menus at:activeMenuNumber.
|
|
597 |
activeLeft := activeMenu left.
|
|
598 |
"
|
|
599 |
released in a submenu ?
|
|
600 |
"
|
|
601 |
(x between:activeLeft and:(activeMenu right)) ifTrue:[
|
|
602 |
activeTop := activeMenu top.
|
|
603 |
(y between:activeTop and:(activeMenu bottom)) ifTrue:[
|
|
604 |
"release in menu"
|
|
605 |
self hideActiveMenu.
|
|
606 |
activeMenu buttonRelease:button
|
|
607 |
x:(x - activeLeft)
|
|
608 |
y:(y - activeTop).
|
|
609 |
^ self
|
|
610 |
]
|
|
611 |
].
|
|
612 |
hideMenu := true.
|
38
|
613 |
] ifFalse:[
|
59
|
614 |
y < 0 ifTrue:[
|
|
615 |
hideMenu := true
|
|
616 |
] ifFalse:[
|
|
617 |
keepMenu ifFalse:[
|
|
618 |
hideMenu := true
|
|
619 |
]
|
|
620 |
]
|
38
|
621 |
].
|
|
622 |
hideMenu ifTrue:[
|
|
623 |
self hideActiveMenu.
|
|
624 |
]
|
0
|
625 |
! !
|