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