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