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