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