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