author | Claus Gittinger <cg@exept.de> |
Sat, 06 Jun 1998 19:51:49 +0200 | |
changeset 911 | 6b1ad8b039c5 |
parent 910 | 5c9592e782fd |
child 963 | 2660033bc16e |
permissions | -rw-r--r-- |
388 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
||
389 | 14 |
SimpleView subclass:#MenuPanel |
689 | 15 |
instanceVariableNames:'adornment shadowView mapTime mustRearrange superMenu |
16 |
shortKeyInset selection items groupSizes receiver enableChannel |
|
17 |
menuHolder enabled onLevel offLevel fgColor activeFgColor |
|
18 |
lastActiveMenu activeBgColor disabledFgColor groupDividerSize |
|
727 | 19 |
itemSpace fitFirstPanel rightArrow rightArrowShadow |
730 | 20 |
selectionFrameBrightColor selectionFrameDarkColor |
21 |
buttonLightColor buttonShadowColor buttonHalfLightColor |
|
816 | 22 |
buttonHalfShadowColor lastButtonSelected' |
689 | 23 |
classVariableNames:'InitialSelectionQuerySignal DefaultAdornment |
24 |
DefaultGroupDividerSize DefaultHilightLevel DefaultLevel |
|
25 |
DefaultItemSpace DefaultForegroundColor DefaultBackgroundColor |
|
26 |
DefaultHilightForegroundColor DefaultHilightBackgroundColor |
|
27 |
DefaultDisabledForegroundColor DefaultFitFirstPanel |
|
730 | 28 |
RightArrowForm RightArrowShadowForm SelectionFrameBrightColor |
29 |
SelectionFrameDarkColor ButtonActiveLevel ButtonPassiveLevel |
|
30 |
ButtonActiveBackgroundColor ButtonPassiveBackgroundColor |
|
31 |
ButtonLightColor ButtonShadowColor ButtonHalfLightColor |
|
794 | 32 |
ButtonHalfShadowColor ButtonEdgeStyle Images LigthenedImages' |
689 | 33 |
poolDictionaries:'' |
34 |
category:'Views-Menus' |
|
388 | 35 |
! |
36 |
||
37 |
Object subclass:#Item |
|
729
18395718ec8e
lighten the icon & image of a disabled LabelAndIcon if the
ca
parents:
728
diff
changeset
|
38 |
instanceVariableNames:'layout menuPanel subMenu adornment rawLabel disabledRawLabel |
18395718ec8e
lighten the icon & image of a disabled LabelAndIcon if the
ca
parents:
728
diff
changeset
|
39 |
enableChannel nameKey accessCharacterPosition value label |
794 | 40 |
rawImage activeHelpKey submenuChannel startGroup isButton |
41 |
isVisible' |
|
689 | 42 |
classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset |
43 |
VerticalButtonInset LabelRightOffset ShortcutKeyOffset |
|
44 |
IndicatorOn IndicatorOff' |
|
45 |
poolDictionaries:'' |
|
46 |
privateIn:MenuPanel |
|
388 | 47 |
! |
48 |
||
49 |
Object subclass:#Adornment |
|
689 | 50 |
instanceVariableNames:'indication accessCharacterPosition shortcutKey argument' |
51 |
classVariableNames:'' |
|
52 |
poolDictionaries:'' |
|
53 |
privateIn:MenuPanel::Item |
|
388 | 54 |
! |
55 |
||
56 |
!MenuPanel class methodsFor:'documentation'! |
|
57 |
||
58 |
copyright |
|
59 |
" |
|
60 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
61 |
All Rights Reserved |
|
62 |
||
63 |
This software is furnished under a license and may be used |
|
64 |
only in accordance with the terms of that license and with the |
|
65 |
inclusion of the above copyright notice. This software may not |
|
66 |
be provided or otherwise made available to, or used by, any |
|
67 |
other person. No title to or ownership of the software is |
|
68 |
hereby transferred. |
|
69 |
" |
|
70 |
||
71 |
! |
|
72 |
||
73 |
documentation |
|
74 |
" |
|
75 |
a menu panel used for both pull-down-menus and pop-up-menus. |
|
76 |
||
77 |
not yet finished MenuPanel class - this will eventually replace |
|
78 |
most of the MenuView and PopUpMenu stuff. |
|
79 |
(and hopefully be ST-80 compatible ...) |
|
80 |
||
502 | 81 |
To create a menu, there exists a MenuEditor which will generate |
82 |
a menu specification. |
|
83 |
||
84 |
||
388 | 85 |
[author:] |
86 |
Claus Atzkern |
|
87 |
||
88 |
[see also:] |
|
89 |
Menu |
|
90 |
MenuItem |
|
502 | 91 |
MenuEditor |
388 | 92 |
" |
93 |
||
94 |
! |
|
95 |
||
96 |
examples |
|
97 |
||
98 |
" |
|
99 |
start as PullDownMenu |
|
100 |
[exBegin] |
|
101 |
|top subView mview desc s1 s2 s3 img lbs labels| |
|
102 |
||
103 |
top := StandardSystemView new. |
|
104 |
||
436 | 105 |
mview := MenuPanel in:top. |
388 | 106 |
|
502 | 107 |
labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ). |
388 | 108 |
mview level:2. |
109 |
mview verticalLayout:false. |
|
110 |
img := Image fromFile:'bitmaps/SBrowser.xbm'. |
|
502 | 111 |
lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'. |
388 | 112 |
mview labels:lbs. |
113 |
mview shortcutKeyAt:2 put:#Cut. |
|
114 |
mview accessCharacterPositionAt:1 put:1. |
|
115 |
mview accessCharacterPositionAt:2 put:2. |
|
116 |
||
117 |
mview enabledAt:5 put:false. |
|
118 |
mview groupSizes:#( 2 2 ). |
|
436 | 119 |
s1 := MenuPanel labels:labels. |
388 | 120 |
s1 accessCharacterPositionAt:1 put:1. |
121 |
s1 accessCharacterPositionAt:2 put:2. |
|
122 |
s1 groupSizes:#( 2 2 ). |
|
436 | 123 |
s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ). |
124 |
s3 := MenuPanel labels:lbs. |
|
388 | 125 |
|
126 |
s1 subMenuAt:2 put:s2. |
|
436 | 127 |
s1 subMenuAt:3 put:(MenuPanel labels:lbs). |
388 | 128 |
s2 subMenuAt:3 put:s3. |
436 | 129 |
s3 subMenuAt:3 put:(MenuPanel labels:labels). |
388 | 130 |
s3 shortcutKeyAt:3 put:$q. |
131 |
||
132 |
mview subMenuAt:1 put:s1. |
|
436 | 133 |
mview subMenuAt:4 put:(MenuPanel labels:lbs). |
388 | 134 |
(mview subMenuAt:4) shortcutKeyAt:3 put:#Copy. |
135 |
s1 shortcutKeyAt:1 put:#Copy. |
|
136 |
s1 shortcutKeyAt:3 put:#Paste. |
|
137 |
||
436 | 138 |
mview subMenuAt:2 put:(MenuPanel labels:labels). |
616 | 139 |
top extent:(mview preferredExtent). |
388 | 140 |
top open. |
141 |
[exEnd] |
|
142 |
||
143 |
||
144 |
start as PopUpMenu |
|
145 |
[exBegin] |
|
146 |
|subView mview desc s1 s2 s3 img lbs labels| |
|
147 |
||
436 | 148 |
mview := MenuPanel new. |
502 | 149 |
labels := #( 'foo' 'bar' 'baz' ). |
388 | 150 |
mview level:2. |
151 |
||
152 |
img := Image fromFile:'bitmaps/SBrowser.xbm'. |
|
502 | 153 |
lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'. |
388 | 154 |
mview labels:lbs. |
155 |
||
436 | 156 |
s1 := MenuPanel labels:labels. |
157 |
s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ). |
|
158 |
s3 := MenuPanel labels:lbs. |
|
388 | 159 |
s1 subMenuAt:2 put:s2. |
436 | 160 |
s1 subMenuAt:3 put:(MenuPanel labels:lbs). |
388 | 161 |
s2 subMenuAt:3 put:s3. |
436 | 162 |
s3 subMenuAt:3 put:(MenuPanel labels:labels). |
388 | 163 |
s3 shortcutKeyAt:3 put:$q. |
164 |
||
165 |
mview subMenuAt:1 put:s1. |
|
436 | 166 |
mview subMenuAt:4 put:(MenuPanel labels:lbs). |
388 | 167 |
(mview subMenuAt:4) shortcutKeyAt:3 put:#Copy. |
168 |
s1 shortcutKeyAt:1 put:#Copy. |
|
169 |
s1 shortcutKeyAt:3 put:#Paste. |
|
170 |
||
436 | 171 |
mview subMenuAt:2 put:(MenuPanel labels:labels). |
388 | 172 |
mview startUp |
173 |
[exEnd] |
|
174 |
||
175 |
||
176 |
start from menu spec |
|
177 |
[exBegin] |
|
178 |
|menu| |
|
179 |
||
436 | 180 |
menu := MenuPanel menu: |
388 | 181 |
#(#Menu #( #(#MenuItem |
182 |
#label: 'File' |
|
183 |
#submenu: |
|
184 |
#(#Menu #(#(#MenuItem #label: 'quit' #value:#quit ) |
|
185 |
(#MenuItem |
|
186 |
#label: 'edit' |
|
187 |
#submenu: |
|
188 |
#(#Menu #( #(#MenuItem #label: 'edit' #value:#edit ) |
|
189 |
#(#MenuItem #label: 'close' #value:#close) |
|
190 |
) |
|
191 |
nil |
|
192 |
nil |
|
193 |
) |
|
194 |
) |
|
195 |
#(#MenuItem #label: 'help' #value:#help ) |
|
196 |
) |
|
197 |
nil |
|
198 |
nil |
|
199 |
) |
|
200 |
) |
|
201 |
#(#MenuItem #label: 'Inspect' #value:#inspectMenu ) |
|
202 |
#(#MenuItem #label: 'Bar' |
|
203 |
#submenu: |
|
389 | 204 |
#(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 ) |
205 |
#(#MenuItem #label: 'bar 2' #value:#bar2 ) |
|
388 | 206 |
) |
207 |
nil |
|
389 | 208 |
nil |
388 | 209 |
) |
210 |
) |
|
211 |
) |
|
212 |
#( 2 ) |
|
213 |
nil |
|
214 |
) decodeAsLiteralArray. |
|
215 |
||
216 |
menu verticalLayout:false. |
|
217 |
Transcript showCR:(menu startUp). |
|
218 |
[exEnd] |
|
219 |
||
220 |
" |
|
221 |
||
222 |
! ! |
|
223 |
||
224 |
!MenuPanel class methodsFor:'instance creation'! |
|
225 |
||
226 |
fromSpec:aSpec |
|
227 |
^ self fromSpec:aSpec receiver:nil |
|
228 |
! |
|
229 |
||
230 |
fromSpec:aSpec receiver:aReceiver |
|
231 |
|menu| |
|
232 |
||
233 |
aSpec notNil ifTrue:[ |
|
234 |
menu := Menu new. |
|
235 |
menu fromLiteralArrayEncoding:aSpec. |
|
236 |
]. |
|
237 |
^ self menu:menu receiver:aReceiver |
|
238 |
! |
|
239 |
||
240 |
labels:labels |
|
241 |
^ self labels:labels nameKeys:nil receiver:nil |
|
242 |
! |
|
243 |
||
244 |
labels:labels nameKeys:nameKeys |
|
245 |
^ self labels:labels nameKeys:nameKeys receiver:nil |
|
246 |
! |
|
247 |
||
248 |
labels:labels nameKeys:nameKeys receiver:aReceiver |
|
249 |
|mview| |
|
250 |
||
251 |
mview := self menu:nil receiver:aReceiver. |
|
252 |
mview labels:labels. |
|
253 |
mview nameKeys:nameKeys. |
|
254 |
^ mview |
|
255 |
||
256 |
! |
|
257 |
||
502 | 258 |
labels:labels receiver:aReceiver |
259 |
^ self labels:labels nameKeys:nil receiver:aReceiver |
|
260 |
! |
|
261 |
||
388 | 262 |
menu:aMenu |
263 |
^ self menu:aMenu receiver:nil |
|
264 |
! |
|
265 |
||
266 |
menu:aMenu receiver:aReceiver |
|
267 |
|mview| |
|
268 |
||
269 |
mview := self new. |
|
270 |
mview menu:aMenu. |
|
271 |
||
272 |
"/ a menu itself may contain a receiver |
|
273 |
"/ thus we do not overwrite the receiver |
|
274 |
||
275 |
aReceiver notNil ifTrue:[ |
|
276 |
mview receiver:aReceiver |
|
277 |
]. |
|
278 |
^ mview |
|
279 |
||
280 |
! ! |
|
281 |
||
282 |
!MenuPanel class methodsFor:'class initialization'! |
|
283 |
||
284 |
initialize |
|
657 | 285 |
" |
286 |
DefaultAdornment := nil. |
|
287 |
self initialize |
|
288 |
" |
|
289 |
||
388 | 290 |
InitialSelectionQuerySignal isNil ifTrue:[ |
291 |
InitialSelectionQuerySignal := QuerySignal new. |
|
292 |
]. |
|
390 | 293 |
|
388 | 294 |
DefaultAdornment isNil ifTrue:[ |
657 | 295 |
DefaultAdornment := IdentityDictionary new |
296 |
at:#showSeparatingLines put:false; |
|
297 |
at:#showGroupDivider put:true; |
|
298 |
at:#verticalLayout put:true; |
|
299 |
at:#item put:nil; |
|
300 |
at:#value put:nil; |
|
301 |
yourself |
|
388 | 302 |
]. |
303 |
||
660
d1670dfe5445
Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents:
658
diff
changeset
|
304 |
"Modified: / 15.1.1998 / 23:08:31 / stefan" |
794 | 305 |
! |
306 |
||
307 |
preSnapshot |
|
308 |
"remove all resources |
|
309 |
" |
|
310 |
Images := nil. |
|
311 |
LigthenedImages := nil. |
|
312 |
||
616 | 313 |
! ! |
314 |
||
315 |
!MenuPanel class methodsFor:'defaults'! |
|
450 | 316 |
|
317 |
updateStyleCache |
|
657 | 318 |
|
616 | 319 |
|menuStyle style font| |
450 | 320 |
|
580 | 321 |
menuStyle := MenuView styleSheet. |
660
d1670dfe5445
Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents:
658
diff
changeset
|
322 |
menuStyle isNil ifTrue:[ |
d1670dfe5445
Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents:
658
diff
changeset
|
323 |
"make sure that style sheet is present" |
d1670dfe5445
Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents:
658
diff
changeset
|
324 |
MenuView updateStyleCache. |
d1670dfe5445
Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents:
658
diff
changeset
|
325 |
menuStyle := MenuView styleSheet. |
d1670dfe5445
Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents:
658
diff
changeset
|
326 |
]. |
616 | 327 |
style := menuStyle name. |
328 |
||
329 |
||
330 |
DefaultForegroundColor := menuStyle colorAt:'pullDownMenu.foregroundColor'. |
|
331 |
||
332 |
DefaultForegroundColor isNil ifTrue:[ |
|
333 |
DefaultForegroundColor := menuStyle colorAt:'menu.foregroundColor' |
|
334 |
default:Color black. |
|
335 |
]. |
|
336 |
||
337 |
(style == #motif or:[style == #iris]) ifTrue:[ |
|
338 |
DefaultBackgroundColor := DefaultViewBackgroundColor. |
|
339 |
DefaultHilightForegroundColor := DefaultForegroundColor. |
|
340 |
DefaultHilightLevel := 2. |
|
341 |
DefaultLevel := 0. |
|
342 |
] ifFalse:[ |
|
343 |
(DefaultHilightLevel := menuStyle at:'pullDownMenu.hilightLevel') isNil ifTrue:[ |
|
344 |
DefaultHilightLevel := menuStyle at:'menu.hilightLevel' default:0. |
|
345 |
]. |
|
346 |
DefaultLevel := menuStyle at:'pullDownMenu.level' default:1. |
|
347 |
DefaultBackgroundColor := menuStyle colorAt:'pullDownMenu.backgroundColor'. |
|
348 |
||
349 |
DefaultBackgroundColor isNil ifTrue:[ |
|
350 |
DefaultBackgroundColor := menuStyle colorAt:'menu.backgroundColor' |
|
351 |
default:DefaultViewBackgroundColor. |
|
352 |
]. |
|
353 |
||
354 |
DefaultHilightForegroundColor := menuStyle colorAt:'pullDownMenu.hilightForegroundColor'. |
|
355 |
DefaultHilightForegroundColor isNil ifTrue:[ |
|
356 |
DefaultHilightForegroundColor := menuStyle colorAt:'menu.hilightForegroundColor' |
|
357 |
default:DefaultBackgroundColor |
|
358 |
]. |
|
601 | 359 |
]. |
616 | 360 |
|
361 |
DefaultDisabledForegroundColor := menuStyle colorAt:'menu.disabledForegroundColor'. |
|
362 |
DefaultDisabledForegroundColor isNil ifTrue:[ |
|
363 |
DefaultDisabledForegroundColor := menuStyle colorAt:'button.disabledForegroundColor' |
|
364 |
default:Color darkGray. |
|
365 |
]. |
|
366 |
||
367 |
style == #motif ifTrue:[ |
|
368 |
DefaultHilightBackgroundColor := DefaultBackgroundColor |
|
369 |
] ifFalse:[ |
|
370 |
DefaultHilightBackgroundColor := menuStyle colorAt:'pullDownMenu.hilightBackgroundColor'. |
|
371 |
DefaultHilightBackgroundColor isNil ifTrue:[ |
|
372 |
DefaultHilightBackgroundColor := menuStyle colorAt:'menu.hilightBackgroundColor' |
|
373 |
default:DefaultBackgroundColor. |
|
374 |
] |
|
375 |
]. |
|
376 |
||
377 |
DefaultGroupDividerSize := menuStyle at:'menu.groupDividerSize' default:6. |
|
378 |
DefaultItemSpace := menuStyle at:'menu.itemSpace' default:0. |
|
379 |
DefaultFitFirstPanel := menuStyle at:'menu.fitFirstPanel' default:true. |
|
380 |
||
829 | 381 |
MenuView updateStyleCache. |
382 |
DefaultFont := MenuView defaultFont. |
|
383 |
"/ font := menuStyle fontAt:'pullDownMenu.font'. |
|
384 |
"/ font isNil ifTrue:[font := menuStyle fontAt:'menu.font']. |
|
385 |
"/ DefaultFont := font. |
|
616 | 386 |
|
387 |
RightArrowForm := SelectionInListView rightArrowFormOn:Display. |
|
388 |
||
389 |
style ~~ #os2 ifTrue:[ |
|
390 |
RightArrowShadowForm := SelectionInListView rightArrowShadowFormOn:Display. |
|
391 |
] ifFalse:[ |
|
392 |
RightArrowShadowForm := nil |
|
393 |
]. |
|
394 |
||
730 | 395 |
SelectionFrameBrightColor := Color white. |
396 |
SelectionFrameDarkColor := Color black. |
|
397 |
||
398 |
ButtonActiveLevel := menuStyle at:'button.activeLevel' default: -2. |
|
399 |
ButtonPassiveLevel := menuStyle at:'button.passiveLevel' default: 2. |
|
400 |
ButtonActiveBackgroundColor := menuStyle at:'button.activeBackgroundColor' default: DefaultBackgroundColor. |
|
727 | 401 |
ButtonPassiveBackgroundColor := (menuStyle at:'button.backgroundColor') ? (menuStyle at:'viewBackground') ? DefaultBackgroundColor. |
730 | 402 |
ButtonLightColor := (menuStyle at:'button.lightColor') ? Color white. |
403 |
ButtonShadowColor := (menuStyle at:'button.shadowColor') ? Color gray. |
|
404 |
ButtonHalfLightColor := menuStyle at:'button.halfLightColor'. |
|
405 |
ButtonHalfShadowColor := menuStyle at:'button.halfShadowColor'. |
|
406 |
ButtonEdgeStyle := menuStyle at:'button.edgeStyle'. |
|
727 | 407 |
|
616 | 408 |
Item updateStyleCache |
388 | 409 |
! ! |
410 |
||
794 | 411 |
!MenuPanel class methodsFor:'image registration'! |
412 |
||
413 |
image:anImage onDevice:aDevice |
|
414 |
" |
|
415 |
Images := nil |
|
416 |
" |
|
417 |
|device image| |
|
418 |
||
419 |
Images isNil ifTrue:[ Images := IdentityDictionary new ]. |
|
420 |
||
421 |
(device := Images at:aDevice ifAbsent:nil) isNil ifTrue:[ |
|
422 |
Images at:aDevice put:(device := Dictionary new) |
|
423 |
]. |
|
424 |
||
425 |
(image := device at:anImage ifAbsent:nil) notNil ifTrue:[ |
|
426 |
^ image |
|
427 |
]. |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
428 |
|
794 | 429 |
image := anImage copy onDevice:aDevice. |
430 |
image clearMaskedPixels. |
|
431 |
device at:anImage put:image. |
|
432 |
^ image |
|
433 |
||
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
434 |
"Modified: / 27.2.1998 / 17:41:37 / cg" |
794 | 435 |
! |
436 |
||
437 |
lightenedImage:anImage onDevice:aDevice |
|
438 |
" |
|
439 |
LigthenedImages := nil |
|
440 |
" |
|
441 |
|device image| |
|
442 |
||
443 |
LigthenedImages isNil ifTrue:[ LigthenedImages := IdentityDictionary new ]. |
|
444 |
||
445 |
(device := LigthenedImages at:aDevice ifAbsent:nil) isNil ifTrue:[ |
|
446 |
LigthenedImages at:aDevice put:(device := Dictionary new) |
|
447 |
]. |
|
448 |
||
449 |
(image := device at:anImage ifAbsent:nil) notNil ifTrue:[ |
|
450 |
^ image |
|
451 |
]. |
|
452 |
||
453 |
((anImage respondsTo:#colorMap) and:[anImage colorMap notNil]) ifTrue:[ |
|
454 |
image := anImage copy lightened onDevice:aDevice. |
|
455 |
image clearMaskedPixels. |
|
456 |
] ifFalse:[ |
|
457 |
image := self image:anImage onDevice:aDevice |
|
458 |
]. |
|
459 |
device at:anImage put:image. |
|
460 |
^ image |
|
461 |
||
462 |
||
463 |
! ! |
|
464 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
465 |
!MenuPanel class methodsFor:'private'! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
466 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
467 |
subMenu:aSubMenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
468 |
"create a submenu; can be redifined in derived classes |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
469 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
470 |
^ (MenuPanel new) menu:aSubMenu. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
471 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
472 |
! ! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
473 |
|
650 | 474 |
!MenuPanel class methodsFor:'resources'! |
475 |
||
476 |
checkedImage |
|
477 |
"ImageEditor openOnClass:self andSelector:#checkedImage" |
|
478 |
||
479 |
<resource: #image> |
|
480 |
^(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[255 255 255 255 234 170 170 169 229 85 85 85 228 21 85 5 228 5 84 5 229 1 80 21 229 64 64 85 229 80 1 85 229 84 5 85 229 80 1 85 229 64 64 85 229 1 80 21 228 5 84 5 228 21 85 5 229 85 85 85 213 85 85 85]) ; colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color grey:49.9962)); at:4 put:((Color grey:66.9978)); yourself)); yourself! |
|
481 |
||
482 |
uncheckedImage |
|
483 |
"ImageEditor openOnClass:self andSelector:#uncheckedImage" |
|
484 |
||
485 |
<resource: #image> |
|
486 |
^(Depth2Image new) width: 16; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(#[170 170 170 170 149 85 85 84 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 144 0 0 0 128 0 0 0]) ; colorMap:((OrderedCollection new add:(Color white); add:(Color grey:49.9977); add:(Color grey:66.9978); add:(Color black); yourself)); yourself! ! |
|
487 |
||
389 | 488 |
!MenuPanel methodsFor:'accept'! |
489 |
||
490 |
accept |
|
491 |
"accept current selected item |
|
492 |
" |
|
510 | 493 |
^ self accept:(self selection) |
389 | 494 |
! |
495 |
||
496 |
accept:anItem |
|
497 |
"this is the topMenu: accept item |
|
498 |
" |
|
524 | 499 |
|value item tgState itemIdx recv| |
389 | 500 |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
501 |
self superMenu notNil ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
502 |
^ self topMenu accept:anItem |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
503 |
]. |
816 | 504 |
lastButtonSelected := nil. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
505 |
self selection:nil. |
420 | 506 |
self forceUngrabMouseAndKeyboard. |
507 |
||
508 |
(anItem notNil and:[anItem canAccept]) ifTrue:[ |
|
524 | 509 |
tgState := anItem toggleIndication. |
510 |
itemIdx := anItem menuPanel findFirst:[:el| el == anItem ]. |
|
511 |
item := anItem. |
|
512 |
recv := anItem menuPanel receiver. |
|
389 | 513 |
]. |
514 |
||
510 | 515 |
self isPopUpView ifFalse:[ |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
516 |
self do:[:el| el updateIndicators]. |
653 | 517 |
self windowGroup processExposeEvents. |
524 | 518 |
] ifTrue:[ |
519 |
self destroy |
|
520 |
]. |
|
521 |
value := self accept:item index:itemIdx toggle:tgState receiver:recv. |
|
522 |
||
523 |
self isPopUpView ifTrue:[ |
|
524 |
self menuAdornmentAt:#value put:value. |
|
653 | 525 |
self menuAdornmentAt:#item put:item. |
524 | 526 |
]. |
653 | 527 |
|
524 | 528 |
^ item. |
529 |
||
530 |
! |
|
531 |
||
532 |
accept:anItem index:anIndex toggle:aState receiver:aReceiver |
|
533 |
"accept an item |
|
534 |
" |
|
545 | 535 |
|value argument numArgs isKindOfValueModel| |
524 | 536 |
|
537 |
anItem isNil ifTrue:[ |
|
538 |
self menuAdornmentAt:#hasPerformed put:true. |
|
539 |
^ nil |
|
540 |
]. |
|
541 |
||
542 |
self menuAdornmentAt:#hasPerformed put:(aReceiver isKindOf:ValueModel). |
|
543 |
||
544 |
(value := anItem value) isNil ifTrue:[ |
|
545 |
^ anIndex |
|
546 |
]. |
|
547 |
||
548 |
(argument := anItem argument) isNil ifTrue:[ |
|
738 | 549 |
argument := aState ? anItem |
389 | 550 |
]. |
524 | 551 |
|
552 |
value isSymbol ifFalse:[ |
|
553 |
(value respondsTo:#numArgs) ifTrue:[numArgs := value numArgs] |
|
554 |
ifFalse:[numArgs := 0]. |
|
555 |
||
556 |
numArgs == 0 ifTrue:[ |
|
557 |
value value |
|
558 |
] ifFalse:[ |
|
559 |
numArgs == 1 ifTrue:[value value:argument] |
|
560 |
ifFalse:[value value:argument value:self] |
|
561 |
]. |
|
465 | 562 |
self menuAdornmentAt:#hasPerformed put:true. |
524 | 563 |
^ anIndex |
564 |
]. |
|
565 |
||
566 |
aReceiver isNil ifTrue:[ |
|
567 |
^ value |
|
568 |
]. |
|
569 |
isKindOfValueModel := aReceiver isKindOf:ValueModel. |
|
570 |
||
571 |
(numArgs := value numArgs) == 0 ifTrue:[ |
|
572 |
isKindOfValueModel ifFalse:[aReceiver perform:value] |
|
573 |
ifTrue:[aReceiver value:value] |
|
465 | 574 |
] ifFalse:[ |
524 | 575 |
numArgs == 1 ifTrue:[ |
576 |
isKindOfValueModel ifFalse:[aReceiver perform:value with:argument] |
|
577 |
ifTrue:[aReceiver value:value value:argument] |
|
578 |
] ifFalse:[ |
|
579 |
isKindOfValueModel ifFalse:[aReceiver perform:value with:argument with:self] |
|
580 |
ifTrue:[aReceiver value:value value:argument value:self] |
|
581 |
] |
|
420 | 582 |
]. |
524 | 583 |
self menuAdornmentAt:#hasPerformed put:true. |
584 |
^ value |
|
389 | 585 |
! |
586 |
||
587 |
lastItemAccepted |
|
588 |
"returns last item selected or nil |
|
589 |
" |
|
390 | 590 |
^ self topMenu menuAdornmentAt:#item |
389 | 591 |
! |
592 |
||
593 |
lastValueAccepted |
|
594 |
"returns last value accepted or nil |
|
595 |
" |
|
465 | 596 |
|top| |
597 |
||
598 |
top := self topMenu. |
|
599 |
||
600 |
(top menuAdornmentAt:#hasPerformed) ~~ true ifTrue:[ |
|
601 |
^ self topMenu menuAdornmentAt:#value. |
|
602 |
]. |
|
603 |
^ nil |
|
389 | 604 |
! ! |
605 |
||
388 | 606 |
!MenuPanel methodsFor:'accessing'! |
607 |
||
608 |
accessCharacterPositionAt:stringOrNumber |
|
390 | 609 |
"get the access character position for a textLabel |
388 | 610 |
" |
611 |
^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ] |
|
612 |
! |
|
613 |
||
614 |
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil |
|
390 | 615 |
"get the access character position for a textLabel |
388 | 616 |
" |
617 |
self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ] |
|
618 |
! |
|
619 |
||
620 |
accessCharacterPositions |
|
621 |
"returns a collection of accessCharacterPosition's or nil |
|
622 |
" |
|
623 |
^ self collect:[:anItem| anItem accessCharacterPosition ] |
|
624 |
||
625 |
! |
|
626 |
||
627 |
accessCharacterPositions:something |
|
628 |
"define accessCharacterPosition's for each item |
|
629 |
" |
|
630 |
self onEachPerform:#accessCharacterPosition: withArgList:something |
|
631 |
! |
|
632 |
||
633 |
args |
|
634 |
"returns a collection of argument's or nil |
|
635 |
" |
|
636 |
^ self collect:[:anItem| anItem argument ] |
|
637 |
! |
|
638 |
||
639 |
args:something |
|
640 |
"define arguments for each item |
|
641 |
" |
|
642 |
self onEachPerform:#argument: withArgList:something |
|
643 |
! |
|
644 |
||
645 |
argsAt:stringOrNumber |
|
646 |
"gets the argument of an item or nil |
|
647 |
" |
|
648 |
^ self itemAt:stringOrNumber do:[:el| el argument ] |
|
649 |
! |
|
650 |
||
651 |
argsAt:stringOrNumber put:anArgument |
|
652 |
"sets the argument of an item |
|
653 |
" |
|
654 |
self itemAt:stringOrNumber do:[:el| el argument:anArgument ] |
|
655 |
! |
|
656 |
||
657 |
groupSizes |
|
658 |
"gets collection of group sizes |
|
659 |
" |
|
660 |
^ groupSizes |
|
661 |
! |
|
662 |
||
663 |
groupSizes:aGroupSizes |
|
664 |
"sets collection of group sizes |
|
665 |
" |
|
666 |
aGroupSizes = groupSizes ifFalse:[ |
|
667 |
groupSizes := aGroupSizes copy. |
|
668 |
self mustRearrange. |
|
669 |
]. |
|
670 |
! |
|
671 |
||
672 |
labelAt:stringOrNumber |
|
673 |
"gets the label of an item or nil |
|
674 |
" |
|
675 |
^ self itemAt:stringOrNumber do:[:el| el label ] |
|
676 |
! |
|
677 |
||
678 |
labelAt:stringOrNumber put:aLabel |
|
679 |
"sets the label of an item |
|
680 |
" |
|
681 |
self itemAt:stringOrNumber do:[:el| el label:aLabel ] |
|
682 |
! |
|
683 |
||
684 |
labels |
|
685 |
"returns a collection of labels's or nil |
|
686 |
" |
|
687 |
^ self collect:[:anItem| anItem label ] |
|
688 |
||
689 |
! |
|
690 |
||
691 |
labels:labels |
|
692 |
"define labels for each item |
|
693 |
" |
|
694 |
self disabledRedrawDo:[ |
|
695 |
self removeAll. |
|
696 |
||
697 |
labels notNil ifTrue:[ |
|
698 |
labels do:[:aLabel|(self createAtIndex:nil) label:aLabel] |
|
699 |
] |
|
700 |
] |
|
701 |
! |
|
702 |
||
703 |
nameKeyAt:stringOrNumber |
|
704 |
"gets the nameKey of an item or nil |
|
705 |
" |
|
706 |
^ self itemAt:stringOrNumber do:[:el| el nameKey ] |
|
707 |
! |
|
708 |
||
709 |
nameKeyAt:stringOrNumber put:aNameKey |
|
710 |
"sets the nameKey of an item |
|
711 |
" |
|
712 |
self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ] |
|
713 |
! |
|
714 |
||
715 |
nameKeys |
|
716 |
"returns a collection of nameKeys's or nil |
|
717 |
" |
|
718 |
^ self collect:[:anItem| anItem nameKey ] |
|
719 |
! |
|
720 |
||
721 |
nameKeys:something |
|
722 |
"define nameKeys for each item |
|
723 |
" |
|
724 |
self onEachPerform:#nameKey: withArgList:something |
|
725 |
! |
|
726 |
||
727 |
numberOfItems |
|
728 |
"gets number of items |
|
729 |
" |
|
730 |
^ items size |
|
731 |
! |
|
732 |
||
733 |
receiver |
|
734 |
"get the menu-receiver. Thats the one who gets the messages ( both from myself and |
|
735 |
from all submenus no specific receiver is defined ). |
|
736 |
" |
|
389 | 737 |
(receiver isNil and:[superMenu notNil]) ifTrue:[ |
388 | 738 |
^ superMenu receiver |
739 |
]. |
|
389 | 740 |
^ receiver |
388 | 741 |
! |
742 |
||
743 |
receiver:anObject |
|
744 |
"set the menu-receiver. Thats the one who gets the messages ( both from myself and |
|
745 |
from all submenus no specific receiver is defined ). |
|
746 |
" |
|
389 | 747 |
receiver := anObject |
388 | 748 |
! |
749 |
||
750 |
shortcutKeyAt:stringOrNumber |
|
751 |
"gets the shortCutKey of an item or nil |
|
752 |
" |
|
753 |
^ self itemAt:stringOrNumber do:[:el| el shortcutKey ] |
|
754 |
! |
|
755 |
||
756 |
shortcutKeyAt:stringOrNumber put:aKey |
|
757 |
"sets the shortCutKey of an item |
|
758 |
" |
|
759 |
self itemAt:stringOrNumber do:[:el| el shortcutKey:aKey ] |
|
760 |
! |
|
761 |
||
762 |
shortcutKeys |
|
763 |
"returns a collection of shortcutKey's or nil |
|
764 |
" |
|
765 |
^ self collect:[:anItem| anItem shortcutKey ] |
|
766 |
||
767 |
! |
|
768 |
||
769 |
shortcutKeys:something |
|
770 |
"define shortcutKey's for each item |
|
771 |
" |
|
772 |
self onEachPerform:#shortcutKey: withArgList:something |
|
773 |
! |
|
774 |
||
775 |
valueAt:stringOrNumber |
|
776 |
"gets value of an item; a block, valueHolder, ... |
|
777 |
" |
|
778 |
^ self itemAt:stringOrNumber do:[:el| el value ] |
|
779 |
||
780 |
! |
|
781 |
||
782 |
valueAt:stringOrNumber put:someThing |
|
783 |
"sets value of an item; a block, valueHolder, ... |
|
784 |
" |
|
785 |
self itemAt:stringOrNumber do:[:el| el value:someThing ] |
|
786 |
||
787 |
||
788 |
! |
|
789 |
||
790 |
values:something |
|
791 |
"define values for each item |
|
792 |
" |
|
793 |
self onEachPerform:#value: withArgList:something |
|
794 |
! ! |
|
795 |
||
796 |
!MenuPanel methodsFor:'accessing behavior'! |
|
797 |
||
798 |
disable |
|
498 | 799 |
"disable the menu |
388 | 800 |
" |
801 |
self enabled:false |
|
802 |
! |
|
803 |
||
804 |
disableAll |
|
498 | 805 |
"disable all items; not the menu in case of enabled |
388 | 806 |
" |
498 | 807 |
self do:[:anItem| anItem enabled:false] |
388 | 808 |
! |
809 |
||
810 |
disableAll:collectionOfIndicesOrNames |
|
811 |
"disable an collection of items |
|
812 |
" |
|
813 |
collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ]. |
|
814 |
||
815 |
! |
|
816 |
||
817 |
enable |
|
498 | 818 |
"enable the menu |
388 | 819 |
" |
820 |
self enabled:true |
|
821 |
! |
|
822 |
||
823 |
enableAll |
|
498 | 824 |
"enable all items; not the menu in case of disabled |
388 | 825 |
" |
498 | 826 |
self do:[:anItem| anItem enabled:true] |
388 | 827 |
! |
828 |
||
829 |
enableAll:collectionOfIndicesOrNames |
|
830 |
"enable an collection of items |
|
831 |
" |
|
832 |
collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ]. |
|
833 |
||
834 |
! |
|
835 |
||
836 |
enabled |
|
837 |
"returns enabled state |
|
838 |
" |
|
498 | 839 |
^ enabled |
388 | 840 |
! |
841 |
||
842 |
enabled:aState |
|
843 |
"change enabled state of menu |
|
844 |
" |
|
545 | 845 |
|state| |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
846 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
847 |
state := aState ? true. |
388 | 848 |
|
498 | 849 |
self enabled == state ifTrue:[ |
850 |
^ self |
|
851 |
]. |
|
852 |
enabled := state. |
|
853 |
||
854 |
self canDrawItem ifTrue:[ |
|
855 |
self do:[:anItem| anItem enabledStateOfMenuChangedTo:enabled] |
|
856 |
]. |
|
388 | 857 |
! |
858 |
||
859 |
enabledAt:stringOrNumber |
|
860 |
"gets the enabled state of an item or false |
|
861 |
" |
|
862 |
^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false |
|
863 |
! |
|
864 |
||
865 |
enabledAt:stringOrNumber put:aState |
|
866 |
"sets the enabled state of an item |
|
867 |
" |
|
868 |
self itemAt:stringOrNumber do:[:el| el enabled:aState ] |
|
869 |
! |
|
870 |
||
871 |
isEnabled:stringOrNumber |
|
872 |
"gets the enabled state of an item or false |
|
873 |
" |
|
874 |
^ self enabledAt:stringOrNumber |
|
875 |
! ! |
|
876 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
877 |
!MenuPanel methodsFor:'accessing channels'! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
878 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
879 |
enableChannel |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
880 |
"gets a enable channel or nil |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
881 |
" |
498 | 882 |
^ enableChannel |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
883 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
884 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
885 |
enableChannel:aValueHolder |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
886 |
"set my enableChannel |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
887 |
" |
498 | 888 |
enableChannel notNil ifTrue:[ |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
889 |
enableChannel removeDependent:self |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
890 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
891 |
|
498 | 892 |
(enableChannel := aValueHolder) notNil ifTrue:[ |
893 |
enableChannel addDependent:self. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
894 |
]. |
498 | 895 |
self enabled:(enableChannel value). |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
896 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
897 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
898 |
menuHolder |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
899 |
"gets a menu holder or nil |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
900 |
" |
498 | 901 |
^ menuHolder |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
902 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
903 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
904 |
menuHolder:aValueHolder |
498 | 905 |
"set my menuHolder |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
906 |
" |
498 | 907 |
menuHolder notNil ifTrue:[ |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
908 |
menuHolder removeDependent:self |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
909 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
910 |
|
498 | 911 |
(menuHolder := aValueHolder) notNil ifTrue:[ |
912 |
menuHolder addDependent:self. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
913 |
]. |
498 | 914 |
self menu:(menuHolder value) |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
915 |
! ! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
916 |
|
390 | 917 |
!MenuPanel methodsFor:'accessing color & font'! |
918 |
||
616 | 919 |
activeBackgroundColor |
920 |
"get the background drawing color used to highlight selection |
|
921 |
" |
|
922 |
^ activeBgColor |
|
923 |
! |
|
924 |
||
390 | 925 |
activeBackgroundColor:aColor |
926 |
"set the background drawing color used to highlight selection. You should not |
|
927 |
use this method; instead leave the value as defined in the styleSheet. |
|
928 |
" |
|
616 | 929 |
activeBgColor ~~ aColor ifTrue:[ |
930 |
activeBgColor := aColor on:device. |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
931 |
shown ifTrue:[ |
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
932 |
self invalidate "/ RepairNow:true |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
933 |
] |
616 | 934 |
] |
935 |
||
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
936 |
"Modified: / 6.6.1998 / 19:49:46 / cg" |
616 | 937 |
! |
938 |
||
939 |
activeForegroundColor |
|
940 |
"get the foreground color used to highlight selections |
|
941 |
" |
|
942 |
^ activeFgColor |
|
943 |
! |
|
944 |
||
945 |
activeForegroundColor:aColor |
|
946 |
"set the foreground color used to highlight selections; You should not |
|
947 |
use this method; instead leave the value as defined in the styleSheet. |
|
948 |
" |
|
949 |
activeFgColor ~~ aColor ifTrue:[ |
|
950 |
activeFgColor := aColor on:device. |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
951 |
shown ifTrue:[ |
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
952 |
self invalidate "/ RepairNow:true |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
953 |
] |
616 | 954 |
] |
955 |
||
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
956 |
"Modified: / 6.6.1998 / 19:50:01 / cg" |
390 | 957 |
! |
958 |
||
959 |
backgroundColor |
|
960 |
"return the background color |
|
961 |
" |
|
502 | 962 |
^ super viewBackground |
390 | 963 |
! |
964 |
||
965 |
backgroundColor:aColor |
|
966 |
"set the background drawing color. You should not use this method; |
|
967 |
instead leave the value as defined in the styleSheet. |
|
968 |
" |
|
616 | 969 |
super viewBackground ~~ aColor ifTrue:[ |
970 |
super viewBackground:aColor. |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
971 |
shown ifTrue:[ |
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
972 |
self invalidate "/ RepairNow:true |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
973 |
] |
616 | 974 |
] |
975 |
||
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
976 |
"Modified: / 6.6.1998 / 19:50:06 / cg" |
390 | 977 |
! |
978 |
||
727 | 979 |
buttonActiveBackgroundColor |
980 |
"get the background drawing color used to highlight button selection |
|
981 |
" |
|
982 |
^ButtonActiveBackgroundColor |
|
983 |
! |
|
984 |
||
730 | 985 |
buttonEdgeStyle |
986 |
"get the button edge style |
|
987 |
" |
|
988 |
^ButtonEdgeStyle |
|
989 |
! |
|
990 |
||
991 |
buttonHalfLightColor |
|
992 |
"get the background drawing color used to half light button frame |
|
993 |
" |
|
994 |
^buttonHalfLightColor |
|
995 |
! |
|
996 |
||
997 |
buttonHalfShadowColor |
|
998 |
"get the background drawing color used to half shadow button frame |
|
999 |
" |
|
1000 |
^buttonHalfShadowColor |
|
727 | 1001 |
! |
1002 |
||
1003 |
buttonLightColor |
|
1004 |
"get the background drawing color used to light button frame |
|
1005 |
" |
|
1006 |
^buttonLightColor |
|
1007 |
! |
|
1008 |
||
1009 |
buttonPassiveBackgroundColor |
|
1010 |
"get the background drawing color used for button |
|
1011 |
" |
|
1012 |
^ButtonPassiveBackgroundColor |
|
1013 |
! |
|
1014 |
||
1015 |
buttonShadowColor |
|
1016 |
"get the background drawing color used to shadow button frame |
|
1017 |
" |
|
1018 |
^buttonShadowColor |
|
1019 |
! |
|
1020 |
||
390 | 1021 |
disabledForegroundColor |
1022 |
"return the foreground color used by disabled items |
|
1023 |
" |
|
616 | 1024 |
^ disabledFgColor |
390 | 1025 |
|
1026 |
! |
|
1027 |
||
1028 |
disabledForegroundColor:aColor |
|
1029 |
"set the foregroundColor drawing color used by disabled items. You should not |
|
1030 |
use this method; instead leave the value as defined in the styleSheet. |
|
1031 |
" |
|
616 | 1032 |
disabledFgColor ~~ aColor ifTrue:[ |
1033 |
disabledFgColor := aColor on:device. |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1034 |
shown ifTrue:[ |
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1035 |
self invalidate "/ RepairNow:true |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1036 |
] |
616 | 1037 |
]. |
1038 |
||
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1039 |
"Modified: / 6.6.1998 / 19:50:17 / cg" |
390 | 1040 |
! |
1041 |
||
1042 |
font:aFont |
|
1043 |
"set the font |
|
1044 |
" |
|
829 | 1045 |
(aFont notNil and:[aFont ~= font]) ifTrue:[ |
1046 |
super font:(aFont on:device). |
|
1047 |
||
1048 |
superMenu notNil ifTrue:[ |
|
1049 |
self extent:(self preferredExtent) |
|
1050 |
]. |
|
1051 |
self mustRearrange. |
|
390 | 1052 |
] |
1053 |
! |
|
1054 |
||
1055 |
foregroundColor |
|
1056 |
"return the passive foreground color |
|
1057 |
" |
|
616 | 1058 |
^ fgColor |
390 | 1059 |
|
1060 |
||
1061 |
! |
|
1062 |
||
1063 |
foregroundColor:aColor |
|
1064 |
"set the foregroundColor drawing color. You should not use this method; |
|
1065 |
instead leave the value as defined in the styleSheet. |
|
1066 |
" |
|
616 | 1067 |
fgColor ~~ aColor ifTrue:[ |
1068 |
fgColor := aColor on:device. |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1069 |
shown ifTrue:[ |
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1070 |
self invalidate "/ RepairNow:true |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1071 |
] |
616 | 1072 |
] |
1073 |
||
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1074 |
"Modified: / 6.6.1998 / 19:50:46 / cg" |
580 | 1075 |
! |
1076 |
||
390 | 1077 |
lightColor |
1078 |
"get the lightColor |
|
1079 |
" |
|
1080 |
^ lightColor |
|
1081 |
||
1082 |
||
1083 |
! |
|
1084 |
||
1085 |
lightColor:aColor |
|
1086 |
"set the light drawing color. You should not use this method; |
|
1087 |
instead leave the value as defined in the styleSheet. |
|
1088 |
" |
|
1089 |
lightColor ~~ aColor ifTrue:[ |
|
1090 |
super lightColor:aColor. |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1091 |
shown ifTrue:[ |
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1092 |
self invalidate "/ RepairNow:true |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1093 |
] |
390 | 1094 |
] |
1095 |
||
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1096 |
"Modified: / 6.6.1998 / 19:50:39 / cg" |
390 | 1097 |
! |
1098 |
||
730 | 1099 |
selectionFrameBrightColor |
1100 |
"get the selection frame bright color |
|
1101 |
" |
|
1102 |
^selectionFrameBrightColor |
|
1103 |
! |
|
1104 |
||
1105 |
selectionFrameDarkColor |
|
1106 |
"get the selection frame dark color |
|
1107 |
" |
|
1108 |
^selectionFrameDarkColor |
|
1109 |
! |
|
1110 |
||
390 | 1111 |
shadowColor |
1112 |
"get the shadowColor |
|
1113 |
" |
|
1114 |
^ shadowColor |
|
1115 |
||
1116 |
||
1117 |
! |
|
1118 |
||
1119 |
shadowColor:aColor |
|
1120 |
"set the shadow drawing color. You should not use this method; |
|
1121 |
instead leave the value as defined in the styleSheet. |
|
1122 |
" |
|
1123 |
shadowColor ~~ aColor ifTrue:[ |
|
1124 |
super shadowColor:aColor. |
|
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1125 |
shown ifTrue:[ |
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1126 |
self invalidate "/ RepairNow:true |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1127 |
] |
390 | 1128 |
] |
1129 |
||
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1130 |
"Modified: / 6.6.1998 / 19:50:32 / cg" |
390 | 1131 |
! ! |
1132 |
||
388 | 1133 |
!MenuPanel methodsFor:'accessing dimensions'! |
1134 |
||
1135 |
height |
|
1136 |
"default height |
|
1137 |
" |
|
1138 |
|item| |
|
1139 |
||
1140 |
(explicitExtent ~~ true) ifTrue:[ |
|
1141 |
(item := self itemAt:1) notNil ifTrue:[ |
|
1142 |
self rearrangeItems. |
|
1143 |
^ item height |
|
1144 |
]. |
|
1145 |
^ 4 + (font height + (font descent * 2)). |
|
1146 |
]. |
|
1147 |
^ super height |
|
1148 |
! |
|
1149 |
||
1150 |
preferredExtent |
|
1151 |
"compute and returns my preferred extent |
|
1152 |
" |
|
650 | 1153 |
|x y hasMenu shCtKey space hrzInset| |
388 | 1154 |
|
1155 |
self numberOfItems == 0 ifTrue:[ |
|
1156 |
^ 32 @ 32 |
|
1157 |
]. |
|
616 | 1158 |
space := (items size + 1) * itemSpace. |
1159 |
||
390 | 1160 |
self isFitPanel ifTrue:[ |
1161 |
x := 0 |
|
1162 |
] ifFalse:[ |
|
616 | 1163 |
x := groupSizes size * groupDividerSize. |
390 | 1164 |
]. |
650 | 1165 |
hrzInset := items first horizontalInset. |
388 | 1166 |
|
1167 |
self verticalLayout ifFalse:[ |
|
1168 |
y := 0. |
|
1169 |
||
1170 |
self do:[:el||z| |
|
712 | 1171 |
el isVisible ifTrue:[ |
1172 |
x := x + el preferredExtentX. |
|
1173 |
y < (z := el preferredExtentY) ifTrue:[y := z] |
|
1174 |
] |
|
388 | 1175 |
]. |
616 | 1176 |
x := x + space. |
388 | 1177 |
] ifTrue:[ |
1178 |
hasMenu := false. |
|
1179 |
shCtKey := 0. |
|
1180 |
y := x. |
|
1181 |
x := 0. |
|
1182 |
||
1183 |
self do:[:el| |l e| |
|
712 | 1184 |
el isVisible ifTrue:[ |
1185 |
(l := el rawLabel) notNil ifTrue:[ |
|
1186 |
(e := l widthOn:self) > x ifTrue:[x := e]. |
|
1187 |
||
1188 |
(el hasSubmenu or:[el submenuChannel notNil]) ifTrue:[ |
|
1189 |
hasMenu := true |
|
1190 |
]. |
|
1191 |
||
1192 |
( (l := el shortcutKeyAsString) notNil |
|
1193 |
and:[(e := l widthOn:self) > shCtKey] |
|
1194 |
) ifTrue:[ |
|
1195 |
shCtKey := e |
|
1196 |
]. |
|
638 | 1197 |
]. |
712 | 1198 |
y := y + el preferredExtentY |
1199 |
] |
|
388 | 1200 |
]. |
650 | 1201 |
x := x + hrzInset. |
388 | 1202 |
|
1203 |
(hasMenu or:[shCtKey ~~ 0]) ifTrue:[ |
|
594 | 1204 |
shortKeyInset := x + Item labelRightOffset. |
616 | 1205 |
x := shortKeyInset + shCtKey + self subMenuIndicationWidth. |
388 | 1206 |
|
1207 |
(shCtKey ~~ 0 and:[hasMenu]) ifTrue:[ |
|
1208 |
x := x + (Item shortcutKeyOffset) |
|
1209 |
] |
|
1210 |
]. |
|
616 | 1211 |
y := y + space. |
650 | 1212 |
x := x + hrzInset. |
388 | 1213 |
]. |
1214 |
^ x @ y |
|
1215 |
||
1216 |
||
1217 |
! |
|
1218 |
||
1219 |
shortKeyInset |
|
1220 |
"left inset of shortcutKey |
|
1221 |
" |
|
1222 |
^ shortKeyInset |
|
616 | 1223 |
! |
1224 |
||
1225 |
subMenuIndicationWidth |
|
1226 |
^ RightArrowForm width |
|
388 | 1227 |
! ! |
1228 |
||
1229 |
!MenuPanel methodsFor:'accessing items'! |
|
1230 |
||
1231 |
itemAt:stringOrNumber |
|
390 | 1232 |
"returns item assigned to an index, nameKey, textLabel or value if symbol. |
1233 |
If no item match nil is returned. |
|
388 | 1234 |
" |
1235 |
|idx| |
|
1236 |
||
1237 |
idx := self indexOf:stringOrNumber. |
|
1238 |
(idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ]. |
|
1239 |
^ nil |
|
1240 |
||
1241 |
! |
|
1242 |
||
1243 |
itemAt:stringOrNumber do:aOneArgBlock |
|
1244 |
"evaluate teh block for an item and return the result from the block. In case that |
|
1245 |
the item not exists nil is returned |
|
1246 |
" |
|
1247 |
^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil |
|
1248 |
! |
|
1249 |
||
1250 |
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock |
|
1251 |
"evaluate teh block for an item and return the result from the block. In case that |
|
1252 |
the item not exists the result of the exception block is returned (no arguments). |
|
1253 |
" |
|
1254 |
|item| |
|
1255 |
||
1256 |
item := self itemAt:stringOrNumber. |
|
1257 |
item notNil ifTrue:[ ^ aOneArgBlock value:item ]. |
|
1258 |
^ exceptionBlock value |
|
706 | 1259 |
! |
1260 |
||
1261 |
itemAtIndex:anIndex |
|
1262 |
"returns item at an index or nil |
|
1263 |
" |
|
1264 |
^ items notNil ifTrue:[items at:anIndex ifAbsent:nil] ifFalse:[nil] |
|
388 | 1265 |
! ! |
1266 |
||
1267 |
!MenuPanel methodsFor:'accessing look'! |
|
1268 |
||
727 | 1269 |
buttonActiveLevel |
1270 |
"get the button active level |
|
1271 |
" |
|
1272 |
^ButtonActiveLevel |
|
1273 |
||
1274 |
! |
|
1275 |
||
1276 |
buttonPassiveLevel |
|
1277 |
"get the button passive level |
|
1278 |
" |
|
1279 |
^ButtonPassiveLevel |
|
1280 |
||
1281 |
! |
|
1282 |
||
390 | 1283 |
fitFirstPanel |
1284 |
"gets true if the first panel in the menu hierarchy must be fit |
|
1285 |
to the extent of its superView |
|
388 | 1286 |
" |
616 | 1287 |
^ fitFirstPanel |
388 | 1288 |
! |
1289 |
||
390 | 1290 |
fitFirstPanel:aState |
1291 |
"sets true if the first panel in the menu hierarchy must be fit |
|
1292 |
to the extent of its superView |
|
388 | 1293 |
" |
616 | 1294 |
(fitFirstPanel == aState or:[self isPopUpView]) ifFalse:[ |
1295 |
fitFirstPanel := aState. |
|
1296 |
self mustRearrange |
|
1297 |
] |
|
388 | 1298 |
! |
1299 |
||
390 | 1300 |
groupDividerSize |
1301 |
"get the size of the group dividers |
|
388 | 1302 |
" |
616 | 1303 |
^ groupDividerSize |
1304 |
||
388 | 1305 |
! |
1306 |
||
390 | 1307 |
groupDividerSize:aSize |
616 | 1308 |
"set the size of the group dividers. You should not use this |
1309 |
method; instead leave the value as defined in the styleSheet. |
|
388 | 1310 |
" |
616 | 1311 |
aSize ~~ groupDividerSize ifTrue:[ |
1312 |
groupDividerSize := aSize. |
|
1313 |
self mustRearrange. |
|
1314 |
]. |
|
1315 |
||
388 | 1316 |
! |
1317 |
||
616 | 1318 |
itemSpace |
1319 |
"get the space space between to items |
|
388 | 1320 |
" |
616 | 1321 |
^ itemSpace |
1322 |
||
388 | 1323 |
! |
1324 |
||
616 | 1325 |
itemSpace:aSize |
1326 |
"set the horizontal space between to items. You should not use this |
|
1327 |
method; instead leave the value as defined in the styleSheet. |
|
388 | 1328 |
" |
616 | 1329 |
aSize ~~ itemSpace ifTrue:[ |
1330 |
itemSpace := aSize. |
|
1331 |
self mustRearrange |
|
1332 |
]. |
|
1333 |
||
1334 |
! |
|
1335 |
||
1336 |
rightArrow |
|
1337 |
^ rightArrow |
|
1338 |
! |
|
1339 |
||
1340 |
rightArrowShadow |
|
1341 |
^ rightArrowShadow |
|
388 | 1342 |
! |
1343 |
||
390 | 1344 |
showGroupDivider |
1345 |
"get the enabled flag for showing groupDiveders |
|
388 | 1346 |
" |
390 | 1347 |
^ self menuAdornmentAt:#showGroupDivider |
388 | 1348 |
! |
1349 |
||
390 | 1350 |
showGroupDivider:aState |
1351 |
"set the enabled flag for showing groupDiveders |
|
388 | 1352 |
" |
653 | 1353 |
(self menuAdornmentAt:#showGroupDivider put:aState) ifTrue:[ |
1354 |
self mustRearrange. |
|
1355 |
] |
|
388 | 1356 |
! |
1357 |
||
1358 |
showSeparatingLines |
|
1359 |
"gets true if drawing of separating lines is enabled. |
|
1360 |
" |
|
390 | 1361 |
^ self menuAdornmentAt:#showSeparatingLines |
388 | 1362 |
! |
1363 |
||
390 | 1364 |
showSeparatingLines:aState |
388 | 1365 |
"turn on/off drawing of separating lines. |
1366 |
" |
|
653 | 1367 |
(self menuAdornmentAt:#showSeparatingLines put:aState) ifTrue:[ |
1368 |
self mustRearrange |
|
1369 |
] |
|
388 | 1370 |
! |
1371 |
||
1372 |
verticalLayout |
|
1373 |
"get the layout: or vertical( true ) or horizontal( false ) |
|
1374 |
" |
|
390 | 1375 |
^ self menuAdornmentAt:#verticalLayout |
388 | 1376 |
! |
1377 |
||
1378 |
verticalLayout:aState |
|
1379 |
"set the layout: or vertical( true ) or horizontal( false ) |
|
1380 |
" |
|
653 | 1381 |
(self menuAdornmentAt:#verticalLayout put:aState) ifTrue:[ |
1382 |
self mustRearrange |
|
1383 |
] |
|
388 | 1384 |
! ! |
1385 |
||
1386 |
!MenuPanel methodsFor:'accessing submenu'! |
|
1387 |
||
1388 |
subMenuAt:stringOrNumber |
|
1389 |
"gets the submenu of an item or nil |
|
1390 |
" |
|
1391 |
^ self itemAt:stringOrNumber do:[:el| el submenu ] |
|
1392 |
! |
|
1393 |
||
1394 |
subMenuAt:stringOrNumber put:aSubMenu |
|
1395 |
"sets the submenu of an item |
|
1396 |
" |
|
1397 |
self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ] |
|
1398 |
||
1399 |
! |
|
1400 |
||
1401 |
subMenuShown |
|
1402 |
"return the currently visible submenu - or nil if there is none |
|
1403 |
" |
|
1404 |
|item| |
|
1405 |
||
1406 |
(item := self selection) notNil ifTrue:[ |
|
1407 |
^ item submenu |
|
1408 |
]. |
|
1409 |
^ nil |
|
1410 |
! ! |
|
1411 |
||
1412 |
!MenuPanel methodsFor:'activation'! |
|
1413 |
||
1414 |
hide |
|
1415 |
"hide the view, leave its modal event loop |
|
1416 |
" |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1417 |
|
388 | 1418 |
self selection:nil. |
1419 |
self unmap. |
|
1420 |
||
1421 |
||
1422 |
! |
|
1423 |
||
1424 |
show |
|
1425 |
"realize the view at its last position |
|
1426 |
" |
|
1427 |
^ self showAt:(self origin) resizing:true |
|
1428 |
||
1429 |
! |
|
1430 |
||
1431 |
showAt:aPoint |
|
1432 |
"realize the view at aPoint |
|
1433 |
" |
|
1434 |
^ self showAt:aPoint resizing:true |
|
1435 |
||
1436 |
||
1437 |
! |
|
1438 |
||
1439 |
showAt:aPoint resizing:aBoolean |
|
1440 |
"realize the view at aPoint |
|
1441 |
" |
|
1442 |
self rearrangeItems. |
|
1443 |
||
1444 |
aBoolean ifTrue:[ |
|
1445 |
self fixSize. |
|
1446 |
]. |
|
1447 |
self origin:aPoint. |
|
1448 |
self makeFullyVisible. |
|
1449 |
self openModal:[true]. "realize " |
|
1450 |
||
389 | 1451 |
^ self lastValueAccepted |
388 | 1452 |
|
898 | 1453 |
"Modified: / 21.5.1998 / 14:18:58 / cg" |
388 | 1454 |
! |
1455 |
||
1456 |
showAtPointer |
|
1457 |
"realize the view at the current pointer position |
|
1458 |
" |
|
1459 |
^ self showAt:(device pointerPosition) resizing:true |
|
1460 |
||
1461 |
||
1462 |
! |
|
1463 |
||
1464 |
showCenteredIn:aView |
|
1465 |
"make myself visible at the screen center. |
|
1466 |
" |
|
1467 |
|top| |
|
1468 |
||
1469 |
top := aView topView. |
|
1470 |
top raise. |
|
1471 |
^ self showAt:(top origin + (aView originRelativeTo:top) + (aView extent // 2) - (self extent // 2)) |
|
1472 |
||
1473 |
||
1474 |
! |
|
1475 |
||
1476 |
startUp |
|
1477 |
"realize the menu at the current pointer position |
|
1478 |
" |
|
1479 |
^ self showAtPointer |
|
897
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1480 |
! |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1481 |
|
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1482 |
startUpAt:aPoint |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1483 |
"realize the menu at aPoint |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1484 |
" |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1485 |
^ self showAt:aPoint |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1486 |
|
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1487 |
"Created: / 21.5.1998 / 14:15:57 / cg" |
388 | 1488 |
! ! |
1489 |
||
434 | 1490 |
!MenuPanel methodsFor:'active help'! |
1491 |
||
1492 |
helpText |
|
1493 |
|appl item key| |
|
1494 |
||
1495 |
(item := self selection) notNil ifTrue:[ |
|
1496 |
(key := item activeHelpKey) notNil ifTrue:[ |
|
1497 |
(appl := self application) notNil ifTrue:[ |
|
1498 |
^ appl helpTextForKey:key |
|
1499 |
]. |
|
1500 |
] |
|
1501 |
]. |
|
1502 |
^ nil. |
|
1503 |
! ! |
|
1504 |
||
388 | 1505 |
!MenuPanel methodsFor:'adding & removing'! |
1506 |
||
1507 |
createAtIndex:anIndexOrNil |
|
1508 |
"create an item and add this item to the index. In case of nil the item |
|
1509 |
is added to the end. If the index is not valid nil is returned otherwise |
|
1510 |
the new created item. |
|
1511 |
" |
|
1512 |
|max item| |
|
1513 |
||
1514 |
max := (items size) + 1. |
|
1515 |
||
1516 |
anIndexOrNil notNil ifTrue:[ |
|
1517 |
(anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[ |
|
1518 |
^ nil |
|
1519 |
] |
|
1520 |
]. |
|
1521 |
items isNil ifTrue:[ |
|
1522 |
items := OrderedCollection new |
|
1523 |
]. |
|
1524 |
item := Item in:self. |
|
1525 |
||
1526 |
(anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[ |
|
1527 |
items add:item |
|
1528 |
] ifFalse:[ |
|
1529 |
items add:item beforeIndex:anIndexOrNil |
|
1530 |
]. |
|
1531 |
^ item |
|
1532 |
! |
|
1533 |
||
1534 |
remove:stringOrNumber |
|
1535 |
"remove the first item which is assigned to stringOrNumber; |
|
1536 |
if found, remove and return it |
|
1537 |
" |
|
1538 |
|item| |
|
1539 |
||
1540 |
(item := self itemAt:stringOrNumber) notNil ifTrue:[ |
|
1541 |
items remove:item. |
|
1542 |
item destroy. |
|
1543 |
items isEmpty ifTrue:[items := nil]. |
|
1544 |
self mustRearrange. |
|
1545 |
]. |
|
1546 |
^ item |
|
1547 |
! |
|
1548 |
||
1549 |
removeAll |
|
1550 |
"remove all items and submenus |
|
1551 |
" |
|
1552 |
self disabledRedrawDo:[ |
|
1553 |
self selection:nil. |
|
1554 |
groupSizes := nil. |
|
1555 |
self do:[:el| el destroy ]. |
|
1556 |
items := nil |
|
1557 |
]. |
|
1558 |
! ! |
|
1559 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1560 |
!MenuPanel methodsFor:'change & update'! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1561 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1562 |
update:something with:aParameter from:changedObject |
498 | 1563 |
|
1564 |
changedObject == menuHolder ifTrue:[^ self menu:(menuHolder value)]. |
|
1565 |
changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)]. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1566 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1567 |
super update:something with:aParameter from:changedObject |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1568 |
! ! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1569 |
|
388 | 1570 |
!MenuPanel methodsFor:'converting'! |
1571 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1572 |
asMenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1573 |
"convert contents to menu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1574 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1575 |
|menu| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1576 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1577 |
menu := Menu new. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1578 |
menu groupSizes:groupSizes. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1579 |
self do:[:anItem| menu addItem:(anItem asMenuItem) ]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1580 |
^ menu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1581 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1582 |
|
388 | 1583 |
fromSpec:aMenuSpec |
1584 |
"build from spec |
|
1585 |
" |
|
1586 |
|menu| |
|
1587 |
||
1588 |
menu := Menu new. |
|
1589 |
menu fromLiteralArrayEncoding:aMenuSpec. |
|
1590 |
self menu:menu |
|
1591 |
||
1592 |
! |
|
1593 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1594 |
menu:aMenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1595 |
"convert to Menu |
388 | 1596 |
" |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1597 |
|menu| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1598 |
|
388 | 1599 |
self disabledRedrawDo:[ |
1600 |
self removeAll. |
|
1601 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1602 |
(menu := aMenu) notNil ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1603 |
(aMenu isCollection) ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1604 |
menu := Menu new. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1605 |
menu fromLiteralArrayEncoding:aMenu. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1606 |
] ifFalse:[ |
524 | 1607 |
menu receiver notNil ifTrue:[receiver := menu receiver] |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1608 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1609 |
menu menuItems notNil ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1610 |
menu menuItems do:[:anItem| |
388 | 1611 |
(self createAtIndex:nil) menuItem:anItem |
1612 |
] |
|
1613 |
]. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1614 |
self groupSizes:(menu groupSizes). |
388 | 1615 |
] |
1616 |
] |
|
1617 |
||
1618 |
! ! |
|
1619 |
||
1620 |
!MenuPanel methodsFor:'drawing'! |
|
1621 |
||
1622 |
disabledRedrawDo:aBlock |
|
1623 |
"evaluate a block without redrawing within the block; after processing |
|
1624 |
of the block a redraw might be performed |
|
1625 |
" |
|
1626 |
|state| |
|
1627 |
||
1628 |
state := mustRearrange. |
|
1629 |
mustRearrange := true. |
|
1630 |
aBlock value. |
|
1631 |
mustRearrange := state. |
|
1632 |
self mustRearrange |
|
1633 |
! |
|
1634 |
||
616 | 1635 |
drawEdgesForX:x y:y width:w height:height isSelected:aBool |
1636 |
||
879 | 1637 |
|level| |
616 | 1638 |
|
1639 |
level := aBool ifTrue:[onLevel] ifFalse:[offLevel]. |
|
1640 |
||
1641 |
level ~~ 0 ifTrue:[ |
|
1642 |
self drawEdgesForX:x y:y width:w height:height level:level |
|
1643 |
]. |
|
1644 |
! |
|
1645 |
||
746 | 1646 |
drawEdgesInLayout: layout withLevel: aLevel |
1647 |
||
1648 |
self drawEdgesForX: layout left y: layout top width: layout width height: layout height level: aLevel |
|
1649 |
shadow: buttonShadowColor |
|
1650 |
light: buttonLightColor |
|
1651 |
halfShadow: buttonHalfShadowColor |
|
1652 |
halfLight: buttonHalfLightColor |
|
1653 |
style: ButtonEdgeStyle |
|
1654 |
! |
|
1655 |
||
388 | 1656 |
mustRearrange |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1657 |
"force rearrange (i.e. set the rearrange flag) |
388 | 1658 |
" |
590 | 1659 |
mustRearrange == true ifFalse:[ |
388 | 1660 |
mustRearrange := true. |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1661 |
shown ifTrue:[ |
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1662 |
self invalidate "/ RepairNow:true |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
1663 |
] |
388 | 1664 |
] |
590 | 1665 |
|
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1666 |
"Modified: / 6.6.1998 / 19:51:07 / cg" |
388 | 1667 |
! |
1668 |
||
710 | 1669 |
rearrangeGroups |
1670 |
|layout |
|
1671 |
dltX "{ Class:SmallInteger }" |
|
1672 |
start "{ Class:SmallInteger }" |
|
1673 |
| |
|
1674 |
||
1675 |
(self isPopUpView or:[self verticalLayout]) ifTrue:[ |
|
1676 |
^ self |
|
1677 |
]. |
|
1678 |
||
1679 |
layout := items last layout. |
|
1680 |
||
1681 |
(dltX := width - margin - 2 - layout right) <= 0 ifTrue:[ |
|
1682 |
^ self "/ no free space |
|
1683 |
]. |
|
1684 |
start := items findFirst:[:anItem| anItem startGroup == #right ]. |
|
1685 |
||
1686 |
start == 0 ifTrue:[ |
|
1687 |
^ self "/ no item detected |
|
1688 |
]. |
|
1689 |
||
1690 |
"/ change layout |
|
1691 |
||
1692 |
items from:start do:[:anItem| |
|
712 | 1693 |
anItem isVisible ifTrue:[ |
1694 |
layout := anItem layout. |
|
1695 |
layout left:(layout left + dltX). |
|
1696 |
layout right:(layout right + dltX). |
|
1697 |
] |
|
710 | 1698 |
]. |
1699 |
! |
|
1700 |
||
388 | 1701 |
rearrangeItems |
1702 |
"recompute layout of my items |
|
1703 |
" |
|
710 | 1704 |
|expLast e grpDivSz layout isVert |
1705 |
x "{ Class:SmallInteger }" |
|
1706 |
y "{ Class:SmallInteger }" |
|
1707 |
noItems "{ Class:SmallInteger }" |
|
1708 |
| |
|
390 | 1709 |
|
1710 |
mustRearrange ifFalse:[ ^ self ]. |
|
1711 |
||
1712 |
"/ fetch font from superMenu |
|
1713 |
(superMenu notNil and:[superMenu font ~~ font]) ifTrue:[ |
|
388 | 1714 |
super font:(superMenu font on:device) |
1715 |
]. |
|
710 | 1716 |
(noItems := items size) == 0 ifTrue:[ |
390 | 1717 |
mustRearrange := false. |
1718 |
^ self |
|
1719 |
]. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1720 |
expLast := false. |
616 | 1721 |
isVert := self verticalLayout. |
390 | 1722 |
|
1723 |
self hasGroupDividers ifTrue:[ |
|
1724 |
self isFitPanel ifFalse:[ |
|
616 | 1725 |
grpDivSz := groupDividerSize |
390 | 1726 |
] ifTrue:[ |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1727 |
expLast := true. |
390 | 1728 |
x := 0. |
1729 |
e := self computeExtent. |
|
388 | 1730 |
|
616 | 1731 |
isVert ifTrue:[ |
390 | 1732 |
items do:[:el|x := x + el preferredExtentY]. |
1733 |
y := e y. |
|
388 | 1734 |
] ifFalse:[ |
390 | 1735 |
items do:[:el|x := x + el preferredExtentX]. |
1736 |
y := e x. |
|
388 | 1737 |
]. |
710 | 1738 |
x := x + (noItems + 1 * itemSpace). |
616 | 1739 |
|
390 | 1740 |
(grpDivSz := (y - x) // (groupSizes size)) <= 0 ifTrue:[ |
1741 |
grpDivSz := nil |
|
388 | 1742 |
] |
1743 |
] |
|
1744 |
]. |
|
390 | 1745 |
|
1746 |
(self isPopUpView or:[explicitExtent ~~ true]) ifTrue:[ |
|
1747 |
e := self preferredExtent. |
|
1748 |
||
1749 |
self isPopUpView ifFalse:[ |
|
616 | 1750 |
isVert ifTrue:[e y:1.0] |
1751 |
ifFalse:[e x:1.0] |
|
390 | 1752 |
]. |
1753 |
self extent:e |
|
1754 |
] ifFalse:[ |
|
1755 |
e := self computeExtent |
|
1756 |
]. |
|
616 | 1757 |
x := y := 0. |
1758 |
||
1759 |
isVert ifTrue:[y := itemSpace] |
|
1760 |
ifFalse:[x := itemSpace]. |
|
390 | 1761 |
|
1762 |
self keysAndValuesDo:[:anIndex :el||org| |
|
1763 |
org := Point x:x y:y. |
|
712 | 1764 |
el isVisible ifTrue:[ |
1765 |
isVert ifTrue:[ |
|
1766 |
y := y + el preferredExtentY. |
|
1767 |
el layout:(Rectangle origin:org corner:(e x @ y)). |
|
1768 |
y := y + itemSpace. |
|
1769 |
] ifFalse:[ |
|
1770 |
x := x + el preferredExtentX. |
|
1771 |
el layout:(Rectangle origin:org corner:(x @ e y)). |
|
1772 |
x := x + itemSpace. |
|
1773 |
]. |
|
1774 |
||
1775 |
(grpDivSz notNil and:[self hasGroupDividerAt:anIndex]) ifTrue:[ |
|
1776 |
isVert ifTrue:[y := y + grpDivSz] |
|
1777 |
ifFalse:[x := x + grpDivSz] |
|
1778 |
] |
|
390 | 1779 |
] ifFalse:[ |
712 | 1780 |
el layout:(Rectangle origin:org corner:org) |
390 | 1781 |
] |
1782 |
]. |
|
710 | 1783 |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1784 |
expLast ifTrue:[ |
712 | 1785 |
e := items last. |
1786 |
||
1787 |
e isVisible ifTrue:[ |
|
1788 |
layout := items last layout. |
|
1789 |
||
1790 |
isVert ifTrue:[layout bottom:((self extent y) + 1)] |
|
1791 |
ifFalse:[layout right:((self extent x) + 1)]. |
|
1792 |
] |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1793 |
]. |
710 | 1794 |
self rearrangeGroups. |
388 | 1795 |
mustRearrange := false. |
1796 |
||
1797 |
||
1798 |
||
1799 |
||
1800 |
||
1801 |
! |
|
1802 |
||
1803 |
redrawX:x y:y width:w height:h |
|
1804 |
"redraw a rectangle |
|
1805 |
" |
|
650 | 1806 |
|start end isVrt x1 x2 y1 y2 item layout lnSz hrzInset prevClipArea| |
388 | 1807 |
|
710 | 1808 |
(shown and:[w ~~ 0]) ifFalse:[^ self]. |
388 | 1809 |
|
1810 |
self paint:(self backgroundColor). |
|
1811 |
self clearRectangleX:x y:y width:w height:h. |
|
1812 |
||
1813 |
isVrt := self verticalLayout. |
|
1814 |
end := items size. |
|
1815 |
||
1816 |
mustRearrange ifTrue:[ |
|
389 | 1817 |
self isPopUpView not ifTrue:[ |
1818 |
explicitExtent := true |
|
1819 |
]. |
|
388 | 1820 |
self rearrangeItems. |
1821 |
start := 1 |
|
1822 |
] ifFalse:[ |
|
1823 |
end == 0 ifTrue:[ ^ self ]. |
|
1824 |
||
1825 |
isVrt ifTrue:[ |
|
1826 |
start := self findFirst:[:el| (el layout bottom) >= y ]. |
|
1827 |
start == 0 ifTrue:[ ^ self ]. |
|
1828 |
end := y + h. |
|
1829 |
end := self findLast:[:el| (el layout top) < end ]. |
|
1830 |
] ifFalse:[ |
|
1831 |
start := self findFirst:[:el| (el layout right) >= x ]. |
|
1832 |
start == 0 ifTrue:[ ^ self ]. |
|
1833 |
end := x + w. |
|
1834 |
end := self findLast:[:el| (el layout left) < end ]. |
|
1835 |
]. |
|
1836 |
||
390 | 1837 |
(start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[ |
388 | 1838 |
start := start - 1 |
1839 |
] |
|
1840 |
]. |
|
1841 |
||
390 | 1842 |
( self hasGroupDividers |
1843 |
and:[self showGroupDivider |
|
1844 |
and:[self isFitPanel not]] |
|
1845 |
) ifTrue:[ |
|
616 | 1846 |
lnSz := groupDividerSize // 2 |
390 | 1847 |
]. |
650 | 1848 |
end == 0 ifTrue:[^ self ]. |
1849 |
||
1850 |
hrzInset := items first horizontalInset. |
|
1851 |
||
1852 |
prevClipArea := clipRect. |
|
1853 |
clipRect := nil. |
|
1854 |
||
1855 |
device setClipX:x y:y width:w height:h in:drawableId gc:gcId. |
|
1856 |
||
388 | 1857 |
|
1858 |
start to:end do:[:i| |
|
1859 |
item := items at:i. |
|
1860 |
item redraw. |
|
1861 |
||
390 | 1862 |
(lnSz notNil and:[self hasGroupDividerAt:i]) ifTrue:[ |
388 | 1863 |
layout := item layout. |
1864 |
||
1865 |
isVrt ifTrue:[ |
|
433 | 1866 |
x1 := layout left + hrzInset. |
1867 |
x2 := layout right - hrzInset. |
|
388 | 1868 |
y1 := (layout bottom) + lnSz. |
1869 |
y2 := y1. |
|
1870 |
] ifFalse:[ |
|
1871 |
x1 := (layout right) + lnSz. |
|
1872 |
x2 := x1. |
|
1873 |
y1 := layout top. |
|
1874 |
y2 := layout bottom. |
|
1875 |
]. |
|
1876 |
self paint:(self shadowColor). |
|
1877 |
self displayLineFromX:x1 y:y1 toX:x2 y:y2. |
|
1878 |
self paint:(self lightColor). |
|
1879 |
||
1880 |
isVrt ifTrue:[y1 := y1 + 1. y2 := y1 ] |
|
1881 |
ifFalse:[x1 := x1 + 1. x2 := x1 ]. |
|
1882 |
||
1883 |
self displayLineFromX:x1 y:y1 toX:x2 y:y2 |
|
1884 |
] |
|
650 | 1885 |
]. |
1886 |
||
1887 |
clipRect := nil. |
|
1888 |
prevClipArea isNil ifTrue:[device noClipIn:drawableId gc:gcId] |
|
1889 |
ifFalse:[self clippingRectangle:prevClipArea]. |
|
1890 |
||
388 | 1891 |
|
1892 |
||
1893 |
! ! |
|
1894 |
||
1895 |
!MenuPanel methodsFor:'enumerting & searching'! |
|
1896 |
||
1897 |
collect:aOneArgBlock |
|
1898 |
"evaluate the argument, aOneArgBlock for every item in the menuPanel |
|
1899 |
and return a collection of the results |
|
1900 |
" |
|
1901 |
items notNil ifTrue:[^ items collect:aOneArgBlock ]. |
|
1902 |
^ nil |
|
1903 |
||
1904 |
! |
|
1905 |
||
1906 |
do:aOneArgBlock |
|
1907 |
"evaluate the argument, aOneArgBlock for every item in the menuPanel. |
|
1908 |
" |
|
1909 |
items notNil ifTrue:[ items do:aOneArgBlock ]. |
|
1910 |
||
1911 |
! |
|
1912 |
||
1913 |
findFirst:aOneArgBlock |
|
1914 |
"find the first item, for which evaluation of the argument, aOneArgBlock |
|
1915 |
returns true; return its index or 0 if none detected. |
|
1916 |
" |
|
1917 |
items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ]. |
|
1918 |
^ 0 |
|
1919 |
||
1920 |
! |
|
1921 |
||
1922 |
findLast:aOneArgBlock |
|
1923 |
"find the last item, for which evaluation of the argument, aOneArgBlock |
|
1924 |
returns true; return its index or 0 if none detected. |
|
1925 |
" |
|
1926 |
items notNil ifTrue:[ ^ items findLast:aOneArgBlock ]. |
|
1927 |
^ 0 |
|
1928 |
||
1929 |
! |
|
1930 |
||
390 | 1931 |
indexOf:something |
1932 |
"returns index of an item assigned to an index, nameKey, textLabel or value if symbol. |
|
1933 |
If no item match 0 is returned. No range checks are performed on a number argument |
|
388 | 1934 |
" |
390 | 1935 |
|i v| |
1936 |
||
1937 |
something isNumber ifTrue:[ ^ something ]. |
|
1938 |
something isNil ifTrue:[ ^ 0 ]. |
|
1939 |
||
650 | 1940 |
i := self findFirst:[:el|(el nameKey = something) or: [el = something]]. |
390 | 1941 |
|
1942 |
i ~~ 0 ifTrue:[ |
|
1943 |
^ i |
|
388 | 1944 |
]. |
390 | 1945 |
|
1946 |
something isSymbol ifTrue:[ |
|
1947 |
i := self findFirst:[:el| |
|
1948 |
v := el value. |
|
1949 |
v isSymbol and:[v == something] |
|
1950 |
]. |
|
1951 |
i ~~ 0 ifTrue:[ |
|
1952 |
^ i |
|
1953 |
] |
|
1954 |
]. |
|
1955 |
||
1956 |
(something respondsTo:#string) ifTrue:[ |
|
1957 |
v := something string. |
|
1958 |
^ self findFirst:[:el|el textLabel = v]. |
|
1959 |
]. |
|
1960 |
^ 0 |
|
388 | 1961 |
! |
1962 |
||
706 | 1963 |
indexOfItem:anItem |
1964 |
"returns the index of the item or 0 |
|
1965 |
" |
|
1966 |
^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0] |
|
1967 |
! |
|
1968 |
||
388 | 1969 |
keysAndValuesDo:aTwoArgBlock |
1970 |
"evaluate the argument, aTwoArgBlock for every item in the menuPanel. |
|
1971 |
" |
|
1972 |
items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ]. |
|
1973 |
||
1974 |
! ! |
|
1975 |
||
1976 |
!MenuPanel methodsFor:'event handling'! |
|
1977 |
||
1978 |
buttonMotion:state x:x y:y |
|
1979 |
"open or close the corresponding submenus |
|
1980 |
" |
|
816 | 1981 |
|menu point sensor sel| |
388 | 1982 |
|
1983 |
( (sensor := self sensor) notNil |
|
1984 |
and:[sensor hasButtonMotionEventFor:nil] |
|
1985 |
) ifTrue:[ |
|
1986 |
^ self |
|
1987 |
]. |
|
1988 |
||
878
67cfbc05069d
care to allow press-motion over spacing (see colorMenu)
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1989 |
"/ lastButtonSelected notNil ifTrue:[ |
67cfbc05069d
care to allow press-motion over spacing (see colorMenu)
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1990 |
"/ ^ self |
67cfbc05069d
care to allow press-motion over spacing (see colorMenu)
Claus Gittinger <cg@exept.de>
parents:
829
diff
changeset
|
1991 |
"/ ]. |
816 | 1992 |
|
388 | 1993 |
(self containsPointX:x y:y) ifTrue:[ |
816 | 1994 |
((sel := self itemAtX:x y:y) notNil and:[sel isButton and:[superMenu isNil]]) ifTrue:[ |
1995 |
sel canSelect ifTrue:[ |
|
1996 |
lastButtonSelected := sel |
|
1997 |
] |
|
1998 |
]. |
|
1999 |
^ self selection:sel |
|
388 | 2000 |
]. |
736 | 2001 |
|
388 | 2002 |
menu := self superMenuAtX:x y:y. |
2003 |
||
2004 |
menu isNil ifTrue:[ |
|
736 | 2005 |
^ self selection:nil |
388 | 2006 |
]. |
2007 |
point := self translatePoint:(x@y) to:menu. |
|
2008 |
menu selection:(menu itemAtX:(point x) y:(point y)) |
|
2009 |
! |
|
2010 |
||
2011 |
buttonPress:button x:x y:y |
|
2012 |
"any button pressed; open or close the corresponding submenus |
|
2013 |
" |
|
2014 |
|menu point item| |
|
2015 |
||
2016 |
menu := self superMenuAtX:x y:y. |
|
2017 |
||
2018 |
menu isNil ifTrue:[ |
|
2019 |
menu := self topMenu. |
|
2020 |
] ifFalse:[ |
|
2021 |
point := self translatePoint:(x@y) to:menu. |
|
2022 |
item := menu itemAtX:(point x) y:(point y) |
|
2023 |
]. |
|
2024 |
menu selection:item |
|
2025 |
! |
|
2026 |
||
2027 |
buttonRelease:button x:x y:y |
|
2028 |
"button release action; accept selection and close all views |
|
2029 |
" |
|
816 | 2030 |
|menu item| |
687 | 2031 |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2032 |
menu := self topMenu activeMenu. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2033 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2034 |
( menu hasSelection |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2035 |
or:[menu isPopUpView not |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2036 |
or:[(OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue) |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2037 |
and:(menu mapTime)) > 200]] |
388 | 2038 |
) ifTrue:[ |
816 | 2039 |
item := nil. |
2040 |
||
2041 |
( (menu := self superMenuAtX:x y:y) notNil |
|
2042 |
and:[(item := menu selection) notNil |
|
2043 |
and:[item submenu notNil]] |
|
2044 |
) ifTrue:[ |
|
2045 |
menu selection:nil |
|
2046 |
] ifFalse:[ |
|
2047 |
( lastButtonSelected isNil |
|
2048 |
or:[item isNil |
|
2049 |
or:[(menu itemAtX:x y:y) == lastButtonSelected]] |
|
2050 |
) ifFalse:[ |
|
2051 |
item := nil |
|
2052 |
]. |
|
2053 |
self topMenu accept:item |
|
2054 |
] |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2055 |
]. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2056 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2057 |
"Modified: / 27.2.1998 / 17:41:23 / cg" |
388 | 2058 |
! |
2059 |
||
2060 |
cursorPressed:aKey |
|
2061 |
"handle a cursor key |
|
2062 |
" |
|
687 | 2063 |
|next submenu item |
2064 |
n "{ Class:SmallInteger }" |
|
2065 |
idx "{ Class:SmallInteger }" |
|
2066 |
first "{ Class:SmallInteger }" |
|
2067 |
| |
|
388 | 2068 |
(self hasSelection not and:[superMenu notNil]) ifTrue:[ |
2069 |
^ superMenu cursorPressed:aKey |
|
2070 |
]. |
|
2071 |
||
2072 |
self verticalLayout ifTrue:[ |
|
2073 |
aKey == #CursorLeft ifTrue:[^ self selection:nil]. |
|
2074 |
aKey ~~ #CursorRight ifTrue:[next := aKey == #CursorDown]. |
|
2075 |
] ifFalse:[ |
|
2076 |
aKey == #CursorUp ifTrue:[^ self selection:nil]. |
|
2077 |
aKey ~~ #CursorDown ifTrue:[next := aKey == #CursorRight]. |
|
2078 |
]. |
|
2079 |
||
2080 |
next isNil ifTrue:[ |
|
2081 |
(item := self selection) notNil ifTrue:[ |
|
2082 |
(submenu := item submenu) notNil ifTrue:[ |
|
2083 |
idx := submenu findFirst:[:el| el canSelect ]. |
|
2084 |
^ submenu selectionIndex:idx |
|
2085 |
]. |
|
2086 |
^ self selection:nil |
|
2087 |
]. |
|
2088 |
^ self |
|
2089 |
]. |
|
2090 |
first := self findFirst:[:el| el canSelect ]. |
|
2091 |
first == 0 ifTrue:[^ self]. |
|
2092 |
||
2093 |
idx := self selectionIndex. |
|
687 | 2094 |
n := 1 + (self sensor compressKeyPressEventsWithKey:aKey). |
2095 |
||
2096 |
n timesRepeat:[ |
|
2097 |
next ifTrue:[ |
|
2098 |
[((idx := idx + 1) <= items size and:[(items at:idx) canSelect not]) |
|
2099 |
] whileTrue. |
|
2100 |
||
2101 |
idx > items size ifTrue:[ |
|
2102 |
idx := first |
|
2103 |
]. |
|
2104 |
] ifFalse:[ |
|
2105 |
[((idx := idx - 1) > 0 and:[(items at:idx) canSelect not]) |
|
2106 |
] whileTrue. |
|
2107 |
||
2108 |
idx < 1 ifTrue:[ idx := self findLast:[:el| el canSelect ] ] |
|
2109 |
] |
|
388 | 2110 |
]. |
2111 |
self selectionIndex:idx |
|
2112 |
! |
|
2113 |
||
2114 |
keyPress:key x:x y:y |
|
2115 |
"any key is pressed |
|
2116 |
" |
|
389 | 2117 |
|listOfItems item menu idx cIdx upperKey lowerKey| |
388 | 2118 |
|
2119 |
menu := self. |
|
2120 |
||
2121 |
[ menu shown ] whileFalse:[ |
|
2122 |
(menu := superMenu) isNil ifTrue:[^ self] |
|
2123 |
]. |
|
2124 |
||
2125 |
key == #Return ifTrue:[ |
|
2126 |
^ menu accept |
|
2127 |
]. |
|
2128 |
||
2129 |
( key == #CursorDown or:[key == #CursorUp |
|
2130 |
or:[key == #CursorLeft or:[key == #CursorRight]]] |
|
2131 |
) ifTrue:[ |
|
2132 |
^ menu cursorPressed:key |
|
2133 |
]. |
|
2134 |
||
2135 |
listOfItems := self selectItemsForShortcutKey:key. |
|
2136 |
listOfItems notNil ifTrue:[ |
|
2137 |
item := listOfItems first. |
|
2138 |
||
2139 |
item hasSubmenu ifFalse:[ |
|
441 | 2140 |
^ menu accept:item |
389 | 2141 |
]. |
2142 |
^ self openMenusFromItems:listOfItems |
|
388 | 2143 |
]. |
2144 |
||
2145 |
(self hasSelection not and:[superMenu notNil]) ifTrue:[ |
|
2146 |
(superMenu containsPoint:(self translatePoint:(x@y) to:superMenu)) ifTrue:[ |
|
2147 |
menu := superMenu |
|
2148 |
] |
|
2149 |
]. |
|
2150 |
||
2151 |
cIdx := menu selectionIndex. |
|
2152 |
cIdx isNil ifTrue:[cIdx := 0]. |
|
2153 |
||
389 | 2154 |
upperKey := key asUppercase. |
2155 |
lowerKey := key asLowercase. |
|
2156 |
||
388 | 2157 |
menu keysAndValuesDo:[:anIndex :el| |c l| |
390 | 2158 |
(el canSelect and:[(l := el textLabel) notNil]) ifTrue:[ |
388 | 2159 |
l size ~~ 0 ifTrue:[ |
2160 |
(c := el accessCharacter) notNil ifTrue:[ |
|
389 | 2161 |
(c == upperKey or:[c == lowerKey]) ifTrue:[ |
388 | 2162 |
^ menu selection:el |
2163 |
] |
|
2164 |
] ifFalse:[ |
|
389 | 2165 |
((c := l first) == upperKey or:[c == lowerKey]) ifTrue:[ |
388 | 2166 |
anIndex > cIdx ifTrue:[ |
2167 |
^ menu selection:el |
|
2168 |
] ifFalse:[ |
|
2169 |
idx isNil ifTrue:[ |
|
2170 |
idx := anIndex |
|
2171 |
] ifFalse:[ |
|
2172 |
anIndex > idx ifTrue:[ |
|
2173 |
anIndex ~~ cIdx ifTrue:[ |
|
2174 |
idx := anIndex |
|
2175 |
] |
|
2176 |
] |
|
2177 |
] |
|
2178 |
] |
|
2179 |
||
2180 |
] |
|
2181 |
] |
|
2182 |
] |
|
2183 |
] |
|
2184 |
]. |
|
417 | 2185 |
(item := menu itemAt:idx) isNil ifTrue:[ |
2186 |
menu hasSelection ifFalse:[ |
|
2187 |
(menu := menu superMenu) isNil ifTrue:[ |
|
2188 |
^ super keyPress:key x:x y:y |
|
2189 |
] |
|
2190 |
] |
|
2191 |
]. |
|
2192 |
menu selection:item. |
|
388 | 2193 |
|
390 | 2194 |
! |
2195 |
||
2196 |
sizeChanged:how |
|
2197 |
self isFitPanel ifTrue:[ |
|
2198 |
self mustRearrange. |
|
2199 |
]. |
|
2200 |
super sizeChanged:how |
|
388 | 2201 |
! ! |
2202 |
||
2203 |
!MenuPanel methodsFor:'grabbing'! |
|
2204 |
||
420 | 2205 |
forceUngrabMouseAndKeyboard |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2206 |
"ungrab resources (mouse and keyboard) |
420 | 2207 |
" |
2208 |
|sensor| |
|
2209 |
||
2210 |
device ungrabPointer. |
|
2211 |
||
2212 |
(sensor := self sensor) notNil ifTrue:[ |
|
2213 |
"/ make certain all X events have been received |
|
2214 |
device sync. |
|
2215 |
"/ now all events have been received. |
|
2216 |
"/ now, flush all pointer events |
|
2217 |
sensor flushKeyboardFor:nil |
|
2218 |
]. |
|
2219 |
device ungrabKeyboard. |
|
2220 |
||
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2221 |
"Modified: / 2.2.1998 / 09:24:48 / stefan" |
420 | 2222 |
! |
2223 |
||
388 | 2224 |
grabMouseAndKeyboard |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2225 |
"get exclusive access to pointer and keyboard. |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2226 |
Only used for popUp menus." |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2227 |
|
388 | 2228 |
|sensor| |
2229 |
||
2230 |
realized ifTrue:[ |
|
2231 |
sensor := self sensor. |
|
2232 |
||
2233 |
device activePointerGrab ~~ self ifTrue:[ |
|
2234 |
sensor notNil ifTrue:[ |
|
2235 |
sensor flushMotionEventsFor:nil. |
|
2236 |
]. |
|
2237 |
||
2238 |
(device grabPointerInView:self) ifFalse:[ |
|
2239 |
Delay waitForSeconds:0.1. |
|
2240 |
(device grabPointerInView:self) ifFalse:[ |
|
2241 |
"give up" |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2242 |
'MenuPanel [warning]: could not grab pointer' errorPrintCR. |
388 | 2243 |
self unmap |
2244 |
] |
|
2245 |
] |
|
2246 |
]. |
|
2247 |
||
2248 |
device activeKeyboardGrab ~~ self ifTrue:[ |
|
2249 |
sensor notNil ifTrue:[ |
|
2250 |
device sync. |
|
2251 |
sensor flushKeyboardFor:nil |
|
2252 |
]. |
|
2253 |
device grabKeyboardInView:self. |
|
687 | 2254 |
|
498 | 2255 |
superMenu notNil ifTrue:[ |
2256 |
self getKeyboardFocus |
|
2257 |
] |
|
388 | 2258 |
] |
2259 |
] |
|
2260 |
||
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2261 |
"Modified: / 2.2.1998 / 23:43:59 / stefan" |
388 | 2262 |
! |
2263 |
||
2264 |
ungrabMouseAndKeyboard |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2265 |
"ungrab resources (mouse and keyboard) |
388 | 2266 |
" |
2267 |
|sensor| |
|
2268 |
||
2269 |
device activePointerGrab == self ifTrue:[ |
|
2270 |
device ungrabPointer. |
|
2271 |
]. |
|
2272 |
device activeKeyboardGrab == self ifTrue:[ |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2273 |
sensor := self sensor. |
680 | 2274 |
sensor notNil ifTrue:[ |
388 | 2275 |
"/ make certain all X events have been received |
2276 |
device sync. |
|
2277 |
"/ now all events have been received. |
|
2278 |
"/ now, flush all pointer events |
|
2279 |
sensor flushKeyboardFor:self |
|
2280 |
]. |
|
2281 |
device ungrabKeyboard. |
|
2282 |
]. |
|
687 | 2283 |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2284 |
"Modified: / 2.2.1998 / 10:27:12 / stefan" |
388 | 2285 |
! ! |
2286 |
||
794 | 2287 |
!MenuPanel methodsFor:'image registration'! |
2288 |
||
2289 |
imageOnDevice:anImage |
|
2290 |
"returns image registered on device |
|
2291 |
" |
|
2292 |
^ self class image:anImage onDevice:device |
|
2293 |
! |
|
2294 |
||
2295 |
lightenedImageOnDevice:anImage |
|
2296 |
"returns lightened image registered on device |
|
2297 |
" |
|
2298 |
^ self class lightenedImage:anImage onDevice:device |
|
2299 |
! ! |
|
2300 |
||
388 | 2301 |
!MenuPanel methodsFor:'initialize / release'! |
2302 |
||
767
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
2303 |
addToCurrentProject |
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
2304 |
"ignored here" |
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
2305 |
|
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
2306 |
^self |
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
2307 |
! |
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
2308 |
|
388 | 2309 |
create |
616 | 2310 |
"create the shadow view for a none contained submenu |
388 | 2311 |
" |
436 | 2312 |
|
388 | 2313 |
super create. |
2314 |
||
2315 |
self isPopUpView ifTrue:[ |
|
680 | 2316 |
(PopUpView styleSheet at:'popup.shadow' default:false) ifTrue:[ |
2317 |
shadowView isNil ifTrue:[ |
|
2318 |
shadowView := (ShadowView onDevice:device) for:self |
|
736 | 2319 |
] ifFalse:[ |
2320 |
self saveUnder:true. |
|
2321 |
]. |
|
388 | 2322 |
] |
2323 |
] ifFalse:[ |
|
2324 |
explicitExtent == true ifTrue:[ |
|
2325 |
(self extent x) == (superView extent x) ifTrue:[ |
|
2326 |
self verticalLayout:false |
|
2327 |
] |
|
2328 |
] |
|
2329 |
] |
|
2330 |
! |
|
2331 |
||
2332 |
destroy |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2333 |
"destroy items and shadowView; remove dependencies |
388 | 2334 |
" |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2335 |
self clearLastActiveMenu. |
388 | 2336 |
self do:[:el|el destroy]. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2337 |
|
498 | 2338 |
menuHolder notNil ifTrue:[menuHolder removeDependent:self]. |
2339 |
enableChannel notNil ifTrue:[enableChannel removeDependent:self]. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2340 |
|
388 | 2341 |
super destroy. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2342 |
superMenu := nil. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2343 |
items := nil. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2344 |
shadowView notNil ifTrue:[shadowView destroy]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2345 |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2346 |
"Modified: / 27.2.1998 / 17:41:25 / cg" |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2347 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2348 |
|
616 | 2349 |
fetchDeviceResources |
2350 |
"fetch device colors, to avoid reallocation at redraw time" |
|
2351 |
||
2352 |
|style| |
|
2353 |
||
2354 |
super fetchDeviceResources. |
|
2355 |
||
2356 |
superMenu isNil ifTrue:[ |
|
730 | 2357 |
fgColor := DefaultForegroundColor onDevice:device. |
2358 |
activeBgColor := DefaultHilightBackgroundColor onDevice:device. |
|
2359 |
activeFgColor := DefaultHilightForegroundColor onDevice:device. |
|
2360 |
disabledFgColor := DefaultDisabledForegroundColor onDevice:device. |
|
2361 |
rightArrow := RightArrowForm onDevice:device. |
|
2362 |
selectionFrameBrightColor := SelectionFrameBrightColor onDevice:device. |
|
2363 |
selectionFrameDarkColor := SelectionFrameDarkColor onDevice:device. |
|
2364 |
buttonLightColor := ButtonLightColor onDevice:device. |
|
2365 |
buttonShadowColor := ButtonShadowColor onDevice:device. |
|
2366 |
ButtonHalfLightColor notNil ifTrue: [ |
|
2367 |
buttonHalfLightColor := ButtonHalfLightColor onDevice:device]. |
|
2368 |
ButtonHalfShadowColor notNil ifTrue: [ |
|
2369 |
buttonHalfShadowColor := ButtonHalfShadowColor onDevice:device]. |
|
616 | 2370 |
|
2371 |
(rightArrowShadow := RightArrowShadowForm) notNil ifTrue:[ |
|
2372 |
rightArrowShadow := rightArrowShadow onDevice:device |
|
2373 |
] |
|
2374 |
] ifFalse:[ |
|
730 | 2375 |
fgColor := superMenu foregroundColor. |
2376 |
activeBgColor := superMenu activeBackgroundColor. |
|
2377 |
activeFgColor := superMenu activeForegroundColor. |
|
2378 |
disabledFgColor := superMenu disabledForegroundColor. |
|
2379 |
rightArrow := superMenu rightArrow. |
|
2380 |
rightArrowShadow := superMenu rightArrowShadow. |
|
2381 |
selectionFrameBrightColor := superMenu selectionFrameBrightColor. |
|
2382 |
selectionFrameDarkColor := superMenu selectionFrameDarkColor. |
|
2383 |
buttonLightColor := superMenu buttonLightColor. |
|
2384 |
buttonShadowColor := superMenu buttonShadowColor. |
|
2385 |
buttonHalfLightColor := superMenu buttonHalfLightColor. |
|
2386 |
buttonHalfShadowColor := superMenu buttonHalfShadowColor. |
|
616 | 2387 |
]. |
2388 |
style := styleSheet name. |
|
2389 |
||
2390 |
self isPopUpView ifFalse:[ |
|
2391 |
(style == #motif or:[style == #iris]) ifTrue:[ |
|
650 | 2392 |
self topView == self superView ifTrue:[ |
2393 |
self level:2 |
|
2394 |
] |
|
616 | 2395 |
] |
2396 |
] ifTrue:[ |
|
2397 |
style == #next ifTrue:[ |
|
2398 |
onLevel := offLevel := 0 |
|
2399 |
] ifFalse:[ |
|
2400 |
style == #openwin ifTrue:[ |
|
2401 |
offLevel := 0. |
|
2402 |
] |
|
2403 |
] |
|
2404 |
]. |
|
2405 |
||
2406 |
||
2407 |
! |
|
2408 |
||
580 | 2409 |
initStyle |
2410 |
"initialize style specific stuff" |
|
2411 |
||
2412 |
super initStyle. |
|
616 | 2413 |
|
2414 |
onLevel := DefaultHilightLevel. |
|
2415 |
offLevel := DefaultLevel. |
|
2416 |
itemSpace := DefaultItemSpace. |
|
2417 |
||
2418 |
groupDividerSize := DefaultGroupDividerSize. |
|
2419 |
fitFirstPanel := DefaultFitFirstPanel. |
|
580 | 2420 |
! |
2421 |
||
388 | 2422 |
initialize |
2423 |
"set default configuration |
|
2424 |
" |
|
616 | 2425 |
|style| |
2426 |
||
388 | 2427 |
super initialize. |
616 | 2428 |
style := styleSheet name. |
2429 |
||
2430 |
(style ~~ #normal and:[style ~~ #mswindows]) ifTrue:[ |
|
2431 |
borderWidth := 1. |
|
2432 |
]. |
|
2433 |
level := 1. |
|
2434 |
style == #st80 ifTrue:[ |
|
2435 |
level := 0 |
|
2436 |
]. |
|
2437 |
||
498 | 2438 |
enabled := true. |
388 | 2439 |
self origin:0.0@0.0. |
2440 |
originChanged := extentChanged := false. |
|
2441 |
explicitExtent := nil. |
|
2442 |
shortKeyInset := 0. |
|
2443 |
mustRearrange := false. |
|
616 | 2444 |
|
829 | 2445 |
font := MenuView defaultFont. |
2446 |
||
2447 |
||
388 | 2448 |
! |
2449 |
||
2450 |
mapped |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2451 |
"grab the pointer here, when visible (but not if control has already been lost). |
388 | 2452 |
If the grab fails, try again and unmap myself if that fails too. |
2453 |
" |
|
2454 |
|anItemList| |
|
2455 |
||
687 | 2456 |
self do:[:anItem| anItem fetchImages ]. |
816 | 2457 |
lastButtonSelected := nil. |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2458 |
self becomesActiveMenu. |
388 | 2459 |
super mapped. |
2460 |
||
2461 |
anItemList := InitialSelectionQuerySignal raise. |
|
2462 |
||
2463 |
self isPopUpView ifTrue:[ |
|
2464 |
self grabMouseAndKeyboard |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2465 |
] ifFalse:[ |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2466 |
super viewBackground:(self backgroundColor). |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2467 |
]. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2468 |
self do:[:el| el updateIndicators ]. |
388 | 2469 |
|
2470 |
anItemList size > 0 ifTrue:[ |
|
2471 |
self redrawX:0 y:0 width:10000 height:10000. |
|
2472 |
self openMenusFromItems:anItemList. |
|
2473 |
]. |
|
2474 |
||
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2475 |
"Modified: / 2.2.1998 / 09:27:21 / stefan" |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2476 |
"Modified: / 27.2.1998 / 17:41:25 / cg" |
388 | 2477 |
! |
2478 |
||
2479 |
realize |
|
2480 |
"realize menu and shadowView |
|
2481 |
" |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2482 |
|
388 | 2483 |
self isPopUpView ifTrue:[ |
736 | 2484 |
"Because of #saveUnder of ShadowView the order of realize is significant: |
2485 |
shadowView must be realized before self" |
|
2486 |
self hiddenOnRealize:true. |
|
2487 |
super realize. |
|
436 | 2488 |
self resize. |
680 | 2489 |
shadowView notNil ifTrue:[ |
2490 |
shadowView realize. |
|
390 | 2491 |
]. |
736 | 2492 |
super map. |
680 | 2493 |
self raise. |
736 | 2494 |
] ifFalse:[ |
2495 |
super realize. |
|
2496 |
] |
|
388 | 2497 |
! |
2498 |
||
2499 |
recreate |
|
2500 |
"this is called after a snapin. If the image was saved with an active menu, |
|
2501 |
hide the menu |
|
2502 |
" |
|
2503 |
self selection:nil. |
|
2504 |
super recreate. |
|
2505 |
||
2506 |
! |
|
2507 |
||
2508 |
unmap |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2509 |
"unmap view. If we have a popup supermenu, it will get all keyboard and |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2510 |
mouse events. |
388 | 2511 |
" |
736 | 2512 |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2513 |
self clearLastActiveMenu. |
879 | 2514 |
|
736 | 2515 |
"/ |
2516 |
"/ Kludge for X11: after grabbing and ungrabbing other views may get buttonMotionEvents |
|
2517 |
"/ when a mouse button is still pressed. To avoid this we grab the mouse for the superview. |
|
2518 |
"/ (Move from upperMenuPanel of NewLauncher to lowerMenuPanel) |
|
2519 |
"/ |
|
2520 |
(superMenu notNil and:[superMenu shown and:[superMenu isPopUpView |
|
2521 |
or:[superMenu sensor anyButtonPressed]]]) ifTrue:[ |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2522 |
superMenu grabMouseAndKeyboard |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2523 |
] ifFalse:[ |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2524 |
self ungrabMouseAndKeyboard. |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2525 |
]. |
388 | 2526 |
super unmap. |
2527 |
shadowView notNil ifTrue:[shadowView unmap]. |
|
2528 |
||
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2529 |
"Modified: / 2.2.1998 / 10:27:06 / stefan" |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2530 |
"Modified: / 27.2.1998 / 17:41:24 / cg" |
388 | 2531 |
! ! |
2532 |
||
2533 |
!MenuPanel methodsFor:'misc'! |
|
2534 |
||
427
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
2535 |
raiseDeiconified |
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
2536 |
^ self raise |
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
2537 |
|
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
2538 |
"Created: 21.6.1997 / 13:29:12 / cg" |
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
2539 |
! |
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
2540 |
|
388 | 2541 |
superMenu |
2542 |
"returns supermenu or nil |
|
2543 |
" |
|
2544 |
^ superMenu |
|
2545 |
||
2546 |
||
2547 |
! |
|
2548 |
||
2549 |
superMenu:aSuperMenu |
|
2550 |
"set the supermenu starting from |
|
2551 |
" |
|
2552 |
superMenu := aSuperMenu. |
|
2553 |
! |
|
2554 |
||
2555 |
topMenu |
|
2556 |
"returns the topMenu; the one having no superMenu |
|
2557 |
" |
|
2558 |
|top| |
|
2559 |
||
2560 |
top := self. |
|
2561 |
||
2562 |
[ top superMenu notNil ] whileTrue:[ |
|
2563 |
top := top superMenu |
|
2564 |
]. |
|
2565 |
^ top |
|
2566 |
||
2567 |
||
2568 |
! ! |
|
2569 |
||
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2570 |
!MenuPanel methodsFor:'printing'! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2571 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2572 |
printString |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2573 |
"return a printed representation of the menu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2574 |
" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2575 |
|string label| |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2576 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2577 |
string := 'Menu:'. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2578 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2579 |
self do:[:anItem| |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2580 |
label := anItem label ? ''. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2581 |
string := string ,' ', label printString. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2582 |
]. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2583 |
^ string |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2584 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2585 |
"Modified: / 27.2.1998 / 17:41:22 / cg" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2586 |
! ! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2587 |
|
388 | 2588 |
!MenuPanel methodsFor:'private'! |
2589 |
||
434 | 2590 |
application |
2591 |
|appl| |
|
2592 |
||
2593 |
superMenu notNil ifTrue:[ |
|
2594 |
^ superMenu application |
|
2595 |
]. |
|
2596 |
(appl := super application) isNil ifTrue:[ |
|
464 | 2597 |
windowGroup notNil ifTrue:[ |
2598 |
appl := windowGroup mainGroup topViews first application |
|
2599 |
] |
|
434 | 2600 |
]. |
2601 |
^ appl |
|
2602 |
! |
|
2603 |
||
390 | 2604 |
menuAdornmentAt:aSymbol |
388 | 2605 |
"returns a value derived from adornment |
2606 |
" |
|
390 | 2607 |
|adm| |
2608 |
||
2609 |
adm := adornment ? DefaultAdornment. |
|
2610 |
^ adm at:aSymbol ifAbsent:nil |
|
388 | 2611 |
! |
2612 |
||
390 | 2613 |
menuAdornmentAt:aSymbol put:something |
653 | 2614 |
"sets a value for the specific menu; if the value differs to the |
2615 |
current stored value, true is returned otherwise false |
|
388 | 2616 |
" |
653 | 2617 |
(self menuAdornmentAt:aSymbol) == something ifTrue:[ |
2618 |
^ false |
|
2619 |
]. |
|
2620 |
adornment isNil ifTrue:[ |
|
2621 |
adornment := DefaultAdornment copy |
|
2622 |
]. |
|
2623 |
adornment at:aSymbol put:something. |
|
2624 |
^ true |
|
388 | 2625 |
! |
2626 |
||
2627 |
onEachPerform:aSelector withArgList:aList |
|
2628 |
"on each item perform selector with an argument derived from aList |
|
2629 |
" |
|
2630 |
aList isCollection ifTrue:[ |
|
2631 |
items size >= aList size ifTrue:[ |
|
2632 |
aList keysAndValuesDo:[:anIndex :anArg| |
|
2633 |
(items at:anIndex) perform:aSelector with:anArg |
|
2634 |
] |
|
2635 |
] |
|
2636 |
] ifFalse:[ |
|
2637 |
self do:[:anItem| anItem perform:aSelector with:aList ] |
|
2638 |
] |
|
2639 |
||
2640 |
||
2641 |
! |
|
2642 |
||
2643 |
openMenusFromItems:anItemList |
|
2644 |
"open all menus derived from sequence of items |
|
2645 |
" |
|
2646 |
|item| |
|
2647 |
||
2648 |
(anItemList isNil or:[anItemList isEmpty]) ifTrue:[ |
|
2649 |
^ self |
|
2650 |
]. |
|
2651 |
item := anItemList removeLast. |
|
2652 |
||
2653 |
item enabled ifFalse:[ |
|
2654 |
^ self |
|
2655 |
]. |
|
2656 |
||
2657 |
InitialSelectionQuerySignal answer:anItemList do:[ |
|
2658 |
self selection:item |
|
2659 |
] |
|
2660 |
! |
|
2661 |
||
2662 |
selectItemsForShortcutKey:aKey |
|
2663 |
"get sequence of items up to the item providing the key (inclusive). The |
|
2664 |
first entry into the collection is the item providing the key, the last |
|
2665 |
entry is the item in the topMenu( reverse ) |
|
2666 |
" |
|
2667 |
|seq| |
|
2668 |
||
2669 |
self do:[:anItem| |
|
2670 |
anItem isEnabled ifTrue:[ |
|
2671 |
anItem shortcutKey = aKey ifTrue:[ |
|
2672 |
seq := OrderedCollection new. |
|
2673 |
] ifFalse:[ |
|
2674 |
anItem hasSubmenu ifTrue:[ |
|
2675 |
seq := anItem submenu selectItemsForShortcutKey:aKey |
|
2676 |
] |
|
2677 |
]. |
|
2678 |
seq notNil ifTrue:[ |
|
2679 |
seq add:anItem. |
|
2680 |
^ seq |
|
2681 |
] |
|
2682 |
] |
|
2683 |
]. |
|
2684 |
^ nil |
|
2685 |
||
2686 |
! |
|
2687 |
||
2688 |
translatePoint:aPoint to:aView |
|
2689 |
"translate a point into a views point; in case of no view nil is returned |
|
2690 |
" |
|
2691 |
aView notNil ifTrue:[ |
|
2692 |
aView == self ifTrue:[^ aPoint]. |
|
2693 |
^ device translatePoint:aPoint from:(self id) to:(aView id) |
|
2694 |
]. |
|
2695 |
^ nil |
|
2696 |
||
2697 |
! ! |
|
2698 |
||
687 | 2699 |
!MenuPanel methodsFor:'private activation'! |
2700 |
||
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2701 |
activeMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2702 |
"returns the current active menu or self (the top menu) |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2703 |
" |
687 | 2704 |
^ lastActiveMenu ? self |
2705 |
||
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2706 |
"Created: / 27.2.1998 / 17:41:15 / cg" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2707 |
! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2708 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2709 |
activeMenu:aMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2710 |
"set the current active menu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2711 |
" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2712 |
lastActiveMenu := aMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2713 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2714 |
"Created: / 27.2.1998 / 17:41:16 / cg" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2715 |
! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2716 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2717 |
becomesActiveMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2718 |
"submenu becomes the active menu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2719 |
" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2720 |
mapTime := Time millisecondClockValue. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2721 |
self topMenu activeMenu:self. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2722 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2723 |
"Created: / 27.2.1998 / 17:41:23 / cg" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2724 |
! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2725 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2726 |
clearLastActiveMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2727 |
"reset the current active menu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2728 |
" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2729 |
|top| |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2730 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2731 |
top := self topMenu. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2732 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2733 |
top activeMenu == self ifTrue:[ |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2734 |
top activeMenu:nil |
687 | 2735 |
] |
2736 |
||
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2737 |
"Created: / 27.2.1998 / 17:41:17 / cg" |
687 | 2738 |
! |
2739 |
||
2740 |
mapTime |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2741 |
"returns the time when the menu becomes active |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2742 |
" |
687 | 2743 |
^ mapTime |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2744 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
2745 |
"Modified: / 27.2.1998 / 17:41:18 / cg" |
687 | 2746 |
! ! |
2747 |
||
388 | 2748 |
!MenuPanel methodsFor:'private searching'! |
2749 |
||
2750 |
itemAtX:x y:y |
|
2751 |
"returns item at a point or nil |
|
2752 |
" |
|
2753 |
self do:[:el| (el containsPointX:x y:y) ifTrue:[^el] ]. |
|
2754 |
^ nil |
|
2755 |
! |
|
2756 |
||
2757 |
superMenuAtX:x y:y |
|
2758 |
"returns supermenu at a point or nil |
|
2759 |
" |
|
2760 |
|menu| |
|
2761 |
||
2762 |
(self containsPointX:x y:y) ifTrue:[^ self]. |
|
2763 |
menu := self. |
|
2764 |
||
2765 |
[ (menu := menu superMenu) notNil ] whileTrue:[ |
|
2766 |
(menu containsPoint:(self translatePoint:(x@y) to:menu)) ifTrue:[ |
|
2767 |
^ menu |
|
2768 |
] |
|
2769 |
]. |
|
2770 |
^ nil |
|
2771 |
! ! |
|
2772 |
||
2773 |
!MenuPanel methodsFor:'queries'! |
|
2774 |
||
2775 |
canDrawItem |
|
2776 |
"returns true if an item could be drawn otherwise false |
|
2777 |
" |
|
710 | 2778 |
^ (mustRearrange not and:[shown]) |
388 | 2779 |
! |
2780 |
||
2781 |
containsPoint:aPoint |
|
2782 |
"returns true if point is contained by the view |
|
2783 |
" |
|
2784 |
^ self containsPointX:(aPoint x) y:(aPoint y) |
|
2785 |
! |
|
2786 |
||
2787 |
containsPointX:x y:y |
|
2788 |
"returns true if point is contained by the view |
|
2789 |
" |
|
708 | 2790 |
^ (x between:0 and:width) and:[y between:0 and:height] |
879 | 2791 |
|
2792 |
"/ |ext| |
|
2793 |
"/ |
|
708 | 2794 |
"/ (x >= 0 and:[y >= 0]) ifTrue:[ |
2795 |
"/ ext := self computeExtent. |
|
2796 |
"/ ^ (x < ext x and:[y < ext y]) |
|
2797 |
"/ ]. |
|
2798 |
"/ ^ false |
|
2799 |
||
2800 |
"Modified: / 29.1.1998 / 16:46:10 / cg" |
|
388 | 2801 |
! |
2802 |
||
390 | 2803 |
hasGroupDividerAt:anIndex |
388 | 2804 |
"returns true if a divider is defined at an index |
2805 |
" |
|
2806 |
|i| |
|
2807 |
||
2808 |
groupSizes size ~~ 0 ifTrue:[ |
|
2809 |
i := 0. |
|
2810 |
||
2811 |
groupSizes do:[:t| |
|
2812 |
(i := i + t) == anIndex ifTrue:[ |
|
2813 |
^ true |
|
2814 |
] |
|
2815 |
] |
|
2816 |
]. |
|
2817 |
^ false |
|
2818 |
||
2819 |
! |
|
2820 |
||
390 | 2821 |
hasGroupDividers |
2822 |
"returns true if any group divider exists |
|
2823 |
" |
|
2824 |
^ (items size ~~ 0 and:[groupSizes size ~~ 0]) |
|
2825 |
! |
|
2826 |
||
388 | 2827 |
isEnabled |
2828 |
"returns enabled state of menu and items |
|
2829 |
" |
|
2830 |
^ self enabled |
|
2831 |
! |
|
2832 |
||
390 | 2833 |
isFitPanel |
2834 |
"returns true if the panel is the first in the menu hierarchy in must |
|
2835 |
be fit to the extent of its superView |
|
2836 |
" |
|
616 | 2837 |
^ self isPopUpView ifTrue:[false] ifFalse:[fitFirstPanel] |
390 | 2838 |
! |
2839 |
||
388 | 2840 |
isPopUpView |
2841 |
"return true if view is a popup view; without decoration |
|
2842 |
and popUp to top immediately |
|
2843 |
" |
|
2844 |
^ superView isNil |
|
2845 |
||
2846 |
||
2847 |
! |
|
2848 |
||
2849 |
isVerticalLayout |
|
2850 |
"returns true if vertical layout otherwise false( horizontal layout ) |
|
2851 |
" |
|
2852 |
^ self verticalLayout |
|
2853 |
||
2854 |
||
416 | 2855 |
! |
2856 |
||
2857 |
type |
|
428 | 2858 |
^ nil. |
416 | 2859 |
|
388 | 2860 |
! ! |
2861 |
||
2862 |
!MenuPanel methodsFor:'selection'! |
|
2863 |
||
2864 |
hasSelection |
|
2865 |
"returns true if a selection exists |
|
2866 |
" |
|
2867 |
^ self selection notNil |
|
2868 |
! |
|
2869 |
||
2870 |
isValidSelection:something |
|
2871 |
"returns true if something could be selected |
|
2872 |
" |
|
2873 |
|item| |
|
2874 |
||
498 | 2875 |
enabled ifTrue:[ |
2876 |
(item := self itemAt:something) notNil ifTrue:[ |
|
2877 |
^ item canSelect |
|
2878 |
] |
|
388 | 2879 |
]. |
2880 |
^ false |
|
2881 |
! |
|
2882 |
||
2883 |
selection |
|
2884 |
"returns current selected item or nil |
|
2885 |
" |
|
2886 |
^ selection |
|
2887 |
||
2888 |
||
2889 |
! |
|
2890 |
||
2891 |
selection:anItemOrNil |
|
2892 |
"change selection to an item |
|
2893 |
" |
|
434 | 2894 |
|item newSel hlp| |
388 | 2895 |
|
2896 |
selection isNumber ifTrue:[ |
|
2897 |
newSel := self itemAt:anItemOrNil |
|
2898 |
] ifFalse:[ |
|
2899 |
(anItemOrNil notNil and:[anItemOrNil canSelect]) ifTrue:[ |
|
2900 |
newSel := anItemOrNil |
|
2901 |
] |
|
2902 |
]. |
|
2903 |
||
2904 |
selection == newSel ifTrue:[^ self]. |
|
2905 |
||
2906 |
(item := selection) notNil ifTrue:[ |
|
2907 |
selection := nil. |
|
2908 |
item selected:false. |
|
2909 |
]. |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2910 |
newSel notNil ifTrue:[ |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2911 |
selection := newSel. |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2912 |
|
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2913 |
ActiveHelp isActive ifTrue:[ |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2914 |
hlp := ActiveHelp currentHelpListener. |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2915 |
hlp initiateHelpFor:self atX:1 y:1 now:true. |
388 | 2916 |
]. |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2917 |
selection selected:true. |
388 | 2918 |
]. |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2919 |
|
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
2920 |
"Modified: / 2.2.1998 / 10:13:46 / stefan" |
388 | 2921 |
! |
2922 |
||
2923 |
selectionIndex |
|
2924 |
"returns index of current selection or 0 |
|
2925 |
" |
|
2926 |
|item| |
|
2927 |
||
2928 |
(item := self selection) notNil ifTrue:[ |
|
2929 |
^ self findFirst:[:el| el == item ] |
|
2930 |
]. |
|
2931 |
^ 0 |
|
2932 |
||
2933 |
! |
|
2934 |
||
2935 |
selectionIndex:anIndex |
|
2936 |
"set selection at an index |
|
2937 |
" |
|
2938 |
self selection:(self itemAt:anIndex) |
|
2939 |
! ! |
|
2940 |
||
2941 |
!MenuPanel::Item class methodsFor:'accessing'! |
|
2942 |
||
689 | 2943 |
horizontalInset |
2944 |
^ HorizontalInset |
|
2945 |
! |
|
2946 |
||
388 | 2947 |
labelRightOffset |
2948 |
^ LabelRightOffset |
|
2949 |
! |
|
2950 |
||
2951 |
shortcutKeyOffset |
|
2952 |
^ ShortcutKeyOffset |
|
689 | 2953 |
! |
2954 |
||
2955 |
verticalInset |
|
2956 |
^ VerticalInset |
|
388 | 2957 |
! ! |
2958 |
||
616 | 2959 |
!MenuPanel::Item class methodsFor:'defaults'! |
2960 |
||
2961 |
separatorSize:aType |
|
2962 |
"returns size of a separator |
|
2963 |
" |
|
2964 |
aType == #doubleLine ifTrue:[^ 10 ]. |
|
2965 |
aType == #singleLine ifTrue:[^ 10 ]. |
|
706 | 2966 |
^ 10 |
616 | 2967 |
! |
2968 |
||
2969 |
updateStyleCache |
|
388 | 2970 |
"setup defaults |
650 | 2971 |
self updateStyleCache |
388 | 2972 |
" |
681 | 2973 |
HorizontalInset := 4. |
2974 |
VerticalInset := 3. |
|
727 | 2975 |
|
2976 |
HorizontalButtonInset := 3. |
|
2977 |
VerticalButtonInset := 3. |
|
2978 |
||
681 | 2979 |
LabelRightOffset := 15. |
2980 |
ShortcutKeyOffset := 5. |
|
388 | 2981 |
|
657 | 2982 |
IndicatorOn := MenuPanel checkedImage. |
2983 |
IndicatorOff := MenuPanel uncheckedImage. |
|
388 | 2984 |
! ! |
2985 |
||
2986 |
!MenuPanel::Item class methodsFor:'instance creation'! |
|
2987 |
||
2988 |
in:aSuperMenu |
|
2989 |
^ self in:aSuperMenu label:nil |
|
2990 |
! |
|
2991 |
||
2992 |
in:aSuperMenu label:aLabel |
|
2993 |
|item| |
|
2994 |
||
2995 |
item := self new in:aSuperMenu. |
|
2996 |
item label:aLabel. |
|
2997 |
^ item |
|
2998 |
! |
|
2999 |
||
3000 |
in:aSuperMenu menuItem:aMenuItem |
|
3001 |
|item| |
|
3002 |
||
3003 |
item := self in:aSuperMenu. |
|
3004 |
item menuItem:aMenuItem. |
|
3005 |
^ item. |
|
3006 |
! ! |
|
3007 |
||
389 | 3008 |
!MenuPanel::Item methodsFor:'accept'! |
3009 |
||
420 | 3010 |
canAccept |
3011 |
"returns true if item is acceptable |
|
3012 |
" |
|
3013 |
^ (self enabled and:[self hasSubmenu not]) |
|
524 | 3014 |
! |
3015 |
||
3016 |
toggleIndication |
|
3017 |
"toggle indication |
|
3018 |
" |
|
3019 |
|arg| |
|
3020 |
||
723 | 3021 |
self hasIndication ifTrue:[ |
524 | 3022 |
arg := self indicationValue not. |
3023 |
self indicationValue:arg. |
|
3024 |
]. |
|
3025 |
^ arg |
|
389 | 3026 |
! ! |
3027 |
||
388 | 3028 |
!MenuPanel::Item methodsFor:'accessing'! |
3029 |
||
3030 |
accessCharacter |
|
389 | 3031 |
"returns my accessCharacter or nil |
388 | 3032 |
" |
389 | 3033 |
accessCharacterPosition isNil ifTrue:[ |
3034 |
^ nil |
|
388 | 3035 |
]. |
389 | 3036 |
^ (rawLabel string) at:accessCharacterPosition |
388 | 3037 |
! |
3038 |
||
3039 |
accessCharacterPosition |
|
390 | 3040 |
"get the access character position or nil |
388 | 3041 |
" |
389 | 3042 |
^ accessCharacterPosition |
388 | 3043 |
! |
3044 |
||
3045 |
accessCharacterPosition:anIndex |
|
390 | 3046 |
"set the access character position or nil |
388 | 3047 |
" |
475 | 3048 |
|lbl| |
390 | 3049 |
|
3050 |
( (accessCharacterPosition ~~ anIndex) |
|
3051 |
and:[(lbl := self textLabel) notNil] |
|
389 | 3052 |
) ifTrue:[ |
390 | 3053 |
anIndex notNil ifTrue:[ |
3054 |
(anIndex < 1 or:[anIndex > lbl size]) ifTrue:[ |
|
3055 |
^ self |
|
3056 |
]. |
|
389 | 3057 |
]. |
390 | 3058 |
accessCharacterPosition := anIndex. |
388 | 3059 |
self updateRawLabel. |
3060 |
]. |
|
3061 |
! |
|
3062 |
||
434 | 3063 |
activeHelpKey |
3064 |
^ activeHelpKey |
|
3065 |
! |
|
3066 |
||
3067 |
activeHelpKey:aHelpKey |
|
3068 |
activeHelpKey := aHelpKey |
|
3069 |
! |
|
3070 |
||
388 | 3071 |
argument |
3072 |
"gets the argument |
|
3073 |
" |
|
3074 |
adornment isNil ifTrue:[^ nil ]. |
|
3075 |
^ adornment argument |
|
3076 |
! |
|
3077 |
||
3078 |
argument:anArgument |
|
3079 |
"sets the argument |
|
3080 |
" |
|
3081 |
self argument ~~ anArgument ifTrue:[ |
|
3082 |
self adornment argument:anArgument. |
|
3083 |
] |
|
3084 |
! |
|
3085 |
||
389 | 3086 |
compareAccessCharacterWith:aKey |
3087 |
"returns true if key is my access character |
|
3088 |
" |
|
3089 |
|s| |
|
3090 |
||
3091 |
accessCharacterPosition notNil ifTrue:[ |
|
3092 |
s := (rawLabel string) at:accessCharacterPosition. |
|
3093 |
s == aKey ifTrue:[^ true ]. |
|
3094 |
]. |
|
3095 |
^ false |
|
3096 |
! |
|
3097 |
||
388 | 3098 |
label |
3099 |
"returns the label |
|
3100 |
" |
|
3101 |
^ label |
|
3102 |
! |
|
3103 |
||
3104 |
label:aLabel |
|
399 | 3105 |
"set a new label; if the label changed, a redraw is performed; |
3106 |
handle characters $& (ST-80 compatibility) |
|
388 | 3107 |
" |
475 | 3108 |
|i rest s| |
389 | 3109 |
|
3110 |
accessCharacterPosition := nil. |
|
399 | 3111 |
label := aLabel value. |
3112 |
||
3113 |
(label isString and:[(s := label size) > 1]) ifTrue:[ |
|
3114 |
i := 1. |
|
3115 |
||
3116 |
[((i := label indexOf:$& startingAt:i) ~~ 0 and:[i < s])] whileTrue:[ |
|
3117 |
rest := label copyFrom:(i+1). |
|
3118 |
||
3119 |
i == 1 ifTrue:[label := rest] |
|
3120 |
ifFalse:[label := (label copyFrom:1 to:(i-1)), rest]. |
|
3121 |
||
3122 |
(label at:i) == $& ifTrue:[i := i + 1] |
|
3123 |
ifFalse:[accessCharacterPosition := i]. |
|
3124 |
s := s - 1. |
|
389 | 3125 |
] |
3126 |
]. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3127 |
|
399 | 3128 |
self updateRawLabel |
388 | 3129 |
! |
3130 |
||
3131 |
menuPanel |
|
3132 |
"returns my menuPanel |
|
3133 |
" |
|
399 | 3134 |
^ menuPanel |
388 | 3135 |
! |
3136 |
||
3137 |
nameKey |
|
3138 |
"gets the nameKey |
|
3139 |
" |
|
3140 |
^ nameKey |
|
3141 |
! |
|
3142 |
||
3143 |
nameKey:aNameKey |
|
3144 |
"sets the nameKey |
|
3145 |
" |
|
3146 |
nameKey := aNameKey. |
|
3147 |
! |
|
3148 |
||
3149 |
rawLabel |
|
390 | 3150 |
"returns my printable Label |
388 | 3151 |
" |
3152 |
^ rawLabel |
|
3153 |
! |
|
3154 |
||
3155 |
shortcutKey |
|
3156 |
"get the key to press to select the submenu from the keyboard or if |
|
3157 |
no submenu exists evaluate the action assigned to the item (accept). |
|
3158 |
" |
|
3159 |
adornment isNil ifTrue:[^ nil ]. |
|
3160 |
^ adornment shortcutKey |
|
3161 |
! |
|
3162 |
||
3163 |
shortcutKey:aKey |
|
3164 |
"set the key to press to select the submenu from the keyboard or if |
|
3165 |
no submenu exists evaluate the action assigned to the item (accept). |
|
3166 |
" |
|
3167 |
self shortcutKey ~~ aKey ifTrue:[ |
|
3168 |
self adornment shortcutKey:aKey. |
|
3169 |
self redraw. |
|
3170 |
]. |
|
3171 |
! |
|
3172 |
||
710 | 3173 |
startGroup |
3174 |
"start group #left #right #center ... or nil |
|
3175 |
at the moment only #right is implemented |
|
3176 |
" |
|
3177 |
^ startGroup |
|
3178 |
! |
|
3179 |
||
3180 |
startGroup:aSymbol |
|
3181 |
"start group #left #right #center ... |
|
3182 |
at the moment only #right is implemented |
|
3183 |
" |
|
3184 |
(startGroup isNil or:[startGroup == #right]) ifTrue:[ |
|
3185 |
startGroup := aSymbol |
|
3186 |
] ifFalse:[ |
|
3187 |
self warn:('not supported group: ', aSymbol printString ). |
|
3188 |
] |
|
3189 |
||
3190 |
! |
|
3191 |
||
388 | 3192 |
submenu |
3193 |
"returns my submenu or nil |
|
3194 |
" |
|
464 | 3195 |
subMenu notNil ifTrue:[^ subMenu]. |
3196 |
^ self setupSubmenu |
|
388 | 3197 |
! |
3198 |
||
3199 |
submenu:aSubMenu |
|
3200 |
"set a new submenu; an existing submenu will be destroyed. This might lead |
|
3201 |
to a redraw if 'hasSubmenu' changed |
|
3202 |
" |
|
580 | 3203 |
|
3204 |
(aSubMenu notNil |
|
3205 |
and:[(aSubMenu isView or:[aSubMenu isKindOf:Menu]) not]) ifTrue:[ |
|
3206 |
^ self submenuChannel:aSubMenu |
|
388 | 3207 |
]. |
3208 |
||
3209 |
(subMenu := aSubMenu) notNil ifTrue:[ |
|
3210 |
aSubMenu class == Menu ifTrue:[ |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3211 |
subMenu := menuPanel class subMenu:aSubMenu |
388 | 3212 |
]. |
580 | 3213 |
(subMenu notNil and:[subMenu isView]) ifTrue:[ |
3214 |
subMenu superMenu:menuPanel |
|
3215 |
] |
|
388 | 3216 |
]. |
3217 |
||
580 | 3218 |
"Modified: / 27.10.1997 / 04:43:43 / cg" |
389 | 3219 |
! |
3220 |
||
390 | 3221 |
textLabel |
3222 |
"returns my textLabel or nil if none text |
|
3223 |
" |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3224 |
(rawLabel respondsTo:#string) ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3225 |
^ rawLabel string |
390 | 3226 |
]. |
3227 |
^ nil |
|
3228 |
! |
|
3229 |
||
389 | 3230 |
value |
3231 |
"gets value |
|
3232 |
" |
|
3233 |
^ value |
|
3234 |
! |
|
3235 |
||
3236 |
value:something |
|
3237 |
"could be a value holder, an action or selector |
|
3238 |
" |
|
3239 |
value := something. |
|
502 | 3240 |
! |
3241 |
||
3242 |
value:aValue argument:anArgument |
|
3243 |
"set the value and an argument |
|
3244 |
" |
|
3245 |
self value:aValue. |
|
3246 |
self argument:anArgument. |
|
388 | 3247 |
! ! |
3248 |
||
3249 |
!MenuPanel::Item methodsFor:'accessing behavior'! |
|
3250 |
||
3251 |
enabled |
|
3252 |
"returns the enabled state |
|
3253 |
" |
|
524 | 3254 |
|state| |
3255 |
||
3256 |
menuPanel enabled ifTrue:[ |
|
3257 |
enableChannel isSymbol ifTrue:[ |
|
3258 |
state := self aspectAt:enableChannel. |
|
3259 |
||
3260 |
(self isKindOfValueHolder:state) ifTrue:[ |
|
3261 |
enableChannel := state. |
|
3262 |
enableChannel addDependent:self. |
|
3263 |
state := enableChannel value. |
|
3264 |
] |
|
465 | 3265 |
] ifFalse:[ |
524 | 3266 |
state := enableChannel value |
465 | 3267 |
]. |
524 | 3268 |
^ state ~~ false |
460 | 3269 |
]. |
524 | 3270 |
^ false |
388 | 3271 |
! |
3272 |
||
389 | 3273 |
enabled:something |
388 | 3274 |
"change the enabled state; if the state changed, a redraw is performed |
3275 |
" |
|
390 | 3276 |
|oldState newState| |
3277 |
||
3278 |
enableChannel isNil ifTrue:[ |
|
3279 |
oldState := true |
|
3280 |
] ifFalse:[ |
|
3281 |
oldState := enableChannel value. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3282 |
(self isKindOfValueHolder:enableChannel) ifTrue:[ |
390 | 3283 |
enableChannel removeDependent:self |
3284 |
] |
|
388 | 3285 |
]. |
390 | 3286 |
enableChannel := something. |
3287 |
||
3288 |
enableChannel isNil ifTrue:[ |
|
580 | 3289 |
menuPanel shown ifFalse:[^ self]. |
390 | 3290 |
newState := true |
3291 |
] ifFalse:[ |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3292 |
(self isKindOfValueHolder:enableChannel) ifTrue:[ |
390 | 3293 |
enableChannel addDependent:self |
460 | 3294 |
] ifFalse:[ |
464 | 3295 |
enableChannel isSymbol ifTrue:[^ self] |
390 | 3296 |
]. |
580 | 3297 |
menuPanel shown ifFalse:[^ self]. |
390 | 3298 |
newState := enableChannel value. |
3299 |
]. |
|
3300 |
||
3301 |
newState ~~ oldState ifTrue:[ |
|
498 | 3302 |
(rawLabel notNil and:[menuPanel canDrawItem]) ifTrue:[ |
3303 |
self drawLabel |
|
3304 |
] |
|
390 | 3305 |
] |
388 | 3306 |
|
580 | 3307 |
"Modified: / 27.10.1997 / 16:13:42 / cg" |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3308 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3309 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3310 |
indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3311 |
"get on/off indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3312 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3313 |
adornment isNil ifTrue:[^ nil]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3314 |
^ adornment indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3315 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3316 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3317 |
indication:something |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3318 |
"set on/off indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3319 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3320 |
|old| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3321 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3322 |
old := self indication. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3323 |
old == something ifTrue:[^ self]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3324 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3325 |
(self isKindOfValueHolder:old) ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3326 |
old removeDependent:self |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3327 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3328 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3329 |
(self isKindOfValueHolder:something) ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3330 |
something addDependent:self |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3331 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3332 |
self adornment indication:something. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3333 |
self updateRawLabel. |
464 | 3334 |
! |
3335 |
||
650 | 3336 |
isButton |
3337 |
"returns whether item looks like a Button |
|
3338 |
" |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3339 |
isButton isNil ifTrue:[ |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3340 |
isButton := false |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3341 |
]. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3342 |
^ isButton |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3343 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3344 |
"Modified: / 27.2.1998 / 17:41:28 / cg" |
650 | 3345 |
! |
3346 |
||
3347 |
isButton:anBoolean |
|
3348 |
"sets whether item looks like a Button |
|
3349 |
" |
|
3350 |
isButton := anBoolean. |
|
3351 |
||
3352 |
layout notNil ifTrue: [self redrawAsButton] |
|
3353 |
||
3354 |
||
3355 |
||
3356 |
! |
|
3357 |
||
464 | 3358 |
setupSubmenu |
663 | 3359 |
|appl recv subm| |
464 | 3360 |
|
3361 |
submenuChannel notNil ifTrue:[ |
|
3362 |
submenuChannel isSymbol ifFalse:[ |
|
3363 |
subm := submenuChannel |
|
3364 |
] ifTrue:[ |
|
3365 |
appl := menuPanel application. |
|
663 | 3366 |
|
3367 |
(subm := self findSubMenuIn:appl) isNil ifTrue:[ |
|
3368 |
(recv := menuPanel receiver) ~~ appl ifTrue:[ |
|
3369 |
subm := self findSubMenuIn:recv |
|
658 | 3370 |
] |
661 | 3371 |
] |
464 | 3372 |
]. |
661 | 3373 |
|
464 | 3374 |
(subm := subm value) isArray ifTrue:[ |
3375 |
subm := Menu new fromLiteralArrayEncoding:subm. |
|
709
4fbc1048fe05
linked menus may also contain label translations ...
Claus Gittinger <cg@exept.de>
parents:
708
diff
changeset
|
3376 |
"/ cg: linked menus also may contain translations ... |
4fbc1048fe05
linked menus may also contain label translations ...
Claus Gittinger <cg@exept.de>
parents:
708
diff
changeset
|
3377 |
subm notNil ifTrue:[ |
4fbc1048fe05
linked menus may also contain label translations ...
Claus Gittinger <cg@exept.de>
parents:
708
diff
changeset
|
3378 |
appl notNil ifTrue:[ |
4fbc1048fe05
linked menus may also contain label translations ...
Claus Gittinger <cg@exept.de>
parents:
708
diff
changeset
|
3379 |
subm findGuiResourcesIn:appl. |
4fbc1048fe05
linked menus may also contain label translations ...
Claus Gittinger <cg@exept.de>
parents:
708
diff
changeset
|
3380 |
] |
4fbc1048fe05
linked menus may also contain label translations ...
Claus Gittinger <cg@exept.de>
parents:
708
diff
changeset
|
3381 |
]. |
464 | 3382 |
]. |
3383 |
self submenu:subm. |
|
3384 |
]. |
|
829 | 3385 |
|
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
3386 |
^ subMenu |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
3387 |
|
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
3388 |
"Modified: / 19.5.1998 / 19:36:56 / cg" |
464 | 3389 |
! |
3390 |
||
3391 |
submenuChannel |
|
3392 |
"get the submenu channel |
|
3393 |
" |
|
3394 |
^ submenuChannel |
|
3395 |
! |
|
3396 |
||
3397 |
submenuChannel:aSelectorOrNil |
|
3398 |
"returns the submenu channel |
|
3399 |
" |
|
3400 |
submenuChannel := aSelectorOrNil. |
|
388 | 3401 |
! ! |
3402 |
||
3403 |
!MenuPanel::Item methodsFor:'accessing dimension'! |
|
3404 |
||
3405 |
height |
|
3406 |
"gets height |
|
3407 |
" |
|
3408 |
layout isNil ifTrue:[ |
|
3409 |
^ self preferredExtentY |
|
3410 |
]. |
|
3411 |
^ layout height |
|
3412 |
! |
|
3413 |
||
650 | 3414 |
horizontalInset |
3415 |
||
727 | 3416 |
self isButton ifTrue: [^menuPanel buttonPassiveLevel + HorizontalButtonInset]. |
650 | 3417 |
^HorizontalInset |
3418 |
! |
|
3419 |
||
388 | 3420 |
layout |
3421 |
"returns my layout ( Rectangle ) |
|
3422 |
" |
|
3423 |
^ layout |
|
3424 |
! |
|
3425 |
||
3426 |
layout:aLayout |
|
3427 |
"set a new layout ( Rectangle ) |
|
3428 |
" |
|
3429 |
layout := aLayout. |
|
3430 |
self redraw. |
|
3431 |
! |
|
3432 |
||
3433 |
preferredExtentX |
|
3434 |
"compute my preferred extent x |
|
3435 |
" |
|
616 | 3436 |
|x s isVertical| |
388 | 3437 |
|
712 | 3438 |
self isVisible ifFalse:[^ 0]. |
3439 |
||
650 | 3440 |
x := self horizontalInset * 2. |
616 | 3441 |
isVertical := menuPanel verticalLayout. |
3442 |
||
3443 |
self isSeparator ifFalse:[ |
|
388 | 3444 |
x := x + (rawLabel widthOn:menuPanel). |
3445 |
||
3446 |
(s := self shortcutKeyAsString) notNil ifTrue:[ |
|
3447 |
x := x + LabelRightOffset + (s widthOn:menuPanel) |
|
3448 |
]. |
|
638 | 3449 |
(isVertical and:[self hasSubmenu or:[submenuChannel notNil]]) ifTrue:[ |
616 | 3450 |
x := x + menuPanel subMenuIndicationWidth. |
3451 |
||
3452 |
s notNil ifTrue:[x := x + ShortcutKeyOffset] |
|
3453 |
ifFalse:[x := x + LabelRightOffset] |
|
464 | 3454 |
]. |
616 | 3455 |
^ x |
3456 |
]. |
|
3457 |
||
3458 |
isVertical ifFalse:[ |
|
3459 |
^ x max:(self class separatorSize:(self separatorType)) |
|
388 | 3460 |
]. |
464 | 3461 |
^ x |
388 | 3462 |
! |
3463 |
||
3464 |
preferredExtentY |
|
3465 |
"compute my preferred extent y |
|
3466 |
" |
|
475 | 3467 |
|y| |
464 | 3468 |
|
712 | 3469 |
self isVisible ifFalse:[^ 0]. |
3470 |
||
650 | 3471 |
y := self verticalInset * 2. |
464 | 3472 |
|
616 | 3473 |
self isSeparator ifFalse:[ |
464 | 3474 |
^ y + (rawLabel heightOn:menuPanel) |
3475 |
]. |
|
3476 |
||
3477 |
menuPanel verticalLayout ifTrue:[ |
|
616 | 3478 |
^ y max:(self class separatorSize:(self separatorType)) |
464 | 3479 |
]. |
3480 |
^ y + (menuPanel font height) |
|
3481 |
! |
|
3482 |
||
650 | 3483 |
verticalInset |
3484 |
||
727 | 3485 |
self isButton ifTrue: [^menuPanel buttonPassiveLevel + VerticalButtonInset]. |
650 | 3486 |
^VerticalInset |
3487 |
! |
|
3488 |
||
388 | 3489 |
width |
3490 |
"gets width |
|
3491 |
" |
|
3492 |
layout isNil ifTrue:[ |
|
3493 |
^ self preferredExtentX |
|
3494 |
]. |
|
3495 |
^ layout width |
|
3496 |
! ! |
|
3497 |
||
524 | 3498 |
!MenuPanel::Item methodsFor:'building'! |
3499 |
||
3500 |
aspectAt:aKey |
|
3501 |
"retursns value assigned to key or nil |
|
3502 |
" |
|
3503 |
|appl value| |
|
3504 |
||
3505 |
appl := menuPanel receiver. |
|
3506 |
||
3507 |
(appl isKindOf:ValueModel) ifTrue:[ |
|
3508 |
^ appl value:aKey |
|
3509 |
]. |
|
3510 |
||
3511 |
(appl notNil or:[(appl := menuPanel application) notNil]) ifTrue:[ |
|
3512 |
Object messageNotUnderstoodSignal handle:[:ex|] do:[ |
|
3513 |
(appl isKindOf:ApplicationModel) ifTrue:[value := appl aspectFor:aKey] |
|
3514 |
ifFalse:[value := appl perform:aKey] |
|
3515 |
] |
|
3516 |
]. |
|
3517 |
^ value |
|
3518 |
! ! |
|
3519 |
||
390 | 3520 |
!MenuPanel::Item methodsFor:'change & update'! |
3521 |
||
498 | 3522 |
enabledStateOfMenuChangedTo:aState |
3523 |
"enabled state of menu changed to aState |
|
3524 |
" |
|
3525 |
rawLabel notNil ifTrue:[ |
|
3526 |
self drawLabel |
|
3527 |
]. |
|
3528 |
||
3529 |
! |
|
3530 |
||
390 | 3531 |
update:something with:aParameter from:changedObject |
498 | 3532 |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3533 |
changedObject == self indication ifTrue:[ |
723 | 3534 |
self isButton ifFalse: [rawLabel icon:(self indicator)]. |
498 | 3535 |
^ self redraw |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3536 |
]. |
498 | 3537 |
|
3538 |
changedObject == enableChannel ifTrue:[ |
|
3539 |
(rawLabel notNil and:[menuPanel canDrawItem]) ifTrue:[ |
|
3540 |
self drawLabel |
|
3541 |
]. |
|
3542 |
^ self |
|
3543 |
]. |
|
712 | 3544 |
|
3545 |
changedObject == isVisible ifTrue:[ |
|
3546 |
^ menuPanel mustRearrange |
|
3547 |
]. |
|
3548 |
||
498 | 3549 |
super update:something with:aParameter from:changedObject |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3550 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3551 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3552 |
updateIndicators |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3553 |
"update indicators |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3554 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3555 |
|indicator| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3556 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3557 |
(indicator := self indicator) notNil ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3558 |
indicator = rawLabel icon ifFalse:[ |
720 | 3559 |
self isButton ifFalse: [rawLabel icon:indicator]. |
465 | 3560 |
^ self redraw. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3561 |
] |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3562 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3563 |
|
390 | 3564 |
! ! |
3565 |
||
388 | 3566 |
!MenuPanel::Item methodsFor:'converting'! |
3567 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3568 |
asMenuItem |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3569 |
"convert to a MenuItem |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3570 |
" |
466 | 3571 |
|item label rcv| |
3572 |
||
3573 |
label := self label. |
|
3574 |
item := MenuItem labeled:(label printString). |
|
3575 |
||
3576 |
label isImage ifTrue:[ |
|
3577 |
rcv := ResourceRetriever new. |
|
3578 |
rcv className:#MenuEditor. |
|
3579 |
rcv selector:#iconUnknown. |
|
3580 |
item labelImage:rcv. |
|
464 | 3581 |
]. |
466 | 3582 |
|
434 | 3583 |
item activeHelpKey:activeHelpKey. |
460 | 3584 |
|
3585 |
enableChannel notNil ifTrue:[ |
|
3586 |
item enabled:(enableChannel value) |
|
3587 |
]. |
|
3588 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3589 |
item accessCharacterPosition:(self accessCharacterPosition). |
710 | 3590 |
item startGroup:(self startGroup). |
502 | 3591 |
item argument:(self argument). |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3592 |
item nameKey:(self nameKey). |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3593 |
item shortcutKeyCharacter:(self shortcutKey). |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3594 |
item value:(value value). |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3595 |
item indication:(self indication value). |
712 | 3596 |
item isVisible:(self isVisible). |
828 | 3597 |
item isButton:(self isButton). |
388 | 3598 |
|
464 | 3599 |
submenuChannel isSymbol ifTrue:[ |
3600 |
item submenuChannel:submenuChannel |
|
3601 |
] ifFalse:[ |
|
3602 |
self submenu notNil ifTrue:[ |
|
3603 |
item submenu:(self submenu asMenu) |
|
3604 |
] |
|
388 | 3605 |
]. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3606 |
^ item |
388 | 3607 |
|
3608 |
! |
|
3609 |
||
3610 |
menuItem:aMenuItem |
|
3611 |
"setup attributes from a MenuItem |
|
3612 |
" |
|
502 | 3613 |
|var lbl| |
389 | 3614 |
|
388 | 3615 |
menuPanel disabledRedrawDo:[ |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3616 |
label := nil. |
434 | 3617 |
activeHelpKey := aMenuItem activeHelpKey. |
390 | 3618 |
self enabled:(aMenuItem enabled). |
388 | 3619 |
self nameKey:(aMenuItem nameKey). |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3620 |
self indication:(aMenuItem indication). |
650 | 3621 |
self isButton:(aMenuItem isButton). |
710 | 3622 |
self startGroup:(aMenuItem startGroup). |
712 | 3623 |
self isVisible:(aMenuItem isVisible). |
390 | 3624 |
|
3625 |
(lbl := aMenuItem labelImage value) isNil ifTrue:[ |
|
3626 |
lbl := aMenuItem label. |
|
3627 |
]. |
|
3628 |
self label:lbl. |
|
3629 |
||
388 | 3630 |
self shortcutKey:(aMenuItem shortcutKeyCharacter). |
389 | 3631 |
|
502 | 3632 |
(var := aMenuItem argument) notNil ifTrue:[ |
3633 |
self argument:var. |
|
3634 |
]. |
|
3635 |
||
3636 |
(var := aMenuItem accessCharacterPosition) notNil ifTrue:[ |
|
3637 |
self accessCharacterPosition:var. |
|
389 | 3638 |
]. |
3639 |
||
464 | 3640 |
submenuChannel := aMenuItem submenuChannel. |
388 | 3641 |
self submenu:(aMenuItem submenu). |
389 | 3642 |
self value:(aMenuItem value). |
388 | 3643 |
] |
3644 |
! ! |
|
3645 |
||
3646 |
!MenuPanel::Item methodsFor:'drawing'! |
|
3647 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3648 |
drawLabel |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3649 |
"draw label |
388 | 3650 |
" |
746 | 3651 |
|y x h l t scKey cLb cLa img fg asc arrow hrzInset buttonLevel| |
464 | 3652 |
|
3653 |
img := rawLabel. |
|
608 | 3654 |
asc := menuPanel font ascent. |
3655 |
h := layout height. |
|
3656 |
l := layout left. |
|
3657 |
t := layout top. |
|
650 | 3658 |
hrzInset := self horizontalInset. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3659 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3660 |
self enabled ifTrue:[ |
650 | 3661 |
fg := self isSelected ifTrue:[self activeForegroundColor] |
608 | 3662 |
ifFalse:[menuPanel foregroundColor]. |
3663 |
||
580 | 3664 |
menuPanel paint:fg |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3665 |
] ifFalse:[ |
464 | 3666 |
menuPanel paint:(menuPanel disabledForegroundColor). |
794 | 3667 |
|
3668 |
(img := disabledRawLabel) isNil ifTrue:[ |
|
3669 |
img := self disabledRawLabel |
|
3670 |
] |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3671 |
]. |
650 | 3672 |
"/ t := t + menuPanel level. |
608 | 3673 |
y := t + ((h - (img heightOn:menuPanel)) // 2). |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3674 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3675 |
(self textLabel) notNil ifTrue:[ |
608 | 3676 |
y := y + asc. |
464 | 3677 |
]. |
650 | 3678 |
|
3679 |
self isButton |
|
3680 |
ifTrue: |
|
718
7281e5074f18
because button press state is an indication, do not longer use indicator icon
tz
parents:
717
diff
changeset
|
3681 |
[ |
720 | 3682 |
(self isSelected or: [self hasIndication and: [self indicationValue]]) |
3683 |
ifTrue: |
|
3684 |
[ |
|
3685 |
img displayOn:menuPanel x:(l + hrzInset) + 1 y: y + 1. |
|
746 | 3686 |
buttonLevel := menuPanel buttonActiveLevel |
720 | 3687 |
] |
650 | 3688 |
ifFalse: |
727 | 3689 |
[ |
650 | 3690 |
img displayOn:menuPanel x:(l + hrzInset) y:y. |
746 | 3691 |
buttonLevel := menuPanel buttonPassiveLevel |
650 | 3692 |
]. |
746 | 3693 |
menuPanel drawEdgesInLayout: layout withLevel: buttonLevel |
650 | 3694 |
] |
3695 |
ifFalse: |
|
3696 |
[ |
|
3697 |
img displayOn:menuPanel x:(l + hrzInset) y:y. |
|
3698 |
]. |
|
608 | 3699 |
"/ DRAW SHORTCUT KEY |
3700 |
||
3701 |
(scKey:= self shortcutKeyAsString) notNil ifTrue:[ |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3702 |
(x := menuPanel shortKeyInset) == 0 ifTrue:[ |
650 | 3703 |
x := hrzInset + LabelRightOffset + (img widthOn:menuPanel) |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3704 |
]. |
608 | 3705 |
x := l + x. |
3706 |
y := t + ((h - (scKey heightOn:menuPanel)) // 2). |
|
3707 |
y := y + asc. |
|
650 | 3708 |
scKey displayOn:menuPanel x:x y:y. |
608 | 3709 |
]. |
3710 |
"/ DRAW SUBMENU INDICATION |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3711 |
|
616 | 3712 |
(menuPanel isVerticalLayout and:[self submenu notNil]) ifTrue:[ |
3713 |
arrow := menuPanel rightArrow. |
|
650 | 3714 |
x := layout right - arrow width - hrzInset. |
616 | 3715 |
y := t + (h - arrow height // 2). |
3716 |
||
3717 |
(img := menuPanel rightArrowShadow) isNil ifTrue:[ |
|
3718 |
^ menuPanel displayForm:arrow x:x y:y |
|
3719 |
]. |
|
608 | 3720 |
cLa := menuPanel shadowColor. |
3721 |
cLb := menuPanel lightColor. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3722 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3723 |
self isSelected ifFalse:[ |
608 | 3724 |
fg := cLa. |
3725 |
cLa := cLb. |
|
3726 |
cLb := fg |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3727 |
]. |
608 | 3728 |
menuPanel paint:cLa. |
616 | 3729 |
menuPanel displayForm:arrow x:x y:y. |
608 | 3730 |
menuPanel paint:cLb. |
727 | 3731 |
menuPanel displayForm:img x:x y:y. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3732 |
] |
746 | 3733 |
|
388 | 3734 |
! |
3735 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3736 |
redraw |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3737 |
"redraw item |
388 | 3738 |
" |
706 | 3739 |
|isSelected ownBgCol showItemSep type paint lgCol shCol |
3740 |
h "{ Class:SmallInteger }" |
|
3741 |
w "{ Class:SmallInteger }" |
|
3742 |
l "{ Class:SmallInteger }" |
|
3743 |
t "{ Class:SmallInteger }" |
|
3744 |
r "{ Class:SmallInteger }" |
|
3745 |
b "{ Class:SmallInteger }" |
|
3746 |
x "{ Class:SmallInteger }" |
|
3747 |
y "{ Class:SmallInteger }" |
|
3748 |
hrzInset "{ Class:SmallInteger }" |
|
3749 |
| |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3750 |
|
712 | 3751 |
(self isVisible and:[menuPanel canDrawItem]) ifFalse:[ |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3752 |
^ self |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3753 |
]. |
616 | 3754 |
isSelected := self isSelected. |
650 | 3755 |
hrzInset := self horizontalInset. |
616 | 3756 |
isSelected ifFalse:[ |
727 | 3757 |
paint := self backgroundColor |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3758 |
] ifTrue:[ |
650 | 3759 |
paint := self activeBackgroundColor |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3760 |
]. |
608 | 3761 |
l := layout left. |
3762 |
t := layout top. |
|
3763 |
r := layout right. |
|
3764 |
b := layout bottom. |
|
3765 |
h := layout height. |
|
3766 |
w := layout width. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3767 |
(ownBgCol := self backgroundColorFromLabel) isNil ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3768 |
menuPanel paint:paint. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3769 |
menuPanel fillRectangle:layout. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3770 |
] ifFalse:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3771 |
self hasIndication ifFalse:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3772 |
menuPanel paint:ownBgCol. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3773 |
menuPanel fillRectangle:layout. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3774 |
] ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3775 |
menuPanel paint:paint. |
650 | 3776 |
x := (rawLabel icon width) + hrzInset + 4. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3777 |
|
608 | 3778 |
menuPanel fillRectangleX:l y:t width:x height:h. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3779 |
menuPanel paint:ownBgCol. |
608 | 3780 |
menuPanel fillRectangleX:(l + x) y:t width:(w - x) height:h. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3781 |
ownBgCol := nil. |
650 | 3782 |
]. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3783 |
]. |
608 | 3784 |
lgCol := menuPanel lightColor. |
3785 |
shCol := menuPanel shadowColor. |
|
616 | 3786 |
showItemSep := menuPanel showSeparatingLines. |
706 | 3787 |
type := self separatorType. |
3788 |
||
3789 |
type notNil ifTrue:[ |
|
3790 |
type == #blankLine ifTrue:[ |
|
608 | 3791 |
^ self |
3792 |
]. |
|
706 | 3793 |
"/ draw separator |
608 | 3794 |
menuPanel paint:shCol. |
3795 |
||
3796 |
menuPanel verticalLayout ifTrue:[ |
|
650 | 3797 |
l := l + hrzInset. |
3798 |
r := r - hrzInset. |
|
608 | 3799 |
y := t - 1 + (h // 2). |
3800 |
||
3801 |
type == #doubleLine ifTrue:[y := y - 2]. |
|
3802 |
||
3803 |
menuPanel displayLineFromX:l y:y toX:r y:y. |
|
3804 |
menuPanel paint:lgCol. |
|
3805 |
y := y + 1. |
|
3806 |
menuPanel displayLineFromX:l y:y toX:r y:y. |
|
3807 |
||
3808 |
type == #doubleLine ifTrue:[ |
|
3809 |
y := y + 3. |
|
3810 |
menuPanel paint:shCol. |
|
3811 |
menuPanel displayLineFromX:l y:y toX:r y:y. |
|
3812 |
menuPanel paint:lgCol. |
|
3813 |
y := y + 1. |
|
3814 |
menuPanel displayLineFromX:l y:y toX:r y:y. |
|
3815 |
]. |
|
3816 |
] ifFalse:[ |
|
3817 |
x := l - 1 + (w // 2). |
|
3818 |
||
3819 |
type == #doubleLine ifTrue:[x := x - 2]. |
|
3820 |
||
3821 |
menuPanel displayLineFromX:x y:t toX:x y:b. |
|
3822 |
menuPanel paint:lgCol. |
|
3823 |
x := x + 1. |
|
3824 |
menuPanel displayLineFromX:x y:t toX:x y:b. |
|
3825 |
||
3826 |
type == #doubleLine ifTrue:[ |
|
3827 |
x := x + 3. |
|
3828 |
menuPanel paint:shCol. |
|
3829 |
menuPanel displayLineFromX:x y:t toX:x y:b. |
|
3830 |
menuPanel paint:lgCol. |
|
3831 |
x := x + 1. |
|
3832 |
menuPanel displayLineFromX:x y:t toX:x y:b. |
|
3833 |
] |
|
3834 |
]. |
|
3835 |
^ self |
|
3836 |
]. |
|
3837 |
||
706 | 3838 |
self isButton ifTrue:[ |
3839 |
^ self drawLabel |
|
3840 |
]. |
|
3841 |
||
3842 |
showItemSep ifTrue:[ |
|
650 | 3843 |
|myIndex lastItem nextItem mayDrawInLastItemsLayout mayDrawInNextItemsLayout| |
706 | 3844 |
|
3845 |
myIndex := menuPanel indexOfItem:self. |
|
3846 |
lastItem := menuPanel itemAtIndex:myIndex - 1. |
|
3847 |
nextItem := menuPanel itemAtIndex:myIndex + 1. |
|
3848 |
mayDrawInLastItemsLayout := lastItem isNil or: [lastItem isButton not]. |
|
3849 |
mayDrawInNextItemsLayout := nextItem isNil or: [nextItem isButton not]. |
|
3850 |
||
608 | 3851 |
menuPanel paint:lgCol. |
706 | 3852 |
|
608 | 3853 |
menuPanel verticalLayout ifTrue:[ |
650 | 3854 |
mayDrawInLastItemsLayout |
3855 |
ifTrue: |
|
3856 |
[ |
|
3857 |
menuPanel displayLineFromX:l y:b - 1 toX:r y:b - 1. |
|
3858 |
menuPanel displayLineFromX:l y:t - 1 toX:r y:t - 1. |
|
3859 |
]. |
|
3860 |
mayDrawInNextItemsLayout |
|
3861 |
ifTrue: |
|
3862 |
[ |
|
3863 |
menuPanel paint:shCol. |
|
3864 |
menuPanel displayLineFromX:l y:b - 2 toX:r y:b - 2. |
|
3865 |
menuPanel displayLineFromX:l y:t - 2 toX:r y:t - 2. |
|
3866 |
] |
|
608 | 3867 |
] ifFalse:[ |
650 | 3868 |
mayDrawInLastItemsLayout |
3869 |
ifTrue: |
|
3870 |
[ |
|
3871 |
menuPanel displayLineFromX:r - 1 y:t toX:r - 1 y:b. |
|
3872 |
menuPanel displayLineFromX:l - 1 y:t toX:l - 1 y:b |
|
3873 |
]. |
|
3874 |
mayDrawInNextItemsLayout |
|
3875 |
ifTrue: |
|
3876 |
[ |
|
3877 |
menuPanel paint:shCol. |
|
3878 |
menuPanel displayLineFromX:r - 2 y:t toX:r - 2 y:b. |
|
3879 |
menuPanel displayLineFromX:l - 2 y:t toX:l - 2 y:b |
|
3880 |
] |
|
388 | 3881 |
] |
608 | 3882 |
]. |
3883 |
||
650 | 3884 |
self drawLabel. |
3885 |
||
706 | 3886 |
(ownBgCol notNil and:[self isSelected]) ifTrue:[ |
730 | 3887 |
ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor] |
3888 |
ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor]. |
|
706 | 3889 |
|
3890 |
menuPanel displayRectangleX:(l + 1) y:(t + 1) width:(w - 2) height:(h - 2). |
|
730 | 3891 |
menuPanel displayRectangleX:(l + 2) y:(t + 2) width:(w - 4) height:(h - 4). |
706 | 3892 |
]. |
3893 |
||
728 | 3894 |
menuPanel drawEdgesForX:l y:t width:w height:h isSelected:isSelected. |
706 | 3895 |
|
388 | 3896 |
! ! |
3897 |
||
3898 |
!MenuPanel::Item methodsFor:'initialization'! |
|
3899 |
||
3900 |
destroy |
|
616 | 3901 |
"destroy submenus, remove dependencies |
388 | 3902 |
" |
616 | 3903 |
|channel| |
3904 |
||
3905 |
self submenu:nil. |
|
3906 |
||
3907 |
(self isKindOfValueHolder:enableChannel) ifTrue:[ |
|
3908 |
enableChannel removeDependent:self |
|
3909 |
]. |
|
3910 |
||
712 | 3911 |
(self isKindOfValueHolder:isVisible) ifTrue:[ |
3912 |
isVisible removeDependent:self |
|
3913 |
]. |
|
3914 |
||
616 | 3915 |
channel := self indication. |
3916 |
||
3917 |
(self isKindOfValueHolder:channel) ifTrue:[ |
|
3918 |
channel removeDependent:self |
|
3919 |
]. |
|
3920 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3921 |
menuPanel := nil. |
616 | 3922 |
|
3923 |
! |
|
3924 |
||
794 | 3925 |
in:aPanel |
3926 |
"create item in a menuPanel |
|
3927 |
" |
|
3928 |
menuPanel := aPanel. |
|
3929 |
! ! |
|
3930 |
||
3931 |
!MenuPanel::Item methodsFor:'label basics'! |
|
3932 |
||
3933 |
disabledRawLabel |
|
3934 |
"returns the label used if the item is disabled |
|
3935 |
" |
|
3936 |
disabledRawLabel isNil ifTrue:[ |
|
3937 |
( rawImage notNil |
|
3938 |
and:[(rawImage respondsTo:#colorMap) |
|
3939 |
and:[rawImage colorMap notNil]] |
|
3940 |
) ifFalse:[ |
|
3941 |
disabledRawLabel := rawLabel |
|
3942 |
] ifTrue:[ |
|
3943 |
disabledRawLabel := menuPanel lightenedImageOnDevice:rawImage. |
|
3944 |
||
3945 |
rawLabel class == LabelAndIcon ifTrue:[ |
|
3946 |
disabledRawLabel := LabelAndIcon form:disabledRawLabel |
|
3947 |
image:(rawLabel image) |
|
3948 |
string:(rawLabel string) |
|
3949 |
] |
|
3950 |
] |
|
3951 |
]. |
|
3952 |
^ disabledRawLabel |
|
3953 |
! |
|
3954 |
||
616 | 3955 |
fetchImages |
3956 |
"fetch images |
|
3957 |
" |
|
794 | 3958 |
|img form| |
3959 |
||
3960 |
rawImage isNil ifTrue:[ |
|
3961 |
^ self |
|
3962 |
]. |
|
687 | 3963 |
|
616 | 3964 |
rawLabel isImage ifTrue:[ |
794 | 3965 |
img := menuPanel imageOnDevice:rawImage. |
735 | 3966 |
|
3967 |
self indicator isNil ifTrue:[ |
|
3968 |
rawLabel := img. |
|
3969 |
] ifFalse:[ |
|
794 | 3970 |
form := self isButton ifTrue:[nil] ifFalse:[self indicator]. |
3971 |
rawLabel := LabelAndIcon form:form image:img |
|
735 | 3972 |
] |
687 | 3973 |
] ifFalse:[ |
794 | 3974 |
(rawLabel class == LabelAndIcon and:[self isButton not]) ifTrue:[ |
3975 |
rawLabel icon:(menuPanel imageOnDevice:rawImage) |
|
687 | 3976 |
] |
616 | 3977 |
] |
687 | 3978 |
|
388 | 3979 |
! |
3980 |
||
794 | 3981 |
rawLabelChanged |
3982 |
||
3983 |
disabledRawLabel := nil. |
|
3984 |
||
3985 |
rawLabel isImage ifTrue:[ |
|
3986 |
rawImage := rawLabel |
|
3987 |
] ifFalse:[ |
|
3988 |
rawLabel class == LabelAndIcon ifTrue:[ |
|
3989 |
rawImage := rawLabel icon |
|
3990 |
] ifFalse:[ |
|
3991 |
rawImage := nil. |
|
3992 |
disabledRawLabel := rawLabel. |
|
3993 |
] |
|
3994 |
]. |
|
3995 |
menuPanel shown ifTrue:[ self fetchImages ]. |
|
3996 |
menuPanel mustRearrange |
|
3997 |
! |
|
3998 |
||
3999 |
updateRawLabel |
|
4000 |
"recreate rawLabel |
|
4001 |
" |
|
4002 |
|char size indicator| |
|
4003 |
||
4004 |
(rawLabel := label value) isString ifFalse:[ |
|
4005 |
^ self rawLabelChanged. |
|
4006 |
]. |
|
4007 |
||
4008 |
rawLabel isText ifFalse:[ |
|
4009 |
rawLabel := rawLabel withoutSeparators |
|
4010 |
]. |
|
4011 |
size := rawLabel size. |
|
4012 |
||
4013 |
(indicator := self indicator) isNil ifTrue:[ |
|
4014 |
size == 0 ifTrue:[ |
|
4015 |
rawLabel := nil. |
|
4016 |
^ self rawLabelChanged |
|
4017 |
]. |
|
4018 |
||
4019 |
size == 1 ifTrue:[ |
|
4020 |
char := rawLabel first. |
|
4021 |
||
4022 |
(char == $- or:[char == $=]) ifTrue:[ "/ other line separators |
|
4023 |
label := String new:1. |
|
4024 |
label at:1 put:char. |
|
4025 |
rawLabel := nil. |
|
4026 |
^ self rawLabelChanged |
|
4027 |
] |
|
4028 |
] |
|
4029 |
] ifFalse:[ |
|
4030 |
size == 0 ifTrue:[rawLabel := label value] |
|
4031 |
]. |
|
4032 |
size := self accessCharacterPosition. |
|
4033 |
||
4034 |
(size notNil and:[size <= rawLabel size]) ifTrue:[ |
|
4035 |
rawLabel isText ifFalse:[ |
|
4036 |
rawLabel := Text string:rawLabel |
|
4037 |
]. |
|
4038 |
rawLabel emphasisAt:size add:#underline |
|
4039 |
]. |
|
4040 |
||
4041 |
(indicator := self indicator) notNil ifTrue:[ |
|
4042 |
rawLabel := LabelAndIcon icon: (self isButton ifFalse: [indicator]) string:rawLabel. |
|
4043 |
]. |
|
4044 |
||
4045 |
self rawLabelChanged. |
|
388 | 4046 |
! ! |
4047 |
||
4048 |
!MenuPanel::Item methodsFor:'private'! |
|
4049 |
||
650 | 4050 |
activeBackgroundColor |
4051 |
"returns the active background color derived from menuPanel |
|
4052 |
" |
|
4053 |
||
727 | 4054 |
self isButton ifTrue: [^menuPanel buttonActiveBackgroundColor]. |
650 | 4055 |
^menuPanel activeBackgroundColor |
4056 |
! |
|
4057 |
||
4058 |
activeForegroundColor |
|
4059 |
"returns the active foreground color derived from menuPanel |
|
4060 |
" |
|
4061 |
||
4062 |
^menuPanel activeForegroundColor |
|
4063 |
! |
|
4064 |
||
388 | 4065 |
adornment |
4066 |
"returns adornment; if not existing yet a new instance |
|
4067 |
is created |
|
4068 |
" |
|
4069 |
adornment isNil ifTrue:[ |
|
4070 |
adornment := Adornment new |
|
4071 |
]. |
|
4072 |
^ adornment |
|
4073 |
! |
|
4074 |
||
727 | 4075 |
backgroundColor |
4076 |
"returns the background color derived from menuPanel |
|
4077 |
" |
|
4078 |
||
4079 |
self isButton ifTrue: [^menuPanel buttonPassiveBackgroundColor]. |
|
4080 |
^menuPanel backgroundColor |
|
4081 |
! |
|
4082 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4083 |
backgroundColorFromLabel |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4084 |
"returns the background color derived from label or nil |
388 | 4085 |
" |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4086 |
|run| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4087 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4088 |
label isText ifFalse:[^ nil ]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4089 |
run := label emphasis. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4090 |
run size == 0 ifTrue:[^ nil ]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4091 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4092 |
run := run first. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4093 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4094 |
run size == 0 ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4095 |
(run value isColor and:[run key == #backgroundColor]) ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4096 |
^ run value |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4097 |
] |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4098 |
] ifFalse:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4099 |
run do:[:r| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4100 |
(r value isColor and:[r key == #backgroundColor]) ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4101 |
^ r value |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4102 |
] |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4103 |
] |
388 | 4104 |
]. |
4105 |
^ nil |
|
4106 |
! |
|
4107 |
||
663 | 4108 |
findSubMenuIn:aRecv |
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4109 |
|subm argument sel| |
663 | 4110 |
|
4111 |
subm := nil. |
|
4112 |
||
4113 |
aRecv notNil ifTrue:[ |
|
711 | 4114 |
submenuChannel last ~~ $: ifTrue:[ |
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4115 |
Object messageNotUnderstoodSignal handle:[:ex| |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4116 |
ex parameter selector == submenuChannel ifFalse:[ |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4117 |
ex reject |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4118 |
]. |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4119 |
] do:[ |
663 | 4120 |
subm := aRecv aspectFor:submenuChannel |
4121 |
]. |
|
4122 |
subm isNil ifTrue:[ |
|
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4123 |
Object messageNotUnderstoodSignal handle:[:ex| |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4124 |
ex parameter selector == submenuChannel ifFalse:[ |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4125 |
ex reject |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4126 |
]. |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4127 |
] do:[ |
663 | 4128 |
subm := aRecv perform:submenuChannel |
4129 |
] |
|
4130 |
]. |
|
4131 |
subm isNil ifTrue:[ |
|
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4132 |
Object messageNotUnderstoodSignal handle:[:ex| |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4133 |
ex parameter selector == submenuChannel ifFalse:[ |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4134 |
ex reject |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4135 |
]. |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4136 |
] do:[ |
663 | 4137 |
subm := aRecv class perform:submenuChannel |
4138 |
] |
|
4139 |
] |
|
4140 |
] ifFalse:[ |
|
711 | 4141 |
(argument := self argument) notNil ifTrue:[ |
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4142 |
sel := submenuChannel asSymbol. |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4143 |
Object messageNotUnderstoodSignal handle:[:ex| |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4144 |
ex parameter selector == sel ifFalse:[ |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4145 |
ex reject |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4146 |
]. |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4147 |
] do:[ |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4148 |
subm := aRecv perform:sel with:argument |
711 | 4149 |
]. |
4150 |
||
4151 |
subm isNil ifTrue:[ |
|
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4152 |
Object messageNotUnderstoodSignal handle:[:ex| |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4153 |
ex parameter selector == sel ifFalse:[ |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4154 |
ex reject |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4155 |
]. |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4156 |
] do:[ |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4157 |
subm := aRecv class perform:sel with:argument |
711 | 4158 |
] |
663 | 4159 |
] |
4160 |
] |
|
4161 |
] |
|
4162 |
]. |
|
4163 |
^ subm |
|
4164 |
||
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4165 |
"Modified: / 19.5.1998 / 19:44:26 / cg" |
663 | 4166 |
! |
4167 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4168 |
indicationValue |
524 | 4169 |
"returns indication value or nil in case of no indication |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4170 |
" |
608 | 4171 |
|indication numArgs sel recv| |
524 | 4172 |
|
4173 |
(indication := self indication) isNil ifTrue:[ |
|
4174 |
^ nil "/ has no indication |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4175 |
]. |
524 | 4176 |
|
4177 |
indication isSymbol ifTrue:[ |
|
608 | 4178 |
(numArgs := indication numArgs) ~~ 0 ifTrue:[ |
4179 |
numArgs == 2 ifTrue:[ |
|
4180 |
recv := menuPanel receiver. |
|
4181 |
||
4182 |
(recv isKindOf:ValueModel) ifFalse:[ |
|
4183 |
(recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[ |
|
4184 |
sel := indication copyFrom:1 to:(indication indexOf:$:). |
|
4185 |
indication := nil. |
|
4186 |
||
4187 |
Object messageNotUnderstoodSignal handle:[:ex| ] do:[ |
|
4188 |
indication := recv perform:(sel asSymbol) with:self argument |
|
4189 |
] |
|
4190 |
]. |
|
4191 |
]. |
|
4192 |
^ indication value == true |
|
4193 |
]. |
|
524 | 4194 |
indication := (indication copyWithoutLast:1) asSymbol |
4195 |
]. |
|
4196 |
indication := self aspectAt:indication. |
|
4197 |
||
4198 |
(self isKindOfValueHolder:indication) ifTrue:[ |
|
4199 |
self adornment indication:indication. |
|
4200 |
indication addDependent:self. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4201 |
] |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4202 |
]. |
524 | 4203 |
^ indication value == true |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4204 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4205 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4206 |
indicationValue:aValue |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4207 |
"returns indication value or nil |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4208 |
" |
608 | 4209 |
|numArgs indication recv| |
524 | 4210 |
|
4211 |
(indication := self indication) isNil ifTrue:[ |
|
4212 |
^ self "/ has no indication |
|
4213 |
]. |
|
4214 |
||
4215 |
indication isSymbol ifFalse:[ |
|
4216 |
(self isKindOfValueHolder:indication) ifTrue:[ "/ is value holder |
|
4217 |
indication value:aValue |
|
4218 |
]. |
|
4219 |
^ self |
|
4220 |
]. |
|
4221 |
recv := menuPanel receiver. |
|
4222 |
||
4223 |
(recv isKindOf:ValueModel) ifTrue:[ |
|
4224 |
recv value:indication value:aValue. |
|
4225 |
] ifFalse:[ |
|
608 | 4226 |
( (numArgs := indication numArgs) ~~ 0 |
4227 |
and:[recv notNil or:[(recv := menuPanel application) notNil]] |
|
4228 |
) ifTrue:[ |
|
4229 |
Object messageNotUnderstoodSignal handle:[:ex| ] do:[ |
|
4230 |
numArgs == 1 ifTrue:[ |
|
4231 |
recv perform:indication with:aValue |
|
4232 |
] ifFalse:[ |
|
739 | 4233 |
recv perform:indication with:(self argument ? self) with:aValue |
608 | 4234 |
] |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4235 |
] |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4236 |
] |
524 | 4237 |
]. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4238 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4239 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4240 |
indicator |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4241 |
"returns indication form or nil |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4242 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4243 |
|value| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4244 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4245 |
(value := self indicationValue) isNil ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4246 |
^ nil |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4247 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4248 |
^ value ifTrue:[IndicatorOn] ifFalse:[IndicatorOff] |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4249 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4250 |
|
464 | 4251 |
separatorType |
4252 |
"returns type of separator line or nil |
|
388 | 4253 |
" |
390 | 4254 |
|c lbl| |
388 | 4255 |
|
4256 |
rawLabel isNil ifFalse:[ |
|
4257 |
^ nil |
|
4258 |
]. |
|
4259 |
||
390 | 4260 |
(lbl := label value) isNil ifTrue:[ |
388 | 4261 |
^ #singleLine |
4262 |
]. |
|
4263 |
||
390 | 4264 |
lbl size == 1 ifTrue:[ |
4265 |
c := lbl first. |
|
388 | 4266 |
c == $- ifTrue:[^ #singleLine]. |
4267 |
c == $= ifTrue:[^ #doubleLine]. |
|
4268 |
]. |
|
4269 |
^ #blankLine |
|
4270 |
! ! |
|
4271 |
||
4272 |
!MenuPanel::Item methodsFor:'queries'! |
|
4273 |
||
4274 |
canSelect |
|
4275 |
"returns true if item is selectable |
|
4276 |
" |
|
712 | 4277 |
^ (self isVisible and:[self enabled and:[rawLabel notNil]]) |
388 | 4278 |
! |
4279 |
||
4280 |
containsPointX:x y:y |
|
4281 |
"returns true if point is contained in my layout |
|
4282 |
" |
|
712 | 4283 |
(self isVisible and:[layout notNil]) ifTrue:[ |
505 | 4284 |
^ ( (x >= layout left) |
4285 |
and:[x < layout right |
|
4286 |
and:[y > layout top |
|
4287 |
and:[y <= layout bottom]]] |
|
4288 |
) |
|
4289 |
]. |
|
4290 |
^ false |
|
388 | 4291 |
! |
4292 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4293 |
hasIndication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4294 |
"returns true if on/off indication exists |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4295 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4296 |
^ self indication notNil |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4297 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4298 |
|
388 | 4299 |
hasSubmenu |
4300 |
"returns true if a submenu exists |
|
4301 |
" |
|
4302 |
^ self submenu notNil |
|
4303 |
! |
|
4304 |
||
4305 |
isEnabled |
|
4306 |
"returns enabled state |
|
4307 |
" |
|
4308 |
^ self enabled |
|
4309 |
! |
|
4310 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4311 |
isKindOfValueHolder:something |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4312 |
"returns true if something is kind of vlaue holder |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4313 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4314 |
^ ((something respondsTo:#value:) and:[something isBlock not]) |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4315 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4316 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4317 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4318 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4319 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4320 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4321 |
|
608 | 4322 |
isSeparator |
4323 |
"returns true if item is a separator |
|
4324 |
" |
|
4325 |
^ rawLabel isNil |
|
4326 |
! |
|
4327 |
||
712 | 4328 |
isVisible |
4329 |
"returns the visibility state |
|
4330 |
" |
|
4331 |
|state| |
|
4332 |
||
4333 |
isVisible isSymbol ifTrue:[ |
|
4334 |
state := self aspectAt:isVisible. |
|
4335 |
||
4336 |
(self isKindOfValueHolder:state) ifTrue:[ |
|
4337 |
isVisible := state. |
|
4338 |
isVisible addDependent:self. |
|
4339 |
state := isVisible value. |
|
4340 |
] |
|
4341 |
] ifFalse:[ |
|
4342 |
state := isVisible value |
|
4343 |
]. |
|
4344 |
^ state ~~ false |
|
4345 |
||
4346 |
! |
|
4347 |
||
4348 |
isVisible:something |
|
4349 |
"change the state; if the state changed, a redraw is performed |
|
4350 |
" |
|
4351 |
|oldState newState| |
|
4352 |
||
4353 |
isVisible isNil ifTrue:[ |
|
4354 |
oldState := true |
|
4355 |
] ifFalse:[ |
|
4356 |
oldState := isVisible value. |
|
4357 |
(self isKindOfValueHolder:isVisible) ifTrue:[ |
|
4358 |
isVisible removeDependent:self |
|
4359 |
] |
|
4360 |
]. |
|
4361 |
isVisible := something. |
|
4362 |
||
4363 |
isVisible isNil ifTrue:[ |
|
4364 |
newState := true |
|
4365 |
] ifFalse:[ |
|
4366 |
(self isKindOfValueHolder:isVisible) ifTrue:[ |
|
4367 |
isVisible addDependent:self |
|
4368 |
] ifFalse:[ |
|
4369 |
isVisible isSymbol ifTrue:[^ self] |
|
4370 |
]. |
|
4371 |
menuPanel shown ifFalse:[^ self]. |
|
4372 |
newState := isVisible value. |
|
4373 |
]. |
|
4374 |
||
4375 |
newState ~~ oldState ifTrue:[ |
|
4376 |
menuPanel mustRearrange |
|
4377 |
] |
|
4378 |
! |
|
4379 |
||
388 | 4380 |
shortcutKeyAsString |
4381 |
"converts shortcutKey to a text object |
|
4382 |
" |
|
475 | 4383 |
|nm key| |
388 | 4384 |
|
4385 |
"/ this is somewhat complicated: we have the symbolic key at hand, |
|
4386 |
"/ but want to show the untranslated (inverse keyBoardMapped) key & modifier |
|
4387 |
"/ |
|
4388 |
||
4389 |
(key := self shortcutKey) isNil ifTrue:[ |
|
4390 |
^ nil |
|
4391 |
]. |
|
4392 |
||
4393 |
key isCharacter ifTrue:[ |
|
4394 |
nm := key asString |
|
4395 |
] ifFalse:[ |
|
4396 |
nm := menuPanel device keyboardMap keyAtValue:key ifAbsent:key. |
|
4397 |
"/ |
|
4398 |
"/ some modifier-key combination ? |
|
4399 |
"/ |
|
4400 |
||
4401 |
(nm startsWith:#Cmd) ifTrue:[ |
|
4402 |
nm := (self shortcutKeyPrefixFor:#Cmd) , (nm copyFrom:4) |
|
4403 |
] ifFalse:[(nm startsWith:#Alt) ifTrue:[ |
|
4404 |
nm := (self shortcutKeyPrefixFor:#Alt) , (nm copyFrom:4) |
|
4405 |
] ifFalse:[(nm startsWith:#Meta) ifTrue:[ |
|
4406 |
nm := (self shortcutKeyPrefixFor:#Meta), (nm copyFrom:5) |
|
4407 |
] |
|
4408 |
ifFalse:[(nm startsWith:#Ctrl) ifTrue:[ |
|
4409 |
nm := (self shortcutKeyPrefixFor:#Ctrl), (nm copyFrom:5) |
|
4410 |
] ifFalse:[ |
|
4411 |
nm := nm asString |
|
4412 |
]]]] |
|
4413 |
]. |
|
608 | 4414 |
^ nm |
388 | 4415 |
|
4416 |
||
4417 |
! |
|
4418 |
||
4419 |
shortcutKeyPrefixFor:aModifier |
|
4420 |
"returns prefix assigned to a modifier |
|
4421 |
" |
|
4422 |
|m| |
|
4423 |
||
4424 |
m := menuPanel device modifierKeyTopFor:aModifier. |
|
4425 |
||
4426 |
m notNil ifTrue:[ |
|
4427 |
^ m , '-' |
|
4428 |
]. |
|
4429 |
^ aModifier. |
|
4430 |
! ! |
|
4431 |
||
4432 |
!MenuPanel::Item methodsFor:'selection'! |
|
4433 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4434 |
hideSubmenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4435 |
"hide submenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4436 |
" |
580 | 4437 |
|subMenu id| |
464 | 4438 |
|
4439 |
subMenu := self submenu. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4440 |
subMenu realized ifFalse:[ |
580 | 4441 |
(id := subMenu id) notNil ifTrue:[ |
4442 |
menuPanel device unmapWindow:id |
|
4443 |
] |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4444 |
] ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4445 |
subMenu hide |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4446 |
] |
580 | 4447 |
|
4448 |
"Modified: / 27.10.1997 / 04:13:13 / cg" |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4449 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4450 |
|
388 | 4451 |
isSelected |
4452 |
"returns true if item is selected |
|
4453 |
" |
|
4454 |
^ menuPanel selection == self |
|
4455 |
! |
|
4456 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4457 |
openSubmenuAt:aPoint |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4458 |
"open submenu at a point |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4459 |
" |
680 | 4460 |
|top windowGrp subMenu| |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4461 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4462 |
windowGrp := menuPanel topMenu windowGroup. |
464 | 4463 |
subMenu := self setupSubmenu. |
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4464 |
subMenu isNil ifTrue:[ |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4465 |
^ self |
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4466 |
]. |
829 | 4467 |
subMenu font:(menuPanel topMenu font). |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4468 |
subMenu becomesActiveMenu. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4469 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4470 |
windowGrp notNil ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4471 |
subMenu windowGroup:windowGrp. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4472 |
windowGrp addTopView:subMenu. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4473 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4474 |
subMenu fixSize. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4475 |
subMenu origin:aPoint. |
816 | 4476 |
"/ subMenu makeFullyVisible. |
680 | 4477 |
top := menuPanel topMenu. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4478 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4479 |
subMenu realized ifFalse:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4480 |
subMenu realize. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4481 |
] ifTrue:[ |
680 | 4482 |
top device mapWindow:subMenu id. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4483 |
]. |
816 | 4484 |
subMenu makeFullyVisible. |
4485 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4486 |
|
680 | 4487 |
"/ (top styleSheet at:'menu.autoSelectFirst') ifTrue:[ |
4488 |
"/ subMenu selectionIndex:1 |
|
4489 |
"/ ] |
|
4490 |
||
890
28c4470c6858
dont catch all messageNotUnderstoods
Claus Gittinger <cg@exept.de>
parents:
879
diff
changeset
|
4491 |
"Modified: / 19.5.1998 / 19:37:37 / cg" |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4492 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4493 |
|
388 | 4494 |
selected:aState |
4495 |
"change selection to a state. Dependant on the state open or hide an existing |
|
4496 |
submenu and perform a redraw |
|
4497 |
" |
|
4498 |
|p d subMenu| |
|
4499 |
||
4500 |
subMenu := self submenu. |
|
4501 |
||
4502 |
aState ifFalse:[ |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4503 |
self redraw. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4504 |
subMenu notNil ifTrue:[ |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4505 |
self hideSubmenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4506 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4507 |
^ self |
388 | 4508 |
]. |
720 | 4509 |
menuPanel shown ifFalse:[^ self]. |
4510 |
(self hasIndication not or: [self isButton not]) ifTrue: [self redraw]. |
|
388 | 4511 |
|
4512 |
subMenu isNil ifTrue:[ |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
4513 |
menuPanel isPopUpView ifTrue:[ |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
4514 |
menuPanel grabMouseAndKeyboard. |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
4515 |
]. |
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
4516 |
^ self. |
388 | 4517 |
]. |
4518 |
||
4519 |
menuPanel verticalLayout ifTrue:[p := (layout right) @ (layout top)] |
|
4520 |
ifFalse:[p := (layout left) @ (layout bottom)]. |
|
4521 |
||
4522 |
d := menuPanel device. |
|
4523 |
p := d translatePoint:p from:(menuPanel id) to:(d rootWindowId). |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4524 |
self openSubmenuAt:p. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4525 |
|
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
4526 |
"Modified: / 2.2.1998 / 10:17:41 / stefan" |
388 | 4527 |
! ! |
4528 |
||
4529 |
!MenuPanel::Item::Adornment methodsFor:'accessing'! |
|
4530 |
||
4531 |
accessCharacterPosition |
|
4532 |
"get the index of the access character in the label text or string, or nil if none |
|
4533 |
" |
|
4534 |
^ accessCharacterPosition |
|
4535 |
! |
|
4536 |
||
4537 |
accessCharacterPosition:anIndexOrNil |
|
4538 |
"set the index of the access character in the label text or string, or nil if none |
|
4539 |
" |
|
4540 |
accessCharacterPosition := anIndexOrNil |
|
4541 |
! |
|
4542 |
||
4543 |
argument |
|
4544 |
"ST/X goody; get argunment to a selector or block |
|
4545 |
" |
|
4546 |
^ argument |
|
4547 |
! |
|
4548 |
||
4549 |
argument:anArgumentOrNil |
|
4550 |
"ST/X goody; set argunment to a selector or block |
|
4551 |
" |
|
4552 |
argument := anArgumentOrNil |
|
4553 |
! |
|
4554 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4555 |
indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4556 |
"get has on/off indicator value |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4557 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4558 |
^ indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4559 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4560 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4561 |
indication:something |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4562 |
"set has on/off indicator value |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4563 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4564 |
indication := something. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
4565 |
! |
388 | 4566 |
|
4567 |
shortcutKey |
|
4568 |
"get the character that is used as a shortcut key for this item |
|
4569 |
" |
|
4570 |
^ shortcutKey |
|
4571 |
! |
|
4572 |
||
4573 |
shortcutKey:aKeyOrNil |
|
4574 |
"set the character that is used as a shortcut key for this item |
|
4575 |
" |
|
4576 |
shortcutKey := aKeyOrNil |
|
4577 |
! ! |
|
4578 |
||
4579 |
!MenuPanel class methodsFor:'documentation'! |
|
4580 |
||
4581 |
version |
|
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
4582 |
^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.87 1998-06-06 17:51:49 cg Exp $' |
388 | 4583 |
! ! |
4584 |
MenuPanel initialize! |