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