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