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