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