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 |
SelectionInListView subclass:#MenuView
|
|
14 |
instanceVariableNames:'selectors args receiver enableFlags
|
59
|
15 |
disabledFgColor onOffFlags subMenus
|
|
16 |
subMenuShown superMenu checkColor
|
|
17 |
lineLevel lineInset'
|
|
18 |
classVariableNames:'DefaultFont DefaultCheckColor
|
|
19 |
DefaultForegroundColor
|
|
20 |
DefaultBackgroundColor
|
|
21 |
DefaultDisabledForegroundColor
|
|
22 |
DefaultHilightForegroundColor
|
|
23 |
DefaultHilightBackgroundColor
|
|
24 |
DefaultHilightLevel
|
|
25 |
DefaultLineLevel
|
|
26 |
DefaultShadowColor DefaultLightColor'
|
0
|
27 |
poolDictionaries:''
|
|
28 |
category:'Views-Menus'
|
|
29 |
!
|
|
30 |
|
|
31 |
MenuView comment:'
|
5
|
32 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
59
|
33 |
All Rights Reserved
|
0
|
34 |
|
59
|
35 |
$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.10 1994-10-10 03:02:14 claus Exp $
|
3
|
36 |
'!
|
|
37 |
|
|
38 |
!MenuView 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/MenuView.st,v 1.10 1994-10-10 03:02:14 claus Exp $
|
38
|
57 |
"
|
|
58 |
!
|
|
59 |
|
3
|
60 |
documentation
|
|
61 |
"
|
38
|
62 |
a menu view used for both pull-down-menus and pop-up-menus
|
|
63 |
the action to be performed can be defined either as:
|
0
|
64 |
|
38
|
65 |
1) action:aBlockWithOneArg
|
|
66 |
which defines a block to be called with the line number (1..n)
|
|
67 |
of the selected line.
|
0
|
68 |
|
38
|
69 |
2) selectors:selectorArray [args: argarray] receiver:anObject
|
|
70 |
which defines the messages to be sent to receiver for each
|
|
71 |
line.
|
0
|
72 |
|
38
|
73 |
It is also possible to define both actionBlock and selectorArray.
|
0
|
74 |
|
38
|
75 |
menu entries starting with '\c' are check-entries.
|
|
76 |
menu entries conisting of '-' alone, are separating lines.
|
21
|
77 |
|
45
|
78 |
Examples:
|
59
|
79 |
Notice: normally, menuviews are wrapped into either a popup-
|
|
80 |
menu or pulldown-menu. But they can also be used stand-alone
|
|
81 |
as in:
|
45
|
82 |
|
59
|
83 |
|m|
|
|
84 |
m := MenuView
|
|
85 |
labels:#('foo'
|
|
86 |
'bar'
|
|
87 |
'baz')
|
|
88 |
selectors:#(
|
|
89 |
#foo
|
|
90 |
#bar
|
|
91 |
#baz)
|
|
92 |
receiver:nil.
|
|
93 |
m open
|
3
|
94 |
"
|
|
95 |
! !
|
0
|
96 |
|
59
|
97 |
!MenuView class methodsFor:'defaults'!
|
|
98 |
|
|
99 |
updateStyleCache
|
|
100 |
DefaultForegroundColor := StyleSheet at:'menuForegroundColor'.
|
|
101 |
DefaultBackgroundColor := StyleSheet at:'menuBackgroundColor'.
|
|
102 |
DefaultShadowColor := StyleSheet at:'menuShadowColor'.
|
|
103 |
DefaultLightColor := StyleSheet at:'menuLightColor'.
|
|
104 |
DefaultHilightForegroundColor := StyleSheet at:'menuHilightForegroundColor'.
|
|
105 |
DefaultHilightBackgroundColor := StyleSheet at:'menuHilightBackgroundColor'.
|
|
106 |
DefaultHilightLevel := StyleSheet at:'menuHilightLevel'.
|
|
107 |
DefaultLineLevel := StyleSheet at:'menuSeparatingLineLevel'.
|
|
108 |
DefaultDisabledForegroundColor := StyleSheet at:'menuDisabledForegroundColor' default:Color darkGrey.
|
|
109 |
DefaultCheckColor := StyleSheet at:'menuCheckColor'.
|
|
110 |
DefaultFont := StyleSheet at:'menuFont'.
|
0
|
111 |
|
59
|
112 |
DefaultShadowColor notNil ifTrue:[
|
|
113 |
DefaultShadowColor := DefaultShadowColor on:Display
|
|
114 |
].
|
|
115 |
DefaultLightColor notNil ifTrue:[
|
|
116 |
DefaultLightColor := DefaultLightColor on:Display
|
|
117 |
].
|
|
118 |
DefaultForegroundColor notNil ifTrue:[
|
|
119 |
DefaultForegroundColor := DefaultForegroundColor on:Display
|
|
120 |
].
|
|
121 |
DefaultBackgroundColor notNil ifTrue:[
|
|
122 |
DefaultBackgroundColor := DefaultBackgroundColor on:Display
|
|
123 |
].
|
|
124 |
DefaultHilightForegroundColor notNil ifTrue:[
|
|
125 |
DefaultHilightForegroundColor := DefaultHilightForegroundColor on:Display
|
|
126 |
].
|
|
127 |
DefaultHilightBackgroundColor notNil ifTrue:[
|
|
128 |
DefaultHilightBackgroundColor := DefaultHilightBackgroundColor on:Display
|
|
129 |
].
|
|
130 |
DefaultDisabledForegroundColor notNil ifTrue:[
|
|
131 |
DefaultDisabledForegroundColor := DefaultDisabledForegroundColor on:Display
|
|
132 |
].
|
|
133 |
DefaultCheckColor notNil ifTrue:[
|
|
134 |
DefaultCheckColor := DefaultCheckColor on:Display
|
|
135 |
].
|
|
136 |
DefaultFont notNil ifTrue:[
|
|
137 |
DefaultFont := DefaultFont on:Display
|
|
138 |
].
|
0
|
139 |
! !
|
|
140 |
|
|
141 |
!MenuView class methodsFor:'instance creation'!
|
|
142 |
|
|
143 |
labels:labels selectors:selArray args:argArray receiver:anObject in:aView
|
|
144 |
"create and return a new MenuView in aView
|
|
145 |
- receiverObject gets message from selectorArray with argument
|
|
146 |
from argArray"
|
|
147 |
|
|
148 |
^ (self in:aView) labels:labels
|
59
|
149 |
selectors:selArray
|
|
150 |
args:argArray
|
|
151 |
receiver:anObject
|
0
|
152 |
!
|
|
153 |
|
|
154 |
labels:labels selectors:selArray receiver:anObject in:aView
|
|
155 |
"create and return a new MenuView in aView
|
|
156 |
- receiverObject gets message from selectorArray without argument"
|
|
157 |
|
|
158 |
^ (self in:aView) labels:labels
|
59
|
159 |
selectors:selArray
|
|
160 |
args:nil
|
|
161 |
receiver:anObject
|
0
|
162 |
!
|
|
163 |
|
|
164 |
labels:labels selector:aSelector args:argArray receiver:anObject in:aTopMenu
|
|
165 |
"create and return a new MenuView
|
|
166 |
- receiverObject gets message aSelector with argument from
|
|
167 |
argArray for all entries"
|
|
168 |
|
|
169 |
^ (self in:aTopMenu) labels:labels
|
59
|
170 |
selectors:aSelector
|
|
171 |
args:argArray
|
|
172 |
receiver:anObject
|
0
|
173 |
!
|
|
174 |
|
|
175 |
labels:labels selector:aSelector args:argArray receiver:anObject for:aTopMenu
|
|
176 |
"create and return a new MenuView
|
|
177 |
- receiverObject gets message aSelector with argument from
|
|
178 |
argArray for all entries"
|
|
179 |
|
|
180 |
^ (self in:(aTopMenu superView)) labels:labels
|
59
|
181 |
selectors:aSelector
|
|
182 |
args:argArray
|
|
183 |
receiver:anObject
|
0
|
184 |
!
|
|
185 |
|
|
186 |
labels:labels selectors:selArray args:argArray receiver:anObject for:aTopMenu
|
|
187 |
^ (self in:(aTopMenu superView)) labels:labels
|
59
|
188 |
selectors:selArray
|
|
189 |
args:argArray
|
|
190 |
receiver:anObject
|
0
|
191 |
!
|
|
192 |
|
|
193 |
labels:labels selectors:selArray receiver:anObject for:aTopMenu
|
|
194 |
^ (self in:(aTopMenu superView)) labels:labels
|
59
|
195 |
selectors:selArray
|
|
196 |
args:nil
|
|
197 |
receiver:anObject
|
38
|
198 |
!
|
|
199 |
|
|
200 |
labels:labels selectors:selArray receiver:anObject
|
|
201 |
"create and return a new MenuView. The parent view
|
|
202 |
should be set later."
|
|
203 |
|
|
204 |
^ (self new) labels:labels
|
59
|
205 |
selectors:selArray
|
|
206 |
args:nil
|
|
207 |
receiver:anObject
|
38
|
208 |
!
|
|
209 |
|
|
210 |
labels:labels selectors:selArray
|
|
211 |
"create and return a new MenuView. The parent veiw
|
|
212 |
and receiver should be set later."
|
|
213 |
|
|
214 |
^ (self new) labels:labels
|
59
|
215 |
selectors:selArray
|
|
216 |
args:nil
|
|
217 |
receiver:nil
|
38
|
218 |
!
|
|
219 |
|
|
220 |
labels:labels
|
|
221 |
"create and return a new MenuView. The parent view,
|
|
222 |
selectors and receiver should be set later."
|
|
223 |
|
|
224 |
^ (self new) labels:labels
|
59
|
225 |
selectors:nil
|
|
226 |
args:nil
|
|
227 |
receiver:nil
|
0
|
228 |
! !
|
|
229 |
|
|
230 |
!MenuView methodsFor:'initialization'!
|
|
231 |
|
|
232 |
initialize
|
|
233 |
super initialize.
|
|
234 |
|
38
|
235 |
((style ~~ #normal) and:[style ~~ #mswindows]) ifTrue:[
|
59
|
236 |
borderWidth := 1.
|
|
237 |
self level:1
|
0
|
238 |
]
|
|
239 |
!
|
|
240 |
|
|
241 |
reinitialize
|
|
242 |
"this is called right after snapIn;
|
|
243 |
a kind of kludge - reset cursor"
|
|
244 |
|
|
245 |
super reinitialize.
|
|
246 |
selection := nil. "self selection:nil."
|
|
247 |
self cursor:Cursor hand
|
|
248 |
!
|
|
249 |
|
7
|
250 |
initStyle
|
|
251 |
super initStyle.
|
|
252 |
|
59
|
253 |
DefaultFont notNil ifTrue:[
|
|
254 |
font := DefaultFont on:device
|
|
255 |
].
|
|
256 |
|
|
257 |
DefaultCheckColor notNil ifTrue:[
|
|
258 |
checkColor := DefaultCheckColor
|
|
259 |
] ifFalse:[
|
|
260 |
checkColor := fgColor.
|
|
261 |
].
|
|
262 |
DefaultDisabledForegroundColor notNil ifTrue:[
|
|
263 |
disabledFgColor := DefaultDisabledForegroundColor
|
|
264 |
] ifFalse:[
|
|
265 |
disabledFgColor := Color darkGrey
|
|
266 |
].
|
|
267 |
disabledFgColor := disabledFgColor on:device.
|
|
268 |
|
|
269 |
DefaultForegroundColor notNil ifTrue:[
|
|
270 |
fgColor := DefaultForegroundColor on:device
|
|
271 |
].
|
|
272 |
DefaultBackgroundColor notNil ifTrue:[
|
|
273 |
bgColor := DefaultBackgroundColor on:device
|
|
274 |
].
|
|
275 |
|
|
276 |
DefaultShadowColor notNil ifTrue:[
|
|
277 |
shadowColor := DefaultShadowColor on:device
|
|
278 |
].
|
|
279 |
DefaultLightColor notNil ifTrue:[
|
|
280 |
lightColor := DefaultLightColor on:device
|
|
281 |
].
|
|
282 |
|
|
283 |
DefaultHilightLevel notNil ifTrue:[
|
|
284 |
hilightLevel := DefaultHilightLevel
|
38
|
285 |
] ifFalse:[
|
59
|
286 |
hilightLevel := 0.
|
|
287 |
].
|
|
288 |
StyleSheet is3D ifTrue:[
|
|
289 |
"some 3D style menu - hilight defaults to same"
|
|
290 |
|
|
291 |
DefaultHilightForegroundColor notNil ifTrue:[
|
|
292 |
hilightFgColor := DefaultHilightForegroundColor on:device
|
|
293 |
] ifFalse:[
|
|
294 |
hilightFgColor := fgColor.
|
|
295 |
].
|
|
296 |
DefaultHilightBackgroundColor notNil ifTrue:[
|
|
297 |
hilightBgColor := DefaultHilightBackgroundColor on:device
|
|
298 |
] ifFalse:[
|
|
299 |
hilightBgColor := bgColor.
|
|
300 |
].
|
|
301 |
DefaultLineLevel notNil ifTrue:[
|
|
302 |
lineLevel := DefaultLineLevel
|
|
303 |
] ifFalse:[
|
|
304 |
lineLevel := -1.
|
|
305 |
]
|
|
306 |
] ifFalse:[
|
|
307 |
"some 2D style menu - hilight defaults to inverse"
|
|
308 |
DefaultHilightForegroundColor notNil ifTrue:[
|
|
309 |
hilightFgColor := DefaultHilightForegroundColor on:device
|
|
310 |
] ifFalse:[
|
|
311 |
hilightFgColor := bgColor.
|
|
312 |
].
|
|
313 |
DefaultHilightBackgroundColor notNil ifTrue:[
|
|
314 |
hilightBgColor := DefaultHilightBackgroundColor on:device
|
|
315 |
] ifFalse:[
|
|
316 |
hilightBgColor := fgColor.
|
|
317 |
].
|
|
318 |
DefaultLineLevel notNil ifTrue:[
|
|
319 |
lineLevel := DefaultLineLevel
|
|
320 |
] ifFalse:[
|
|
321 |
lineLevel := 0.
|
|
322 |
]
|
|
323 |
].
|
|
324 |
|
|
325 |
"
|
|
326 |
the following has to be changed to
|
|
327 |
use the styleSheet too
|
|
328 |
"
|
|
329 |
(style == #normal) ifTrue:[
|
|
330 |
"/ lineLevel := 0
|
|
331 |
] ifFalse:[
|
|
332 |
"/ lineLevel := -1.
|
|
333 |
"the inset on each side"
|
|
334 |
style == #motif ifTrue:[
|
|
335 |
lineInset := 0
|
|
336 |
] ifFalse:[
|
|
337 |
lineInset := (device horizontalPixelPerMillimeter * 0.8) rounded.
|
|
338 |
]
|
38
|
339 |
].
|
7
|
340 |
(style == #iris) ifTrue:[
|
59
|
341 |
device hasGreyscales ifTrue:[
|
|
342 |
"/ hilightFgColor := fgColor.
|
|
343 |
"/ hilightBgColor := White "bgColor".
|
|
344 |
"/ hilightLevel := 1 "2".
|
|
345 |
lineSpacing := 3
|
|
346 |
].
|
|
347 |
"/ device hasColors ifTrue:[
|
|
348 |
"/ checkColor := Color red.
|
|
349 |
"/ ].
|
38
|
350 |
].
|
|
351 |
(style == #motif) ifTrue:[
|
59
|
352 |
"/ hilightFgColor := fgColor.
|
|
353 |
"/ hilightBgColor := bgColor.
|
|
354 |
"/ hilightLevel := 2.
|
|
355 |
lineSpacing := (2 * hilightLevel)
|
38
|
356 |
].
|
|
357 |
style == #openwin ifTrue:[
|
59
|
358 |
"add some space for rounded-hilight area"
|
|
359 |
self leftMargin:10.
|
|
360 |
"/ lineLevel := 1.
|
38
|
361 |
].
|
|
362 |
(style == #st80) ifTrue:[
|
59
|
363 |
viewBackground := White.
|
|
364 |
"/ fgColor := Black.
|
|
365 |
"/ bgColor := White.
|
|
366 |
level := 0.
|
|
367 |
"/ lineLevel := 0.
|
|
368 |
lineInset := 0
|
38
|
369 |
].
|
7
|
370 |
!
|
|
371 |
|
0
|
372 |
initEvents
|
|
373 |
super initEvents.
|
|
374 |
self enableLeaveEvents.
|
|
375 |
self enableButtonMotionEvents
|
|
376 |
!
|
|
377 |
|
|
378 |
create
|
|
379 |
super create.
|
7
|
380 |
subMenuShown := nil.
|
0
|
381 |
self recomputeSize
|
|
382 |
!
|
|
383 |
|
|
384 |
recreate
|
|
385 |
super recreate.
|
38
|
386 |
style == #openwin ifTrue:[
|
59
|
387 |
self leftMargin:10.
|
38
|
388 |
].
|
0
|
389 |
self recomputeSize
|
|
390 |
! !
|
|
391 |
|
|
392 |
!MenuView methodsFor:'accessing'!
|
|
393 |
|
7
|
394 |
superMenu:aMenu
|
|
395 |
"set the menu I am contained in
|
|
396 |
- need this to hide main menus when a submenu performed its action"
|
|
397 |
|
|
398 |
superMenu := aMenu
|
|
399 |
!
|
|
400 |
|
|
401 |
superMenu
|
|
402 |
"ret the menu I am contained in
|
|
403 |
- need this to hide main menus when a submenu performed its action"
|
|
404 |
|
|
405 |
^ superMenu
|
|
406 |
!
|
|
407 |
|
|
408 |
subMenuShown
|
|
409 |
"return the currently visible submenu - or nil if there is none"
|
|
410 |
|
|
411 |
^ subMenuShown
|
|
412 |
!
|
|
413 |
|
0
|
414 |
labels
|
|
415 |
"return the menu-labels"
|
|
416 |
|
|
417 |
^ list
|
|
418 |
!
|
|
419 |
|
|
420 |
labels:text
|
|
421 |
"set the labels to the argument, text"
|
|
422 |
|
38
|
423 |
(text isString) ifTrue:[
|
59
|
424 |
self list:(text asText)
|
0
|
425 |
] ifFalse:[
|
59
|
426 |
self list:text
|
0
|
427 |
].
|
21
|
428 |
enableFlags := Array new:(list size) withAll:true.
|
0
|
429 |
self recomputeSize
|
|
430 |
!
|
|
431 |
|
|
432 |
labelAt:indexOrName put:aString
|
|
433 |
"change the label at index to be aString"
|
|
434 |
|
|
435 |
|i|
|
|
436 |
|
|
437 |
i := self indexOf:indexOrName.
|
3
|
438 |
i == 0 ifTrue:[^ self].
|
0
|
439 |
list at:i put:aString.
|
3
|
440 |
|
0
|
441 |
"create onOff flags, if this label has a check-mark"
|
|
442 |
(aString startsWith:'\c') ifTrue:[
|
59
|
443 |
onOffFlags isNil ifTrue:[
|
|
444 |
onOffFlags := Array new:(list size) withAll:false
|
|
445 |
] ifFalse:[
|
|
446 |
[onOffFlags size < list size] whileTrue:[
|
|
447 |
onOffFlags := onOffFlags copyWith:false
|
|
448 |
]
|
|
449 |
].
|
|
450 |
onOffFlags at:i put:false
|
0
|
451 |
].
|
|
452 |
self recomputeSize
|
|
453 |
!
|
|
454 |
|
|
455 |
font:aFont
|
|
456 |
"adjust size for new font"
|
|
457 |
|
|
458 |
super font:(aFont on:device).
|
|
459 |
self recomputeSize
|
|
460 |
!
|
|
461 |
|
59
|
462 |
addSeparatingLine
|
|
463 |
"add a separating line"
|
|
464 |
|
|
465 |
self addLabel:'-' selector:nil
|
|
466 |
!
|
|
467 |
|
|
468 |
addSeparatingLineAfter:aLabelOrSelectorOrNumber
|
|
469 |
"add a separating line"
|
|
470 |
|
|
471 |
self addLabel:'-' selector:nil after:aLabelOrSelectorOrNumber
|
|
472 |
!
|
|
473 |
|
0
|
474 |
addLabel:aLabel selector:aSelector
|
|
475 |
"add another label/selector pair"
|
|
476 |
|
|
477 |
list isNil ifTrue:[
|
59
|
478 |
list := Array with:aLabel
|
0
|
479 |
] ifFalse:[
|
59
|
480 |
list := list copyWith:aLabel
|
0
|
481 |
].
|
|
482 |
selectors := selectors copyWith:aSelector.
|
|
483 |
enableFlags := enableFlags copyWith:true.
|
|
484 |
self recomputeSize
|
|
485 |
!
|
|
486 |
|
|
487 |
addLabel:aLabel selector:aSelector arg:anArg
|
|
488 |
"add another label/selector/argument trio"
|
|
489 |
|
|
490 |
list isNil ifTrue:[
|
59
|
491 |
list := Array with:aLabel
|
0
|
492 |
] ifFalse:[
|
59
|
493 |
list := list copyWith:aLabel
|
0
|
494 |
].
|
|
495 |
selectors := selectors copyWith:aSelector.
|
|
496 |
args := args copyWith:anArg.
|
|
497 |
enableFlags := enableFlags copyWith:true.
|
|
498 |
self recomputeSize
|
|
499 |
!
|
|
500 |
|
38
|
501 |
addLabel:aLabel selector:aSelector after:aLabelOrSelectorOrNumber
|
|
502 |
"insert another label/selector pair at some place.
|
|
503 |
Being very friendly here, allowing label-string, selector or numeric
|
|
504 |
index for the argument aLabelOrSelectorOrNumber"
|
|
505 |
|
|
506 |
|idx|
|
|
507 |
|
|
508 |
list isNil ifTrue:[
|
59
|
509 |
^ self addLabel:aLabel selector:aSelector
|
38
|
510 |
].
|
|
511 |
"
|
|
512 |
be user friendly - allow both label or selector
|
|
513 |
to be passed
|
|
514 |
"
|
|
515 |
aLabelOrSelectorOrNumber isInteger ifTrue:[
|
59
|
516 |
idx := aLabelOrSelectorOrNumber
|
38
|
517 |
] ifFalse:[
|
59
|
518 |
idx := list indexOf:aLabelOrSelectorOrNumber ifAbsent:[selectors indexOf:aLabelOrSelectorOrNumber].
|
38
|
519 |
].
|
|
520 |
(idx between:1 and:list size) ifFalse:[
|
59
|
521 |
"add to end"
|
|
522 |
^ self addLabel:aLabel selector:aSelector
|
38
|
523 |
].
|
|
524 |
|
|
525 |
list := list asOrderedCollection add:aLabel beforeIndex:(idx + 1).
|
|
526 |
selectors := selectors asOrderedCollection add:aSelector beforeIndex:(idx + 1).
|
|
527 |
enableFlags := enableFlags asOrderedCollection add:true beforeIndex:(idx + 1).
|
|
528 |
subMenus notNil ifTrue:[
|
59
|
529 |
subMenus := subMenus asOrderedCollection add:nil beforeIndex:(idx + 1).
|
38
|
530 |
].
|
|
531 |
args notNil ifTrue:[
|
59
|
532 |
args := args asOrderedCollection add:nil beforeIndex:(idx + 1).
|
38
|
533 |
].
|
|
534 |
self recomputeSize
|
|
535 |
|
|
536 |
"
|
|
537 |
|v|
|
|
538 |
CodeView new realize.
|
|
539 |
v := CodeView new realize.
|
|
540 |
v middleButtonMenu menuView addLabel:'new entry' selector:#foo after:'paste'.
|
|
541 |
"
|
|
542 |
!
|
|
543 |
|
|
544 |
remove:indexOrName
|
|
545 |
"remove the label at index"
|
|
546 |
|
|
547 |
|i|
|
|
548 |
|
|
549 |
i := self indexOf:indexOrName.
|
|
550 |
i == 0 ifTrue:[^ self].
|
|
551 |
list := list asOrderedCollection removeIndex:i.
|
|
552 |
selectors := selectors asOrderedCollection removeIndex:i.
|
|
553 |
enableFlags := enableFlags asOrderedCollection removeIndex:i.
|
|
554 |
subMenus notNil ifTrue:[
|
59
|
555 |
subMenus := subMenus asOrderedCollection removeIndex:i.
|
38
|
556 |
].
|
|
557 |
self recomputeSize
|
|
558 |
!
|
|
559 |
|
0
|
560 |
indexOf:indexOrName
|
|
561 |
"return the index of the label named:aName or , if its a symbol
|
|
562 |
the index in the selector list"
|
|
563 |
|
|
564 |
(indexOrName isMemberOf:Symbol) ifTrue:[
|
59
|
565 |
^ selectors indexOf:indexOrName
|
0
|
566 |
].
|
38
|
567 |
(indexOrName isString) ifTrue:[
|
59
|
568 |
^ list indexOf:indexOrName
|
38
|
569 |
].
|
0
|
570 |
^ indexOrName
|
|
571 |
!
|
|
572 |
|
|
573 |
disable:indexOrName
|
|
574 |
"disable an entry"
|
|
575 |
|
|
576 |
|index|
|
|
577 |
|
|
578 |
index := self indexOf:indexOrName.
|
|
579 |
index ~~ 0 ifTrue:[
|
59
|
580 |
(enableFlags at:index) ifTrue:[
|
|
581 |
enableFlags at:index put:false.
|
|
582 |
shown ifTrue:[
|
|
583 |
self redrawLine:index
|
|
584 |
]
|
|
585 |
]
|
12
|
586 |
] ifFalse:[
|
59
|
587 |
"try submenus for convenience"
|
|
588 |
(indexOrName isNumber not and:[subMenus notNil]) ifTrue:[
|
|
589 |
subMenus do:[:m |
|
|
590 |
m notNil ifTrue:[
|
|
591 |
m disable:indexOrName
|
|
592 |
]
|
|
593 |
]
|
|
594 |
]
|
0
|
595 |
]
|
|
596 |
!
|
|
597 |
|
|
598 |
enable:indexOrName
|
|
599 |
"enable an entry"
|
|
600 |
|
|
601 |
|index|
|
|
602 |
|
|
603 |
index := self indexOf:indexOrName.
|
|
604 |
index ~~ 0 ifTrue:[
|
59
|
605 |
(enableFlags at:index) ifFalse:[
|
|
606 |
enableFlags at:index put:true.
|
|
607 |
shown ifTrue:[
|
|
608 |
self redrawLine:index
|
|
609 |
]
|
|
610 |
]
|
12
|
611 |
] ifFalse:[
|
59
|
612 |
"try submenus for convenience"
|
|
613 |
(indexOrName isNumber not and:[subMenus notNil]) ifTrue:[
|
|
614 |
subMenus do:[:m |
|
|
615 |
m notNil ifTrue:[
|
|
616 |
m enable:indexOrName
|
|
617 |
]
|
|
618 |
]
|
|
619 |
]
|
0
|
620 |
]
|
|
621 |
!
|
|
622 |
|
|
623 |
receiver
|
|
624 |
"return the receiver of the message"
|
|
625 |
|
|
626 |
^ receiver
|
|
627 |
!
|
|
628 |
|
|
629 |
selectors
|
|
630 |
"return the selector array"
|
|
631 |
|
|
632 |
^ selectors
|
|
633 |
!
|
|
634 |
|
|
635 |
selectors:anArray
|
|
636 |
"set the selector array"
|
|
637 |
|
|
638 |
selectors := anArray
|
|
639 |
!
|
|
640 |
|
|
641 |
selectorAt:indexOrName
|
|
642 |
"return an individual selector"
|
|
643 |
|
|
644 |
|i|
|
|
645 |
|
|
646 |
i := self indexOf:indexOrName.
|
3
|
647 |
i ~~ 0 ifTrue:[^ selectors at:i].
|
|
648 |
^ nil
|
0
|
649 |
!
|
|
650 |
|
|
651 |
selectorAt:indexOrName put:aSelector
|
|
652 |
"set an individual selector"
|
|
653 |
|
|
654 |
|i|
|
|
655 |
|
|
656 |
i := self indexOf:indexOrName.
|
3
|
657 |
i ~~ 0 ifTrue:[selectors at:i put:aSelector]
|
0
|
658 |
!
|
|
659 |
|
|
660 |
args
|
|
661 |
"return the argument array"
|
|
662 |
|
|
663 |
^ args
|
|
664 |
!
|
|
665 |
|
|
666 |
args:anArray
|
|
667 |
"set the argument array"
|
|
668 |
|
|
669 |
args := anArray
|
|
670 |
!
|
|
671 |
|
|
672 |
argsAt:indexOrName put:something
|
|
673 |
"set an individual selector"
|
|
674 |
|
3
|
675 |
|i|
|
|
676 |
|
|
677 |
i := self indexOf:indexOrName.
|
|
678 |
i ~~ 0 ifTrue:[args at:i put:something]
|
0
|
679 |
!
|
|
680 |
|
|
681 |
receiver:anObject
|
|
682 |
"set the receiver of the message"
|
|
683 |
|
|
684 |
receiver := anObject
|
|
685 |
!
|
|
686 |
|
|
687 |
labels:text selectors:selArray args:argArray receiver:anObject
|
|
688 |
"set all relevant stuff"
|
|
689 |
|
|
690 |
self labels:text.
|
|
691 |
selectors := selArray.
|
|
692 |
args := argArray.
|
|
693 |
receiver := anObject
|
|
694 |
!
|
|
695 |
|
|
696 |
checkToggleAt:indexOrName
|
|
697 |
"return a check-toggles boolean state"
|
|
698 |
|
|
699 |
|index|
|
|
700 |
|
|
701 |
index := self indexOf:indexOrName.
|
3
|
702 |
index == 0 ifTrue:[^ false].
|
0
|
703 |
onOffFlags isNil ifTrue:[^ false].
|
|
704 |
^ onOffFlags at:index
|
|
705 |
!
|
|
706 |
|
|
707 |
checkToggleAt:indexOrName put:aBoolean
|
|
708 |
"set/clear a check-toggle"
|
|
709 |
|
|
710 |
|index|
|
|
711 |
|
|
712 |
onOffFlags isNil ifTrue:[
|
59
|
713 |
onOffFlags := Array new:(list size) withAll:false
|
0
|
714 |
].
|
|
715 |
index := self indexOf:indexOrName.
|
3
|
716 |
index == 0 ifTrue:[^ self].
|
0
|
717 |
onOffFlags at:index put:aBoolean.
|
|
718 |
shown ifTrue:[
|
59
|
719 |
self redrawLine:index
|
0
|
720 |
]
|
|
721 |
!
|
|
722 |
|
|
723 |
subMenuAt:indexOrName
|
|
724 |
"return a submenu, or nil"
|
|
725 |
|
3
|
726 |
|i|
|
|
727 |
|
0
|
728 |
subMenus isNil ifTrue:[^ nil].
|
3
|
729 |
i := self indexOf:indexOrName.
|
|
730 |
i == 0 ifTrue:[^ nil].
|
|
731 |
^ subMenus at:i
|
0
|
732 |
!
|
|
733 |
|
|
734 |
subMenuAt:indexOrName put:aPopUpMenu
|
|
735 |
"define a submenu"
|
|
736 |
|
59
|
737 |
|i newSubMenus|
|
3
|
738 |
|
|
739 |
i := self indexOf:indexOrName.
|
|
740 |
i == 0 ifTrue:[^ nil].
|
59
|
741 |
subMenus size < i ifTrue:[
|
|
742 |
newSubMenus := Array new:(list size max:i).
|
|
743 |
subMenus notNil ifTrue:[
|
|
744 |
newSubMenus replaceFrom:1 with:subMenus.
|
|
745 |
].
|
|
746 |
subMenus := newSubMenus.
|
|
747 |
self recomputeSize
|
0
|
748 |
].
|
3
|
749 |
subMenus at:i put:aPopUpMenu
|
0
|
750 |
! !
|
|
751 |
|
|
752 |
!MenuView methodsFor:'private'!
|
|
753 |
|
7
|
754 |
hideSubmenu
|
|
755 |
subMenuShown notNil ifTrue:[
|
59
|
756 |
subMenuShown hide.
|
|
757 |
subMenuShown := nil
|
7
|
758 |
].
|
|
759 |
!
|
|
760 |
|
0
|
761 |
recomputeSize
|
|
762 |
|margin2 w h|
|
|
763 |
|
|
764 |
margin2 := margin * 2.
|
|
765 |
w := self widthOfContents + leftMargin + leftMargin + margin2.
|
|
766 |
h := (self numberOfLines) * fontHeight + (2 * topMargin) + margin2.
|
21
|
767 |
"if there is a submenu, add some space for the right arrow"
|
|
768 |
subMenus notNil ifTrue:[
|
59
|
769 |
w := w + 16
|
21
|
770 |
].
|
0
|
771 |
self extent:(w @ h).
|
|
772 |
(font device == device) ifTrue:[
|
59
|
773 |
self computeNumberOfLinesShown
|
0
|
774 |
]
|
|
775 |
!
|
|
776 |
|
|
777 |
setSelectionForX:x y:y
|
7
|
778 |
|newSelection org mx my|
|
0
|
779 |
|
38
|
780 |
(x < 0
|
|
781 |
or:[x >= width
|
|
782 |
or:[y < 0
|
|
783 |
or:[y >= height]]]) ifTrue:[
|
59
|
784 |
"
|
|
785 |
moved outside submenu, but not within self
|
|
786 |
"
|
|
787 |
subMenuShown notNil ifTrue:[
|
|
788 |
^ self
|
|
789 |
].
|
38
|
790 |
].
|
|
791 |
|
0
|
792 |
newSelection := self positionToSelectionX:x y:y.
|
7
|
793 |
newSelection ~= selection ifTrue:[
|
59
|
794 |
self selection:newSelection.
|
|
795 |
subMenuShown notNil ifTrue:[
|
|
796 |
self hideSubmenu.
|
|
797 |
].
|
38
|
798 |
"/ windowGroup notNil ifTrue:[windowGroup sensor flushUserEvents].
|
59
|
799 |
newSelection notNil ifTrue:[
|
|
800 |
(enableFlags at:newSelection) ifFalse:[
|
|
801 |
newSelection := nil
|
|
802 |
] ifTrue:[
|
|
803 |
subMenus notNil ifTrue:[
|
|
804 |
subMenuShown := subMenus at:newSelection.
|
|
805 |
subMenuShown notNil ifTrue:[
|
|
806 |
"old: show at pointer"
|
7
|
807 |
"
|
59
|
808 |
org := device translatePoint:(x @ y)
|
|
809 |
from:(self id)
|
|
810 |
to:(DisplayRootView new id).
|
|
811 |
org := org - 10.
|
7
|
812 |
"
|
59
|
813 |
"new: show at right of this menu"
|
|
814 |
mx := width - 5.
|
|
815 |
my := self yOfVisibleLine:newSelection.
|
|
816 |
org := device translatePoint:(mx @ my)
|
|
817 |
from:(self id)
|
|
818 |
to:(DisplayRootView new id).
|
7
|
819 |
|
38
|
820 |
"/ ActiveGrab == self ifTrue:[
|
|
821 |
"/ device ungrabPointer.
|
|
822 |
"/ ActiveGrab := nil
|
|
823 |
"/ ].
|
|
824 |
windowGroup notNil ifTrue:[windowGroup processExposeEvents].
|
59
|
825 |
subMenuShown superMenu:self.
|
38
|
826 |
"/ subMenuShown showAt:org.
|
|
827 |
"
|
|
828 |
realize the submenu in MY windowgroup
|
|
829 |
"
|
|
830 |
subMenuShown windowGroup:windowGroup.
|
|
831 |
subMenuShown windowGroup addTopView:subMenuShown.
|
|
832 |
subMenuShown fixSize.
|
|
833 |
subMenuShown origin:org.
|
|
834 |
subMenuShown makeFullyVisible.
|
|
835 |
subMenuShown realize.
|
|
836 |
device synchronizeOutput.
|
59
|
837 |
^ self
|
|
838 |
]
|
|
839 |
] ifFalse:[
|
|
840 |
subMenuShown := nil
|
|
841 |
]
|
|
842 |
]
|
|
843 |
].
|
7
|
844 |
]
|
0
|
845 |
! !
|
|
846 |
|
|
847 |
!MenuView methodsFor:'showing'!
|
|
848 |
|
|
849 |
show
|
|
850 |
hidden := false.
|
|
851 |
super realize
|
|
852 |
! !
|
|
853 |
|
|
854 |
!MenuView methodsFor:'redrawing'!
|
|
855 |
|
|
856 |
drawMarkInVisibleLine:visLineNr with:fg and:bg
|
|
857 |
"draw an on-mark"
|
|
858 |
|
|
859 |
|w h y x l check|
|
|
860 |
|
|
861 |
l := self visibleLineToListLine:visLineNr.
|
|
862 |
onOffFlags isNil ifTrue:[
|
59
|
863 |
onOffFlags := Array new:(list size) withAll:false.
|
|
864 |
check := false
|
0
|
865 |
] ifFalse:[
|
59
|
866 |
check := onOffFlags at:l.
|
0
|
867 |
].
|
|
868 |
|
14
|
869 |
w := font widthOf:'\c'.
|
0
|
870 |
h := font ascent.
|
|
871 |
|
59
|
872 |
x := (self xOfCol:1 inVisibleLine:visLineNr) - leftOffset.
|
|
873 |
y := self yOfVisibleLine:visLineNr.
|
0
|
874 |
|
|
875 |
self paint:bg.
|
7
|
876 |
self fillRectangleX:x y:y width:w height:fontHeight.
|
0
|
877 |
self paint:fg.
|
|
878 |
check ifTrue:[
|
59
|
879 |
self paint:checkColor.
|
|
880 |
self displayLineFromX:x
|
|
881 |
y:(y + (h // 2))
|
|
882 |
toX:(x + (w // 3))
|
|
883 |
y:(y + h - 1).
|
0
|
884 |
|
59
|
885 |
self displayLineFromX:(x + (w // 3))
|
|
886 |
y:(y + h - 1)
|
|
887 |
toX:(x + w - 1)
|
|
888 |
y:y
|
0
|
889 |
]
|
|
890 |
!
|
|
891 |
|
|
892 |
drawVisibleLine:visLineNr with:fg and:bg
|
|
893 |
|line isSpecial special|
|
|
894 |
|
|
895 |
line := self visibleAt:visLineNr.
|
|
896 |
|
|
897 |
isSpecial := false.
|
|
898 |
|
|
899 |
((line at:1) == $\) ifTrue:[
|
59
|
900 |
special := line at:2.
|
|
901 |
(special == $c) ifTrue:[
|
|
902 |
isSpecial := true
|
|
903 |
]
|
0
|
904 |
].
|
|
905 |
isSpecial ifFalse:[
|
59
|
906 |
super drawVisibleLine:visLineNr with:fg and:bg
|
0
|
907 |
] ifTrue:[
|
59
|
908 |
super drawVisibleLine:visLineNr "from:3" with:fg and:bg.
|
|
909 |
self drawMarkInVisibleLine:visLineNr with:fg and:bg
|
0
|
910 |
]
|
|
911 |
!
|
|
912 |
|
38
|
913 |
drawVisibleLineSelected:visLineNr
|
|
914 |
"redraw a single line as selected."
|
|
915 |
|
|
916 |
|listLine fg bg
|
|
917 |
y "{ Class: SmallInteger }"
|
|
918 |
y2 "{ Class: SmallInteger }"
|
|
919 |
r2 radius topLeftColor botRightColor |
|
|
920 |
|
|
921 |
style ~~ #openwin ifTrue:[
|
59
|
922 |
^ super drawVisibleLineSelected:visLineNr.
|
38
|
923 |
].
|
|
924 |
"
|
|
925 |
openwin draws selections in a menu as (edged) rounded rectangles
|
|
926 |
"
|
|
927 |
|
|
928 |
bg := hilightBgColor.
|
|
929 |
fg := hilightFgColor.
|
|
930 |
listLine := self visibleLineToListLine:visLineNr.
|
|
931 |
listLine notNil ifTrue:[
|
|
932 |
|
59
|
933 |
self drawVisibleLine:visLineNr with:fg and:bg.
|
|
934 |
y := self yOfVisibleLine:visLineNr.
|
|
935 |
y2 := y + fontHeight - 1.
|
|
936 |
r2 := font height.
|
|
937 |
radius := r2 // 2.
|
38
|
938 |
|
59
|
939 |
"
|
|
940 |
refill with normal bg, where arcs will be drawn below
|
|
941 |
"
|
|
942 |
self paint:bgColor.
|
|
943 |
self fillRectangleX:margin y:y width:radius height:fontHeight.
|
|
944 |
self fillRectangleX:width-radius-margin y:y width:radius height:fontHeight.
|
38
|
945 |
|
59
|
946 |
"
|
|
947 |
fill the arcs
|
|
948 |
"
|
|
949 |
self paint:hilightBgColor.
|
|
950 |
self fillArcX:1+margin+1 y:y w:r2 h:r2+1+1 from:90 angle:180.
|
|
951 |
self fillArcX:width-r2-1-1-margin-1 y:y w:r2 h:r2+1+1 from:270 angle:180.
|
38
|
952 |
|
59
|
953 |
"
|
|
954 |
a highlight-border around
|
|
955 |
"
|
|
956 |
hilightFrameColor notNil ifTrue:[
|
|
957 |
self paint:hilightFrameColor.
|
|
958 |
self displayLineFromX:radius+2 y:y toX:width-radius-3 y:y.
|
|
959 |
self displayLineFromX:radius+2 y:y2 toX:width-radius-3 y:y2.
|
38
|
960 |
|
59
|
961 |
self displayArcX:1+margin+1 y:y w:r2 h:r2+1+1 from:90 angle:180.
|
|
962 |
self displayArcX:width-r2-1-1-margin-1 y:y w:r2 h:r2+1+1 from:270 angle:180.
|
|
963 |
^ self
|
|
964 |
].
|
38
|
965 |
|
59
|
966 |
"
|
|
967 |
an edge around
|
|
968 |
"
|
|
969 |
(hilightLevel ~~ 0) ifTrue:[
|
|
970 |
(hilightLevel < 0) ifTrue:[
|
|
971 |
topLeftColor := shadowColor.
|
|
972 |
botRightColor := lightColor.
|
|
973 |
] ifFalse:[
|
|
974 |
topLeftColor := lightColor.
|
|
975 |
botRightColor := shadowColor.
|
|
976 |
].
|
38
|
977 |
|
59
|
978 |
self paint:topLeftColor.
|
|
979 |
self displayLineFromX:radius+2 y:y toX:width-radius-3 y:y.
|
38
|
980 |
|
59
|
981 |
self displayArcX:1+margin+1 y:y w:r2 h:r2+1+1 from:90 angle:125.
|
|
982 |
self displayArcX:width-r2-1-1-margin-1 y:y w:r2 h:r2+1+1 from:270+125 angle:55.
|
38
|
983 |
|
59
|
984 |
self paint:botRightColor.
|
38
|
985 |
|
59
|
986 |
self displayLineFromX:radius+2 y:y2 toX:width-radius-3 y:y2.
|
|
987 |
self displayArcX:1+margin+1 y:y w:r2 h:r2+1+1 from:90+125 angle:55.
|
|
988 |
self displayArcX:width-r2-1-1-margin-1 y:y w:r2 h:r2+1+1 from:270 angle:125.
|
|
989 |
^ self
|
|
990 |
]
|
38
|
991 |
].
|
|
992 |
^ super drawVisibleLine:visLineNr with:fg and:bg
|
|
993 |
!
|
|
994 |
|
0
|
995 |
redrawVisibleLine:visLine col:col
|
|
996 |
self redrawVisibleLine:visLine
|
|
997 |
!
|
|
998 |
|
|
999 |
redrawVisibleLine:visLine from:startCol
|
|
1000 |
self redrawVisibleLine:visLine
|
|
1001 |
!
|
|
1002 |
|
|
1003 |
redrawVisibleLine:visLine from:startCol to:endCol
|
|
1004 |
self redrawVisibleLine:visLine
|
|
1005 |
!
|
|
1006 |
|
|
1007 |
redrawVisibleLine:visLineNr
|
38
|
1008 |
|line lineNr y isSpecial isSeparatingLine right clr1 clr2|
|
0
|
1009 |
|
|
1010 |
line := self visibleAt:visLineNr.
|
|
1011 |
|
|
1012 |
isSpecial := false.
|
|
1013 |
(line = '-') ifTrue:[
|
59
|
1014 |
isSeparatingLine := true.
|
|
1015 |
isSpecial := true
|
0
|
1016 |
] ifFalse:[
|
59
|
1017 |
(line = '') ifTrue:[
|
|
1018 |
isSeparatingLine := false.
|
|
1019 |
isSpecial := true
|
|
1020 |
]
|
0
|
1021 |
].
|
|
1022 |
isSpecial ifFalse:[
|
59
|
1023 |
lineNr := self visibleLineToListLine:visLineNr.
|
|
1024 |
(enableFlags at:lineNr) ifFalse:[
|
|
1025 |
self drawVisibleLine:visLineNr with:disabledFgColor and:bgColor
|
|
1026 |
] ifTrue:[
|
|
1027 |
super redrawVisibleLine:visLineNr
|
|
1028 |
].
|
|
1029 |
"is there a submenu ?"
|
|
1030 |
(subMenus notNil and:[(subMenus at:lineNr) notNil]) ifTrue:[
|
|
1031 |
self drawRightArrowInVisibleLine:visLineNr
|
|
1032 |
].
|
|
1033 |
^ self
|
0
|
1034 |
].
|
|
1035 |
|
|
1036 |
"handle separating lines"
|
|
1037 |
|
59
|
1038 |
y := self yOfVisibleLine:visLineNr.
|
38
|
1039 |
|
|
1040 |
self paint:bgColor.
|
|
1041 |
self fillRectangleX:0 y:y width:width height:fontHeight.
|
|
1042 |
|
0
|
1043 |
isSeparatingLine ifTrue:[
|
59
|
1044 |
y := y + (fontHeight // 2).
|
|
1045 |
lineLevel == 0 ifTrue:[
|
|
1046 |
self paint:fgColor.
|
|
1047 |
self displayLineFromX:0 y:y toX:width y:y
|
|
1048 |
] ifFalse:[
|
|
1049 |
"the inset on each side"
|
38
|
1050 |
|
59
|
1051 |
lineLevel < 0 ifTrue:[
|
|
1052 |
clr1 := shadowColor.
|
|
1053 |
clr2 := lightColor.
|
|
1054 |
] ifFalse:[
|
|
1055 |
clr1 := lightColor.
|
|
1056 |
clr2 := shadowColor.
|
|
1057 |
].
|
|
1058 |
self paint:clr1.
|
|
1059 |
right := width - 1 - lineInset.
|
|
1060 |
self displayLineFromX:lineInset y:y toX:right y:y.
|
|
1061 |
self paint:clr2.
|
|
1062 |
y := y + 1.
|
|
1063 |
self displayLineFromX:lineInset y:y toX:right y:y
|
|
1064 |
]
|
0
|
1065 |
]
|
|
1066 |
!
|
|
1067 |
|
|
1068 |
redrawFromVisibleLine:start to:stop
|
|
1069 |
"redraw a line range"
|
|
1070 |
|
|
1071 |
"the natural way to do it is:
|
|
1072 |
|
|
1073 |
start to:stop do:[:visLine |
|
59
|
1074 |
self redrawVisibleLine:visLine
|
0
|
1075 |
]
|
|
1076 |
|
|
1077 |
but I want to draw the stuff in big chunks for slow machines ..."
|
|
1078 |
|
|
1079 |
|first current line special index|
|
|
1080 |
|
|
1081 |
first := start.
|
|
1082 |
current := start.
|
|
1083 |
index := self visibleLineToListLine:start.
|
|
1084 |
index notNil ifTrue:[
|
59
|
1085 |
[current <= stop] whileTrue:[
|
|
1086 |
line := self visibleAt:current.
|
0
|
1087 |
|
59
|
1088 |
special := (line = '-') or:[(line = '') or:[(line at:1) == $\]].
|
|
1089 |
(special
|
|
1090 |
or:[(enableFlags at:index) not]) ifTrue:[
|
|
1091 |
"a special case"
|
|
1092 |
(first < current) ifTrue:[
|
|
1093 |
super redrawFromVisibleLine:first to:(current - 1)
|
|
1094 |
].
|
|
1095 |
self redrawVisibleLine:current.
|
|
1096 |
first := current + 1
|
|
1097 |
].
|
|
1098 |
current := current + 1.
|
|
1099 |
index := index + 1
|
|
1100 |
].
|
|
1101 |
(first < current) ifTrue:[
|
|
1102 |
super redrawFromVisibleLine:first to:(current - 1)
|
|
1103 |
].
|
21
|
1104 |
|
59
|
1105 |
"draw submenu marks"
|
|
1106 |
subMenus notNil ifTrue:[
|
|
1107 |
index := self visibleLineToListLine:start.
|
|
1108 |
start to:stop do:[:l |
|
|
1109 |
index <= subMenus size ifTrue:[
|
|
1110 |
(subMenus at:index) notNil ifTrue:[
|
|
1111 |
self drawRightArrowInVisibleLine:l
|
|
1112 |
].
|
|
1113 |
index := index + 1
|
|
1114 |
]
|
|
1115 |
]
|
|
1116 |
]
|
0
|
1117 |
]
|
|
1118 |
! !
|
|
1119 |
|
7
|
1120 |
!MenuView methodsFor:'submenu actions'!
|
|
1121 |
|
|
1122 |
submenuTriggered
|
|
1123 |
"submenu has performed some action - have to deselect here"
|
|
1124 |
|
|
1125 |
self selection:nil.
|
|
1126 |
"a bad kludge - 5 minutes before writing the alpha tapes ..."
|
|
1127 |
(superView isKindOf:PopUpMenu) ifTrue:[
|
59
|
1128 |
superView hide
|
7
|
1129 |
].
|
|
1130 |
superMenu notNil ifTrue:[
|
59
|
1131 |
superMenu submenuTriggered
|
7
|
1132 |
].
|
|
1133 |
!
|
|
1134 |
|
38
|
1135 |
XXregainControl
|
7
|
1136 |
"take over pointer control from a submenu"
|
|
1137 |
|
|
1138 |
^ self
|
|
1139 |
!
|
|
1140 |
|
|
1141 |
showActive
|
|
1142 |
"submenu is about to perform an action - show wait cursor here as well"
|
|
1143 |
|
|
1144 |
self cursor:(Cursor wait)
|
|
1145 |
!
|
|
1146 |
|
|
1147 |
showPassive
|
|
1148 |
"submenu has performed its action - show normal cursor again"
|
|
1149 |
|
|
1150 |
self cursor:(Cursor hand)
|
|
1151 |
! !
|
|
1152 |
|
0
|
1153 |
!MenuView methodsFor:'event handling'!
|
|
1154 |
|
|
1155 |
buttonPress:button x:x y:y
|
|
1156 |
self setSelectionForX:x y:y
|
|
1157 |
!
|
|
1158 |
|
|
1159 |
buttonMotion:state x:x y:y
|
|
1160 |
self setSelectionForX:x y:y
|
|
1161 |
!
|
|
1162 |
|
|
1163 |
pointerLeave:state
|
7
|
1164 |
subMenuShown notNil ifTrue:[
|
59
|
1165 |
^ self
|
7
|
1166 |
].
|
38
|
1167 |
"/ self setSelectionForX:-1 y:-1. "force deselect"
|
7
|
1168 |
subMenuShown isNil ifTrue:[
|
59
|
1169 |
self selection:nil
|
7
|
1170 |
].
|
38
|
1171 |
"/ superMenu notNil ifTrue:[
|
|
1172 |
"/ superMenu regainControl.
|
|
1173 |
"/ ]
|
0
|
1174 |
!
|
|
1175 |
|
|
1176 |
buttonRelease:button x:x y:y
|
|
1177 |
|theSelector isCheck|
|
|
1178 |
|
7
|
1179 |
subMenuShown notNil ifTrue:[
|
59
|
1180 |
^ self
|
7
|
1181 |
].
|
|
1182 |
|
0
|
1183 |
(x >= 0 and:[x < width]) ifTrue:[
|
59
|
1184 |
(y >= 0 and:[y < height]) ifTrue:[
|
|
1185 |
selection notNil ifTrue:[
|
|
1186 |
(subMenus isNil or:[(subMenus at:selection) isNil]) ifTrue:[
|
|
1187 |
self cursor:Cursor wait.
|
|
1188 |
superMenu notNil ifTrue:[
|
|
1189 |
superMenu showActive
|
|
1190 |
].
|
|
1191 |
"
|
|
1192 |
either action-block or selectors-array-style
|
|
1193 |
"
|
|
1194 |
actionBlock notNil ifTrue:[
|
|
1195 |
Object abortSignal handle:[:ex |
|
|
1196 |
ex return
|
|
1197 |
] do:[
|
|
1198 |
actionBlock value:(self selection)
|
|
1199 |
]
|
|
1200 |
] ifFalse:[
|
|
1201 |
selectors notNil ifTrue: [
|
|
1202 |
ActiveGrab == self ifTrue:[
|
|
1203 |
device ungrabPointer.
|
|
1204 |
ActiveGrab := nil.
|
|
1205 |
].
|
|
1206 |
(selectors isKindOf:Symbol) ifFalse:[
|
|
1207 |
selection <= (selectors size) ifTrue:[
|
|
1208 |
theSelector := selectors at:selection
|
|
1209 |
]
|
|
1210 |
] ifTrue:[
|
|
1211 |
theSelector := selectors
|
|
1212 |
].
|
|
1213 |
theSelector notNil ifTrue:[
|
|
1214 |
isCheck := false.
|
|
1215 |
onOffFlags notNil ifTrue:[
|
|
1216 |
onOffFlags size >= selection ifTrue:[
|
|
1217 |
isCheck := (onOffFlags at:selection) notNil
|
|
1218 |
]
|
|
1219 |
].
|
|
1220 |
Object abortSignal handle:[:ex |
|
|
1221 |
ex return
|
|
1222 |
] do:[
|
|
1223 |
isCheck ifTrue:[
|
|
1224 |
onOffFlags at:selection
|
|
1225 |
put:(onOffFlags at:selection) not.
|
|
1226 |
self redrawLine:selection.
|
|
1227 |
receiver perform:theSelector
|
|
1228 |
with:(onOffFlags at:selection)
|
|
1229 |
] ifFalse:[
|
|
1230 |
args isNil ifTrue:[
|
|
1231 |
receiver perform:theSelector
|
|
1232 |
] ifFalse:[
|
|
1233 |
receiver perform:theSelector
|
|
1234 |
with:(args at:selection)
|
|
1235 |
]
|
|
1236 |
]
|
|
1237 |
]
|
|
1238 |
]
|
|
1239 |
]
|
|
1240 |
].
|
|
1241 |
realized ifTrue:[
|
|
1242 |
self cursor:Cursor hand.
|
|
1243 |
].
|
|
1244 |
superMenu notNil ifTrue:[
|
|
1245 |
superMenu showPassive
|
|
1246 |
].
|
|
1247 |
].
|
|
1248 |
]
|
|
1249 |
]
|
0
|
1250 |
]
|
|
1251 |
! !
|