author | Claus Gittinger <cg@exept.de> |
Thu, 05 Jun 2008 19:13:20 +0200 | |
changeset 2494 | 994b030ae562 |
parent 2433 | 632122b652eb |
child 2584 | 5b5c3dda9a4b |
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 |
273 |
"returns last item |
|
274 |
" |
|
275 |
^ items notNil ifTrue:[items last] ifFalse:[nil] |
|
276 |
! |
|
277 |
||
489 | 278 |
lines |
737 | 279 |
"return the indexes of the menu items that are the last menu item in their group (except the very last)." |
489 | 280 |
|
801 | 281 |
|lines groupSz| |
737 | 282 |
|
801 | 283 |
(groupSz := groupSizes size) <= 1 ifTrue: [^ Array new]. |
284 |
lines := Array new:(groupSz - 1). |
|
285 |
lines at:1 put:groupSizes first. |
|
286 |
2 to:(groupSz-1) do:[:i | |
|
287 |
lines at:i put:(lines at:(i - 1)) + (groupSizes at:i) |
|
288 |
]. |
|
289 |
^ lines |
|
489 | 290 |
|
801 | 291 |
"Modified: / 2.2.1998 / 13:28:19 / cg" |
489 | 292 |
! |
293 |
||
294 |
menuItemAt:index |
|
584 | 295 |
"gets the menu item at the given index. When the index is out of bounds |
296 |
nil is returned |
|
297 |
" |
|
298 |
(index > 0 and:[index <= items size]) ifTrue:[ |
|
740 | 299 |
^ items at:index |
584 | 300 |
]. |
301 |
^ nil |
|
489 | 302 |
! |
303 |
||
724 | 304 |
menuItemLabeled:anItemLabel |
305 |
"return the menuItem for the given nameKey; nil if no such item is in the menu. |
|
306 |
Searches all items (i.e. also submenu items)" |
|
307 |
||
308 |
self allItemsDo:[:anItem| |
|
740 | 309 |
|l| |
724 | 310 |
|
740 | 311 |
((l := anItem label) sameAs: anItemLabel) ifTrue:[ |
312 |
^ anItem |
|
313 |
]. |
|
314 |
(l includes:$&) ifTrue:[ |
|
315 |
((l copyWithout:$&) sameAs: anItemLabel) ifTrue:[ |
|
316 |
^ anItem |
|
317 |
] |
|
318 |
] |
|
319 |
]. |
|
724 | 320 |
^ nil |
321 |
||
322 |
"Created: / 13.9.1997 / 10:25:16 / cg" |
|
323 |
"Modified: / 27.10.1997 / 15:23:33 / cg" |
|
324 |
! |
|
325 |
||
1652 | 326 |
menuItemWithValue:aValue |
327 |
"return the menuItem for the given value; nil if no such item is in the menu. |
|
328 |
Searches all items (i.e. also submenu items)" |
|
329 |
||
330 |
self allItemsDo:[:anItem| |
|
331 |
|l| |
|
332 |
||
333 |
(anItem value == aValue) ifTrue:[ |
|
334 |
^ anItem |
|
335 |
]. |
|
336 |
]. |
|
337 |
^ nil |
|
338 |
||
339 |
"Created: / 13.9.1997 / 10:25:16 / cg" |
|
340 |
"Modified: / 27.10.1997 / 15:23:33 / cg" |
|
341 |
! |
|
342 |
||
489 | 343 |
menuItems |
1327
b0b482a84570
menuItems always returns a collection (never nil)
Claus Gittinger <cg@exept.de>
parents:
1308
diff
changeset
|
344 |
^ items ? #() |
489 | 345 |
! |
346 |
||
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
347 |
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
|
348 |
|n| |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
349 |
|
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
350 |
items := groupSizes := nil. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
351 |
|
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
352 |
aCollectionOfMenuItems size == 0 ifTrue:[ ^ self ]. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
353 |
|
451 | 354 |
items := aCollectionOfMenuItems. |
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
355 |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
356 |
sizes size > 0 ifTrue:[ |
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
357 |
groupSizes := sizes. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
358 |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
359 |
n := sizes inject:0 into:[:sumSoFar :this | sumSoFar + this]. |
1620
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 = 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
|
362 |
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
|
363 |
] |
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
364 |
]. |
451 | 365 |
|
579 | 366 |
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
|
367 |
items with:values do:[:anItem :aValue |anItem value:aValue] |
454 | 368 |
]. |
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
369 |
|
900
aa93395cdb55
care for empty group at the end (avoid line at end of menu)
Claus Gittinger <cg@exept.de>
parents:
801
diff
changeset
|
370 |
"Modified: / 19.4.1998 / 11:47:34 / cg" |
451 | 371 |
! |
372 |
||
1116 | 373 |
menuPerformer:something |
374 |
"set the receiver of the menu messages" |
|
375 |
||
376 |
receiver := something. |
|
377 |
||
378 |
"Modified: / 2.2.1998 / 13:26:29 / cg" |
|
379 |
! |
|
380 |
||
494 | 381 |
numberOfItems |
801 | 382 |
"return the number of items in this menu" |
383 |
||
494 | 384 |
^ items size |
385 |
||
801 | 386 |
"Created: / 6.3.1997 / 15:15:53 / cg" |
387 |
"Modified: / 2.2.1998 / 13:26:40 / cg" |
|
494 | 388 |
! |
389 |
||
579 | 390 |
receiver |
801 | 391 |
"return the receiver of the menu messages" |
579 | 392 |
|
801 | 393 |
^ receiver |
394 |
||
395 |
"Modified: / 2.2.1998 / 13:26:20 / cg" |
|
396 |
! |
|
579 | 397 |
|
398 |
receiver:something |
|
801 | 399 |
"set the receiver of the menu messages" |
579 | 400 |
|
801 | 401 |
receiver := something. |
402 |
||
403 |
"Modified: / 2.2.1998 / 13:26:29 / cg" |
|
404 |
! |
|
579 | 405 |
|
451 | 406 |
valueAt:index |
407 |
"return a collection of values from my items" |
|
408 |
||
409 |
^ (items at:index) value |
|
410 |
||
411 |
"Created: 25.2.1997 / 19:49:41 / cg" |
|
412 |
! |
|
413 |
||
494 | 414 |
valueAt:anIndex put:aValue |
415 |
"put value an an index" |
|
416 |
||
417 |
(items at:anIndex) value:aValue |
|
418 |
||
419 |
"Created: 6.3.1997 / 15:15:48 / cg" |
|
420 |
! |
|
421 |
||
451 | 422 |
values |
423 |
"return a collection of values from my items" |
|
424 |
||
425 |
^ items collect:[:anItem | anItem value] |
|
426 |
||
427 |
"Created: 25.2.1997 / 19:49:29 / cg" |
|
724 | 428 |
! |
429 |
||
430 |
values:aCollectionOfValues |
|
431 |
"return a collection of values from my items" |
|
432 |
||
433 |
|s| |
|
434 |
||
435 |
s := aCollectionOfValues readStream. |
|
436 |
self itemsDo:[:item | |
|
1111 | 437 |
|val| |
724 | 438 |
|
1111 | 439 |
val := s next. |
440 |
item value:val |
|
724 | 441 |
]. |
1111 | 442 |
s atEnd ifFalse:[ |
2092 | 443 |
self error:'not enough elements in the value collection' mayProceed:true |
1111 | 444 |
] |
724 | 445 |
|
446 |
"Created: / 27.10.1997 / 15:15:47 / cg" |
|
447 |
! |
|
448 |
||
449 |
visibleMenuItemGroups |
|
801 | 450 |
|itemGroups visibleItemGroups nextItem| |
724 | 451 |
|
801 | 452 |
itemGroups := OrderedCollection new. |
453 |
nextItem := 1. |
|
454 |
groupSizes do:[:groupSize | |
|
455 |
itemGroups addLast: (items copyFrom:nextItem to:nextItem + groupSize - 1). |
|
456 |
nextItem := nextItem + groupSize |
|
457 |
]. |
|
458 |
self hasHiddenItems ifFalse:[^ itemGroups]. |
|
724 | 459 |
|
801 | 460 |
"Remove the hidden items." |
461 |
visibleItemGroups := OrderedCollection new. |
|
462 |
itemGroups do:[:eachItemGroup | |
|
463 |
|visibleItemGroup| |
|
464 |
||
465 |
visibleItemGroup := eachItemGroup reject:[:eachMenuItem | eachMenuItem hidden]. |
|
2129 | 466 |
visibleItemGroup notEmpty ifTrue:[ |
801 | 467 |
visibleItemGroups addLast: visibleItemGroup |
468 |
] |
|
469 |
]. |
|
470 |
^ visibleItemGroups |
|
724 | 471 |
|
472 |
"Created: / 27.10.1997 / 15:07:50 / cg" |
|
801 | 473 |
"Modified: / 2.2.1998 / 13:25:52 / cg" |
451 | 474 |
! ! |
475 |
||
1397 | 476 |
!Menu methodsFor:'accessing-resource'! |
582 | 477 |
|
584 | 478 |
findGuiResourcesIn:aResourceContainerOrApplication |
2269
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
479 |
"setup a resource owner" |
1986 | 480 |
|
481 |
receiver isNil ifTrue:[ |
|
482 |
receiver := aResourceContainerOrApplication |
|
483 |
]. |
|
2269
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
484 |
^ self |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
485 |
findGuiResourcesIn:aResourceContainerOrApplication |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
486 |
rememberResourcesIn:(ValueHolder new) |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
487 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
488 |
"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
|
489 |
! |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
490 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
491 |
findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
492 |
"setup a resource owner" |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
493 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
494 |
|resolvedItems rcv| |
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 |
"/ 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
|
497 |
"/ menu via #receiver: by the application. |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
498 |
"/ 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
|
499 |
"/ 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
|
500 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
501 |
"/ receiver isNil ifTrue:[ |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
502 |
"/ receiver := aResourceContainerOrApplication |
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
503 |
"/ ]. |
1986 | 504 |
items isEmptyOrNil ifTrue:[^ self]. |
505 |
||
506 |
resolvedItems := OrderedCollection new. |
|
507 |
||
508 |
items do:[:anItem | |
|
509 |
anItem isMenuSlice ifTrue:[ |resItems| |
|
2059
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
510 |
rcv := aResourceContainerOrApplication. |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
511 |
[rcv notNil and:[resItems isNil]] whileTrue:[ |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
512 |
resItems := anItem resolveSliceMenuItemsIn:rcv |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
513 |
rememberResourcesIn:aValueHolderOrNil. |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
514 |
rcv := rcv perform:#masterApplication ifNotUnderstood:nil. |
36e4aa247402
fixed menu-slice resolving (search in masterApplication too)
Claus Gittinger <cg@exept.de>
parents:
2039
diff
changeset
|
515 |
]. |
1986 | 516 |
|
517 |
resItems notEmptyOrNil ifTrue:[ |
|
518 |
resolvedItems addAll:resItems. |
|
519 |
] |
|
520 |
] ifFalse:[ |
|
521 |
anItem |
|
522 |
findGuiResourcesIn:aResourceContainerOrApplication |
|
523 |
rememberResourcesIn:aValueHolderOrNil. |
|
524 |
||
525 |
resolvedItems add:anItem. |
|
1534
292c277fcf6a
findGuiResources... now sets the receiver, if not yet set
Claus Gittinger <cg@exept.de>
parents:
1532
diff
changeset
|
526 |
]. |
1986 | 527 |
]. |
528 |
items := resolvedItems. |
|
2269
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
529 |
|
7fae2df3ba48
resolveGUIResources no longer sets the receiver recursively
Claus Gittinger <cg@exept.de>
parents:
2129
diff
changeset
|
530 |
"Modified: / 26-10-2006 / 16:45:14 / cg" |
582 | 531 |
! ! |
532 |
||
940 | 533 |
!Menu methodsFor:'adding & removing'! |
534 |
||
535 |
addItem:aMenuItem |
|
1029 | 536 |
"add a menuItem at the end; |
537 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
538 |
||
940 | 539 |
items isNil ifTrue:[ |
1029 | 540 |
items := OrderedCollection new |
541 |
] ifFalse:[ |
|
542 |
items := items asOrderedCollection |
|
940 | 543 |
]. |
544 |
items add:aMenuItem. |
|
1029 | 545 |
|
546 |
"Modified: / 4.8.1998 / 17:31:13 / cg" |
|
940 | 547 |
! |
548 |
||
549 |
addItem:aMenuItem beforeIndex:anIndex |
|
1029 | 550 |
"add a menuItem at some position; |
551 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
552 |
||
940 | 553 |
items isNil ifTrue:[ |
554 |
items := OrderedCollection new |
|
1029 | 555 |
] ifFalse:[ |
556 |
items := items asOrderedCollection |
|
940 | 557 |
]. |
558 |
items add:aMenuItem beforeIndex:anIndex. |
|
1029 | 559 |
|
560 |
"Modified: / 4.8.1998 / 17:31:39 / cg" |
|
940 | 561 |
! |
562 |
||
563 |
addItem:aMenuItem value:aValue |
|
564 |
aMenuItem value:aValue. |
|
565 |
self addItem:aMenuItem. |
|
566 |
! |
|
567 |
||
1758 | 568 |
addItemGroup:aGroup |
1029 | 569 |
"add a group of items at the end; |
570 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
571 |
||
940 | 572 |
groupSizes isNil ifTrue:[ |
1758 | 573 |
groupSizes := OrderedCollection with:items size. |
940 | 574 |
]. |
1758 | 575 |
groupSizes add:aGroup size. |
940 | 576 |
|
1758 | 577 |
aGroup do:[:item | |
1029 | 578 |
self addItem:item |
940 | 579 |
]. |
580 |
||
581 |
"Created: / 27.10.1997 / 15:02:15 / cg" |
|
1029 | 582 |
"Modified: / 4.8.1998 / 17:32:06 / cg" |
940 | 583 |
! |
584 |
||
585 |
addItemGroup:aGroup values:values |
|
1029 | 586 |
"add a group of items at the end; |
587 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
588 |
||
1758 | 589 |
aGroup with:values do:[:item :value | |
590 |
item value:value |
|
940 | 591 |
]. |
1758 | 592 |
self addItemGroup:aGroup |
1029 | 593 |
|
594 |
"Modified: / 4.8.1998 / 17:32:18 / cg" |
|
940 | 595 |
! |
596 |
||
597 |
addItemGroupLabels:labels values:values |
|
1029 | 598 |
"add a group of items at the end; |
599 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
600 |
||
940 | 601 |
|items| |
602 |
||
603 |
items := labels with:values |
|
1029 | 604 |
collect:[:label :value | |
605 |
MenuItem label:label value:value |
|
606 |
]. |
|
940 | 607 |
self addItemGroup:items |
608 |
||
609 |
"Created: / 27.10.1997 / 19:49:27 / cg" |
|
1029 | 610 |
"Modified: / 4.8.1998 / 17:35:22 / cg" |
940 | 611 |
! |
612 |
||
613 |
addItemLabel:label value:value |
|
1029 | 614 |
"add an item at the end; |
615 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
940 | 616 |
|
1029 | 617 |
self addItem:(MenuItem label:label value:value) |
940 | 618 |
|
619 |
"Created: / 27.10.1997 / 19:47:12 / cg" |
|
1029 | 620 |
"Modified: / 4.8.1998 / 17:34:44 / cg" |
940 | 621 |
! |
622 |
||
1500 | 623 |
addSeparator |
624 |
"add a separating line item at the end; |
|
625 |
useful to build a menu programmatically (or, to add more items dynamically)" |
|
626 |
||
627 |
self addItem:(MenuItem new label:'-'). |
|
628 |
! |
|
629 |
||
940 | 630 |
removeItem:aMenuItem |
631 |
"remove an item from the menu" |
|
632 |
||
633 |
|idx| |
|
634 |
||
635 |
items notNil ifTrue:[ |
|
636 |
idx := items identityIndexOf:aMenuItem. |
|
637 |
idx ~~ 0 ifTrue:[ |
|
638 |
items removeAtIndex:idx |
|
639 |
] |
|
640 |
]. |
|
641 |
||
642 |
"Created: / 13.9.1997 / 10:27:31 / cg" |
|
643 |
"Modified: / 2.2.1998 / 13:26:49 / cg" |
|
644 |
! |
|
645 |
||
646 |
removeItemAt:anIndex |
|
647 |
"remove item at an index |
|
648 |
" |
|
649 |
anIndex <= items size ifTrue:[ |
|
650 |
^ items removeAtIndex:anIndex |
|
651 |
]. |
|
652 |
^ nil |
|
653 |
! ! |
|
654 |
||
451 | 655 |
!Menu methodsFor:'converting'! |
656 |
||
2081 | 657 |
asOldStylePopUpMenuFor:anApplicationOrNil |
2080 | 658 |
"a temporary kludge - will vanish, when oldStyle MenuView and PopUpMenu are gone" |
659 |
||
2081 | 660 |
|menuView itemsShown| |
661 |
||
662 |
itemsShown := items select:[:each | |
|
663 |
|visibilityInItem| |
|
664 |
||
665 |
visibilityInItem := each isVisible. |
|
666 |
visibilityInItem isNil ifTrue:[ |
|
667 |
true |
|
668 |
] ifFalse:[ |
|
669 |
visibilityInItem isBoolean ifTrue:[ |
|
670 |
visibilityInItem |
|
671 |
] ifFalse:[ |
|
672 |
visibilityInItem isSymbol ifTrue:[ |
|
673 |
(anApplicationOrNil perform:visibilityInItem) value. |
|
674 |
] ifFalse:[ |
|
675 |
visibilityInItem value |
|
676 |
]. |
|
677 |
]. |
|
678 |
]. |
|
679 |
]. |
|
2080 | 680 |
|
681 |
menuView := MenuView |
|
2081 | 682 |
labels:(itemsShown collect:[:each | each label]) |
683 |
selectors:(itemsShown collect:[:each | each value]) |
|
684 |
args:(itemsShown collect:[:each | each argument]) |
|
2080 | 685 |
receiver:receiver. |
686 |
||
2092 | 687 |
itemsShown doWithIndex:[:each :idx | |
2081 | 688 |
|enabledInItem enabled| |
689 |
||
690 |
enabledInItem := each enabled. |
|
691 |
enabledInItem notNil ifTrue:[ |
|
692 |
enabledInItem isSymbol ifTrue:[ |
|
693 |
enabled := (anApplicationOrNil perform:enabledInItem). |
|
694 |
] ifFalse:[ |
|
695 |
enabledInItem isBoolean ifTrue:[ |
|
696 |
enabled := enabledInItem |
|
697 |
]. |
|
698 |
]. |
|
699 |
enabled value ifFalse:[ |
|
2092 | 700 |
menuView disable:idx |
2081 | 701 |
]. |
702 |
]. |
|
703 |
]. |
|
704 |
||
2092 | 705 |
menuView actions:(itemsShown collect:[:each | [ receiver perform:each value ]]). |
2080 | 706 |
|
707 |
^ PopUpMenu forMenu:menuView |
|
708 |
! |
|
709 |
||
451 | 710 |
fromLiteralArrayEncoding:aLiteralEncodedArray |
711 |
"read my contents from a aLiteralEncodedArray" |
|
712 |
||
713 |
|items groups values| |
|
714 |
||
1620
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
715 |
items := aLiteralEncodedArray at:2. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
716 |
|
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
717 |
items ifNotNil:[ |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
718 |
items := items collect:[:item | item decodeAsLiteralArray]. |
bf72298c42bc
bug fixes; handle unspecified items in literalArrayEncoding
ca
parents:
1599
diff
changeset
|
719 |
]. |
1405
c7775c10e8fd
tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
720 |
groups := aLiteralEncodedArray at:3 ifAbsent:nil. |
c7775c10e8fd
tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
721 |
values := aLiteralEncodedArray at:4 ifAbsent:nil. |
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
722 |
self menuItems:items menuItemGroups:groups values:values. |
451 | 723 |
|
724 |
"extract from PD folder.st: |
|
725 |
#(#Menu #( |
|
1245 | 726 |
#(#MenuItem |
727 |
#rawLabel: 'left' |
|
728 |
#value: #left ) |
|
729 |
#(#MenuItem |
|
730 |
#rawLabel: 'center' |
|
731 |
#value: #center ) |
|
732 |
#(#MenuItem |
|
733 |
#rawLabel: 'right' |
|
734 |
#value: #right ) |
|
735 |
) |
|
736 |
#(3 ) |
|
737 |
nil |
|
451 | 738 |
) decodeAsLiteralArray |
739 |
" |
|
452 | 740 |
" |
741 |
#(#Menu #( |
|
1245 | 742 |
#(#MenuItem |
743 |
#label: 'Straighten Up' ) |
|
744 |
#(#MenuItem |
|
745 |
#label: 'Inspect' ) |
|
746 |
#(#MenuItem |
|
747 |
#label: 'Coredump' ) |
|
748 |
) |
|
749 |
#(3 ) |
|
750 |
#(#straightenUp #inspect #halt ) |
|
452 | 751 |
) decodeAsLiteralArray startUp |
752 |
" |
|
457 | 753 |
|
454 | 754 |
"extract from iconicBrowser.st: |
452 | 755 |
#(#Menu #( |
1245 | 756 |
#(#MenuItem |
757 |
#label: 'Straighten Up' ) |
|
758 |
#(#MenuItem |
|
759 |
#label: 'Inspect' ) |
|
760 |
#(#MenuItem |
|
761 |
#label: 'Coredump' ) |
|
762 |
) |
|
763 |
#(3 ) |
|
764 |
#(1 2 3 ) |
|
452 | 765 |
) decodeAsLiteralArray startUp |
766 |
" |
|
451 | 767 |
|
454 | 768 |
"extract from refactory213.st: |
769 |
#(#Menu #( |
|
1245 | 770 |
#(#MenuItem |
771 |
#label: 'File List' |
|
772 |
#accessCharacterPosition: 1 ) |
|
773 |
#(#MenuItem #label: 'File Editor...' |
|
774 |
#accessCharacterPosition: 6 ) |
|
775 |
#(#MenuItem #label: 'Refactoring Tool...' |
|
776 |
#accessCharacterPosition: 1 ) |
|
777 |
#(#MenuItem #label: 'Workspace' |
|
778 |
#accessCharacterPosition: 1 ) |
|
779 |
#(#MenuItem #label: 'New Canvas' |
|
780 |
#accessCharacterPosition: 1 ) |
|
781 |
#(#MenuItem #label: 'Palette' |
|
782 |
#accessCharacterPosition: 1 ) |
|
783 |
#(#MenuItem #label: 'Canvas Tool' |
|
784 |
#accessCharacterPosition: 1 ) |
|
785 |
#(#MenuItem #label: 'Image Editor' |
|
786 |
#accessCharacterPosition: 1 ) |
|
787 |
#(#MenuItem #label: 'Menu Editor' |
|
788 |
#accessCharacterPosition: 1 ) |
|
789 |
#(#MenuItem #label: 'Advanced' |
|
790 |
#accessCharacterPosition: 1 ) |
|
791 |
#(#MenuItem #label: 'DLL and C Connect' |
|
792 |
#accessCharacterPosition: 1 ) |
|
793 |
#(#MenuItem #label: 'System Transcript' |
|
794 |
#accessCharacterPosition: 8 ) |
|
795 |
) |
|
796 |
#(4 5 2 1 ) |
|
797 |
#(#openFileList #openFileEditor #openRefactoringTool #toolsNewWorkspace #toolsNewCanvas #toolsPalette #toolsCanvasTool #toolsMaskEditor #toolsMenuEditor nil #openExternalFinder #toggleSystemTranscript ) |
|
798 |
) decodeAsLiteralArray startUp |
|
454 | 799 |
" |
800 |
||
457 | 801 |
"submenus: |
802 |
#(#Menu #( |
|
1245 | 803 |
#(#MenuItem |
804 |
#label: 'Foo' |
|
805 |
#submenu: #(#Menu #( |
|
806 |
#(#MenuItem #label: 'foo 1') |
|
807 |
#(#MenuItem #label: 'foo 2') |
|
808 |
) |
|
809 |
nil |
|
810 |
#(11 22) |
|
811 |
) |
|
812 |
) |
|
813 |
#(#MenuItem |
|
814 |
#label: 'Inspect' ) |
|
815 |
#(#MenuItem |
|
816 |
#label: 'Coredump' ) |
|
817 |
) |
|
818 |
#(3 ) |
|
819 |
#(1 2 3 ) |
|
457 | 820 |
) decodeAsLiteralArray startUp |
821 |
" |
|
822 |
||
610
72dbf392e888
ST80 compatible inst creation method..
Claus Gittinger <cg@exept.de>
parents:
589
diff
changeset
|
823 |
"Modified: 20.6.1997 / 10:45:51 / cg" |
489 | 824 |
! |
825 |
||
826 |
literalArrayEncoding |
|
827 |
"return myself encoded as a literal array" |
|
828 |
||
1245 | 829 |
|coll array size| |
489 | 830 |
|
831 |
coll := OrderedCollection new. |
|
832 |
coll add:#Menu. |
|
1245 | 833 |
|
834 |
(size := items size) == 0 ifTrue:[ |
|
835 |
array := nil |
|
836 |
] ifFalse:[ |
|
837 |
array := Array new:size. |
|
838 |
items keysAndValuesDo:[:anIndex :anItem| |
|
839 |
array at:anIndex put:(anItem literalArrayEncoding) |
|
840 |
] |
|
841 |
]. |
|
842 |
coll add:array. |
|
843 |
||
844 |
(size := groupSizes size) == 0 ifTrue:[ |
|
845 |
array := nil |
|
846 |
] ifFalse:[ |
|
847 |
array := Array new:size. |
|
848 |
groupSizes keysAndValuesDo:[:anIndex :aSize| |
|
849 |
array at:anIndex put:(aSize literalArrayEncoding) |
|
850 |
] |
|
851 |
]. |
|
852 |
coll add:array. |
|
489 | 853 |
coll add:nil. |
579 | 854 |
^ coll asArray |
451 | 855 |
! ! |
856 |
||
584 | 857 |
!Menu methodsFor:'enumerating'! |
858 |
||
2494
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
859 |
allItemsDetect:aOneArgBlock ifNone:exceptionalValue |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
860 |
"find an element amongst each item and submenu items" |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
861 |
|
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
862 |
self itemsDo:[:anItem| |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
863 |
|sub subItem| |
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 |
(aOneArgBlock value:anItem) ifTrue:[^ anItem]. |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
866 |
(sub := anItem submenu) notNil ifTrue:[ |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
867 |
subItem := sub allItemsDetect:aOneArgBlock ifNone:nil. |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
868 |
subItem notNil ifTrue:[^ subItem]. |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
869 |
] |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
870 |
]. |
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
871 |
^ exceptionalValue value |
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 |
|
665 | 874 |
allItemsDo:aOneArgBlock |
875 |
"evaluate block on each item and submenu items |
|
876 |
" |
|
877 |
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
|
878 |
|sub| |
724 | 879 |
|
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
880 |
aOneArgBlock value:anItem. |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
881 |
(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
|
882 |
sub allItemsDo:aOneArgBlock |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
883 |
] |
665 | 884 |
] |
724 | 885 |
|
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
886 |
"Modified: / 19.6.1998 / 00:34:53 / cg" |
665 | 887 |
! |
888 |
||
940 | 889 |
detectItem:aBlock |
890 |
"evaluate the argument, aBlock for each item in the menu until the |
|
891 |
block returns true; in this case return the item which caused the |
|
892 |
true evaluation. |
|
893 |
If none of the evaluations returns true, return the result of the |
|
894 |
evaluation of the exceptionBlock |
|
895 |
" |
|
896 |
^ self detectItem:aBlock ifNone:[self errorNotFound] |
|
897 |
||
898 |
! |
|
899 |
||
900 |
detectItem:aBlock ifNone:exceptionBlock |
|
901 |
"evaluate the argument, aBlock for each item in the menu until the |
|
902 |
block returns true; in this case return the item which caused the |
|
903 |
true evaluation. |
|
904 |
If none of the evaluations returns true, return the result of the |
|
905 |
evaluation of the exceptionBlock |
|
906 |
" |
|
907 |
items notNil ifTrue:[ |
|
908 |
^ items detect:aBlock ifNone:exceptionBlock |
|
909 |
]. |
|
910 |
^ exceptionBlock value |
|
911 |
! |
|
912 |
||
589 | 913 |
itemsDo:aOneArgBlock |
914 |
"evaluate the block for each item in the current menu |
|
915 |
" |
|
916 |
items notNil ifTrue:[items do:aOneArgBlock] |
|
917 |
! |
|
918 |
||
584 | 919 |
menuAndSubmenusDetectItem:aOneArgBlock |
920 |
"evaluate the block for each item in the current menu and all |
|
921 |
submenus. In case that the block returns a non nil argument, |
|
922 |
the item will be returned |
|
923 |
" |
|
724 | 924 |
|item| |
584 | 925 |
|
926 |
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
|
927 |
items do:[:anItem| |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
928 |
|sub| |
724 | 929 |
|
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
930 |
(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
|
931 |
^ anItem |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
932 |
]. |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
933 |
(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
|
934 |
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
|
935 |
item notNil ifTrue:[ |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
936 |
^ item |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
937 |
] |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
938 |
] |
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
939 |
] |
584 | 940 |
]. |
724 | 941 |
^ nil |
942 |
||
972
09bc0765dbc1
no need to send submenu value - the item does it now.
Claus Gittinger <cg@exept.de>
parents:
950
diff
changeset
|
943 |
"Modified: / 19.6.1998 / 00:35:00 / cg" |
584 | 944 |
! ! |
945 |
||
672
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
946 |
!Menu methodsFor:'kludged fixes'! |
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
947 |
|
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
948 |
destroy |
1599 | 949 |
"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
|
950 |
|
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
951 |
"Created: 28.7.1997 / 10:16:52 / cg" |
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
952 |
! ! |
2db4bb41aa93
added dummy #destroy (q&d hack)
Claus Gittinger <cg@exept.de>
parents:
665
diff
changeset
|
953 |
|
584 | 954 |
!Menu methodsFor:'menu items'! |
955 |
||
2404 | 956 |
removeAllAccelerators |
957 |
self allItemsDo:[:eachItem | |
|
958 |
eachItem shortcutKey:nil. |
|
959 |
]. |
|
960 |
! |
|
961 |
||
740 | 962 |
someMenuItemLabeled:aLabel |
963 |
"get the menu item with that label; in case that the label |
|
964 |
is not found, nil is returned |
|
965 |
" |
|
966 |
^ self someMenuItemLabeled:aLabel ifNone:nil |
|
967 |
||
968 |
"Created: / 14.11.1997 / 20:55:17 / cg" |
|
969 |
! |
|
970 |
||
971 |
someMenuItemLabeled:aLabel ifNone:exceptionBlock |
|
972 |
"get the menu item labeled aLabel; in case that the value |
|
973 |
is not found, the given exceptionBlock is executed and its value returned |
|
974 |
" |
|
975 |
|item| |
|
976 |
||
977 |
item := self menuAndSubmenusDetectItem:[:anItem| anItem label = aLabel]. |
|
978 |
||
979 |
item notNil ifTrue:[ |
|
980 |
^ item |
|
981 |
]. |
|
982 |
^ exceptionBlock value |
|
983 |
||
984 |
"Created: / 14.11.1997 / 20:56:13 / cg" |
|
985 |
! |
|
986 |
||
584 | 987 |
someMenuItemWithValue:aValue |
988 |
"get the menu item assigned with the value; in case that the value |
|
989 |
is not found nil is returned |
|
990 |
" |
|
991 |
^ self someMenuItemWithValue:aValue ifNone:nil |
|
992 |
! |
|
993 |
||
994 |
someMenuItemWithValue:aValue ifNone:exceptionBlock |
|
995 |
"get the menu item assigned with the value; in case that the value |
|
996 |
is not found, the given exceptionBlock is executed and returned |
|
997 |
" |
|
998 |
|item| |
|
999 |
||
1000 |
item := self menuAndSubmenusDetectItem:[:anItem| anItem value == aValue]. |
|
1001 |
||
1002 |
item notNil ifTrue:[ |
|
740 | 1003 |
^ item |
584 | 1004 |
]. |
1005 |
^ exceptionBlock value |
|
1006 |
! ! |
|
1007 |
||
1008 |
!Menu methodsFor:'queries'! |
|
1009 |
||
724 | 1010 |
hasHiddenItems |
1011 |
"test whether any item is hidden" |
|
1012 |
||
1013 |
self allItemsDo:[:anItem| |
|
740 | 1014 |
anItem isHidden ifTrue:[^ true] |
724 | 1015 |
]. |
1016 |
^ false |
|
1017 |
||
1018 |
"Modified: / 27.10.1997 / 15:12:44 / cg" |
|
1019 |
! |
|
1020 |
||
584 | 1021 |
hasSubMenuAt:anIndex |
1022 |
"test whether the menu item at the given index has a submenu |
|
1023 |
" |
|
1024 |
^ (self menuItemAt:anIndex) hasSubmenu |
|
1025 |
! ! |
|
1026 |
||
451 | 1027 |
!Menu methodsFor:'startup'! |
1028 |
||
729 | 1029 |
show |
1030 |
"realize the menu at its last position; returns the value associated with the |
|
1031 |
selected item, 0 if none was selected" |
|
1032 |
||
1033 |
^ (MenuPanel menu:self) show ? 0 |
|
1034 |
||
1035 |
||
1036 |
! |
|
1037 |
||
1038 |
showAt:aPoint |
|
1039 |
"realize the menu at aPoint; returns the value associated with the |
|
1040 |
selected item, 0 if none was selected" |
|
1041 |
||
1042 |
^ self showAt:aPoint resizing:true |
|
1043 |
||
1044 |
||
1045 |
! |
|
1046 |
||
1047 |
showAt:aPoint resizing:aBoolean |
|
1048 |
"realize the menu at aPoint; returns the value associated with the |
|
451 | 1049 |
selected item, 0 if none was selected" |
1050 |
||
996
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1051 |
^ ((MenuPanel menu:self) showAt:aPoint resizing:aBoolean) ? 0 |
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1052 |
|
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1053 |
"Modified: / 8.7.1998 / 19:57:55 / cg" |
729 | 1054 |
! |
1055 |
||
1056 |
showAtPointer |
|
1057 |
"realize the menu at the current pointer position; returns the value associated with the |
|
1058 |
selected item, 0 if none was selected" |
|
1059 |
||
1060 |
^ self startUp |
|
1061 |
! |
|
457 | 1062 |
|
729 | 1063 |
showCenteredIn:aView |
1064 |
"realize the menu visible at the aView center; returns the value associated with the |
|
1065 |
selected item, 0 if none was selected" |
|
1066 |
||
996
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1067 |
^ ((MenuPanel menu:self) showCenteredIn:aView) ? 0 |
729 | 1068 |
|
996
1e10d01c90b8
careful: ? is a binary selector.
Claus Gittinger <cg@exept.de>
parents:
977
diff
changeset
|
1069 |
"Modified: / 8.7.1998 / 19:58:05 / cg" |
729 | 1070 |
! |
1071 |
||
1072 |
startUp |
|
1073 |
"display the menu as a popUp; returns the value associated with the |
|
2039 | 1074 |
selected item, nil if none was selected. |
1075 |
(should we return 0 form ST-80 compatibility ?)" |
|
729 | 1076 |
|
1367 | 1077 |
^ (MenuPanel menu:self) startUp "/ ? 0 |
451 | 1078 |
|
579 | 1079 |
" |
1367 | 1080 |
|m| |
579 | 1081 |
|
1367 | 1082 |
m := #(#Menu #( |
1083 |
#(#MenuItem |
|
1084 |
#rawLabel: 'left' |
|
1085 |
#value: #left ) |
|
1086 |
#(#MenuItem |
|
1087 |
#rawLabel: 'center' |
|
1088 |
#value: #center ) |
|
1089 |
#(#MenuItem |
|
1090 |
#rawLabel: 'right' |
|
1091 |
#value: #right ) ) |
|
1092 |
#(2) |
|
1093 |
nil |
|
1094 |
) decodeAsLiteralArray. |
|
451 | 1095 |
|
579 | 1096 |
Transcript showCR:(m startUp) |
1097 |
" |
|
938
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1098 |
! |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1099 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1100 |
startUpAt:aPoint |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1101 |
"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
|
1102 |
selected item, 0 if none was selected" |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1103 |
|
939 | 1104 |
^ ((MenuPanel menu:self) startUpAt:aPoint) ? 0 |
938
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1105 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1106 |
" |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1107 |
|m| |
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 |
m := #(#Menu #( |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1110 |
#(#MenuItem |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1111 |
#rawLabel: 'left' |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1112 |
#value: #left ) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1113 |
#(#MenuItem |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1114 |
#rawLabel: 'center' |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1115 |
#value: #center ) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1116 |
#(#MenuItem |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1117 |
#rawLabel: 'right' |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1118 |
#value: #right ) ) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1119 |
#(2) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1120 |
nil |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1121 |
) decodeAsLiteralArray. |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1122 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1123 |
Transcript showCR:(m startUpAt:100@100) |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1124 |
" |
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1125 |
|
dfa1b1666cfa
added #startUpAt: (MenuView compatibility)
Claus Gittinger <cg@exept.de>
parents:
900
diff
changeset
|
1126 |
"Created: / 21.5.1998 / 14:15:21 / cg" |
939 | 1127 |
"Modified: / 21.5.1998 / 14:17:46 / cg" |
1367 | 1128 |
! |
1129 |
||
1652 | 1130 |
startUpFor:originatingWidget |
1131 |
"display the menu as a popUp; returns the value associated with the |
|
2039 | 1132 |
selected item, nil if none was selected. |
1133 |
(should we return 0 for ST-80 compatibility ?)" |
|
1652 | 1134 |
|
1135 |
^ (MenuPanel menu:self) startUpFor:originatingWidget "/ ? 0 |
|
1136 |
||
1137 |
" |
|
1138 |
|m| |
|
1139 |
||
1140 |
m := #(#Menu #( |
|
1141 |
#(#MenuItem |
|
1142 |
#rawLabel: 'left' |
|
1143 |
#value: #left ) |
|
1144 |
#(#MenuItem |
|
1145 |
#rawLabel: 'center' |
|
1146 |
#value: #center ) |
|
1147 |
#(#MenuItem |
|
1148 |
#rawLabel: 'right' |
|
1149 |
#value: #right ) ) |
|
1150 |
#(2) |
|
1151 |
nil |
|
1152 |
) decodeAsLiteralArray. |
|
1153 |
||
1154 |
Transcript showCR:(m startUp) |
|
1155 |
" |
|
1156 |
! |
|
1157 |
||
1367 | 1158 |
startUpOrNil |
1159 |
"display the menu as a popUp; returns the value associated with the |
|
1160 |
selected item, nil if none was selected" |
|
1161 |
||
1405
c7775c10e8fd
tolerant literalDecoding (missing 2nd and 3rd elements);
Claus Gittinger <cg@exept.de>
parents:
1401
diff
changeset
|
1162 |
^ (MenuPanel menu:self) startUpOrNil |
451 | 1163 |
! ! |
1164 |
||
1165 |
!Menu class methodsFor:'documentation'! |
|
1166 |
||
1167 |
version |
|
2494
994b030ae562
new enumerator: allItemsDetect:ifNone:
Claus Gittinger <cg@exept.de>
parents:
2433
diff
changeset
|
1168 |
^ '$Header: /cvs/stx/stx/libview2/Menu.st,v 1.70 2008-06-05 17:13:20 cg Exp $' |
451 | 1169 |
! ! |