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