author | Claus Gittinger <cg@exept.de> |
Mon, 28 Sep 2009 11:25:25 +0200 | |
changeset 2751 | d0729d604864 |
parent 2584 | 5b5c3dda9a4b |
child 2764 | c83f22018324 |
permissions | -rw-r--r-- |
1354 | 1 |
" |
2 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
3 |
All Rights Reserved |
|
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 |
" |
|
1367 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
451 | 14 |
Object subclass:#Menu |
579 | 15 |
instanceVariableNames:'items groupSizes receiver' |
451 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Support' |
|
19 |
! |
|
20 |
||
21 |
!Menu class methodsFor:'documentation'! |
|
22 |
||
1354 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1997 by eXept Software AG |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
||
36 |
||
37 |
! |
|
38 |
||
451 | 39 |
documentation |
40 |
" |
|
41 |
not yet finished Menu class - this will eventually replace |
|
42 |
most of the MenuView and PopUpMenu stuff. |
|
43 |
(and hopefully be ST-80 compatible ...) |
|
44 |
||
45 |
For now, only a subset of the full protocol is implemented. |
|
46 |
||
47 |
[author:] |
|
740 | 48 |
Claus Gittinger |
451 | 49 |
|
50 |
[see also:] |
|
740 | 51 |
MenuItem |
52 |
PopUpMenu |
|
451 | 53 |
" |
54 |
! ! |
|
55 |
||
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
56 |
!Menu class methodsFor:'instance creation'! |
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
57 |
|
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
58 |
labelArray:arrayOfString lines:linesArray values:valueArrayOrNil |
737 | 59 |
"return a menu with menu items built with labels from arrayOfString (not Symbols). |
60 |
The linesArray describes which menu items are the last menu item in their group. |
|
61 |
The valueArray contains value objects for each menu item |
|
62 |
(or is nil if no value objects are specified)." |
|
63 |
||
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
64 |
|nLabel valueArray menuItems groupLengths| |
737 | 65 |
|
66 |
nLabel := arrayOfString size. |
|
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
67 |
|
737 | 68 |
valueArrayOrNil isNil ifTrue:[ |
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
69 |
(valueArray := arrayOfString isEmpty) ifTrue: [ |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
70 |
valueArray := #() |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
71 |
] ifFalse:[ |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
72 |
valueArray := (1 to:nLabel) |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
73 |
] |
737 | 74 |
] ifFalse:[ |
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
75 |
valueArray := valueArrayOrNil |
737 | 76 |
]. |
77 |
||
78 |
nLabel ~~ valueArray size ifTrue: [ |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
79 |
^ self error: 'illegal menu combination' |
737 | 80 |
]. |
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
81 |
|
737 | 82 |
menuItems := Array new:nLabel. |
83 |
1 to:nLabel do:[:i | |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
84 |
|mi v| |
737 | 85 |
|
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
86 |
mi := MenuItem labeled:(arrayOfString at:i) asString. |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
87 |
v := valueArray at:i. |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
88 |
(v isKindOf:Menu) ifTrue:[mi submenu:v]. |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
89 |
menuItems at:i put:mi |
737 | 90 |
]. |
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
91 |
|
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
92 |
(linesArray size == 0) ifTrue:[ |
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
93 |
groupLengths := (menuItems isEmpty) |
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
94 |
ifTrue: [Array new:0] |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
95 |
ifFalse: [Array with:menuItems size] |
737 | 96 |
] ifFalse:[ |
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
97 |
groupLengths := Array new:(linesArray size + 1). |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
98 |
groupLengths at:1 put:linesArray first. |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
99 |
2 to:linesArray size do: [:i | |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
100 |
groupLengths at:i put:((linesArray at:i) - (linesArray at:i - 1)) |
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
101 |
]. |
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
102 |
groupLengths at:groupLengths size put:(menuItems size - linesArray last). |
737 | 103 |
]. |
104 |
||
105 |
^ self new |
|
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
106 |
menuItems:menuItems |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
107 |
menuItemGroups:groupLengths |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
108 |
values:valueArray |
737 | 109 |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
110 |
"Modified: / 19.4.1998 / 11:30:18 / cg" |
696 | 111 |
! |
112 |
||
1174
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
113 |
labelArray:arrayOfString values:valueArrayOrNil |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
114 |
"return a menu with menu items built with labels from arrayOfString (not Symbols). |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
115 |
The valueArray contains value objects for each menu item |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
116 |
(or is nil if no value objects are specified)." |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
117 |
|
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
118 |
^ self |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
119 |
labelArray:arrayOfString |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
120 |
lines:nil |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
121 |
values: valueArrayOrNil |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
122 |
|
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
123 |
! |
f58d5c8cee82
added #labelArray:values: (ST80 compatibility)
Claus Gittinger <cg@exept.de>
parents:
1116
diff
changeset
|
124 |
|
696 | 125 |
labelList:arrayOfGroupStrings values:valueArrayOrNil |
126 |
|labels lines| |
|
127 |
||
128 |
lines := arrayOfGroupStrings collect:[:each | each size]. |
|
2017 | 129 |
labels := arrayOfGroupStrings collectAll:[:eachGroup | eachGroup]. |
696 | 130 |
^ self labelArray:labels lines:lines values:valueArrayOrNil |
131 |
||
132 |
"Modified: 20.6.1997 / 10:46:45 / cg" |
|
133 |
"Created: 13.9.1997 / 10:35:46 / cg" |
|
737 | 134 |
! |
135 |
||
738 | 136 |
labels:aString lines:linesArray values:valueArrayOrNil |
737 | 137 |
^ self |
740 | 138 |
labelArray:(aString asCollectionOfLines) |
139 |
lines:linesArray |
|
140 |
values:valueArrayOrNil |
|
737 | 141 |
|
142 |
"Created: / 31.10.1997 / 03:12:20 / cg" |
|
738 | 143 |
"Modified: / 31.10.1997 / 03:23:42 / cg" |
1525 | 144 |
! |
145 |
||
146 |
labels:aString values:valueArrayOrNil |
|
147 |
^ self |
|
148 |
labelArray:(aString asCollectionOfLines) |
|
149 |
lines:#() |
|
150 |
values:valueArrayOrNil |
|
151 |
||
152 |
"Modified: / 31.10.1997 / 03:23:42 / cg" |
|
153 |
"Created: / 12.11.2001 / 16:06:36 / cg" |
|
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
154 |
! ! |
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
155 |
|
1764 | 156 |
!Menu methodsFor:'Compatibility-ST80'! |
724 | 157 |
|
2126 | 158 |
addLine |
159 |
self addSeparator |
|
160 |
! |
|
161 |
||
724 | 162 |
indexOfMenuItem:anItem |
2433 | 163 |
^ items indexOf:anItem |
724 | 164 |
|
2433 | 165 |
"Created: / 27.10.1997 / 16:34:19 / cg" |
166 |
! |
|
167 |
||
168 |
indexOfMenuItemForWhich:aBlock |
|
169 |
^ items findFirst:aBlock |
|
724 | 170 |
|
171 |
"Created: / 27.10.1997 / 16:34:19 / cg" |
|
172 |
! |
|
173 |
||
174 |
menuButtons |
|
175 |
"ST-80 seems to use a special menuButton class here. |
|
176 |
Here, kludge a collection of menuItems." |
|
177 |
||
178 |
^ items |
|
179 |
||
180 |
"Created: / 27.10.1997 / 16:33:35 / cg" |
|
181 |
! ! |
|
182 |
||
1782 | 183 |
!Menu methodsFor:'Compatibility-Squeak'! |
184 |
||
185 |
labels:labels lines:lines selections:selections |
|
186 |
|labelArray| |
|
187 |
||
188 |
labels isString ifTrue:[ |
|
189 |
labelArray := labels asCollectionOfLines. |
|
190 |
] ifFalse:[ |
|
191 |
labelArray := labels. |
|
192 |
]. |
|
193 |
||
194 |
1 to:labelArray size do:[:idx | |
|
195 |
|item| |
|
196 |
||
197 |
item := MenuItem new. |
|
198 |
item label:(labelArray at:idx). |
|
199 |
item value:(selections at:idx). |
|
200 |
self addItem:item. |
|
201 |
||
202 |
(lines includes:idx) ifTrue:[ |
|
203 |
self addSeparator. |
|
204 |
]. |
|
205 |
]. |
|
206 |
! ! |
|
207 |
||
451 | 208 |
!Menu methodsFor:'accessing'! |
209 |
||
696 | 210 |
atNameKey:aNameKey |
724 | 211 |
"return the menuItem for the given nameKey; nil if no such item is in the menu. |
212 |
Searches in allItems (i.e. also in subMenus)" |
|
696 | 213 |
|
724 | 214 |
self allItemsDo:[:anItem| |
740 | 215 |
anItem nameKey == aNameKey ifTrue:[^ anItem] |
724 | 216 |
]. |
696 | 217 |
^ nil |
218 |
||
724 | 219 |
"Modified: / 27.10.1997 / 15:12:00 / cg" |
696 | 220 |
! |
221 |
||
578 | 222 |
groupSizes |
1500 | 223 |
^ groupSizes |
224 |
! |
|
578 | 225 |
|
226 |
groupSizes:something |
|
1500 | 227 |
groupSizes := something. |
228 |
! |
|
578 | 229 |
|
1986 | 230 |
items |
231 |
^ items |
|
232 |
! |
|
233 |
||
584 | 234 |
labelAt:anIndex |
235 |
"gets the label of the menu item at the given index or nil |
|
236 |
" |
|
237 |
|item| |
|
238 |
||
239 |
(item := self menuItemAt:anIndex) notNil ifTrue:[ |
|
801 | 240 |
^ item label |
584 | 241 |
]. |
801 | 242 |
^ nil |
584 | 243 |
|
801 | 244 |
"Modified: / 2.2.1998 / 13:28:32 / cg" |
584 | 245 |
! |
246 |
||
247 |
labelAtValue:aValue |
|
248 |
"gets the label of the menu item assigned to value |
|
249 |
" |
|
250 |
|item| |
|
251 |
||
801 | 252 |
item := self menuAndSubmenusDetectItem:[:anItem | anItem value == aValue ]. |
584 | 253 |
|
254 |
item notNil ifTrue:[ |
|
801 | 255 |
^ item label |
584 | 256 |
]. |
801 | 257 |
^ nil |
584 | 258 |
|
801 | 259 |
"Modified: / 2.2.1998 / 13:28:28 / cg" |
584 | 260 |
! |
261 |
||
451 | 262 |
labels |
263 |
"return a collection of labels from my items" |
|
264 |
||
977
e07277070839
return valid collection in #labels.
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
265 |
items isNil ifTrue:[^ #()]. |
451 | 266 |
^ items collect:[:anItem | anItem label] |
267 |
||
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
268 |
"Created: / 25.2.1997 / 19:47:53 / cg" |
977
e07277070839
return valid collection in #labels.
Claus Gittinger <cg@exept.de>
parents:
972
diff
changeset
|
269 |
"Modified: / 19.6.1998 / 02:36:22 / cg" |
451 | 270 |
! |
271 |
||
940 | 272 |
lastItem |
2584 | 273 |
"returns the last item or nil, if there are none" |
274 |
||
275 |
^ items isEmptyOrNil |
|
276 |
ifTrue:[nil] |
|
277 |
ifFalse:[items last] |
|
940 | 278 |
! |
279 |
||
489 | 280 |
lines |
737 | 281 |
"return the indexes of the menu items that are the last menu item in their group (except the very last)." |
489 | 282 |
|
801 | 283 |
|lines groupSz| |
737 | 284 |
|
801 | 285 |
(groupSz := groupSizes size) <= 1 ifTrue: [^ Array new]. |
286 |
lines := Array new:(groupSz - 1). |
|
287 |
lines at:1 put:groupSizes first. |
|
288 |
2 to:(groupSz-1) do:[:i | |
|
289 |
lines at:i put:(lines at:(i - 1)) + (groupSizes at:i) |
|
290 |
]. |
|
291 |
^ lines |
|
489 | 292 |
|
801 | 293 |
"Modified: / 2.2.1998 / 13:28:19 / cg" |
489 | 294 |
! |
295 |
||
296 |
menuItemAt:index |
|
584 | 297 |
"gets the menu item at the given index. When the index is out of bounds |
298 |
nil is returned |
|
299 |
" |
|
300 |
(index > 0 and:[index <= items size]) ifTrue:[ |
|
740 | 301 |
^ items at:index |
584 | 302 |
]. |
303 |
^ nil |
|
489 | 304 |
! |
305 |
||
724 | 306 |
menuItemLabeled:anItemLabel |
307 |
"return the menuItem for the given nameKey; nil if no such item is in the menu. |
|
308 |
Searches all items (i.e. also submenu items)" |
|
309 |
||
310 |
self allItemsDo:[:anItem| |
|
740 | 311 |
|l| |
724 | 312 |
|
740 | 313 |
((l := anItem label) sameAs: anItemLabel) ifTrue:[ |
314 |
^ anItem |
|
315 |
]. |
|
316 |
(l includes:$&) ifTrue:[ |
|
317 |
((l copyWithout:$&) sameAs: anItemLabel) ifTrue:[ |
|
318 |
^ anItem |
|
319 |
] |
|
320 |
] |
|
321 |
]. |
|
724 | 322 |
^ nil |
323 |
||
324 |
"Created: / 13.9.1997 / 10:25:16 / cg" |
|
325 |
"Modified: / 27.10.1997 / 15:23:33 / cg" |
|
326 |
! |
|
327 |
||
1652 | 328 |
menuItemWithValue:aValue |
329 |
"return the menuItem for the given value; nil if no such item is in the menu. |
|
330 |
Searches all items (i.e. also submenu items)" |
|
331 |
||
332 |
self allItemsDo:[:anItem| |
|
333 |
|l| |
|
334 |
||
335 |
(anItem value == aValue) ifTrue:[ |
|
336 |
^ anItem |
|
337 |
]. |
|
338 |
]. |
|
339 |
^ nil |
|
340 |
||
341 |
"Created: / 13.9.1997 / 10:25:16 / cg" |
|
342 |
"Modified: / 27.10.1997 / 15:23:33 / cg" |
|
343 |
! |
|
344 |
||
489 | 345 |
menuItems |
1327
b0b482a84570
menuItems always returns a collection (never nil)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
346 |
^ items ? #() |
489 | 347 |
! |
348 |
||
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
349 |
menuItems:aCollectionOfMenuItems menuItemGroups:sizes values:values |
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
350 |
|n| |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
351 |
|
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
352 |
items := groupSizes := nil. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
353 |
|
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
354 |
aCollectionOfMenuItems size == 0 ifTrue:[ ^ self ]. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
355 |
|
451 | 356 |
items := aCollectionOfMenuItems. |
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
357 |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
358 |
sizes size > 0 ifTrue:[ |
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
359 |
groupSizes := sizes. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
360 |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
361 |
n := sizes inject:0 into:[:sumSoFar :this | sumSoFar + this]. |
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
362 |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
363 |
n = items size ifTrue:[ |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
364 |
groupSizes := sizes copyWithoutLast:1 |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
365 |
] |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
366 |
]. |
451 | 367 |
|
579 | 368 |
values notNil ifTrue:[ |
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
369 |
items with:values do:[:anItem :aValue |anItem value:aValue] |
454 | 370 |
]. |
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
371 |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
372 |
"Modified: / 19.4.1998 / 11:47:34 / cg" |
451 | 373 |
! |
374 |
||
1116 | 375 |
menuPerformer:something |
376 |
"set the receiver of the menu messages" |
|
377 |
||
378 |
receiver := something. |
|
379 |
||
380 |
"Modified: / 2.2.1998 / 13:26:29 / cg" |
|
381 |
! |
|
382 |
||
494 | 383 |
numberOfItems |
801 | 384 |
"return the number of items in this menu" |
385 |
||
494 | 386 |
^ items size |
387 |
||
801 | 388 |
"Created: / 6.3.1997 / 15:15:53 / cg" |
389 |
"Modified: / 2.2.1998 / 13:26:40 / cg" |
|
494 | 390 |
! |
391 |
||
579 | 392 |
receiver |
801 | 393 |
"return the receiver of the menu messages" |
579 | 394 |
|
801 | 395 |
^ receiver |
396 |
||
397 |
"Modified: / 2.2.1998 / 13:26:20 / cg" |
|
398 |
! |
|
579 | 399 |
|
400 |
receiver:something |
|
801 | 401 |
"set the receiver of the menu messages" |
579 | 402 |
|
801 | 403 |
receiver := something. |
404 |
||
405 |
"Modified: / 2.2.1998 / 13:26:29 / cg" |
|
406 |
! |
|
579 | 407 |
|
451 | 408 |
valueAt:index |
409 |
"return a collection of values from my items" |
|
410 |
||
411 |
^ (items at:index) value |
|
412 |
||
413 |
"Created: 25.2.1997 / 19:49:41 / cg" |
|
414 |
! |
|
415 |
||
494 | 416 |
valueAt:anIndex put:aValue |
417 |
"put value an an index" |
|
418 |
||
419 |
(items at:anIndex) value:aValue |
|
420 |
||
421 |
"Created: 6.3.1997 / 15:15:48 / cg" |
|
422 |
! |
|
423 |
||
451 | 424 |
values |
425 |
"return a collection of values from my items" |
|
426 |
||
427 |
^ items collect:[:anItem | anItem value] |
|
428 |
||
429 |
"Created: 25.2.1997 / 19:49:29 / cg" |
|
724 | 430 |
! |
431 |
||
432 |
values:aCollectionOfValues |
|
433 |
"return a collection of values from my items" |
|
434 |
||
435 |
|s| |
|
436 |
||
437 |
s := aCollectionOfValues readStream. |
|
438 |
self itemsDo:[:item | |
|
1111 | 439 |
|val| |
724 | 440 |
|
1111 | 441 |
val := s next. |
442 |
item value:val |
|
724 | 443 |
]. |
1111 | 444 |
s atEnd ifFalse:[ |
2092 | 445 |
self error:'not enough elements in the value collection' mayProceed:true |
1111 | 446 |
] |
724 | 447 |
|
448 |
"Created: / 27.10.1997 / 15:15:47 / cg" |
|
449 |
! |
|
450 |
||
451 |
visibleMenuItemGroups |
|
801 | 452 |
|itemGroups visibleItemGroups nextItem| |
724 | 453 |
|
801 | 454 |
itemGroups := OrderedCollection new. |
455 |
nextItem := 1. |
|
456 |
groupSizes do:[:groupSize | |
|
457 |
itemGroups addLast: (items copyFrom:nextItem to:nextItem + groupSize - 1). |
|
458 |
nextItem := nextItem + groupSize |
|
459 |
]. |
|
460 |
self hasHiddenItems ifFalse:[^ itemGroups]. |
|
724 | 461 |
|
801 | 462 |
"Remove the hidden items." |
463 |
visibleItemGroups := OrderedCollection new. |
|
464 |
itemGroups do:[:eachItemGroup | |
|
465 |
|visibleItemGroup| |
|
466 |
||
467 |
visibleItemGroup := eachItemGroup reject:[:eachMenuItem | eachMenuItem hidden]. |
|
2129 | 468 |
visibleItemGroup notEmpty ifTrue:[ |
801 | 469 |
visibleItemGroups addLast: visibleItemGroup |
470 |
] |
|
471 |
]. |
|
472 |
^ visibleItemGroups |
|
724 | 473 |
|
474 |
"Created: / 27.10.1997 / 15:07:50 / cg" |
|
801 | 475 |
"Modified: / 2.2.1998 / 13:25:52 / cg" |
451 | 476 |
! ! |
477 |
||
1397 | 478 |
!Menu methodsFor:'accessing-resource'! |
582 | 479 |
|
584 | 480 |
findGuiResourcesIn:aResourceContainerOrApplication |
2269
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
481 |
"setup a resource owner" |
1986 | 482 |
|
483 |
receiver isNil ifTrue:[ |
|
484 |
receiver := aResourceContainerOrApplication |
|
485 |
]. |
|
2269
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
486 |
^ self |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
487 |
findGuiResourcesIn:aResourceContainerOrApplication |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
488 |
rememberResourcesIn:(ValueHolder new) |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
489 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
490 |
"Modified: / 26-10-2006 / 16:37:57 / cg" |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
491 |
! |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
492 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
493 |
findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
494 |
"setup a resource owner" |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
495 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
496 |
|resolvedItems rcv| |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
497 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
498 |
"/ cg: do not recursively change the receiver - it could be set for the top |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
499 |
"/ menu via #receiver: by the application. |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
500 |
"/ if the submenu's receiver is nil, the parentmenus receiver will be used, which is ok. |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
501 |
"/ But if it was changed below, we would need a recursive setting in #receiver: as well. |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
502 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
503 |
"/ receiver isNil ifTrue:[ |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
504 |
"/ receiver := aResourceContainerOrApplication |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
505 |
"/ ]. |
1986 | 506 |
items isEmptyOrNil ifTrue:[^ self]. |
507 |
||
508 |
resolvedItems := OrderedCollection new. |
|
509 |
||
510 |
items do:[:anItem | |
|
511 |
anItem isMenuSlice ifTrue:[ |resItems| |
|
2059
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
512 |
rcv := aResourceContainerOrApplication. |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
513 |
[rcv notNil and:[resItems isNil]] whileTrue:[ |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
514 |
resItems := anItem resolveSliceMenuItemsIn:rcv |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
515 |
rememberResourcesIn:aValueHolderOrNil. |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
516 |
rcv := rcv perform:#masterApplication ifNotUnderstood:nil. |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
517 |
]. |
1986 | 518 |
|
519 |
resItems notEmptyOrNil ifTrue:[ |
|
520 |
resolvedItems addAll:resItems. |
|
521 |
] |
|
522 |
] ifFalse:[ |
|
523 |
anItem |
|
524 |
findGuiResourcesIn:aResourceContainerOrApplication |
|
525 |
rememberResourcesIn:aValueHolderOrNil. |
|
526 |
||
527 |
resolvedItems add:anItem. |
|
1534
292c277fcf6a
findGuiResources... now sets the receiver, if not yet set
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
528 |
]. |
1986 | 529 |
]. |
530 |
items := resolvedItems. |
|
2269
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
531 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
532 |
"Modified: / 26-10-2006 / 16:45:14 / cg" |
582 | 533 |
! ! |
534 |
||
940 | 535 |
!Menu methodsFor:'adding & removing'! |
536 |
||
537 |
addItem:aMenuItem |
|
1029 | 538 |
"add a menuItem at the end; |
539 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
540 |
||
940 | 541 |
items isNil ifTrue:[ |
1029 | 542 |
items := OrderedCollection new |
543 |
] ifFalse:[ |
|
544 |
items := items asOrderedCollection |
|
940 | 545 |
]. |
546 |
items add:aMenuItem. |
|
1029 | 547 |
|
548 |
"Modified: / 4.8.1998 / 17:31:13 / cg" |
|
940 | 549 |
! |
550 |
||
551 |
addItem:aMenuItem beforeIndex:anIndex |
|
1029 | 552 |
"add a menuItem at some position; |
553 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
554 |
||
940 | 555 |
items isNil ifTrue:[ |
556 |
items := OrderedCollection new |
|
1029 | 557 |
] ifFalse:[ |
558 |
items := items asOrderedCollection |
|
940 | 559 |
]. |
560 |
items add:aMenuItem beforeIndex:anIndex. |
|
1029 | 561 |
|
562 |
"Modified: / 4.8.1998 / 17:31:39 / cg" |
|
940 | 563 |
! |
564 |
||
565 |
addItem:aMenuItem value:aValue |
|
566 |
aMenuItem value:aValue. |
|
567 |
self addItem:aMenuItem. |
|
568 |
! |
|
569 |
||
1758 | 570 |
addItemGroup:aGroup |
1029 | 571 |
"add a group of items at the end; |
572 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
573 |
||
940 | 574 |
groupSizes isNil ifTrue:[ |
1758 | 575 |
groupSizes := OrderedCollection with:items size. |
940 | 576 |
]. |
1758 | 577 |
groupSizes add:aGroup size. |
940 | 578 |
|
1758 | 579 |
aGroup do:[:item | |
1029 | 580 |
self addItem:item |
940 | 581 |
]. |
582 |
||
583 |
"Created: / 27.10.1997 / 15:02:15 / cg" |
|
1029 | 584 |
"Modified: / 4.8.1998 / 17:32:06 / cg" |
940 | 585 |
! |
586 |
||
587 |
addItemGroup:aGroup values:values |
|
1029 | 588 |
"add a group of items at the end; |
589 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
590 |
||
1758 | 591 |
aGroup with:values do:[:item :value | |
592 |
item value:value |
|
940 | 593 |
]. |
1758 | 594 |
self addItemGroup:aGroup |
1029 | 595 |
|
596 |
"Modified: / 4.8.1998 / 17:32:18 / cg" |
|
940 | 597 |
! |
598 |
||
599 |
addItemGroupLabels:labels values:values |
|
1029 | 600 |
"add a group of items at the end; |
601 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
602 |
||
940 | 603 |
|items| |
604 |
||
605 |
items := labels with:values |
|
1029 | 606 |
collect:[:label :value | |
607 |
MenuItem label:label value:value |
|
608 |
]. |
|
940 | 609 |
self addItemGroup:items |
610 |
||
611 |
"Created: / 27.10.1997 / 19:49:27 / cg" |
|
1029 | 612 |
"Modified: / 4.8.1998 / 17:35:22 / cg" |
940 | 613 |
! |
614 |
||
615 |
addItemLabel:label value:value |
|
1029 | 616 |
"add an item at the end; |
617 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
940 | 618 |
|
1029 | 619 |
self addItem:(MenuItem label:label value:value) |
940 | 620 |
|
621 |
"Created: / 27.10.1997 / 19:47:12 / cg" |
|
1029 | 622 |
"Modified: / 4.8.1998 / 17:34:44 / cg" |
940 | 623 |
! |
624 |
||
1500 | 625 |
addSeparator |
626 |
"add a separating line item at the end; |
|
627 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
628 |
||
629 |
self addItem:(MenuItem new label:'-'). |
|
630 |
! |
|
631 |
||
940 | 632 |
removeItem:aMenuItem |
633 |
"remove an item from the menu" |
|
634 |
||
635 |
|idx| |
|
636 |
||
637 |
items notNil ifTrue:[ |
|
638 |
idx := items identityIndexOf:aMenuItem. |
|
639 |
idx ~~ 0 ifTrue:[ |
|
640 |
items removeAtIndex:idx |
|
641 |
] |
|
642 |
]. |
|
643 |
||
644 |
"Created: / 13.9.1997 / 10:27:31 / cg" |
|
645 |
"Modified: / 2.2.1998 / 13:26:49 / cg" |
|
646 |
! |
|
647 |
||
648 |
removeItemAt:anIndex |
|
649 |
"remove item at an index |
|
650 |
" |
|
651 |
anIndex <= items size ifTrue:[ |
|
652 |
^ items removeAtIndex:anIndex |
|
653 |
]. |
|
654 |
^ nil |
|
655 |
! ! |
|
656 |
||
451 | 657 |
!Menu methodsFor:'converting'! |
658 |
||
2081 | 659 |
asOldStylePopUpMenuFor:anApplicationOrNil |
2080 | 660 |
"a temporary kludge - will vanish, when oldStyle MenuView and PopUpMenu are gone" |
661 |
||
2081 | 662 |
|menuView itemsShown| |
663 |
||
664 |
itemsShown := items select:[:each | |
|
665 |
|visibilityInItem| |
|
666 |
||
667 |
visibilityInItem := each isVisible. |
|
668 |
visibilityInItem isNil ifTrue:[ |
|
669 |
true |
|
670 |
] ifFalse:[ |
|
671 |
visibilityInItem isBoolean ifTrue:[ |
|
672 |
visibilityInItem |
|
673 |
] ifFalse:[ |
|
674 |
visibilityInItem isSymbol ifTrue:[ |
|
675 |
(anApplicationOrNil perform:visibilityInItem) value. |
|
676 |
] ifFalse:[ |
|
677 |
visibilityInItem value |
|
678 |
]. |
|
679 |
]. |
|
680 |
]. |
|
681 |
]. |
|
2080 | 682 |
|
683 |
menuView := MenuView |
|
2081 | 684 |
labels:(itemsShown collect:[:each | each label]) |
685 |
selectors:(itemsShown collect:[:each | each value]) |
|
2751
d0729d604864
changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents:
2584
diff
changeset
|
686 |
accelerators:(itemsShown collect:[:each | each shortcutKey]) |
2081 | 687 |
args:(itemsShown collect:[:each | each argument]) |
2080 | 688 |
receiver:receiver. |
689 |
||
2092 | 690 |
itemsShown doWithIndex:[:each :idx | |
2081 | 691 |
|enabledInItem enabled| |
692 |
||
693 |
enabledInItem := each enabled. |
|
694 |
enabledInItem notNil ifTrue:[ |
|
695 |
enabledInItem isSymbol ifTrue:[ |
|
696 |
enabled := (anApplicationOrNil perform:enabledInItem). |
|
697 |
] ifFalse:[ |
|
698 |
enabledInItem isBoolean ifTrue:[ |
|
699 |
enabled := enabledInItem |
|
700 |
]. |
|
701 |
]. |
|
702 |
enabled value ifFalse:[ |
|
2092 | 703 |
menuView disable:idx |
2081 | 704 |
]. |
705 |
]. |
|
706 |
]. |
|
707 |
||
2092 | 708 |
menuView actions:(itemsShown collect:[:each | [ receiver perform:each value ]]). |
2080 | 709 |
|
710 |
^ PopUpMenu forMenu:menuView |
|
711 |
! |
|
712 |
||
451 | 713 |
fromLiteralArrayEncoding:aLiteralEncodedArray |
714 |
"read my contents from a aLiteralEncodedArray" |
|
715 |
||
716 |
|items groups values| |
|
717 |
||
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
718 |
items := aLiteralEncodedArray at:2. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
719 |
|
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
720 |
items ifNotNil:[ |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
721 |
items := items collect:[:item | item decodeAsLiteralArray]. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
722 |
]. |
1405
c7775c10e8fd
tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
723 |
groups := aLiteralEncodedArray at:3 ifAbsent:nil. |
c7775c10e8fd
tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
724 |
values := aLiteralEncodedArray at:4 ifAbsent:nil. |
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
725 |
self menuItems:items menuItemGroups:groups values:values. |
451 | 726 |
|
727 |
"extract from PD folder.st: |
|
728 |
#(#Menu #( |
|
1245 | 729 |
#(#MenuItem |
730 |
#rawLabel: 'left' |
|
731 |
#value: #left ) |
|
732 |
#(#MenuItem |
|
733 |
#rawLabel: 'center' |
|
734 |
#value: #center ) |
|
735 |
#(#MenuItem |
|
736 |
#rawLabel: 'right' |
|
737 |
#value: #right ) |
|
738 |
) |
|
739 |
#(3 ) |
|
740 |
nil |
|
451 | 741 |
) decodeAsLiteralArray |
742 |
" |
|
452 | 743 |
" |
744 |
#(#Menu #( |
|
1245 | 745 |
#(#MenuItem |
746 |
#label: 'Straighten Up' ) |
|
747 |
#(#MenuItem |
|
748 |
#label: 'Inspect' ) |
|
749 |
#(#MenuItem |
|
750 |
#label: 'Coredump' ) |
|
751 |
) |
|
752 |
#(3 ) |
|
753 |
#(#straightenUp #inspect #halt ) |
|
452 | 754 |
) decodeAsLiteralArray startUp |
755 |
" |
|
457 | 756 |
|
454 | 757 |
"extract from iconicBrowser.st: |
452 | 758 |
#(#Menu #( |
1245 | 759 |
#(#MenuItem |
760 |
#label: 'Straighten Up' ) |
|
761 |
#(#MenuItem |
|
762 |
#label: 'Inspect' ) |
|
763 |
#(#MenuItem |
|
764 |
#label: 'Coredump' ) |
|
765 |
) |
|
766 |
#(3 ) |
|
767 |
#(1 2 3 ) |
|
452 | 768 |
) decodeAsLiteralArray startUp |
769 |
" |
|
451 | 770 |
|
454 | 771 |
"extract from refactory213.st: |
772 |
#(#Menu #( |
|
1245 | 773 |
#(#MenuItem |
774 |
#label: 'File List' |
|
775 |
#accessCharacterPosition: 1 ) |
|
776 |
#(#MenuItem #label: 'File Editor...' |
|
777 |
#accessCharacterPosition: 6 ) |
|
778 |
#(#MenuItem #label: 'Refactoring Tool...' |
|
779 |
#accessCharacterPosition: 1 ) |
|
780 |
#(#MenuItem #label: 'Workspace' |
|
781 |
#accessCharacterPosition: 1 ) |
|
782 |
#(#MenuItem #label: 'New Canvas' |
|
783 |
#accessCharacterPosition: 1 ) |
|
784 |
#(#MenuItem #label: 'Palette' |
|
785 |
#accessCharacterPosition: 1 ) |
|
786 |
#(#MenuItem #label: 'Canvas Tool' |
|
787 |
#accessCharacterPosition: 1 ) |
|
788 |
#(#MenuItem #label: 'Image Editor' |
|
789 |
#accessCharacterPosition: 1 ) |
|
790 |
#(#MenuItem #label: 'Menu Editor' |
|
791 |
#accessCharacterPosition: 1 ) |
|
792 |
#(#MenuItem #label: 'Advanced' |
|
793 |
#accessCharacterPosition: 1 ) |
|
794 |
#(#MenuItem #label: 'DLL and C Connect' |
|
795 |
#accessCharacterPosition: 1 ) |
|
796 |
#(#MenuItem #label: 'System Transcript' |
|
797 |
#accessCharacterPosition: 8 ) |
|
798 |
) |
|
799 |
#(4 5 2 1 ) |
|
800 |
#(#openFileList #openFileEditor #openRefactoringTool #toolsNewWorkspace #toolsNewCanvas #toolsPalette #toolsCanvasTool #toolsMaskEditor #toolsMenuEditor nil #openExternalFinder #toggleSystemTranscript ) |
|
801 |
) decodeAsLiteralArray startUp |
|
454 | 802 |
" |
803 |
||
457 | 804 |
"submenus: |
805 |
#(#Menu #( |
|
1245 | 806 |
#(#MenuItem |
807 |
#label: 'Foo' |
|
808 |
#submenu: #(#Menu #( |
|
809 |
#(#MenuItem #label: 'foo 1') |
|
810 |
#(#MenuItem #label: 'foo 2') |
|
811 |
) |
|
812 |
nil |
|
813 |
#(11 22) |
|
814 |
) |
|
815 |
) |
|
816 |
#(#MenuItem |
|
817 |
#label: 'Inspect' ) |
|
818 |
#(#MenuItem |
|
819 |
#label: 'Coredump' ) |
|
820 |
) |
|
821 |
#(3 ) |
|
822 |
#(1 2 3 ) |
|
457 | 823 |
) decodeAsLiteralArray startUp |
824 |
" |
|
825 |
||
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
826 |
"Modified: 20.6.1997 / 10:45:51 / cg" |
489 | 827 |
! |
828 |
||
829 |
literalArrayEncoding |
|
830 |
"return myself encoded as a literal array" |
|
831 |
||
1245 | 832 |
|coll array size| |
489 | 833 |
|
834 |
coll := OrderedCollection new. |
|
835 |
coll add:#Menu. |
|
1245 | 836 |
|
837 |
(size := items size) == 0 ifTrue:[ |
|
838 |
array := nil |
|
839 |
] ifFalse:[ |
|
840 |
array := Array new:size. |
|
841 |
items keysAndValuesDo:[:anIndex :anItem| |
|
842 |
array at:anIndex put:(anItem literalArrayEncoding) |
|
843 |
] |
|
844 |
]. |
|
845 |
coll add:array. |
|
846 |
||
847 |
(size := groupSizes size) == 0 ifTrue:[ |
|
848 |
array := nil |
|
849 |
] ifFalse:[ |
|
850 |
array := Array new:size. |
|
851 |
groupSizes keysAndValuesDo:[:anIndex :aSize| |
|
852 |
array at:anIndex put:(aSize literalArrayEncoding) |
|
853 |
] |
|
854 |
]. |
|
855 |
coll add:array. |
|
489 | 856 |
coll add:nil. |
579 | 857 |
^ coll asArray |
451 | 858 |
! ! |
859 |
||
584 | 860 |
!Menu methodsFor:'enumerating'! |
861 |
||
2494
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
862 |
allItemsDetect:aOneArgBlock ifNone:exceptionalValue |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
863 |
"find an element amongst each item and submenu items" |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
864 |
|
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
865 |
self itemsDo:[:anItem| |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
866 |
|sub subItem| |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
867 |
|
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
868 |
(aOneArgBlock value:anItem) ifTrue:[^ anItem]. |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
869 |
(sub := anItem submenu) notNil ifTrue:[ |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
870 |
subItem := sub allItemsDetect:aOneArgBlock ifNone:nil. |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
871 |
subItem notNil ifTrue:[^ subItem]. |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
872 |
] |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
873 |
]. |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
874 |
^ exceptionalValue value |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
875 |
! |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
876 |
|
665 | 877 |
allItemsDo:aOneArgBlock |
878 |
"evaluate block on each item and submenu items |
|
879 |
" |
|
880 |
self itemsDo:[:anItem| |
|
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
881 |
|sub| |
724 | 882 |
|
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
883 |
aOneArgBlock value:anItem. |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
884 |
(sub := anItem submenu) notNil ifTrue:[ |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
885 |
sub allItemsDo:aOneArgBlock |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
886 |
] |
665 | 887 |
] |
724 | 888 |
|
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
889 |
"Modified: / 19.6.1998 / 00:34:53 / cg" |
665 | 890 |
! |
891 |
||
940 | 892 |
detectItem:aBlock |
893 |
"evaluate the argument, aBlock for each item in the menu until the |
|
894 |
block returns true; in this case return the item which caused the |
|
895 |
true evaluation. |
|
896 |
If none of the evaluations returns true, return the result of the |
|
897 |
evaluation of the exceptionBlock |
|
898 |
" |
|
899 |
^ self detectItem:aBlock ifNone:[self errorNotFound] |
|
900 |
||
901 |
! |
|
902 |
||
903 |
detectItem:aBlock ifNone:exceptionBlock |
|
904 |
"evaluate the argument, aBlock for each item in the menu until the |
|
905 |
block returns true; in this case return the item which caused the |
|
906 |
true evaluation. |
|
907 |
If none of the evaluations returns true, return the result of the |
|
908 |
evaluation of the exceptionBlock |
|
909 |
" |
|
910 |
items notNil ifTrue:[ |
|
911 |
^ items detect:aBlock ifNone:exceptionBlock |
|
912 |
]. |
|
913 |
^ exceptionBlock value |
|
914 |
! |
|
915 |
||
589 | 916 |
itemsDo:aOneArgBlock |
917 |
"evaluate the block for each item in the current menu |
|
918 |
" |
|
919 |
items notNil ifTrue:[items do:aOneArgBlock] |
|
920 |
! |
|
921 |
||
584 | 922 |
menuAndSubmenusDetectItem:aOneArgBlock |
923 |
"evaluate the block for each item in the current menu and all |
|
924 |
submenus. In case that the block returns a non nil argument, |
|
925 |
the item will be returned |
|
926 |
" |
|
724 | 927 |
|item| |
584 | 928 |
|
929 |
items notNil ifTrue:[ |
|
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
930 |
items do:[:anItem| |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
931 |
|sub| |
724 | 932 |
|
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
933 |
(aOneArgBlock value:anItem) ifTrue:[ |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
934 |
^ anItem |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
935 |
]. |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
936 |
(sub := anItem submenu) notNil ifTrue:[ |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
937 |
item := sub menuAndSubmenusDetectItem:aOneArgBlock. |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
938 |
item notNil ifTrue:[ |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
939 |
^ item |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
940 |
] |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
941 |
] |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
942 |
] |
584 | 943 |
]. |
724 | 944 |
^ nil |
945 |
||
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
946 |
"Modified: / 19.6.1998 / 00:35:00 / cg" |
584 | 947 |
! ! |
948 |
||
672
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
949 |
!Menu methodsFor:'kludged fixes'! |
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
950 |
|
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
951 |
destroy |
1599 | 952 |
"dummy to allow a menu to be used where a MenuView used to be" |
672
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
953 |
|
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
954 |
"Created: 28.7.1997 / 10:16:52 / cg" |
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
955 |
! ! |
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
956 |
|
584 | 957 |
!Menu methodsFor:'menu items'! |
958 |
||
2404 | 959 |
removeAllAccelerators |
960 |
self allItemsDo:[:eachItem | |
|
961 |
eachItem shortcutKey:nil. |
|
962 |
]. |
|
963 |
! |
|
964 |
||
740 | 965 |
someMenuItemLabeled:aLabel |
966 |
"get the menu item with that label; in case that the label |
|
967 |
is not found, nil is returned |
|
968 |
" |
|
969 |
^ self someMenuItemLabeled:aLabel ifNone:nil |
|
970 |
||
971 |
"Created: / 14.11.1997 / 20:55:17 / cg" |
|
972 |
! |
|
973 |
||
974 |
someMenuItemLabeled:aLabel ifNone:exceptionBlock |
|
975 |
"get the menu item labeled aLabel; in case that the value |
|
976 |
is not found, the given exceptionBlock is executed and its value returned |
|
977 |
" |
|
978 |
|item| |
|
979 |
||
980 |
item := self menuAndSubmenusDetectItem:[:anItem| anItem label = aLabel]. |
|
981 |
||
982 |
item notNil ifTrue:[ |
|
983 |
^ item |
|
984 |
]. |
|
985 |
^ exceptionBlock value |
|
986 |
||
987 |
"Created: / 14.11.1997 / 20:56:13 / cg" |
|
988 |
! |
|
989 |
||
584 | 990 |
someMenuItemWithValue:aValue |
991 |
"get the menu item assigned with the value; in case that the value |
|
992 |
is not found nil is returned |
|
993 |
" |
|
994 |
^ self someMenuItemWithValue:aValue ifNone:nil |
|
995 |
! |
|
996 |
||
997 |
someMenuItemWithValue:aValue ifNone:exceptionBlock |
|
998 |
"get the menu item assigned with the value; in case that the value |
|
999 |
is not found, the given exceptionBlock is executed and returned |
|
1000 |
" |
|
1001 |
|item| |
|
1002 |
||
1003 |
item := self menuAndSubmenusDetectItem:[:anItem| anItem value == aValue]. |
|
1004 |
||
1005 |
item notNil ifTrue:[ |
|
740 | 1006 |
^ item |
584 | 1007 |
]. |
1008 |
^ exceptionBlock value |
|
1009 |
! ! |
|
1010 |
||
1011 |
!Menu methodsFor:'queries'! |
|
1012 |
||
724 | 1013 |
hasHiddenItems |
1014 |
"test whether any item is hidden" |
|
1015 |
||
1016 |
self allItemsDo:[:anItem| |
|
740 | 1017 |
anItem isHidden ifTrue:[^ true] |
724 | 1018 |
]. |
1019 |
^ false |
|
1020 |
||
1021 |
"Modified: / 27.10.1997 / 15:12:44 / cg" |
|
1022 |
! |
|
1023 |
||
2584 | 1024 |
hasItems |
1025 |
"test whether there are any menu-items" |
|
1026 |
||
1027 |
^ items notEmptyOrNil |
|
1028 |
! |
|
1029 |
||
584 | 1030 |
hasSubMenuAt:anIndex |
1031 |
"test whether the menu item at the given index has a submenu |
|
1032 |
" |
|
1033 |
^ (self menuItemAt:anIndex) hasSubmenu |
|
1034 |
! ! |
|
1035 |
||
451 | 1036 |
!Menu methodsFor:'startup'! |
1037 |
||
729 | 1038 |
show |
1039 |
"realize the menu at its last position; returns the value associated with the |
|
1040 |
selected item, 0 if none was selected" |
|
1041 |
||
1042 |
^ (MenuPanel menu:self) show ? 0 |
|
1043 |
||
1044 |
||
1045 |
! |
|
1046 |
||
1047 |
showAt:aPoint |
|
1048 |
"realize the menu at aPoint; returns the value associated with the |
|
1049 |
selected item, 0 if none was selected" |
|
1050 |
||
1051 |
^ self showAt:aPoint resizing:true |
|
1052 |
||
1053 |
||
1054 |
! |
|
1055 |
||
1056 |
showAt:aPoint resizing:aBoolean |
|
1057 |
"realize the menu at aPoint; returns the value associated with the |
|
451 | 1058 |
selected item, 0 if none was selected" |
1059 |
||
996
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1060 |
^ ((MenuPanel menu:self) showAt:aPoint resizing:aBoolean) ? 0 |
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1061 |
|
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1062 |
"Modified: / 8.7.1998 / 19:57:55 / cg" |
729 | 1063 |
! |
1064 |
||
1065 |
showAtPointer |
|
1066 |
"realize the menu at the current pointer position; returns the value associated with the |
|
1067 |
selected item, 0 if none was selected" |
|
1068 |
||
1069 |
^ self startUp |
|
1070 |
! |
|
457 | 1071 |
|
729 | 1072 |
showCenteredIn:aView |
1073 |
"realize the menu visible at the aView center; returns the value associated with the |
|
1074 |
selected item, 0 if none was selected" |
|
1075 |
||
996
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1076 |
^ ((MenuPanel menu:self) showCenteredIn:aView) ? 0 |
729 | 1077 |
|
996
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1078 |
"Modified: / 8.7.1998 / 19:58:05 / cg" |
729 | 1079 |
! |
1080 |
||
1081 |
startUp |
|
1082 |
"display the menu as a popUp; returns the value associated with the |
|
2039 | 1083 |
selected item, nil if none was selected. |
1084 |
(should we return 0 form ST-80 compatibility ?)" |
|
729 | 1085 |
|
1367 | 1086 |
^ (MenuPanel menu:self) startUp "/ ? 0 |
451 | 1087 |
|
579 | 1088 |
" |
1367 | 1089 |
|m| |
579 | 1090 |
|
1367 | 1091 |
m := #(#Menu #( |
1092 |
#(#MenuItem |
|
1093 |
#rawLabel: 'left' |
|
1094 |
#value: #left ) |
|
1095 |
#(#MenuItem |
|
1096 |
#rawLabel: 'center' |
|
1097 |
#value: #center ) |
|
1098 |
#(#MenuItem |
|
1099 |
#rawLabel: 'right' |
|
1100 |
#value: #right ) ) |
|
1101 |
#(2) |
|
1102 |
nil |
|
1103 |
) decodeAsLiteralArray. |
|
451 | 1104 |
|
579 | 1105 |
Transcript showCR:(m startUp) |
1106 |
" |
|
938
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1107 |
! |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1108 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1109 |
startUpAt:aPoint |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1110 |
"display the menu as a popUp at aPoint; returns the value associated with the |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1111 |
selected item, 0 if none was selected" |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1112 |
|
939 | 1113 |
^ ((MenuPanel menu:self) startUpAt:aPoint) ? 0 |
938
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1114 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1115 |
" |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1116 |
|m| |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1117 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1118 |
m := #(#Menu #( |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1119 |
#(#MenuItem |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1120 |
#rawLabel: 'left' |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1121 |
#value: #left ) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1122 |
#(#MenuItem |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1123 |
#rawLabel: 'center' |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1124 |
#value: #center ) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1125 |
#(#MenuItem |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1126 |
#rawLabel: 'right' |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1127 |
#value: #right ) ) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1128 |
#(2) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1129 |
nil |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1130 |
) decodeAsLiteralArray. |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1131 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1132 |
Transcript showCR:(m startUpAt:100@100) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1133 |
" |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1134 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1135 |
"Created: / 21.5.1998 / 14:15:21 / cg" |
939 | 1136 |
"Modified: / 21.5.1998 / 14:17:46 / cg" |
1367 | 1137 |
! |
1138 |
||
1652 | 1139 |
startUpFor:originatingWidget |
1140 |
"display the menu as a popUp; returns the value associated with the |
|
2039 | 1141 |
selected item, nil if none was selected. |
1142 |
(should we return 0 for ST-80 compatibility ?)" |
|
1652 | 1143 |
|
1144 |
^ (MenuPanel menu:self) startUpFor:originatingWidget "/ ? 0 |
|
1145 |
||
1146 |
" |
|
1147 |
|m| |
|
1148 |
||
1149 |
m := #(#Menu #( |
|
1150 |
#(#MenuItem |
|
1151 |
#rawLabel: 'left' |
|
1152 |
#value: #left ) |
|
1153 |
#(#MenuItem |
|
1154 |
#rawLabel: 'center' |
|
1155 |
#value: #center ) |
|
1156 |
#(#MenuItem |
|
1157 |
#rawLabel: 'right' |
|
1158 |
#value: #right ) ) |
|
1159 |
#(2) |
|
1160 |
nil |
|
1161 |
) decodeAsLiteralArray. |
|
1162 |
||
1163 |
Transcript showCR:(m startUp) |
|
1164 |
" |
|
1165 |
! |
|
1166 |
||
1367 | 1167 |
startUpOrNil |
1168 |
"display the menu as a popUp; returns the value associated with the |
|
1169 |
selected item, nil if none was selected" |
|
1170 |
||
1405
c7775c10e8fd
tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
1171 |
^ (MenuPanel menu:self) startUpOrNil |
451 | 1172 |
! ! |
1173 |
||
1174 |
!Menu class methodsFor:'documentation'! |
|
1175 |
||
1176 |
version |
|
2751
d0729d604864
changed: #asOldStylePopUpMenuFor:
Claus Gittinger <cg@exept.de>
parents:
2584
diff
changeset
|
1177 |
^ '$Header: /cvs/stx/stx/libview2/Menu.st,v 1.72 2009-09-28 09:25:25 cg Exp $' |
451 | 1178 |
! ! |