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