author | Claus Gittinger <cg@exept.de> |
Tue, 05 Dec 1995 20:12:25 +0100 | |
changeset 238 | a81e517187e4 |
parent 228 | dd2c63ac0b13 |
child 245 | 13513c63df71 |
permissions | -rw-r--r-- |
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 |
|
202 | 14 |
instanceVariableNames:'selectors args receiver enableFlags disabledFgColor onOffFlags |
224 | 15 |
subMenus subMenuShown superMenu checkColor lineLevel lineInset |
16 |
masterView hilightStyle needResize hideOnRelease' |
|
202 | 17 |
classVariableNames:'DefaultFont DefaultCheckColor DefaultViewBackground |
224 | 18 |
DefaultForegroundColor DefaultBackgroundColor |
19 |
DefaultDisabledForegroundColor DefaultHilightForegroundColor |
|
20 |
DefaultHilightBackgroundColor DefaultHilightLevel |
|
21 |
DefaultHilightStyle DefaultHilightFrameColor DefaultLineLevel |
|
22 |
DefaultLineInset DefaultShadowColor DefaultLightColor' |
|
202 | 23 |
poolDictionaries:'' |
24 |
category:'Views-Menus' |
|
0 | 25 |
! |
26 |
||
3 | 27 |
!MenuView class methodsFor:'documentation'! |
28 |
||
38 | 29 |
copyright |
30 |
" |
|
31 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 32 |
All Rights Reserved |
38 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
3 | 43 |
documentation |
44 |
" |
|
63 | 45 |
a menu view used for both pull-down-menus and pop-up-menus (and also, |
46 |
for nonModal menus, such as the Launchers click-menu). |
|
38 | 47 |
the action to be performed can be defined either as: |
0 | 48 |
|
38 | 49 |
1) action:aBlockWithOneArg |
50 |
which defines a block to be called with the line number (1..n) |
|
51 |
of the selected line. |
|
0 | 52 |
|
119 | 53 |
2) selectors:selectorArray [args: argArray] [receiver:anObject] |
54 |
which defines the messages to be sent to the model or |
|
55 |
receiver. Giving an explicit receiver overrides the model. |
|
0 | 56 |
|
38 | 57 |
It is also possible to define both actionBlock and selectorArray. |
0 | 58 |
|
63 | 59 |
The wellknown popups are created by wrapping a MenuView into an instance of |
60 |
PopUpMenu (read the description of popupmenu). |
|
61 |
||
38 | 62 |
menu entries starting with '\c' are check-entries. |
131 | 63 |
menu entries starting with '\b' are checkBox-entries. |
64 |
menu entries starting with '\t' are thumbUp/Down-entries. |
|
38 | 65 |
menu entries conisting of '-' alone, are separating lines. |
63 | 66 |
menu entries conisting of '=' alone, are double separating lines. |
130 | 67 |
|
68 |
||
69 |
StyleSheet defaults: |
|
70 |
||
71 |
menuFont font to use for menus |
|
72 |
||
73 |
menuViewBackground view background (should be same as menuBackgroundColor) |
|
74 |
menuForegroundColor foreground color |
|
75 |
menuBackgroundColor background color |
|
76 |
||
77 |
menuShadowColor shadow color for 3D effects |
|
78 |
menuLightColor lightColor for 3D effects |
|
79 |
menuHilightForegroundColor hilighted items foregroundColor |
|
80 |
menuHilightBackgroundColor hilighted items backgroundColor |
|
81 |
||
82 |
menuHilightFrameColor frame arounf hilighted items (or nil, if none) |
|
83 |
defaults to selectionHilightFrameColor |
|
84 |
menuHilightLevel 3D level of selected items |
|
85 |
menuHilightStyle #openwin or nil (special kludge) |
|
86 |
menuSeparatingLineLevel 3D level of sep. lines |
|
87 |
menuSeparatingLineInset left/right inset of sep. lines |
|
88 |
menuDisabledForegroundColor foreground color of disabled items |
|
89 |
menuCheckColor color to use for check marks |
|
90 |
menuFont font to use |
|
91 |
||
92 |
other values and some defaults are inherited via SelectionInListViews |
|
93 |
styles (i.e. look for selectionForegroundColor ...) |
|
63 | 94 |
" |
95 |
! |
|
21 | 96 |
|
63 | 97 |
examples |
98 |
" |
|
45 | 99 |
Examples: |
59 | 100 |
Notice: normally, menuviews are wrapped into either a popup- |
101 |
menu or pulldown-menu. But they can also be used stand-alone |
|
102 |
as in: |
|
45 | 103 |
|
59 | 104 |
|m| |
105 |
m := MenuView |
|
106 |
labels:#('foo' |
|
107 |
'bar' |
|
108 |
'baz') |
|
109 |
selectors:#( |
|
110 |
#foo |
|
111 |
#bar |
|
112 |
#baz) |
|
113 |
receiver:nil. |
|
114 |
m open |
|
3 | 115 |
" |
202 | 116 |
! ! |
117 |
||
118 |
!MenuView class methodsFor:'instance creation'! |
|
119 |
||
120 |
labels:labels |
|
121 |
"create and return a new MenuView. The parent view, |
|
122 |
selectors and receiver should be set later." |
|
123 |
||
124 |
^ self labels:labels selectors:nil args:nil receiver:nil |
|
125 |
! |
|
126 |
||
127 |
labels:labels selector:aSelector args:argArray receiver:anObject for:aTopMenu |
|
128 |
"create and return a new MenuView |
|
129 |
- receiverObject gets message aSelector with argument from |
|
130 |
argArray for ALL entries" |
|
131 |
||
132 |
"OBSOLETE protocol: labels:selectors:args:receiver: knows how to handle a |
|
133 |
single symbol-arg for selectors ..." |
|
134 |
||
135 |
^ self labels:labels selectors:aSelector args:argArray receiver:anObject in:(aTopMenu superView) |
|
136 |
! |
|
137 |
||
138 |
labels:labels selector:aSelector args:argArray receiver:anObject in:aTopMenu |
|
139 |
"create and return a new MenuView |
|
140 |
- receiverObject gets message aSelector with argument from |
|
141 |
argArray for all entries" |
|
142 |
||
143 |
"OBSOLETE protocol: labels:selectors:args:receiver: knows how to handle a |
|
144 |
single symbol-arg for selectors ..." |
|
145 |
||
146 |
^ self labels:labels selectors:aSelector args:argArray receiver:anObject in:aTopMenu |
|
147 |
! |
|
148 |
||
149 |
labels:labels selectors:selArray |
|
150 |
"create and return a new MenuView. The parent veiw |
|
151 |
and receiver should be set later." |
|
152 |
||
153 |
^ self labels:labels selectors:selArray args:nil receiver:nil |
|
154 |
! |
|
155 |
||
156 |
labels:labels selectors:selArray args:argArray |
|
157 |
"create and return a new MenuView. The parent view |
|
158 |
should be set later." |
|
159 |
||
160 |
^ self labels:labels selectors:selArray args:argArray |
|
161 |
! |
|
162 |
||
163 |
labels:labels selectors:selArray args:argArray receiver:anObject |
|
164 |
"create and return a new MenuView. The parent view |
|
165 |
should be set later." |
|
166 |
||
167 |
^ (self new) |
|
168 |
labels:labels |
|
169 |
selectors:selArray |
|
170 |
args:argArray |
|
171 |
receiver:anObject |
|
172 |
! |
|
173 |
||
174 |
labels:labels selectors:selArray args:argArray receiver:anObject for:aTopMenu |
|
175 |
"create and return a new MenuView for a topMenu" |
|
176 |
||
177 |
^ self labels:labels selectors:selArray args:argArray receiver:anObject in:(aTopMenu superView) |
|
178 |
! |
|
179 |
||
180 |
labels:labels selectors:selArray args:argArray receiver:anObject in:aView |
|
181 |
"create and return a new MenuView in aView |
|
182 |
- receiverObject gets message from selectorArray with argument |
|
183 |
from argArray" |
|
184 |
||
185 |
^ (self in:aView) |
|
186 |
labels:labels |
|
187 |
selectors:selArray |
|
188 |
args:argArray |
|
189 |
receiver:anObject |
|
190 |
! |
|
191 |
||
192 |
labels:labels selectors:selArray receiver:anObject |
|
193 |
"create and return a new MenuView. The parent view |
|
194 |
should be set later." |
|
195 |
||
196 |
^ self labels:labels selectors:selArray args:nil receiver:anObject |
|
197 |
! |
|
198 |
||
199 |
labels:labels selectors:selArray receiver:anObject for:aTopMenu |
|
200 |
^ self labels:labels selectors:selArray args:nil receiver:anObject for:aTopMenu |
|
201 |
! |
|
202 |
||
203 |
labels:labels selectors:selArray receiver:anObject in:aView |
|
204 |
"create and return a new MenuView in aView |
|
205 |
- receiverObject gets message from selectorArray without argument" |
|
206 |
||
207 |
^ self labels:labels selectors:selArray args:nil receiver:anObject in:aView |
|
3 | 208 |
! ! |
0 | 209 |
|
59 | 210 |
!MenuView class methodsFor:'defaults'! |
211 |
||
212 |
updateStyleCache |
|
60 | 213 |
DefaultViewBackground := StyleSheet colorAt:'menuViewBackground'. |
214 |
DefaultForegroundColor := StyleSheet colorAt:'menuForegroundColor'. |
|
215 |
DefaultBackgroundColor := StyleSheet colorAt:'menuBackgroundColor'. |
|
216 |
DefaultShadowColor := StyleSheet colorAt:'menuShadowColor'. |
|
217 |
DefaultLightColor := StyleSheet colorAt:'menuLightColor'. |
|
218 |
DefaultHilightForegroundColor := StyleSheet colorAt:'menuHilightForegroundColor'. |
|
219 |
DefaultHilightBackgroundColor := StyleSheet colorAt:'menuHilightBackgroundColor'. |
|
130 | 220 |
DefaultHilightFrameColor := StyleSheet colorAt:'menuHilightFrameColor' |
221 |
default:(StyleSheet colorAt:'selectionHilightFrameColor'). |
|
59 | 222 |
DefaultHilightLevel := StyleSheet at:'menuHilightLevel'. |
77 | 223 |
DefaultHilightStyle := StyleSheet at:'menuHilightStyle'. |
59 | 224 |
DefaultLineLevel := StyleSheet at:'menuSeparatingLineLevel'. |
130 | 225 |
DefaultLineInset := StyleSheet at:'menuSeparatingLineInset'. |
60 | 226 |
DefaultDisabledForegroundColor := StyleSheet colorAt:'menuDisabledForegroundColor' default:Color darkGrey. |
227 |
DefaultCheckColor := StyleSheet colorAt:'menuCheckColor'. |
|
228 |
DefaultFont := StyleSheet fontAt:'menuFont'. |
|
0 | 229 |
! ! |
230 |
||
136 | 231 |
!MenuView methodsFor:'accessing-behavior'! |
232 |
||
233 |
disable:indexOrName |
|
234 |
"disable an entry" |
|
235 |
||
236 |
self setEnable:indexOrName to:false |
|
237 |
! |
|
238 |
||
239 |
disableAll:collectionOfIndicesOrNames |
|
240 |
"disable an collection of entries" |
|
241 |
||
242 |
collectionOfIndicesOrNames do:[:entry | |
|
243 |
self disable:entry |
|
244 |
] |
|
245 |
! |
|
246 |
||
202 | 247 |
enable:indexOrName |
248 |
"enable an entry" |
|
249 |
||
250 |
self setEnable:indexOrName to:true |
|
251 |
! |
|
252 |
||
136 | 253 |
enableAll:collectionOfIndicesOrNames |
254 |
"enable an collection of entries" |
|
255 |
||
256 |
collectionOfIndicesOrNames do:[:entry | |
|
257 |
self enable:entry |
|
258 |
] |
|
259 |
! |
|
260 |
||
202 | 261 |
hideOnRelease:aBoolean |
262 |
hideOnRelease := aBoolean |
|
263 |
! |
|
264 |
||
136 | 265 |
isEnabled:indexOrName |
266 |
|index| |
|
267 |
||
268 |
index := self indexOf:indexOrName. |
|
269 |
index ~~ 0 ifTrue:[ |
|
270 |
enableFlags isNil ifTrue:[^ true]. |
|
271 |
^ enableFlags at:index |
|
272 |
]. |
|
273 |
"ask submenus for convenience" |
|
274 |
(indexOrName isNumber not and:[subMenus notNil]) ifTrue:[ |
|
275 |
subMenus do:[:m | |
|
276 |
m notNil ifTrue:[ |
|
277 |
m enable:indexOrName |
|
278 |
] |
|
279 |
] |
|
280 |
] |
|
281 |
! |
|
282 |
||
283 |
setEnable:indexOrName to:aBoolean |
|
284 |
"enable/disable an entry" |
|
285 |
||
286 |
|index| |
|
287 |
||
288 |
index := self indexOf:indexOrName. |
|
289 |
index ~~ 0 ifTrue:[ |
|
290 |
(enableFlags at:index) ~~ aBoolean ifTrue:[ |
|
291 |
enableFlags at:index put:aBoolean. |
|
292 |
shown ifTrue:[ |
|
293 |
self redrawLine:index |
|
294 |
] |
|
295 |
] |
|
296 |
] ifFalse:[ |
|
297 |
"try submenus for convenience" |
|
298 |
(indexOrName isNumber not and:[subMenus notNil]) ifTrue:[ |
|
299 |
subMenus do:[:m | |
|
300 |
m notNil ifTrue:[ |
|
301 |
m setEnable:indexOrName to:aBoolean |
|
302 |
] |
|
303 |
] |
|
304 |
] |
|
305 |
] |
|
306 |
! ! |
|
307 |
||
308 |
!MenuView methodsFor:'accessing-items'! |
|
7 | 309 |
|
0 | 310 |
addLabel:aLabel selector:aSelector |
311 |
"add another label/selector pair" |
|
312 |
||
313 |
list isNil ifTrue:[ |
|
59 | 314 |
list := Array with:aLabel |
0 | 315 |
] ifFalse:[ |
59 | 316 |
list := list copyWith:aLabel |
0 | 317 |
]. |
318 |
selectors := selectors copyWith:aSelector. |
|
319 |
enableFlags := enableFlags copyWith:true. |
|
119 | 320 |
shown ifTrue:[ |
127 | 321 |
self resize |
119 | 322 |
] ifFalse:[ |
323 |
needResize := true |
|
324 |
] |
|
0 | 325 |
! |
326 |
||
38 | 327 |
addLabel:aLabel selector:aSelector after:aLabelOrSelectorOrNumber |
328 |
"insert another label/selector pair at some place. |
|
329 |
Being very friendly here, allowing label-string, selector or numeric |
|
95 | 330 |
index for the argument aLabelOrSelectorOrNumber. |
331 |
||
332 |
To be independent of the entries label, we recommend you use the selector |
|
333 |
as index; in systems which translate strings for national variants, |
|
334 |
this makes your code easier to maintain." |
|
335 |
||
336 |
^ self addLabel:aLabel |
|
337 |
selector:aSelector |
|
338 |
before:(self indexOf:aLabelOrSelectorOrNumber) + 1 |
|
339 |
" |
|
340 |
|v1 v2 v3 v4| |
|
341 |
||
342 |
v1 := CodeView new realize. |
|
343 |
||
344 |
v2 := CodeView new realize. |
|
119 | 345 |
v2 middleButtonMenu: |
346 |
v editMenu addLabel:'new entry' selector:#foo after:'paste'. |
|
95 | 347 |
|
348 |
v3 := CodeView new realize. |
|
119 | 349 |
v3 middleButtonMenu: |
350 |
v editMenu addLabel:'new entry' selector:#foo after:#others. |
|
95 | 351 |
|
352 |
v4 := CodeView new realize. |
|
119 | 353 |
v4 middleButtonMenu: |
354 |
v editMenu addLabel:'new entry' selector:#foo after:1. |
|
355 |
" |
|
356 |
! |
|
357 |
||
202 | 358 |
addLabel:aLabel selector:aSelector arg:anArg |
359 |
"add another label/selector/argument trio" |
|
360 |
||
361 |
list isNil ifTrue:[ |
|
362 |
list := Array with:aLabel |
|
363 |
] ifFalse:[ |
|
364 |
list := list copyWith:aLabel |
|
365 |
]. |
|
366 |
selectors := selectors copyWith:aSelector. |
|
367 |
args := args copyWith:anArg. |
|
368 |
enableFlags := enableFlags copyWith:true. |
|
369 |
shown ifTrue:[ |
|
370 |
self resize |
|
371 |
] ifFalse:[ |
|
372 |
needResize := true |
|
373 |
] |
|
374 |
! |
|
375 |
||
376 |
addLabel:aLabel selector:aSelector before:aLabelOrSelectorOrNumber |
|
377 |
"insert another label/selector pair at some place. |
|
378 |
Being very friendly here, allowing label-string, selector or numeric |
|
379 |
index for the argument aLabelOrSelectorOrNumber. |
|
380 |
||
381 |
To be independent of the entries label, we recommend you use the selector |
|
382 |
as index; in systems which translate strings for national variants, |
|
383 |
this makes your code easier to maintain." |
|
384 |
||
385 |
|idx| |
|
386 |
||
387 |
list isNil ifTrue:[ |
|
388 |
^ self addLabel:aLabel selector:aSelector |
|
389 |
]. |
|
390 |
" |
|
391 |
be user friendly - allow both label or selector |
|
392 |
to be passed |
|
393 |
" |
|
394 |
idx := self indexOf:aLabelOrSelectorOrNumber. |
|
395 |
(idx between:1 and:list size) ifFalse:[ |
|
396 |
"add to end" |
|
397 |
^ self addLabel:aLabel selector:aSelector |
|
398 |
]. |
|
399 |
||
400 |
list := list asOrderedCollection. |
|
401 |
list add:aLabel beforeIndex:idx. |
|
402 |
selectors := selectors asOrderedCollection. |
|
403 |
selectors add:aSelector beforeIndex:idx. |
|
404 |
enableFlags := enableFlags asOrderedCollection. |
|
405 |
enableFlags add:true beforeIndex:idx. |
|
406 |
subMenus notNil ifTrue:[ |
|
407 |
subMenus := subMenus asOrderedCollection. |
|
408 |
subMenus add:nil beforeIndex:idx. |
|
409 |
]. |
|
410 |
args notNil ifTrue:[ |
|
411 |
args := args asOrderedCollection. |
|
412 |
args add:nil beforeIndex:idx. |
|
413 |
]. |
|
414 |
shown ifTrue:[ |
|
415 |
self resize |
|
416 |
] ifFalse:[ |
|
417 |
needResize := true |
|
418 |
] |
|
419 |
||
420 |
" |
|
421 |
|v1 v2 v3 v4| |
|
422 |
||
423 |
v1 := CodeView new realize. |
|
424 |
||
425 |
v2 := CodeView new realize. |
|
426 |
v2 middleButtonMenu: |
|
427 |
(v2 editMenu) addLabel:'new entry' selector:#foo before:'paste'. |
|
428 |
||
429 |
v3 := CodeView new realize. |
|
430 |
v3 middleButtonMenu: |
|
431 |
(v3 editMenu) addLabel:'new entry' selector:#foo before:#again. |
|
432 |
||
433 |
v4 := CodeView new realize. |
|
434 |
v4 middleButtonMenu: |
|
435 |
(v4 editMenu) addLabel:'new entry' selector:#foo before:1. |
|
436 |
" |
|
437 |
! |
|
438 |
||
131 | 439 |
addLabels:moreLabels selectors:moreSelectors |
440 |
"add more labels and selectors at the end" |
|
441 |
||
442 |
list isNil ifTrue:[ |
|
443 |
list := moreLabels |
|
444 |
] ifFalse:[ |
|
445 |
list := list , moreLabels |
|
446 |
]. |
|
447 |
selectors := selectors , moreSelectors. |
|
448 |
enableFlags := enableFlags , (Array new:moreLabels size withAll:true). |
|
449 |
shown ifTrue:[ |
|
450 |
self resize |
|
451 |
] ifFalse:[ |
|
452 |
needResize := true |
|
453 |
] |
|
454 |
! |
|
455 |
||
119 | 456 |
addLabels:moreLabels selectors:moreSelectors after:aLabelOrSelectorOrNumber |
457 |
"insert more labels/selectors at some place. |
|
458 |
Being very friendly here, allowing label-string, selector or numeric |
|
459 |
index for the argument aLabelOrSelectorOrNumber. |
|
460 |
||
461 |
To be independent of the entries label, we recommend you use the selector |
|
462 |
as index; in systems which translate strings for national variants, |
|
463 |
this makes your code easier to maintain." |
|
464 |
||
465 |
^ self addLabels:moreLabels |
|
466 |
selectors:moreSelectors |
|
467 |
before:(self indexOf:aLabelOrSelectorOrNumber) + 1 |
|
468 |
! |
|
469 |
||
470 |
addLabels:moreLabels selectors:moreSelectors before:aLabelOrSelectorOrNumber |
|
471 |
"insert more labels/selectors at some place. |
|
472 |
Being very friendly here, allowing label-string, selector or numeric |
|
473 |
index for the argument aLabelOrSelectorOrNumber. |
|
474 |
||
475 |
To be independent of the entries label, we recommend you use the selector |
|
476 |
as index; in systems which translate strings for national variants, |
|
477 |
this makes your code easier to maintain." |
|
478 |
||
479 |
|idx |
|
480 |
i "{ Class: SmallInteger }" |
|
481 |
nMore "{ Class: SmallInteger }"| |
|
482 |
||
483 |
list isNil ifTrue:[ |
|
484 |
^ self addLabels:moreLabels selectors:moreSelectors |
|
485 |
]. |
|
486 |
" |
|
487 |
be user friendly - allow both label or selector |
|
488 |
to be passed |
|
489 |
" |
|
490 |
idx := self indexOf:aLabelOrSelectorOrNumber. |
|
491 |
(idx between:1 and:list size) ifFalse:[ |
|
492 |
"add to end" |
|
493 |
^ self addLabels:moreLabels selectors:moreSelectors |
|
494 |
]. |
|
495 |
||
496 |
nMore := moreLabels size. |
|
497 |
"/ just a check |
|
498 |
moreSelectors size ~~ nMore ifTrue:[ |
|
499 |
^ self error |
|
500 |
]. |
|
501 |
||
502 |
list := list asOrderedCollection. |
|
503 |
i := idx. |
|
504 |
moreLabels do:[:aLabel | |
|
505 |
list add:aLabel beforeIndex:i. i := i + 1. |
|
506 |
]. |
|
507 |
||
508 |
selectors := selectors asOrderedCollection. |
|
509 |
i := idx. |
|
510 |
moreSelectors do:[:sel | |
|
511 |
selectors add:sel beforeIndex:i. i := i + 1. |
|
512 |
]. |
|
513 |
||
514 |
enableFlags := enableFlags asOrderedCollection. |
|
515 |
i := idx. |
|
516 |
nMore timesRepeat:[ |
|
517 |
enableFlags add:true beforeIndex:i. i := i + 1. |
|
518 |
]. |
|
519 |
||
520 |
subMenus notNil ifTrue:[ |
|
521 |
subMenus := subMenus asOrderedCollection. |
|
522 |
i := idx. |
|
523 |
nMore timesRepeat:[ |
|
524 |
subMenus add:nil beforeIndex:i. i := i + 1. |
|
525 |
]. |
|
526 |
]. |
|
527 |
args notNil ifTrue:[ |
|
528 |
args := args asOrderedCollection. |
|
529 |
i := idx. |
|
530 |
nMore timesRepeat:[ |
|
531 |
args add:nil beforeIndex:i. i := i + 1. |
|
532 |
] |
|
533 |
]. |
|
534 |
shown ifTrue:[ |
|
127 | 535 |
self resize |
119 | 536 |
] ifFalse:[ |
537 |
needResize := true |
|
538 |
] |
|
539 |
||
540 |
" |
|
541 |
|v1 v2 v3 v4 m| |
|
542 |
||
543 |
||
544 |
v1 := CodeView new realize. |
|
545 |
||
546 |
v2 := CodeView new realize. |
|
547 |
m := v2 editMenu. |
|
548 |
m |
|
549 |
addLabels:#('new entry1' 'new entry2') |
|
550 |
selectors:#(foo bar) |
|
551 |
before:'paste'. |
|
552 |
v2 middleButtonMenu:m. |
|
553 |
||
554 |
v3 := CodeView new realize. |
|
555 |
m := v3 editMenu. |
|
556 |
m |
|
557 |
addLabels:#('new entry1' 'new entry2') |
|
558 |
selectors:#(foo bar) |
|
559 |
before:#again. |
|
560 |
v3 middleButtonMenu:m. |
|
561 |
||
562 |
v4 := CodeView new realize. |
|
563 |
m := v4 editMenu. |
|
564 |
m |
|
565 |
addLabels:#('new entry1' 'new entry2') |
|
566 |
selectors:#(foo bar) |
|
567 |
before:1. |
|
568 |
v4 middleButtonMenu:m. |
|
95 | 569 |
" |
570 |
! |
|
571 |
||
202 | 572 |
addSeparatingLine |
573 |
"add a separating line" |
|
60 | 574 |
|
202 | 575 |
self addLabel:'-' selector:nil |
60 | 576 |
! |
577 |
||
202 | 578 |
addSeparatingLineAfter:aLabelOrSelectorOrNumber |
579 |
"add a separating line" |
|
133 | 580 |
|
202 | 581 |
self addLabel:'-' selector:nil after:aLabelOrSelectorOrNumber |
0 | 582 |
! |
583 |
||
584 |
args |
|
585 |
"return the argument array" |
|
586 |
||
587 |
^ args |
|
588 |
! |
|
589 |
||
590 |
args:anArray |
|
591 |
"set the argument array" |
|
592 |
||
593 |
args := anArray |
|
594 |
! |
|
595 |
||
596 |
argsAt:indexOrName put:something |
|
597 |
"set an individual selector" |
|
598 |
||
3 | 599 |
|i| |
600 |
||
601 |
i := self indexOf:indexOrName. |
|
602 |
i ~~ 0 ifTrue:[args at:i put:something] |
|
0 | 603 |
! |
604 |
||
202 | 605 |
checkFlags |
606 |
"return an array filled with the check-mark flags. |
|
607 |
Non check-menu items have a nil entry in this array." |
|
0 | 608 |
|
202 | 609 |
^ onOffFlags |
0 | 610 |
! |
611 |
||
612 |
checkToggleAt:indexOrName |
|
613 |
"return a check-toggles boolean state" |
|
614 |
||
615 |
|index| |
|
616 |
||
617 |
index := self indexOf:indexOrName. |
|
3 | 618 |
index == 0 ifTrue:[^ false]. |
0 | 619 |
onOffFlags isNil ifTrue:[^ false]. |
620 |
^ onOffFlags at:index |
|
621 |
! |
|
622 |
||
623 |
checkToggleAt:indexOrName put:aBoolean |
|
624 |
"set/clear a check-toggle" |
|
625 |
||
626 |
|index| |
|
627 |
||
628 |
index := self indexOf:indexOrName. |
|
3 | 629 |
index == 0 ifTrue:[^ self]. |
65 | 630 |
|
631 |
onOffFlags isNil ifTrue:[ |
|
632 |
onOffFlags := Array new:(list size) |
|
633 |
]. |
|
0 | 634 |
onOffFlags at:index put:aBoolean. |
635 |
shown ifTrue:[ |
|
59 | 636 |
self redrawLine:index |
0 | 637 |
] |
202 | 638 |
! |
639 |
||
640 |
indexOf:indexOrName |
|
641 |
"return the index of the label named:aName or , if its a symbol |
|
642 |
the index in the selector list" |
|
643 |
||
644 |
indexOrName isSymbol ifTrue:[ |
|
645 |
^ selectors indexOf:indexOrName |
|
646 |
]. |
|
647 |
indexOrName isString ifTrue:[ |
|
648 |
^ list indexOf:indexOrName |
|
649 |
]. |
|
650 |
indexOrName isNil ifTrue:[^ 0]. |
|
651 |
^ indexOrName |
|
652 |
! |
|
653 |
||
654 |
labelAt:indexOrName put:aString |
|
655 |
"change the label at index to be aString" |
|
656 |
||
657 |
|i nItems| |
|
658 |
||
659 |
i := self indexOf:indexOrName. |
|
660 |
i == 0 ifTrue:[^ self]. |
|
661 |
list at:i put:aString. |
|
662 |
||
663 |
"create onOff flags, if this label has a check-mark" |
|
664 |
(self isCheckItem:aString) ifTrue:[ |
|
665 |
nItems := list size. |
|
666 |
onOffFlags isNil ifTrue:[ |
|
667 |
onOffFlags := Array new:nItems |
|
668 |
] ifFalse:[ |
|
669 |
[onOffFlags size < nItems] whileTrue:[ |
|
670 |
onOffFlags := onOffFlags copyWith:nil |
|
671 |
] |
|
672 |
]. |
|
673 |
onOffFlags at:i put:false |
|
674 |
]. |
|
675 |
shown ifTrue:[ |
|
676 |
self resize |
|
677 |
] ifFalse:[ |
|
678 |
needResize := true |
|
679 |
] |
|
680 |
! |
|
681 |
||
682 |
labels |
|
683 |
"return the menu-labels" |
|
684 |
||
685 |
^ list |
|
686 |
! |
|
687 |
||
688 |
labels:text |
|
689 |
"set the labels to the argument, text" |
|
690 |
||
691 |
|l| |
|
692 |
||
693 |
(text isString) ifTrue:[ |
|
694 |
l := text asStringCollection |
|
695 |
] ifFalse:[ |
|
696 |
l := text |
|
697 |
]. |
|
698 |
"/ self list:l |
|
699 |
self setList:l expandTabs:false. |
|
700 |
enableFlags := Array new:(list size) withAll:true. |
|
701 |
onOffFlags := Array new:(list size). |
|
702 |
text keysAndValuesDo:[:index :line | |
|
703 |
(line notNil and:[line includes:$\ ]) ifTrue:[ |
|
704 |
onOffFlags at:index put:false |
|
705 |
]. |
|
706 |
]. |
|
707 |
shown ifTrue:[ |
|
708 |
self resize |
|
709 |
] ifFalse:[ |
|
710 |
needResize := true |
|
711 |
] |
|
712 |
! |
|
713 |
||
714 |
labels:text selectors:selArray args:argArray receiver:anObject |
|
715 |
"set all relevant stuff" |
|
716 |
||
717 |
self labels:text. |
|
718 |
selectors := selArray. |
|
719 |
args := argArray. |
|
720 |
receiver := anObject |
|
721 |
! |
|
722 |
||
723 |
receiver |
|
724 |
"return the receiver of the message" |
|
725 |
||
726 |
^ receiver |
|
727 |
! |
|
728 |
||
729 |
receiver:anObject |
|
730 |
"set the receiver of the message" |
|
731 |
||
732 |
receiver := anObject. |
|
733 |
subMenus notNil ifTrue:[ |
|
734 |
subMenus do:[:aMenu | |
|
735 |
aMenu notNil ifTrue:[ |
|
736 |
aMenu receiver:anObject |
|
737 |
] |
|
738 |
] |
|
739 |
] |
|
740 |
! |
|
741 |
||
742 |
remove:indexOrName |
|
743 |
"remove the label at index" |
|
744 |
||
745 |
|i| |
|
746 |
||
747 |
i := self indexOf:indexOrName. |
|
748 |
i == 0 ifTrue:[^ self]. |
|
749 |
list := list asOrderedCollection removeIndex:i. |
|
750 |
selectors := selectors asOrderedCollection removeIndex:i. |
|
751 |
enableFlags := enableFlags asOrderedCollection removeIndex:i. |
|
752 |
subMenus notNil ifTrue:[ |
|
753 |
subMenus := subMenus asOrderedCollection removeIndex:i. |
|
754 |
]. |
|
755 |
shown ifTrue:[ |
|
756 |
self resize |
|
757 |
] ifFalse:[ |
|
758 |
needResize := true |
|
759 |
] |
|
760 |
! |
|
761 |
||
762 |
selectorAt:indexOrName |
|
763 |
"return an individual selector" |
|
764 |
||
765 |
|i| |
|
766 |
||
767 |
i := self indexOf:indexOrName. |
|
768 |
i ~~ 0 ifTrue:[^ selectors at:i]. |
|
769 |
^ nil |
|
770 |
! |
|
771 |
||
772 |
selectorAt:indexOrName put:aSelector |
|
773 |
"set an individual selector" |
|
774 |
||
775 |
|i| |
|
776 |
||
777 |
i := self indexOf:indexOrName. |
|
778 |
i ~~ 0 ifTrue:[selectors at:i put:aSelector] |
|
779 |
! |
|
780 |
||
781 |
selectors |
|
782 |
"return the selector array" |
|
783 |
||
784 |
^ selectors |
|
785 |
! |
|
786 |
||
787 |
selectors:anArray |
|
788 |
"set the selector array" |
|
789 |
||
790 |
selectors := anArray |
|
791 |
! |
|
792 |
||
793 |
someMenuItemLabeled:aLabel |
|
794 |
"find a menu item. |
|
795 |
Currently, in ST/X, instances of MenuItem are only created as dummy" |
|
796 |
||
797 |
|idx| |
|
798 |
||
799 |
idx := self indexOf:aLabel. |
|
800 |
idx ~~ 0 ifTrue:[ |
|
801 |
^ MenuItem new menu:self index:idx |
|
802 |
]. |
|
803 |
subMenus notNil ifTrue:[ |
|
804 |
subMenus do:[:aMenu | |
|
805 |
|item| |
|
806 |
||
807 |
aMenu notNil ifTrue:[ |
|
808 |
(item := aMenu someMenuItemLabeled:aLabel) notNil ifTrue:[ |
|
809 |
^ item |
|
810 |
] |
|
811 |
] |
|
812 |
]. |
|
813 |
]. |
|
814 |
^ nil |
|
815 |
! ! |
|
816 |
||
817 |
!MenuView methodsFor:'accessing-look'! |
|
818 |
||
819 |
font:aFont |
|
820 |
"adjust size for new font" |
|
821 |
||
822 |
super font:(aFont on:device). |
|
823 |
shown ifTrue:[ |
|
824 |
self resize |
|
825 |
] ifFalse:[ |
|
826 |
needResize := true |
|
827 |
] |
|
828 |
! ! |
|
829 |
||
830 |
!MenuView methodsFor:'accessing-misc'! |
|
831 |
||
832 |
masterView |
|
833 |
"return the popup-masterview I am contained in." |
|
834 |
||
835 |
^ masterView |
|
836 |
! |
|
837 |
||
838 |
masterView:aPopUpView |
|
839 |
"set the popup-masterview I am contained in." |
|
840 |
||
841 |
masterView := aPopUpView |
|
842 |
! |
|
843 |
||
844 |
selection:index |
|
845 |
|sel line| |
|
846 |
||
847 |
sel := index. |
|
848 |
sel notNil ifTrue:[ |
|
849 |
line := self listAt:index. |
|
850 |
(self isGraphicItem:line) ifTrue:[ |
|
851 |
" |
|
852 |
not really selectable, but a separating line |
|
853 |
" |
|
854 |
sel := nil |
|
855 |
] |
|
856 |
]. |
|
857 |
super selection:sel |
|
858 |
! |
|
859 |
||
860 |
superMenu |
|
861 |
"ret the menu I am contained in |
|
862 |
- need this to hide main menus when a submenu performed its action" |
|
863 |
||
864 |
^ superMenu |
|
865 |
! |
|
866 |
||
867 |
superMenu:aMenu |
|
868 |
"set the menu I am contained in |
|
869 |
- need this to hide main menus when a submenu performed its action" |
|
870 |
||
871 |
superMenu := aMenu |
|
136 | 872 |
! ! |
873 |
||
874 |
!MenuView methodsFor:'accessing-submenus'! |
|
875 |
||
0 | 876 |
subMenuAt:indexOrName |
877 |
"return a submenu, or nil" |
|
878 |
||
3 | 879 |
|i| |
880 |
||
0 | 881 |
subMenus isNil ifTrue:[^ nil]. |
3 | 882 |
i := self indexOf:indexOrName. |
883 |
i == 0 ifTrue:[^ nil]. |
|
884 |
^ subMenus at:i |
|
0 | 885 |
! |
886 |
||
887 |
subMenuAt:indexOrName put:aPopUpMenu |
|
888 |
"define a submenu" |
|
889 |
||
59 | 890 |
|i newSubMenus| |
3 | 891 |
|
892 |
i := self indexOf:indexOrName. |
|
893 |
i == 0 ifTrue:[^ nil]. |
|
59 | 894 |
subMenus size < i ifTrue:[ |
895 |
newSubMenus := Array new:(list size max:i). |
|
896 |
subMenus notNil ifTrue:[ |
|
897 |
newSubMenus replaceFrom:1 with:subMenus. |
|
898 |
]. |
|
899 |
subMenus := newSubMenus. |
|
119 | 900 |
shown ifTrue:[ |
127 | 901 |
self resize |
119 | 902 |
] ifFalse:[ |
903 |
needResize := true |
|
904 |
] |
|
0 | 905 |
]. |
3 | 906 |
subMenus at:i put:aPopUpMenu |
202 | 907 |
! |
908 |
||
909 |
subMenuShown |
|
910 |
"return the currently visible submenu - or nil if there is none" |
|
911 |
||
912 |
^ subMenuShown |
|
913 |
! ! |
|
914 |
||
915 |
!MenuView methodsFor:'disabled scrolling'! |
|
916 |
||
917 |
makeSelectionVisible |
|
918 |
^ self |
|
919 |
! ! |
|
920 |
||
921 |
!MenuView methodsFor:'event handling'! |
|
922 |
||
923 |
buttonMotion:state x:x y:y |
|
924 |
state ~~ 0 ifTrue:[ |
|
925 |
self setSelectionForX:x y:y |
|
926 |
] |
|
927 |
! |
|
928 |
||
929 |
buttonPress:button x:x y:y |
|
930 |
self setSelectionForX:x y:y |
|
931 |
! |
|
932 |
||
933 |
buttonRelease:button x:x y:y |
|
934 |
|theSelector isCheck checkOn val| |
|
935 |
||
936 |
subMenuShown notNil ifTrue:[ |
|
937 |
^ self |
|
938 |
]. |
|
939 |
||
940 |
(x >= 0 and:[x < width]) ifTrue:[ |
|
941 |
(y >= 0 and:[y < height]) ifTrue:[ |
|
942 |
selection notNil ifTrue:[ |
|
943 |
(subMenus isNil or:[(subMenus at:selection) isNil]) ifTrue:[ |
|
944 |
self showActive. |
|
945 |
[ |
|
946 |
superMenu notNil ifTrue:[ |
|
947 |
superMenu showActive |
|
948 |
]. |
|
949 |
||
950 |
val := selection. |
|
951 |
args notNil ifTrue:[ |
|
952 |
val := args at:selection |
|
953 |
]. |
|
954 |
||
955 |
isCheck := false. |
|
956 |
onOffFlags notNil ifTrue:[ |
|
957 |
onOffFlags size >= selection ifTrue:[ |
|
958 |
checkOn := (onOffFlags at:selection). |
|
959 |
isCheck := checkOn notNil. |
|
960 |
isCheck ifTrue:[ |
|
961 |
checkOn := val := checkOn not. |
|
962 |
onOffFlags at:selection put:checkOn. |
|
963 |
] |
|
964 |
] |
|
965 |
]. |
|
966 |
||
967 |
" |
|
968 |
ST-80 style model notification |
|
969 |
" |
|
970 |
self sendChangeMessageWith:val. |
|
971 |
||
972 |
" |
|
973 |
either action-block or selectors-array-style |
|
974 |
" |
|
975 |
actionBlock notNil ifTrue:[ |
|
976 |
Object abortSignal handle:[:ex | |
|
977 |
ex return |
|
978 |
] do:[ |
|
979 |
actionBlock value:selection |
|
980 |
] |
|
981 |
] ifFalse:[ |
|
982 |
selectors notNil ifTrue: [ |
|
983 |
device activePointerGrab == self ifTrue:[ |
|
984 |
device ungrabPointer. |
|
985 |
]. |
|
986 |
selectors isSymbol ifFalse:[ |
|
987 |
(selection notNil |
|
988 |
and:[selection <= selectors size]) ifTrue:[ |
|
989 |
theSelector := selectors at:selection |
|
990 |
] |
|
991 |
] ifTrue:[ |
|
992 |
theSelector := selectors |
|
993 |
]. |
|
994 |
theSelector notNil ifTrue:[ |
|
995 |
Object abortSignal handle:[:ex | |
|
996 |
ex return |
|
997 |
] do:[ |
|
998 |
isCheck ifTrue:[ |
|
999 |
self redrawLine:selection. |
|
1000 |
receiver perform:theSelector with:checkOn |
|
1001 |
] ifFalse:[ |
|
1002 |
(args isNil or:[theSelector numArgs == 0]) ifTrue:[ |
|
1003 |
receiver perform:theSelector |
|
1004 |
] ifFalse:[ |
|
1005 |
receiver perform:theSelector with:val |
|
1006 |
] |
|
1007 |
] |
|
1008 |
] |
|
1009 |
] |
|
1010 |
] |
|
1011 |
]. |
|
1012 |
] valueNowOrOnUnwindDo:[ |
|
1013 |
realized ifTrue:[ |
|
1014 |
self showPassive. |
|
1015 |
]. |
|
1016 |
superMenu notNil ifTrue:[ |
|
1017 |
superMenu showPassive |
|
1018 |
] |
|
1019 |
]. |
|
1020 |
]. |
|
1021 |
] |
|
1022 |
] |
|
1023 |
]. |
|
1024 |
(superMenu notNil and:[superMenu shown not]) ifTrue:[ |
|
1025 |
(superView notNil and:[superView shown]) ifTrue:[superView hide]. |
|
1026 |
]. |
|
1027 |
hideOnRelease ifTrue:[ |
|
1028 |
superView hide |
|
1029 |
]. |
|
1030 |
! |
|
1031 |
||
1032 |
keyPress:aKey x:x y:y |
|
1033 |
|m| |
|
1034 |
||
1035 |
subMenuShown notNil ifTrue:[ |
|
1036 |
subMenuShown keyPress:aKey x:0 y:0. |
|
1037 |
^ self |
|
1038 |
]. |
|
1039 |
||
1040 |
" |
|
1041 |
Return, space or the (virtual) MenuSelect |
|
1042 |
key trigger a selected entry. |
|
1043 |
" |
|
1044 |
(aKey == #Return |
|
1045 |
or:[aKey == #MenuSelect |
|
1046 |
or:[aKey == Character space]]) ifTrue:[ |
|
1047 |
selection notNil ifTrue:[ |
|
1048 |
(subMenus notNil and:[(m := subMenus at:selection) notNil]) ifTrue:[ |
|
1049 |
self showSubmenu:selection. |
|
1050 |
m hideOnLeave:false |
|
1051 |
] ifFalse:[ |
|
1052 |
subMenuShown := nil. |
|
1053 |
self buttonRelease:1 x:x y:y. |
|
1054 |
] |
|
1055 |
]. |
|
1056 |
^ self |
|
1057 |
]. |
|
1058 |
super keyPress:aKey x:x y:y |
|
1059 |
! |
|
1060 |
||
1061 |
pointerLeave:state |
|
1062 |
subMenuShown notNil ifTrue:[ |
|
1063 |
^ self |
|
1064 |
]. |
|
1065 |
"/ self setSelectionForX:-1 y:-1. "force deselect" |
|
1066 |
subMenuShown isNil ifTrue:[ |
|
1067 |
self selection:nil |
|
1068 |
]. |
|
1069 |
"/ superMenu notNil ifTrue:[ |
|
1070 |
"/ superMenu regainControl. |
|
1071 |
"/ ] |
|
1072 |
! ! |
|
1073 |
||
1074 |
!MenuView methodsFor:'initialize / release'! |
|
1075 |
||
1076 |
create |
|
1077 |
super create. |
|
1078 |
subMenuShown := nil. |
|
1079 |
self resizeIfChanged |
|
1080 |
! |
|
1081 |
||
1082 |
destroy |
|
1083 |
" |
|
1084 |
have to destroy the submenus manually here, |
|
1085 |
since they are no real subviews of myself |
|
1086 |
" |
|
1087 |
subMenus notNil ifTrue:[ |
|
1088 |
subMenus do:[:m | |
|
1089 |
m notNil ifTrue:[ |
|
1090 |
m destroy |
|
1091 |
] |
|
1092 |
]. |
|
1093 |
subMenus := nil |
|
1094 |
]. |
|
1095 |
super destroy. |
|
1096 |
! |
|
1097 |
||
1098 |
initEvents |
|
1099 |
super initEvents. |
|
1100 |
self enableLeaveEvents. |
|
1101 |
windowGroup notNil ifTrue:[ |
|
1102 |
windowGroup sensor compressMotionEvents:true |
|
1103 |
] |
|
1104 |
! |
|
1105 |
||
1106 |
initStyle |
|
1107 |
|style| |
|
1108 |
||
1109 |
super initStyle. |
|
1110 |
||
1111 |
DefaultFont notNil ifTrue:[ |
|
1112 |
font := DefaultFont on:device |
|
1113 |
]. |
|
1114 |
||
1115 |
DefaultCheckColor notNil ifTrue:[ |
|
1116 |
checkColor := DefaultCheckColor |
|
1117 |
] ifFalse:[ |
|
1118 |
checkColor := fgColor. |
|
1119 |
]. |
|
1120 |
disabledFgColor := DefaultDisabledForegroundColor on:device. |
|
1121 |
||
1122 |
DefaultForegroundColor notNil ifTrue:[ |
|
1123 |
fgColor := DefaultForegroundColor on:device |
|
1124 |
]. |
|
1125 |
DefaultBackgroundColor notNil ifTrue:[ |
|
1126 |
bgColor := DefaultBackgroundColor on:device |
|
1127 |
]. |
|
1128 |
||
1129 |
DefaultShadowColor notNil ifTrue:[ |
|
1130 |
shadowColor := DefaultShadowColor on:device |
|
1131 |
]. |
|
1132 |
DefaultLightColor notNil ifTrue:[ |
|
1133 |
lightColor := DefaultLightColor on:device |
|
1134 |
]. |
|
1135 |
||
1136 |
DefaultHilightLevel notNil ifTrue:[ |
|
1137 |
hilightLevel := DefaultHilightLevel |
|
1138 |
] ifFalse:[ |
|
1139 |
hilightLevel := 0. |
|
1140 |
]. |
|
1141 |
hilightStyle := DefaultHilightStyle. |
|
1142 |
||
1143 |
hilightFrameColor := DefaultHilightFrameColor. |
|
1144 |
||
1145 |
styleSheet is3D ifTrue:[ |
|
1146 |
"some 3D style menu - set hilight defaults to same" |
|
1147 |
||
1148 |
DefaultHilightForegroundColor notNil ifTrue:[ |
|
1149 |
hilightFgColor := DefaultHilightForegroundColor on:device |
|
1150 |
] ifFalse:[ |
|
1151 |
hilightFgColor := fgColor. |
|
1152 |
]. |
|
1153 |
DefaultHilightBackgroundColor notNil ifTrue:[ |
|
1154 |
hilightBgColor := DefaultHilightBackgroundColor on:device |
|
1155 |
] ifFalse:[ |
|
1156 |
hilightBgColor := bgColor. |
|
1157 |
]. |
|
1158 |
DefaultLineLevel notNil ifTrue:[ |
|
1159 |
lineLevel := DefaultLineLevel |
|
1160 |
] ifFalse:[ |
|
1161 |
lineLevel := -1. |
|
1162 |
] |
|
1163 |
] ifFalse:[ |
|
1164 |
"some 2D style menu - set hilight defaults to inverse" |
|
1165 |
DefaultHilightForegroundColor notNil ifTrue:[ |
|
1166 |
hilightFgColor := DefaultHilightForegroundColor on:device |
|
1167 |
] ifFalse:[ |
|
1168 |
hilightFgColor := bgColor. |
|
1169 |
]. |
|
1170 |
DefaultHilightBackgroundColor notNil ifTrue:[ |
|
1171 |
hilightBgColor := DefaultHilightBackgroundColor on:device |
|
1172 |
] ifFalse:[ |
|
1173 |
hilightBgColor := fgColor. |
|
1174 |
]. |
|
1175 |
DefaultLineLevel notNil ifTrue:[ |
|
1176 |
lineLevel := DefaultLineLevel |
|
1177 |
] ifFalse:[ |
|
1178 |
lineLevel := 0. |
|
1179 |
] |
|
1180 |
]. |
|
1181 |
||
1182 |
DefaultLineInset notNil ifTrue:[ |
|
1183 |
lineInset := DefaultLineInset |
|
1184 |
] ifFalse:[ |
|
1185 |
lineInset := (device horizontalPixelPerMillimeter * 0.8) rounded. |
|
1186 |
]. |
|
1187 |
||
1188 |
" |
|
1189 |
the following has to be changed to |
|
1190 |
use the styleSheet too |
|
1191 |
" |
|
1192 |
style := styleSheet name. |
|
1193 |
||
1194 |
(style == #iris) ifTrue:[ |
|
1195 |
device hasGreyscales ifTrue:[ |
|
1196 |
lineSpacing := 3 |
|
1197 |
]. |
|
1198 |
]. |
|
1199 |
(style == #motif) ifTrue:[ |
|
1200 |
lineSpacing := (2 * hilightLevel) |
|
1201 |
]. |
|
1202 |
hilightStyle == #openwin ifTrue:[ |
|
1203 |
"add some space for rounded-hilight area" |
|
1204 |
self leftMargin:10. |
|
1205 |
] ifFalse:[ |
|
1206 |
(hilightLevel ~~ 0) ifTrue:[ |
|
1207 |
self leftMargin:hilightLevel abs + self margin abs + 1. |
|
1208 |
lineSpacing := lineSpacing max:(hilightLevel abs * 2). |
|
1209 |
] |
|
1210 |
]. |
|
1211 |
(style == #st80) ifTrue:[ |
|
1212 |
level := 0. |
|
1213 |
]. |
|
1214 |
DefaultViewBackground notNil ifTrue:[ |
|
1215 |
viewBackground := DefaultViewBackground on:device |
|
1216 |
]. |
|
1217 |
||
1218 |
"Modified: 22.11.1995 / 23:18:54 / cg" |
|
1219 |
! |
|
1220 |
||
1221 |
initialize |
|
1222 |
|style| |
|
1223 |
||
1224 |
super initialize. |
|
1225 |
hideOnRelease := false. |
|
1226 |
autoScroll := false. |
|
1227 |
||
1228 |
(((style := styleSheet name) ~~ #normal) |
|
1229 |
and:[style ~~ #mswindows]) ifTrue:[ |
|
1230 |
borderWidth := 1. |
|
224 | 1231 |
(style ~~ #st80) ifTrue:[self level:1] |
202 | 1232 |
]. |
1233 |
||
1234 |
"stupid - have to redo this ..." |
|
1235 |
hilightStyle == #openwin ifTrue:[ |
|
1236 |
"add some space for rounded-hilight area" |
|
1237 |
self leftMargin:10. |
|
1238 |
]. |
|
1239 |
! |
|
1240 |
||
1241 |
recreate |
|
1242 |
"when recreated after a snapin, resize myself, in case |
|
1243 |
font dimensions have changed on the display" |
|
1244 |
||
1245 |
super recreate. |
|
1246 |
hilightStyle == #openwin ifTrue:[ |
|
1247 |
self leftMargin:10. |
|
1248 |
]. |
|
1249 |
self resize |
|
1250 |
! |
|
1251 |
||
1252 |
reinitialize |
|
1253 |
"this is called right after snapIn; |
|
1254 |
a kind of kludge - reset cursor (in case the save was |
|
1255 |
done with myself being shown and active)" |
|
1256 |
||
1257 |
super reinitialize. |
|
1258 |
selection := nil. "self selection:nil." |
|
1259 |
self showPassive |
|
0 | 1260 |
! ! |
1261 |
||
1262 |
!MenuView methodsFor:'private'! |
|
1263 |
||
7 | 1264 |
hideSubmenu |
1265 |
subMenuShown notNil ifTrue:[ |
|
59 | 1266 |
subMenuShown hide. |
1267 |
subMenuShown := nil |
|
7 | 1268 |
]. |
1269 |
! |
|
1270 |
||
202 | 1271 |
isCheckItem:line |
1272 |
line notNil ifTrue:[ |
|
1273 |
(line startsWith:'\c') ifTrue:[^ true]. |
|
1274 |
(line startsWith:'\b') ifTrue:[^ true]. |
|
1275 |
(line startsWith:'\t')ifTrue:[^ true]. |
|
1276 |
]. |
|
1277 |
^ false. |
|
119 | 1278 |
! |
1279 |
||
202 | 1280 |
isGraphicItem:line |
1281 |
(line = '-') ifTrue:[^ true]. |
|
1282 |
(line = '=') ifTrue:[^ true]. |
|
1283 |
(line = '') ifTrue:[^ true]. |
|
1284 |
^ false. |
|
127 | 1285 |
! |
119 | 1286 |
|
127 | 1287 |
recomputeSize |
1288 |
"resize myself to my preferred size |
|
1289 |
OBSOLETE - use resize" |
|
1290 |
||
1291 |
self resize. |
|
0 | 1292 |
! |
1293 |
||
202 | 1294 |
resize |
1295 |
"resize myself to my preferred size" |
|
77 | 1296 |
|
202 | 1297 |
widthOfWidestLine := nil. "/ i.e. unknown |
1298 |
super resize. |
|
1299 |
! |
|
77 | 1300 |
|
202 | 1301 |
resizeIfChanged |
1302 |
needResize == true ifTrue:[ |
|
1303 |
self resize. |
|
1304 |
needResize := false |
|
1305 |
] |
|
77 | 1306 |
! |
1307 |
||
0 | 1308 |
setSelectionForX:x y:y |
77 | 1309 |
"select whatever is under x/y coordinate - if there is |
1310 |
a subMenu, show it" |
|
1311 |
||
133 | 1312 |
|newSelection subMenu| |
0 | 1313 |
|
38 | 1314 |
(x < 0 |
1315 |
or:[x >= width |
|
1316 |
or:[y < 0 |
|
1317 |
or:[y >= height]]]) ifTrue:[ |
|
59 | 1318 |
" |
1319 |
moved outside submenu, but not within self |
|
1320 |
" |
|
1321 |
subMenuShown notNil ifTrue:[ |
|
1322 |
^ self |
|
1323 |
]. |
|
70 | 1324 |
superMenu notNil ifTrue:[ |
1325 |
superMenu regainControl |
|
1326 |
]. |
|
38 | 1327 |
]. |
1328 |
||
0 | 1329 |
newSelection := self positionToSelectionX:x y:y. |
7 | 1330 |
newSelection ~= selection ifTrue:[ |
59 | 1331 |
newSelection notNil ifTrue:[ |
1332 |
(enableFlags at:newSelection) ifFalse:[ |
|
1333 |
newSelection := nil |
|
70 | 1334 |
] |
1335 |
]. |
|
1336 |
||
1337 |
self selection:newSelection. |
|
1338 |
||
1339 |
subMenuShown notNil ifTrue:[ |
|
1340 |
self hideSubmenu. |
|
1341 |
]. |
|
133 | 1342 |
]. |
7 | 1343 |
|
133 | 1344 |
subMenu := nil. |
1345 |
selection notNil ifTrue:[ |
|
1346 |
subMenus notNil ifTrue:[ |
|
1347 |
x > (width // 2) ifTrue:[ |
|
1348 |
subMenu := (subMenus at:selection) |
|
59 | 1349 |
] |
133 | 1350 |
] |
1351 |
]. |
|
1352 |
subMenu notNil ifTrue:[ |
|
1353 |
self showSubmenu:selection. |
|
1354 |
] ifFalse:[ |
|
1355 |
subMenuShown notNil ifTrue:[ |
|
1356 |
self hideSubmenu. |
|
59 | 1357 |
]. |
133 | 1358 |
subMenuShown := nil |
7 | 1359 |
] |
131 | 1360 |
! |
1361 |
||
202 | 1362 |
showSubmenu:index |
1363 |
"show subMenu at index" |
|
1364 |
||
1365 |
|org mx my m| |
|
1366 |
||
1367 |
m := subMenus at:index. |
|
1368 |
m isNil ifTrue:[^ self]. |
|
1369 |
m == subMenuShown ifTrue:[^ self]. |
|
1370 |
||
1371 |
mx := width - 5. |
|
1372 |
my := self yOfVisibleLine:index. |
|
1373 |
" |
|
1374 |
need to know the physical screen coordinate, |
|
1375 |
to map the subview there |
|
1376 |
" |
|
1377 |
org := device |
|
1378 |
translatePoint:(mx @ my) |
|
1379 |
from:(self id) |
|
1380 |
to:(device rootWindowId). |
|
1381 |
||
1382 |
"/ mhmh - is this still needed ? |
|
1383 |
" |
|
1384 |
before showing, process all of my expose events |
|
1385 |
" |
|
1386 |
windowGroup notNil ifTrue:[ |
|
1387 |
windowGroup processExposeEvents |
|
131 | 1388 |
]. |
202 | 1389 |
|
1390 |
m superMenu:self. |
|
131 | 1391 |
|
202 | 1392 |
" |
1393 |
realize the submenu in MY windowgroup |
|
1394 |
" |
|
1395 |
windowGroup notNil ifTrue:[ |
|
1396 |
m windowGroup:windowGroup. |
|
1397 |
windowGroup addTopView:m. |
|
1398 |
]. |
|
1399 |
m fixSize. |
|
1400 |
m origin:org. |
|
1401 |
m makeFullyVisible. |
|
1402 |
m noShadow. |
|
1403 |
m realize. |
|
1404 |
device flush. |
|
1405 |
||
1406 |
subMenuShown := m |
|
0 | 1407 |
! ! |
1408 |
||
202 | 1409 |
!MenuView methodsFor:'queries'! |
0 | 1410 |
|
202 | 1411 |
preferredExtent |
1412 |
|margin2 w h| |
|
1413 |
||
1414 |
widthOfWidestLine := nil. "/ i.e. unknown |
|
119 | 1415 |
|
202 | 1416 |
margin2 := margin * 2. |
1417 |
w := self widthOfContents + leftMargin + leftMargin + margin2. |
|
1418 |
h := (self numberOfLines) * fontHeight - lineSpacing + (2 * topMargin) + margin2. |
|
228 | 1419 |
hilightLevel ~~ 0 ifTrue:[ |
1420 |
h := h + (hilightLevel abs) |
|
224 | 1421 |
]. |
202 | 1422 |
"if there is a submenu, add some space for the right arrow" |
1423 |
subMenus notNil ifTrue:[ |
|
1424 |
w := w + 16 |
|
1425 |
]. |
|
1426 |
^ (w @ h). |
|
77 | 1427 |
! ! |
1428 |
||
0 | 1429 |
!MenuView methodsFor:'redrawing'! |
1430 |
||
131 | 1431 |
drawLine:line withCheckMark:markType inVisibleLine:visLineNr with:fg and:bg |
1432 |
"draw an on/off-mark (or the space for it). |
|
1433 |
Supported checkmark types: |
|
1434 |
\c simple mark; space if off |
|
1435 |
\b box mark |
|
1436 |
\t thumbsUp/thumbsDown mark |
|
1437 |
" |
|
0 | 1438 |
|
131 | 1439 |
|w h y x l check xR yB form| |
0 | 1440 |
|
1441 |
l := self visibleLineToListLine:visLineNr. |
|
1442 |
onOffFlags isNil ifTrue:[ |
|
59 | 1443 |
check := false |
0 | 1444 |
] ifFalse:[ |
65 | 1445 |
check := (onOffFlags at:l) == true. |
0 | 1446 |
]. |
1447 |
||
59 | 1448 |
x := (self xOfCol:1 inVisibleLine:visLineNr) - leftOffset. |
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1449 |
y := (self yOfVisibleLine:visLineNr) - (lineSpacing//2). |
0 | 1450 |
|
131 | 1451 |
(markType == $c) ifTrue:[ |
1452 |
w := font widthOf:' '. |
|
1453 |
] ifFalse:[ |
|
1454 |
(markType == $b) ifTrue:[ |
|
1455 |
w := font widthOf:' '. |
|
1456 |
] ifFalse:[ |
|
1457 |
(markType == $t) ifTrue:[ |
|
1458 |
w := 16. |
|
1459 |
check ifTrue:[form := Cursor thumbsUp sourceForm] |
|
1460 |
ifFalse:[form := Cursor thumbsDown sourceForm] |
|
1461 |
] |
|
1462 |
] |
|
1463 |
]. |
|
1464 |
||
0 | 1465 |
self paint:bg. |
7 | 1466 |
self fillRectangleX:x y:y width:w height:fontHeight. |
131 | 1467 |
|
1468 |
self drawLine:line atX:w inVisible:visLineNr with:fg and:bg. |
|
1469 |
||
155 | 1470 |
self paint:(check ifTrue:[checkColor == bg ifTrue:[fg] ifFalse:[checkColor]] ifFalse:[fg]). |
131 | 1471 |
|
1472 |
h := font ascent. |
|
1473 |
y := y + (font height - h // 2). |
|
1474 |
yB := y + h - 1. |
|
63 | 1475 |
|
131 | 1476 |
(markType == $c) ifTrue:[ |
1477 |
check ifTrue:[ |
|
1478 |
xR := x + (w // 3). |
|
1479 |
self displayLineFromX:x y:(y + (h // 2)) toX:xR y:yB. |
|
1480 |
self displayLineFromX:xR y:yB toX:(x + w - 1) y:y |
|
1481 |
] |
|
1482 |
] ifFalse:[ |
|
1483 |
(markType == $t) ifTrue:[ |
|
1484 |
self displayForm:form x:x y:y |
|
1485 |
] ifFalse:[ |
|
1486 |
(markType == $b) ifTrue:[ |
|
1487 |
check ifTrue:[ |
|
1488 |
xR := x + w - 2. |
|
1489 |
self displayLineFromX:x y:y toX:xR y:yB. |
|
1490 |
self displayLineFromX:xR y:y toX:x y:yB. |
|
1491 |
]. |
|
1492 |
self paint:fg. |
|
1493 |
self displayRectangleX:x y:y width:h height:h. |
|
1494 |
] |
|
1495 |
] |
|
0 | 1496 |
] |
155 | 1497 |
|
1498 |
"Modified: 31.8.1995 / 19:27:02 / claus" |
|
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1499 |
"Modified: 22.11.1995 / 23:24:13 / cg" |
0 | 1500 |
! |
1501 |
||
1502 |
drawVisibleLine:visLineNr with:fg and:bg |
|
131 | 1503 |
|lineString isSpecial| |
0 | 1504 |
|
131 | 1505 |
lineString := self visibleAt:visLineNr. |
0 | 1506 |
|
131 | 1507 |
isSpecial := lineString notNil and:[lineString includes:$\]. |
0 | 1508 |
isSpecial ifFalse:[ |
63 | 1509 |
" |
1510 |
a normal entry |
|
1511 |
" |
|
131 | 1512 |
^ super drawVisibleLine:visLineNr with:fg and:bg |
1513 |
]. |
|
1514 |
" |
|
1515 |
some speciality in this line |
|
1516 |
" |
|
1517 |
(lineString startsWith:'\') ifTrue:[ |
|
1518 |
(self isCheckItem:lineString) ifTrue:[ |
|
1519 |
" |
|
1520 |
(check-mark) |
|
1521 |
" |
|
1522 |
^ self drawLine:(lineString copyFrom:3) withCheckMark:(lineString at:2) inVisibleLine:visLineNr with:fg and:bg |
|
1523 |
]. |
|
63 | 1524 |
" |
131 | 1525 |
ignored escape ... |
63 | 1526 |
" |
131 | 1527 |
^ super drawLine:(lineString copyFrom:2) inVisible:visLineNr with:fg and:bg. |
1528 |
]. |
|
1529 |
^ super drawVisibleLine:visLineNr with:fg and:bg |
|
0 | 1530 |
! |
1531 |
||
38 | 1532 |
drawVisibleLineSelected:visLineNr |
1533 |
"redraw a single line as selected." |
|
1534 |
||
1535 |
|listLine fg bg |
|
87 | 1536 |
y "{ Class: SmallInteger }" |
38 | 1537 |
y2 "{ Class: SmallInteger }" |
1538 |
r2 radius topLeftColor botRightColor | |
|
1539 |
||
77 | 1540 |
hilightStyle ~~ #openwin ifTrue:[ |
59 | 1541 |
^ super drawVisibleLineSelected:visLineNr. |
38 | 1542 |
]. |
77 | 1543 |
|
38 | 1544 |
" |
1545 |
openwin draws selections in a menu as (edged) rounded rectangles |
|
1546 |
" |
|
1547 |
bg := hilightBgColor. |
|
1548 |
fg := hilightFgColor. |
|
1549 |
listLine := self visibleLineToListLine:visLineNr. |
|
1550 |
listLine notNil ifTrue:[ |
|
1551 |
||
59 | 1552 |
self drawVisibleLine:visLineNr with:fg and:bg. |
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1553 |
y := (self yOfVisibleLine:visLineNr) - (lineSpacing//2). |
59 | 1554 |
y2 := y + fontHeight - 1. |
1555 |
r2 := font height. |
|
1556 |
radius := r2 // 2. |
|
1557 |
" |
|
1558 |
refill with normal bg, where arcs will be drawn below |
|
1559 |
" |
|
1560 |
self paint:bgColor. |
|
1561 |
self fillRectangleX:margin y:y width:radius height:fontHeight. |
|
1562 |
self fillRectangleX:width-radius-margin y:y width:radius height:fontHeight. |
|
1563 |
" |
|
1564 |
fill the arcs |
|
1565 |
" |
|
1566 |
self paint:hilightBgColor. |
|
1567 |
self fillArcX:1+margin+1 y:y w:r2 h:r2+1+1 from:90 angle:180. |
|
1568 |
self fillArcX:width-r2-1-1-margin-1 y:y w:r2 h:r2+1+1 from:270 angle:180. |
|
38 | 1569 |
|
59 | 1570 |
" |
1571 |
a highlight-border around |
|
1572 |
" |
|
1573 |
hilightFrameColor notNil ifTrue:[ |
|
1574 |
self paint:hilightFrameColor. |
|
1575 |
self displayLineFromX:radius+2 y:y toX:width-radius-3 y:y. |
|
1576 |
self displayLineFromX:radius+2 y:y2 toX:width-radius-3 y:y2. |
|
38 | 1577 |
|
59 | 1578 |
self displayArcX:1+margin+1 y:y w:r2 h:r2+1+1 from:90 angle:180. |
1579 |
self displayArcX:width-r2-1-1-margin-1 y:y w:r2 h:r2+1+1 from:270 angle:180. |
|
1580 |
^ self |
|
1581 |
]. |
|
38 | 1582 |
|
59 | 1583 |
" |
1584 |
an edge around |
|
1585 |
" |
|
1586 |
(hilightLevel ~~ 0) ifTrue:[ |
|
1587 |
(hilightLevel < 0) ifTrue:[ |
|
1588 |
topLeftColor := shadowColor. |
|
1589 |
botRightColor := lightColor. |
|
1590 |
] ifFalse:[ |
|
1591 |
topLeftColor := lightColor. |
|
1592 |
botRightColor := shadowColor. |
|
1593 |
]. |
|
38 | 1594 |
|
59 | 1595 |
self paint:topLeftColor. |
1596 |
self displayLineFromX:radius+2 y:y toX:width-radius-3 y:y. |
|
38 | 1597 |
|
59 | 1598 |
self displayArcX:1+margin+1 y:y w:r2 h:r2+1+1 from:90 angle:125. |
1599 |
self displayArcX:width-r2-1-1-margin-1 y:y w:r2 h:r2+1+1 from:270+125 angle:55. |
|
38 | 1600 |
|
59 | 1601 |
self paint:botRightColor. |
38 | 1602 |
|
59 | 1603 |
self displayLineFromX:radius+2 y:y2 toX:width-radius-3 y:y2. |
1604 |
self displayArcX:1+margin+1 y:y w:r2 h:r2+1+1 from:90+125 angle:55. |
|
1605 |
self displayArcX:width-r2-1-1-margin-1 y:y w:r2 h:r2+1+1 from:270 angle:125. |
|
77 | 1606 |
]. |
1607 |
^ self |
|
38 | 1608 |
]. |
1609 |
^ super drawVisibleLine:visLineNr with:fg and:bg |
|
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1610 |
|
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1611 |
"Modified: 22.11.1995 / 23:28:47 / cg" |
38 | 1612 |
! |
1613 |
||
202 | 1614 |
redrawFromVisibleLine:start to:stop |
1615 |
"redraw a line range - redefined to care for special entries." |
|
1616 |
||
1617 |
"the natural way to do it is: |
|
1618 |
||
1619 |
start to:stop do:[:visLine | |
|
1620 |
self redrawVisibleLine:visLine |
|
1621 |
] |
|
1622 |
||
1623 |
but I want to draw the stuff in big chunks for slow machines ..." |
|
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1624 |
|
202 | 1625 |
|first |
1626 |
index "{ Class: SmallInteger }" |
|
1627 |
current "{ Class: SmallInteger }" |
|
1628 |
line special index0| |
|
1629 |
||
1630 |
index0 := self visibleLineToListLine:start. |
|
1631 |
index0 notNil ifTrue:[ |
|
1632 |
index := index0. |
|
1633 |
first := start. |
|
1634 |
current := start. |
|
1635 |
[current <= stop] whileTrue:[ |
|
1636 |
line := (self visibleAt:current) string. |
|
1637 |
||
1638 |
special := line notNil |
|
1639 |
and:[(self isGraphicItem:line) |
|
1640 |
or:[(line at:1) == $\ ]]. |
|
0 | 1641 |
|
202 | 1642 |
(special |
1643 |
or:[(enableFlags at:index) not]) ifTrue:[ |
|
1644 |
"a special case" |
|
1645 |
(first < current) ifTrue:[ |
|
1646 |
super redrawFromVisibleLine:first to:(current - 1) |
|
1647 |
]. |
|
1648 |
self redrawVisibleLine:current. |
|
1649 |
first := current + 1 |
|
1650 |
]. |
|
1651 |
current := current + 1. |
|
1652 |
index := index + 1 |
|
1653 |
]. |
|
1654 |
(first < current) ifTrue:[ |
|
1655 |
super redrawFromVisibleLine:first to:(current - 1) |
|
1656 |
]. |
|
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1657 |
|
202 | 1658 |
"draw submenu marks" |
1659 |
subMenus notNil ifTrue:[ |
|
1660 |
index := index0. |
|
1661 |
start to:stop do:[:l | |
|
1662 |
index <= subMenus size ifTrue:[ |
|
1663 |
(subMenus at:index) notNil ifTrue:[ |
|
1664 |
self drawRightArrowInVisibleLine:l |
|
1665 |
]. |
|
1666 |
index := index + 1 |
|
1667 |
] |
|
1668 |
] |
|
1669 |
] |
|
1670 |
] |
|
0 | 1671 |
! |
1672 |
||
1673 |
redrawVisibleLine:visLineNr |
|
63 | 1674 |
"redefined from normal list-line drawing, to handle special |
1675 |
lines. These are: |
|
1676 |
lines consisting of '-' only: draw a horizontal separating line |
|
1677 |
lines consisting of '=' only: draw double separating line |
|
1678 |
empty line : leave blank |
|
1679 |
there may be more in the future. |
|
1680 |
" |
|
1681 |
||
1682 |
|line lineNr y isSpecial isSeparatingLine |
|
1683 |
isDoubleLine right clr1 clr2| |
|
0 | 1684 |
|
1685 |
line := self visibleAt:visLineNr. |
|
1686 |
||
63 | 1687 |
isSpecial := isDoubleLine := isSeparatingLine := false. |
0 | 1688 |
(line = '-') ifTrue:[ |
63 | 1689 |
isSeparatingLine := isSpecial := true. |
0 | 1690 |
] ifFalse:[ |
63 | 1691 |
(line = '=') ifTrue:[ |
1692 |
isSeparatingLine := isSpecial := isDoubleLine := true. |
|
1693 |
] ifFalse:[ |
|
1694 |
(line = '') ifTrue:[ |
|
1695 |
isSpecial := true |
|
1696 |
] |
|
59 | 1697 |
] |
0 | 1698 |
]. |
63 | 1699 |
|
0 | 1700 |
isSpecial ifFalse:[ |
59 | 1701 |
lineNr := self visibleLineToListLine:visLineNr. |
1702 |
(enableFlags at:lineNr) ifFalse:[ |
|
1703 |
self drawVisibleLine:visLineNr with:disabledFgColor and:bgColor |
|
1704 |
] ifTrue:[ |
|
1705 |
super redrawVisibleLine:visLineNr |
|
1706 |
]. |
|
1707 |
"is there a submenu ?" |
|
1708 |
(subMenus notNil and:[(subMenus at:lineNr) notNil]) ifTrue:[ |
|
1709 |
self drawRightArrowInVisibleLine:visLineNr |
|
1710 |
]. |
|
1711 |
^ self |
|
0 | 1712 |
]. |
1713 |
||
1714 |
"handle separating lines" |
|
1715 |
||
59 | 1716 |
y := self yOfVisibleLine:visLineNr. |
38 | 1717 |
|
1718 |
self paint:bgColor. |
|
1719 |
self fillRectangleX:0 y:y width:width height:fontHeight. |
|
1720 |
||
0 | 1721 |
isSeparatingLine ifTrue:[ |
59 | 1722 |
y := y + (fontHeight // 2). |
63 | 1723 |
isDoubleLine ifTrue:[ |
1724 |
y := y - (fontHeight // 8). |
|
1725 |
]. |
|
130 | 1726 |
|
1727 |
right := width - 1 - lineInset. |
|
1728 |
||
59 | 1729 |
lineLevel == 0 ifTrue:[ |
1730 |
self paint:fgColor. |
|
130 | 1731 |
self displayLineFromX:lineInset y:y toX:right y:y. |
63 | 1732 |
isDoubleLine ifTrue:[ |
1733 |
y := y + (fontHeight // 4). |
|
130 | 1734 |
self displayLineFromX:lineInset y:y toX:right y:y |
63 | 1735 |
] |
59 | 1736 |
] ifFalse:[ |
1737 |
"the inset on each side" |
|
38 | 1738 |
|
59 | 1739 |
lineLevel < 0 ifTrue:[ |
1740 |
clr1 := shadowColor. |
|
1741 |
clr2 := lightColor. |
|
1742 |
] ifFalse:[ |
|
1743 |
clr1 := lightColor. |
|
1744 |
clr2 := shadowColor. |
|
1745 |
]. |
|
63 | 1746 |
|
59 | 1747 |
self paint:clr1. |
1748 |
self displayLineFromX:lineInset y:y toX:right y:y. |
|
1749 |
self paint:clr2. |
|
1750 |
y := y + 1. |
|
63 | 1751 |
self displayLineFromX:lineInset y:y toX:right y:y. |
1752 |
isDoubleLine ifTrue:[ |
|
1753 |
y := y + (fontHeight // 4). |
|
1754 |
self displayLineFromX:lineInset y:y toX:right y:y. |
|
1755 |
y := y - 1. |
|
1756 |
self paint:clr1. |
|
1757 |
self displayLineFromX:lineInset y:y toX:right y:y. |
|
1758 |
] |
|
59 | 1759 |
] |
0 | 1760 |
] |
1761 |
! |
|
1762 |
||
202 | 1763 |
redrawVisibleLine:visLine col:col |
1764 |
"redefined to always draw a full line - for openwin handling" |
|
0 | 1765 |
|
202 | 1766 |
self redrawVisibleLine:visLine |
1767 |
! |
|
97 | 1768 |
|
202 | 1769 |
redrawVisibleLine:visLine from:startCol |
1770 |
"redefined to always draw a full line - for openwin handling" |
|
21 | 1771 |
|
202 | 1772 |
self redrawVisibleLine:visLine |
1773 |
! |
|
1774 |
||
1775 |
redrawVisibleLine:visLine from:startCol to:endCol |
|
1776 |
"redefined to always draw a full line - for openwin handling" |
|
1777 |
||
1778 |
self redrawVisibleLine:visLine |
|
0 | 1779 |
! ! |
1780 |
||
202 | 1781 |
!MenuView methodsFor:'selections'! |
1782 |
||
1783 |
isValidSelection:aNumber |
|
1784 |
"return true, if aNumber is ok for a selection lineNo" |
|
1785 |
||
1786 |
|line| |
|
1787 |
||
1788 |
(super isValidSelection:aNumber) ifFalse:[^ false]. |
|
1789 |
||
1790 |
line := self listAt:aNumber. |
|
1791 |
^ (self isGraphicItem:line) not |
|
1792 |
! ! |
|
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1793 |
|
202 | 1794 |
!MenuView methodsFor:'showing'! |
1795 |
||
1796 |
realize |
|
1797 |
needResize == true ifTrue:[ |
|
1798 |
self recomputeSize |
|
1799 |
]. |
|
1800 |
super realize |
|
1801 |
! |
|
1802 |
||
1803 |
show |
|
1804 |
hiddenOnRealize := false. |
|
1805 |
self realize |
|
191
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1806 |
! ! |
5ccbde40bb6b
draw strings half a lineSpacing lower - highlight frames look better
Claus Gittinger <cg@exept.de>
parents:
174
diff
changeset
|
1807 |
|
110 | 1808 |
!MenuView methodsFor:'submenu notifications'! |
7 | 1809 |
|
70 | 1810 |
regainControl |
7 | 1811 |
"take over pointer control from a submenu" |
1812 |
||
70 | 1813 |
masterView notNil ifTrue:[ |
1814 |
masterView regainControl |
|
1815 |
]. |
|
7 | 1816 |
! |
1817 |
||
1818 |
showActive |
|
110 | 1819 |
"submenu is about to perform a menu-action - show wait cursor here as well" |
7 | 1820 |
|
1821 |
self cursor:(Cursor wait) |
|
1822 |
! |
|
1823 |
||
1824 |
showPassive |
|
110 | 1825 |
"submenu has finished its menu-action - show normal cursor again" |
7 | 1826 |
|
1827 |
self cursor:(Cursor hand) |
|
0 | 1828 |
! |
1829 |
||
202 | 1830 |
submenuTriggered |
1831 |
"submenu has performed some action - have to deselect here" |
|
77 | 1832 |
|
202 | 1833 |
self selection:nil. |
1834 |
"a bad kludge - 5 minutes before writing the alpha tapes ..." |
|
1835 |
(superView isKindOf:PopUpMenu) ifTrue:[ |
|
136 | 1836 |
superView hide |
1837 |
]. |
|
202 | 1838 |
superMenu notNil ifTrue:[ |
1839 |
superMenu submenuTriggered |
|
1840 |
]. |
|
0 | 1841 |
! ! |
202 | 1842 |
|
205 | 1843 |
!MenuView class methodsFor:'documentation'! |
1844 |
||
1845 |
version |
|
228 | 1846 |
^ '$Header: /cvs/stx/stx/libwidg/MenuView.st,v 1.39 1995-12-03 23:59:26 cg Exp $' |
205 | 1847 |
! ! |