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