author | Claus Gittinger <cg@exept.de> |
Thu, 26 Sep 2002 09:38:41 +0200 | |
changeset 2220 | 5ea0ceb20354 |
parent 2219 | 93426020ceed |
child 2231 | 65cec3d10fb1 |
permissions | -rw-r--r-- |
2005 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
2145 | 3 |
All Rights Reserved |
2005 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
13 |
||
1750 | 14 |
"{ Package: 'stx:libwidg2' }" |
15 |
||
2182
59a770bbb95a
changed superclass to View (to inherit model)
Claus Gittinger <cg@exept.de>
parents:
2171
diff
changeset
|
16 |
View subclass:#MenuPanel |
2145 | 17 |
instanceVariableNames:'adornment shadowView mapTime mustRearrange superMenu |
2219 | 18 |
shortKeyInset selection items groupSizes receiver enabled |
19 |
lastActiveMenu enteredItem prevFocusView previousPointerGrab |
|
20 |
previousKeyboardGrab relativeGrabOrigin hasImplicitGrap |
|
21 |
scrollActivity rightArrowShadow rightArrow fgColor' |
|
22 |
classVariableNames:'InitialSelectionQuerySignal DefaultAdornment Images |
|
23 |
LigthenedImages' |
|
2145 | 24 |
poolDictionaries:'' |
25 |
category:'Views-Menus' |
|
388 | 26 |
! |
27 |
||
28 |
Object subclass:#Item |
|
2145 | 29 |
instanceVariableNames:'layout menuPanel subMenu rawLabel rawLabelExtent disabledRawLabel |
30 |
enableChannel nameKey value label activeHelpKey activeHelpText |
|
31 |
submenuChannel startGroup isButton isVisible hideMenuOnActivated |
|
32 |
indication accessCharacterPosition shortcutKey argument choice |
|
33 |
choiceValue showBusyCursorWhilePerforming accessCharacter font |
|
34 |
keepLinkedMenu triggerOnDown horizontalLayout delayMenu' |
|
35 |
classVariableNames:'HorizontalInset VerticalInset HorizontalButtonInset |
|
36 |
VerticalButtonInset LabelRightOffset VerticalPopUpInset' |
|
37 |
poolDictionaries:'' |
|
38 |
privateIn:MenuPanel |
|
388 | 39 |
! |
40 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
41 |
Object subclass:#ScrollActivity |
2145 | 42 |
instanceVariableNames:'semaLock activeMenu scrollTask direction icons' |
43 |
classVariableNames:'' |
|
44 |
poolDictionaries:'' |
|
45 |
privateIn:MenuPanel |
|
2016 | 46 |
! |
47 |
||
388 | 48 |
!MenuPanel class methodsFor:'documentation'! |
49 |
||
2005 | 50 |
copyright |
51 |
" |
|
52 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
2145 | 53 |
All Rights Reserved |
2005 | 54 |
|
55 |
This software is furnished under a license and may be used |
|
56 |
only in accordance with the terms of that license and with the |
|
57 |
inclusion of the above copyright notice. This software may not |
|
58 |
be provided or otherwise made available to, or used by, any |
|
59 |
other person. No title to or ownership of the software is |
|
60 |
hereby transferred. |
|
61 |
" |
|
62 |
||
388 | 63 |
! |
64 |
||
65 |
documentation |
|
66 |
" |
|
67 |
a menu panel used for both pull-down-menus and pop-up-menus. |
|
68 |
||
2170 | 69 |
this will eventually replace most of the MenuView and PopUpMenu stuff. |
388 | 70 |
(and hopefully be ST-80 compatible ...) |
71 |
||
502 | 72 |
To create a menu, there exists a MenuEditor which will generate |
73 |
a menu specification. |
|
74 |
||
75 |
||
2061 | 76 |
Notice: |
77 |
This is going to replace the obsolete MenuView. |
|
78 |
||
388 | 79 |
[author:] |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
80 |
Claus Atzkern |
388 | 81 |
|
82 |
[see also:] |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
83 |
Menu |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
84 |
MenuItem |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
85 |
MenuEditor |
2170 | 86 |
|
87 |
cg: this code is so ugly - needs a complete rewrite... |
|
88 |
||
388 | 89 |
" |
90 |
! |
|
91 |
||
92 |
examples |
|
93 |
||
94 |
" |
|
95 |
start as PullDownMenu |
|
2219 | 96 |
[exBegin] |
388 | 97 |
|top subView mview desc s1 s2 s3 img lbs labels| |
98 |
||
99 |
top := StandardSystemView new. |
|
100 |
||
436 | 101 |
mview := MenuPanel in:top. |
388 | 102 |
|
502 | 103 |
labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ). |
388 | 104 |
mview level:2. |
105 |
mview verticalLayout:false. |
|
106 |
img := Image fromFile:'bitmaps/SBrowser.xbm'. |
|
502 | 107 |
lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'. |
388 | 108 |
mview labels:lbs. |
109 |
mview shortcutKeyAt:2 put:#Cut. |
|
110 |
mview accessCharacterPositionAt:1 put:1. |
|
111 |
mview accessCharacterPositionAt:2 put:2. |
|
112 |
||
113 |
mview enabledAt:5 put:false. |
|
114 |
mview groupSizes:#( 2 2 ). |
|
436 | 115 |
s1 := MenuPanel labels:labels. |
388 | 116 |
s1 accessCharacterPositionAt:1 put:1. |
117 |
s1 accessCharacterPositionAt:2 put:2. |
|
118 |
s1 groupSizes:#( 2 2 ). |
|
436 | 119 |
s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ). |
120 |
s3 := MenuPanel labels:lbs. |
|
388 | 121 |
|
122 |
s1 subMenuAt:2 put:s2. |
|
436 | 123 |
s1 subMenuAt:3 put:(MenuPanel labels:lbs). |
388 | 124 |
s2 subMenuAt:3 put:s3. |
436 | 125 |
s3 subMenuAt:3 put:(MenuPanel labels:labels). |
388 | 126 |
s3 shortcutKeyAt:3 put:$q. |
127 |
||
128 |
mview subMenuAt:1 put:s1. |
|
436 | 129 |
mview subMenuAt:4 put:(MenuPanel labels:lbs). |
388 | 130 |
(mview subMenuAt:4) shortcutKeyAt:3 put:#Copy. |
131 |
s1 shortcutKeyAt:1 put:#Copy. |
|
132 |
s1 shortcutKeyAt:3 put:#Paste. |
|
133 |
||
436 | 134 |
mview subMenuAt:2 put:(MenuPanel labels:labels). |
616 | 135 |
top extent:(mview preferredExtent). |
388 | 136 |
top open. |
2219 | 137 |
[exEnd] |
138 |
||
139 |
[exBegin] |
|
1767 | 140 |
|top menu view item| |
141 |
||
142 |
top := StandardSystemView extent:240@100. |
|
143 |
menu := MenuPanel in:top. |
|
144 |
menu labels:#( 'foo' 'Application' 'Clock' ). |
|
145 |
menu verticalLayout:false. |
|
146 |
||
147 |
menu subMenuAt:1 put:(MenuPanel labels:#( 'bar' 'baz' )). |
|
148 |
menu subMenuAt:2 put:(MenuPanel labels:#( 'foo' 'bar' 'baz' )). |
|
149 |
||
150 |
view := ClockView new. |
|
151 |
view preferredExtent:100@100. |
|
152 |
item := menu itemAt:3. |
|
153 |
item submenu:view. |
|
154 |
||
155 |
view := SimpleView new. |
|
156 |
view client:(CodingExamples_GUI::GUIDemoExtendedComboBox new). |
|
157 |
view preferredExtent:(400@50). |
|
158 |
item := menu itemAt:2. |
|
159 |
item submenu:view. |
|
160 |
||
161 |
menu origin:0@0 corner:1.0@30. |
|
162 |
top open. |
|
2219 | 163 |
[exEnd] |
388 | 164 |
|
165 |
||
166 |
start as PopUpMenu |
|
2219 | 167 |
[exBegin] |
388 | 168 |
|subView mview desc s1 s2 s3 img lbs labels| |
169 |
||
436 | 170 |
mview := MenuPanel new. |
502 | 171 |
labels := #( 'foo' 'bar' 'baz' ). |
388 | 172 |
mview level:2. |
173 |
||
174 |
img := Image fromFile:'bitmaps/SBrowser.xbm'. |
|
502 | 175 |
lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'. |
388 | 176 |
mview labels:lbs. |
177 |
||
436 | 178 |
s1 := MenuPanel labels:labels. |
179 |
s2 := MenuPanel labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ). |
|
180 |
s3 := MenuPanel labels:lbs. |
|
388 | 181 |
s1 subMenuAt:2 put:s2. |
436 | 182 |
s1 subMenuAt:3 put:(MenuPanel labels:lbs). |
388 | 183 |
s2 subMenuAt:3 put:s3. |
436 | 184 |
s3 subMenuAt:3 put:(MenuPanel labels:labels). |
388 | 185 |
s3 shortcutKeyAt:3 put:$q. |
186 |
||
187 |
mview subMenuAt:1 put:s1. |
|
436 | 188 |
mview subMenuAt:4 put:(MenuPanel labels:lbs). |
388 | 189 |
(mview subMenuAt:4) shortcutKeyAt:3 put:#Copy. |
190 |
s1 shortcutKeyAt:1 put:#Copy. |
|
191 |
s1 shortcutKeyAt:3 put:#Paste. |
|
192 |
||
436 | 193 |
mview subMenuAt:2 put:(MenuPanel labels:labels). |
388 | 194 |
mview startUp |
2219 | 195 |
[exEnd] |
388 | 196 |
|
197 |
||
198 |
start from menu spec |
|
2219 | 199 |
[exBegin] |
388 | 200 |
|menu| |
201 |
||
436 | 202 |
menu := MenuPanel menu: |
2219 | 203 |
#(#Menu #( #(#MenuItem |
204 |
#label: 'File' |
|
205 |
#submenu: |
|
206 |
#(#Menu #(#(#MenuItem #label: 'quit' #value:#quit ) |
|
207 |
(#MenuItem |
|
208 |
#label: 'edit' |
|
209 |
#submenu: |
|
210 |
#(#Menu #( #(#MenuItem #label: 'edit' #value:#edit ) |
|
211 |
#(#MenuItem #label: 'close' #value:#close) |
|
212 |
) |
|
213 |
nil |
|
214 |
nil |
|
215 |
) |
|
216 |
) |
|
217 |
#(#MenuItem #label: 'help' #value:#help ) |
|
218 |
) |
|
219 |
nil |
|
220 |
nil |
|
221 |
) |
|
222 |
) |
|
223 |
#(#MenuItem #label: 'Inspect' #value:#inspectMenu ) |
|
224 |
#(#MenuItem #label: 'Bar' |
|
225 |
#submenu: |
|
226 |
#(#Menu #( #(#MenuItem #label: 'bar 1' #value:#bar1 ) |
|
227 |
#(#MenuItem #label: 'bar 2' #value:#bar2 ) |
|
228 |
) |
|
229 |
nil |
|
230 |
nil |
|
231 |
) |
|
232 |
) |
|
233 |
) |
|
234 |
#( 2 ) |
|
235 |
nil |
|
236 |
) decodeAsLiteralArray. |
|
388 | 237 |
|
238 |
menu verticalLayout:false. |
|
239 |
Transcript showCR:(menu startUp). |
|
2219 | 240 |
[exEnd] |
388 | 241 |
|
242 |
" |
|
243 |
||
244 |
! ! |
|
245 |
||
246 |
!MenuPanel class methodsFor:'instance creation'! |
|
247 |
||
248 |
fromSpec:aSpec |
|
249 |
^ self fromSpec:aSpec receiver:nil |
|
250 |
! |
|
251 |
||
252 |
fromSpec:aSpec receiver:aReceiver |
|
253 |
|menu| |
|
254 |
||
255 |
aSpec notNil ifTrue:[ |
|
2219 | 256 |
menu := Menu new. |
257 |
menu receiver:aReceiver. |
|
258 |
menu fromLiteralArrayEncoding:aSpec. |
|
388 | 259 |
]. |
260 |
^ self menu:menu receiver:aReceiver |
|
261 |
! |
|
262 |
||
263 |
labels:labels |
|
264 |
^ self labels:labels nameKeys:nil receiver:nil |
|
265 |
! |
|
266 |
||
267 |
labels:labels nameKeys:nameKeys |
|
268 |
^ self labels:labels nameKeys:nameKeys receiver:nil |
|
269 |
! |
|
270 |
||
271 |
labels:labels nameKeys:nameKeys receiver:aReceiver |
|
272 |
|mview| |
|
273 |
||
274 |
mview := self menu:nil receiver:aReceiver. |
|
275 |
mview labels:labels. |
|
276 |
mview nameKeys:nameKeys. |
|
277 |
^ mview |
|
278 |
||
279 |
! |
|
280 |
||
502 | 281 |
labels:labels receiver:aReceiver |
282 |
^ self labels:labels nameKeys:nil receiver:aReceiver |
|
283 |
! |
|
284 |
||
388 | 285 |
menu:aMenu |
286 |
^ self menu:aMenu receiver:nil |
|
287 |
! |
|
288 |
||
289 |
menu:aMenu receiver:aReceiver |
|
290 |
|mview| |
|
291 |
||
292 |
mview := self new. |
|
1955 | 293 |
|
294 |
(aMenu notNil and:[aMenu receiver isNil]) ifTrue:[ |
|
2219 | 295 |
"/ no receiver specified in the menu; thus set the receiver immediately |
296 |
mview receiver:aReceiver |
|
1955 | 297 |
]. |
298 |
||
388 | 299 |
mview menu:aMenu. |
300 |
||
1955 | 301 |
|
388 | 302 |
"/ a menu itself may contain a receiver |
303 |
"/ thus we do not overwrite the receiver |
|
304 |
||
305 |
aReceiver notNil ifTrue:[ |
|
2219 | 306 |
mview receiver:aReceiver |
388 | 307 |
]. |
308 |
^ mview |
|
309 |
! ! |
|
310 |
||
311 |
!MenuPanel class methodsFor:'class initialization'! |
|
312 |
||
313 |
initialize |
|
657 | 314 |
" |
315 |
DefaultAdornment := nil. |
|
316 |
self initialize |
|
317 |
" |
|
318 |
||
388 | 319 |
InitialSelectionQuerySignal isNil ifTrue:[ |
2145 | 320 |
InitialSelectionQuerySignal := QuerySignal new. |
388 | 321 |
]. |
390 | 322 |
|
388 | 323 |
DefaultAdornment isNil ifTrue:[ |
2145 | 324 |
DefaultAdornment := IdentityDictionary new |
325 |
at:#showSeparatingLines put:false; |
|
326 |
at:#showGroupDivider put:true; |
|
327 |
at:#verticalLayout put:true; |
|
328 |
at:#item put:nil; |
|
329 |
at:#value put:nil; |
|
330 |
yourself |
|
388 | 331 |
]. |
332 |
||
660
d1670dfe5445
Do not call #updateStyleCache from #initialize.
Stefan Vogel <sv@exept.de>
parents:
658
diff
changeset
|
333 |
"Modified: / 15.1.1998 / 23:08:31 / stefan" |
794 | 334 |
! |
335 |
||
336 |
preSnapshot |
|
337 |
"remove all resources |
|
338 |
" |
|
339 |
Images := nil. |
|
340 |
LigthenedImages := nil. |
|
341 |
||
616 | 342 |
! ! |
343 |
||
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
344 |
!MenuPanel class methodsFor:'default icons'! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
345 |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
346 |
iconIndicationDisabledOff |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
347 |
"This resource specification was automatically generated |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
348 |
by the ImageEditor of ST/X." |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
349 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
350 |
"Do not manually edit this!! If it is corrupted, |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
351 |
the ImageEditor may not be able to read the specification." |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
352 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
353 |
" |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
354 |
self iconIndicationDisabledOff inspect |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
355 |
ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOff |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
356 |
" |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
357 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
358 |
<resource: #image> |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
359 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
360 |
^Icon |
2219 | 361 |
constantNamed:#'MenuPanel iconIndicationDisabledOff' |
362 |
ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUPG???8A:***@^*** G***(A:***@^*** G***(A:***@^*** G***(A:***@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] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
363 |
! |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
364 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
365 |
iconIndicationDisabledOn |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
366 |
"This resource specification was automatically generated |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
367 |
by the ImageEditor of ST/X." |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
368 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
369 |
"Do not manually edit this!! If it is corrupted, |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
370 |
the ImageEditor may not be able to read the specification." |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
371 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
372 |
" |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
373 |
self iconIndicationDisabledOn inspect |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
374 |
ImageEditor openOnClass:self andSelector:#iconIndicationDisabledOn |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
375 |
" |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
376 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
377 |
<resource: #image> |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
378 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
379 |
^Icon |
2219 | 380 |
constantNamed:#'MenuPanel iconIndicationDisabledOn' |
381 |
ifAbsentPut:[(Depth2Image new) width: 14; height: 14; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'****$H@@@MBO???P#???4H??<=BO?<OP#O<C4H0<C=BL@C?P#0C?4H?C?=BO???P/???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] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
382 |
! |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
383 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
384 |
iconIndicationOff |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
385 |
"This resource specification was automatically generated |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
386 |
by the ImageEditor of ST/X." |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
387 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
388 |
"Do not manually edit this!! If it is corrupted, |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
389 |
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
|
390 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
391 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
392 |
self iconIndicationOff inspect |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
393 |
ImageEditor openOnClass:self andSelector:#iconIndicationOff |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
394 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
395 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
396 |
<resource: #image> |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
397 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
398 |
^Icon |
2219 | 399 |
constantNamed:#'MenuPanel iconIndicationOff' |
400 |
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] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
401 |
! |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
402 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
403 |
iconIndicationOn |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
404 |
"This resource specification was automatically generated |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
405 |
by the ImageEditor of ST/X." |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
406 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
407 |
"Do not manually edit this!! If it is corrupted, |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
408 |
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
|
409 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
410 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
411 |
self iconIndicationOn inspect |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
412 |
ImageEditor openOnClass:self andSelector:#iconIndicationOn |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
413 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
414 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
415 |
<resource: #image> |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
416 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
417 |
^Icon |
2219 | 418 |
constantNamed:#'MenuPanel iconIndicationOn' |
419 |
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] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
420 |
! |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
421 |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
422 |
iconRadioGroupDisabledOff |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
423 |
"This resource specification was automatically generated |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
424 |
by the ImageEditor of ST/X." |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
425 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
426 |
"Do not manually edit this!! If it is corrupted, |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
427 |
the ImageEditor may not be able to read the specification." |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
428 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
429 |
" |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
430 |
self iconRadioGroupDisabledOff inspect |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
431 |
ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOff |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
432 |
" |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
433 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
434 |
<resource: #image> |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
435 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
436 |
^Icon |
2219 | 437 |
constantNamed:#'MenuPanel iconRadioGroupDisabledOff' |
438 |
ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DJ*Y@DZ**(AJ**+AJ***LR***#D***(1J***LR***#AZ**#@Z**(0A** 0@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] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
439 |
! |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
440 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
441 |
iconRadioGroupDisabledOn |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
442 |
"This resource specification was automatically generated |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
443 |
by the ImageEditor of ST/X." |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
444 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
445 |
"Do not manually edit this!! If it is corrupted, |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
446 |
the ImageEditor may not be able to read the specification." |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
447 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
448 |
" |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
449 |
self iconRadioGroupDisabledOn inspect |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
450 |
ImageEditor openOnClass:self andSelector:#iconRadioGroupDisabledOn |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
451 |
" |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
452 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
453 |
<resource: #image> |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
454 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
455 |
^Icon |
2219 | 456 |
constantNamed:#'MenuPanel iconRadioGroupDisabledOn' |
457 |
ifAbsentPut:[(Depth2Image new) width: 15; height: 15; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@AUP@@E@AP@DJ*Y@DY@Z(AH@@+AI@@FLR@@@#D @@H1H@@BLRP@A#AX@@#@Z$A(0A** 0@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] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
458 |
! |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
459 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
460 |
iconRadioGroupOff |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
461 |
"This resource specification was automatically generated |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
462 |
by the ImageEditor of ST/X." |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
463 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
464 |
"Do not manually edit this!! If it is corrupted, |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
465 |
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
|
466 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
467 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
468 |
self iconRadioGroupOff inspect |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
469 |
ImageEditor openOnClass:self andSelector:#iconRadioGroupOff |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
470 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
471 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
472 |
<resource: #image> |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
473 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
474 |
^Icon |
2219 | 475 |
constantNamed:#'MenuPanel iconRadioGroupOff' |
476 |
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] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
477 |
! |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
478 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
479 |
iconRadioGroupOn |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
480 |
"This resource specification was automatically generated |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
481 |
by the ImageEditor of ST/X." |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
482 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
483 |
"Do not manually edit this!! If it is corrupted, |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
484 |
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
|
485 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
486 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
487 |
self iconRadioGroupOn inspect |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
488 |
ImageEditor openOnClass:self andSelector:#iconRadioGroupOn |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
489 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
490 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
491 |
<resource: #image> |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
492 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
493 |
^Icon |
2219 | 494 |
constantNamed:#'MenuPanel iconRadioGroupOn' |
495 |
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] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
496 |
! ! |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
497 |
|
616 | 498 |
!MenuPanel class methodsFor:'defaults'! |
450 | 499 |
|
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
500 |
defaultBackgroundColor |
2219 | 501 |
^ StyleSheet at:#'menuPanel.backgroundColor' |
502 |
! |
|
503 |
||
504 |
defaultFont |
|
505 |
^ StyleSheet at:#'menu.font' |
|
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
506 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
507 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
508 |
defaultLevel |
2219 | 509 |
^ StyleSheet at:#'menuPanel.level' |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
510 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
511 |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
512 |
mnemonicIdentifier |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
513 |
"returns the identifier each mnemonic starts with; |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
514 |
ex: |
2219 | 515 |
&File mnemonic := Cmdf |
516 |
F&ile mnemonic := Cmdi |
|
517 |
..... |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
518 |
" |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
519 |
^ 'Cmd' |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
520 |
! |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
521 |
|
450 | 522 |
updateStyleCache |
657 | 523 |
|
2219 | 524 |
<resource: #style ( |
525 |
#'popup.borderWidth' #'popup.level' |
|
526 |
#'selection.disabledForegroundColor' |
|
527 |
#'pullDownMenu.foregroundColor' #'pullDownMenu.backgroundColor' #'pullDownMenu.level' |
|
528 |
#'menu.itemHorizontalSpace' #'menu.buttonItemHorizontalSpace' #'menu.buttonItemSpace' |
|
529 |
#'menu.buttonItemVerticalSpace' |
|
530 |
#'menu.buttonActiveLevel' #'menu.buttonPassiveLevel' #'menu.buttonEnteredLevel' |
|
531 |
#'menu.hilightLevel' #'menu.enteredLevel' |
|
532 |
#'menu.groupDividerSize' #'menu.itemMargin' |
|
533 |
#'menu.disabledEtchedForegroundColor' #'menu.hilightForegroundColor' |
|
534 |
#'menu.enteredBackgroundColor' #'menu.enteredForegroundColor' |
|
535 |
#'menu.disabledForegroundColor' #'menu.buttonEnteredBackgroundColor' |
|
536 |
#'menu.selectionFollowsMouse' |
|
537 |
#'button.disabledEtchedForegroundColor' #'button.disabledForegroundColor' |
|
538 |
#'button.activeBackgroundColor' #'button.backgroundColor' #'button.lightColor' |
|
539 |
#'button.enteredBackgroundColor' #'button.halfLightColor' #'button.halfShadowColor' |
|
540 |
#'button.activeLevel' #'button.passiveLevel' #'button.edgeStyle' |
|
541 |
)> |
|
542 |
||
543 |
|styleSheet style var foregroundColor backgroundColor buttonPassiveBackgroundColor |
|
544 |
buttonActiveLevel buttonPassiveLevel buttonEnteredLevel| |
|
545 |
" |
|
546 |
self updateStyleCache |
|
547 |
" |
|
548 |
MenuView updateStyleCache. |
|
549 |
SelectionInListView updateStyleCache. |
|
1699 | 550 |
|
551 |
styleSheet := StyleSheet. |
|
552 |
style := styleSheet name. |
|
553 |
||
2219 | 554 |
foregroundColor := styleSheet colorAt:#'pullDownMenu.foregroundColor' default:Color black. |
555 |
styleSheet at:#'menuPanel.foregroundColor' put:foregroundColor. |
|
556 |
||
557 |
backgroundColor := styleSheet colorAt:#'pullDownMenu.backgroundColor' default:DefaultViewBackgroundColor. |
|
558 |
styleSheet at:#'menuPanel.backgroundColor' put:backgroundColor. |
|
559 |
||
560 |
var := styleSheet at:#'menu.buttonItemHorizontalSpace'. |
|
561 |
var ifNil:[ var := styleSheet at:#'menu.buttonItemSpace' default:0 ]. |
|
562 |
styleSheet at:#'menuPanel.buttonInsetX' put:(var abs). |
|
563 |
||
564 |
var := styleSheet at:#'menu.buttonItemVerticalSpace'. |
|
565 |
var ifNil:[ var := styleSheet at:#'menu.buttonItemSpace' default:0 ]. |
|
566 |
styleSheet at:#'menuPanel.buttonInsetY' put:(var abs). |
|
567 |
||
568 |
var := styleSheet at:#'menuPanel.level' default:nil. |
|
569 |
var isNil ifTrue:[ var := styleSheet at:#'pullDownMenu.level' default:1 ]. |
|
570 |
styleSheet at:#'menuPanel.level' put:var. |
|
571 |
||
572 |
var := styleSheet at:#'menu.itemHorizontalSpace'. |
|
573 |
var ifNil:[ var := styleSheet at:#'menu.itemSpace' default:0 ]. |
|
574 |
styleSheet at:#'menuPanel.itemSpace' put:var. |
|
575 |
||
576 |
var := styleSheet colorAt:#'menu.hilightBackgroundColor'. |
|
577 |
var ifNil:[ |
|
578 |
style == #motif ifTrue:[ var := backgroundColor ] |
|
579 |
ifFalse:[ var := styleSheet is3D ifFalse:[foregroundColor] ifTrue:[backgroundColor] ] |
|
580 |
]. |
|
581 |
styleSheet at:#'menuPanel.activeBackgroundColor' put:var. |
|
582 |
||
583 |
var := styleSheet colorAt:#'menu.disabledEtchedForegroundColor'. |
|
584 |
var ifNil:[ var := styleSheet colorAt:#'button.disabledEtchedForegroundColor' ]. |
|
585 |
styleSheet at:#'menuPanel.disabledEtchedFgColor' put:var. |
|
586 |
||
587 |
var := styleSheet colorAt:#'menu.disabledForegroundColor'. |
|
588 |
var ifNil:[ |
|
589 |
var := styleSheet colorAt:#'selection.disabledForegroundColor'. |
|
590 |
var ifNil:[ var := styleSheet colorAt:#'button.disabledForegroundColor' default:Color darkGray ] |
|
591 |
]. |
|
592 |
styleSheet at:#'menuPanel.disabledForegroundColor' put:var. |
|
593 |
||
594 |
var := styleSheet colorAt:#'menu.hilightForegroundColor'. |
|
595 |
var ifNil:[ var := styleSheet is3D ifTrue:[foregroundColor] ifFalse:[backgroundColor] ]. |
|
596 |
styleSheet at:#'menuPanel.activeForegroundColor' put:var. |
|
597 |
||
598 |
||
599 |
buttonActiveLevel := styleSheet at:#'menu.buttonActiveLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]). |
|
600 |
buttonActiveLevel ifNil:[ buttonActiveLevel := styleSheet at:#'button.activeLevel' default:(styleSheet is3D ifTrue:[-2] ifFalse:[0]) ]. |
|
601 |
styleSheet at:#'menuPanel.buttonActiveLevel' put:buttonActiveLevel. |
|
602 |
||
603 |
buttonPassiveLevel := styleSheet at:#'menu.buttonPassiveLevel'. |
|
604 |
buttonPassiveLevel ifNil:[ buttonPassiveLevel := styleSheet at:#'button.passiveLevel' default:(styleSheet is3D ifTrue:[2] ifFalse:[0])]. |
|
605 |
styleSheet at:#'menuPanel.buttonPassiveLevel' put:buttonPassiveLevel. |
|
606 |
||
607 |
buttonEnteredLevel := styleSheet at:#'menu.buttonEnteredLevel' default:buttonPassiveLevel. |
|
608 |
styleSheet at:#'menuPanel.buttonEnteredLevel' put:buttonEnteredLevel. |
|
609 |
||
610 |
var := (buttonActiveLevel abs max:(buttonPassiveLevel abs)) max:(buttonEnteredLevel abs). |
|
611 |
styleSheet at:#'menuPanel.maxAbsoluteButtonLevel' put:var. |
|
612 |
||
613 |
buttonPassiveBackgroundColor := styleSheet at:#'button.backgroundColor'. |
|
614 |
buttonPassiveBackgroundColor ifNil:[ |
|
615 |
buttonPassiveBackgroundColor := (styleSheet at:'viewBackground') ? backgroundColor |
|
616 |
]. |
|
617 |
styleSheet at:#'menuPanel.buttonPassiveBackgroundColor' put:buttonPassiveBackgroundColor. |
|
618 |
||
619 |
var := styleSheet at:#'button.lightColor'. |
|
620 |
var ifNil:[ var := (buttonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) lightened ]. |
|
621 |
styleSheet at:#'menuPanel.buttonLightColor' put:var. |
|
622 |
||
623 |
var := styleSheet at:#'button.shadowColor'. |
|
624 |
var ifNil:[ var := (buttonPassiveBackgroundColor averageColorIn:(0@0 corner:7@7)) darkened ]. |
|
625 |
styleSheet at:#'menuPanel.buttonShadowColor' put:var. |
|
626 |
||
627 |
var := styleSheet colorAt:#'menu.buttonEnteredBackgroundColor'. |
|
628 |
var ifNil:[ var := styleSheet colorAt:#'button.enteredBackgroundColor' default:buttonPassiveBackgroundColor ]. |
|
629 |
styleSheet at:#'menuPanel.buttonEnteredBackgroundColor' put:var. |
|
630 |
||
631 |
Item updateStyleCache. |
|
388 | 632 |
! ! |
633 |
||
794 | 634 |
!MenuPanel class methodsFor:'image registration'! |
635 |
||
636 |
image:anImage onDevice:aDevice |
|
637 |
" |
|
638 |
Images := nil |
|
639 |
" |
|
1097 | 640 |
|deviceImages image| |
794 | 641 |
|
1156
6fa33dc93509
fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents:
1151
diff
changeset
|
642 |
anImage device == aDevice ifTrue:[ |
2219 | 643 |
^ anImage |
1853
399e2eac3b99
Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents:
1841
diff
changeset
|
644 |
]. |
399e2eac3b99
Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents:
1841
diff
changeset
|
645 |
|
399e2eac3b99
Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents:
1841
diff
changeset
|
646 |
Images isNil ifTrue:[ Images := WeakIdentityDictionary new ]. |
794 | 647 |
|
1097 | 648 |
(deviceImages := Images at:aDevice ifAbsent:nil) isNil ifTrue:[ |
2219 | 649 |
Images at:aDevice put:(deviceImages := Dictionary new) |
1097 | 650 |
]. |
651 |
||
652 |
(image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[ |
|
2219 | 653 |
^ image |
794 | 654 |
]. |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
655 |
|
794 | 656 |
image := anImage copy onDevice:aDevice. |
657 |
image clearMaskedPixels. |
|
1097 | 658 |
deviceImages at:anImage put:image. |
794 | 659 |
^ image |
660 |
||
1156
6fa33dc93509
fix to avoid repeated image>>onDevice
Claus Gittinger <cg@exept.de>
parents:
1151
diff
changeset
|
661 |
"Modified: / 29.9.1998 / 12:02:41 / cg" |
794 | 662 |
! |
663 |
||
664 |
lightenedImage:anImage onDevice:aDevice |
|
665 |
" |
|
666 |
LigthenedImages := nil |
|
667 |
" |
|
1097 | 668 |
|deviceImages image| |
794 | 669 |
|
1853
399e2eac3b99
Use WeakIdentityDictionaries to cache images per Workstation.
Stefan Vogel <sv@exept.de>
parents:
1841
diff
changeset
|
670 |
LigthenedImages isNil ifTrue:[ LigthenedImages := WeakIdentityDictionary new ]. |
794 | 671 |
|
1097 | 672 |
(deviceImages := LigthenedImages at:aDevice ifAbsent:nil) isNil ifTrue:[ |
2219 | 673 |
LigthenedImages at:aDevice put:(deviceImages := Dictionary new) |
1097 | 674 |
]. |
675 |
||
676 |
(image := deviceImages at:anImage ifAbsent:nil) notNil ifTrue:[ |
|
2219 | 677 |
^ image |
794 | 678 |
]. |
679 |
||
680 |
((anImage respondsTo:#colorMap) and:[anImage colorMap notNil]) ifTrue:[ |
|
2219 | 681 |
image := anImage copy lightened onDevice:aDevice. |
682 |
image clearMaskedPixels. |
|
794 | 683 |
] ifFalse:[ |
2219 | 684 |
image := self image:anImage onDevice:aDevice |
794 | 685 |
]. |
1097 | 686 |
deviceImages at:anImage put:image. |
794 | 687 |
^ image |
688 |
||
689 |
||
690 |
! ! |
|
691 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
692 |
!MenuPanel class methodsFor:'private'! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
693 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
694 |
subMenu:aSubMenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
695 |
"create a submenu; can be redifined in derived classes |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
696 |
" |
1063
08b7ca464437
dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
697 |
^ (self new) menu:aSubMenu. |
08b7ca464437
dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
698 |
|
08b7ca464437
dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
699 |
"Modified: / 8.8.1998 / 02:13:11 / cg" |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
700 |
! ! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
701 |
|
2219 | 702 |
!MenuPanel methodsFor:'a zeige claus'! |
703 |
||
704 |
superMenu:aSuperMenu |
|
705 |
"set my supermenu from which i'am activated |
|
706 |
" |
|
707 |
superMenu := aSuperMenu. |
|
708 |
||
709 |
superMenu ifNotNil:[ |
|
710 |
styleSheet := superMenu styleSheet. |
|
711 |
rightArrow := superMenu rightArrow. |
|
712 |
rightArrowShadow := superMenu rightArrowShadow. |
|
713 |
]. |
|
714 |
! ! |
|
715 |
||
1808 | 716 |
!MenuPanel methodsFor:'accepting'! |
389 | 717 |
|
718 |
accept |
|
719 |
"accept current selected item |
|
720 |
" |
|
1670 | 721 |
^ self acceptItem:(self selection) inMenu:self |
389 | 722 |
! |
723 |
||
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
724 |
accept:anItem |
389 | 725 |
"this is the topMenu: accept item |
726 |
" |
|
2050
ef5517d7a2d0
do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents:
2048
diff
changeset
|
727 |
|value item tgState itemIdx recv panel masterGroup winGrp acceptAction| |
1630 | 728 |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
729 |
self superMenu notNil ifTrue:[ |
2219 | 730 |
^ self topMenu accept:anItem |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
731 |
]. |
2199 | 732 |
self openDelayed:nil. |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
733 |
self scrollActivity stop. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
734 |
self selection:nil. |
420 | 735 |
|
736 |
(anItem notNil and:[anItem canAccept]) ifTrue:[ |
|
2219 | 737 |
tgState := anItem toggleIndication. |
738 |
panel := anItem menuPanel. |
|
739 |
itemIdx := panel findFirst:[:el| el == anItem ]. |
|
740 |
item := anItem. |
|
741 |
recv := panel receiver. |
|
389 | 742 |
]. |
1699 | 743 |
self doUngrab:true. |
389 | 744 |
|
510 | 745 |
self isPopUpView ifFalse:[ |
2219 | 746 |
self do:[:el| el updateIndicators]. |
747 |
self windowGroup processExposeEvents. |
|
524 | 748 |
] ifTrue:[ |
2219 | 749 |
self unmap. |
750 |
(winGrp := self windowGroup) notNil ifTrue:[ |
|
751 |
"/ give expose event a chance to arrive |
|
752 |
[shown and:[realized]] whileTrue:[ |
|
753 |
winGrp processExposeEventsFor:self |
|
754 |
]. |
|
755 |
masterGroup := winGrp previousGroup. |
|
756 |
]. |
|
757 |
"/ cg: disabled-not needed - try PopUpList with destroy... |
|
758 |
"/ self destroy. |
|
759 |
masterGroup notNil ifTrue:[masterGroup processExposeEvents]. |
|
524 | 760 |
]. |
1710 | 761 |
|
2050
ef5517d7a2d0
do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents:
2048
diff
changeset
|
762 |
acceptAction := [ value := self accept:item index:itemIdx toggle:tgState receiver:recv ]. |
ef5517d7a2d0
do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents:
2048
diff
changeset
|
763 |
|
1710 | 764 |
(item notNil |
765 |
and:[item showBusyCursorWhilePerforming |
|
766 |
and:[(winGrp := (masterGroup ? (self windowGroup))) notNil]]) |
|
767 |
ifTrue:[ |
|
2219 | 768 |
winGrp withWaitCursorDo:acceptAction |
2132 | 769 |
] ifFalse:[acceptAction value]. |
524 | 770 |
|
771 |
self isPopUpView ifTrue:[ |
|
2219 | 772 |
self menuAdornmentAt:#value put:value. |
773 |
self menuAdornmentAt:#item put:item. |
|
524 | 774 |
]. |
1699 | 775 |
^ item. |
524 | 776 |
|
2050
ef5517d7a2d0
do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents:
2048
diff
changeset
|
777 |
"Modified: / 15.11.2001 / 17:05:40 / cg" |
524 | 778 |
! |
779 |
||
780 |
accept:anItem index:anIndex toggle:aState receiver:aReceiver |
|
781 |
"accept an item |
|
782 |
" |
|
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
783 |
|value argument numArgs isKindOfValueModel rec args arg2 |
1697
345d3664e10c
added 'showBusyCursorWhileActive' attribute
Claus Gittinger <cg@exept.de>
parents:
1695
diff
changeset
|
784 |
app master fallBack| |
524 | 785 |
|
786 |
anItem isNil ifTrue:[ |
|
2219 | 787 |
self menuAdornmentAt:#hasPerformed put:true. |
788 |
^ nil |
|
524 | 789 |
]. |
790 |
||
1219
6a0d677a6fac
removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents:
1218
diff
changeset
|
791 |
self menuAdornmentAt:#hasPerformed put:(aReceiver isValueModel). |
524 | 792 |
|
793 |
(value := anItem value) isNil ifTrue:[ |
|
2219 | 794 |
^ anIndex |
524 | 795 |
]. |
796 |
||
797 |
(argument := anItem argument) isNil ifTrue:[ |
|
2219 | 798 |
argument := aState ? anItem |
389 | 799 |
]. |
524 | 800 |
|
801 |
value isSymbol ifFalse:[ |
|
2219 | 802 |
"/ a valueHolder or block |
803 |
(value respondsTo:#valueWithArguments:) ifFalse:[ |
|
804 |
^ value |
|
805 |
]. |
|
806 |
||
807 |
numArgs := value perform:#numArgs ifNotUnderstood:0. |
|
808 |
||
809 |
numArgs == 0 ifTrue:[ |
|
810 |
args := nil |
|
811 |
] ifFalse:[ |
|
812 |
numArgs == 1 ifTrue:[ |
|
813 |
args := Array with:argument |
|
814 |
] ifFalse:[ |
|
815 |
args := Array with:argument with:self |
|
816 |
] |
|
817 |
]. |
|
818 |
||
819 |
value valueWithArguments:args. |
|
820 |
||
821 |
self menuAdornmentAt:#hasPerformed put:true. |
|
822 |
^ anIndex |
|
524 | 823 |
]. |
824 |
||
825 |
aReceiver isNil ifTrue:[ |
|
2219 | 826 |
^ value |
524 | 827 |
]. |
1270
0ae582fd7294
send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents:
1267
diff
changeset
|
828 |
|
1219
6a0d677a6fac
removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents:
1218
diff
changeset
|
829 |
isKindOfValueModel := aReceiver isValueModel. |
1270
0ae582fd7294
send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents:
1267
diff
changeset
|
830 |
isKindOfValueModel ifTrue:[ |
2219 | 831 |
aReceiver value:value |
465 | 832 |
] ifFalse:[ |
2219 | 833 |
rec := aReceiver. |
834 |
arg2 := self. |
|
835 |
||
836 |
"/ support for ST80 style applications |
|
837 |
"/ (expecting the message to go to the application |
|
838 |
"/ if not understood by the view) |
|
839 |
"/ These expect the controller to be passed as argument. |
|
840 |
"/ sigh. |
|
841 |
||
842 |
(aReceiver isView |
|
843 |
and:[(aReceiver respondsTo:value) not |
|
844 |
and:[(app := aReceiver application) ~~ aReceiver |
|
845 |
and:[app notNil]]]) ifTrue:[ |
|
846 |
rec := app. |
|
847 |
arg2 := aReceiver controller "/ the Views controller |
|
848 |
]. |
|
849 |
||
850 |
(numArgs := value numArgs) == 0 ifTrue:[ |
|
851 |
args := nil |
|
852 |
] ifFalse:[ |
|
853 |
numArgs == 1 ifTrue:[ |
|
854 |
args := Array with:argument |
|
855 |
] ifFalse:[ |
|
856 |
args := Array with:argument with:arg2 |
|
857 |
] |
|
858 |
]. |
|
859 |
||
860 |
fallBack := |
|
861 |
[ |
|
862 |
"/ mhmh - the receiver did not respond to that message; |
|
863 |
"/ if there is a master-application, try that one |
|
864 |
"/ (recursive) |
|
865 |
master := rec perform:#masterApplication ifNotUnderstood:nil. |
|
866 |
master notNil ifTrue:[ |
|
867 |
rec := master. |
|
868 |
rec perform:value withArguments:args ifNotUnderstood:fallBack |
|
869 |
] ifFalse:[ |
|
870 |
self |
|
871 |
error:'unimplemented (or error in) menu message: ' , value |
|
872 |
mayProceed:true |
|
873 |
]. |
|
874 |
]. |
|
875 |
||
876 |
rec perform:value withArguments:args ifNotUnderstood:fallBack. |
|
420 | 877 |
]. |
524 | 878 |
self menuAdornmentAt:#hasPerformed put:true. |
1270
0ae582fd7294
send menuMessage to application,
Claus Gittinger <cg@exept.de>
parents:
1267
diff
changeset
|
879 |
^ value |
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
880 |
|
1719
ba7ebb56e6fd
recursively try masterApps when performing
Claus Gittinger <cg@exept.de>
parents:
1715
diff
changeset
|
881 |
"Modified: / 19.2.2000 / 11:08:22 / cg" |
389 | 882 |
! |
883 |
||
1670 | 884 |
acceptItem:anItem inMenu:aMenu |
2199 | 885 |
|tgState topMenu| |
886 |
||
887 |
topMenu := self topMenu. |
|
888 |
topMenu openDelayed:nil. |
|
1670 | 889 |
|
1841 | 890 |
(anItem isNil or:[anItem hideMenuOnActivated]) ifTrue:[ |
2219 | 891 |
topMenu accept:anItem |
1670 | 892 |
] ifFalse:[ |
2219 | 893 |
anItem canAccept ifTrue:[ |
894 |
tgState := anItem toggleIndication. |
|
895 |
||
896 |
self accept:anItem |
|
897 |
index:(aMenu selectionIndex) |
|
898 |
toggle:tgState |
|
899 |
receiver:(aMenu receiver). |
|
900 |
||
901 |
aMenu do:[:el| el updateIndicators]. |
|
902 |
] |
|
1670 | 903 |
] |
904 |
! |
|
905 |
||
389 | 906 |
lastItemAccepted |
907 |
"returns last item selected or nil |
|
908 |
" |
|
390 | 909 |
^ self topMenu menuAdornmentAt:#item |
389 | 910 |
! |
911 |
||
912 |
lastValueAccepted |
|
913 |
"returns last value accepted or nil |
|
914 |
" |
|
971 | 915 |
^ (self lastItemAccepted) value |
916 |
"/ |top| |
|
917 |
"/ |
|
918 |
"/ top := self topMenu. |
|
919 |
"/ |
|
920 |
"/ (top menuAdornmentAt:#hasPerformed) == true ifTrue:[ |
|
921 |
"/ ^ self topMenu menuAdornmentAt:#value. |
|
922 |
"/ ]. |
|
923 |
"/ ^ nil |
|
924 |
||
925 |
"Modified: / 18.6.1998 / 23:37:09 / cg" |
|
389 | 926 |
! ! |
927 |
||
388 | 928 |
!MenuPanel methodsFor:'accessing'! |
929 |
||
930 |
accessCharacterPositionAt:stringOrNumber |
|
390 | 931 |
"get the access character position for a textLabel |
388 | 932 |
" |
2059 | 933 |
^ self itemAt:stringOrNumber do:[:el| el accessCharacterPosition ] |
388 | 934 |
! |
935 |
||
936 |
accessCharacterPositionAt:stringOrNumber put:anIndexOrNil |
|
390 | 937 |
"get the access character position for a textLabel |
388 | 938 |
" |
939 |
self itemAt:stringOrNumber do:[:el| el accessCharacterPosition:anIndexOrNil ] |
|
940 |
! |
|
941 |
||
942 |
accessCharacterPositions |
|
943 |
"returns a collection of accessCharacterPosition's or nil |
|
944 |
" |
|
945 |
^ self collect:[:anItem| anItem accessCharacterPosition ] |
|
946 |
||
947 |
! |
|
948 |
||
949 |
accessCharacterPositions:something |
|
950 |
"define accessCharacterPosition's for each item |
|
951 |
" |
|
952 |
self onEachPerform:#accessCharacterPosition: withArgList:something |
|
953 |
! |
|
954 |
||
955 |
args |
|
956 |
"returns a collection of argument's or nil |
|
957 |
" |
|
958 |
^ self collect:[:anItem| anItem argument ] |
|
959 |
! |
|
960 |
||
961 |
args:something |
|
962 |
"define arguments for each item |
|
963 |
" |
|
964 |
self onEachPerform:#argument: withArgList:something |
|
965 |
! |
|
966 |
||
967 |
argsAt:stringOrNumber |
|
968 |
"gets the argument of an item or nil |
|
969 |
" |
|
2059 | 970 |
^ self itemAt:stringOrNumber do:[:el| el argument ] |
388 | 971 |
! |
972 |
||
973 |
argsAt:stringOrNumber put:anArgument |
|
974 |
"sets the argument of an item |
|
975 |
" |
|
976 |
self itemAt:stringOrNumber do:[:el| el argument:anArgument ] |
|
977 |
! |
|
978 |
||
1081
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
979 |
enteredItem |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
980 |
"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
|
981 |
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
|
982 |
|
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
983 |
^ enteredItem |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
984 |
|
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
985 |
"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
|
986 |
! |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
987 |
|
388 | 988 |
groupSizes |
989 |
"gets collection of group sizes |
|
990 |
" |
|
991 |
^ groupSizes |
|
992 |
! |
|
993 |
||
994 |
groupSizes:aGroupSizes |
|
995 |
"sets collection of group sizes |
|
996 |
" |
|
997 |
aGroupSizes = groupSizes ifFalse:[ |
|
2145 | 998 |
groupSizes := aGroupSizes copy. |
999 |
self mustRearrange. |
|
388 | 1000 |
]. |
1001 |
! |
|
1002 |
||
1003 |
labelAt:stringOrNumber |
|
1004 |
"gets the label of an item or nil |
|
1005 |
" |
|
1006 |
^ self itemAt:stringOrNumber do:[:el| el label ] |
|
1007 |
! |
|
1008 |
||
1009 |
labelAt:stringOrNumber put:aLabel |
|
1010 |
"sets the label of an item |
|
1011 |
" |
|
1012 |
self itemAt:stringOrNumber do:[:el| el label:aLabel ] |
|
1013 |
! |
|
1014 |
||
1015 |
labels |
|
1016 |
"returns a collection of labels's or nil |
|
1017 |
" |
|
1018 |
^ self collect:[:anItem| anItem label ] |
|
1019 |
||
1020 |
! |
|
1021 |
||
1022 |
labels:labels |
|
1023 |
"define labels for each item |
|
1024 |
" |
|
2118
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
1025 |
|size| |
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
1026 |
|
388 | 1027 |
self disabledRedrawDo:[ |
2219 | 1028 |
self removeAll. |
1029 |
size := labels size. |
|
1030 |
||
1031 |
size > 0 ifTrue:[ |
|
1032 |
items := OrderedCollection new:size. |
|
1033 |
labels do:[:aLabel| items add:(Item in:self label:aLabel) ] |
|
1034 |
] |
|
2118
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
1035 |
]. |
388 | 1036 |
! |
1037 |
||
1999 | 1038 |
menuPerformer:anObject |
1039 |
"set the menu-receiver. Thats the one who gets the messages ( both from myself and |
|
1040 |
from all submenus no specific receiver is defined ). |
|
1041 |
" |
|
1042 |
^ self receiver:anObject |
|
1043 |
! |
|
1044 |
||
388 | 1045 |
nameKeyAt:stringOrNumber |
1046 |
"gets the nameKey of an item or nil |
|
1047 |
" |
|
1048 |
^ self itemAt:stringOrNumber do:[:el| el nameKey ] |
|
1049 |
! |
|
1050 |
||
1051 |
nameKeyAt:stringOrNumber put:aNameKey |
|
1052 |
"sets the nameKey of an item |
|
1053 |
" |
|
1054 |
self itemAt:stringOrNumber do:[:el| el nameKey:aNameKey ] |
|
1055 |
! |
|
1056 |
||
1057 |
nameKeys |
|
1058 |
"returns a collection of nameKeys's or nil |
|
1059 |
" |
|
1060 |
^ self collect:[:anItem| anItem nameKey ] |
|
1061 |
! |
|
1062 |
||
1063 |
nameKeys:something |
|
1064 |
"define nameKeys for each item |
|
1065 |
" |
|
1066 |
self onEachPerform:#nameKey: withArgList:something |
|
1067 |
! |
|
1068 |
||
1069 |
numberOfItems |
|
1070 |
"gets number of items |
|
1071 |
" |
|
1072 |
^ items size |
|
1073 |
! |
|
1074 |
||
1075 |
receiver |
|
1076 |
"get the menu-receiver. Thats the one who gets the messages ( both from myself and |
|
1077 |
from all submenus no specific receiver is defined ). |
|
1078 |
" |
|
389 | 1079 |
(receiver isNil and:[superMenu notNil]) ifTrue:[ |
2145 | 1080 |
^ superMenu receiver |
388 | 1081 |
]. |
389 | 1082 |
^ receiver |
388 | 1083 |
! |
1084 |
||
1085 |
receiver:anObject |
|
1086 |
"set the menu-receiver. Thats the one who gets the messages ( both from myself and |
|
1087 |
from all submenus no specific receiver is defined ). |
|
1088 |
" |
|
389 | 1089 |
receiver := anObject |
388 | 1090 |
! |
1091 |
||
1092 |
shortcutKeyAt:stringOrNumber |
|
1093 |
"gets the shortCutKey of an item or nil |
|
1094 |
" |
|
1095 |
^ self itemAt:stringOrNumber do:[:el| el shortcutKey ] |
|
1096 |
! |
|
1097 |
||
1098 |
shortcutKeyAt:stringOrNumber put:aKey |
|
1099 |
"sets the shortCutKey of an item |
|
1100 |
" |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
1101 |
self itemAt:stringOrNumber do:[:el| el shortcutKey:aKey ] |
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
1102 |
! |
388 | 1103 |
|
1104 |
shortcutKeys |
|
1105 |
"returns a collection of shortcutKey's or nil |
|
1106 |
" |
|
1107 |
^ self collect:[:anItem| anItem shortcutKey ] |
|
1108 |
||
1109 |
! |
|
1110 |
||
1111 |
shortcutKeys:something |
|
1112 |
"define shortcutKey's for each item |
|
1113 |
" |
|
1114 |
self onEachPerform:#shortcutKey: withArgList:something |
|
1115 |
! |
|
1116 |
||
1117 |
valueAt:stringOrNumber |
|
1118 |
"gets value of an item; a block, valueHolder, ... |
|
1119 |
" |
|
1120 |
^ self itemAt:stringOrNumber do:[:el| el value ] |
|
1121 |
||
1122 |
! |
|
1123 |
||
1124 |
valueAt:stringOrNumber put:someThing |
|
1125 |
"sets value of an item; a block, valueHolder, ... |
|
1126 |
" |
|
1127 |
self itemAt:stringOrNumber do:[:el| el value:someThing ] |
|
1128 |
||
1129 |
||
1130 |
! |
|
1131 |
||
1132 |
values:something |
|
1133 |
"define values for each item |
|
1134 |
" |
|
1135 |
self onEachPerform:#value: withArgList:something |
|
1136 |
! ! |
|
1137 |
||
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1138 |
!MenuPanel methodsFor:'accessing-behavior'! |
388 | 1139 |
|
1140 |
disableAll |
|
498 | 1141 |
"disable all items; not the menu in case of enabled |
388 | 1142 |
" |
498 | 1143 |
self do:[:anItem| anItem enabled:false] |
388 | 1144 |
! |
1145 |
||
1146 |
disableAll:collectionOfIndicesOrNames |
|
1147 |
"disable an collection of items |
|
1148 |
" |
|
1149 |
collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:false ]. |
|
1150 |
||
1151 |
! |
|
1152 |
||
1153 |
enableAll |
|
498 | 1154 |
"enable all items; not the menu in case of disabled |
388 | 1155 |
" |
498 | 1156 |
self do:[:anItem| anItem enabled:true] |
388 | 1157 |
! |
1158 |
||
1159 |
enableAll:collectionOfIndicesOrNames |
|
1160 |
"enable an collection of items |
|
1161 |
" |
|
1162 |
collectionOfIndicesOrNames do:[:entry| self enabledAt:entry put:true ]. |
|
1163 |
||
1164 |
! |
|
1165 |
||
1166 |
enabled |
|
1167 |
"returns enabled state |
|
1168 |
" |
|
498 | 1169 |
^ enabled |
388 | 1170 |
! |
1171 |
||
1172 |
enabled:aState |
|
1173 |
"change enabled state of menu |
|
1174 |
" |
|
545 | 1175 |
|state| |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1176 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1177 |
state := aState ? true. |
388 | 1178 |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
1179 |
enabled ~~ state ifTrue:[ |
2219 | 1180 |
enabled := state. |
1181 |
self invalidate. |
|
498 | 1182 |
]. |
388 | 1183 |
! |
1184 |
||
1185 |
enabledAt:stringOrNumber |
|
1186 |
"gets the enabled state of an item or false |
|
1187 |
" |
|
1188 |
^ self itemAt:stringOrNumber do:[:el| el enabled ] ifAbsent:false |
|
1189 |
! |
|
1190 |
||
1191 |
enabledAt:stringOrNumber put:aState |
|
1192 |
"sets the enabled state of an item |
|
1193 |
" |
|
1194 |
self itemAt:stringOrNumber do:[:el| el enabled:aState ] |
|
1195 |
! |
|
1196 |
||
1197 |
isEnabled:stringOrNumber |
|
1198 |
"gets the enabled state of an item or false |
|
1199 |
" |
|
1200 |
^ self enabledAt:stringOrNumber |
|
1201 |
! ! |
|
1202 |
||
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1203 |
!MenuPanel methodsFor:'accessing-channels'! |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1204 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1205 |
enableChannel:aValueHolder |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1206 |
"set my enableChannel |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1207 |
" |
498 | 1208 |
enableChannel notNil ifTrue:[ |
2145 | 1209 |
enableChannel removeDependent:self |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1210 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1211 |
|
498 | 1212 |
(enableChannel := aValueHolder) notNil ifTrue:[ |
2145 | 1213 |
enableChannel addDependent:self. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1214 |
]. |
498 | 1215 |
self enabled:(enableChannel value). |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1216 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1217 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1218 |
menuHolder:aValueHolder |
498 | 1219 |
"set my menuHolder |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1220 |
" |
498 | 1221 |
menuHolder notNil ifTrue:[ |
2145 | 1222 |
menuHolder removeDependent:self |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1223 |
]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1224 |
|
498 | 1225 |
(menuHolder := aValueHolder) notNil ifTrue:[ |
2145 | 1226 |
menuHolder addDependent:self. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1227 |
]. |
498 | 1228 |
self menu:(menuHolder value) |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1229 |
! ! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1230 |
|
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1231 |
!MenuPanel methodsFor:'accessing-color & font'! |
390 | 1232 |
|
616 | 1233 |
activeBackgroundColor |
1234 |
"get the background drawing color used to highlight selection |
|
1235 |
" |
|
2219 | 1236 |
^ styleSheet colorAt:#'menuPanel.activeBackgroundColor' |
616 | 1237 |
! |
1238 |
||
1239 |
activeForegroundColor |
|
1240 |
"get the foreground color used to highlight selections |
|
1241 |
" |
|
2219 | 1242 |
^ styleSheet colorAt:#'menuPanel.activeForegroundColor' |
616 | 1243 |
! |
1244 |
||
390 | 1245 |
backgroundColor |
1246 |
"return the background color |
|
1247 |
" |
|
502 | 1248 |
^ super viewBackground |
390 | 1249 |
! |
1250 |
||
1251 |
backgroundColor:aColor |
|
1252 |
"set the background drawing color. You should not use this method; |
|
1253 |
instead leave the value as defined in the styleSheet. |
|
1254 |
" |
|
616 | 1255 |
super viewBackground ~~ aColor ifTrue:[ |
2145 | 1256 |
super viewBackground:aColor. |
1257 |
shown ifTrue:[ |
|
1258 |
self invalidate "/ RepairNow:true |
|
1259 |
] |
|
616 | 1260 |
] |
1261 |
||
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
1262 |
"Modified: / 6.6.1998 / 19:50:06 / cg" |
390 | 1263 |
! |
1264 |
||
727 | 1265 |
buttonActiveBackgroundColor |
1266 |
"get the background drawing color used to highlight button selection |
|
1267 |
" |
|
2219 | 1268 |
^ styleSheet colorAt:#'button.activeBackgroundColor' |
1269 |
default:(self viewBackground) |
|
727 | 1270 |
! |
1271 |
||
730 | 1272 |
buttonEdgeStyle |
1273 |
"get the button edge style |
|
1274 |
" |
|
2219 | 1275 |
^ styleSheet at:#'button.edgeStyle' |
730 | 1276 |
! |
1277 |
||
1081
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1278 |
buttonEnteredBackgroundColor |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1279 |
"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
|
1280 |
" |
2219 | 1281 |
^ styleSheet colorAt:#'menuPanel.buttonEnteredBackgroundColor' |
1081
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1282 |
! |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1283 |
|
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1284 |
buttonEnteredLevel |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1285 |
"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
|
1286 |
" |
2219 | 1287 |
^ styleSheet at:#'menuPanel.buttonEnteredLevel' |
1081
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1288 |
! |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
1289 |
|
730 | 1290 |
buttonHalfLightColor |
1291 |
"get the background drawing color used to half light button frame |
|
1292 |
" |
|
2219 | 1293 |
^ styleSheet colorAt:#'button.halfLightColor' |
730 | 1294 |
! |
1295 |
||
1296 |
buttonHalfShadowColor |
|
1297 |
"get the background drawing color used to half shadow button frame |
|
1298 |
" |
|
2219 | 1299 |
^ styleSheet colorAt:#'button.halfShadowColor' |
727 | 1300 |
! |
1301 |
||
1302 |
buttonLightColor |
|
1303 |
"get the background drawing color used to light button frame |
|
1304 |
" |
|
2219 | 1305 |
^ styleSheet colorAt:#'menuPanel.buttonLightColor' |
727 | 1306 |
! |
1307 |
||
1308 |
buttonPassiveBackgroundColor |
|
1309 |
"get the background drawing color used for button |
|
1310 |
" |
|
2219 | 1311 |
^ styleSheet colorAt:#'menuPanel.buttonPassiveBackgroundColor' |
727 | 1312 |
! |
1313 |
||
1314 |
buttonShadowColor |
|
1315 |
"get the background drawing color used to shadow button frame |
|
1316 |
" |
|
2219 | 1317 |
^ styleSheet colorAt:#'menuPanel.buttonShadowColor' |
2059 | 1318 |
! |
1319 |
||
1320 |
disabledEtchedForegroundColor |
|
1321 |
"return the color used for etching disabled items. |
|
1322 |
If nil, no 3D effect is drawn. |
|
1323 |
" |
|
2219 | 1324 |
^ styleSheet colorAt:#'menuPanel.disabledEtchedFgColor' |
727 | 1325 |
! |
1326 |
||
390 | 1327 |
disabledForegroundColor |
1328 |
"return the foreground color used by disabled items |
|
1329 |
" |
|
2219 | 1330 |
^ styleSheet colorAt:#'menuPanel.disabledForegroundColor' |
390 | 1331 |
! |
1332 |
||
2170 | 1333 |
enteredBackgroundColor |
1334 |
"return the background color for entered items |
|
1335 |
" |
|
2219 | 1336 |
^ styleSheet colorAt:#'menu.enteredBackgroundColor' |
1337 |
default:(self backgroundColor) |
|
2170 | 1338 |
! |
1339 |
||
1340 |
enteredForegroundColor |
|
1341 |
"return the foreground color for entered items |
|
1342 |
" |
|
2219 | 1343 |
^ styleSheet colorAt:#'menu.enteredForegroundColor' default:fgColor |
2170 | 1344 |
! |
1345 |
||
390 | 1346 |
font:aFont |
1347 |
"set the font |
|
1348 |
" |
|
829 | 1349 |
(aFont notNil and:[aFont ~= font]) ifTrue:[ |
2219 | 1350 |
super font:(aFont "onDevice:device"). |
1351 |
||
1352 |
superMenu notNil ifTrue:[ |
|
1353 |
self extent:(self preferredExtent) |
|
1354 |
]. |
|
1355 |
self mustRearrange. |
|
390 | 1356 |
] |
1357 |
! |
|
1358 |
||
1359 |
foregroundColor |
|
1360 |
"return the passive foreground color |
|
1361 |
" |
|
2059 | 1362 |
^ fgColor |
390 | 1363 |
! |
1364 |
||
1365 |
foregroundColor:aColor |
|
1366 |
"set the foregroundColor drawing color. You should not use this method; |
|
1367 |
instead leave the value as defined in the styleSheet. |
|
1368 |
" |
|
2219 | 1369 |
aColor ~= fgColor ifTrue:[ |
1478 | 1370 |
fgColor := aColor onDevice:device. |
2219 | 1371 |
shown ifTrue:[ self invalidate ] |
1372 |
]. |
|
580 | 1373 |
! |
1374 |
||
1699 | 1375 |
maxAbsoluteButtonLevel |
1376 |
"returns the maximum absolute button level; used to compute the preferred |
|
1377 |
extent of a button |
|
1378 |
" |
|
2219 | 1379 |
^ styleSheet at:#'menuPanel.maxAbsoluteButtonLevel' |
390 | 1380 |
! |
1381 |
||
730 | 1382 |
selectionFrameBrightColor |
1383 |
"get the selection frame bright color |
|
1384 |
" |
|
2219 | 1385 |
^ Color white |
730 | 1386 |
! |
1387 |
||
1388 |
selectionFrameDarkColor |
|
1389 |
"get the selection frame dark color |
|
1390 |
" |
|
2219 | 1391 |
^ Color black |
730 | 1392 |
! |
1393 |
||
1727 | 1394 |
setFont:aFont |
1395 |
"set the font derived from item; if unchanged nil is returned otherwise the old font |
|
1396 |
" |
|
1397 |
|currentFont| |
|
1398 |
||
1399 |
(aFont notNil and:[aFont ~= font]) ifTrue:[ |
|
2219 | 1400 |
currentFont := font. |
1401 |
super font:aFont. |
|
1727 | 1402 |
]. |
1403 |
^ currentFont |
|
390 | 1404 |
! ! |
1405 |
||
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1406 |
!MenuPanel methodsFor:'accessing-dimensions'! |
388 | 1407 |
|
1408 |
height |
|
1409 |
"default height |
|
1410 |
" |
|
1411 |
(explicitExtent ~~ true) ifTrue:[ |
|
2219 | 1412 |
^ self preferredExtent y |
388 | 1413 |
]. |
1414 |
^ super height |
|
1415 |
! |
|
1416 |
||
2016 | 1417 |
maxExtent |
1418 |
"CLAUS: returns the maximum extent |
|
1419 |
" |
|
1420 |
|x y| |
|
1421 |
||
1422 |
device isNil ifTrue:[ |
|
2219 | 1423 |
superMenu notNil ifTrue:[ |
1424 |
^ superMenu maxExtent |
|
1425 |
]. |
|
2016 | 1426 |
]. |
1427 |
y := device usableHeight - 2. |
|
1428 |
x := device usableWidth - 2. |
|
1429 |
^ x@y |
|
1430 |
! |
|
1431 |
||
388 | 1432 |
preferredExtent |
1433 |
"compute and returns my preferred extent |
|
2016 | 1434 |
" |
2024 | 1435 |
|maxExtent usedExtent w| |
1436 |
||
2016 | 1437 |
preferredExtent notNil ifTrue:[ |
2219 | 1438 |
^ preferredExtent |
2016 | 1439 |
]. |
2024 | 1440 |
maxExtent := self maxExtent. |
1441 |
usedExtent := self preferredExtentOfItems. |
|
1442 |
||
1443 |
superView isNil ifTrue:[ |
|
2219 | 1444 |
"/ is standalone |
1445 |
w := self menuAdornmentAt:#Width. |
|
1446 |
||
1447 |
w notNil ifTrue:[ |
|
1448 |
usedExtent x < w ifTrue:[ |
|
1449 |
usedExtent := w @ usedExtent y. |
|
1450 |
] |
|
1451 |
] |
|
2024 | 1452 |
]. |
1453 |
||
1454 |
^ usedExtent min:maxExtent |
|
1455 |
||
1456 |
"Modified: / 10.10.2001 / 14:57:25 / cg" |
|
2016 | 1457 |
! |
1458 |
||
1459 |
preferredExtentOfItems |
|
1460 |
"compute and returns my preferred extent including all items |
|
1723
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
1461 |
!!!!!! changes have influence on method #rearrangeItems !!!!!! |
388 | 1462 |
" |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
1463 |
|hasMenu shCtKey extent showAcc sck |
2219 | 1464 |
x "{ Class:SmallInteger }" |
1465 |
y "{ Class:SmallInteger }" |
|
1466 |
size "{ Class:SmallInteger }" |
|
2145 | 1467 |
buttonInsetX "{ Class:SmallInteger }" |
1468 |
buttonInsetY "{ Class:SmallInteger }" |
|
2219 | 1469 |
labelInsetX "{ Class:SmallInteger }" |
1470 |
labelInsetY "{ Class:SmallInteger }" |
|
1471 |
itemSpace "{ Class:SmallInteger }" |
|
1472 |
itemMargin "{ Class:SmallInteger }" |
|
1473 |
groupDividerSize "{ Class:SmallInteger }" |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
1474 |
| |
388 | 1475 |
|
1699 | 1476 |
(size := items size) == 0 ifTrue:[ |
2219 | 1477 |
self isViewWrapper ifTrue:[ ^ subViews first extent ]. |
1478 |
^ 32 @ 32 |
|
1479 |
]. |
|
1480 |
buttonInsetX := 2 * self buttonInsetX. |
|
1481 |
buttonInsetY := 2 * self buttonInsetY. |
|
1699 | 1482 |
|
1483 |
self isPopUpView ifFalse:[ |
|
2219 | 1484 |
labelInsetX := labelInsetY := 2 * (self enteredLevel abs). |
1699 | 1485 |
] ifTrue:[ |
2145 | 1486 |
labelInsetX := labelInsetY := 0. |
1699 | 1487 |
]. |
1488 |
||
1489 |
x := 0. |
|
1490 |
y := 0. |
|
2219 | 1491 |
groupDividerSize := self groupDividerSize. |
388 | 1492 |
|
1493 |
self verticalLayout ifFalse:[ |
|
2219 | 1494 |
itemSpace := self itemSpace. |
1495 |
||
1699 | 1496 |
items keysAndValuesDo:[:key :el| |eX eY| |
1497 |
extent := el preferredExtent. |
|
1498 |
||
1499 |
"/ check for visibility (extent x ~~ 0) |
|
1500 |
(eX := extent x) ~~ 0 ifTrue:[ |
|
1501 |
eY := extent y. |
|
1502 |
||
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1503 |
el isButton ifTrue:[ |
2145 | 1504 |
eX := eX + buttonInsetX. |
1505 |
eY := eY + buttonInsetY. |
|
1699 | 1506 |
] ifFalse:[ |
2145 | 1507 |
eX := eX + labelInsetX. |
1508 |
eY := eY + labelInsetY. |
|
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1509 |
]. |
1699 | 1510 |
key ~~ size ifTrue:[ |
1511 |
(self hasGroupDividerAt:key) ifTrue:[ |
|
1512 |
x := x + groupDividerSize |
|
1513 |
] ifFalse:[ |
|
1723
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
1514 |
el isLabeledItem ifTrue:[ |
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
1515 |
x := x + itemSpace |
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
1516 |
] |
1699 | 1517 |
] |
1518 |
]. |
|
1519 |
x := eX + x. |
|
1520 |
y := eY max:y. |
|
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1521 |
] |
1699 | 1522 |
] |
388 | 1523 |
] ifTrue:[ |
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1524 |
hasMenu := false. |
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1525 |
shCtKey := 0. |
1699 | 1526 |
showAcc := MenuView showAcceleratorKeys == true. |
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1527 |
y := x. |
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1528 |
x := 0. |
2219 | 1529 |
itemMargin := 2 * self itemMargin. |
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1530 |
|
1699 | 1531 |
items keysAndValuesDo:[:key :el| |eX eY| |
1532 |
extent := el preferredExtent. |
|
1533 |
||
1534 |
"/ check for visibility (extent x ~~ 0) |
|
1535 |
(eX := extent x) ~~ 0 ifTrue:[ |
|
1536 |
eY := extent y. |
|
1537 |
||
1538 |
el isButton ifTrue:[ |
|
2145 | 1539 |
eX := eX + buttonInsetX. |
1540 |
eY := eY + buttonInsetY. |
|
1699 | 1541 |
] ifFalse:[ |
2145 | 1542 |
eX := eX + labelInsetX. |
1543 |
eY := eY + labelInsetY. |
|
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1544 |
]. |
1699 | 1545 |
hasMenu ifFalse:[ |
1546 |
hasMenu := el hasSubmenu |
|
1547 |
]. |
|
1548 |
(showAcc and:[(sck := el shortcutKeyAsString) notNil]) ifTrue:[ |
|
1549 |
shCtKey := shCtKey max:(sck widthOn:self) |
|
1550 |
]. |
|
1551 |
key ~~ size ifTrue:[ |
|
1552 |
(self hasGroupDividerAt:key) ifTrue:[ |
|
1553 |
y := y + groupDividerSize |
|
1554 |
] |
|
1555 |
]. |
|
1556 |
y := eY + y. |
|
1557 |
x := eX max:x. |
|
1558 |
]. |
|
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1559 |
]. |
2219 | 1560 |
x := x + itemMargin. |
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1561 |
|
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1562 |
(hasMenu or:[shCtKey ~~ 0]) ifTrue:[ |
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1563 |
shortKeyInset := x + Item labelRightOffset. |
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1564 |
x := shortKeyInset + shCtKey + self subMenuIndicationWidth. |
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1565 |
|
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1566 |
(shCtKey ~~ 0 and:[hasMenu]) ifTrue:[ |
2219 | 1567 |
x := x + self shortcutKeyOffset. |
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1568 |
] |
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
1569 |
]. |
1699 | 1570 |
"/ to have a small inset |
1571 |
y := y + 1. |
|
1572 |
"/ x := x + 1. |
|
1573 |
]. |
|
1574 |
x := x + margin + margin. |
|
1575 |
y := y + margin + margin. |
|
1576 |
||
1577 |
^ x @ y |
|
388 | 1578 |
! |
1579 |
||
2024 | 1580 |
preferredWidth:aWidth |
1581 |
self menuAdornmentAt:#Width put:aWidth. |
|
1582 |
||
1583 |
"Created: / 10.10.2001 / 14:56:39 / cg" |
|
1584 |
! |
|
1585 |
||
388 | 1586 |
shortKeyInset |
1587 |
"left inset of shortcutKey |
|
1588 |
" |
|
1589 |
^ shortKeyInset |
|
616 | 1590 |
! |
1591 |
||
1592 |
subMenuIndicationWidth |
|
2219 | 1593 |
^ self rightArrow width |
388 | 1594 |
! ! |
1595 |
||
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1596 |
!MenuPanel methodsFor:'accessing-interactors'! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1597 |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1598 |
iconIndicationDisabledOff |
2219 | 1599 |
^ self registerImageOnDevice:(self class iconIndicationDisabledOff) |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1600 |
! |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1601 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1602 |
iconIndicationDisabledOn |
2219 | 1603 |
^ self registerImageOnDevice:(self class iconIndicationDisabledOn) |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1604 |
! |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1605 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1606 |
iconIndicationOff |
2219 | 1607 |
^ self registerImageOnDevice:(self class iconIndicationOff) |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1608 |
! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1609 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1610 |
iconIndicationOn |
2219 | 1611 |
^ self registerImageOnDevice:(self class iconIndicationOn) |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1612 |
! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1613 |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1614 |
iconRadioGroupDisabledOff |
2219 | 1615 |
^ self registerImageOnDevice:(self class iconRadioGroupDisabledOff) |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1616 |
! |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1617 |
|
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1618 |
iconRadioGroupDisabledOn |
2219 | 1619 |
^ self registerImageOnDevice:(self class iconRadioGroupDisabledOn) |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1620 |
! |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1621 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1622 |
iconRadioGroupOff |
2219 | 1623 |
^ self registerImageOnDevice:(self class iconRadioGroupOff) |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1624 |
! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1625 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1626 |
iconRadioGroupOn |
2219 | 1627 |
^ self registerImageOnDevice:(self class iconRadioGroupOn) |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1628 |
! ! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
1629 |
|
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1630 |
!MenuPanel methodsFor:'accessing-items'! |
388 | 1631 |
|
1632 |
itemAt:stringOrNumber |
|
390 | 1633 |
"returns item assigned to an index, nameKey, textLabel or value if symbol. |
1634 |
If no item match nil is returned. |
|
388 | 1635 |
" |
1636 |
|idx| |
|
1637 |
||
1638 |
idx := self indexOf:stringOrNumber. |
|
1639 |
(idx > 0 and:[idx <= items size]) ifTrue:[ ^ items at:idx ]. |
|
1640 |
^ nil |
|
1641 |
||
1642 |
! |
|
1643 |
||
1644 |
itemAt:stringOrNumber do:aOneArgBlock |
|
1645 |
"evaluate teh block for an item and return the result from the block. In case that |
|
1646 |
the item not exists nil is returned |
|
1647 |
" |
|
1648 |
^ self itemAt:stringOrNumber do:aOneArgBlock ifAbsent:nil |
|
1649 |
! |
|
1650 |
||
1651 |
itemAt:stringOrNumber do:aOneArgBlock ifAbsent:exceptionBlock |
|
1652 |
"evaluate teh block for an item and return the result from the block. In case that |
|
1653 |
the item not exists the result of the exception block is returned (no arguments). |
|
1654 |
" |
|
1655 |
|item| |
|
1656 |
||
1657 |
item := self itemAt:stringOrNumber. |
|
1658 |
item notNil ifTrue:[ ^ aOneArgBlock value:item ]. |
|
1659 |
^ exceptionBlock value |
|
706 | 1660 |
! |
1661 |
||
1662 |
itemAtIndex:anIndex |
|
1663 |
"returns item at an index or nil |
|
1664 |
" |
|
1665 |
^ 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
|
1666 |
! |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
1667 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
1668 |
items |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
1669 |
"returns list of items or nil |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
1670 |
" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
1671 |
^ items |
388 | 1672 |
! ! |
1673 |
||
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1674 |
!MenuPanel methodsFor:'accessing-look'! |
388 | 1675 |
|
727 | 1676 |
buttonActiveLevel |
1677 |
"get the button active level |
|
1678 |
" |
|
2219 | 1679 |
^ styleSheet at:#'menuPanel.buttonActiveLevel' |
727 | 1680 |
! |
1681 |
||
1682 |
buttonPassiveLevel |
|
2219 | 1683 |
"get the button active level |
1684 |
" |
|
1685 |
^ styleSheet at:#'menuPanel.buttonPassiveLevel' |
|
727 | 1686 |
! |
1687 |
||
390 | 1688 |
fitFirstPanel |
1689 |
"gets true if the first panel in the menu hierarchy must be fit |
|
1690 |
to the extent of its superView |
|
1699 | 1691 |
|
1692 |
NOT SUPPORTED |
|
388 | 1693 |
" |
2219 | 1694 |
^ false |
388 | 1695 |
! |
1696 |
||
390 | 1697 |
fitFirstPanel:aState |
1698 |
"sets true if the first panel in the menu hierarchy must be fit |
|
1699 |
to the extent of its superView |
|
1699 | 1700 |
|
1701 |
NOT SUPPORTED |
|
1702 |
" |
|
616 | 1703 |
! |
1704 |
||
1093 | 1705 |
level:anInt |
2003
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
1706 |
anInt ~~ level ifTrue:[ |
2219 | 1707 |
super level:anInt. |
1708 |
self mustRearrange |
|
2003
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
1709 |
] |
2052 | 1710 |
|
1711 |
"Modified: / 15.11.2001 / 17:42:07 / cg" |
|
1093 | 1712 |
! |
1713 |
||
616 | 1714 |
rightArrow |
2219 | 1715 |
rightArrow ifNil:[ |
1716 |
device ifNil:[ |
|
1717 |
^ SelectionInListView rightArrowFormOn:Display |
|
1718 |
]. |
|
1719 |
rightArrow := SelectionInListView rightArrowFormOn:device |
|
1720 |
]. |
|
616 | 1721 |
^ rightArrow |
1722 |
! |
|
1723 |
||
1724 |
rightArrowShadow |
|
1725 |
^ rightArrowShadow |
|
388 | 1726 |
! |
1727 |
||
390 | 1728 |
showGroupDivider |
1729 |
"get the enabled flag for showing groupDiveders |
|
388 | 1730 |
" |
1222 | 1731 |
^ (self menuAdornmentAt:#showGroupDivider) |
388 | 1732 |
! |
1733 |
||
390 | 1734 |
showGroupDivider:aState |
1735 |
"set the enabled flag for showing groupDiveders |
|
388 | 1736 |
" |
653 | 1737 |
(self menuAdornmentAt:#showGroupDivider put:aState) ifTrue:[ |
2145 | 1738 |
self mustRearrange. |
653 | 1739 |
] |
388 | 1740 |
! |
1741 |
||
1742 |
showSeparatingLines |
|
1743 |
"gets true if drawing of separating lines is enabled. |
|
1744 |
" |
|
1222 | 1745 |
^ (self menuAdornmentAt:#showSeparatingLines) |
388 | 1746 |
! |
1747 |
||
390 | 1748 |
showSeparatingLines:aState |
388 | 1749 |
"turn on/off drawing of separating lines. |
1750 |
" |
|
653 | 1751 |
(self menuAdornmentAt:#showSeparatingLines put:aState) ifTrue:[ |
2145 | 1752 |
self mustRearrange |
653 | 1753 |
] |
388 | 1754 |
! |
1755 |
||
1756 |
verticalLayout |
|
1757 |
"get the layout: or vertical( true ) or horizontal( false ) |
|
1758 |
" |
|
1824 | 1759 |
|direction| |
1760 |
||
1761 |
direction := self menuAdornmentAt:#verticalLayout. |
|
2079 | 1762 |
direction notNil ifTrue:[^ direction]. |
1763 |
self isPopUpView ifTrue:[^ true]. |
|
1764 |
^ superMenu notNil |
|
388 | 1765 |
! |
1766 |
||
1767 |
verticalLayout:aState |
|
1768 |
"set the layout: or vertical( true ) or horizontal( false ) |
|
1769 |
" |
|
653 | 1770 |
(self menuAdornmentAt:#verticalLayout put:aState) ifTrue:[ |
2145 | 1771 |
self mustRearrange |
653 | 1772 |
] |
388 | 1773 |
! ! |
1774 |
||
2219 | 1775 |
!MenuPanel methodsFor:'accessing-style'! |
1776 |
||
1777 |
buttonInsetX |
|
1778 |
"returns the verical button space |
|
1779 |
" |
|
1780 |
^ styleSheet at:#'menuPanel.buttonInsetX' |
|
1781 |
! |
|
1782 |
||
1783 |
buttonInsetY |
|
1784 |
"returns the verical button space |
|
1785 |
" |
|
1786 |
^ styleSheet at:#'menuPanel.buttonInsetY' |
|
1787 |
! |
|
1788 |
||
1789 |
enteredLevel |
|
1790 |
"returns the enter-level for an unselected item moved through |
|
1791 |
" |
|
1792 |
^ styleSheet at:#'menu.enteredLevel' default:0 |
|
1793 |
! |
|
1794 |
||
1795 |
groupDividerSize |
|
1796 |
"returns the width of a group divider |
|
1797 |
" |
|
1798 |
^ styleSheet at:#'menu.groupDividerSize' default:6 |
|
1799 |
! |
|
1800 |
||
1801 |
itemMargin |
|
1802 |
"returns the margin of an item |
|
1803 |
" |
|
1804 |
^ styleSheet at:#'menu.itemMargin' default:0 |
|
1805 |
! |
|
1806 |
||
1807 |
itemSpace |
|
1808 |
"returns the additional space for an item in a (vertical) panel |
|
1809 |
" |
|
1810 |
^ styleSheet at:#'menuPanel.itemSpace' |
|
1811 |
! |
|
1812 |
||
1813 |
selectionFollowsMouse |
|
1814 |
"returns true if the selection follows the mouse |
|
1815 |
" |
|
1816 |
^ styleSheet at:#'menu.selectionFollowsMouse' default:false |
|
1817 |
! |
|
1818 |
||
1819 |
shortcutKeyOffset |
|
1820 |
"returns the offset for a shortcutKey |
|
1821 |
" |
|
1822 |
^ 5 |
|
1823 |
! ! |
|
1824 |
||
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
1825 |
!MenuPanel methodsFor:'accessing-submenu'! |
388 | 1826 |
|
1827 |
subMenuAt:stringOrNumber |
|
1828 |
"gets the submenu of an item or nil |
|
1829 |
" |
|
1830 |
^ self itemAt:stringOrNumber do:[:el| el submenu ] |
|
1831 |
! |
|
1832 |
||
1833 |
subMenuAt:stringOrNumber put:aSubMenu |
|
1834 |
"sets the submenu of an item |
|
1835 |
" |
|
1836 |
self itemAt:stringOrNumber do:[:el| el submenu:aSubMenu ] |
|
1837 |
||
1838 |
! |
|
1839 |
||
1840 |
subMenuShown |
|
1841 |
"return the currently visible submenu - or nil if there is none |
|
1842 |
" |
|
1843 |
|item| |
|
1844 |
||
1845 |
(item := self selection) notNil ifTrue:[ |
|
2145 | 1846 |
^ item submenu |
388 | 1847 |
]. |
1848 |
^ nil |
|
1849 |
! ! |
|
1850 |
||
1698 | 1851 |
!MenuPanel methodsFor:'activation / deactivation'! |
388 | 1852 |
|
1795
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
1853 |
closeMenus |
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
1854 |
"close all menus; operation is done; nothing accepted |
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
1855 |
" |
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
1856 |
self topMenu accept:nil. |
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
1857 |
! |
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
1858 |
|
388 | 1859 |
hide |
1860 |
"hide the view, leave its modal event loop |
|
1861 |
" |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
1862 |
|
388 | 1863 |
self selection:nil. |
1864 |
self unmap. |
|
1865 |
||
1866 |
||
1867 |
! |
|
1868 |
||
1869 |
show |
|
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1870 |
"realize the view at its last position; |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1871 |
return the value of the selectedItem or nil, of none was selected |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1872 |
(unless the menu has already performed its action, by sending an appropriate message |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1873 |
to some performer) |
388 | 1874 |
" |
1875 |
^ self showAt:(self origin) resizing:true |
|
1876 |
||
1877 |
! |
|
1878 |
||
1879 |
showAt:aPoint |
|
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1880 |
"realize the view at aPoint. |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1881 |
return the value of the selectedItem or nil, of none was selected |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1882 |
(unless the menu has already performed its action, by sending an appropriate message |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1883 |
to some performer) |
388 | 1884 |
" |
1885 |
^ self showAt:aPoint resizing:true |
|
1886 |
||
1887 |
||
1888 |
! |
|
1889 |
||
1890 |
showAt:aPoint resizing:aBoolean |
|
984
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1891 |
"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
|
1892 |
or if I have already performed. |
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1893 |
Return the items value, otherwise. |
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1894 |
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
|
1895 |
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
|
1896 |
if a non-nil is returned. |
388 | 1897 |
" |
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1898 |
|
1331
aae37cbfb30a
fixed style handling to avoid bad resizing when popup-level/bw
Claus Gittinger <cg@exept.de>
parents:
1330
diff
changeset
|
1899 |
self rearrangeItemsIfItemVisibilityChanged. |
388 | 1900 |
|
1901 |
aBoolean ifTrue:[ |
|
2219 | 1902 |
self fixSize. |
388 | 1903 |
]. |
1904 |
self origin:aPoint. |
|
1459 | 1905 |
"/ self makeFullyVisible. -- done in realize |
388 | 1906 |
self openModal:[true]. "realize " |
1907 |
||
984
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1908 |
"/ if I have already performed, |
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1909 |
"/ return nil - to avoid items triggering twice. |
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1910 |
|
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1911 |
(self topMenu menuAdornmentAt:#hasPerformed) == true ifTrue:[ |
2219 | 1912 |
^ nil |
984
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1913 |
]. |
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1914 |
|
984
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1915 |
^ self lastValueAccepted |
87d36803b9d8
oops - menu items fired twice.
Claus Gittinger <cg@exept.de>
parents:
971
diff
changeset
|
1916 |
|
1137
7df0b776e47a
fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents:
1130
diff
changeset
|
1917 |
"Modified: / 15.9.1998 / 12:50:23 / cg" |
388 | 1918 |
! |
1919 |
||
1920 |
showAtPointer |
|
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1921 |
"realize the view at the current pointer position. |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1922 |
return the value of the selectedItem or nil, of none was selected |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1923 |
(unless the menu has already performed its action, by sending an appropriate message |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1924 |
to some performer) |
388 | 1925 |
" |
1926 |
^ self showAt:(device pointerPosition) resizing:true |
|
1927 |
||
1928 |
||
1929 |
! |
|
1930 |
||
1931 |
showCenteredIn:aView |
|
1932 |
"make myself visible at the screen center. |
|
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1933 |
return the value of the selectedItem or nil, of none was selected |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1934 |
(unless the menu has already performed its action, by sending an appropriate message |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1935 |
to some performer) |
388 | 1936 |
" |
1937 |
|top| |
|
1938 |
||
1939 |
top := aView topView. |
|
1940 |
top raise. |
|
1137
7df0b776e47a
fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents:
1130
diff
changeset
|
1941 |
^ 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
|
1942 |
|
7df0b776e47a
fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents:
1130
diff
changeset
|
1943 |
"Modified: / 15.9.1998 / 12:45:50 / cg" |
388 | 1944 |
! |
1945 |
||
1946 |
startUp |
|
1947 |
"realize the menu at the current pointer position |
|
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1948 |
return the value of the selectedItem or nil, of none was selected |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1949 |
(unless the menu has already performed its action, by sending an appropriate message |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1950 |
to some performer) |
388 | 1951 |
" |
1952 |
^ self showAtPointer |
|
897
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1953 |
! |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1954 |
|
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1955 |
startUpAt:aPoint |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1956 |
"realize the menu at aPoint |
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1957 |
return the value of the selectedItem or nil, of none was selected |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1958 |
(unless the menu has already performed its action, by sending an appropriate message |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1959 |
to some performer) |
897
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1960 |
" |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1961 |
^ self showAt:aPoint |
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1962 |
|
6bbc8c15ac0a
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
890
diff
changeset
|
1963 |
"Created: / 21.5.1998 / 14:15:57 / cg" |
1750 | 1964 |
! |
1965 |
||
1966 |
startUpOrNil |
|
1967 |
"realize the menu at the current pointer position |
|
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1968 |
return the value of the selectedItem or nil, of none was selected |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1969 |
(unless the menu has already performed its action, by sending an appropriate message |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
1970 |
to some performer) |
1750 | 1971 |
" |
1972 |
^ self showAtPointer |
|
388 | 1973 |
! ! |
1974 |
||
1975 |
!MenuPanel methodsFor:'adding & removing'! |
|
1976 |
||
1977 |
createAtIndex:anIndexOrNil |
|
1800 | 1978 |
"create an item and add this item to the index. In case of nil, the item |
1979 |
is added to the end. If the index is not valid nil is returned; |
|
1980 |
otherwise the new created item is returned. |
|
388 | 1981 |
" |
1982 |
|max item| |
|
1983 |
||
1984 |
max := (items size) + 1. |
|
1985 |
||
1986 |
anIndexOrNil notNil ifTrue:[ |
|
2219 | 1987 |
(anIndexOrNil < 1 or:[anIndexOrNil > max]) ifTrue:[ |
1988 |
^ nil |
|
1989 |
] |
|
388 | 1990 |
]. |
1991 |
items isNil ifTrue:[ |
|
2219 | 1992 |
items := OrderedCollection new |
1151
199863d6a463
items: convert Array to OrderedCollection
Claus Gittinger <cg@exept.de>
parents:
1137
diff
changeset
|
1993 |
] ifFalse:[ |
2219 | 1994 |
items := items asOrderedCollection |
388 | 1995 |
]. |
1996 |
item := Item in:self. |
|
1997 |
||
1998 |
(anIndexOrNil isNil or:[anIndexOrNil == max]) ifTrue:[ |
|
2219 | 1999 |
items add:item |
388 | 2000 |
] ifFalse:[ |
2219 | 2001 |
items add:item beforeIndex:anIndexOrNil |
388 | 2002 |
]. |
2003 |
^ item |
|
2004 |
! |
|
2005 |
||
2006 |
remove:stringOrNumber |
|
2007 |
"remove the first item which is assigned to stringOrNumber; |
|
2008 |
if found, remove and return it |
|
2009 |
" |
|
2010 |
|item| |
|
2011 |
||
2012 |
(item := self itemAt:stringOrNumber) notNil ifTrue:[ |
|
2145 | 2013 |
items remove:item. |
2014 |
item destroy. |
|
2015 |
items isEmpty ifTrue:[items := nil]. |
|
2016 |
self mustRearrange. |
|
388 | 2017 |
]. |
2018 |
^ item |
|
2019 |
! |
|
2020 |
||
2021 |
removeAll |
|
2022 |
"remove all items and submenus |
|
2023 |
" |
|
2024 |
self disabledRedrawDo:[ |
|
2219 | 2025 |
self selection:nil. |
2026 |
groupSizes := nil. |
|
2027 |
items notNil ifTrue:[ |
|
2028 |
items copy do:[:el| el destroy ]. |
|
2029 |
]. |
|
2030 |
items := nil |
|
2050
ef5517d7a2d0
do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents:
2048
diff
changeset
|
2031 |
]. |
ef5517d7a2d0
do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents:
2048
diff
changeset
|
2032 |
|
ef5517d7a2d0
do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents:
2048
diff
changeset
|
2033 |
"Modified: / 15.11.2001 / 17:02:51 / cg" |
388 | 2034 |
! ! |
2035 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2036 |
!MenuPanel methodsFor:'change & update'! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2037 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2038 |
update:something with:aParameter from:changedObject |
498 | 2039 |
|
2040 |
changedObject == menuHolder ifTrue:[^ self menu:(menuHolder value)]. |
|
2041 |
changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)]. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2042 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2043 |
super update:something with:aParameter from:changedObject |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2044 |
! ! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2045 |
|
388 | 2046 |
!MenuPanel methodsFor:'converting'! |
2047 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2048 |
asMenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2049 |
"convert contents to menu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2050 |
" |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2051 |
|menu| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2052 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2053 |
menu := Menu new. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2054 |
menu groupSizes:groupSizes. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2055 |
self do:[:anItem| menu addItem:(anItem asMenuItem) ]. |
2059 | 2056 |
^ menu |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2057 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2058 |
|
388 | 2059 |
fromSpec:aMenuSpec |
2060 |
"build from spec |
|
2061 |
" |
|
2062 |
|menu| |
|
2063 |
||
2064 |
menu := Menu new. |
|
2065 |
menu fromLiteralArrayEncoding:aMenuSpec. |
|
2066 |
self menu:menu |
|
2067 |
||
2068 |
! |
|
2069 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2070 |
menu:aMenu |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2071 |
"convert to Menu |
388 | 2072 |
" |
2073 |
self disabledRedrawDo:[ |
|
2219 | 2074 |
|menu newItems| |
2075 |
||
2076 |
self removeAll. |
|
2077 |
||
2078 |
(menu := aMenu) notNil ifTrue:[ |
|
2079 |
(aMenu isCollection) ifTrue:[ |
|
2080 |
menu := Menu new. |
|
2081 |
menu fromLiteralArrayEncoding:aMenu. |
|
2082 |
] ifFalse:[ |
|
2083 |
menu receiver notNil ifTrue:[receiver := menu receiver] |
|
2084 |
]. |
|
2085 |
(newItems := menu menuItems) size > 0 ifTrue:[ |
|
2086 |
items := newItems collect:[:ni | |
|
2087 |
|i| |
|
2088 |
||
2089 |
i:= Item in:self. |
|
2090 |
i menuItem:ni. |
|
2091 |
i. |
|
2092 |
]. |
|
2093 |
]. |
|
2094 |
self groupSizes:(menu groupSizes). |
|
2095 |
] |
|
1063
08b7ca464437
dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
2096 |
] |
08b7ca464437
dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
2097 |
|
08b7ca464437
dont show accelerators for horizontal layouts
Claus Gittinger <cg@exept.de>
parents:
1054
diff
changeset
|
2098 |
"Modified: / 8.8.1998 / 02:05:04 / cg" |
388 | 2099 |
! ! |
2100 |
||
2101 |
!MenuPanel methodsFor:'drawing'! |
|
2102 |
||
2103 |
disabledRedrawDo:aBlock |
|
2104 |
"evaluate a block without redrawing within the block; after processing |
|
2105 |
of the block a redraw might be performed |
|
2106 |
" |
|
2107 |
|state| |
|
2108 |
||
2109 |
state := mustRearrange. |
|
2110 |
mustRearrange := true. |
|
2111 |
aBlock value. |
|
2112 |
mustRearrange := state. |
|
2113 |
self mustRearrange |
|
2114 |
! |
|
2115 |
||
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2116 |
drawButtonEdgesFor:anItem level:aLevel |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2117 |
|layout| |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2118 |
|
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2119 |
aLevel ~~ 0 ifTrue:[ |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2120 |
layout := anItem layout. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2121 |
|
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2122 |
styleSheet is3D ifFalse:[ |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2123 |
self displayRectangle:layout. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2124 |
] ifTrue:[ |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2125 |
self drawEdgesForX:(layout left) |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2126 |
y:(layout top) |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2127 |
width:(layout width) |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2128 |
height:(layout height) |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2129 |
level:aLevel |
2219 | 2130 |
shadow:(self buttonShadowColor) |
2131 |
light:(self buttonLightColor) |
|
2132 |
halfShadow:(self buttonHalfShadowColor) |
|
2133 |
halfLight:(self buttonHalfLightColor) |
|
2134 |
style:(self buttonEdgeStyle) |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2135 |
] |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2136 |
] |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2137 |
! |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2138 |
|
2016 | 2139 |
drawItemsX:x y:y width:w height:h |
2140 |
"redraw items and groups in a damage |
|
2141 |
" |
|
2142 |
|isVertical item layout prevClip |
|
2143 |
x1 "{ Class:SmallInteger }" |
|
2144 |
x2 "{ Class:SmallInteger }" |
|
2145 |
y1 "{ Class:SmallInteger }" |
|
2146 |
y2 "{ Class:SmallInteger }" |
|
2147 |
start "{ Class:SmallInteger }" |
|
2148 |
stop "{ Class:SmallInteger }" |
|
2149 |
size "{ Class:SmallInteger }" |
|
2150 |
groupDivInset "{ Class:SmallInteger }" |
|
2151 |
| |
|
2152 |
||
2153 |
size := items size. |
|
2154 |
isVertical := self verticalLayout. |
|
2155 |
||
2156 |
isVertical ifTrue:[ |
|
2064 | 2157 |
start := items findFirst:[:el| |l| l := el layout. l notNil and:[l bottom > y]]. |
2016 | 2158 |
start == 0 ifTrue:[ ^ self ]. |
2159 |
y1 := y + h. |
|
2064 | 2160 |
stop := items findFirst:[:el| |l| l := el layout. l notNil and:[l top > y1] ] |
2161 |
startingAt:(start + 1). |
|
2016 | 2162 |
] ifFalse:[ |
2064 | 2163 |
start := items findFirst:[:el| |l| l := el layout. l notNil and:[l right > x ]]. |
2016 | 2164 |
start == 0 ifTrue:[ ^ self ]. |
2165 |
x1 := x + w. |
|
2064 | 2166 |
stop := items findFirst:[:el| |l| l := el layout.l notNil and:[l left > x1]] |
2167 |
startingAt:(start + 1). |
|
2016 | 2168 |
]. |
2169 |
stop == 0 ifTrue:[stop := size] ifFalse:[stop := stop - 1]. |
|
2170 |
||
2171 |
(groupSizes size ~~ 0 and:[self showGroupDivider]) ifTrue:[ |
|
2219 | 2172 |
groupDivInset := self groupDividerSize // 2. |
2016 | 2173 |
|
2174 |
groupDivInset ~~ 0 ifTrue:[ |
|
2175 |
(start ~~ 1 and:[self hasGroupDividerAt:(start-1)]) ifTrue:[ |
|
2176 |
start := start - 1 |
|
2177 |
] |
|
2178 |
]. |
|
2179 |
] ifFalse:[ |
|
2180 |
groupDivInset := 0 |
|
2181 |
]. |
|
2182 |
||
2183 |
prevClip := clipRect. |
|
2184 |
self clippingRectangle:(Rectangle left:x top:y width:w height:h). |
|
2185 |
||
2186 |
start to:stop do:[:i| |
|
2187 |
item := items at:i. |
|
2188 |
item redraw. |
|
2189 |
||
2190 |
(groupDivInset ~~ 0 and:[i ~~ size and:[self hasGroupDividerAt:i]]) ifTrue:[ |
|
2191 |
layout := item layout. |
|
2192 |
||
2193 |
isVertical ifTrue:[ |
|
2194 |
x1 := layout left. |
|
2195 |
x2 := layout right. |
|
2196 |
y1 := layout bottom + groupDivInset. |
|
2197 |
y2 := y1. |
|
2198 |
] ifFalse:[ |
|
2199 |
y1 := layout top. |
|
2200 |
y2 := layout bottom. |
|
2201 |
x1 := layout right + groupDivInset. |
|
2202 |
x2 := x1. |
|
2203 |
]. |
|
2204 |
self paint:shadowColor. |
|
2205 |
self displayLineFromX:x1 y:y1 toX:x2 y:y2. |
|
2206 |
self paint:lightColor. |
|
2207 |
||
2208 |
isVertical ifTrue:[y1 := y1 + 1. y2 := y1 ] |
|
2209 |
ifFalse:[x1 := x1 + 1. x2 := x1 ]. |
|
2210 |
||
2211 |
self displayLineFromX:x1 y:y1 toX:x2 y:y2 |
|
2212 |
] |
|
2213 |
]. |
|
2214 |
self clippingRectangle:prevClip. |
|
2215 |
! |
|
2216 |
||
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2217 |
drawLabelEdgeFor:anItem selected:isSelected |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2218 |
|level layout| |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2219 |
|
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2220 |
isSelected ifTrue:[ |
2219 | 2221 |
level := styleSheet at:#'menu.hilightLevel' default:0. |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2222 |
] ifFalse:[ |
2219 | 2223 |
anItem == enteredItem ifTrue:[ level := self enteredLevel ] |
2224 |
ifFalse:[ level := 0 ] |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2225 |
]. |
1081
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
2226 |
|
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
2227 |
level ~~ 0 ifTrue:[ |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2228 |
layout := anItem layout. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2229 |
|
1691 | 2230 |
self drawEdgesForX:(layout left) |
2231 |
y:(layout top) |
|
2232 |
width:(layout width) |
|
2233 |
height:(layout height) |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2234 |
level:level |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2235 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2236 |
! |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2237 |
|
2016 | 2238 |
drawScrollerAt:aDirection bounds:bounds |
2239 |
"draw a scroller |
|
2240 |
" |
|
2241 |
|scrolling icon level x y w h| |
|
2242 |
||
2243 |
x := bounds left. |
|
2244 |
y := bounds top. |
|
2245 |
w := bounds width. |
|
2246 |
h := bounds height. |
|
2247 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2248 |
scrolling := self scrollActivity. |
2016 | 2249 |
|
2250 |
(scrolling activeMenu == self and:[scrolling direction == aDirection]) ifTrue:[ |
|
2219 | 2251 |
level := -2 |
2016 | 2252 |
] ifFalse:[ |
2219 | 2253 |
level := 1 |
2016 | 2254 |
]. |
2255 |
||
2256 |
level ~~ 0 ifTrue:[ |
|
2219 | 2257 |
self drawEdgesForX:x y:y width:w height:h level:level. |
2016 | 2258 |
]. |
2259 |
icon := scrolling iconAt:aDirection on:self. |
|
2260 |
||
2261 |
icon displayOn:self x:(x + (w - icon width // 2)) |
|
2219 | 2262 |
y:(y + (h - icon height // 2)). |
2016 | 2263 |
! |
2264 |
||
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2265 |
invalidateItem:anItem repairNow:aBool |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2266 |
"an item changed; invalidate the items layout |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2267 |
" |
2016 | 2268 |
|layout| |
2269 |
||
2073
26c30a04413d
do not invalidate if sensor is nil
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
2270 |
self sensor isNil ifTrue:[^ self]. |
26c30a04413d
do not invalidate if sensor is nil
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
2271 |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2272 |
(mustRearrange not and:[shown]) ifTrue:[ |
2219 | 2273 |
layout := anItem layout. |
2274 |
||
2275 |
(layout bottom > margin and:[layout top < (height - margin)]) ifTrue:[ |
|
2276 |
self invalidate:(layout copy insetBy:-1) repairNow:aBool |
|
2277 |
] |
|
1728 | 2278 |
]. |
2279 |
||
2280 |
"Modified: / 29.2.2000 / 11:28:59 / cg" |
|
746 | 2281 |
! |
2282 |
||
388 | 2283 |
mustRearrange |
910
5c9592e782fd
always repairNow (to make change visible immediately)
Claus Gittinger <cg@exept.de>
parents:
898
diff
changeset
|
2284 |
"force rearrange (i.e. set the rearrange flag) |
388 | 2285 |
" |
2080 | 2286 |
mustRearrange ifFalse:[ |
2219 | 2287 |
mustRearrange := true. |
2288 |
shown ifTrue:[ |
|
2289 |
self invalidate "/ RepairNow:true |
|
2290 |
] |
|
388 | 2291 |
] |
590 | 2292 |
|
911
6b1ad8b039c5
no, repairNow should not be needed here
Claus Gittinger <cg@exept.de>
parents:
910
diff
changeset
|
2293 |
"Modified: / 6.6.1998 / 19:51:07 / cg" |
388 | 2294 |
! |
2295 |
||
710 | 2296 |
rearrangeGroups |
1699 | 2297 |
"implements the groupIdentifier #right in a horizontal menu |
2298 |
" |
|
2299 |
|layout point |
|
710 | 2300 |
dltX "{ Class:SmallInteger }" |
2301 |
start "{ Class:SmallInteger }" |
|
2302 |
| |
|
2303 |
||
2304 |
(self isPopUpView or:[self verticalLayout]) ifTrue:[ |
|
2219 | 2305 |
^ self |
710 | 2306 |
]. |
2307 |
||
2308 |
layout := items last layout. |
|
2309 |
||
1699 | 2310 |
(dltX := width - margin - layout right) <= 0 ifTrue:[ |
2219 | 2311 |
^ self "/ no free space |
710 | 2312 |
]. |
2313 |
start := items findFirst:[:anItem| anItem startGroup == #right ]. |
|
2314 |
||
2315 |
start == 0 ifTrue:[ |
|
2219 | 2316 |
^ self "/ no item detected |
1699 | 2317 |
]. |
2318 |
point := dltX @ 0. |
|
2319 |
||
2320 |
"/ move items layout to right |
|
710 | 2321 |
|
2322 |
items from:start do:[:anItem| |
|
2219 | 2323 |
anItem isVisible ifTrue:[ |
2324 |
anItem layout moveBy:point. |
|
2325 |
] |
|
710 | 2326 |
]. |
2327 |
! |
|
2328 |
||
388 | 2329 |
rearrangeItems |
1699 | 2330 |
"recompute the layout of each item |
2016 | 2331 |
!!!!!! changes have influence on method #preferredExtentOfItems !!!!!! |
1699 | 2332 |
" |
1791 | 2333 |
|isVertical extent isPopUpMenu |
2219 | 2334 |
x "{ Class:SmallInteger }" |
2335 |
y "{ Class:SmallInteger }" |
|
2336 |
x0 "{ Class:SmallInteger }" |
|
2337 |
y0 "{ Class:SmallInteger }" |
|
2338 |
x1 "{ Class:SmallInteger }" |
|
2339 |
y1 "{ Class:SmallInteger }" |
|
2340 |
size "{ Class:SmallInteger }" |
|
2341 |
insetX "{ Class:SmallInteger }" |
|
2342 |
insetY "{ Class:SmallInteger }" |
|
2343 |
labelInsetX "{ Class:SmallInteger }" |
|
2344 |
labelInsetY "{ Class:SmallInteger }" |
|
2145 | 2345 |
buttonInsetX "{ Class:SmallInteger }" |
2346 |
buttonInsetY "{ Class:SmallInteger }" |
|
2219 | 2347 |
itemMargin "{ Class:SmallInteger }" |
2348 |
itemSpace "{ Class:SmallInteger }" |
|
2349 |
groupDividerSize "{ Class:SmallInteger }" |
|
710 | 2350 |
| |
1699 | 2351 |
(mustRearrange and:[(size := items size) ~~ 0]) ifFalse:[ |
1478 | 2352 |
mustRearrange := false. |
390 | 2353 |
^ self |
2354 |
]. |
|
2219 | 2355 |
|
2080 | 2356 |
"/ DON'T SET THIS!! |
2357 |
"/ item layout: below of first item -> item invalidate |
|
2358 |
"/ -> menuPanel invalidateItem:repairDamage: |
|
2359 |
"/ -> invalidate:rapairDamage: |
|
2360 |
"/ -> redrawX:y:width:height: |
|
2361 |
"/ tries to get uninitialized layout from second item. |
|
2362 |
"/ This happens in a modal debugger!! |
|
2363 |
"/ mustRearrange := false. |
|
2219 | 2364 |
isVertical := self verticalLayout. |
2365 |
itemSpace := self itemSpace. |
|
2366 |
groupDividerSize := self groupDividerSize. |
|
2367 |
buttonInsetX := self buttonInsetX. |
|
2368 |
buttonInsetY := self buttonInsetY. |
|
2369 |
isPopUpMenu := self isPopUpView. |
|
1791 | 2370 |
|
2371 |
isPopUpMenu ifFalse:[ |
|
2219 | 2372 |
labelInsetX := labelInsetY := self enteredLevel abs. |
1699 | 2373 |
] ifTrue:[ |
2145 | 2374 |
labelInsetX := labelInsetY := 0 |
388 | 2375 |
]. |
390 | 2376 |
|
2016 | 2377 |
(isPopUpMenu or:[explicitExtent ~~ true]) ifTrue:[ |savExt maxExt| |
2378 |
savExt := extent := self preferredExtent copy. |
|
1478 | 2379 |
|
1791 | 2380 |
isPopUpMenu ifFalse:[ |
1699 | 2381 |
isVertical ifTrue:[extent y:1.0] ifFalse:[extent x:1.0] |
2016 | 2382 |
] ifTrue:[ |
2383 |
savExt := extent copy. |
|
2384 |
maxExt := self maxExtent. |
|
2385 |
||
2386 |
isVertical ifTrue:[ |
|
2387 |
extent y:(extent y min:(maxExt y)) |
|
2388 |
] ifFalse:[ |
|
2389 |
extent x:(extent x min:(maxExt x)) |
|
2390 |
] |
|
1478 | 2391 |
]. |
2016 | 2392 |
self extent:extent. |
2393 |
extent := savExt. |
|
390 | 2394 |
] ifFalse:[ |
1699 | 2395 |
extent := self computeExtent |
390 | 2396 |
]. |
1082
382324ddce3f
support and additional buttonSpacing (for normal and win95 styles)
Claus Gittinger <cg@exept.de>
parents:
1081
diff
changeset
|
2397 |
|
1093 | 2398 |
x := y := margin. |
2399 |
||
1699 | 2400 |
isVertical ifFalse:[ |
2401 |
y0 := margin. |
|
2402 |
y1 := extent y - margin. |
|
2403 |
||
2404 |
items keysAndValuesDo:[:anIndex :el| |
|
2405 |
el isVisible ifFalse:[ |
|
2406 |
el layout:(Rectangle left:x top:y0 right:x bottom:y1) |
|
2407 |
] ifTrue:[ |
|
1478 | 2408 |
el isButton ifTrue:[ |
2145 | 2409 |
insetX := buttonInsetX. |
2410 |
insetY := buttonInsetY. |
|
2062 | 2411 |
] ifFalse:[ |
2145 | 2412 |
insetX := labelInsetX. |
2413 |
insetY := labelInsetY. |
|
1478 | 2414 |
]. |
2145 | 2415 |
x0 := x + insetX. |
2171 | 2416 |
x1 := x0 + (el preferredExtent x). |
2145 | 2417 |
el layout:(Rectangle left:x0 top:(y0 + insetY) right:x1 bottom:(y1 - insetY)). |
2418 |
x := x1 + insetX. |
|
1699 | 2419 |
|
2420 |
size ~~ anIndex ifTrue:[ |
|
2421 |
(self hasGroupDividerAt:anIndex) ifTrue:[ |
|
2422 |
x := x + groupDividerSize |
|
2423 |
] ifFalse:[ |
|
1723
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
2424 |
el isLabeledItem ifTrue:[ |
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
2425 |
x := x + itemSpace |
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
2426 |
] |
1699 | 2427 |
] |
2428 |
] |
|
1478 | 2429 |
]. |
1699 | 2430 |
]. |
2431 |
] ifTrue:[ |
|
2219 | 2432 |
itemMargin := self itemMargin. |
1699 | 2433 |
x0 := margin. |
2219 | 2434 |
x1 := extent x - margin - itemMargin. "/ -1 |
1699 | 2435 |
|
2436 |
items keysAndValuesDo:[:anIndex :el| |
|
2437 |
el isVisible ifFalse:[ |
|
2438 |
el layout:(Rectangle left:x0 top:y right:x1 bottom:y) |
|
2439 |
] ifTrue:[ |
|
2440 |
el isButton ifTrue:[ |
|
2145 | 2441 |
insetX := buttonInsetX. |
2442 |
insetY := buttonInsetY. |
|
1699 | 2443 |
] ifFalse:[ |
2145 | 2444 |
insetX := labelInsetX. |
2445 |
insetY := labelInsetY. |
|
1699 | 2446 |
]. |
2145 | 2447 |
y0 := y + insetY. |
1699 | 2448 |
y1 := y0 + el preferredExtent y. |
2219 | 2449 |
el layout:(Rectangle left:(x0 + insetX + itemMargin) top:y0 right:(x1 - insetX) bottom:y1). |
2145 | 2450 |
y := y1 + insetY. |
1699 | 2451 |
|
2452 |
size ~~ anIndex ifTrue:[ |
|
2453 |
(self hasGroupDividerAt:anIndex) ifTrue:[ |
|
2454 |
y := y + groupDividerSize |
|
2455 |
] |
|
2456 |
] |
|
1478 | 2457 |
] |
2458 |
] |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
2459 |
]. |
710 | 2460 |
self rearrangeGroups. |
2048 | 2461 |
selection notNil ifTrue:[self makeItemVisible:selection]. |
388 | 2462 |
mustRearrange := false. |
2048 | 2463 |
|
2464 |
"Modified: / 13.11.2001 / 20:17:21 / cg" |
|
388 | 2465 |
! |
2466 |
||
1217
c6a4c536aa8c
care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2467 |
rearrangeItemsIfItemVisibilityChanged |
1699 | 2468 |
"check for items which can change its visibility; |
2469 |
if at least one item exists, rearrange all items |
|
2470 |
" |
|
1464 | 2471 |
items isNil ifTrue:[^ self]. |
1699 | 2472 |
|
1217
c6a4c536aa8c
care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2473 |
items do:[:item | |
2219 | 2474 |
item canChangeVisibility ifTrue:[ |
2475 |
mustRearrange := true. |
|
2476 |
self rearrangeItems. |
|
2477 |
^ self |
|
2478 |
]. |
|
1217
c6a4c536aa8c
care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2479 |
] |
c6a4c536aa8c
care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2480 |
! |
c6a4c536aa8c
care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
2481 |
|
388 | 2482 |
redrawX:x y:y width:w height:h |
2016 | 2483 |
"redraw a damage |
2484 |
" |
|
2052 | 2485 |
|y0 y1 x0 x1 bounds mustDrawPrevScroller mustDrawNextScroller| |
388 | 2486 |
|
710 | 2487 |
(shown and:[w ~~ 0]) ifFalse:[^ self]. |
388 | 2488 |
|
1699 | 2489 |
mustRearrange ifTrue:[ |
2490 |
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
|
2491 |
self rearrangeItems. |
1699 | 2492 |
^ self invalidate |
2493 |
]. |
|
2219 | 2494 |
self paint:(self viewBackground). |
1699 | 2495 |
self clearRectangleX:x y:y width:w height:h. |
2496 |
||
2016 | 2497 |
items size == 0 ifTrue:[ |
1699 | 2498 |
^ self |
2499 |
]. |
|
2016 | 2500 |
y0 := y. |
2501 |
y1 := y + h. |
|
2018 | 2502 |
x0 := x. |
2503 |
x1 := x + w. |
|
2016 | 2504 |
|
2505 |
self hasScrollers ifTrue:[ |
|
2506 |
(self hasScrollerAt:#PREV) ifTrue:[ |
|
2507 |
bounds := self scrollerBoundsAt:#PREV. |
|
2052 | 2508 |
mustDrawPrevScroller := false. |
2016 | 2509 |
|
2018 | 2510 |
self verticalLayout ifTrue:[ |
2511 |
bounds bottom > y ifTrue:[ |
|
2512 |
y0 := bounds bottom. |
|
2052 | 2513 |
mustDrawPrevScroller := true. |
2018 | 2514 |
]. |
2515 |
] ifFalse:[ |
|
2516 |
bounds right > x ifTrue:[ |
|
2517 |
x0 := bounds right. |
|
2052 | 2518 |
mustDrawPrevScroller := true. |
2018 | 2519 |
]. |
2052 | 2520 |
]. |
2521 |
mustDrawPrevScroller ifTrue:[ |
|
2522 |
self drawScrollerAt:#PREV bounds:bounds. |
|
2523 |
]. |
|
1387
ad7a920fdf61
less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents:
1382
diff
changeset
|
2524 |
]. |
2016 | 2525 |
|
2526 |
(self hasScrollerAt:#NEXT) ifTrue:[ |
|
2527 |
bounds := self scrollerBoundsAt:#NEXT. |
|
2052 | 2528 |
mustDrawNextScroller := false. |
2016 | 2529 |
|
2018 | 2530 |
self verticalLayout ifTrue:[ |
2531 |
bounds top < y1 ifTrue:[ |
|
2532 |
y1 := bounds top. |
|
2052 | 2533 |
mustDrawNextScroller := true. |
2018 | 2534 |
] |
2535 |
] ifFalse:[ |
|
2536 |
bounds left < x1 ifTrue:[ |
|
2537 |
x1 := bounds left. |
|
2052 | 2538 |
mustDrawNextScroller := true. |
2018 | 2539 |
] |
2052 | 2540 |
]. |
2541 |
mustDrawNextScroller ifTrue:[ |
|
2542 |
self drawScrollerAt:#NEXT bounds:bounds. |
|
2543 |
]. |
|
1387
ad7a920fdf61
less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents:
1382
diff
changeset
|
2544 |
] |
ad7a920fdf61
less flicker by using a clipRect in redraw
Claus Gittinger <cg@exept.de>
parents:
1382
diff
changeset
|
2545 |
]. |
2018 | 2546 |
(y1 > y0 and:[x1 > x0]) ifTrue:[ |
2547 |
self drawItemsX:x0 y:y0 width:(x1 - x0) height:(y1 - y0) |
|
2016 | 2548 |
]. |
2052 | 2549 |
|
2550 |
"Modified: / 15.11.2001 / 20:57:32 / cg" |
|
388 | 2551 |
! ! |
2552 |
||
2553 |
!MenuPanel methodsFor:'enumerting & searching'! |
|
2554 |
||
2555 |
collect:aOneArgBlock |
|
2556 |
"evaluate the argument, aOneArgBlock for every item in the menuPanel |
|
2557 |
and return a collection of the results |
|
2558 |
" |
|
2559 |
items notNil ifTrue:[^ items collect:aOneArgBlock ]. |
|
2059 | 2560 |
^ nil |
388 | 2561 |
! |
2562 |
||
2563 |
do:aOneArgBlock |
|
2564 |
"evaluate the argument, aOneArgBlock for every item in the menuPanel. |
|
2565 |
" |
|
2566 |
items notNil ifTrue:[ items do:aOneArgBlock ]. |
|
2567 |
||
2568 |
! |
|
2569 |
||
2570 |
findFirst:aOneArgBlock |
|
2571 |
"find the first item, for which evaluation of the argument, aOneArgBlock |
|
2572 |
returns true; return its index or 0 if none detected. |
|
2573 |
" |
|
2574 |
items notNil ifTrue:[ ^ items findFirst:aOneArgBlock ]. |
|
2575 |
^ 0 |
|
2576 |
||
2577 |
! |
|
2578 |
||
2579 |
findLast:aOneArgBlock |
|
2580 |
"find the last item, for which evaluation of the argument, aOneArgBlock |
|
2581 |
returns true; return its index or 0 if none detected. |
|
2582 |
" |
|
2583 |
items notNil ifTrue:[ ^ items findLast:aOneArgBlock ]. |
|
2584 |
^ 0 |
|
2585 |
||
2586 |
! |
|
2587 |
||
390 | 2588 |
indexOf:something |
2589 |
"returns index of an item assigned to an index, nameKey, textLabel or value if symbol. |
|
2590 |
If no item match 0 is returned. No range checks are performed on a number argument |
|
388 | 2591 |
" |
390 | 2592 |
|i v| |
2593 |
||
2594 |
something isNumber ifTrue:[ ^ something ]. |
|
2595 |
something isNil ifTrue:[ ^ 0 ]. |
|
2596 |
||
1218 | 2597 |
i := self findFirst:[:el | (el nameKey = something) or: [el = something]]. |
390 | 2598 |
|
2599 |
i ~~ 0 ifTrue:[ |
|
2145 | 2600 |
^ i |
388 | 2601 |
]. |
390 | 2602 |
|
2603 |
something isSymbol ifTrue:[ |
|
2145 | 2604 |
i := self findFirst:[:el| |
2605 |
v := el value. |
|
2606 |
v isSymbol and:[v == something] |
|
2607 |
]. |
|
2608 |
i ~~ 0 ifTrue:[ |
|
2609 |
^ i |
|
2610 |
] |
|
390 | 2611 |
]. |
2612 |
||
2613 |
(something respondsTo:#string) ifTrue:[ |
|
2145 | 2614 |
v := something string. |
1218 | 2615 |
^ self findFirst:[:el | el textLabel = v]. |
2616 |
]. |
|
2617 |
^ 0 |
|
388 | 2618 |
! |
2619 |
||
706 | 2620 |
indexOfItem:anItem |
2621 |
"returns the index of the item or 0 |
|
2622 |
" |
|
2623 |
^ items notNil ifTrue:[items identityIndexOf:anItem] ifFalse:[0] |
|
2624 |
! |
|
2625 |
||
388 | 2626 |
keysAndValuesDo:aTwoArgBlock |
2627 |
"evaluate the argument, aTwoArgBlock for every item in the menuPanel. |
|
2628 |
" |
|
2629 |
items notNil ifTrue:[ items keysAndValuesDo:aTwoArgBlock ]. |
|
2630 |
||
2631 |
! ! |
|
2632 |
||
2633 |
!MenuPanel methodsFor:'event handling'! |
|
2634 |
||
2635 |
buttonMotion:state x:x y:y |
|
2636 |
"open or close the corresponding submenus |
|
2637 |
" |
|
2046 | 2638 |
|menue motionPoint translatedPoint sensor| |
1699 | 2639 |
|
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2640 |
self scrollActivity isActive ifTrue:[ |
2219 | 2641 |
^ self |
2016 | 2642 |
]. |
2643 |
||
1699 | 2644 |
sensor := self sensor. |
2645 |
||
2646 |
(sensor isNil or:[sensor hasButtonMotionEventFor:nil]) ifTrue:[ |
|
2219 | 2647 |
^ self |
1699 | 2648 |
]. |
2649 |
menue := self detectGrabMenu. |
|
1841 | 2650 |
|
2046 | 2651 |
motionPoint := x@y. |
2652 |
translatedPoint := menue translateGrabPoint:motionPoint. |
|
2048 | 2653 |
menue handleButtonMotion:state atPoint:translatedPoint. |
1699 | 2654 |
|
2655 |
(self isPopUpView or:[sensor anyButtonPressed]) ifTrue:[ |
|
2219 | 2656 |
^ self |
1699 | 2657 |
]. |
2658 |
||
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
2659 |
(selection notNil and:[selection visibleSubmenu isNil]) ifTrue:[ |
2219 | 2660 |
"/ selection on grabView withou a submenu (Button ...); check whether moving out |
2661 |
(self containsPoint:motionPoint) ifFalse:[ |
|
2662 |
^ self accept:nil |
|
2663 |
] |
|
1699 | 2664 |
]. |
2665 |
||
2048 | 2666 |
"Modified: / 13.11.2001 / 20:21:49 / cg" |
1699 | 2667 |
! |
2668 |
||
2162 | 2669 |
buttonMultiPress:button x:x y:y |
2670 |
"/ self buttonPress:button x:x y:y |
|
2671 |
! |
|
2672 |
||
1699 | 2673 |
buttonPress:button x:x y:y |
2674 |
"any button pressed; open or close the corresponding submenus |
|
2675 |
" |
|
2016 | 2676 |
|menu point| |
2677 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2678 |
self scrollActivity stop. |
2016 | 2679 |
point := x@y. |
2680 |
menu := self detectMenuAtGrabPoint:point. |
|
2681 |
||
2682 |
menu isNil ifTrue:[ |
|
2133
293dadf237ad
hide on buttonRelease outside (instead of buttonPress outside)
Claus Gittinger <cg@exept.de>
parents:
2132
diff
changeset
|
2683 |
"/ self accept:nil |
2016 | 2684 |
] ifFalse:[ |
2219 | 2685 |
point := menu translateGrabPoint:point. |
2686 |
menu handleButtonPressAtPoint:point. |
|
2016 | 2687 |
] |
2046 | 2688 |
|
2689 |
"Modified: / 13.11.2001 / 14:12:32 / cg" |
|
1699 | 2690 |
! |
2691 |
||
2692 |
buttonRelease:button x:x y:y |
|
2693 |
"button release action; accept selection and close all views |
|
2694 |
" |
|
2199 | 2695 |
|topMenu dstMenu item srcPoint dstPoint subm| |
2696 |
||
2697 |
topMenu := self topMenu. |
|
2698 |
topMenu openDelayed:nil. |
|
1699 | 2699 |
|
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2700 |
self scrollActivity stop ifTrue:[ |
2219 | 2701 |
^ self |
2016 | 2702 |
]. |
2703 |
||
1699 | 2704 |
dstMenu := topMenu activeMenu. |
2705 |
||
2706 |
( dstMenu selection notNil |
|
2707 |
or:[dstMenu isPopUpView not |
|
2708 |
or:[(OperatingSystem millisecondTimeDeltaBetween:(Time millisecondClockValue) |
|
2219 | 2709 |
and:(dstMenu mapTime)) > 400]] |
388 | 2710 |
) ifTrue:[ |
2219 | 2711 |
srcPoint := x@y. |
1699 | 2712 |
|
2219 | 2713 |
( (dstMenu := self detectMenuAtGrabPoint:srcPoint) notNil |
2714 |
and:[(item := dstMenu selection) notNil] |
|
2715 |
) ifTrue:[ |
|
2716 |
item visibleSubmenu notNil ifTrue:[ |
|
2717 |
dstMenu selection:nil. |
|
2718 |
||
2719 |
(selection isNil and:[self isPopUpView not]) ifTrue:[ |
|
2720 |
self accept:nil |
|
2721 |
]. |
|
2722 |
^ self |
|
2723 |
||
2724 |
]. |
|
2725 |
subm := item currentSubmenu. |
|
2726 |
||
2727 |
subm ifNotNil:[ |
|
2728 |
subm shown ifTrue:[^ self]. |
|
2729 |
"/ test whether any action is assigned to the menu |
|
2730 |
"/ if not ignorre accept |
|
2731 |
item hasDelayedMenu ifFalse:[^ self]. |
|
2732 |
"/ handle action defined for the delayed menu |
|
2733 |
]. |
|
2734 |
dstPoint := dstMenu translateGrabPoint:srcPoint. |
|
2735 |
||
2736 |
(dstMenu itemAtX:(dstPoint x) y:(dstPoint y)) == dstMenu selection ifFalse:[ |
|
2737 |
item := nil |
|
2738 |
]. |
|
2739 |
topMenu acceptItem:item inMenu:dstMenu. |
|
2740 |
^ self |
|
2741 |
]. |
|
2742 |
||
2743 |
(selection notNil and:[dstMenu == self]) ifTrue:[ |
|
2744 |
selection visibleSubmenu notNil ifTrue:[ |
|
2745 |
^ self |
|
2746 |
] |
|
2747 |
]. |
|
2748 |
self accept:nil. |
|
1699 | 2749 |
]. |
2750 |
! |
|
2751 |
||
2752 |
keyPress:key x:x y:y |
|
2753 |
"any key is pressed |
|
2754 |
" |
|
2219 | 2755 |
|menu| |
1699 | 2756 |
|
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2757 |
self scrollActivity isActive ifTrue:[ |
2016 | 2758 |
key ~~ #Escape ifTrue:[ |
2759 |
^ self |
|
2760 |
]. |
|
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2761 |
self scrollActivity stop |
2016 | 2762 |
]. |
2763 |
||
1699 | 2764 |
(key == #Tab |
2765 |
or:[key == #FocusNext |
|
2766 |
or:[key == #FocusPrevious]]) ifTrue:[ |
|
2767 |
self accept:nil. |
|
2768 |
^ super keyPress:key x:x y:y |
|
2769 |
]. |
|
2770 |
||
2771 |
menu := self detectGrabMenu. |
|
2772 |
||
2773 |
key == #Escape ifTrue:[ |
|
2774 |
"/ must hide the active menu |
|
1703 | 2775 |
((menu := menu superMenu) notNil and:[menu ~~ self]) ifTrue:[ |
2776 |
"/ hide active menu but keep the grab |
|
2777 |
menu selection:nil |
|
1699 | 2778 |
] ifFalse:[ |
1703 | 2779 |
"/ hide active menu and ungrab |
1699 | 2780 |
self accept:nil |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
2781 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
2782 |
] ifFalse:[ |
1793 | 2783 |
menu isViewWrapper ifFalse:[ |
2784 |
self sensor compressKeyPressEventsWithKey:key. |
|
2785 |
||
2786 |
menu handleKeyPress:key. |
|
2787 |
||
1836
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
2788 |
"/ selection isNil ifTrue:[ |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
2789 |
"/ self accept:nil keepValue:true |
89a1b938c09e
fixed returned value from non-performing menu
Claus Gittinger <cg@exept.de>
parents:
1832
diff
changeset
|
2790 |
"/ ] |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
2791 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
2792 |
]. |
1699 | 2793 |
! |
2794 |
||
2795 |
pointerLeave:state |
|
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
2796 |
self scrollActivity isActive ifTrue:[^ self]. |
2016 | 2797 |
|
1699 | 2798 |
self detectGrabMenu handlePointerLeave:state. |
2799 |
||
2800 |
self isPopUpView ifTrue:[ |
|
2219 | 2801 |
^ self |
1699 | 2802 |
]. |
2016 | 2803 |
(selection notNil and:[selection hasSubmenu not]) ifTrue:[ |
2219 | 2804 |
"/ selection on grabView withou a submenu (Button ...); check whether moving out |
2141
1a9381cdeb13
turn off button when leaving the view with mouse-button pressed
Claus Gittinger <cg@exept.de>
parents:
2137
diff
changeset
|
2805 |
"/ self sensor anyButtonPressed ifFalse:[ |
2219 | 2806 |
self accept:nil. |
2141
1a9381cdeb13
turn off button when leaving the view with mouse-button pressed
Claus Gittinger <cg@exept.de>
parents:
2137
diff
changeset
|
2807 |
"/ ]. |
1699 | 2808 |
]. |
2809 |
! |
|
2810 |
||
2811 |
sizeChanged:how |
|
2812 |
"redraw #right groups |
|
2813 |
" |
|
2018 | 2814 |
self isPopUpView ifFalse:[ |
2219 | 2815 |
mustRearrange := true. |
2816 |
shown ifTrue:[ |
|
2817 |
self invalidate |
|
2818 |
] |
|
1699 | 2819 |
]. |
2820 |
super sizeChanged:how |
|
2821 |
! ! |
|
2822 |
||
2823 |
!MenuPanel methodsFor:'event handling processing'! |
|
2824 |
||
1767 | 2825 |
clearImplicitGrab |
2826 |
self menuAdornmentAt:#implicitGrabView put:nil. |
|
2827 |
self menuAdornmentAt:#lastPointerView put:nil. |
|
2828 |
||
2829 |
||
2830 |
! |
|
2831 |
||
2832 |
dispatchEvent:ev withFocusOn:focusView delegate:doDelegate |
|
2833 |
"dispatch and handle an event |
|
2834 |
" |
|
2835 |
|view x y p syntheticEvent implicitGrabView lastPointerView menu| |
|
2836 |
||
2837 |
implicitGrabView := self menuAdornmentAt:#implicitGrabView. |
|
2838 |
||
2839 |
"/ situation: we get a buttonPress, set implicitGrab (for scrollbars etc.) |
|
2840 |
"/ but never get the buttonRelease, since someone else (a popUp) grabbed the |
|
2841 |
"/ pointer in the meantime, and has eaten the release event ... (double-sigh) |
|
2842 |
implicitGrabView notNil ifTrue:[ |
|
2219 | 2843 |
self sensor leftButtonPressed ifFalse:[ |
2844 |
self clearImplicitGrab. |
|
2845 |
]. |
|
1767 | 2846 |
]. |
2847 |
||
2848 |
((x := ev x) isNil or:[(y := ev y) isNil]) ifTrue:[ |
|
2219 | 2849 |
^ super dispatchEvent:ev withFocusOn:focusView delegate:false. |
1767 | 2850 |
]. |
2851 |
||
2852 |
implicitGrabView notNil ifTrue:[ |
|
2219 | 2853 |
ev isButtonEvent ifTrue:[ |
2854 |
p := device translatePoint:(x@y) fromView:self toView:implicitGrabView. |
|
2855 |
ev view:implicitGrabView. |
|
2856 |
ev arguments at:2 put:p x. |
|
2857 |
ev arguments at:3 put:p y. |
|
2858 |
implicitGrabView dispatchEvent:ev withFocusOn:focusView delegate:false. |
|
2859 |
||
2860 |
ev isButtonReleaseEvent ifTrue:[ |
|
2861 |
self clearImplicitGrab. |
|
2862 |
]. |
|
2863 |
^ self |
|
2864 |
] |
|
1767 | 2865 |
]. |
2866 |
menu := self detectMenuAtGrabPoint:(x@y). |
|
2867 |
||
2016 | 2868 |
(menu isNil or:[menu isViewWrapper not]) ifTrue:[ |
2219 | 2869 |
self clearImplicitGrab. |
1767 | 2870 |
^ super dispatchEvent:ev withFocusOn:focusView delegate:false |
2871 |
]. |
|
2872 |
||
2873 |
p := menu translateGrabPoint:(x@y). |
|
2874 |
view := self detectViewAtX:(p x) y:(p y) in:menu. |
|
2020
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
2875 |
p := device translatePoint:(x@y) fromView:self toView:view. |
1767 | 2876 |
|
2877 |
ev isButtonPressEvent ifTrue:[ |
|
2219 | 2878 |
(view wantsFocusWithButtonPress) ifTrue:[ |
2879 |
view requestFocus. |
|
2880 |
]. |
|
2881 |
view ~~ self ifTrue:[ "/ can this ever be self ? |
|
2882 |
self menuAdornmentAt:#implicitGrabView put:view. |
|
2883 |
] |
|
1767 | 2884 |
]. |
2885 |
lastPointerView := self menuAdornmentAt:#lastPointerView. |
|
2886 |
||
2887 |
ev isButtonMotionEvent ifTrue:[ |
|
2219 | 2888 |
lastPointerView ~~ view ifTrue:[ |
2889 |
"/ must generate enter/leave ... (sigh) |
|
2890 |
lastPointerView notNil ifTrue:[ |
|
2891 |
"/ XXX: should be fixed |
|
2892 |
syntheticEvent := WindowEvent pointerLeave:0 view:lastPointerView. |
|
2893 |
lastPointerView dispatchEvent:syntheticEvent withFocusOn:nil delegate:false. |
|
2894 |
]. |
|
2895 |
view notNil ifTrue:[ |
|
2896 |
syntheticEvent := WindowEvent pointerEnter:0 x:x y:y view:view. |
|
2897 |
view dispatchEvent:syntheticEvent withFocusOn:nil delegate:false. |
|
2898 |
]. |
|
2899 |
self menuAdornmentAt:#lastPointerView put:view. |
|
2900 |
]. |
|
1767 | 2901 |
]. |
2902 |
||
2903 |
ev view:view. |
|
2904 |
ev x:p x. |
|
2905 |
ev y:p y. |
|
2906 |
view dispatchEvent:ev withFocusOn:focusView delegate:false. |
|
2020
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
2907 |
|
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
2908 |
"Modified: / 10.10.2001 / 13:54:47 / cg" |
1767 | 2909 |
! |
2910 |
||
2048 | 2911 |
handleButtonMotion:state atPoint:motionPoint |
1699 | 2912 |
"open or close the corresponding submenus |
2913 |
" |
|
2048 | 2914 |
|menu translatedPoint sel| |
1699 | 2915 |
|
1910 | 2916 |
(state == 0 or:[self sensor anyButtonPressed not]) ifTrue:[ |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2917 |
"/ highlight enterItem if no selection exists |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2918 |
selection isNil ifTrue:[ |
2046 | 2919 |
(self containsPoint:motionPoint) ifTrue:[ |
2920 |
((sel := self itemAtPoint:motionPoint) isNil or:[sel canSelect not]) ifTrue:[ |
|
1699 | 2921 |
^ self pointerEntersItem:nil |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2922 |
]. |
2219 | 2923 |
(superMenu notNil and:[self selectionFollowsMouse]) ifTrue:[ |
2061 | 2924 |
self select:sel openMenu:true. |
2925 |
"/ self openMenuOnSelect:true. |
|
2926 |
"/ self selection:sel. |
|
2927 |
"/ self openMenuOnSelect:nil. |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2928 |
] ifFalse:[ |
1699 | 2929 |
self pointerEntersItem:sel |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2930 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2931 |
^ self |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2932 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2933 |
]. |
1699 | 2934 |
self pointerEntersItem:nil. |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2935 |
|
2219 | 2936 |
( self selectionFollowsMouse |
2937 |
and:[(menu := self superMenuAtPoint:motionPoint) notNil] |
|
2938 |
) ifTrue:[ |
|
2046 | 2939 |
translatedPoint := self translateMenuPoint:motionPoint toMenu:menu. |
2940 |
sel := menu itemAtPoint:translatedPoint. |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2941 |
|
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2942 |
(sel notNil and:[sel canSelect]) ifTrue:[ |
2096 | 2943 |
menu select:sel openMenu:true. |
2061 | 2944 |
"/ self openMenuOnSelect:true. |
2945 |
"/ self selection:sel. |
|
2946 |
"/ self openMenuOnSelect:nil. |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2947 |
] |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2948 |
]. |
2048 | 2949 |
^ self |
2950 |
]. |
|
2951 |
||
1699 | 2952 |
self pointerEntersItem:nil. |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2953 |
|
2048 | 2954 |
(menu := self superMenuAtPoint:motionPoint) isNil ifTrue:[ |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2955 |
self isPopUpView ifTrue:[ |
1699 | 2956 |
self selection:nil |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2957 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2958 |
^ self |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2959 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
2960 |
|
1699 | 2961 |
menu == self ifTrue:[ |
2046 | 2962 |
(sel := self itemAtPoint:motionPoint) notNil ifTrue:[ |
2061 | 2963 |
self select:sel openMenu:true. |
2964 |
"/ self openMenuOnSelect:true. |
|
2965 |
"/ self selection:sel. |
|
2966 |
"/ self openMenuOnSelect:nil. |
|
1699 | 2967 |
]. |
388 | 2968 |
] ifFalse:[ |
2046 | 2969 |
translatedPoint := self translateMenuPoint:motionPoint toMenu:menu. |
2970 |
sel := menu itemAtPoint:translatedPoint. |
|
1699 | 2971 |
|
2972 |
(sel isNil and:[menu isPopUpView not]) ifTrue:[ |
|
2973 |
sel := menu selection. |
|
2974 |
]. |
|
2061 | 2975 |
menu select:sel openMenu:true. |
2976 |
"/ menu openMenuOnSelect:true. |
|
2977 |
"/ menu selection:sel. |
|
2978 |
"/ menu openMenuOnSelect:nil. |
|
1699 | 2979 |
] |
2980 |
||
2048 | 2981 |
"Created: / 13.11.2001 / 20:21:24 / cg" |
2982 |
"Modified: / 13.11.2001 / 20:26:32 / cg" |
|
2046 | 2983 |
! |
2984 |
||
2985 |
handleButtonPressAtPoint:aPoint |
|
2016 | 2986 |
"a button pressed; open or close the corresponding submenus |
2987 |
" |
|
2199 | 2988 |
|triggerOnDown item sensor direction| |
2016 | 2989 |
|
2046 | 2990 |
item := self itemAtPoint:aPoint. |
2016 | 2991 |
|
2992 |
item notNil ifTrue:[ |
|
2219 | 2993 |
direction := self scrollerDirectionAtPoint:aPoint. |
2994 |
direction notNil ifTrue:[ |
|
2995 |
(self scrollActivity startIfRequiredAt:direction on:self) ifTrue:[ |
|
2996 |
self pointerEntersItem:nil. |
|
2997 |
^ self |
|
2998 |
] |
|
2999 |
] |
|
2016 | 3000 |
]. |
3001 |
||
3002 |
self openMenuOnSelect:true. |
|
3003 |
self selection:item. |
|
3004 |
self openMenuOnSelect:nil. |
|
3005 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3006 |
item isNil ifTrue:[^ self]. |
2199 | 3007 |
item hasDelayedMenu ifTrue:[^ self]. |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3008 |
|
2159
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
3009 |
triggerOnDown := item triggerOnDown. |
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
3010 |
|
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
3011 |
((item isToggle or:[triggerOnDown]) |
2016 | 3012 |
and:[item canAccept |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
3013 |
and:[item == self selection]] |
2016 | 3014 |
) ifTrue:[ |
2219 | 3015 |
self invalidateItem:item repairNow:true. |
3016 |
self acceptItem:item inMenu:self. |
|
3017 |
||
3018 |
self selection == item ifTrue:[ |
|
3019 |
(sensor := self sensor) notNil ifTrue:[ |
|
3020 |
[sensor anyButtonPressed] whileTrue:[ Delay waitForSeconds:0.1 ]. |
|
3021 |
sensor flushUserEvents. |
|
3022 |
]. |
|
3023 |
self selection:nil. |
|
3024 |
] |
|
2016 | 3025 |
]. |
2046 | 3026 |
|
3027 |
"Created: / 13.11.2001 / 14:12:04 / cg" |
|
2047
62de65e3a61b
initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents:
2046
diff
changeset
|
3028 |
"Modified: / 13.11.2001 / 19:50:52 / cg" |
2016 | 3029 |
! |
3030 |
||
1699 | 3031 |
handleCursorKey:aKey |
388 | 3032 |
"handle a cursor key |
3033 |
" |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3034 |
|next menu item isVrt backKey p1 p2 |
687 | 3035 |
idx "{ Class:SmallInteger }" |
1705 | 3036 |
size "{ Class:SmallInteger }" |
687 | 3037 |
| |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3038 |
(size := items size) == 0 ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3039 |
superMenu notNil ifTrue:[superMenu handleCursorKey:aKey]. |
388 | 3040 |
^ self |
3041 |
]. |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3042 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3043 |
isVrt := self verticalLayout. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3044 |
|
2016 | 3045 |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3046 |
( (isVrt and:[aKey == #CursorUp or:[aKey == #CursorDown]]) |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3047 |
or:[(isVrt not and:[aKey == #CursorRight or:[aKey == #CursorLeft]])] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3048 |
) ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3049 |
selection isNil ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3050 |
(superMenu notNil and:[superMenu verticalLayout == isVrt]) ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3051 |
^ superMenu handleCursorKey:aKey |
1699 | 3052 |
]. |
2016 | 3053 |
idx := 0. |
3054 |
||
3055 |
isVrt ifTrue:[ |
|
3056 |
"/ used because of vertical scrolling |
|
3057 |
idx := items findFirst:[:el| el layout top > 0 ]. |
|
3058 |
idx ~~ 0 ifTrue:[idx := idx := idx - 1 ] |
|
3059 |
]. |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3060 |
] ifFalse:[ |
2016 | 3061 |
idx := self indexOf:selection. |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3062 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3063 |
next := aKey == #CursorRight or:[aKey == #CursorDown]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3064 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3065 |
size timesRepeat:[|el| |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3066 |
next ifTrue:[(idx := idx + 1) > size ifTrue:[idx := 1]] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3067 |
ifFalse:[(idx := idx - 1) < 1 ifTrue:[idx := size]]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3068 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3069 |
(el := items at:idx ifAbsent:nil) notNil ifTrue:[ |
2219 | 3070 |
el canSelect ifTrue:[ |
3071 |
self selection:el. |
|
3072 |
self openDelayed:nil. "/ do not open delayed |
|
3073 |
^ self |
|
3074 |
]. |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3075 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3076 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3077 |
^ self |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3078 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3079 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3080 |
superMenu notNil ifTrue:[ |
1791 | 3081 |
p1 := self translateGrabPoint:0. |
3082 |
p2 := superMenu translateGrabPoint:0. |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3083 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3084 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3085 |
isVrt ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3086 |
(superMenu notNil and:[p1 x > p2 x]) ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3087 |
backKey := #CursorRight |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3088 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3089 |
backKey := #CursorLeft. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3090 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3091 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3092 |
(superMenu notNil and:[p1 y > p2 y]) ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3093 |
backKey := #CursorDown |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3094 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3095 |
backKey := #CursorUp. |
1699 | 3096 |
] |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3097 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3098 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3099 |
aKey == backKey ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3100 |
superMenu isNil ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3101 |
self accept:nil |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3102 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3103 |
superMenu verticalLayout ~~ isVrt ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3104 |
superMenu handleCursorKey:aKey |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3105 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3106 |
superMenu selection hideSubmenu |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3107 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3108 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3109 |
^ self |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3110 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3111 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3112 |
selection isNil ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3113 |
superMenu isNil ifTrue:[^ self accept:nil]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3114 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3115 |
superMenu verticalLayout ~~ isVrt ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3116 |
superMenu handleCursorKey:aKey |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3117 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3118 |
(item := items findFirst:[:el| el canSelect]) notNil ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3119 |
self selection:item |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3120 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3121 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3122 |
^ self |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3123 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3124 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3125 |
selection hasSubmenu ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3126 |
(menu := selection visibleSubmenu) isNil ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3127 |
selection toggleSubmenuVisibility |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3128 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3129 |
menu selectionIndex:1 |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3130 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3131 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3132 |
superMenu notNil ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3133 |
superMenu verticalLayout ~~ isVrt ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3134 |
superMenu handleCursorKey:aKey |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3135 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3136 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3137 |
self accept:nil |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3138 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3139 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3140 |
! |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3141 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3142 |
handleKeyPress:key |
1699 | 3143 |
"any key is pressed |
3144 |
" |
|
2219 | 3145 |
|item inMenu| |
1699 | 3146 |
|
3147 |
(key == #Return or:[key == Character space]) ifTrue:[ |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3148 |
self handleReturnPressed |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3149 |
] ifFalse:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3150 |
key isCharacter ifTrue:[ |
1862 | 3151 |
"/ selection notNil ifTrue:[ |
3152 |
"/ inMenu := self |
|
3153 |
"/ ] ifFalse:[ |
|
3154 |
"/ (inMenu := superMenu) isNil ifTrue:[^ self]. |
|
3155 |
"/ ]. |
|
3156 |
inMenu := self. |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3157 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3158 |
(item := inMenu detectItemForKey:key) notNil ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3159 |
inMenu selection:item |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3160 |
] |
1699 | 3161 |
] ifFalse:[ |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3162 |
( key == #CursorDown or:[key == #CursorUp |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3163 |
or:[key == #CursorLeft or:[key == #CursorRight]]] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3164 |
) ifTrue:[ |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3165 |
self handleCursorKey:key |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3166 |
] |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3167 |
] |
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3168 |
] |
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3169 |
! |
1699 | 3170 |
|
3171 |
handlePointerLeave:state |
|
3172 |
self pointerEntersItem:nil. |
|
3173 |
super pointerLeave:state |
|
3174 |
! |
|
3175 |
||
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3176 |
handleReturnPressed |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3177 |
"any key is pressed |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3178 |
" |
2199 | 3179 |
|sensor subm| |
1841 | 3180 |
|
3181 |
selection isNil ifTrue:[ |
|
2219 | 3182 |
superMenu notNil ifTrue:[ |
3183 |
superMenu selection toggleSubmenuVisibility |
|
3184 |
] ifFalse:[ |
|
3185 |
self accept |
|
3186 |
]. |
|
3187 |
^ self |
|
1841 | 3188 |
]. |
3189 |
selection hasSubmenu ifTrue:[ |
|
2219 | 3190 |
selection hasDelayedMenu ifFalse:[ |
3191 |
^ selection toggleSubmenuVisibility |
|
3192 |
]. |
|
3193 |
subm := selection currentSubmenu. |
|
3194 |
||
3195 |
(subm notNil and:[subm shown]) ifTrue:[ |
|
3196 |
^ selection toggleSubmenuVisibility |
|
3197 |
]. |
|
3198 |
self openDelayed:nil |
|
1841 | 3199 |
]. |
3200 |
self accept. |
|
3201 |
||
3202 |
(selection notNil and:[selection triggerOnDown]) ifFalse:[ |
|
2219 | 3203 |
^ self |
1841 | 3204 |
]. |
3205 |
||
3206 |
(sensor := self sensor) isNil ifTrue:[ |
|
2219 | 3207 |
^ self |
1841 | 3208 |
]. |
3209 |
||
3210 |
[ sensor flushKeyboardFor:nil. |
|
2219 | 3211 |
Delay waitForSeconds:0.1. |
3212 |
sensor hasKeyPressEventFor:nil. |
|
1841 | 3213 |
|
3214 |
] whileTrue. |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3215 |
! |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
3216 |
|
1699 | 3217 |
pointerEntersItem:anItemOrNil |
3218 |
"the pointer moves over an item or nil; restore the old item and |
|
3219 |
redraw the new item highlighted. |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3220 |
" |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3221 |
|oldItem newItem| |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3222 |
|
1699 | 3223 |
( anItemOrNil notNil |
3224 |
and:[anItemOrNil canSelect |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3225 |
and:[selection isNil |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3226 |
and:[self isPopUpView not]]]) ifTrue:[ |
1699 | 3227 |
anItemOrNil isButton ifTrue:[ |
2219 | 3228 |
( self buttonEnteredBackgroundColor ~= self buttonPassiveBackgroundColor |
3229 |
or:[self buttonEnteredLevel ~= self buttonPassiveLevel] |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3230 |
) ifTrue:[ |
1699 | 3231 |
newItem := anItemOrNil |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3232 |
] |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3233 |
] ifFalse:[ |
2219 | 3234 |
(self enteredLevel ~~ 0 |
3235 |
or:[self enteredBackgroundColor ~= self backgroundColor] |
|
3236 |
) ifTrue:[ |
|
1699 | 3237 |
newItem := anItemOrNil |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3238 |
] |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3239 |
] |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3240 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3241 |
|
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3242 |
newItem ~~ enteredItem ifTrue:[ |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3243 |
oldItem := enteredItem. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3244 |
enteredItem := newItem. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3245 |
|
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3246 |
oldItem notNil ifTrue:[ |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3247 |
self invalidateItem:oldItem repairNow:(enteredItem isNil). |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3248 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3249 |
|
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3250 |
enteredItem notNil ifTrue:[ |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3251 |
self invalidateItem:enteredItem repairNow:true. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3252 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3253 |
]. |
388 | 3254 |
! ! |
3255 |
||
3256 |
!MenuPanel methodsFor:'grabbing'! |
|
3257 |
||
1699 | 3258 |
doGrab |
3259 |
relativeGrabOrigin := nil. |
|
3260 |
||
3261 |
superMenu notNil ifTrue:[ |
|
2219 | 3262 |
superMenu doGrab |
1699 | 3263 |
] ifFalse:[ |
2219 | 3264 |
hasImplicitGrap ~~ true ifTrue:[ |
3265 |
self grabMouseAndKeyboard. |
|
3266 |
hasImplicitGrap := true |
|
3267 |
] |
|
1699 | 3268 |
] |
3269 |
! |
|
3270 |
||
3271 |
doUngrab:forceDo |
|
3272 |
||
3273 |
relativeGrabOrigin := nil. |
|
1767 | 3274 |
self clearImplicitGrab. |
1699 | 3275 |
|
3276 |
superMenu notNil ifTrue:[ |
|
2219 | 3277 |
forceDo ifTrue:[ |
3278 |
superMenu doUngrab:true |
|
3279 |
]. |
|
3280 |
^ self |
|
1699 | 3281 |
]. |
3282 |
||
3283 |
hasImplicitGrap ~~ true ifTrue:[ |
|
2219 | 3284 |
^ self |
1699 | 3285 |
]. |
3286 |
||
3287 |
forceDo ifFalse:[ |
|
2219 | 3288 |
(selection notNil or:[prevFocusView == self]) ifTrue:[ |
3289 |
^ self |
|
3290 |
]. |
|
1699 | 3291 |
]. |
3292 |
self ungrabMouseAndKeyboard. |
|
3293 |
self selection:nil. |
|
3294 |
hasImplicitGrap := nil. |
|
1703 | 3295 |
prevFocusView := nil. |
3296 |
||
1699 | 3297 |
! |
3298 |
||
1630 | 3299 |
grabKeyboard |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3300 |
"grap the keyboard; keep previous grab |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3301 |
" |
1630 | 3302 |
previousKeyboardGrab := device activeKeyboardGrab. |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3303 |
^ super grabKeyboard |
1630 | 3304 |
|
3305 |
||
3306 |
! |
|
3307 |
||
388 | 3308 |
grabMouseAndKeyboard |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
3309 |
"get exclusive access to pointer and keyboard. |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3310 |
" |
388 | 3311 |
|sensor| |
3312 |
||
3313 |
realized ifTrue:[ |
|
2219 | 3314 |
prevFocusView := self windowGroup focusView. |
3315 |
||
3316 |
sensor := self sensor. |
|
3317 |
device activePointerGrab ~~ self ifTrue:[ |
|
3318 |
sensor notNil ifTrue:[ |
|
3319 |
sensor flushMotionEventsFor:nil. |
|
3320 |
]. |
|
3321 |
||
3322 |
(self grabPointer) ifFalse:[ |
|
3323 |
Delay waitForSeconds:0.1. |
|
3324 |
(self grabPointer) ifFalse:[ |
|
3325 |
"give up" |
|
3326 |
'MenuPanel [warning]: could not grab pointer' errorPrintCR. |
|
3327 |
self unmap |
|
3328 |
] |
|
3329 |
] |
|
3330 |
]. |
|
3331 |
||
3332 |
device activeKeyboardGrab ~~ self ifTrue:[ |
|
3333 |
sensor notNil ifTrue:[ |
|
3334 |
device sync. |
|
3335 |
sensor flushKeyboardFor:nil |
|
3336 |
]. |
|
3337 |
self grabKeyboard. |
|
3338 |
] |
|
388 | 3339 |
] |
3340 |
||
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
3341 |
"Modified: / 2.2.1998 / 23:43:59 / stefan" |
1254 | 3342 |
"Modified: / 15.3.1999 / 12:01:38 / cg" |
388 | 3343 |
! |
3344 |
||
1630 | 3345 |
grabPointerWithCursor:aCursorOrNil |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3346 |
"grap the pointer; keep previous grab |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3347 |
" |
1630 | 3348 |
previousPointerGrab := device activePointerGrab. |
1699 | 3349 |
hasImplicitGrap := true. |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3350 |
^ super grabPointerWithCursor:aCursorOrNil |
1630 | 3351 |
|
3352 |
||
3353 |
! |
|
3354 |
||
3355 |
ungrabKeyboard |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3356 |
"ungrap the keyboard; restore previous grab |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3357 |
" |
1630 | 3358 |
super ungrabKeyboard. |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3359 |
|
1630 | 3360 |
previousKeyboardGrab notNil ifTrue:[ |
2219 | 3361 |
device grabKeyboardInView:previousKeyboardGrab. |
1630 | 3362 |
]. |
3363 |
||
3364 |
||
3365 |
! |
|
3366 |
||
388 | 3367 |
ungrabMouseAndKeyboard |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
3368 |
"ungrab resources (mouse and keyboard) |
388 | 3369 |
" |
1630 | 3370 |
self ungrabPointer. |
3371 |
self ungrabKeyboard. |
|
3372 |
! |
|
3373 |
||
3374 |
ungrabPointer |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3375 |
"ungrap the pointer; restore previous grab |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3376 |
" |
1630 | 3377 |
super ungrabPointer. |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3378 |
|
1630 | 3379 |
previousPointerGrab notNil ifTrue:[ |
2219 | 3380 |
device grabPointerInView:previousPointerGrab. |
1630 | 3381 |
]. |
3382 |
||
3383 |
||
388 | 3384 |
! ! |
3385 |
||
1251 | 3386 |
!MenuPanel methodsFor:'help'! |
3387 |
||
2058 | 3388 |
flyByHelpTextAt:srcPoint |
3389 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item). |
|
2063 | 3390 |
If there is a selection, that items helpText is used (ignoring the given point). |
2058 | 3391 |
" |
3392 |
|dstMenu dstPoint| |
|
3393 |
||
3394 |
dstMenu := self detectMenuAtGrabPoint:srcPoint. |
|
2063 | 3395 |
dstMenu isNil ifTrue:[^ nil]. |
2058 | 3396 |
|
3397 |
dstPoint := dstMenu translateGrabPoint:srcPoint. |
|
2063 | 3398 |
^ dstMenu flyByHelpTextForItem:(dstMenu itemAtX:(dstPoint x) y:(dstPoint y)). |
2058 | 3399 |
! |
3400 |
||
3401 |
flyByHelpTextForItem:anItem |
|
3402 |
"returns the helpText for an item (empty if none) |
|
3403 |
" |
|
2063 | 3404 |
|key app| |
3405 |
||
3406 |
anItem isNil ifTrue:[^ nil]. |
|
3407 |
||
3408 |
anItem isButton ifFalse:[^ nil]. |
|
3409 |
||
3410 |
key := anItem activeHelpKey. |
|
3411 |
key isNil ifTrue:[^ nil]. |
|
3412 |
||
3413 |
app := self application. |
|
3414 |
app isNil ifTrue:[^ nil]. |
|
3415 |
||
3416 |
^ app flyByHelpTextForKey:key. |
|
2058 | 3417 |
! |
3418 |
||
1251 | 3419 |
helpText |
1613 | 3420 |
"return the helpText for the currently selected item (empty if none) |
3421 |
" |
|
3422 |
^ self helpTextForItem:selection |
|
1251 | 3423 |
! |
3424 |
||
1699 | 3425 |
helpTextAt:srcPoint |
1252 | 3426 |
"return the helpText for aPoint (i.e. when mouse-pointer is moved over an item). |
3427 |
If there is a selection, that items helpText is used (ignoreing the given point). |
|
3428 |
" |
|
1699 | 3429 |
|dstMenu dstPoint| |
3430 |
||
3431 |
dstMenu := self detectMenuAtGrabPoint:srcPoint. |
|
3432 |
||
3433 |
dstMenu isNil ifTrue:[ |
|
2219 | 3434 |
^ '' |
1613 | 3435 |
]. |
1699 | 3436 |
|
3437 |
dstPoint := dstMenu translateGrabPoint:srcPoint. |
|
3438 |
^ dstMenu helpTextForItem:(dstMenu itemAtX:(dstPoint x) y:(dstPoint y)). |
|
1613 | 3439 |
! |
3440 |
||
3441 |
helpTextForItem:anItem |
|
3442 |
"returns the helpText for an item (empty if none) |
|
3443 |
" |
|
3444 |
|key val app| |
|
3445 |
||
3446 |
anItem isNil ifTrue:[^ '']. |
|
3447 |
||
3448 |
(val := anItem activeHelpText) isNil ifTrue:[ |
|
2219 | 3449 |
( (key := anItem activeHelpKey) notNil |
3450 |
and:[(app := self application) notNil] |
|
3451 |
) ifTrue:[ |
|
3452 |
val := app helpTextForKey:key. |
|
3453 |
]. |
|
3454 |
anItem activeHelpText:(val ? ''). |
|
1613 | 3455 |
]. |
3456 |
^ val |
|
1251 | 3457 |
! ! |
3458 |
||
794 | 3459 |
!MenuPanel methodsFor:'image registration'! |
3460 |
||
3461 |
imageOnDevice:anImage |
|
3462 |
"returns image registered on device |
|
3463 |
" |
|
3464 |
^ self class image:anImage onDevice:device |
|
3465 |
! |
|
3466 |
||
3467 |
lightenedImageOnDevice:anImage |
|
3468 |
"returns lightened image registered on device |
|
3469 |
" |
|
3470 |
^ self class lightenedImage:anImage onDevice:device |
|
3471 |
! ! |
|
3472 |
||
1688 | 3473 |
!MenuPanel methodsFor:'initialization & release'! |
388 | 3474 |
|
767
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
3475 |
addToCurrentProject |
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
3476 |
"ignored here" |
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
3477 |
! |
ffa2a09a1039
added #addToCurrentProject in order to avoid restart errors
tz
parents:
746
diff
changeset
|
3478 |
|
388 | 3479 |
create |
616 | 3480 |
"create the shadow view for a none contained submenu |
388 | 3481 |
" |
3482 |
super create. |
|
3483 |
||
3484 |
self isPopUpView ifTrue:[ |
|
2219 | 3485 |
(PopUpView shadowsOnDevice:device) ifTrue:[ |
3486 |
shadowView isNil ifTrue:[ |
|
3487 |
shadowView := (ShadowView onDevice:device) for:self |
|
3488 |
] ifFalse:[ |
|
3489 |
self saveUnder:true. |
|
3490 |
]. |
|
3491 |
] |
|
388 | 3492 |
] ifFalse:[ |
2219 | 3493 |
explicitExtent == true ifTrue:[ |
3494 |
(self width) == (superView width) ifTrue:[ |
|
3495 |
self verticalLayout:false |
|
3496 |
] |
|
3497 |
] |
|
388 | 3498 |
] |
1024
28c87a2369f6
show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
3499 |
|
28c87a2369f6
show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
3500 |
"Modified: / 28.7.1998 / 02:11:44 / cg" |
388 | 3501 |
! |
3502 |
||
3503 |
destroy |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3504 |
"destroy items and shadowView; remove dependencies |
388 | 3505 |
" |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3506 |
self clearLastActiveMenu. |
2051 | 3507 |
items notNil ifTrue:[items copy do:[:el|el destroy]]. |
2050
ef5517d7a2d0
do not destroy myself after accepting (for PopUpList)
Claus Gittinger <cg@exept.de>
parents:
2048
diff
changeset
|
3508 |
items := nil. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3509 |
|
498 | 3510 |
menuHolder notNil ifTrue:[menuHolder removeDependent:self]. |
3511 |
enableChannel notNil ifTrue:[enableChannel removeDependent:self]. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3512 |
|
388 | 3513 |
super destroy. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3514 |
superMenu := nil. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3515 |
shadowView notNil ifTrue:[shadowView destroy]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3516 |
|
2051 | 3517 |
"Modified: / 15.11.2001 / 17:08:45 / cg" |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3518 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3519 |
|
616 | 3520 |
fetchDeviceResources |
2219 | 3521 |
"fetch device colors, to avoid reallocation at redraw time |
3522 |
" |
|
3523 |
|style| |
|
3524 |
||
3525 |
superMenu ifNotNil:[ |
|
3526 |
styleSheet := superMenu styleSheet |
|
3527 |
]. |
|
616 | 3528 |
|
3529 |
super fetchDeviceResources. |
|
3530 |
||
1081
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
3531 |
"/ 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
|
3532 |
"/ (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
|
3533 |
|
616 | 3534 |
superMenu isNil ifTrue:[ |
2219 | 3535 |
rightArrow ifNil:[ |
3536 |
rightArrow := SelectionInListView rightArrowFormOn:device. |
|
2059 | 3537 |
]. |
2219 | 3538 |
fgColor := fgColor onDevice:device. |
3539 |
style := styleSheet name. |
|
3540 |
||
3541 |
(style ~~ #os2 and:[style ~~ #win95]) ifTrue:[ |
|
3542 |
rightArrowShadow := SelectionInListView rightArrowShadowFormOn:device |
|
3543 |
] ifFalse:[ |
|
3544 |
rightArrowShadow := nil |
|
3545 |
]. |
|
616 | 3546 |
] ifFalse:[ |
2219 | 3547 |
rightArrow := superMenu rightArrow. |
3548 |
rightArrowShadow := superMenu rightArrowShadow. |
|
3549 |
||
3550 |
self foregroundColor:(superMenu foregroundColor). |
|
3551 |
self font:(superMenu font). |
|
3552 |
self viewBackground:(superMenu viewBackground). |
|
1137
7df0b776e47a
fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents:
1130
diff
changeset
|
3553 |
]. |
7df0b776e47a
fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents:
1130
diff
changeset
|
3554 |
|
1829 | 3555 |
items notNil ifTrue:[ |
2219 | 3556 |
items do:[:eachItem| eachItem fetchDeviceResources ] |
1829 | 3557 |
]. |
3558 |
||
1137
7df0b776e47a
fixes for 2D styles (borderWidth)
Claus Gittinger <cg@exept.de>
parents:
1130
diff
changeset
|
3559 |
"Modified: / 15.9.1998 / 12:51:29 / cg" |
616 | 3560 |
! |
3561 |
||
580 | 3562 |
initStyle |
3563 |
"initialize style specific stuff" |
|
3564 |
||
3565 |
super initStyle. |
|
616 | 3566 |
|
2219 | 3567 |
viewBackground := styleSheet colorAt:#'menuPanel.backgroundColor'. |
3568 |
font := styleSheet fontAt:#'menu.font'. |
|
3569 |
fgColor := styleSheet colorAt:#'menuPanel.foregroundColor'. |
|
1923 | 3570 |
|
2003
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3571 |
self updateLevelAndBorder. |
580 | 3572 |
! |
3573 |
||
388 | 3574 |
initialize |
3575 |
"set default configuration |
|
3576 |
" |
|
3577 |
super initialize. |
|
616 | 3578 |
|
1730
4936edfc2eee
must enable motion events in #initialize (not in map)
Claus Gittinger <cg@exept.de>
parents:
1728
diff
changeset
|
3579 |
self enableMotionEvents. |
498 | 3580 |
enabled := true. |
1877
3b415fa4710f
only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents:
1874
diff
changeset
|
3581 |
self extentChangedFlag:false. |
3b415fa4710f
only access originChanged, extentChanged and cornerChanged
Claus Gittinger <cg@exept.de>
parents:
1874
diff
changeset
|
3582 |
self originChangedFlag:false. |
388 | 3583 |
explicitExtent := nil. |
3584 |
shortKeyInset := 0. |
|
3585 |
mustRearrange := false. |
|
3586 |
! |
|
3587 |
||
1573 | 3588 |
map |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
3589 |
"grab the pointer here, when visible (but not if control has already been lost). |
388 | 3590 |
If the grab fails, try again and unmap myself if that fails too. |
3591 |
" |
|
1791 | 3592 |
|loIndices loItems| |
388 | 3593 |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3594 |
enteredItem := nil. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
3595 |
|
1024
28c87a2369f6
show active help on pointer motion.
Claus Gittinger <cg@exept.de>
parents:
1022
diff
changeset
|
3596 |
self enableMotionEvents. |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3597 |
self becomesActiveMenu. |
1573 | 3598 |
super map. |
388 | 3599 |
|
1785 | 3600 |
loIndices := InitialSelectionQuerySignal query. |
1791 | 3601 |
loItems := items ? #[]. |
3602 |
||
3603 |
loItems do:[:anItem| anItem fetchImages ]. |
|
1572 | 3604 |
|
388 | 3605 |
self isPopUpView ifTrue:[ |
2219 | 3606 |
self doGrab |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3607 |
] ifFalse:[ |
2219 | 3608 |
super viewBackground:(self backgroundColor). |
717
540e638fdebb
Avoid pointer and keyboard grabbing if not necessary
Stefan Vogel <sv@exept.de>
parents:
712
diff
changeset
|
3609 |
]. |
1791 | 3610 |
loItems do:[:el| el updateIndicators ]. |
388 | 3611 |
|
1785 | 3612 |
loIndices size > 0 ifTrue:[ |
2219 | 3613 |
self redrawX:0 y:0 width:width height:height. |
3614 |
self openMenusFromItemIndices:loIndices. |
|
388 | 3615 |
]. |
3616 |
||
1177 | 3617 |
"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
|
3618 |
"Modified: / 18.3.1999 / 18:22:18 / stefan" |
388 | 3619 |
! |
3620 |
||
3621 |
realize |
|
3622 |
"realize menu and shadowView |
|
3623 |
" |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
3624 |
|
388 | 3625 |
self isPopUpView ifTrue:[ |
2219 | 3626 |
"Because of #saveUnder of ShadowView the order of realize is significant: |
3627 |
shadowView must be realized before self" |
|
3628 |
self hiddenOnRealize:true. |
|
3629 |
super realize. |
|
3630 |
self resize. |
|
3631 |
self makeFullyVisible. |
|
2003
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3632 |
"/ self mustRearrange. |
2219 | 3633 |
shadowView notNil ifTrue:[ |
3634 |
shadowView realize. |
|
3635 |
]. |
|
3636 |
self raise. |
|
3637 |
self map. |
|
736 | 3638 |
] ifFalse:[ |
2219 | 3639 |
super realize. |
1767 | 3640 |
]. |
3641 |
self allSubViewsDo:[:aView| aView realize ]. |
|
388 | 3642 |
! |
3643 |
||
3644 |
recreate |
|
1832 | 3645 |
"this is called after a snapin or a migration. |
3646 |
If the image was saved with an active menu, hide the menu |
|
388 | 3647 |
" |
1455 | 3648 |
selection := nil. |
388 | 3649 |
super recreate. |
3650 |
! |
|
3651 |
||
1130 | 3652 |
reinitStyle |
3653 |
"handle style change while being open (win32 only - for now)" |
|
3654 |
||
3655 |
super reinitStyle. |
|
3656 |
||
3657 |
self fetchDeviceResources. |
|
1811 | 3658 |
self mustRearrange. "/ care for changed font sizes etc. |
3659 |
||
3660 |
self do:[:anItem | |
|
3661 |
anItem reinitStyle |
|
3662 |
]. |
|
1130 | 3663 |
|
3664 |
"Created: / 10.9.1998 / 21:37:05 / cg" |
|
1811 | 3665 |
"Modified: / 17.8.2000 / 18:01:33 / cg" |
1130 | 3666 |
! |
3667 |
||
1796
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3668 |
reinitialize |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3669 |
"reinit after a snapIn |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3670 |
" |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3671 |
|
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3672 |
super reinitialize. |
1811 | 3673 |
"/ self reinitStyle. |
3674 |
||
3675 |
"Modified: / 17.8.2000 / 17:53:31 / cg" |
|
1796
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3676 |
! |
c9d801c011f7
recompute layout after snapIn (font geometry could be different)
Claus Gittinger <cg@exept.de>
parents:
1795
diff
changeset
|
3677 |
|
388 | 3678 |
unmap |
1330 | 3679 |
"unmap the view - the view stays created (but invisible), and can be remapped again later. |
3680 |
If we have a popup supermenu, it will get all keyboard and mouse events." |
|
736 | 3681 |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3682 |
self clearLastActiveMenu. |
1699 | 3683 |
self doUngrab:(superMenu isNil). |
3684 |
"/ self isPopUpView ifTrue:[ |
|
3685 |
"/ self doUngrab:(superMenu isNil) |
|
3686 |
"/ ]. |
|
3687 |
||
388 | 3688 |
super unmap. |
3689 |
shadowView notNil ifTrue:[shadowView unmap]. |
|
2003
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3690 |
! |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3691 |
|
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3692 |
updateLevelAndBorder |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3693 |
"update level & border, when it is known if I am a popUpView" |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3694 |
|
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3695 |
|bw lvl| |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3696 |
|
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3697 |
self isPopUpView ifTrue:[ |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3698 |
bw := styleSheet at:#'popup.borderWidth' default:1. |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3699 |
lvl := styleSheet at:#'popup.level' default:0. |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3700 |
] ifFalse:[ |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3701 |
bw := styleSheet is3D ifFalse:[1] ifTrue:[0]. |
2219 | 3702 |
lvl := styleSheet at:#'menuPanel.level'. |
2003
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3703 |
]. |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3704 |
self borderWidth:bw. |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
3705 |
self level:lvl. |
388 | 3706 |
! ! |
3707 |
||
1878 | 3708 |
!MenuPanel methodsFor:'keyboard control'! |
3709 |
||
3710 |
mnemonicViewNext:aKeyEvent |
|
3711 |
"a mnemonicKey event as forwarded from the keyboardProcessor - if there |
|
3712 |
is the mnemonic-key defined for any menuItem, handle the menuItem and |
|
3713 |
return the topMenu otherwise nil. |
|
3714 |
" |
|
2112 | 3715 |
|menu uKey lKey list index| |
3716 |
||
3717 |
superMenu notNil ifTrue:[ ^ superMenu mnemonicViewNext:aKeyEvent ]. |
|
1878 | 3718 |
shown ifFalse:[^ nil]. |
3719 |
||
3720 |
uKey := aKeyEvent rawKey last asUppercase. |
|
3721 |
lKey := uKey asLowercase. |
|
2112 | 3722 |
|
3723 |
selection notNil ifTrue:[ |
|
2219 | 3724 |
"first lookup the current grapMenu before starting in the topMenu |
3725 |
" |
|
3726 |
menu := self detectGrabMenu. |
|
3727 |
||
3728 |
[ menu ~~ self ] whileTrue:[ |
|
3729 |
index := menu selectionIndex. |
|
3730 |
list := menu selectItemIndicesFor:[:el||k| k := el accessCharacter. k == uKey or:[k == lKey]] |
|
3731 |
maxDepth:10 from:(index + 1) to:99999. |
|
2112 | 3732 |
|
2219 | 3733 |
list size ~~ 0 ifTrue:[ |
3734 |
"/ has item which responds to the mnemonic |
|
3735 |
menu processCollectedIndices:list. |
|
3736 |
^ self |
|
3737 |
]. |
|
3738 |
menu := menu superMenu. |
|
3739 |
]. |
|
3740 |
index := self selectionIndex. |
|
3741 |
list := self selectItemIndicesFor:[:el||k| k := el accessCharacter. k == uKey or:[k == lKey] ] |
|
3742 |
maxDepth:10 from:(1 + index) to:99999. |
|
2112 | 3743 |
] ifFalse:[ |
2219 | 3744 |
index := 99999. |
3745 |
list := nil. |
|
2112 | 3746 |
]. |
3747 |
||
3748 |
list ifNil:[ |
|
2219 | 3749 |
list := self selectItemIndicesFor:[:el||k| k := el accessCharacter. k == uKey or:[k == lKey] ] |
3750 |
maxDepth:10 from:1 to:index. |
|
3751 |
||
3752 |
list isNil ifTrue:[ |
|
3753 |
"/ must clear existing selection |
|
3754 |
self selection:nil. |
|
3755 |
^ nil |
|
3756 |
] |
|
2112 | 3757 |
]. |
3758 |
||
3759 |
"/ has item which responds to the mnemonic |
|
3760 |
self processCollectedIndices:list. |
|
3761 |
^ self |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3762 |
! |
1878 | 3763 |
|
3764 |
openMenusFromItemIndices:anItemIndiceList |
|
3765 |
"open all menus derived from sequence of item indices |
|
3766 |
" |
|
3767 |
|item| |
|
3768 |
||
3769 |
anItemIndiceList size == 0 ifTrue:[ |
|
2219 | 3770 |
^ self |
1878 | 3771 |
]. |
3772 |
item := self itemAt:(anItemIndiceList removeFirst). |
|
3773 |
||
3774 |
(item notNil and:[item enabled]) ifTrue:[ |
|
2219 | 3775 |
InitialSelectionQuerySignal answer:anItemIndiceList do:[ |
3776 |
self openMenuOnSelect:true. |
|
3777 |
self selection:item. |
|
3778 |
self openMenuOnSelect:nil. |
|
3779 |
] |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3780 |
]. |
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3781 |
! |
1878 | 3782 |
|
3783 |
processCollectedIndices:indices |
|
3784 |
|menu item| |
|
3785 |
||
3786 |
indices size == 0 ifTrue:[ |
|
2219 | 3787 |
^ self |
1878 | 3788 |
]. |
3789 |
menu := self. |
|
3790 |
||
3791 |
[menu selectionIndex == indices first] whileTrue:[ |
|
2219 | 3792 |
( (item := menu selection) isNil "/ shouldn't happen |
3793 |
or:[(menu := item submenu) isNil] "/ no more indices; done |
|
3794 |
) ifTrue:[ |
|
3795 |
^ true |
|
3796 |
]. |
|
3797 |
indices removeFirst. |
|
3798 |
||
3799 |
indices isEmpty ifTrue:[ |
|
3800 |
menu selection:nil. |
|
3801 |
^ self |
|
3802 |
] |
|
1878 | 3803 |
]. |
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3804 |
menu openMenusFromItemIndices:indices. |
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3805 |
! |
1878 | 3806 |
|
3807 |
processShortcut:aKeyEvent |
|
3808 |
"a shortcutKey event as forwarded from the keyboardProcessor - if there is the |
|
3809 |
shortcut-key defined process the shortcut and return true otherwise false. |
|
3810 |
" |
|
2219 | 3811 |
|menu rKey lKey list item| |
1878 | 3812 |
|
3813 |
superMenu notNil ifTrue:[ |
|
3814 |
^ superMenu processShortcut:aKeyEvent |
|
3815 |
]. |
|
3816 |
shown ifFalse:[^ false]. |
|
3817 |
||
3818 |
item := nil. |
|
3819 |
rKey := aKeyEvent rawKey. |
|
3820 |
lKey := aKeyEvent key. |
|
3821 |
menu := self detectGrabMenu. "/ first lookup the current grapMenu before starting in the topMenu |
|
3822 |
||
3823 |
[true] whileTrue:[ |
|
3824 |
list := menu selectItemIndicesFor:[:el||skey| |
|
3825 |
item := el. |
|
3826 |
skey := el shortcutKey. |
|
3827 |
skey == rKey or:[skey == lKey] |
|
3828 |
] |
|
3829 |
maxDepth:10. |
|
3830 |
||
3831 |
list size ~~ 0 ifTrue:[ |
|
3832 |
"/ has item which responds to the shortcut |
|
3833 |
item hasSubmenu ifFalse:[ |
|
3834 |
menu accept:item |
|
3835 |
] ifTrue:[ |
|
3836 |
menu processCollectedIndices:list. |
|
3837 |
self windowGroup focusView:self. |
|
3838 |
]. |
|
3839 |
^ true |
|
3840 |
]. |
|
3841 |
||
3842 |
menu == self ifTrue:[ ^ false ]. |
|
3843 |
menu := self. |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3844 |
]. |
2219 | 3845 |
^ false "/ never reached |
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3846 |
! |
1878 | 3847 |
|
3848 |
selectItemIndicesFor:aOneArgBlock maxDepth:maxDepth |
|
3849 |
"returns the sequence of indices up to the item for which the block |
|
3850 |
returns true. The first entry is the topmenu, the last entry the |
|
3851 |
item for which the block returns true. |
|
3852 |
If no item is detected, nil is returned |
|
3853 |
" |
|
2112 | 3854 |
^ self selectItemIndicesFor:aOneArgBlock maxDepth:maxDepth from:1 to:99999 |
3855 |
! |
|
3856 |
||
3857 |
selectItemIndicesFor:aOneArgBlock maxDepth:maxDepth from:aStart to:aStop |
|
3858 |
"returns the sequence of indices up to the item for which the block |
|
3859 |
returns true. The first entry is the topmenu, the last entry the |
|
3860 |
item for which the block returns true. |
|
3861 |
If no item is detected, nil is returned |
|
3862 |
" |
|
3863 |
|start stop| |
|
3864 |
||
3865 |
maxDepth <= 0 ifTrue:[^ nil]. |
|
3866 |
||
3867 |
start := aStart max:1. |
|
3868 |
stop := aStop min:(items size). |
|
3869 |
||
2199 | 3870 |
start to:stop do:[:i| |item menu seq isItem test| |
2219 | 3871 |
item := items at:i. |
3872 |
test := isItem := aOneArgBlock value:item. |
|
3873 |
||
3874 |
test ifFalse:[ |
|
3875 |
item hasSubmenu ifTrue:[ |
|
3876 |
test := item hasDelayedMenu not |
|
3877 |
] |
|
3878 |
]. |
|
3879 |
test ifTrue:[ |
|
3880 |
(item enabled and:[item isVisible]) ifTrue:[ |
|
3881 |
isItem ifTrue:[ ^ OrderedCollection with:i ]. |
|
3882 |
||
3883 |
"process submenu" |
|
3884 |
menu := item submenu. |
|
3885 |
||
3886 |
(menu notNil and:[menu isEnabled]) ifTrue:[ |
|
3887 |
seq := menu selectItemIndicesFor:aOneArgBlock maxDepth:(maxDepth - 1). |
|
3888 |
seq notNil ifTrue:[ |
|
3889 |
seq addFirst:i. |
|
3890 |
^ seq |
|
3891 |
] |
|
3892 |
] |
|
3893 |
] |
|
3894 |
]. |
|
1878 | 3895 |
]. |
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3896 |
^ nil |
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
3897 |
! ! |
1878 | 3898 |
|
388 | 3899 |
!MenuPanel methodsFor:'misc'! |
3900 |
||
427
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
3901 |
raiseDeiconified |
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
3902 |
^ self raise |
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
3903 |
|
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
3904 |
"Created: 21.6.1997 / 13:29:12 / cg" |
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
3905 |
! |
82cbad72e197
raiseDeiconified is treated like a raise
Claus Gittinger <cg@exept.de>
parents:
420
diff
changeset
|
3906 |
|
388 | 3907 |
superMenu |
3908 |
"returns supermenu or nil |
|
3909 |
" |
|
3910 |
^ superMenu |
|
3911 |
||
3912 |
||
3913 |
! |
|
3914 |
||
3915 |
topMenu |
|
3916 |
"returns the topMenu; the one having no superMenu |
|
3917 |
" |
|
1791 | 3918 |
|menu smenu| |
3919 |
||
3920 |
menu := self. |
|
3921 |
||
3922 |
[(smenu := menu superMenu) notNil] whileTrue:[ |
|
2219 | 3923 |
menu := smenu |
1791 | 3924 |
]. |
3925 |
^ menu |
|
388 | 3926 |
! ! |
3927 |
||
1825 | 3928 |
!MenuPanel methodsFor:'printing & storing'! |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3929 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3930 |
printString |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3931 |
"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
|
3932 |
" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3933 |
|string label| |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3934 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3935 |
string := 'Menu:'. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3936 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3937 |
self do:[:anItem| |
2145 | 3938 |
label := anItem label ? ''. |
3939 |
string := string ,' ', label printString. |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3940 |
]. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3941 |
^ string |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3942 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3943 |
"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
|
3944 |
! ! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
3945 |
|
388 | 3946 |
!MenuPanel methodsFor:'private'! |
3947 |
||
434 | 3948 |
application |
1613 | 3949 |
"optimize access to retrive the application |
3950 |
" |
|
1921
f3f120d43849
oops - handle query for application, when view is already closed.
Claus Gittinger <cg@exept.de>
parents:
1919
diff
changeset
|
3951 |
|appl akey w views| |
434 | 3952 |
|
3953 |
superMenu notNil ifTrue:[ |
|
2219 | 3954 |
^ superMenu application |
1613 | 3955 |
]. |
1870 | 3956 |
|
1613 | 3957 |
akey := #appl. |
3958 |
appl := self menuAdornmentAt:akey. |
|
3959 |
||
3960 |
appl isNil ifTrue:[ |
|
2219 | 3961 |
(appl := super application) isNil ifTrue:[ |
3962 |
windowGroup isNil ifTrue:[ |
|
3963 |
^ nil "/ RETRY LATER |
|
3964 |
]. |
|
3965 |
views := windowGroup mainGroup topViews. |
|
3966 |
views size == 0 ifTrue:[ |
|
3967 |
^ nil "/ RETRY LATER |
|
3968 |
]. |
|
3969 |
w := views first. |
|
3970 |
w == self ifTrue:[ |
|
3971 |
thisContext isRecursive ifTrue:[ |
|
3972 |
self error:'recursive application query' |
|
3973 |
]. |
|
3974 |
"/ appl := akey |
|
3975 |
]. |
|
3976 |
appl := (w application) ? akey. |
|
3977 |
]. |
|
3978 |
self menuAdornmentAt:akey put:appl |
|
1613 | 3979 |
]. |
1872 | 3980 |
^ appl ~~ akey ifTrue:[appl] ifFalse:[nil] |
3981 |
! |
|
434 | 3982 |
|
1572 | 3983 |
detectItemForKey:aKey |
3984 |
"returns the item assigned to a key, accessCharacter or starts with. |
|
3985 |
if no item is detected nil is returned. |
|
3986 |
" |
|
3987 |
|cIdx uKey lKey item| |
|
3988 |
||
1699 | 3989 |
items isNil ifTrue:[^ nil]. |
3990 |
||
1572 | 3991 |
cIdx := self selectionIndex. |
3992 |
uKey := aKey asUppercase. |
|
3993 |
lKey := aKey asLowercase. |
|
3994 |
||
1699 | 3995 |
items keysAndValuesDo:[:anIndex :anItem| |char label| |
2219 | 3996 |
( anIndex ~~ cIdx |
3997 |
and:[anItem canSelect |
|
3998 |
and:[(label := anItem textLabel) notNil |
|
3999 |
and:[label size ~~ 0]]] |
|
4000 |
) ifTrue:[ |
|
4001 |
(char := anItem accessCharacter) notNil ifTrue:[ |
|
4002 |
(char == uKey or:[char == lKey]) ifTrue:[ |
|
4003 |
^ anItem |
|
4004 |
] |
|
4005 |
] ifFalse:[ |
|
4006 |
char := label at:1. |
|
4007 |
||
4008 |
(char == uKey or:[char == lKey]) ifTrue:[ |
|
4009 |
anIndex > cIdx ifTrue:[ |
|
4010 |
^ anItem |
|
4011 |
]. |
|
4012 |
item isNil ifTrue:[item := anItem] |
|
4013 |
] |
|
4014 |
] |
|
4015 |
] |
|
1572 | 4016 |
]. |
4017 |
^ item |
|
4018 |
! |
|
4019 |
||
390 | 4020 |
menuAdornmentAt:aSymbol |
388 | 4021 |
"returns a value derived from adornment |
4022 |
" |
|
390 | 4023 |
|adm| |
4024 |
||
4025 |
adm := adornment ? DefaultAdornment. |
|
4026 |
^ adm at:aSymbol ifAbsent:nil |
|
388 | 4027 |
! |
4028 |
||
390 | 4029 |
menuAdornmentAt:aSymbol put:something |
653 | 4030 |
"sets a value for the specific menu; if the value differs to the |
4031 |
current stored value, true is returned otherwise false |
|
388 | 4032 |
" |
653 | 4033 |
(self menuAdornmentAt:aSymbol) == something ifTrue:[ |
2145 | 4034 |
^ false |
653 | 4035 |
]. |
4036 |
adornment isNil ifTrue:[ |
|
2145 | 4037 |
adornment := DefaultAdornment copy |
653 | 4038 |
]. |
4039 |
adornment at:aSymbol put:something. |
|
4040 |
^ true |
|
388 | 4041 |
! |
4042 |
||
4043 |
onEachPerform:aSelector withArgList:aList |
|
4044 |
"on each item perform selector with an argument derived from aList |
|
4045 |
" |
|
4046 |
aList isCollection ifTrue:[ |
|
2145 | 4047 |
items size >= aList size ifTrue:[ |
4048 |
aList keysAndValuesDo:[:anIndex :anArg| |
|
4049 |
(items at:anIndex) perform:aSelector with:anArg |
|
4050 |
] |
|
4051 |
] |
|
388 | 4052 |
] ifFalse:[ |
2145 | 4053 |
self do:[:anItem| anItem perform:aSelector with:aList ] |
388 | 4054 |
] |
4055 |
||
4056 |
||
4057 |
! |
|
4058 |
||
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4059 |
registerImageOnDevice:anImage |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4060 |
|image| |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4061 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4062 |
(image := anImage) notNil ifTrue:[ |
2219 | 4063 |
image device ~~ device ifTrue:[ |
4064 |
image := image copy. |
|
4065 |
]. |
|
4066 |
image := image onDevice:device. |
|
4067 |
image := image clearMaskedPixels. |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4068 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4069 |
^ image |
388 | 4070 |
! ! |
4071 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4072 |
!MenuPanel methodsFor:'private-activation'! |
687 | 4073 |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4074 |
activeMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4075 |
"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
|
4076 |
" |
687 | 4077 |
^ lastActiveMenu ? self |
4078 |
||
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4079 |
"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
|
4080 |
! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4081 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4082 |
activeMenu:aMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4083 |
"set the current active menu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4084 |
" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4085 |
lastActiveMenu := aMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4086 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4087 |
"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
|
4088 |
! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4089 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4090 |
becomesActiveMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4091 |
"submenu becomes the active menu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4092 |
" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4093 |
mapTime := Time millisecondClockValue. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4094 |
self topMenu activeMenu:self. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4095 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4096 |
"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
|
4097 |
! |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4098 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4099 |
clearLastActiveMenu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4100 |
"reset the current active menu |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4101 |
" |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4102 |
|top| |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4103 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4104 |
top := self topMenu. |
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4105 |
|
1612 | 4106 |
prevFocusView notNil ifTrue:[ |
2219 | 4107 |
self windowGroup focusView:prevFocusView. |
4108 |
prevFocusView := nil. |
|
1612 | 4109 |
]. |
4110 |
||
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4111 |
top activeMenu == self ifTrue:[ |
2219 | 4112 |
top activeMenu:nil |
687 | 4113 |
] |
4114 |
||
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4115 |
"Created: / 27.2.1998 / 17:41:17 / cg" |
687 | 4116 |
! |
4117 |
||
4118 |
mapTime |
|
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4119 |
"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
|
4120 |
" |
687 | 4121 |
^ mapTime |
798
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4122 |
|
74f4e7b66a46
ca's fixes for mapTime (fast-button-release)
Claus Gittinger <cg@exept.de>
parents:
794
diff
changeset
|
4123 |
"Modified: / 27.2.1998 / 17:41:18 / cg" |
687 | 4124 |
! ! |
4125 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4126 |
!MenuPanel methodsFor:'private-scrolling'! |
2016 | 4127 |
|
4128 |
hasScrollerAt:aDirection |
|
4129 |
"returns true if a visible scroller at a direction exists |
|
4130 |
" |
|
4131 |
|layout| |
|
4132 |
||
4133 |
self hasScrollers ifFalse:[ |
|
2219 | 4134 |
^ false |
2016 | 4135 |
]. |
4136 |
||
4137 |
aDirection == #PREV ifTrue:[ |
|
2219 | 4138 |
layout := items first layout. |
2016 | 4139 |
|
4140 |
^ self verticalLayout ifTrue:[ layout top < margin] |
|
2219 | 4141 |
ifFalse:[ layout left < margin] |
2016 | 4142 |
]. |
4143 |
layout := items last layout. |
|
4144 |
||
4145 |
^ self verticalLayout ifTrue:[ layout bottom > (height - margin)] |
|
2219 | 4146 |
ifFalse:[ layout right > (width - margin)] |
2016 | 4147 |
! |
4148 |
||
4149 |
hasScrollers |
|
4150 |
"returns true if scrollers are needed |
|
4151 |
" |
|
2018 | 4152 |
|maxExtent first last isVert| |
4153 |
||
4154 |
(mustRearrange or:[items size < 2]) ifTrue:[^ false]. |
|
4155 |
||
4156 |
isVert := self verticalLayout. |
|
4157 |
||
4158 |
superView notNil ifTrue:[ |
|
2219 | 4159 |
( (first := items first layout) isNil |
4160 |
or:[(last := items last layout) isNil] |
|
4161 |
) ifTrue:[ |
|
4162 |
^ false |
|
4163 |
]. |
|
4164 |
isVert ifTrue:[ |
|
4165 |
^ first top < 0 or:[last bottom > height] |
|
4166 |
]. |
|
4167 |
^ first left < 0 or:[last right > width] |
|
2018 | 4168 |
]. |
4169 |
maxExtent := self maxExtent. |
|
4170 |
||
4171 |
isVert ifTrue:[ |
|
2219 | 4172 |
^ (height < maxExtent y) not |
2018 | 4173 |
]. |
4174 |
^ (width < maxExtent x) not |
|
2016 | 4175 |
! |
4176 |
||
4177 |
indexOfItemAtScroller:aDirection |
|
4178 |
"returns the index of the item under the scroller or 0 |
|
4179 |
" |
|
4180 |
|bounds min max layout| |
|
4181 |
||
4182 |
bounds := self scrollerBoundsAt:aDirection. |
|
4183 |
||
4184 |
bounds isNil ifTrue:[ |
|
2219 | 4185 |
^ 0 |
2016 | 4186 |
]. |
4187 |
||
4188 |
self verticalLayout ifTrue:[ |
|
2219 | 4189 |
min := bounds top. |
4190 |
max := bounds bottom. |
|
4191 |
||
4192 |
items keysAndValuesDo:[:anIndex :anItem| |
|
4193 |
anItem isVisible ifTrue:[ |
|
4194 |
layout := anItem layout. |
|
4195 |
||
4196 |
(layout top < max and:[layout bottom > min]) ifTrue:[ |
|
4197 |
^ anIndex |
|
4198 |
]. |
|
4199 |
]. |
|
4200 |
]. |
|
2016 | 4201 |
] ifFalse:[ |
2219 | 4202 |
min := bounds left. |
4203 |
max := bounds right. |
|
4204 |
||
4205 |
items keysAndValuesDo:[:anIndex :anItem| |
|
4206 |
anItem isVisible ifTrue:[ |
|
4207 |
layout := anItem layout. |
|
4208 |
||
4209 |
(layout left < max and:[layout right > min]) ifTrue:[ |
|
4210 |
^ anIndex |
|
4211 |
]. |
|
4212 |
]. |
|
4213 |
] |
|
2016 | 4214 |
]. |
4215 |
^ 0 |
|
4216 |
! |
|
4217 |
||
4218 |
makeItemVisible:anItem |
|
4219 |
"make an item visible |
|
4220 |
" |
|
2018 | 4221 |
|boundsPREV boundsNEXT delta layout index scr0 scr1 windowSz scrSz doScroll |
4222 |
isVertical boundsMin layoutMin boundsMax layoutMax dltOrg |
|
2042 | 4223 |
inv1 inv2| |
2018 | 4224 |
|
4225 |
( anItem notNil |
|
4226 |
and:[self hasScrollers |
|
4227 |
and:[(layout := anItem layout) notNil]] |
|
4228 |
) ifFalse:[ |
|
2219 | 4229 |
^ self |
2016 | 4230 |
]. |
2018 | 4231 |
index := self indexOfItem:anItem. |
2016 | 4232 |
boundsPREV := self scrollerBoundsAt:#PREV. |
4233 |
boundsNEXT := self scrollerBoundsAt:#NEXT. |
|
4234 |
||
2018 | 4235 |
isVertical := self verticalLayout. |
4236 |
||
4237 |
isVertical ifTrue:[ |
|
2219 | 4238 |
boundsMin := boundsPREV bottom. |
4239 |
boundsMax := boundsNEXT top. |
|
4240 |
layoutMin := layout top. |
|
4241 |
layoutMax := layout bottom. |
|
4242 |
windowSz := height. |
|
2018 | 4243 |
] ifFalse:[ |
2219 | 4244 |
boundsMin := boundsPREV right. |
4245 |
boundsMax := boundsNEXT left. |
|
4246 |
layoutMin := layout left. |
|
4247 |
layoutMax := layout right. |
|
4248 |
windowSz := width. |
|
2018 | 4249 |
]. |
4250 |
||
4251 |
||
4252 |
layoutMin < boundsMin ifTrue:[ |
|
2219 | 4253 |
layoutMin >= 0 ifTrue:[ |
4254 |
^ self |
|
4255 |
]. |
|
4256 |
"/ test whether is first visible item |
|
4257 |
index := items findLast:[:el| el isVisible] startingAt:(index - 1). |
|
4258 |
||
4259 |
index == 0 ifTrue:[ scr0 := margin ] |
|
4260 |
ifFalse:[ scr0 := boundsMin ]. |
|
4261 |
||
4262 |
delta := layoutMin negated + scr0. |
|
2016 | 4263 |
] ifFalse:[ |
2219 | 4264 |
layoutMax > boundsMax ifFalse:[ |
4265 |
^ self |
|
4266 |
]. |
|
4267 |
"/ test whether is last visible item |
|
4268 |
index := items findFirst:[:el| el isVisible ] startingAt:(index + 1). |
|
4269 |
||
4270 |
index == 0 ifTrue:[ scr0 := windowSz - margin ] |
|
4271 |
ifFalse:[ scr0 := boundsMax ]. |
|
4272 |
||
4273 |
delta := scr0 - layoutMax. |
|
2018 | 4274 |
]. |
4275 |
delta == 0 ifTrue:[ ^ self ]. |
|
4276 |
||
2016 | 4277 |
doScroll := false. |
4278 |
||
4279 |
shown ifTrue:[ |
|
2219 | 4280 |
delta abs < (windowSz / 2) ifTrue:[ |
4281 |
doScroll := true. |
|
4282 |
self repairDamage |
|
4283 |
] |
|
2016 | 4284 |
]. |
2018 | 4285 |
isVertical ifTrue:[ dltOrg := 0@delta ] ifFalse:[dltOrg := delta@0]. |
4286 |
items do:[:el| el moveBy:dltOrg ]. |
|
2016 | 4287 |
|
4288 |
doScroll ifFalse:[ |
|
2219 | 4289 |
^ self invalidate |
2016 | 4290 |
]. |
4291 |
||
2018 | 4292 |
windowSz := windowSz - margin - margin. |
4293 |
||
4294 |
scr0 := boundsMin. |
|
4295 |
scr1 := scr0 + delta abs. |
|
4296 |
scrSz := boundsMax - scr1. |
|
4297 |
||
4298 |
delta < 0 ifTrue:[ |
|
2219 | 4299 |
isVertical ifTrue:[ |
4300 |
self copyFrom:self x:margin y:scr1 toX:margin y:scr0 |
|
4301 |
width:windowSz height:scrSz async:false. |
|
4302 |
||
4303 |
scr1 := scr0 + scrSz. |
|
4304 |
inv2 := (margin @ scr1) extent:(windowSz @ (height - scr1 - margin)). |
|
4305 |
"/ self invalidateX:margin y:scr1 width:windowSz height:(height - scr1 - margin). |
|
4306 |
] ifFalse:[ |
|
4307 |
self copyFrom:self x:scr1 y:margin toX:scr0 y:margin |
|
4308 |
width:scrSz height:windowSz async:false. |
|
4309 |
||
4310 |
scr1 := scr0 + scrSz. |
|
4311 |
inv2 := (scr1 @ margin) extent:((width - scr1 - margin) @ windowSz). |
|
4312 |
"/ self invalidateX:scr1 y:margin width:(width - scr1 - margin) height:windowSz. |
|
4313 |
]. |
|
4314 |
inv1 := boundsPREV. |
|
2016 | 4315 |
] ifFalse:[ |
2219 | 4316 |
isVertical ifTrue:[ |
4317 |
self copyFrom:self x:margin y:scr0 toX:margin y:scr1 |
|
4318 |
width:windowSz height:scrSz async:false. |
|
4319 |
||
4320 |
inv2 := (margin @ margin) extent:(windowSz @ (scr1 - margin)). |
|
4321 |
"/ self invalidateX:margin y:margin width:windowSz height:scr1 - margin. |
|
4322 |
] ifFalse:[ |
|
4323 |
self copyFrom:self x:scr0 y:margin toX:scr1 y:margin |
|
4324 |
width:scrSz height:windowSz async:false. |
|
4325 |
||
4326 |
inv2 := (margin @ margin) extent:(scr1 - margin) @ windowSz. |
|
4327 |
"/ self invalidateX:margin y:margin width:scr1 - margin height:windowSz. |
|
4328 |
]. |
|
4329 |
inv1 := boundsNEXT. |
|
2042 | 4330 |
]. |
4331 |
self invalidate:inv1. |
|
4332 |
self invalidate:inv2. |
|
2048 | 4333 |
|
4334 |
"Modified: / 13.11.2001 / 20:26:42 / cg" |
|
2016 | 4335 |
! |
4336 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4337 |
scrollActivity |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4338 |
"returns the one and only scrollActivity - data holder |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4339 |
for a menu and all contained submenus |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4340 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4341 |
superMenu notNil ifTrue:[ |
2219 | 4342 |
^ superMenu scrollActivity |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4343 |
]. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4344 |
scrollActivity isNil ifTrue:[ |
2219 | 4345 |
scrollActivity := ScrollActivity new. |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4346 |
]. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4347 |
^ scrollActivity |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4348 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4349 |
|
2016 | 4350 |
scrollerBoundsAt:aDirection |
4351 |
"returns the bounds of the scroller at a direction or nil |
|
4352 |
" |
|
4353 |
|y x w h inset| |
|
4354 |
||
4355 |
self hasScrollers ifFalse:[ |
|
2219 | 4356 |
^ nil |
2016 | 4357 |
]. |
4358 |
inset := 0. |
|
4359 |
x := y := inset. |
|
4360 |
w := h := 15. |
|
4361 |
||
4362 |
self verticalLayout ifTrue:[ |
|
2219 | 4363 |
aDirection == #NEXT ifTrue:[ |
4364 |
y := height - h - inset. |
|
4365 |
]. |
|
4366 |
w := width - inset - inset. |
|
2016 | 4367 |
] ifFalse:[ |
2219 | 4368 |
aDirection == #NEXT ifTrue:[ |
4369 |
x := width - w - inset. |
|
4370 |
]. |
|
4371 |
h := height - inset - inset. |
|
2016 | 4372 |
]. |
4373 |
^ Rectangle left:x top:y width:w height:h |
|
4374 |
! |
|
4375 |
||
2046 | 4376 |
scrollerDirectionAtPoint:aPoint |
4377 |
"returns the scroller-direction at aPoint, or nil |
|
4378 |
" |
|
4379 |
self hasScrollers ifTrue:[ |
|
2219 | 4380 |
#( PREV NEXT ) do:[:aDirection| |bounds| |
4381 |
( (bounds := self scrollerBoundsAt:aDirection) notNil |
|
4382 |
and:[bounds containsPoint:aPoint] |
|
4383 |
) ifTrue:[ |
|
4384 |
^ (self hasScrollerAt:aDirection) ifTrue:[aDirection] ifFalse:[nil] |
|
4385 |
] |
|
4386 |
] |
|
2046 | 4387 |
]. |
4388 |
^ nil |
|
4389 |
||
4390 |
"Created: / 13.11.2001 / 14:13:16 / cg" |
|
2016 | 4391 |
! ! |
4392 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4393 |
!MenuPanel methodsFor:'private-searching'! |
388 | 4394 |
|
1699 | 4395 |
detectGrabMenu |
4396 |
"returns the menu which is responsible for the grap; the last opened menu |
|
4397 |
" |
|
4398 |
|subMenu| |
|
4399 |
||
4400 |
selection notNil ifTrue:[ |
|
2219 | 4401 |
(subMenu := selection visibleSubmenu) notNil ifTrue:[ |
4402 |
^ subMenu detectGrabMenu |
|
4403 |
] |
|
1699 | 4404 |
]. |
4405 |
^ self |
|
4406 |
! |
|
4407 |
||
4408 |
detectMenuAtGrabPoint:aGrabPoint |
|
4409 |
"returns the menu which contains the grab-point |
|
4410 |
" |
|
4411 |
|dstMenu dstPoint firstMenu| |
|
4412 |
||
4413 |
dstPoint := self translateGrabPoint:aGrabPoint. |
|
4414 |
||
4415 |
((dstPoint x between:0 and:width) and:[dstPoint y between:0 and:height]) ifTrue:[ |
|
2219 | 4416 |
firstMenu := self. |
1699 | 4417 |
]. |
4418 |
||
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
4419 |
(selection isNil or:[(dstMenu := selection visibleSubmenu) isNil]) ifTrue:[ |
2219 | 4420 |
^ firstMenu |
1699 | 4421 |
]. |
4422 |
dstMenu := dstMenu detectMenuAtGrabPoint:aGrabPoint. |
|
2059 | 4423 |
^ dstMenu ? firstMenu |
1699 | 4424 |
! |
4425 |
||
1767 | 4426 |
detectViewAtX:x y:y in:aTopView |
1922 | 4427 |
"detect view at x@y |
4428 |
" |
|
2020
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4429 |
^ aTopView detectViewAt:(x@y). |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4430 |
|
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4431 |
"/ cg: old code was (refactored to use common code) |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4432 |
"/ |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4433 |
"/ |p subViews| |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4434 |
"/ |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4435 |
"/ (subViews := aTopView subViews) notNil ifTrue:[ |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4436 |
"/ subViews do:[:v| |p| |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4437 |
"/ v shown ifTrue:[ |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4438 |
"/ ( (x between:(v left) and:(v right)) |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4439 |
"/ and:[y between:(v top) and:(v bottom)] |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4440 |
"/ ) ifTrue:[ |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4441 |
"/ p := device translatePoint:(x@y) from:(aTopView id) to:(v id). |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4442 |
"/ ^ self detectViewAtX:p x y:p y in:v. |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4443 |
"/ ] |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4444 |
"/ ] |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4445 |
"/ ] |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4446 |
"/ ]. |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4447 |
"/ ^ aTopView |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4448 |
|
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4449 |
"Modified: / 10.10.2001 / 13:45:56 / cg" |
1767 | 4450 |
! |
4451 |
||
2046 | 4452 |
itemAtPoint:aPoint |
4453 |
"returns the item at a point x@y or nil if none detected |
|
4454 |
" |
|
4455 |
items notNil ifTrue:[ |
|
2219 | 4456 |
^ items detect:[:el| el containsPoint:aPoint] ifNone:nil |
2046 | 4457 |
]. |
4458 |
^ nil |
|
4459 |
||
4460 |
"Created: / 13.11.2001 / 13:58:23 / cg" |
|
4461 |
! |
|
4462 |
||
388 | 4463 |
itemAtX:x y:y |
1699 | 4464 |
"returns the item at a point x@y or nil if none detected |
4465 |
" |
|
4466 |
items notNil ifTrue:[ |
|
2219 | 4467 |
^ items detect:[:el| el containsPointX:x y:y] ifNone:nil |
1699 | 4468 |
]. |
4469 |
^ nil |
|
388 | 4470 |
! |
4471 |
||
2048 | 4472 |
superMenuAtPoint:aPoint |
4473 |
"returns the superMenu which contains aPoint, or nil if none detected |
|
1699 | 4474 |
" |
4475 |
|grabPoint superMenu| |
|
4476 |
||
2048 | 4477 |
(self containsPoint:aPoint) ifTrue:[ |
2219 | 4478 |
^ self |
1699 | 4479 |
]. |
4480 |
||
2048 | 4481 |
grabPoint := aPoint - (self translateGrabPoint:0). |
1699 | 4482 |
superMenu := self. |
4483 |
||
4484 |
[ (superMenu := superMenu superMenu) notNil ] whileTrue:[ |
|
2219 | 4485 |
(superMenu containsPoint:(superMenu translateGrabPoint:grabPoint)) ifTrue:[ |
4486 |
^ superMenu |
|
4487 |
] |
|
388 | 4488 |
]. |
4489 |
^ nil |
|
1699 | 4490 |
|
2048 | 4491 |
"Created: / 13.11.2001 / 20:22:53 / cg" |
388 | 4492 |
! ! |
4493 |
||
4494 |
!MenuPanel methodsFor:'queries'! |
|
4495 |
||
2003
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
4496 |
container:aView |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
4497 |
super container:aView. |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
4498 |
aView notNil ifTrue:[ |
2219 | 4499 |
"/ I am no longer a popUpView |
4500 |
self updateLevelAndBorder |
|
2003
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
4501 |
]. |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
4502 |
! |
732fbaf5864f
avoid changing the level after realization (to avoid confusing the shadow)
Claus Gittinger <cg@exept.de>
parents:
2000
diff
changeset
|
4503 |
|
388 | 4504 |
containsPoint:aPoint |
4505 |
"returns true if point is contained by the view |
|
4506 |
" |
|
4507 |
^ self containsPointX:(aPoint x) y:(aPoint y) |
|
4508 |
! |
|
4509 |
||
4510 |
containsPointX:x y:y |
|
4511 |
"returns true if point is contained by the view |
|
4512 |
" |
|
708 | 4513 |
^ (x between:0 and:width) and:[y between:0 and:height] |
879 | 4514 |
|
388 | 4515 |
! |
4516 |
||
390 | 4517 |
hasGroupDividerAt:anIndex |
388 | 4518 |
"returns true if a divider is defined at an index |
4519 |
" |
|
4520 |
|i| |
|
4521 |
||
4522 |
groupSizes size ~~ 0 ifTrue:[ |
|
2219 | 4523 |
i := 0. |
4524 |
||
4525 |
groupSizes do:[:t| |
|
4526 |
(i := i + t) == anIndex ifTrue:[ |
|
4527 |
^ true |
|
4528 |
] |
|
4529 |
] |
|
388 | 4530 |
]. |
4531 |
^ false |
|
4532 |
||
4533 |
! |
|
4534 |
||
390 | 4535 |
hasGroupDividers |
4536 |
"returns true if any group divider exists |
|
4537 |
" |
|
4538 |
^ (items size ~~ 0 and:[groupSizes size ~~ 0]) |
|
4539 |
! |
|
4540 |
||
388 | 4541 |
isEnabled |
4542 |
"returns enabled state of menu and items |
|
4543 |
" |
|
4544 |
^ self enabled |
|
4545 |
! |
|
4546 |
||
390 | 4547 |
isFitPanel |
4548 |
"returns true if the panel is the first in the menu hierarchy in must |
|
1699 | 4549 |
be fit to the extent of its superView; |
4550 |
NOT SUPPORTED |
|
4551 |
" |
|
4552 |
^ false |
|
390 | 4553 |
! |
4554 |
||
388 | 4555 |
isPopUpView |
4556 |
"return true if view is a popup view; without decoration |
|
4557 |
and popUp to top immediately |
|
4558 |
" |
|
4559 |
^ superView isNil |
|
4560 |
||
4561 |
||
4562 |
! |
|
4563 |
||
4564 |
isVerticalLayout |
|
4565 |
"returns true if vertical layout otherwise false( horizontal layout ) |
|
4566 |
" |
|
1699 | 4567 |
^ self verticalLayout |
388 | 4568 |
|
4569 |
||
416 | 4570 |
! |
4571 |
||
1793 | 4572 |
isViewWrapper |
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4573 |
^ items size == 0 and:[subViews size ~~ 0] |
1793 | 4574 |
! |
4575 |
||
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
4576 |
openMenuOnSelect |
2219 | 4577 |
"returns true if the item should open its menu if selected |
4578 |
" |
|
4579 |
|flag| |
|
4580 |
||
4581 |
flag := self menuAdornmentAt:#openMenuOnSelect. |
|
4582 |
flag ifNotNil:[^ flag]. |
|
4583 |
||
4584 |
^ styleSheet at:#'menu.openOnSelect' default:false |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
4585 |
! |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
4586 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
4587 |
openMenuOnSelect:something |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
4588 |
^ self menuAdornmentAt:#openMenuOnSelect put:something |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
4589 |
! |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
4590 |
|
2061 | 4591 |
select:newSel openMenu:openMenu |
4592 |
|old| |
|
4593 |
||
4594 |
old := self menuAdornmentAt:#openMenuOnSelect. |
|
4595 |
self menuAdornmentAt:#openMenuOnSelect put:openMenu. |
|
4596 |
self selection:newSel. |
|
4597 |
self menuAdornmentAt:#openMenuOnSelect put:old. |
|
4598 |
! |
|
4599 |
||
416 | 4600 |
type |
428 | 4601 |
^ nil. |
416 | 4602 |
|
388 | 4603 |
! ! |
4604 |
||
4605 |
!MenuPanel methodsFor:'selection'! |
|
4606 |
||
4607 |
hasSelection |
|
4608 |
"returns true if a selection exists |
|
4609 |
" |
|
4610 |
^ self selection notNil |
|
4611 |
! |
|
4612 |
||
2199 | 4613 |
openDelayed:anItem |
4614 |
|block| |
|
4615 |
||
4616 |
superMenu ifNotNil:[ |
|
2219 | 4617 |
superMenu openDelayed:anItem. |
4618 |
^ self |
|
4619 |
]. |
|
4620 |
||
4621 |
adornment isNil ifTrue:[ |
|
4622 |
anItem ifNil:[^ self]. |
|
4623 |
adornment := DefaultAdornment copy. |
|
4624 |
] ifFalse:[ |
|
4625 |
block := adornment removeKey:#delayedBlock ifAbsent:nil. |
|
4626 |
block ifNotNil:[ Processor removeTimedBlock:block ]. |
|
4627 |
anItem ifNil:[^ self]. |
|
4628 |
]. |
|
4629 |
||
4630 |
block := [ adornment at:#delayedBlock put:nil. |
|
2199 | 4631 |
anItem openDelayedSubmenu |
4632 |
]. |
|
4633 |
||
2219 | 4634 |
adornment at:#delayedBlock put:block. |
2199 | 4635 |
Processor addTimedBlock:block afterSeconds:0.5. |
4636 |
! |
|
4637 |
||
388 | 4638 |
selection |
4639 |
"returns current selected item or nil |
|
4640 |
" |
|
4641 |
^ selection |
|
4642 |
||
4643 |
||
4644 |
! |
|
4645 |
||
4646 |
selection:anItemOrNil |
|
2016 | 4647 |
"change selection to an item or nil |
4648 |
" |
|
4649 |
|item newSel hlp visItem| |
|
388 | 4650 |
|
1572 | 4651 |
(newSel := anItemOrNil) isNumber ifTrue:[ |
2219 | 4652 |
newSel := self itemAt:anItemOrNil |
1572 | 4653 |
]. |
2016 | 4654 |
visItem := newSel. |
4655 |
||
1572 | 4656 |
(newSel notNil and:[newSel canSelect]) ifFalse:[ |
2219 | 4657 |
newSel := nil |
388 | 4658 |
]. |
4659 |
||
2016 | 4660 |
selection == newSel ifTrue:[ |
2219 | 4661 |
^ self |
2016 | 4662 |
]. |
2199 | 4663 |
self openDelayed:nil. |
388 | 4664 |
|
4665 |
(item := selection) notNil ifTrue:[ |
|
2219 | 4666 |
selection := nil. |
4667 |
item selected:false. |
|
388 | 4668 |
]. |
2048 | 4669 |
visItem notNil ifTrue:[self makeItemVisible:visItem]. |
2016 | 4670 |
|
4671 |
newSel isNil ifTrue:[^ self]. |
|
4672 |
||
4673 |
newSel == enteredItem ifTrue:[ |
|
2219 | 4674 |
enteredItem := nil |
2016 | 4675 |
] ifFalse:[ |
2219 | 4676 |
self pointerEntersItem:nil |
2016 | 4677 |
]. |
4678 |
selection := newSel. |
|
4679 |
||
4680 |
ActiveHelp isActive ifTrue:[ |
|
2219 | 4681 |
hlp := ActiveHelp currentHelpListener. |
4682 |
hlp initiateHelpFor:self at:nil now:true. |
|
2016 | 4683 |
]. |
4684 |
shown "realized" ifTrue:[self rearrangeItems]. |
|
4685 |
selection selected:true. |
|
2048 | 4686 |
|
4687 |
"Modified: / 13.11.2001 / 20:17:47 / cg" |
|
388 | 4688 |
! |
4689 |
||
4690 |
selectionIndex |
|
4691 |
"returns index of current selection or 0 |
|
4692 |
" |
|
4693 |
|item| |
|
4694 |
||
4695 |
(item := self selection) notNil ifTrue:[ |
|
2145 | 4696 |
^ self findFirst:[:el| el == item ] |
388 | 4697 |
]. |
4698 |
^ 0 |
|
4699 |
||
4700 |
! |
|
4701 |
||
4702 |
selectionIndex:anIndex |
|
4703 |
"set selection at an index |
|
4704 |
" |
|
4705 |
self selection:(self itemAt:anIndex) |
|
4706 |
! ! |
|
4707 |
||
1791 | 4708 |
!MenuPanel methodsFor:'translation'! |
4709 |
||
4710 |
translateGrabPoint:aGrabPoint |
|
4711 |
"translate the grab point into self |
|
4712 |
" |
|
4713 |
superMenu isNil ifTrue:[ |
|
2219 | 4714 |
"I am the grapView" |
4715 |
aGrabPoint isNumber ifTrue:[^ aGrabPoint @ aGrabPoint]. |
|
1791 | 4716 |
^ aGrabPoint |
4717 |
]. |
|
4718 |
||
4719 |
relativeGrabOrigin isNil ifTrue:[ |
|
2219 | 4720 |
relativeGrabOrigin := self topMenu translatePoint:0 to:self. |
1791 | 4721 |
]. |
4722 |
^ relativeGrabOrigin + aGrabPoint |
|
4723 |
||
4724 |
! |
|
4725 |
||
4726 |
translateMenuPoint:aPoint toMenu:aMenu |
|
4727 |
"translate a point into another menu its point |
|
4728 |
" |
|
4729 |
|grapPoint| |
|
4730 |
||
4731 |
aMenu == self ifTrue:[ |
|
2219 | 4732 |
^ aPoint |
1791 | 4733 |
]. |
4734 |
grapPoint := aPoint - (self translateGrabPoint:0). |
|
4735 |
||
4736 |
^ aMenu translateGrabPoint:grapPoint |
|
4737 |
||
4738 |
! |
|
4739 |
||
2020
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4740 |
translatePoint:aPoint to:anotherWindowOrNilForScreen |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4741 |
"translate a point in my window to anotherWindowOrNilForScreen (or root window if nil) |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4742 |
" |
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4743 |
|
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4744 |
^ device |
2219 | 4745 |
translatePoint:aPoint asPoint |
4746 |
fromView:self |
|
4747 |
toView:anotherWindowOrNilForScreen |
|
2020
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4748 |
|
1f1868eba475
extracted common code to detectViewAt:aPoint.
Claus Gittinger <cg@exept.de>
parents:
2018
diff
changeset
|
4749 |
"Modified: / 10.10.2001 / 14:11:47 / cg" |
1791 | 4750 |
! ! |
4751 |
||
388 | 4752 |
!MenuPanel::Item class methodsFor:'accessing'! |
4753 |
||
689 | 4754 |
horizontalInset |
4755 |
^ HorizontalInset |
|
4756 |
! |
|
4757 |
||
388 | 4758 |
labelRightOffset |
4759 |
^ LabelRightOffset |
|
4760 |
! |
|
4761 |
||
689 | 4762 |
verticalInset |
4763 |
^ VerticalInset |
|
1765 | 4764 |
! |
4765 |
||
4766 |
verticalPopUpInset |
|
4767 |
^ VerticalPopUpInset |
|
388 | 4768 |
! ! |
4769 |
||
616 | 4770 |
!MenuPanel::Item class methodsFor:'defaults'! |
4771 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4772 |
halfSeparatorSize |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4773 |
"returns size of a space-separator |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4774 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4775 |
^ 5 |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4776 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
4777 |
|
1699 | 4778 |
separatorSize |
616 | 4779 |
"returns size of a separator |
4780 |
" |
|
1699 | 4781 |
^ 10 |
616 | 4782 |
! |
4783 |
||
4784 |
updateStyleCache |
|
388 | 4785 |
"setup defaults |
650 | 4786 |
self updateStyleCache |
388 | 4787 |
" |
1765 | 4788 |
<resource: #style (#'menuPanel.verticalInset')> |
4789 |
||
1699 | 4790 |
HorizontalInset := 2. |
1765 | 4791 |
VerticalInset := MenuPanel styleSheet at:#'menuPanel.verticalInset' default:2. |
4792 |
VerticalPopUpInset := 2. |
|
727 | 4793 |
|
4794 |
HorizontalButtonInset := 3. |
|
4795 |
VerticalButtonInset := 3. |
|
4796 |
||
681 | 4797 |
LabelRightOffset := 15. |
1765 | 4798 |
|
4799 |
||
1124 | 4800 |
! ! |
1078 | 4801 |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4802 |
!MenuPanel::Item class methodsFor:'defaults delayed menu'! |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4803 |
|
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4804 |
delayedMenuIndicator |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4805 |
"This resource specification was automatically generated |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4806 |
by the ImageEditor of ST/X." |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4807 |
|
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4808 |
"Do not manually edit this!! If it is corrupted, |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4809 |
the ImageEditor may not be able to read the specification." |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4810 |
|
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4811 |
" |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4812 |
self delayedMenuIndicator inspect |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4813 |
ImageEditor openOnClass:self andSelector:#delayedMenuIndicator |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4814 |
Icon flushCachedIcons |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4815 |
" |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4816 |
|
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4817 |
<resource: #image> |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4818 |
|
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4819 |
^Icon |
2219 | 4820 |
constantNamed:#'MenuPanel::Item class delayedMenuIndicator' |
4821 |
ifAbsentPut:[(Depth1Image new) width: 7; height: 4; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@B@0 @a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 7; height: 4; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'?''08D@@a') ; yourself); yourself] |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4822 |
! |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4823 |
|
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4824 |
delayedMenuIndicatorOffset |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4825 |
"returns an additional offset between the label and the |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4826 |
delayedMenu indication |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4827 |
" |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4828 |
^ 2 |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4829 |
! ! |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
4830 |
|
388 | 4831 |
!MenuPanel::Item class methodsFor:'instance creation'! |
4832 |
||
4833 |
in:aSuperMenu |
|
4834 |
^ self in:aSuperMenu label:nil |
|
4835 |
! |
|
4836 |
||
4837 |
in:aSuperMenu label:aLabel |
|
4838 |
|item| |
|
4839 |
||
4840 |
item := self new in:aSuperMenu. |
|
4841 |
item label:aLabel. |
|
4842 |
^ item |
|
4843 |
! |
|
4844 |
||
4845 |
in:aSuperMenu menuItem:aMenuItem |
|
4846 |
|item| |
|
4847 |
||
4848 |
item := self in:aSuperMenu. |
|
4849 |
item menuItem:aMenuItem. |
|
4850 |
^ item. |
|
4851 |
! ! |
|
4852 |
||
1808 | 4853 |
!MenuPanel::Item methodsFor:'accepting'! |
389 | 4854 |
|
420 | 4855 |
canAccept |
4856 |
"returns true if item is acceptable |
|
4857 |
" |
|
2199 | 4858 |
self enabled ifFalse:[ ^ false]. |
4859 |
self hasSubmenu ifFalse:[ ^ true ]. |
|
4860 |
||
4861 |
self hasDelayedMenu ifFalse:[^ false ]. |
|
4862 |
^ subMenu isNil or:[subMenu shown not] |
|
524 | 4863 |
! |
4864 |
||
4865 |
toggleIndication |
|
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
4866 |
"toggle indication or choice |
524 | 4867 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4868 |
|arg| |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4869 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4870 |
indication notNil ifTrue:[ |
2219 | 4871 |
arg := self indicationValue not. |
4872 |
self indicationValue:arg. |
|
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
4873 |
] ifFalse:[ |
2219 | 4874 |
choice notNil ifTrue:[ |
4875 |
choice value:choiceValue. |
|
4876 |
^ true |
|
4877 |
] |
|
524 | 4878 |
]. |
4879 |
^ arg |
|
389 | 4880 |
! ! |
4881 |
||
388 | 4882 |
!MenuPanel::Item methodsFor:'accessing'! |
4883 |
||
4884 |
accessCharacter |
|
389 | 4885 |
"returns my accessCharacter or nil |
388 | 4886 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4887 |
^ accessCharacter |
388 | 4888 |
! |
4889 |
||
4890 |
accessCharacterPosition |
|
390 | 4891 |
"get the access character position or nil |
388 | 4892 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4893 |
^ accessCharacterPosition |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4894 |
! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4895 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4896 |
accessCharacterPosition:anIndex |
390 | 4897 |
"set the access character position or nil |
388 | 4898 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4899 |
accessCharacterPosition := anIndex. |
388 | 4900 |
! |
4901 |
||
4902 |
argument |
|
4903 |
"gets the argument |
|
4904 |
" |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4905 |
^ argument |
388 | 4906 |
! |
4907 |
||
4908 |
argument:anArgument |
|
4909 |
"sets the argument |
|
4910 |
" |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4911 |
argument := anArgument. |
389 | 4912 |
! |
4913 |
||
1727 | 4914 |
font |
4915 |
"returns the user configured font or nil (default menu font) |
|
4916 |
" |
|
4917 |
^ font |
|
4918 |
! |
|
4919 |
||
4920 |
font:aFont |
|
4921 |
"returns the user configured font or nil (default menu font) |
|
4922 |
" |
|
4923 |
aFont ~= font ifTrue:[ |
|
2219 | 4924 |
font := aFont notNil ifTrue:[aFont onDevice:(menuPanel device)] |
4925 |
ifFalse:[nil]. |
|
4926 |
||
4927 |
rawLabel notNil ifTrue:[ |
|
4928 |
"have to recompute the extent" |
|
4929 |
self label:label |
|
4930 |
] |
|
1727 | 4931 |
]. |
4932 |
! |
|
4933 |
||
388 | 4934 |
label |
4935 |
"returns the label |
|
4936 |
" |
|
4937 |
^ label |
|
4938 |
! |
|
4939 |
||
4940 |
label:aLabel |
|
399 | 4941 |
"set a new label; if the label changed, a redraw is performed; |
4942 |
handle characters $& (ST-80 compatibility) |
|
388 | 4943 |
" |
1978
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
4944 |
|size char lbl mfont f oldExtent |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4945 |
h "{ Class:SmallInteger }" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4946 |
w "{ Class:SmallInteger }" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4947 |
| |
1978
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
4948 |
oldExtent := rawLabelExtent. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4949 |
accessCharacter := rawLabelExtent := disabledRawLabel := nil. |
1978
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
4950 |
label := aLabel value. |
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
4951 |
rawLabel := label value ? ''. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4952 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4953 |
rawLabel isString ifTrue:[ |
2219 | 4954 |
"CHECK FOR SEPARATOR" |
4955 |
||
4956 |
(isButton not and:[indication isNil and:[choice isNil]]) ifTrue:[ |
|
4957 |
size := rawLabel size. |
|
4958 |
||
4959 |
size == 0 ifTrue:[ |
|
4960 |
rawLabel := nil. "blank separator" |
|
4961 |
^ self |
|
4962 |
]. |
|
4963 |
||
4964 |
size == 1 ifTrue:[ |
|
4965 |
char := rawLabel first. |
|
4966 |
||
4967 |
(char == $- or:[char == $=]) ifTrue:[ |
|
4968 |
label := rawLabel. "line separator" |
|
4969 |
rawLabel := nil. |
|
4970 |
^ self |
|
4971 |
] |
|
4972 |
] |
|
4973 |
] |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4974 |
] ifFalse:[ |
2219 | 4975 |
rawLabel isCollection ifTrue:[ |
4976 |
rawLabel := rawLabel asArray. |
|
4977 |
] |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4978 |
]. |
1727 | 4979 |
mfont := menuPanel setFont:font. |
4980 |
||
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4981 |
rawLabel isArray ifTrue:[ |
2219 | 4982 |
w := h := 0. |
4983 |
||
4984 |
rawLabel keysAndValuesDo:[:i :el| |
|
4985 |
el notNil ifTrue:[ |
|
4986 |
lbl := self updateAccessCharacterFor:el. |
|
4987 |
rawLabel at:i put:lbl. |
|
4988 |
w := w max:(lbl widthOn:menuPanel). |
|
4989 |
h := h + 1 + (lbl heightOn:menuPanel). |
|
4990 |
] ifFalse:[ |
|
4991 |
h := h + 3 |
|
4992 |
] |
|
4993 |
] |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4994 |
] ifFalse:[ |
2219 | 4995 |
rawLabel := self updateAccessCharacterFor:rawLabel. |
4996 |
w := rawLabel widthOn:menuPanel. |
|
4997 |
h := rawLabel heightOn:menuPanel. |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
4998 |
]. |
1797
28327a68241b
give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
4999 |
|
28327a68241b
give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
5000 |
"/ care for italic fonts - give a few more pixels at the end |
28327a68241b
give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
5001 |
f := mfont ? (menuPanel font). |
28327a68241b
give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
5002 |
(f notNil and:[f italic]) ifTrue:[ |
2219 | 5003 |
w := w + 2. |
1797
28327a68241b
give a few more pixels at the right if the used font is
Claus Gittinger <cg@exept.de>
parents:
1796
diff
changeset
|
5004 |
]. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5005 |
rawLabelExtent := w@h. |
1978
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
5006 |
|
1727 | 5007 |
menuPanel setFont:mfont. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5008 |
menuPanel shown ifTrue:[ self fetchImages ]. |
1978
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
5009 |
|
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
5010 |
oldExtent = rawLabelExtent ifTrue:[ |
2219 | 5011 |
self invalidate |
1978
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
5012 |
] ifFalse:[ |
2219 | 5013 |
menuPanel mustRearrange |
1978
a53447b8cbe2
set label; reange menu if extent changed otherwise redraw only the item
martin
parents:
1955
diff
changeset
|
5014 |
]. |
388 | 5015 |
! |
5016 |
||
5017 |
menuPanel |
|
5018 |
"returns my menuPanel |
|
5019 |
" |
|
399 | 5020 |
^ menuPanel |
388 | 5021 |
! |
5022 |
||
5023 |
nameKey |
|
5024 |
"gets the nameKey |
|
5025 |
" |
|
5026 |
^ nameKey |
|
5027 |
! |
|
5028 |
||
5029 |
nameKey:aNameKey |
|
5030 |
"sets the nameKey |
|
5031 |
" |
|
5032 |
nameKey := aNameKey. |
|
5033 |
! |
|
5034 |
||
5035 |
rawLabel |
|
390 | 5036 |
"returns my printable Label |
388 | 5037 |
" |
5038 |
^ rawLabel |
|
5039 |
! |
|
5040 |
||
5041 |
shortcutKey |
|
5042 |
"get the key to press to select the submenu from the keyboard or if |
|
5043 |
no submenu exists evaluate the action assigned to the item (accept). |
|
5044 |
" |
|
1609 | 5045 |
^ shortcutKey |
388 | 5046 |
! |
5047 |
||
5048 |
shortcutKey:aKey |
|
5049 |
"set the key to press to select the submenu from the keyboard or if |
|
5050 |
no submenu exists evaluate the action assigned to the item (accept). |
|
5051 |
" |
|
1609 | 5052 |
shortcutKey ~~ aKey ifTrue:[ |
2219 | 5053 |
shortcutKey := aKey. |
5054 |
self invalidate. |
|
1889
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
5055 |
]. |
43516e4588ce
give warning messages for unimplemented menu-aspects
Claus Gittinger <cg@exept.de>
parents:
1878
diff
changeset
|
5056 |
! |
388 | 5057 |
|
710 | 5058 |
startGroup |
5059 |
"start group #left #right #center ... or nil |
|
5060 |
at the moment only #right is implemented |
|
5061 |
" |
|
5062 |
^ startGroup |
|
5063 |
! |
|
5064 |
||
5065 |
startGroup:aSymbol |
|
5066 |
"start group #left #right #center ... |
|
5067 |
at the moment only #right is implemented |
|
5068 |
" |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5069 |
startGroup := aSymbol. |
710 | 5070 |
! |
5071 |
||
388 | 5072 |
submenu |
5073 |
"returns my submenu or nil |
|
5074 |
" |
|
464 | 5075 |
subMenu notNil ifTrue:[^ subMenu]. |
5076 |
^ self setupSubmenu |
|
388 | 5077 |
! |
5078 |
||
5079 |
submenu:aSubMenu |
|
5080 |
"set a new submenu; an existing submenu will be destroyed. This might lead |
|
5081 |
to a redraw if 'hasSubmenu' changed |
|
5082 |
" |
|
1795
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
5083 |
|widget| |
1767 | 5084 |
|
5085 |
aSubMenu isNil ifTrue:[ |
|
2219 | 5086 |
subMenu notNil ifTrue:[ |
5087 |
subMenu destroy. |
|
5088 |
subMenu := nil. |
|
5089 |
]. |
|
5090 |
^ self |
|
1767 | 5091 |
]. |
5092 |
||
1795
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
5093 |
(aSubMenu isKindOf:Menu) ifTrue:[ |
2219 | 5094 |
subMenu := MenuPanel new. |
5095 |
||
5096 |
menuPanel notNil ifTrue:[ |
|
5097 |
subMenu receiver:menuPanel receiver. |
|
5098 |
]. |
|
5099 |
subMenu superMenu:menuPanel. |
|
5100 |
||
5101 |
horizontalLayout == true ifTrue:[ |
|
5102 |
subMenu verticalLayout:false |
|
5103 |
]. |
|
5104 |
subMenu menu:aSubMenu. |
|
1767 | 5105 |
] ifFalse:[ |
2219 | 5106 |
aSubMenu isView ifFalse:[ |
5107 |
(aSubMenu isKindOf:ApplicationModel) ifFalse:[ |
|
5108 |
"/ ... mhhhh .... |
|
5109 |
^ self submenuChannel:aSubMenu |
|
5110 |
]. |
|
5111 |
widget := SimpleView new. |
|
5112 |
widget client:aSubMenu. |
|
5113 |
] ifTrue:[ |
|
5114 |
widget := aSubMenu |
|
5115 |
]. |
|
5116 |
||
5117 |
(widget isKindOf:MenuPanel) ifTrue:[ |
|
5118 |
subMenu := widget. |
|
5119 |
horizontalLayout == true ifTrue:[ subMenu verticalLayout:false ]. |
|
5120 |
] ifFalse:[ |
|
5121 |
subMenu := MenuPanel new. |
|
5122 |
subMenu receiver:menuPanel receiver. |
|
5123 |
subMenu addSubView:widget. |
|
5124 |
subMenu extent:(widget preferredExtent). |
|
5125 |
widget origin:0.0@0.0 corner:1.0@1.0. |
|
5126 |
]. |
|
5127 |
subMenu superMenu:menuPanel. |
|
1929 | 5128 |
]. |
5129 |
self keepLinkedMenu ifTrue:[ |
|
2219 | 5130 |
submenuChannel := nil |
1929 | 5131 |
] |
389 | 5132 |
! |
5133 |
||
390 | 5134 |
textLabel |
5135 |
"returns my textLabel or nil if none text |
|
5136 |
" |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5137 |
|txt| |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5138 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5139 |
rawLabel notNil ifTrue:[ |
2219 | 5140 |
rawLabel isArray ifFalse:[ |
5141 |
^ rawLabel perform:#string ifNotUnderstood:nil |
|
5142 |
]. |
|
5143 |
||
5144 |
rawLabel do:[:el| |
|
5145 |
(txt := el perform:#string ifNotUnderstood:nil) notNil ifTrue:[ |
|
5146 |
^ txt |
|
5147 |
] |
|
5148 |
]. |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5149 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5150 |
^ nil |
1699 | 5151 |
|
390 | 5152 |
! |
5153 |
||
1841 | 5154 |
triggerOnDown |
5155 |
"trigger the action if pressed |
|
5156 |
" |
|
5157 |
triggerOnDown == true ifTrue:[ |
|
2219 | 5158 |
self hasSubmenu ifFalse:[^ true]. |
5159 |
triggerOnDown := false. |
|
1841 | 5160 |
]. |
5161 |
^ false |
|
5162 |
! |
|
5163 |
||
5164 |
triggerOnDown:aBool |
|
5165 |
"trigger the action if pressed |
|
5166 |
" |
|
5167 |
triggerOnDown := aBool. |
|
5168 |
! |
|
5169 |
||
389 | 5170 |
value |
5171 |
"gets value |
|
5172 |
" |
|
5173 |
^ value |
|
5174 |
! |
|
5175 |
||
5176 |
value:something |
|
5177 |
"could be a value holder, an action or selector |
|
5178 |
" |
|
5179 |
value := something. |
|
502 | 5180 |
! |
5181 |
||
5182 |
value:aValue argument:anArgument |
|
5183 |
"set the value and an argument |
|
5184 |
" |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5185 |
value := aValue. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5186 |
argument := anArgument. |
388 | 5187 |
! ! |
5188 |
||
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
5189 |
!MenuPanel::Item methodsFor:'accessing-behavior'! |
388 | 5190 |
|
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5191 |
choice |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5192 |
"implements a radio group; the field |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5193 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5194 |
^ choice |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5195 |
|
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5196 |
! |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5197 |
|
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5198 |
choice:something |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5199 |
"set choice indication |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5200 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5201 |
choice == something ifTrue:[^ self]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5202 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5203 |
choice isValueModel ifTrue:[ |
2219 | 5204 |
choice removeDependent:self |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5205 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5206 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5207 |
(choice := something) notNil ifTrue:[ |
2219 | 5208 |
choice isSymbol ifTrue:[ |
5209 |
(choice := self aspectAt:choice) isNil ifTrue:[ |
|
5210 |
choice := something |
|
5211 |
] |
|
5212 |
]. |
|
5213 |
choice isValueModel ifTrue:[ |
|
5214 |
choice addDependent:self |
|
5215 |
] |
|
1699 | 5216 |
]. |
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5217 |
! |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5218 |
|
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5219 |
choiceValue |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5220 |
"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
|
5221 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5222 |
^ choiceValue |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5223 |
|
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5224 |
! |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5225 |
|
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5226 |
choiceValue:something |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5227 |
"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
|
5228 |
" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5229 |
choiceValue ~= something ifTrue:[ |
2219 | 5230 |
choiceValue := something. |
5231 |
||
5232 |
choice notNil ifTrue:[ |
|
5233 |
self invalidate |
|
5234 |
] |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5235 |
]. |
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5236 |
! |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
5237 |
|
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5238 |
delayMenu |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5239 |
"return true, the menu is shown delayed, if the button is still pressed after a while. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5240 |
Only useful with buttons in non-popup-menus |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5241 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5242 |
^ delayMenu ? false |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5243 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5244 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5245 |
delayMenu:aBoolean |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5246 |
"if true, the menu is shown delayed, if the button is still pressed after a while. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5247 |
Only useful with buttons in non-popup-menus |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5248 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5249 |
delayMenu := aBoolean. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5250 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5251 |
|
388 | 5252 |
enabled |
5253 |
"returns the enabled state |
|
5254 |
" |
|
524 | 5255 |
|state| |
5256 |
||
5257 |
menuPanel enabled ifTrue:[ |
|
2219 | 5258 |
enableChannel isSymbol ifTrue:[ |
5259 |
state := self aspectAt:enableChannel. |
|
5260 |
state isNil ifTrue:[ |
|
5261 |
self ifNotInUIBuilderInfoPrintCR: |
|
5262 |
('MenuPanel::Item [info]: no aspect for ', enableChannel, ' (in ' , (label?rawLabel) printString , ')') |
|
5263 |
] ifFalse:[ |
|
5264 |
state isValueModel ifTrue:[ |
|
5265 |
enableChannel := state. |
|
5266 |
enableChannel addDependent:self. |
|
5267 |
state := enableChannel value. |
|
5268 |
] ifFalse:[ |
|
5269 |
state := state value |
|
5270 |
] |
|
5271 |
] |
|
5272 |
] ifFalse:[ |
|
5273 |
state := enableChannel value |
|
5274 |
]. |
|
524 | 5275 |
^ state ~~ false |
460 | 5276 |
]. |
524 | 5277 |
^ false |
388 | 5278 |
! |
5279 |
||
389 | 5280 |
enabled:something |
388 | 5281 |
"change the enabled state; if the state changed, a redraw is performed |
5282 |
" |
|
390 | 5283 |
|oldState newState| |
5284 |
||
5285 |
enableChannel isNil ifTrue:[ |
|
2219 | 5286 |
oldState := true |
390 | 5287 |
] ifFalse:[ |
2219 | 5288 |
oldState := enableChannel value. |
5289 |
enableChannel isValueModel ifTrue:[ |
|
5290 |
enableChannel removeDependent:self |
|
5291 |
] |
|
388 | 5292 |
]. |
390 | 5293 |
enableChannel := something. |
5294 |
||
5295 |
enableChannel isNil ifTrue:[ |
|
2219 | 5296 |
menuPanel shown ifFalse:[^ self]. |
5297 |
newState := true |
|
390 | 5298 |
] ifFalse:[ |
2219 | 5299 |
enableChannel isValueModel ifTrue:[ |
5300 |
enableChannel addDependent:self |
|
5301 |
] ifFalse:[ |
|
5302 |
enableChannel isSymbol ifTrue:[^ self] |
|
5303 |
]. |
|
5304 |
menuPanel shown ifFalse:[^ self]. |
|
5305 |
newState := enableChannel value. |
|
390 | 5306 |
]. |
5307 |
||
5308 |
newState ~~ oldState ifTrue:[ |
|
2219 | 5309 |
self invalidate |
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
5310 |
]. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5311 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5312 |
|
1670 | 5313 |
hideMenuOnActivated |
5314 |
"hide the menu when the item was activated; the default is true |
|
5315 |
" |
|
5316 |
^ hideMenuOnActivated ? true |
|
5317 |
||
5318 |
! |
|
5319 |
||
5320 |
hideMenuOnActivated:aBool |
|
5321 |
"hide the menu when the item was activated; the default is true |
|
5322 |
" |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5323 |
hideMenuOnActivated := aBool. |
1670 | 5324 |
|
5325 |
||
5326 |
! |
|
5327 |
||
2216 | 5328 |
ifNotInUIBuilderInfoPrintCR:aMessage |
5329 |
"/ q&d hack to suppress info-messages in UIBuilder |
|
5330 |
||
5331 |
(menuPanel receiver isNil |
|
5332 |
and:[ menuPanel application notNil |
|
5333 |
and:[ menuPanel application askFor:#isUIPainter]]) |
|
5334 |
ifTrue:[ |
|
2219 | 5335 |
^ self "/ suppressed |
2216 | 5336 |
]. |
5337 |
aMessage infoPrintCR |
|
5338 |
! |
|
5339 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5340 |
indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5341 |
"get on/off indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5342 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5343 |
^ indication |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5344 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5345 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5346 |
indication:something |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5347 |
"set on/off indication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5348 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5349 |
indication == something ifTrue:[^ self]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5350 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5351 |
indication isValueModel ifTrue:[ |
2219 | 5352 |
indication removeDependent:self |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5353 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5354 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5355 |
(indication := something) notNil ifTrue:[ |
2219 | 5356 |
indication isValueModel ifTrue:[ |
5357 |
indication addDependent:self |
|
5358 |
] ifFalse:[ |
|
5359 |
"/ to force an update of the value |
|
5360 |
self indicationValue |
|
5361 |
] |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5362 |
]. |
464 | 5363 |
! |
5364 |
||
1767 | 5365 |
keepLinkedMenu |
5366 |
"get the keepLinkedMenu flag |
|
5367 |
" |
|
5368 |
^ keepLinkedMenu ? false |
|
5369 |
! |
|
5370 |
||
5371 |
keepLinkedMenu:aFlag |
|
5372 |
"get the keepLinkedMenu flag |
|
5373 |
" |
|
5374 |
keepLinkedMenu := aFlag |
|
5375 |
! |
|
5376 |
||
464 | 5377 |
submenuChannel |
5378 |
"get the submenu channel |
|
5379 |
" |
|
5380 |
^ submenuChannel |
|
5381 |
! |
|
5382 |
||
5383 |
submenuChannel:aSelectorOrNil |
|
5384 |
"returns the submenu channel |
|
5385 |
" |
|
5386 |
submenuChannel := aSelectorOrNil. |
|
388 | 5387 |
! ! |
5388 |
||
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
5389 |
!MenuPanel::Item methodsFor:'accessing-dimension'! |
388 | 5390 |
|
2016 | 5391 |
moveBy:aPoint |
5392 |
"move layout origin |
|
5393 |
" |
|
5394 |
layout moveBy:aPoint. |
|
5395 |
! |
|
5396 |
||
1699 | 5397 |
preferredExtent |
5398 |
"compute my preferred extent excluding the shortCutKey and the menu identifier |
|
5399 |
" |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
5400 |
|isVertical icon |
1699 | 5401 |
x "{ Class:SmallInteger }" |
5402 |
y "{ Class:SmallInteger }" |
|
5403 |
s "{ Class:SmallInteger }" |
|
5404 |
| |
|
5405 |
self isVisible ifFalse:[^ 0@0 ]. |
|
5406 |
||
5407 |
isButton ifTrue:[ |
|
2219 | 5408 |
s := menuPanel maxAbsoluteButtonLevel. |
5409 |
x := s + HorizontalButtonInset. |
|
5410 |
y := s + VerticalButtonInset. |
|
1699 | 5411 |
] ifFalse:[ |
2219 | 5412 |
x := HorizontalInset. |
5413 |
y := (menuPanel isPopUpView ifTrue:[VerticalPopUpInset] ifFalse:[VerticalInset]) ? 2. |
|
1699 | 5414 |
]. |
5415 |
x := x * 2. |
|
5416 |
y := y * 2. |
|
5417 |
||
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5418 |
isVertical := menuPanel verticalLayout. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5419 |
|
1699 | 5420 |
rawLabel isNil ifTrue:[ |
2219 | 5421 |
"SEPARATOR" |
5422 |
||
5423 |
s := self class separatorSize. |
|
5424 |
label = '' ifTrue:[ |
|
5425 |
s := self class halfSeparatorSize. |
|
5426 |
]. |
|
5427 |
||
5428 |
"width of doubleSeparator is 5 !!!!" |
|
5429 |
isVertical ifFalse:[ |
|
5430 |
x := x max:s. |
|
5431 |
y := y + 5. |
|
5432 |
] ifTrue:[ |
|
5433 |
y := y max:s. |
|
5434 |
x := x + 5. |
|
5435 |
]. |
|
1699 | 5436 |
] ifFalse:[ |
2219 | 5437 |
x := x + rawLabelExtent x. |
5438 |
y := y + rawLabelExtent y. |
|
5439 |
||
5440 |
isButton ifFalse:[ |
|
5441 |
menuPanel showSeparatingLines ifTrue:[ |
|
5442 |
"width of separator is 2 plus right offset 1 := 3" |
|
5443 |
isVertical ifFalse:[x := x + 3] ifTrue:[y := y + 3]. |
|
5444 |
]. |
|
5445 |
(indication notNil or:[choice notNil]) ifTrue:[ |
|
5446 |
x := x + 2 + menuPanel iconIndicationOff width. |
|
5447 |
]. |
|
5448 |
]. |
|
5449 |
self hasDelayedMenuIndicator ifTrue:[ |
|
5450 |
icon := self class delayedMenuIndicator. |
|
5451 |
||
5452 |
x := x + self class delayedMenuIndicatorOffset + icon width. |
|
5453 |
]. |
|
1699 | 5454 |
]. |
5455 |
^ x@y |
|
388 | 5456 |
! ! |
5457 |
||
1679
af40842718f6
when accepting, and the application does not respond to that
Claus Gittinger <cg@exept.de>
parents:
1670
diff
changeset
|
5458 |
!MenuPanel::Item methodsFor:'accessing-help'! |
1613 | 5459 |
|
5460 |
activeHelpKey |
|
5461 |
"get the active helpKey; the key to retrieve the helpText from the application |
|
5462 |
" |
|
5463 |
^ activeHelpKey |
|
5464 |
! |
|
5465 |
||
5466 |
activeHelpKey:aHelpKey |
|
5467 |
"set the active helpKey; the key to retrieve the helpText from the application |
|
5468 |
" |
|
5469 |
activeHelpKey ~~ aHelpKey ifTrue:[ |
|
2219 | 5470 |
activeHelpKey := aHelpKey. |
5471 |
activeHelpText := nil. |
|
1613 | 5472 |
]. |
5473 |
||
5474 |
! |
|
5475 |
||
5476 |
activeHelpText |
|
5477 |
"get the active helpText or nil if not yet resolved |
|
5478 |
" |
|
5479 |
^ activeHelpText |
|
5480 |
! |
|
5481 |
||
5482 |
activeHelpText:aText |
|
5483 |
"set the active helpText |
|
5484 |
" |
|
5485 |
activeHelpText := aText. |
|
5486 |
! ! |
|
5487 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5488 |
!MenuPanel::Item methodsFor:'accessing-look'! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5489 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5490 |
horizontalLayout |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5491 |
"on default submenus has a vertical layout; |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5492 |
true, the submenu has a horizontal layout. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5493 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5494 |
subMenu ifNotNil:[ |
2219 | 5495 |
^ subMenu verticalLayout == false |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5496 |
]. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5497 |
^ horizontalLayout ? false |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5498 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5499 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5500 |
horizontalLayout:aBoolean |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5501 |
"on default submenus has a vertical layout; |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5502 |
true, the submenu has a horizontal layout. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5503 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5504 |
aBoolean == true ifTrue:[ |
2219 | 5505 |
horizontalLayout := true |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5506 |
] ifFalse:[ |
2219 | 5507 |
horizontalLayout := nil "/ default |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5508 |
]. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5509 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5510 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5511 |
isButton |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5512 |
"returns whether item looks like a Button |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5513 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5514 |
^ isButton |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5515 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5516 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5517 |
isButton:anBoolean |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5518 |
"sets whether item looks like a Button |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5519 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5520 |
isButton := anBoolean. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5521 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5522 |
layout notNil ifTrue:[ |
2219 | 5523 |
self invalidate. |
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5524 |
] |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5525 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5526 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5527 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5528 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5529 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5530 |
layout |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5531 |
"returns my layout ( Rectangle ) |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5532 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5533 |
^ layout |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5534 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5535 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5536 |
layout:aLayout |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5537 |
"set a new layout ( Rectangle ) |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5538 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5539 |
layout := aLayout. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5540 |
self invalidate. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5541 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5542 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5543 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5544 |
showBusyCursorWhilePerforming |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5545 |
"get the flag which controls if a busy cursor is to be shown |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5546 |
while performing the menu action. Defaults to false. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5547 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5548 |
^ showBusyCursorWhilePerforming ? false |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5549 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5550 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5551 |
! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5552 |
|
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5553 |
showBusyCursorWhilePerforming:aBoolean |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5554 |
"set/clear the flag which controls if a busy cursor is to be shown |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5555 |
while performing the menu action. Defaults to false. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5556 |
" |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5557 |
showBusyCursorWhilePerforming := aBoolean. |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5558 |
! ! |
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
5559 |
|
1705 | 5560 |
!MenuPanel::Item methodsFor:'activation / deactivation'! |
5561 |
||
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5562 |
currentSubmenu |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5563 |
"returns the current submenu or nil |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5564 |
" |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5565 |
^ subMenu |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5566 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5567 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5568 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5569 |
! |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5570 |
|
1705 | 5571 |
hideSubmenu |
5572 |
"hide submenu |
|
5573 |
" |
|
2199 | 5574 |
self hideSubmenu:subMenu. |
5575 |
! |
|
5576 |
||
5577 |
hideSubmenu:aSubmenu |
|
5578 |
"hide submenu |
|
5579 |
" |
|
1705 | 5580 |
|id| |
5581 |
||
2199 | 5582 |
aSubmenu ifNil:[^ self]. |
5583 |
||
5584 |
aSubmenu realized ifFalse:[ |
|
2219 | 5585 |
id := aSubmenu id. |
5586 |
id ifNotNil:[ menuPanel device unmapWindow:id ] |
|
2199 | 5587 |
] ifTrue:[ |
2219 | 5588 |
aSubmenu hide |
2199 | 5589 |
]. |
5590 |
||
5591 |
aSubmenu windowGroup:nil. |
|
5592 |
menuPanel windowGroup removeView:aSubmenu. |
|
5593 |
||
5594 |
"/ release menu if derived from channel |
|
5595 |
submenuChannel notNil ifTrue:[ |
|
2219 | 5596 |
subMenu == aSubmenu ifTrue:[ |
5597 |
subMenu := nil |
|
5598 |
] |
|
2199 | 5599 |
]. |
5600 |
! |
|
5601 |
||
5602 |
openDelayedSubmenu |
|
5603 |
"called to open now my delayed submenu |
|
5604 |
" |
|
5605 |
|subm| |
|
5606 |
||
5607 |
(self isSelected and:[menuPanel shown]) ifFalse:[^ self]. |
|
5608 |
||
5609 |
subMenu ifNotNil:[ |
|
2219 | 5610 |
subMenu realized ifTrue:[ |
5611 |
"/ already open |
|
5612 |
^ self |
|
5613 |
]. |
|
2199 | 5614 |
]. |
5615 |
subm := self setupSubmenu. |
|
5616 |
subm ifNil:[^ self]. |
|
5617 |
||
5618 |
self openSubmenu. |
|
5619 |
||
5620 |
(subm == subMenu and:[self isSelected]) ifFalse:[ |
|
2219 | 5621 |
"/ closed during building or opening the submenu |
5622 |
self hideSubmenu:subm. |
|
2199 | 5623 |
]. |
1705 | 5624 |
! |
1701 | 5625 |
|
5626 |
openSubmenu |
|
5627 |
"opens the submenu; make sure, that the submenu and the menPanel |
|
5628 |
is fully visible by shifting it into the visible screen area if |
|
5629 |
nescessary. |
|
5630 |
" |
|
1790
98b89f8f4c17
do not select the first item if it represants a submenu
ca
parents:
1788
diff
changeset
|
5631 |
|p o device isVertical topMenu windGrp prefExtent item |
1701 | 5632 |
devBot "{ Class:SmallInteger }" |
5633 |
devRight "{ Class:SmallInteger }" |
|
5634 |
width "{ Class:SmallInteger }" |
|
5635 |
height "{ Class:SmallInteger }" |
|
5636 |
top "{ Class:SmallInteger }" |
|
5637 |
left "{ Class:SmallInteger }" |
|
5638 |
| |
|
5639 |
||
1737
c18896a7cb50
replace shown by realized; when opening a submenue-submenue by shortcut key
ca
parents:
1735
diff
changeset
|
5640 |
(subMenu notNil and:[subMenu shown not and:[self isSelected and:[menuPanel realized]]]) ifFalse:[ |
2219 | 5641 |
^ self |
1701 | 5642 |
]. |
5643 |
||
5644 |
topMenu := menuPanel topMenu. |
|
1829 | 5645 |
(subMenu device notNil and:[topMenu device ~~ subMenu device]) ifTrue:[ |
2219 | 5646 |
subMenu releaseDeviceResources. |
5647 |
subMenu setDevice:topMenu device id:nil gcId:nil. |
|
5648 |
subMenu recreate. |
|
1829 | 5649 |
]. |
5650 |
||
1701 | 5651 |
windGrp := topMenu windowGroup. |
5652 |
||
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5653 |
subMenu superMenu:menuPanel. |
1701 | 5654 |
subMenu becomesActiveMenu. |
5655 |
subMenu cursor:Cursor hand. |
|
5656 |
||
5657 |
windGrp notNil ifTrue:[ |
|
2219 | 5658 |
subMenu windowGroup:windGrp. |
5659 |
windGrp addTopView:subMenu. |
|
1701 | 5660 |
]. |
5661 |
||
2111 | 5662 |
"Q&D kludge - test whether the layout is nil; |
2219 | 5663 |
if true recompute the layouts |
2111 | 5664 |
" |
5665 |
layout ifNil:[menuPanel rearrangeItems]. |
|
5666 |
||
1701 | 5667 |
" Q&D kludge - if any visibility attributes are blocks; |
5668 |
TODO: only invoke mustRearrange if any are blocks |
|
2219 | 5669 |
(since I react correctly on valueHolder changes) |
1701 | 5670 |
" |
5671 |
subMenu rearrangeItemsIfItemVisibilityChanged. |
|
5672 |
subMenu fixSize. |
|
5673 |
||
5674 |
"compute origin of subMenu |
|
5675 |
" |
|
5676 |
isVertical := menuPanel verticalLayout. |
|
5677 |
device := menuPanel device. |
|
1714
b4c05977e9d5
get heigth and width from preferredExtent when open a submenu
ca
parents:
1710
diff
changeset
|
5678 |
prefExtent := subMenu preferredExtent. |
b4c05977e9d5
get heigth and width from preferredExtent when open a submenu
ca
parents:
1710
diff
changeset
|
5679 |
height := prefExtent y. |
b4c05977e9d5
get heigth and width from preferredExtent when open a submenu
ca
parents:
1710
diff
changeset
|
5680 |
width := prefExtent x. |
1701 | 5681 |
devBot := device usableHeight. |
5682 |
devRight := device usableWidth. |
|
5683 |
||
5684 |
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
|
5685 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5686 |
menuPanel isPopUpView ifTrue:[ |
2219 | 5687 |
o := menuPanel origin + p |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5688 |
] ifFalse:[ |
2219 | 5689 |
o := menuPanel translatePoint:p to:nil. "/ translate to root window |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5690 |
]. |
1701 | 5691 |
left := o x. |
5692 |
top := o y. |
|
5693 |
||
2016 | 5694 |
top + height > devBot ifTrue:[ |
2219 | 5695 |
top := isVertical ifTrue:[devBot - height] |
5696 |
ifFalse:[top - layout height - height + 2] |
|
2016 | 5697 |
]. |
5698 |
top := top max:0. |
|
5699 |
||
5700 |
"/ (isVertical not and:[subMenu isVerticalLayout]) ifTrue:[ |
|
5701 |
"/ top < menuPanel bottom ifTrue:[ |
|
5702 |
"/ left := left + layout width. |
|
5703 |
"/ ]. |
|
5704 |
"/ left + width > devRight ifTrue:[ |
|
5705 |
"/ left := o x - width - 2 |
|
5706 |
"/ ]. |
|
5707 |
"/ ]. |
|
5708 |
||
1701 | 5709 |
left + width > devRight ifTrue:[ |
2219 | 5710 |
left := isVertical ifTrue:[left - layout width - width + 2] |
5711 |
ifFalse:[devRight - width] |
|
1701 | 5712 |
]. |
5713 |
left := left max:0. |
|
5714 |
||
5715 |
subMenu origin:(left@top). |
|
5716 |
||
5717 |
subMenu realized ifFalse:[ |
|
2219 | 5718 |
subMenu realize. |
1701 | 5719 |
] ifTrue:[ |
2219 | 5720 |
topMenu device mapWindow:(subMenu id). |
1701 | 5721 |
]. |
1790
98b89f8f4c17
do not select the first item if it represants a submenu
ca
parents:
1788
diff
changeset
|
5722 |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5723 |
menuPanel openMenuOnSelect ifFalse:[ |
2219 | 5724 |
( menuPanel superMenu notNil "/ not the top menu |
5725 |
or:[((item := subMenu itemAt:1) notNil and:[item hasSubmenu not])] "/ top menu but no submenu item |
|
5726 |
) ifTrue:[ |
|
5727 |
subMenu selectionIndex:1 |
|
5728 |
] |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5729 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5730 |
! |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5731 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5732 |
toggleSubmenuVisibility |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5733 |
"toggle the visibility of the submenu |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5734 |
" |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5735 |
subMenu notNil ifTrue:[ |
2219 | 5736 |
subMenu shown ifTrue:[^ self hideSubmenu] |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5737 |
] ifFalse:[ |
2219 | 5738 |
(subMenu := self setupSubmenu) isNil ifTrue:[ |
5739 |
"/ cannot open a submenu |
|
5740 |
^ self |
|
5741 |
] |
|
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5742 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5743 |
self openSubmenu. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5744 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5745 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5746 |
! |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5747 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5748 |
visibleSubmenu |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5749 |
"returns the current visible submenu or nil |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5750 |
" |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5751 |
subMenu notNil ifTrue:[ |
2219 | 5752 |
subMenu shown ifTrue:[^ subMenu]. |
1786
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5753 |
]. |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5754 |
^ nil |
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5755 |
|
f27f48940f48
change behaviour of cursor/key control and menu actication
ca
parents:
1785
diff
changeset
|
5756 |
|
1701 | 5757 |
|
5758 |
! ! |
|
5759 |
||
524 | 5760 |
!MenuPanel::Item methodsFor:'building'! |
5761 |
||
5762 |
aspectAt:aKey |
|
5763 |
"retursns value assigned to key or nil |
|
5764 |
" |
|
5765 |
|appl value| |
|
5766 |
||
5767 |
appl := menuPanel receiver. |
|
5768 |
||
1219
6a0d677a6fac
removed some #isKindOf: calls.
Claus Gittinger <cg@exept.de>
parents:
1218
diff
changeset
|
5769 |
(appl isValueModel) ifTrue:[ |
2219 | 5770 |
^ appl value:aKey |
524 | 5771 |
]. |
5772 |
||
2123 | 5773 |
appl isNil ifTrue:[ |
2219 | 5774 |
appl := menuPanel application. |
2123 | 5775 |
]. |
5776 |
appl isNil ifTrue:[ ^ nil]. |
|
5777 |
||
5778 |
MessageNotUnderstood handle:[:ex| |
|
2219 | 5779 |
ex selector == aKey ifFalse:[ |
5780 |
ex reject |
|
5781 |
]. |
|
5782 |
self ifNotInUIBuilderInfoPrintCR: |
|
5783 |
('MenuPanel::Item [info]: application does not provide aspect: ' , aKey). |
|
2123 | 5784 |
] do:[ |
2219 | 5785 |
aKey numArgs == 1 ifTrue:[ |
5786 |
value := appl perform:aKey with:(argument ? self). |
|
5787 |
] ifFalse:[ |
|
5788 |
(appl respondsTo:#aspectFor:) ifTrue:[ |
|
5789 |
value := appl aspectFor:aKey |
|
5790 |
] ifFalse:[ |
|
5791 |
value := appl perform:aKey |
|
5792 |
] |
|
5793 |
] |
|
524 | 5794 |
]. |
5795 |
^ value |
|
1029
c9e90585fa89
only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
5796 |
|
c9e90585fa89
only ignore messageNotUnderstood for my aspects.
Claus Gittinger <cg@exept.de>
parents:
1026
diff
changeset
|
5797 |
"Modified: / 29.7.1998 / 11:59:50 / cg" |
524 | 5798 |
! ! |
5799 |
||
390 | 5800 |
!MenuPanel::Item methodsFor:'change & update'! |
5801 |
||
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5802 |
update:something with:aParameter from:changedObject |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5803 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5804 |
|form rect| |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5805 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5806 |
(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
|
5807 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5808 |
self isSeparator ifFalse:[ |
2219 | 5809 |
"/ NOT A SEPARATOR |
5810 |
||
5811 |
menuPanel shown ifTrue:[ |
|
5812 |
changedObject == enableChannel ifTrue:[ |
|
5813 |
(enableChannel value == false and:[self isSelected]) ifTrue:[ |
|
5814 |
^ menuPanel selection:nil. |
|
5815 |
]. |
|
5816 |
^ self invalidate |
|
5817 |
]. |
|
5818 |
||
5819 |
(changedObject == indication or:[changedObject == choice]) ifTrue:[ |
|
5820 |
isButton ifTrue:[ |
|
5821 |
self invalidate |
|
5822 |
] ifFalse:[ |
|
5823 |
"/ invalidate the interactor only |
|
5824 |
"/ take any interactor; interactors has the same extent |
|
5825 |
form := menuPanel iconIndicationOff. |
|
5826 |
||
5827 |
rect := Rectangle left:(layout left + HorizontalInset) |
|
5828 |
top:(layout top) |
|
5829 |
width:(form width) |
|
5830 |
height:(layout height). |
|
5831 |
||
5832 |
menuPanel invalidate:rect repairNow:false |
|
5833 |
]. |
|
5834 |
^ self |
|
5835 |
]. |
|
5836 |
]. |
|
498 | 5837 |
]. |
712 | 5838 |
|
5839 |
changedObject == isVisible ifTrue:[ |
|
2219 | 5840 |
menuPanel mustRearrange. |
5841 |
menuPanel rearrangeItems. |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
5842 |
^ self. |
712 | 5843 |
]. |
5844 |
||
498 | 5845 |
super update:something with:aParameter from:changedObject |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5846 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5847 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5848 |
updateIndicators |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5849 |
"update indicators |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5850 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5851 |
(indication notNil and:[indication isSymbol]) ifTrue:[ |
2219 | 5852 |
" indication is a selector otherwise a change notification |
5853 |
is raised from the model !!!! |
|
5854 |
" |
|
5855 |
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
|
5856 |
] |
390 | 5857 |
! ! |
5858 |
||
388 | 5859 |
!MenuPanel::Item methodsFor:'converting'! |
5860 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5861 |
asMenuItem |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5862 |
"convert to a MenuItem |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5863 |
" |
466 | 5864 |
|item label rcv| |
5865 |
||
5866 |
label := self label. |
|
5867 |
item := MenuItem labeled:(label printString). |
|
5868 |
||
5869 |
label isImage ifTrue:[ |
|
2219 | 5870 |
rcv := ResourceRetriever new. |
5871 |
rcv className:#MenuEditor. |
|
5872 |
rcv selector:#iconUnknown. |
|
5873 |
item labelImage:rcv. |
|
464 | 5874 |
]. |
466 | 5875 |
|
434 | 5876 |
item activeHelpKey:activeHelpKey. |
460 | 5877 |
|
1819 | 5878 |
enableChannel isSymbol ifTrue:[ |
2219 | 5879 |
item enabled:enableChannel |
460 | 5880 |
]. |
1727 | 5881 |
item font:font. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5882 |
item accessCharacterPosition:accessCharacterPosition. |
1819 | 5883 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5884 |
item startGroup:startGroup. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5885 |
item argument:argument. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5886 |
item nameKey:nameKey. |
1609 | 5887 |
item shortcutKeyCharacter:shortcutKey. |
1819 | 5888 |
value isSymbol ifTrue:[item value:value]. |
5889 |
indication isSymbol ifTrue:[item indication:indication]. |
|
5890 |
choice isSymbol ifTrue:[item choice:choice]. |
|
5891 |
isVisible isSymbol ifTrue:[item isVisible:isVisible]. |
|
5892 |
||
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5893 |
item choiceValue:choiceValue. |
1819 | 5894 |
item hideMenuOnActivated:hideMenuOnActivated. |
5895 |
item keepLinkedMenu:keepLinkedMenu. |
|
5896 |
item showBusyCursorWhilePerforming:showBusyCursorWhilePerforming. |
|
1841 | 5897 |
item triggerOnDown:(self triggerOnDown). |
1045 | 5898 |
item isButton:isButton. |
388 | 5899 |
|
2100
fb4eb6025151
menuBuilder: support of horizontal/vertical layout of submenu
ca
parents:
2098
diff
changeset
|
5900 |
self hasSubmenu ifTrue:[ |
2219 | 5901 |
horizontalLayout == true ifTrue:[ |
5902 |
item horizontalLayout:true |
|
5903 |
]. |
|
5904 |
||
5905 |
submenuChannel isSymbol ifTrue:[ |
|
5906 |
item submenuChannel:submenuChannel |
|
5907 |
] ifFalse:[ |
|
5908 |
subMenu notNil ifTrue:[ |
|
5909 |
item submenu:(subMenu asMenu) |
|
5910 |
] |
|
5911 |
]. |
|
388 | 5912 |
]. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
5913 |
^ item |
388 | 5914 |
! |
5915 |
||
5916 |
menuItem:aMenuItem |
|
5917 |
"setup attributes from a MenuItem |
|
5918 |
" |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
5919 |
|lbl| |
389 | 5920 |
|
388 | 5921 |
menuPanel disabledRedrawDo:[ |
2219 | 5922 |
label := rawLabel := nil. |
5923 |
accessCharacterPosition := aMenuItem accessCharacterPosition. |
|
5924 |
argument := aMenuItem argument. |
|
5925 |
choiceValue := aMenuItem choiceValue. |
|
5926 |
showBusyCursorWhilePerforming := aMenuItem showBusyCursorWhilePerforming. |
|
5927 |
horizontalLayout := aMenuItem horizontalLayout. |
|
5928 |
triggerOnDown := aMenuItem triggerOnDown. |
|
5929 |
hideMenuOnActivated := aMenuItem hideMenuOnActivated. |
|
5930 |
keepLinkedMenu := aMenuItem keepLinkedMenu. |
|
5931 |
isButton := aMenuItem isButton ? false. |
|
5932 |
nameKey := aMenuItem nameKey. |
|
5933 |
startGroup := aMenuItem startGroup. |
|
5934 |
shortcutKey := aMenuItem shortcutKeyCharacter. |
|
5935 |
value := aMenuItem value. |
|
5936 |
activeHelpKey := aMenuItem activeHelpKey. |
|
5937 |
activeHelpText := nil. |
|
5938 |
||
5939 |
self font:(aMenuItem font). |
|
5940 |
||
5941 |
self enabled:(aMenuItem enabled). |
|
5942 |
self indication:(aMenuItem indication). |
|
5943 |
self choice:(aMenuItem choice). |
|
5944 |
self isVisible:(aMenuItem isVisible). |
|
5945 |
||
5946 |
(lbl := aMenuItem labelImage value) isNil ifTrue:[ |
|
5947 |
lbl := aMenuItem rawLabel. "/ avoid translating &'s twice |
|
5948 |
]. |
|
5949 |
||
5950 |
self label:lbl. |
|
5951 |
submenuChannel := aMenuItem submenuChannel. |
|
5952 |
self submenu:(aMenuItem submenu). |
|
388 | 5953 |
] |
1033
9badc22e3d03
oops &'s where eliminated twice - leading to double &'s
Claus Gittinger <cg@exept.de>
parents:
1032
diff
changeset
|
5954 |
|
1090
cf3d9f5648da
only draw with enteredLevel, if item is enabled
Claus Gittinger <cg@exept.de>
parents:
1083
diff
changeset
|
5955 |
"Modified: / 22.8.1998 / 15:34:16 / cg" |
388 | 5956 |
! ! |
5957 |
||
5958 |
!MenuPanel::Item methodsFor:'drawing'! |
|
5959 |
||
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5960 |
drawButton |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5961 |
"draw as button |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5962 |
" |
2159
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
5963 |
|drawObject fg etchFg level isEnabled isSelected isPressedToggle bg ownBgCol |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5964 |
x "{ Class:SmallInteger }" |
2143 | 5965 |
y "{ Class:SmallInteger }" |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5966 |
| |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5967 |
drawObject := rawLabel. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5968 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5969 |
"COMPUTE COLORS" |
2059 | 5970 |
isEnabled := self enabled. |
2159
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
5971 |
isSelected := self isSelected. |
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
5972 |
isPressedToggle := self isToggle and:[self indicationValue]. |
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
5973 |
(isSelected or:[isPressedToggle]) ifTrue:[ |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5974 |
bg := self activeBackgroundColor. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5975 |
fg := self activeForegroundColor. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5976 |
] ifFalse:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5977 |
self isEntered ifTrue:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5978 |
bg := self buttonEnteredBackgroundColor |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5979 |
] ifFalse:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5980 |
bg := self backgroundColor |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5981 |
]. |
2059 | 5982 |
isEnabled ifTrue:[ |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5983 |
fg := menuPanel foregroundColor |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5984 |
] ifFalse:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5985 |
fg := menuPanel disabledForegroundColor. |
2059 | 5986 |
etchFg := menuPanel disabledEtchedForegroundColor. |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5987 |
drawObject := self disabledRawLabel |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5988 |
] |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5989 |
]. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5990 |
|
1708
cfaf55b9043d
bug fix in background color of button when derives from label(text)
ca
parents:
1707
diff
changeset
|
5991 |
(ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[ |
cfaf55b9043d
bug fix in background color of button when derives from label(text)
ca
parents:
1707
diff
changeset
|
5992 |
bg := ownBgCol |
cfaf55b9043d
bug fix in background color of button when derives from label(text)
ca
parents:
1707
diff
changeset
|
5993 |
]. |
cfaf55b9043d
bug fix in background color of button when derives from label(text)
ca
parents:
1707
diff
changeset
|
5994 |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5995 |
"DRAW BACKGROUND" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5996 |
bg ~= menuPanel backgroundColor ifTrue:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5997 |
menuPanel paint:bg. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5998 |
menuPanel fillRectangle:layout. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
5999 |
]. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6000 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6001 |
x := layout left + menuPanel buttonPassiveLevel + HorizontalButtonInset. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6002 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6003 |
isSelected ifFalse:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6004 |
"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
|
6005 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6006 |
indication notNil ifTrue:[ |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6007 |
"button is indicator and set" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6008 |
isSelected := self indicationValue |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6009 |
] ifFalse:[ |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6010 |
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
|
6011 |
] |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6012 |
]. |
2143 | 6013 |
y := 0. |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6014 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6015 |
isSelected ifTrue:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6016 |
level := menuPanel buttonActiveLevel. |
2142 | 6017 |
x := x + 1 "level abs". |
2143 | 6018 |
y := y + 1 "level abs". |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6019 |
] ifFalse:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6020 |
level := self isEntered ifTrue:[menuPanel buttonEnteredLevel] |
2219 | 6021 |
ifFalse:[menuPanel buttonPassiveLevel]. |
2059 | 6022 |
]. |
6023 |
||
6024 |
etchFg notNil ifTrue:[ |
|
2143 | 6025 |
self drawRawLabel:drawObject atX:x+1 yOffset:y+1 paint:etchFg. |
6026 |
]. |
|
6027 |
self drawRawLabel:drawObject atX:x yOffset:y+0 paint:fg. |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6028 |
self drawDelayedMenuIndicator. |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6029 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6030 |
level ~~ 0 ifTrue:[ |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6031 |
menuPanel drawButtonEdgesFor:self level:level |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6032 |
]. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6033 |
! |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6034 |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6035 |
drawDelayedMenuIndicator |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6036 |
"draw a labeled entry; no button, no separator. |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6037 |
" |
2220 | 6038 |
|x y icon bAbsLevel| |
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6039 |
|
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6040 |
self hasDelayedMenuIndicator ifFalse:[ |
2220 | 6041 |
^ self |
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6042 |
]. |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6043 |
|
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6044 |
icon := self class delayedMenuIndicator. |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6045 |
x := layout right - icon width. |
2220 | 6046 |
false "/ delayedMenuIndicatorVerticalPosition == #center |
6047 |
ifTrue:[ |
|
6048 |
y := layout height - icon height // 2 + layout top. |
|
6049 |
] ifFalse:[ |
|
6050 |
y := layout bottom - icon height - 2. |
|
6051 |
]. |
|
6052 |
||
6053 |
bAbsLevel := 0. |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6054 |
isButton ifTrue:[ |
2220 | 6055 |
self isSelected ifTrue:[ |
6056 |
x := x + 1. |
|
6057 |
y := y + 1. |
|
6058 |
]. |
|
6059 |
bAbsLevel := menuPanel maxAbsoluteButtonLevel. |
|
6060 |
x := x - bAbsLevel. |
|
6061 |
y := y - bAbsLevel. |
|
6062 |
]. |
|
6063 |
x := x - 1 "- HorizontalInset". |
|
6064 |
||
6065 |
(self isEnabled "and:[self delayedMenuIsEnabled]") ifFalse:[ |
|
6066 |
icon := menuPanel lightenedImageOnDevice:icon |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6067 |
]. |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6068 |
icon displayOn:menuPanel x:x y:y. |
2220 | 6069 |
|
6070 |
("drawDelayedMenuIndicatorSeparator and:[" menuPanel buttonPassiveLevel ~~ 0 "]") |
|
6071 |
ifTrue:[ |
|
6072 |
menuPanel paint:menuPanel buttonShadowColor. |
|
6073 |
menuPanel displayLineFromX:x-2 y:layout top+bAbsLevel+1 toX:x-2 y:layout bottom-bAbsLevel-2. |
|
6074 |
menuPanel paint:menuPanel buttonLightColor. |
|
6075 |
menuPanel displayLineFromX:x-1 y:layout top+bAbsLevel+1 toX:x-1 y:layout bottom-bAbsLevel-2. |
|
6076 |
]. |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6077 |
! |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6078 |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6079 |
drawLabel |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6080 |
"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
|
6081 |
" |
2059 | 6082 |
|scKey cLb cLa drawObject fg etchFg arrow |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6083 |
isSelected isEnabled form |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6084 |
h "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6085 |
y "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6086 |
x "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6087 |
t "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6088 |
| |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6089 |
drawObject := rawLabel. |
1048 | 6090 |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6091 |
isEnabled := self enabled. |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6092 |
isSelected := self isSelected. |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6093 |
isSelected ifTrue:[ |
2219 | 6094 |
fg := self activeForegroundColor |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6095 |
] ifFalse:[ |
2219 | 6096 |
isEnabled ifTrue:[ |
6097 |
self isEntered ifTrue:[ |
|
6098 |
fg := menuPanel enteredForegroundColor |
|
6099 |
] ifFalse:[ |
|
6100 |
fg := menuPanel foregroundColor |
|
6101 |
] |
|
6102 |
] ifFalse:[ |
|
6103 |
fg := menuPanel disabledForegroundColor. |
|
6104 |
etchFg := menuPanel disabledEtchedForegroundColor. |
|
6105 |
drawObject := self disabledRawLabel |
|
6106 |
] |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6107 |
]. |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6108 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6109 |
h := layout height. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6110 |
x := layout left + HorizontalInset. |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6111 |
t := layout top. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6112 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6113 |
((form := self indicatorForm) notNil or:[(form := self choiceForm) notNil]) ifTrue:[ |
2219 | 6114 |
y := t + ((h - form height) // 2). |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6115 |
|
2219 | 6116 |
form displayOn:menuPanel x:x y:y. |
6117 |
x := x + 2 + form width. |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6118 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6119 |
|
2059 | 6120 |
etchFg notNil ifTrue:[ |
2219 | 6121 |
self drawRawLabel:drawObject atX:x+1 yOffset:1 paint:etchFg. |
2059 | 6122 |
]. |
6123 |
self drawRawLabel:drawObject atX:x yOffset:0 paint:fg. |
|
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6124 |
self drawDelayedMenuIndicator. |
1046 | 6125 |
|
608 | 6126 |
"/ DRAW SHORTCUT KEY |
6127 |
||
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6128 |
( shortcutKey notNil |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6129 |
and:[(x := menuPanel shortKeyInset) ~~ 0 |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6130 |
and:[(scKey:= self shortcutKeyAsString) notNil]] |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6131 |
) ifTrue:[ |
2219 | 6132 |
x := layout left + x. |
6133 |
y := t + ((h - (scKey heightOn:menuPanel)) // 2). |
|
6134 |
y := y + menuPanel font ascent. |
|
6135 |
scKey displayOn:menuPanel x:x y:y. |
|
608 | 6136 |
]. |
963
2660033bc16e
hide shortKeys in menu (may be later enabled via a classVar)
Claus Gittinger <cg@exept.de>
parents:
911
diff
changeset
|
6137 |
|
608 | 6138 |
"/ DRAW SUBMENU INDICATION |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6139 |
|
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
6140 |
(menuPanel isVerticalLayout and:[self hasSubmenu]) ifTrue:[ |
2219 | 6141 |
arrow := menuPanel rightArrow. |
6142 |
x := layout right - arrow width - HorizontalInset. |
|
6143 |
y := t + (h - arrow height // 2). |
|
6144 |
||
6145 |
(menuPanel styleSheet is3D not |
|
6146 |
or:[(drawObject := menuPanel rightArrowShadow) isNil]) ifTrue:[ |
|
6147 |
^ menuPanel displayForm:arrow x:x y:y |
|
6148 |
]. |
|
6149 |
cLa := menuPanel shadowColor. |
|
6150 |
cLb := menuPanel lightColor. |
|
6151 |
||
6152 |
isSelected ifFalse:[ |
|
6153 |
fg := cLa. |
|
6154 |
cLa := cLb. |
|
6155 |
cLb := fg |
|
6156 |
]. |
|
6157 |
menuPanel paint:cLa. |
|
6158 |
menuPanel displayForm:arrow x:x y:y. |
|
6159 |
menuPanel paint:cLb. |
|
6160 |
menuPanel displayForm:drawObject x:x y:y. |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6161 |
] |
746 | 6162 |
|
1124 | 6163 |
"Modified: / 6.9.1998 / 21:48:53 / cg" |
388 | 6164 |
! |
6165 |
||
2059 | 6166 |
drawRawLabel:aLabel atX:x yOffset:yOffset paint:fg |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6167 |
"draw a labeled entry; no button, no separator. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6168 |
" |
2059 | 6169 |
|mfont fontAscent |
1727 | 6170 |
y "{ Class:SmallInteger }" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6171 |
y0 "{ Class:SmallInteger }" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6172 |
x0 "{ Class:SmallInteger }" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6173 |
| |
2059 | 6174 |
|
1727 | 6175 |
mfont := menuPanel setFont:font. |
2059 | 6176 |
fontAscent := menuPanel font ascent. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6177 |
menuPanel paint:fg. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6178 |
|
2059 | 6179 |
y := layout top + (layout height - rawLabelExtent y // 2) + yOffset. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6180 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6181 |
aLabel isArray ifFalse:[ |
2219 | 6182 |
aLabel isImageOrForm ifFalse:[ |
6183 |
y := y + fontAscent. |
|
6184 |
]. |
|
6185 |
aLabel displayOn:menuPanel x:x y:y. |
|
1727 | 6186 |
] ifTrue:[ |
2219 | 6187 |
aLabel do:[:el| |
6188 |
el notNil ifTrue:[ |
|
6189 |
el isImageOrForm ifFalse:[ |
|
6190 |
y0 := y + fontAscent |
|
6191 |
] ifTrue:[ |
|
6192 |
y0 := y |
|
6193 |
]. |
|
6194 |
x0 := x + (rawLabelExtent x - (el widthOn:menuPanel) // 2). |
|
6195 |
el displayOn:menuPanel x:x0 y:y0. |
|
6196 |
y := y + 1 + (el heightOn:menuPanel) |
|
6197 |
] ifFalse:[ |
|
6198 |
y := y + 3 "/ see #label: |
|
6199 |
] |
|
6200 |
]. |
|
1727 | 6201 |
]. |
6202 |
menuPanel setFont:mfont |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6203 |
! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6204 |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6205 |
drawSeparatingLines |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6206 |
"draw separating lines |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6207 |
" |
2059 | 6208 |
|myIndex lfSep rtSep items prevItem nextItem |
6209 |
lightColor shadowColor |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6210 |
l "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6211 |
t "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6212 |
r "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6213 |
b "{ Class:SmallInteger }" |
706 | 6214 |
| |
2059 | 6215 |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6216 |
items := menuPanel items. |
2059 | 6217 |
myIndex := items identityIndexOf:self. |
6218 |
||
6219 |
prevItem := items at:(myIndex - 1) ifAbsent:nil. |
|
6220 |
lfSep := prevItem notNil and:[prevItem isButton not]. |
|
6221 |
||
6222 |
nextItem := items at:(myIndex + 1) ifAbsent:nil. |
|
6223 |
rtSep := nextItem notNil and:[nextItem isButton not]. |
|
6224 |
||
6225 |
(lfSep or:[rtSep]) ifFalse:[ |
|
2219 | 6226 |
^ self |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6227 |
]. |
2059 | 6228 |
|
6229 |
lightColor := menuPanel lightColor. |
|
6230 |
shadowColor := menuPanel shadowColor. |
|
6231 |
||
6232 |
menuPanel paint:lightColor. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6233 |
|
608 | 6234 |
l := layout left. |
6235 |
t := layout top. |
|
6236 |
r := layout right. |
|
6237 |
b := layout bottom. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6238 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6239 |
menuPanel verticalLayout ifTrue:[ |
2219 | 6240 |
lfSep ifTrue:[menuPanel displayLineFromX:l y:t-1 toX:r y:t-1]. |
6241 |
rtSep ifTrue:[menuPanel displayLineFromX:l y:b-1 toX:r y:b-1]. |
|
6242 |
||
6243 |
menuPanel paint:shadowColor. |
|
6244 |
lfSep ifTrue:[menuPanel displayLineFromX:l y:t-2 toX:r y:t-2]. |
|
6245 |
rtSep ifTrue:[menuPanel displayLineFromX:l y:b-2 toX:r y:b-2]. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6246 |
] ifFalse:[ |
2219 | 6247 |
lfSep ifTrue:[menuPanel displayLineFromX:l-1 y:t toX:l-1 y:b]. |
6248 |
rtSep ifTrue:[menuPanel displayLineFromX:r-1 y:t toX:r-1 y:b]. |
|
6249 |
||
6250 |
menuPanel paint:shadowColor. |
|
6251 |
lfSep ifTrue:[menuPanel displayLineFromX:l-2 y:t toX:l-2 y:b]. |
|
6252 |
rtSep ifTrue:[menuPanel displayLineFromX:r-2 y:t toX:r-2 y:b]. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6253 |
] |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6254 |
! |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6255 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6256 |
drawSeparator |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6257 |
"draw as separator |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6258 |
" |
2059 | 6259 |
|type lightColor shadowColor isDouble |
6260 |
left top |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6261 |
x0 "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6262 |
x1 "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6263 |
y0 "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6264 |
y1 "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6265 |
| |
2059 | 6266 |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6267 |
type := self separatorType. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6268 |
(type isNil or:[type == #blankLine]) ifTrue:[ |
2219 | 6269 |
^ self |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6270 |
]. |
2059 | 6271 |
|
6272 |
isDouble := type == #doubleLine. |
|
6273 |
||
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6274 |
lightColor := menuPanel lightColor. |
2059 | 6275 |
shadowColor := menuPanel shadowColor. |
6276 |
menuPanel paint:shadowColor. |
|
6277 |
||
6278 |
left := layout left. |
|
6279 |
top := layout top. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6280 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6281 |
menuPanel verticalLayout ifTrue:[ |
2219 | 6282 |
x0 := left + HorizontalInset. |
6283 |
x1 := layout right - HorizontalInset. |
|
6284 |
y0 := top - 1 + (layout height // 2). |
|
6285 |
isDouble ifTrue:[y0 := y0 - 2]. |
|
6286 |
||
6287 |
menuPanel displayLineFromX:x0 y:y0 toX:x1 y:y0. |
|
6288 |
isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+4 toX:x1 y:y0+4]. |
|
6289 |
||
6290 |
menuPanel paint:lightColor. |
|
6291 |
menuPanel displayLineFromX:x0 y:y0+1 toX:x1 y:y0+1. |
|
6292 |
isDouble ifTrue:[menuPanel displayLineFromX:x0 y:y0+5 toX:x1 y:y0+5]. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6293 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6294 |
] ifFalse:[ |
2219 | 6295 |
y1 := layout bottom. |
6296 |
x0 := left - 1 + (layout width // 2). |
|
6297 |
y0 := top. |
|
6298 |
isDouble ifTrue:[x0 := x0 - 2]. |
|
6299 |
||
6300 |
menuPanel displayLineFromX:x0 y:y0 toX:x0 y:y1. |
|
6301 |
isDouble ifTrue:[menuPanel displayLineFromX:x0+4 y:y0 toX:x0+4 y:y1]. |
|
6302 |
||
6303 |
menuPanel paint:lightColor. |
|
6304 |
menuPanel displayLineFromX:x0+1 y:y0 toX:x0+1 y:y1. |
|
6305 |
isDouble ifTrue:[menuPanel displayLineFromX:x0+5 y:y0 toX:x0+5 y:y1]. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6306 |
] |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6307 |
! |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6308 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6309 |
invalidate |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6310 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6311 |
(rawLabel notNil and:[menuPanel notNil]) ifTrue:[ |
2219 | 6312 |
menuPanel invalidateItem:self repairNow:false |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6313 |
] |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6314 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6315 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6316 |
! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6317 |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6318 |
redraw |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6319 |
"redraw item |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6320 |
" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6321 |
|isSelected ownBgCol paint bgColor |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6322 |
x "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6323 |
y "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6324 |
w "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6325 |
h "{ Class:SmallInteger }" |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6326 |
| |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6327 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6328 |
self isVisible ifFalse:[^ self]. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6329 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6330 |
rawLabel isNil ifTrue:[^ self drawSeparator]. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6331 |
isButton ifTrue:[^ self drawButton]. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6332 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6333 |
"/ 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
|
6334 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6335 |
isSelected := self isSelected. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6336 |
bgColor := menuPanel backgroundColor. |
2170 | 6337 |
paint := isSelected |
2219 | 6338 |
ifTrue:[self activeBackgroundColor] |
6339 |
ifFalse:[ |
|
6340 |
(self isEnabled and:[ self isEntered ]) ifTrue:[ |
|
6341 |
menuPanel enteredBackgroundColor |
|
6342 |
] ifFalse:[ |
|
6343 |
bgColor |
|
6344 |
]]. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6345 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6346 |
(ownBgCol := self backgroundColorFromLabel) notNil ifTrue:[ |
2219 | 6347 |
paint := ownBgCol |
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6348 |
]. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6349 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6350 |
paint ~= bgColor ifTrue:[ |
2219 | 6351 |
menuPanel paint:paint. |
6352 |
menuPanel fillRectangle:layout. |
|
1707
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6353 |
]. |
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6354 |
|
4354f516e937
add some comment to methods; split draw routines for buttons labels ..
ca
parents:
1705
diff
changeset
|
6355 |
menuPanel showSeparatingLines ifTrue:[ |
2219 | 6356 |
self drawSeparatingLines |
608 | 6357 |
]. |
6358 |
||
650 | 6359 |
self drawLabel. |
6360 |
||
1045 | 6361 |
(ownBgCol notNil and:[isSelected]) ifTrue:[ |
2219 | 6362 |
ownBgCol brightness > 0.5 ifTrue:[menuPanel paint: menuPanel selectionFrameDarkColor] |
6363 |
ifFalse:[menuPanel paint: menuPanel selectionFrameBrightColor]. |
|
6364 |
||
6365 |
x := layout left. |
|
6366 |
y := layout top. |
|
6367 |
w := layout width. |
|
6368 |
h := layout height. |
|
6369 |
||
6370 |
menuPanel displayRectangleX:(x + 1) y:(y + 1) width:(w - 2) height:(h - 2). |
|
6371 |
menuPanel displayRectangleX:(x + 2) y:(y + 2) width:(w - 4) height:(h - 4). |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
6372 |
]. |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
6373 |
menuPanel drawLabelEdgeFor:self selected:isSelected. |
388 | 6374 |
! ! |
6375 |
||
6376 |
!MenuPanel::Item methodsFor:'initialization'! |
|
6377 |
||
6378 |
destroy |
|
616 | 6379 |
"destroy submenus, remove dependencies |
388 | 6380 |
" |
616 | 6381 |
self submenu:nil. |
6382 |
||
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6383 |
enableChannel isValueModel ifTrue:[enableChannel removeDependent:self]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6384 |
isVisible isValueModel ifTrue:[isVisible removeDependent:self]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6385 |
indication isValueModel ifTrue:[indication removeDependent:self]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6386 |
choice isValueModel ifTrue:[choice removeDependent:self]. |
616 | 6387 |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6388 |
menuPanel := nil. |
616 | 6389 |
! |
6390 |
||
794 | 6391 |
in:aPanel |
6392 |
"create item in a menuPanel |
|
6393 |
" |
|
6394 |
menuPanel := aPanel. |
|
1045 | 6395 |
isButton := false. |
1811 | 6396 |
! |
6397 |
||
6398 |
reinitStyle |
|
6399 |
||
6400 |
subMenu notNil ifTrue:[ |
|
2219 | 6401 |
subMenu reinitStyle |
1811 | 6402 |
]. |
6403 |
||
6404 |
"Created: / 17.8.2000 / 17:57:07 / cg" |
|
6405 |
"Modified: / 17.8.2000 / 18:00:08 / cg" |
|
794 | 6406 |
! ! |
6407 |
||
6408 |
!MenuPanel::Item methodsFor:'label basics'! |
|
6409 |
||
6410 |
disabledRawLabel |
|
6411 |
"returns the label used if the item is disabled |
|
6412 |
" |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6413 |
|block form image| |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6414 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6415 |
disabledRawLabel notNil ifTrue:[^ disabledRawLabel]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6416 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6417 |
disabledRawLabel := rawLabel ? ''. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6418 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6419 |
disabledRawLabel isString ifTrue:[ |
2219 | 6420 |
^ disabledRawLabel |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6421 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6422 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6423 |
block := [:el| |rslt| |
2219 | 6424 |
(rslt := el) notNil ifTrue:[ |
6425 |
el isImageOrForm ifTrue:[ |
|
6426 |
el colorMap notNil ifTrue:[ |
|
6427 |
rslt := menuPanel lightenedImageOnDevice:el |
|
6428 |
] |
|
6429 |
] ifFalse:[ |
|
6430 |
el class == LabelAndIcon ifTrue:[ |
|
6431 |
((form := el icon) notNil and:[form colorMap notNil]) ifTrue:[ |
|
6432 |
form := menuPanel lightenedImageOnDevice:form |
|
6433 |
]. |
|
6434 |
((image := el image) notNil and:[image colorMap notNil]) ifTrue:[ |
|
6435 |
image := menuPanel lightenedImageOnDevice:image |
|
6436 |
]. |
|
6437 |
rslt := LabelAndIcon form:form image:image string:(el string). |
|
6438 |
] |
|
6439 |
] |
|
6440 |
]. |
|
6441 |
rslt |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6442 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6443 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6444 |
rawLabel isArray ifTrue:[ |
2219 | 6445 |
disabledRawLabel := Array new:(rawLabel size). |
6446 |
||
6447 |
rawLabel keysAndValuesDo:[:anIndex :aLabel| |
|
6448 |
disabledRawLabel at:anIndex put:(block value:aLabel) |
|
6449 |
] |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6450 |
] ifFalse:[ |
2219 | 6451 |
disabledRawLabel := block value:rawLabel |
794 | 6452 |
]. |
6453 |
^ disabledRawLabel |
|
6454 |
! |
|
6455 |
||
1829 | 6456 |
fetchDeviceResources |
6457 |
disabledRawLabel := nil. |
|
6458 |
self fetchImages. |
|
6459 |
||
6460 |
font notNil ifTrue:[ |
|
2219 | 6461 |
font := font onDevice:(menuPanel device) |
1829 | 6462 |
]. |
6463 |
! |
|
6464 |
||
616 | 6465 |
fetchImages |
6466 |
"fetch images |
|
6467 |
" |
|
2118
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6468 |
|icon| |
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6469 |
|
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6470 |
(rawLabel isNil or:[rawLabel isString]) ifTrue:[ |
2219 | 6471 |
^ self |
2118
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6472 |
]. |
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6473 |
rawLabel isImageOrForm ifTrue:[ |
2219 | 6474 |
rawLabel := menuPanel imageOnDevice:rawLabel. |
2118
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6475 |
^ self. |
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6476 |
]. |
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6477 |
|
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6478 |
rawLabel class == LabelAndIcon ifTrue:[ |
2219 | 6479 |
(icon := rawLabel image) notNil ifTrue:[ |
6480 |
rawLabel image:(menuPanel imageOnDevice:icon) |
|
6481 |
]. |
|
6482 |
(icon := rawLabel icon) notNil ifTrue:[ |
|
6483 |
rawLabel icon:(menuPanel imageOnDevice:icon) |
|
6484 |
]. |
|
6485 |
^ self |
|
2118
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6486 |
]. |
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6487 |
|
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6488 |
rawLabel isArray ifFalse:[^ self]. |
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6489 |
|
89d02ebc5b65
optimize #labels: and #fetchImages in Item. discard block
ca
parents:
2113
diff
changeset
|
6490 |
rawLabel keysAndValuesDo:[:i :el| |
2219 | 6491 |
(el notNil and:[el isString not]) ifTrue:[ |
6492 |
el isImageOrForm ifTrue:[ |
|
6493 |
rawLabel at:i put:(menuPanel imageOnDevice:el). |
|
6494 |
] ifFalse:[ |
|
6495 |
el class == LabelAndIcon ifTrue:[ |
|
6496 |
(icon := el image) notNil ifTrue:[ |
|
6497 |
el image:(menuPanel imageOnDevice:icon) |
|
6498 |
]. |
|
6499 |
(icon := el icon) notNil ifTrue:[ |
|
6500 |
el icon:(menuPanel imageOnDevice:icon) |
|
6501 |
] |
|
6502 |
] |
|
6503 |
] |
|
6504 |
] |
|
1078 | 6505 |
]. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6506 |
! |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6507 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6508 |
updateAccessCharacterFor:aLabel |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6509 |
|s i rest label pos| |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6510 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6511 |
(accessCharacter notNil or:[aLabel isNil]) ifTrue:[ |
2219 | 6512 |
^ aLabel |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6513 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6514 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6515 |
aLabel isString ifFalse:[ |
2219 | 6516 |
aLabel class == LabelAndIcon ifTrue:[ |
6517 |
aLabel string:(self updateAccessCharacterFor:(aLabel string)) |
|
6518 |
]. |
|
6519 |
^ aLabel |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6520 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6521 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6522 |
s := aLabel size. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6523 |
i := 1. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6524 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6525 |
label := aLabel. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6526 |
pos := accessCharacterPosition. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6527 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6528 |
[((i := label indexOf:$& startingAt:i) ~~ 0 and:[i < s])] whileTrue:[ |
2219 | 6529 |
rest := label copyFrom:(i+1). |
6530 |
||
6531 |
i == 1 ifTrue:[label := rest] |
|
6532 |
ifFalse:[label := (label copyFrom:1 to:(i-1)), rest]. |
|
6533 |
||
6534 |
(label at:i) == $& ifTrue:[i := i + 1] ifFalse:[pos := i]. |
|
6535 |
s := s - 1. |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6536 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6537 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6538 |
(pos isNil or:[(accessCharacter := label at:pos ifAbsent:nil) isNil]) ifTrue:[ |
2219 | 6539 |
^ label |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6540 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6541 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6542 |
label isText ifFalse:[ |
2219 | 6543 |
label := Text string:label |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6544 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6545 |
label emphasisAt:pos add:#underline. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6546 |
^ label |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6547 |
|
388 | 6548 |
! ! |
6549 |
||
1573 | 6550 |
!MenuPanel::Item methodsFor:'printing & storing'! |
6551 |
||
6552 |
displayString |
|
1690
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
6553 |
^ self class name, '[', label printString, ']' |
38b23fb1a931
add DefaultEnteredLevel and DefaultSelectionFollowsMouse
ca
parents:
1688
diff
changeset
|
6554 |
|
1573 | 6555 |
! ! |
6556 |
||
388 | 6557 |
!MenuPanel::Item methodsFor:'private'! |
6558 |
||
650 | 6559 |
activeBackgroundColor |
6560 |
"returns the active background color derived from menuPanel |
|
6561 |
" |
|
6562 |
||
1045 | 6563 |
isButton ifTrue: [^menuPanel buttonActiveBackgroundColor]. |
650 | 6564 |
^menuPanel activeBackgroundColor |
6565 |
! |
|
6566 |
||
6567 |
activeForegroundColor |
|
6568 |
"returns the active foreground color derived from menuPanel |
|
6569 |
" |
|
6570 |
||
6571 |
^menuPanel activeForegroundColor |
|
6572 |
! |
|
6573 |
||
727 | 6574 |
backgroundColor |
6575 |
"returns the background color derived from menuPanel |
|
6576 |
" |
|
6577 |
||
1045 | 6578 |
isButton ifTrue: [^menuPanel buttonPassiveBackgroundColor]. |
727 | 6579 |
^menuPanel backgroundColor |
6580 |
! |
|
6581 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6582 |
backgroundColorFromLabel |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6583 |
"returns the background color derived from label or nil |
388 | 6584 |
" |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6585 |
|run| |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6586 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6587 |
label isText ifFalse:[^ nil ]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6588 |
run := label emphasis. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6589 |
run size == 0 ifTrue:[^ nil ]. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6590 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6591 |
run := run first. |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6592 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6593 |
run size == 0 ifTrue:[ |
2145 | 6594 |
(run value isColor and:[run key == #backgroundColor]) ifTrue:[ |
6595 |
^ run value |
|
6596 |
] |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6597 |
] ifFalse:[ |
2145 | 6598 |
run do:[:r| |
6599 |
(r value isColor and:[r key == #backgroundColor]) ifTrue:[ |
|
6600 |
^ r value |
|
6601 |
] |
|
6602 |
] |
|
388 | 6603 |
]. |
6604 |
^ nil |
|
6605 |
! |
|
6606 |
||
1081
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6607 |
buttonEnteredBackgroundColor |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6608 |
"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
|
6609 |
derived from menuPanel |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6610 |
" |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6611 |
|
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6612 |
isButton ifTrue: [^ menuPanel buttonEnteredBackgroundColor]. |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6613 |
^ menuPanel backgroundColor |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6614 |
|
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6615 |
"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
|
6616 |
! |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6617 |
|
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
6618 |
choiceForm |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
6619 |
"returns choice form or nil |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
6620 |
" |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6621 |
|isOn| |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6622 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6623 |
choice isNil ifTrue:[^ nil]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6624 |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6625 |
isOn := choice value = choiceValue. |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6626 |
self enabled ifFalse:[ |
2219 | 6627 |
^ isOn ifTrue:[menuPanel iconRadioGroupDisabledOn] |
6628 |
ifFalse:[menuPanel iconRadioGroupDisabledOff] |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6629 |
]. |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6630 |
^ isOn ifTrue:[menuPanel iconRadioGroupOn] |
2219 | 6631 |
ifFalse:[menuPanel iconRadioGroupOff] |
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
6632 |
! |
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
6633 |
|
663 | 6634 |
findSubMenuIn:aRecv |
1051
a448c854fcbb
catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
6635 |
"ask the receiver for a submenu aspect, sending it |
a448c854fcbb
catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
6636 |
#aspectFor: first; then trying the selector itself. |
a448c854fcbb
catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
6637 |
Ignore the error if that message is not understood |
a448c854fcbb
catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
6638 |
(but not other message-not-understoods)" |
a448c854fcbb
catch messageNotUnderstood for #aspectFor:
Claus Gittinger <cg@exept.de>
parents:
1048
diff
changeset
|
6639 |
|
2069
7891c7d3af69
use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents:
2064
diff
changeset
|
6640 |
|subm sel numArgs| |
1795
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
6641 |
|
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
6642 |
aRecv isNil ifTrue:[^ nil]. |
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
6643 |
|
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
6644 |
sel := submenuChannel asSymbol. |
2069
7891c7d3af69
use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents:
2064
diff
changeset
|
6645 |
numArgs := sel numArgs. |
7891c7d3af69
use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents:
2064
diff
changeset
|
6646 |
|
7891c7d3af69
use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents:
2064
diff
changeset
|
6647 |
numArgs == 0 ifTrue:[ |
2219 | 6648 |
MessageNotUnderstood handle:[:ex | |
6649 |
|selector| |
|
6650 |
||
6651 |
((selector := ex message selector) == sel |
|
6652 |
or:[selector == #aspectFor:]) ifFalse:[ |
|
6653 |
ex reject |
|
6654 |
]. |
|
6655 |
] do:[ |
|
6656 |
subm := aRecv aspectFor:sel. |
|
6657 |
]. |
|
6658 |
subm notNil ifTrue:[^ subm]. |
|
1795
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
6659 |
]. |
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
6660 |
|
2043 | 6661 |
(Array with:(aRecv) with:(aRecv class)) |
6662 |
do:[:aPossibleReceiver | |
|
2219 | 6663 |
MessageNotUnderstood handle:[:ex| |
6664 |
ex message selector == sel ifFalse:[ ex reject ] |
|
6665 |
] do:[ |
|
6666 |
numArgs == 0 ifTrue:[ |
|
6667 |
subm := aPossibleReceiver perform:sel |
|
6668 |
] ifFalse:[ |
|
6669 |
numArgs == 1 ifTrue:[ |
|
6670 |
subm := aPossibleReceiver perform:sel with:(argument ? menuPanel) |
|
6671 |
] ifFalse:[ |
|
6672 |
subm := aPossibleReceiver perform:sel with:argument with:menuPanel |
|
6673 |
] |
|
6674 |
] |
|
6675 |
]. |
|
6676 |
subm notNil ifTrue:[^ subm]. |
|
1795
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
6677 |
]. |
6afd0e768267
submenuChannel selector: allow upto two arguments, the arg and the menu
ca
parents:
1793
diff
changeset
|
6678 |
|
663 | 6679 |
^ subm |
2043 | 6680 |
|
6681 |
"Modified: / 30.10.2001 / 13:28:25 / cg" |
|
663 | 6682 |
! |
6683 |
||
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6684 |
indicationValue |
524 | 6685 |
"returns indication value or nil in case of no indication |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6686 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6687 |
|numArgs sel recv| |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6688 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6689 |
indication isNil ifTrue:[^ nil]. "no indication specified" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6690 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6691 |
indication isSymbol ifFalse:[ |
2219 | 6692 |
^ indication value == true "block or model" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6693 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6694 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6695 |
(numArgs := indication numArgs) == 2 ifTrue:[ |
2219 | 6696 |
recv := menuPanel receiver. |
6697 |
||
6698 |
(recv isValueModel) ifFalse:[ |
|
6699 |
(recv notNil or:[(recv := menuPanel application) notNil]) ifTrue:[ |
|
6700 |
sel := indication copyFrom:1 to:(indication indexOf:$:). |
|
6701 |
sel := sel asSymbol. |
|
6702 |
||
6703 |
MessageNotUnderstood handle:[:ex| |
|
6704 |
ex message selector == sel ifFalse:[ |
|
6705 |
ex reject |
|
6706 |
]. |
|
6707 |
] do:[ |
|
6708 |
sel := recv perform:sel with:argument |
|
6709 |
] |
|
6710 |
]. |
|
6711 |
]. |
|
6712 |
^ sel value == true |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6713 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6714 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6715 |
numArgs ~~ 0 ifTrue:[ |
2219 | 6716 |
sel := (indication copyWithoutLast:1) asSymbol |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6717 |
] ifFalse:[ |
2219 | 6718 |
sel := indication |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6719 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6720 |
sel := self aspectAt:sel. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6721 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6722 |
sel isValueModel ifTrue:[ |
2219 | 6723 |
indication := sel. |
6724 |
indication addDependent:self. |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6725 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6726 |
^ sel value == true |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6727 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6728 |
|
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6729 |
indicationValue:aValue |
1218 | 6730 |
"set the indication value |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6731 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6732 |
|numArgs recv| |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6733 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6734 |
indication isNil ifTrue:[^ self]. "no indication specified" |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6735 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6736 |
indication isSymbol ifFalse:[ |
2219 | 6737 |
indication perform:#value: with:aValue ifNotUnderstood:nil. "block or model" |
6738 |
^ self |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6739 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6740 |
|
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6741 |
(numArgs := indication numArgs) == 0 ifTrue:[ "no arguments to selector; cannot set" |
2219 | 6742 |
^ self |
1218 | 6743 |
]. |
6744 |
||
524 | 6745 |
recv := menuPanel receiver. |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6746 |
recv isValueModel ifTrue:[^ self]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6747 |
|
1218 | 6748 |
recv isNil ifTrue:[ |
2219 | 6749 |
recv := menuPanel application. |
6750 |
recv isNil ifTrue:[^ self]. |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6751 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6752 |
|
2069
7891c7d3af69
use new #perform:withOptionalArgument:
Claus Gittinger <cg@exept.de>
parents:
2064
diff
changeset
|
6753 |
MessageNotUnderstood handle:[:ex| |
2219 | 6754 |
(ex message selector ~~ indication) ifTrue:[ |
6755 |
ex reject |
|
6756 |
]. |
|
6757 |
self ifNotInUIBuilderInfoPrintCR: |
|
6758 |
('MenuPanel::Item [info]: application does not respond to ' , indication). |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6759 |
] do:[ |
2219 | 6760 |
numArgs == 1 ifTrue:[ |
6761 |
recv perform:indication with:aValue |
|
6762 |
] ifFalse:[ |
|
6763 |
recv perform:indication with:(argument ? self) with:aValue |
|
6764 |
] |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6765 |
]. |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6766 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6767 |
|
1074
25e3910947de
added choice type menu items (i.e. radioButton behavior)
Claus Gittinger <cg@exept.de>
parents:
1068
diff
changeset
|
6768 |
indicatorForm |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6769 |
"returns indication form or nil |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6770 |
" |
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6771 |
|val| |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6772 |
|
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6773 |
indication isNil ifTrue:[^ nil]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6774 |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6775 |
val := self indicationValue. |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6776 |
self enabled ifFalse:[ |
2219 | 6777 |
^ val == true |
6778 |
ifTrue:[menuPanel iconIndicationDisabledOn] |
|
6779 |
ifFalse:[menuPanel iconIndicationDisabledOff] |
|
1798
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6780 |
]. |
08ae92e6fdf3
extra disabled icons for checkBoxes and radioButtons
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
6781 |
^ val == true |
2219 | 6782 |
ifTrue:[menuPanel iconIndicationOn] |
6783 |
ifFalse:[menuPanel iconIndicationOff] |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6784 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6785 |
|
1081
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6786 |
isEntered |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6787 |
"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
|
6788 |
" |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6789 |
^ menuPanel enteredItem == self |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6790 |
|
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6791 |
"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
|
6792 |
! |
fd67c198eeea
added enter/leave processing for enteredLevel/enteredBG processing.
Claus Gittinger <cg@exept.de>
parents:
1080
diff
changeset
|
6793 |
|
464 | 6794 |
separatorType |
6795 |
"returns type of separator line or nil |
|
388 | 6796 |
" |
390 | 6797 |
|c lbl| |
388 | 6798 |
|
6799 |
rawLabel isNil ifFalse:[ |
|
2145 | 6800 |
^ nil |
388 | 6801 |
]. |
6802 |
||
390 | 6803 |
(lbl := label value) isNil ifTrue:[ |
2145 | 6804 |
^ #singleLine |
388 | 6805 |
]. |
6806 |
||
390 | 6807 |
lbl size == 1 ifTrue:[ |
2145 | 6808 |
c := lbl first. |
6809 |
c == $- ifTrue:[^ #singleLine]. |
|
6810 |
c == $= ifTrue:[^ #doubleLine]. |
|
388 | 6811 |
]. |
6812 |
^ #blankLine |
|
1130 | 6813 |
! |
6814 |
||
6815 |
setupSubmenu |
|
6816 |
|appl recv subm| |
|
6817 |
||
6818 |
submenuChannel notNil ifTrue:[ |
|
2219 | 6819 |
submenuChannel isSymbol ifFalse:[ |
6820 |
subm := submenuChannel |
|
6821 |
] ifTrue:[ |
|
6822 |
appl := menuPanel application. |
|
6823 |
||
6824 |
(subm := self findSubMenuIn:appl) isNil ifTrue:[ |
|
6825 |
(recv := menuPanel receiver) ~~ appl ifTrue:[ |
|
6826 |
subm := self findSubMenuIn:recv |
|
6827 |
] |
|
6828 |
] |
|
6829 |
]. |
|
6830 |
||
6831 |
(subm := subm value) isArray ifTrue:[ |
|
6832 |
subm := Menu new fromLiteralArrayEncoding:subm. |
|
6833 |
"/ cg: linked menus also may contain translations ... |
|
6834 |
subm notNil ifTrue:[ |
|
6835 |
appl notNil ifTrue:[ |
|
6836 |
subm findGuiResourcesIn:appl. |
|
6837 |
] |
|
6838 |
]. |
|
6839 |
]. |
|
6840 |
self submenu:subm. |
|
1130 | 6841 |
]. |
6842 |
||
6843 |
^ subMenu |
|
6844 |
||
6845 |
"Modified: / 19.5.1998 / 19:36:56 / cg" |
|
388 | 6846 |
! ! |
6847 |
||
6848 |
!MenuPanel::Item methodsFor:'queries'! |
|
6849 |
||
1217
c6a4c536aa8c
care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
6850 |
canChangeVisibility |
1699 | 6851 |
"return true if I am not always visible; can only be changed by a selector |
6852 |
otherwise there is a change notification raised if the model changed |
|
6853 |
" |
|
6854 |
^ isVisible isSymbol |
|
6855 |
"/ ^ isVisible notNil and:[isVisible ~~ true] |
|
1217
c6a4c536aa8c
care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
6856 |
! |
c6a4c536aa8c
care for items which change visibility via
Claus Gittinger <cg@exept.de>
parents:
1212
diff
changeset
|
6857 |
|
388 | 6858 |
canSelect |
1699 | 6859 |
"returns true if item is selectable; no separator, visible and enabled. |
6860 |
in case of a choice (RadioButton) i have to check for the choiceValue |
|
388 | 6861 |
" |
1699 | 6862 |
(rawLabel notNil and:[self isVisible and:[self enabled]]) ifTrue:[ |
2219 | 6863 |
(choice isNil or:[choice value ~= choiceValue]) ifTrue:[ |
6864 |
^ true |
|
6865 |
]. |
|
1078 | 6866 |
]. |
6867 |
^ false |
|
388 | 6868 |
! |
6869 |
||
2046 | 6870 |
containsPoint:aPoint |
6871 |
"returns true if aPoint is contained in my layout |
|
6872 |
" |
|
6873 |
(self isVisible and:[layout notNil]) ifTrue:[ |
|
2219 | 6874 |
^ layout containsPoint:aPoint |
2046 | 6875 |
]. |
6876 |
^ false |
|
6877 |
||
6878 |
"Created: / 13.11.2001 / 13:55:31 / cg" |
|
6879 |
! |
|
6880 |
||
388 | 6881 |
containsPointX:x y:y |
6882 |
"returns true if point is contained in my layout |
|
6883 |
" |
|
712 | 6884 |
(self isVisible and:[layout notNil]) ifTrue:[ |
2219 | 6885 |
^ layout containsPointX:x y:y |
505 | 6886 |
]. |
6887 |
^ false |
|
388 | 6888 |
! |
6889 |
||
2199 | 6890 |
hasDelayedMenu |
6891 |
"returns true if a delayed menu exists |
|
6892 |
" |
|
6893 |
(subMenu isNil and:[submenuChannel isNil]) ifTrue:[ |
|
2219 | 6894 |
^ false |
2199 | 6895 |
]. |
6896 |
(value isNil and:[indication isNil and:[choice isNil]]) ifTrue:[ |
|
2219 | 6897 |
^ false |
2199 | 6898 |
]. |
6899 |
^ true |
|
6900 |
! |
|
6901 |
||
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6902 |
hasDelayedMenuIndicator |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6903 |
"returns true if the item has a delayed menu |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6904 |
and is the topMenu |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6905 |
" |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6906 |
menuPanel isPopUpView ifFalse:[ |
2219 | 6907 |
^ self hasDelayedMenu |
2214
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6908 |
]. |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6909 |
^ false |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6910 |
! |
8eefad87cf62
drawing delayed menu indicators... first try not yet finished
ca
parents:
2199
diff
changeset
|
6911 |
|
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6912 |
hasIndication |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6913 |
"returns true if on/off indication exists |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6914 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
6915 |
^ indication notNil |
407
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6916 |
! |
40554a07d5aa
fix bugs; implement indication; text with backgroundColor
ca
parents:
399
diff
changeset
|
6917 |
|
388 | 6918 |
hasSubmenu |
1473
1f62652f146e
use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents:
1472
diff
changeset
|
6919 |
"returns true if the item is configured as an subMenu entry |
388 | 6920 |
" |
1472
fd1871a0d888
call hasSubmenu insteat of submenu
Claus Gittinger <cg@exept.de>
parents:
1464
diff
changeset
|
6921 |
^ subMenu notNil or:[submenuChannel notNil] |
388 | 6922 |
! |
6923 |
||
6924 |
isEnabled |
|
6925 |
"returns enabled state |
|
6926 |
" |
|
6927 |
^ self enabled |
|
6928 |
! |
|
6929 |
||
1723
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
6930 |
isLabeledItem |
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
6931 |
"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
|
6932 |
" |
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
6933 |
^ rawLabel notNil and:[isButton not] |
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
6934 |
! |
f633725a0ace
use itemSpace only for horizontal menus and between labeled items
ca
parents:
1719
diff
changeset
|
6935 |
|
608 | 6936 |
isSeparator |
6937 |
"returns true if item is a separator |
|
6938 |
" |
|
6939 |
^ rawLabel isNil |
|
6940 |
! |
|
6941 |
||
2159
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
6942 |
isToggle |
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
6943 |
"returns true if on/off indication exists |
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
6944 |
" |
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
6945 |
^ self hasIndication and:[ self isButton ] |
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
6946 |
! |
1eac041aeb3d
toggle button draw & behavior
Claus Gittinger <cg@exept.de>
parents:
2145
diff
changeset
|
6947 |
|
712 | 6948 |
isVisible |
6949 |
"returns the visibility state |
|
6950 |
" |
|
6951 |
|state| |
|
6952 |
||
6953 |
isVisible isSymbol ifTrue:[ |
|
2219 | 6954 |
state := self aspectAt:isVisible. |
6955 |
||
6956 |
state isValueModel ifTrue:[ |
|
6957 |
isVisible := state. |
|
6958 |
isVisible addDependent:self. |
|
6959 |
state := isVisible. |
|
6960 |
] |
|
712 | 6961 |
] ifFalse:[ |
2219 | 6962 |
state := isVisible |
1164
e6e9633abf48
kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
6963 |
]. |
e6e9633abf48
kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
6964 |
^ state value ~~ false |
e6e9633abf48
kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
6965 |
|
e6e9633abf48
kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
6966 |
"Modified: / 5.10.1998 / 12:08:28 / cg" |
712 | 6967 |
! |
6968 |
||
6969 |
isVisible:something |
|
6970 |
"change the state; if the state changed, a redraw is performed |
|
6971 |
" |
|
6972 |
|oldState newState| |
|
6973 |
||
6974 |
isVisible isNil ifTrue:[ |
|
2219 | 6975 |
oldState := true |
712 | 6976 |
] ifFalse:[ |
2219 | 6977 |
oldState := isVisible value. |
6978 |
isVisible isValueModel ifTrue:[ |
|
6979 |
isVisible removeDependent:self |
|
6980 |
] |
|
712 | 6981 |
]. |
6982 |
isVisible := something. |
|
6983 |
||
6984 |
isVisible isNil ifTrue:[ |
|
2219 | 6985 |
newState := true |
712 | 6986 |
] ifFalse:[ |
2219 | 6987 |
isVisible isValueModel ifTrue:[ |
6988 |
isVisible addDependent:self |
|
6989 |
] ifFalse:[ |
|
6990 |
isVisible isSymbol ifTrue:[^ self] |
|
6991 |
]. |
|
6992 |
menuPanel shown ifFalse:[^ self]. |
|
6993 |
newState := isVisible value. |
|
712 | 6994 |
]. |
6995 |
||
6996 |
newState ~~ oldState ifTrue:[ |
|
2219 | 6997 |
menuPanel mustRearrange |
712 | 6998 |
] |
1164
e6e9633abf48
kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
6999 |
|
e6e9633abf48
kludge fix: invoke mustRearrange to care for block-visibility attributes
Claus Gittinger <cg@exept.de>
parents:
1156
diff
changeset
|
7000 |
"Modified: / 5.10.1998 / 12:12:04 / cg" |
712 | 7001 |
! |
7002 |
||
388 | 7003 |
shortcutKeyAsString |
7004 |
"converts shortcutKey to a text object |
|
7005 |
" |
|
1609 | 7006 |
|nm prefix| |
7007 |
||
7008 |
shortcutKey isNil ifTrue:[ |
|
2219 | 7009 |
^ nil |
1609 | 7010 |
]. |
7011 |
||
7012 |
shortcutKey isCharacter ifTrue:[ |
|
2219 | 7013 |
nm := shortcutKey asString |
388 | 7014 |
] ifFalse:[ |
2219 | 7015 |
"/ this is somewhat complicated: we have the symbolic key at hand, |
7016 |
"/ but want to show the untranslated (inverse keyBoardMapped) key & modifier |
|
7017 |
"/ Ask the devices keyboardMap for the backtranslation. |
|
7018 |
||
7019 |
nm := menuPanel device keyboardMap keyAtValue:shortcutKey ifAbsent:shortcutKey. |
|
7020 |
"/ |
|
7021 |
"/ some modifier-key combination ? |
|
7022 |
"/ |
|
7023 |
(nm startsWith:#Cmd) ifTrue:[ |
|
7024 |
prefix := #Cmd. |
|
7025 |
] ifFalse:[(nm startsWith:#Alt) ifTrue:[ |
|
7026 |
prefix := #Alt. |
|
7027 |
] ifFalse:[(nm startsWith:#Meta) ifTrue:[ |
|
7028 |
prefix := #Meta. |
|
7029 |
] ifFalse:[(nm startsWith:#Ctrl) ifTrue:[ |
|
7030 |
prefix := #Ctrl. |
|
7031 |
]]]]. |
|
7032 |
prefix notNil ifTrue:[ |
|
7033 |
nm := (self shortcutKeyPrefixFor:prefix), (nm copyFrom:(prefix size + 1)) |
|
7034 |
] ifFalse:[ |
|
7035 |
nm := nm asString |
|
7036 |
] |
|
388 | 7037 |
]. |
608 | 7038 |
^ nm |
388 | 7039 |
|
987 | 7040 |
"Modified: / 17.7.1998 / 11:56:40 / cg" |
388 | 7041 |
! |
7042 |
||
7043 |
shortcutKeyPrefixFor:aModifier |
|
7044 |
"returns prefix assigned to a modifier |
|
7045 |
" |
|
7046 |
|m| |
|
7047 |
||
7048 |
m := menuPanel device modifierKeyTopFor:aModifier. |
|
7049 |
m notNil ifTrue:[ |
|
2145 | 7050 |
^ m , '-' |
388 | 7051 |
]. |
987 | 7052 |
^ aModifier , '-'. |
7053 |
||
7054 |
"Modified: / 17.7.1998 / 11:56:46 / cg" |
|
388 | 7055 |
! ! |
7056 |
||
7057 |
!MenuPanel::Item methodsFor:'selection'! |
|
7058 |
||
7059 |
isSelected |
|
7060 |
"returns true if item is selected |
|
7061 |
" |
|
1998 | 7062 |
|
7063 |
^ menuPanel notNil and:[menuPanel selection == self] |
|
388 | 7064 |
! |
7065 |
||
1701 | 7066 |
selected:isSelected |
1473
1f62652f146e
use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents:
1472
diff
changeset
|
7067 |
"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
|
7068 |
submenu and perform a redraw |
1f62652f146e
use hasSubmenu insteat of submenu if possible;
Claus Gittinger <cg@exept.de>
parents:
1472
diff
changeset
|
7069 |
" |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
7070 |
menuPanel isNil ifTrue:[ |
2219 | 7071 |
^ self hideSubmenu |
1726
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
7072 |
]. |
a4733a8b51e1
support labeled arrays; printing vertical (font not yet supported)
ca
parents:
1723
diff
changeset
|
7073 |
|
1701 | 7074 |
isSelected ifFalse:[ |
2219 | 7075 |
self invalidate. |
2199 | 7076 |
^ self hideSubmenu. |
7077 |
]. |
|
7078 |
menuPanel realized ifFalse:[ ^ self ]. |
|
7079 |
||
7080 |
(indication isNil or:[isButton not]) ifTrue:[ |
|
2219 | 7081 |
self invalidate |
2199 | 7082 |
]. |
7083 |
self hasSubmenu ifFalse:[ ^ self]. |
|
7084 |
||
7085 |
(menuPanel isPopUpView not or:[menuPanel openMenuOnSelect]) ifFalse:[ |
|
2219 | 7086 |
^ self |
2199 | 7087 |
]. |
7088 |
self hasDelayedMenu ifTrue:[ |
|
2219 | 7089 |
menuPanel openDelayed:self |
2199 | 7090 |
] ifFalse:[ |
2219 | 7091 |
subMenu := self setupSubmenu. |
7092 |
subMenu ifNotNil:[ self openSubmenu ]. |
|
1701 | 7093 |
]. |
388 | 7094 |
! ! |
7095 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
7096 |
!MenuPanel::ScrollActivity class methodsFor:'default icons'! |
2016 | 7097 |
|
2018 | 7098 |
icon |
2016 | 7099 |
"This resource specification was automatically generated |
7100 |
by the ImageEditor of ST/X." |
|
7101 |
||
7102 |
"Do not manually edit this!! If it is corrupted, |
|
7103 |
the ImageEditor may not be able to read the specification." |
|
7104 |
||
7105 |
" |
|
2018 | 7106 |
self icon inspect |
7107 |
ImageEditor openOnClass:self andSelector:#icon |
|
2016 | 7108 |
" |
7109 |
||
7110 |
<resource: #image> |
|
7111 |
||
7112 |
^Icon |
|
2219 | 7113 |
constantNamed:#'MenuPanel::Scrolling class icon' |
7114 |
ifAbsentPut:[(Depth1Image new) width: 11; height: 11; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'?>@@@@@@ @C@@N@@<@C8@O<@@@@@@@@a') ; colorMapFromArray:#[0 0 0 255 255 255]; mask:((Depth1Image new) width: 11; height: 11; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@_<@? A<@C @D@@@@@@@@@@@a') ; yourself); yourself] |
|
2016 | 7115 |
! ! |
7116 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
7117 |
!MenuPanel::ScrollActivity class methodsFor:'instance creation'! |
2016 | 7118 |
|
7119 |
new |
|
7120 |
^ self basicNew initialize |
|
7121 |
! ! |
|
7122 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
7123 |
!MenuPanel::ScrollActivity methodsFor:'accessing'! |
2016 | 7124 |
|
7125 |
activeMenu |
|
7126 |
"returns the active menu the scrolling is activated on; nil |
|
7127 |
is returned if scrolling is deactivated |
|
7128 |
" |
|
7129 |
^ activeMenu |
|
7130 |
! |
|
7131 |
||
7132 |
direction |
|
7133 |
"returns the scroll-direction |
|
7134 |
" |
|
7135 |
^ direction |
|
7136 |
! |
|
7137 |
||
7138 |
iconAt:aDirection on:aMenu |
|
2018 | 7139 |
|icon device index| |
2016 | 7140 |
|
7141 |
device := aMenu device. |
|
7142 |
||
7143 |
aDirection == #PREV ifTrue:[ |
|
2219 | 7144 |
aMenu verticalLayout ifTrue:[index := 3] "/ 3 - 1 * 90 180 |
7145 |
ifFalse:[index := 2] "/ 2 - 1 * 90 90 |
|
2018 | 7146 |
] ifFalse:[ |
2219 | 7147 |
aMenu verticalLayout ifTrue:[index := 1] "/ 1 - 1 * 90 0 |
7148 |
ifFalse:[index := 4] "/ 4 - 1 * 90 270 |
|
2018 | 7149 |
]. |
7150 |
||
7151 |
icon := icons at:index. |
|
7152 |
||
7153 |
(icon isNil or:[icon device ~~ device]) ifTrue:[ |
|
2219 | 7154 |
icon := self class icon. |
7155 |
index > 1 ifTrue:[ icon := icon rotated:(index - 1 * 90) ] |
|
7156 |
ifFalse:[ icon := icon copy ]. |
|
7157 |
||
7158 |
icon := icon onDevice:device. |
|
7159 |
icon clearMaskedPixels. |
|
7160 |
icons at:index put:icon |
|
2018 | 7161 |
]. |
7162 |
^ icon |
|
2016 | 7163 |
! ! |
7164 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
7165 |
!MenuPanel::ScrollActivity methodsFor:'initialization'! |
2016 | 7166 |
|
7167 |
initialize |
|
7168 |
||
7169 |
semaLock := RecursionLock new. |
|
2018 | 7170 |
icons := Array new:4. |
2016 | 7171 |
! ! |
7172 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
7173 |
!MenuPanel::ScrollActivity methodsFor:'queries'! |
2016 | 7174 |
|
7175 |
isActive |
|
7176 |
"returns true if scrolling is activated |
|
7177 |
" |
|
7178 |
^ activeMenu notNil |
|
7179 |
! ! |
|
7180 |
||
2137
0aaeeab0811d
renamed Scrolling to ScrollActivity.
Claus Gittinger <cg@exept.de>
parents:
2133
diff
changeset
|
7181 |
!MenuPanel::ScrollActivity methodsFor:'user operations'! |
2016 | 7182 |
|
2047
62de65e3a61b
initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents:
2046
diff
changeset
|
7183 |
startIfRequiredAt:aDirection on:aMenu |
2016 | 7184 |
"start scrolling; returns true if scrolling is activated |
7185 |
" |
|
7186 |
|bounds index| |
|
7187 |
||
7188 |
semaLock critical:[ |
|
2219 | 7189 |
self stop. |
7190 |
||
7191 |
( aDirection notNil |
|
7192 |
and:[aMenu notNil |
|
7193 |
and:[(bounds := aMenu scrollerBoundsAt:aDirection) notNil]] |
|
7194 |
) ifTrue:[ |
|
7195 |
activeMenu := aMenu. |
|
7196 |
direction := aDirection. |
|
7197 |
||
7198 |
index := aMenu indexOfItemAtScroller:aDirection. |
|
7199 |
||
7200 |
index ~~ 0 ifTrue:[ |
|
7201 |
scrollTask := |
|
7202 |
[ |
|
7203 |
|item step| |
|
7204 |
||
7205 |
[ |
|
7206 |
step := (aDirection == #PREV) ifTrue:[-1] ifFalse:[1]. |
|
7207 |
( aMenu shown and:[(item := aMenu itemAt:index) notNil] ) ifTrue:[ |
|
7208 |
aMenu makeItemVisible:item. |
|
7209 |
index := index + step. |
|
7210 |
]. |
|
7211 |
||
7212 |
Delay waitForSeconds:(ButtonController defaultInitialDelay). |
|
7213 |
||
7214 |
[ aMenu shown and:[(item := aMenu itemAt:index) notNil] ] whileTrue:[ |
|
7215 |
aMenu makeItemVisible:item. |
|
7216 |
Delay waitForSeconds:(ButtonController defaultRepeatDelay). |
|
7217 |
index := index + step. |
|
7218 |
]. |
|
7219 |
item := nil. |
|
7220 |
] ensure:[ |
|
7221 |
scrollTask := nil. |
|
7222 |
||
7223 |
item notNil ifTrue:[ |
|
7224 |
"/ process was killed |
|
7225 |
aMenu invalidate:bounds |
|
7226 |
] |
|
7227 |
] |
|
7228 |
] forkAt:8. |
|
7229 |
] |
|
7230 |
] |
|
2016 | 7231 |
]. |
7232 |
^ bounds notNil |
|
2047
62de65e3a61b
initial delay; autoRepeat delay
Claus Gittinger <cg@exept.de>
parents:
2046
diff
changeset
|
7233 |
|
2048 | 7234 |
"Created: ca" |
7235 |
||
7236 |
"Modified: / 13.11.2001 / 20:15:52 / cg" |
|
2016 | 7237 |
! |
7238 |
||
7239 |
stop |
|
7240 |
"stop scrolling; returns true if the scrolling was activated otherwise false |
|
7241 |
" |
|
7242 |
|task resp| |
|
7243 |
||
7244 |
activeMenu isNil ifTrue:[ |
|
2219 | 7245 |
^ false |
2016 | 7246 |
]. |
7247 |
semaLock critical:[ |
|
2219 | 7248 |
resp := activeMenu notNil. |
7249 |
||
7250 |
(task := scrollTask) notNil ifTrue:[ |
|
7251 |
scrollTask := nil. |
|
7252 |
||
7253 |
Error handle:[:ex| |
|
7254 |
] do:[ |
|
7255 |
task terminateWithAllSubprocesses. |
|
7256 |
task waitUntilTerminated. |
|
7257 |
]. |
|
7258 |
]. |
|
7259 |
activeMenu := direction := nil. |
|
2016 | 7260 |
]. |
7261 |
^ resp |
|
7262 |
! ! |
|
7263 |
||
388 | 7264 |
!MenuPanel class methodsFor:'documentation'! |
7265 |
||
7266 |
version |
|
2220 | 7267 |
^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.328 2002-09-26 07:38:41 cg Exp $' |
388 | 7268 |
! ! |
2199 | 7269 |
|
388 | 7270 |
MenuPanel initialize! |