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