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