12 |
12 |
13 |
13 |
14 "{ Package: 'stx:libview2' }" |
14 "{ Package: 'stx:libview2' }" |
15 |
15 |
16 Object subclass:#MenuItem |
16 Object subclass:#MenuItem |
17 instanceVariableNames:'activeHelpKey enabled label value nameKey adornment |
17 instanceVariableNames:'activeHelpKey enabled label itemValue value nameKey |
18 translateLabel isButton startGroup isVisible hideMenuOnActivated |
18 translateLabel isButton startGroup isVisible hideMenuOnActivated |
19 triggerOnDown delayMenu' |
19 triggerOnDown delayMenu indication submenu submenuChannel |
|
20 shortcutKey labelImage accessCharacterPosition argument choice |
|
21 choiceValue font auxValue showBusyCursorWhilePerforming |
|
22 keepLinkedMenu horizontalLayout' |
20 classVariableNames:'' |
23 classVariableNames:'' |
21 poolDictionaries:'' |
24 poolDictionaries:'' |
22 category:'Views-Support' |
25 category:'Views-Support' |
23 ! |
|
24 |
|
25 Object subclass:#MenuItemAdornment |
|
26 instanceVariableNames:'color indication submenu submenuChannel shortcutKey labelText |
|
27 labelImage accessCharacterPosition argument choice choiceValue |
|
28 font auxValue showBusyCursorWhilePerforming keepLinkedMenu |
|
29 horizontalLayout' |
|
30 classVariableNames:'' |
|
31 poolDictionaries:'' |
|
32 privateIn:MenuItem |
|
33 ! |
26 ! |
34 |
27 |
35 !MenuItem class methodsFor:'documentation'! |
28 !MenuItem class methodsFor:'documentation'! |
36 |
29 |
37 copyright |
30 copyright |
155 arg := nil |
140 arg := nil |
156 ] |
141 ] |
157 ] |
142 ] |
158 ]. |
143 ]. |
159 |
144 |
160 (arg isNil and:[adornment isNil]) ifFalse:[ |
145 argument := arg |
161 self adornment argument:arg |
|
162 ] |
|
163 ! |
146 ! |
164 |
147 |
165 auxValue |
148 auxValue |
166 "an additional, arbitrary value" |
149 "an additional, arbitrary value" |
167 |
150 |
168 adornment notNil ifTrue:[ |
151 ^ auxValue |
169 ^ adornment auxValue |
|
170 ]. |
|
171 ^ nil |
|
172 ! |
152 ! |
173 |
153 |
174 auxValue:something |
154 auxValue:something |
175 "set the auxValue - an arbitrary user value |
155 "set the auxValue - an arbitrary user value |
176 " |
156 " |
177 (something notNil or:[adornment notNil]) ifTrue:[ |
157 auxValue := something |
178 self adornment auxValue:something |
158 ! |
179 ] |
159 |
180 |
160 choice:something |
181 "Modified: / 4.2.2000 / 12:38:44 / cg" |
161 "set the value of the instance variable 'choice' (automatically generated)" |
|
162 |
|
163 choice := something. |
|
164 |
|
165 "Created: / 14.8.1998 / 14:32:06 / cg" |
|
166 ! |
|
167 |
|
168 choiceValue |
|
169 "return the value of the instance variable 'choiceValue' (automatically generated)" |
|
170 |
|
171 ^ choiceValue |
|
172 |
|
173 "Created: / 14.8.1998 / 15:39:26 / cg" |
|
174 ! |
|
175 |
|
176 choiceValue:something |
|
177 "set the value of the instance variable 'choiceValue' (automatically generated)" |
|
178 |
|
179 choiceValue := something. |
|
180 |
|
181 "Created: / 14.8.1998 / 15:39:26 / cg" |
|
182 ! |
|
183 |
|
184 font |
|
185 "get the specific font for an item or nil |
|
186 " |
|
187 ^ font |
|
188 ! |
|
189 |
|
190 font:aFont |
|
191 "set a specific font for an item |
|
192 " |
|
193 font := aFont. |
|
194 ! |
|
195 |
|
196 horizontalLayout |
|
197 "on default submenus has a vertical layout; |
|
198 true, the submenu has a horizontal layout. |
|
199 " |
|
200 ^ horizontalLayout |
|
201 ! |
|
202 |
|
203 horizontalLayout:aBoolean |
|
204 "on default submenus has a vertical layout; |
|
205 true, the submenu has a horizontal layout. |
|
206 " |
|
207 horizontalLayout := aBoolean. |
|
208 ! |
|
209 |
|
210 indication |
|
211 "test whether the menu item has an on/off indicator (CheckToggle) |
|
212 " |
|
213 ^ indication |
|
214 |
|
215 "Created: 25.2.1997 / 20:59:28 / cg" |
|
216 ! |
|
217 |
|
218 indication:something |
|
219 "test whether the menu item has an on/off indicator (CheckToggle) |
|
220 " |
|
221 indication := something. |
|
222 |
|
223 "Created: 25.2.1997 / 20:59:28 / cg" |
182 ! |
224 ! |
183 |
225 |
184 isVisible |
226 isVisible |
185 ^ isVisible ? true |
227 ^ isVisible ? true |
186 ! |
228 ! |
187 |
229 |
188 isVisible:something |
230 isVisible:something |
189 isVisible := something |
231 isVisible := something |
190 ! |
232 ! |
191 |
233 |
|
234 itemValue |
|
235 ^ itemValue |
|
236 |
|
237 "Created: 25.2.1997 / 19:50:14 / cg" |
|
238 ! |
|
239 |
|
240 itemValue:something |
|
241 itemValue := something |
|
242 |
|
243 "Created: 25.2.1997 / 19:11:13 / cg" |
|
244 ! |
|
245 |
192 keepLinkedMenu |
246 keepLinkedMenu |
193 "an additional, arbitrary value" |
247 "return the value of the instance variable 'keepLinkedMenu' (automatically generated)" |
194 |
248 |
195 adornment notNil ifTrue:[ |
249 ^ keepLinkedMenu ? false |
196 ^ adornment keepLinkedMenu |
|
197 ]. |
|
198 ^ false |
|
199 ! |
250 ! |
200 |
251 |
201 keepLinkedMenu:aBoolean |
252 keepLinkedMenu:aBoolean |
202 "set the keepLinkedMenu |
253 "set the value of the instance variable 'keepLinkedMenu' (automatically generated)" |
203 " |
254 |
204 adornment notNil ifTrue:[ |
255 keepLinkedMenu := aBoolean ? false. |
205 adornment keepLinkedMenu:aBoolean. |
256 ! |
206 ] ifFalse:[ |
257 |
207 aBoolean == true ifTrue:[ |
258 labelImage |
208 "/ the default is false |
259 "return the value of the instance variable 'labelImage' (automatically generated)" |
209 self adornment keepLinkedMenu:true |
260 |
210 ] |
261 ^ labelImage |
211 ]. |
262 ! |
|
263 |
|
264 labelImage:something |
|
265 "set the value of the instance variable 'labelImage' (automatically generated)" |
|
266 |
|
267 labelImage := something. |
212 ! |
268 ! |
213 |
269 |
214 nameKey |
270 nameKey |
215 ^ nameKey |
271 ^ nameKey |
216 |
272 |
236 ! |
292 ! |
237 |
293 |
238 resourceRetriever |
294 resourceRetriever |
239 |retriever| |
295 |retriever| |
240 |
296 |
241 adornment ifNotNil:[ |
297 retriever := labelImage. |
242 retriever := adornment labelImage. |
298 (retriever notNil and:[retriever isKindOf:ResourceRetriever]) ifTrue:[ |
243 |
299 ^ retriever |
244 (retriever notNil and:[retriever isKindOf:ResourceRetriever]) ifTrue:[ |
300 ]. |
245 ^ retriever |
301 ^ nil |
|
302 ! |
|
303 |
|
304 resourceRetriever:aRetriever |
|
305 self labelImage:aRetriever |
|
306 ! |
|
307 |
|
308 shortcutKeyCharacter |
|
309 "get the key to press to select the menu item from the keyboard |
|
310 " |
|
311 ^ shortcutKey |
|
312 ! |
|
313 |
|
314 shortcutKeyCharacter:something |
|
315 "set the key to press to select the menu item from the keyboard |
|
316 " |
|
317 shortcutKey := something. |
|
318 ! |
|
319 |
|
320 showBusyCursorWhilePerforming |
|
321 "get the flag which controls if a busy cursor is to be shown |
|
322 while performing the menu action. Defaults to false." |
|
323 |
|
324 ^ showBusyCursorWhilePerforming ? false |
|
325 |
|
326 ! |
|
327 |
|
328 showBusyCursorWhilePerforming:aBoolean |
|
329 "set/clear the flag which controls if a busy cursor is to be shown |
|
330 while performing the menu action. Defaults to false." |
|
331 |
|
332 showBusyCursorWhilePerforming := aBoolean |
|
333 |
|
334 ! |
|
335 |
|
336 submenu |
|
337 "get the submenu or nil |
|
338 " |
|
339 ^ submenu value |
|
340 |
|
341 "Created: / 25.2.1997 / 20:59:28 / cg" |
|
342 "Modified: / 19.6.1998 / 00:33:58 / cg" |
|
343 ! |
|
344 |
|
345 submenu:something |
|
346 "set the submenu or nil |
|
347 " |
|
348 (something isValueModel or:[something isBlock]) ifTrue:[ |
|
349 submenuChannel notNil ifTrue:[ |
|
350 "/ programmers error ? |
|
351 "/ how can I decide which one to use if there is both |
|
352 "/ a channel and a subMenu ... |
|
353 self halt:'overwriting submenuchannel'. |
246 ]. |
354 ]. |
247 ]. |
355 submenuChannel := something |
248 ^ nil |
356 ] ifFalse:[ |
249 ! |
357 submenu := something. |
250 |
|
251 resourceRetriever:aRetriever |
|
252 (aRetriever notNil or:[adornment notNil]) ifTrue:[ |
|
253 self adornment labelImage:aRetriever |
|
254 ]. |
|
255 ! |
|
256 |
|
257 shortcutKeyCharacter |
|
258 "ignored for now" |
|
259 |
|
260 adornment notNil ifTrue:[ |
|
261 ^ adornment shortcutKeyCharacter |
|
262 ]. |
|
263 ^ nil |
|
264 ! |
|
265 |
|
266 shortcutKeyCharacter:aKey |
|
267 "set the key to press to select the menu item from the keyboard |
|
268 " |
|
269 (aKey notNil or:[adornment notNil]) ifTrue:[ |
|
270 self adornment shortcutKeyCharacter:aKey |
|
271 ] |
358 ] |
272 |
359 |
273 "Modified: / 4.2.2000 / 12:39:30 / cg" |
360 "Created: / 25.2.1997 / 20:59:28 / cg" |
274 ! |
361 "Modified: / 5.2.2000 / 16:53:28 / cg" |
275 |
|
276 submenu |
|
277 adornment notNil ifTrue:[ |
|
278 ^ adornment submenu |
|
279 ]. |
|
280 ^ nil |
|
281 |
|
282 "Created: 25.2.1997 / 20:57:24 / cg" |
|
283 ! |
|
284 |
|
285 submenu:aMenu |
|
286 (aMenu notNil or:[adornment notNil]) ifTrue:[ |
|
287 self adornment submenu:aMenu |
|
288 ] |
|
289 |
|
290 "Created: / 25.2.1997 / 20:56:20 / cg" |
|
291 "Modified: / 4.2.2000 / 12:40:02 / cg" |
|
292 ! |
362 ! |
293 |
363 |
294 submenuChannel |
364 submenuChannel |
295 adornment notNil ifTrue:[ |
365 "get the submenuChannel or nil |
296 ^ adornment submenuChannel |
366 " |
297 ]. |
367 ^ submenuChannel |
298 ^ nil |
|
299 ! |
368 ! |
300 |
369 |
301 submenuChannel:something |
370 submenuChannel:something |
302 (something notNil or:[adornment notNil]) ifTrue:[ |
371 "set the submenuChannel or nil |
303 self adornment submenuChannel:something |
372 " |
304 ] |
373 submenuChannel := something. |
305 |
|
306 "Modified: / 4.2.2000 / 12:40:19 / cg" |
|
307 ! |
374 ! |
308 |
375 |
309 value |
376 value |
310 ^ value |
377 self halt. |
|
378 ^ itemValue |
311 |
379 |
312 "Created: 25.2.1997 / 19:50:14 / cg" |
380 "Created: 25.2.1997 / 19:50:14 / cg" |
313 ! |
381 ! |
314 |
382 |
315 value:something |
383 value:something |
316 value := something |
384 itemValue := something |
317 |
385 |
318 "Created: 25.2.1997 / 19:11:13 / cg" |
386 "Created: 25.2.1997 / 19:11:13 / cg" |
319 ! ! |
387 ! ! |
320 |
388 |
321 !MenuItem methodsFor:'accessing-behavior'! |
389 !MenuItem methodsFor:'accessing-behavior'! |
333 ! |
401 ! |
334 |
402 |
335 choice |
403 choice |
336 "return the menu items choice indicator (RadioButton) |
404 "return the menu items choice indicator (RadioButton) |
337 " |
405 " |
338 adornment notNil ifTrue:[ |
406 ^ choice |
339 ^ adornment choice |
|
340 ]. |
|
341 ^ nil |
|
342 |
407 |
343 "Created: / 14.8.1998 / 14:34:55 / cg" |
408 "Created: / 14.8.1998 / 14:34:55 / cg" |
344 "Modified: / 14.8.1998 / 15:11:57 / cg" |
409 "Modified: / 14.8.1998 / 15:11:57 / cg" |
345 ! |
|
346 |
|
347 choice:aChoice |
|
348 "set the menu items choice indicator (RadioButton) |
|
349 " |
|
350 (aChoice notNil or:[adornment notNil]) ifTrue:[ |
|
351 self adornment choice:aChoice. |
|
352 ]. |
|
353 |
|
354 "Created: / 14.8.1998 / 15:11:17 / cg" |
|
355 ! |
|
356 |
|
357 choiceValue |
|
358 "return the menu items choiceValue (RadioButton) |
|
359 " |
|
360 adornment notNil ifTrue:[ |
|
361 ^ adornment choiceValue |
|
362 ]. |
|
363 ^ nil |
|
364 |
|
365 "Modified: / 14.8.1998 / 15:11:57 / cg" |
|
366 "Created: / 14.8.1998 / 15:38:05 / cg" |
|
367 ! |
|
368 |
|
369 choiceValue:something |
|
370 "set the menu items choiceValue (RadioButton) |
|
371 " |
|
372 (something notNil or:[adornment notNil]) ifTrue:[ |
|
373 self adornment choiceValue:something. |
|
374 ]. |
|
375 |
|
376 "Created: / 14.8.1998 / 15:39:12 / cg" |
|
377 ! |
410 ! |
378 |
411 |
379 delayMenu |
412 delayMenu |
380 "return true, the menu is shown delayed, if the button is still pressed after a while. |
413 "return true, the menu is shown delayed, if the button is still pressed after a while. |
381 Only useful with buttons in non-popup-menus |
414 Only useful with buttons in non-popup-menus |
426 " |
459 " |
427 hideMenuOnActivated := aBool ? true |
460 hideMenuOnActivated := aBool ? true |
428 |
461 |
429 ! |
462 ! |
430 |
463 |
431 indication |
|
432 "return the menu items on/off indicator (CheckToggle) |
|
433 " |
|
434 adornment notNil ifTrue:[ |
|
435 ^ adornment indication |
|
436 ]. |
|
437 ^ nil |
|
438 |
|
439 "Modified: / 14.8.1998 / 15:11:37 / cg" |
|
440 ! |
|
441 |
|
442 indication:anIndication |
|
443 "set the menu items an on/off indicator (CheckToggle) |
|
444 " |
|
445 (anIndication notNil or:[adornment notNil]) ifTrue:[ |
|
446 self adornment indication:anIndication. |
|
447 ]. |
|
448 |
|
449 "Modified: / 14.8.1998 / 15:11:25 / cg" |
|
450 ! |
|
451 |
|
452 showBusyCursorWhilePerforming |
|
453 "get the flag which controls if a busy cursor is to be shown |
|
454 while performing the menu action. Defaults to false." |
|
455 |
|
456 adornment notNil ifTrue:[ |
|
457 ^ adornment showBusyCursorWhilePerforming |
|
458 ]. |
|
459 ^ nil |
|
460 ! |
|
461 |
|
462 showBusyCursorWhilePerforming:aBoolean |
|
463 "set/clear the flag which controls if a busy cursor is to be shown |
|
464 while performing the menu action. Defaults to false." |
|
465 |
|
466 ((aBoolean == true) or:[adornment notNil]) ifTrue:[ |
|
467 self adornment showBusyCursorWhilePerforming:aBoolean |
|
468 ] |
|
469 ! |
|
470 |
|
471 translateLabel |
464 translateLabel |
472 "returns whether label is translated |
465 "returns whether label is translated |
473 " |
466 " |
474 ^translateLabel ? false |
467 ^translateLabel ? false |
475 |
468 |
497 triggerOnDown := aBool. |
490 triggerOnDown := aBool. |
498 ! ! |
491 ! ! |
499 |
492 |
500 !MenuItem methodsFor:'accessing-look'! |
493 !MenuItem methodsFor:'accessing-look'! |
501 |
494 |
502 font |
495 icon:anImage |
503 "get the specific font for an item or nil |
496 self resourceRetriever: (ResourceRetriever icon:anImage) |
504 " |
|
505 adornment notNil ifTrue:[ |
|
506 ^ adornment font |
|
507 ]. |
|
508 ^ nil |
|
509 ! |
|
510 |
|
511 font:aFont |
|
512 "set the index of the access character in the label text or string, or nil if none |
|
513 " |
|
514 |
|
515 (aFont isNil and:[adornment isNil]) ifFalse:[ |
|
516 self adornment font:aFont |
|
517 ] |
|
518 ! |
|
519 |
|
520 horizontalLayout |
|
521 "on default submenus has a vertical layout; |
|
522 true, the submenu has a horizontal layout. |
|
523 " |
|
524 adornment notNil ifTrue:[ |
|
525 ^ adornment horizontalLayout |
|
526 ]. |
|
527 ^ nil |
|
528 ! |
|
529 |
|
530 horizontalLayout:aBoolean |
|
531 "on default submenus has a vertical layout; |
|
532 true, the submenu has a horizontal layout. |
|
533 " |
|
534 ((aBoolean == true) or:[adornment notNil]) ifTrue:[ |
|
535 self adornment horizontalLayout:aBoolean |
|
536 ]. |
|
537 ! |
497 ! |
538 |
498 |
539 isButton |
499 isButton |
540 "returns whether item looks like a Button |
500 "returns whether item looks like a Button |
541 " |
501 " |
610 ! |
558 ! |
611 |
559 |
612 findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil |
560 findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil |
613 "setup a resource container |
561 "setup a resource container |
614 " |
562 " |
615 |lblImg m| |
563 |retriever m| |
616 |
564 |
617 self translateLabel ifTrue:[ |
565 self translateLabel ifTrue:[ |
618 label := ResourceRetriever |
566 label := ResourceRetriever |
619 findResourceLabel:label |
567 findResourceLabel:label |
620 in:aResourceContainerOrApplication |
568 in:aResourceContainerOrApplication |
621 rememberResourcesIn:aValueHolderOrNil |
569 rememberResourcesIn:aValueHolderOrNil |
622 ]. |
570 ]. |
623 |
571 |
624 adornment notNil ifTrue:[ |
572 (retriever := self resourceRetriever) notNil ifTrue:[ |
625 (lblImg := adornment labelImage) notNil ifTrue:[ |
573 retriever findGuiResourcesIn:aResourceContainerOrApplication. |
626 lblImg findGuiResourcesIn:aResourceContainerOrApplication. |
574 retriever labelText notNil ifTrue: [retriever labelText: label]. |
627 lblImg labelText notNil ifTrue: [lblImg labelText: label]. |
575 ]. |
628 ]. |
576 (m := self submenu) notNil ifTrue:[ |
629 (m := adornment submenu) notNil ifTrue:[ |
577 m := m value. |
630 m := m value. |
578 m notNil ifTrue:[ |
631 m notNil ifTrue:[ |
579 m findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil |
632 m findGuiResourcesIn:aResourceContainerOrApplication rememberResourcesIn:aValueHolderOrNil |
580 ] |
633 ] |
581 ] |
|
582 |
|
583 "Modified: / 18.6.1998 / 16:54:25 / cg" |
|
584 ! ! |
|
585 |
|
586 !MenuItem methodsFor:'converting'! |
|
587 |
|
588 literalArrayEncoding |
|
589 "return myself encoded as a literal array" |
|
590 |
|
591 |coll something| |
|
592 |
|
593 coll := OrderedCollection new. |
|
594 coll add:#MenuItem. |
|
595 |
|
596 label notNil ifTrue:[ |
|
597 coll add:#label: ; add:(label literalArrayEncoding) |
|
598 ]. |
|
599 self translateLabel ifTrue:[ |
|
600 coll add:#translateLabel: ; add:true |
|
601 ]. |
|
602 self isButton ifTrue:[ |
|
603 coll add:#isButton:; add:true |
|
604 ]. |
|
605 |
|
606 triggerOnDown == true ifTrue:[ |
|
607 coll add:#triggerOnDown: ; add:triggerOnDown |
|
608 ]. |
|
609 hideMenuOnActivated == false ifTrue:[ |
|
610 coll add:#hideMenuOnActivated: ; add:hideMenuOnActivated |
|
611 ]. |
|
612 nameKey notNil ifTrue:[ |
|
613 coll add:#nameKey: ; add:(nameKey literalArrayEncoding) |
|
614 ]. |
|
615 isVisible notNil ifTrue:[ |
|
616 isVisible ~~ true ifTrue:[ |
|
617 coll add:#isVisible: ; add:(isVisible literalArrayEncoding) |
|
618 ] |
|
619 ]. |
|
620 (startGroup notNil and:[startGroup ~~ #left]) ifTrue:[ |
|
621 coll add:#startGroup: ; add:(startGroup literalArrayEncoding) |
|
622 ]. |
|
623 |
|
624 value notNil ifTrue:[ |
|
625 coll add:#value: ; add:(value literalArrayEncoding). |
|
626 ]. |
|
627 activeHelpKey notNil ifTrue:[ |
|
628 coll add:#activeHelpKey: ; add:(activeHelpKey literalArrayEncoding). |
|
629 ]. |
|
630 (something := self enabled) notNil ifTrue:[ |
|
631 coll add:#enabled: ; add:(enabled literalArrayEncoding). |
|
632 ]. |
|
633 |
|
634 (something := self shortcutKeyCharacter) notNil ifTrue:[ |
|
635 coll add:#shortcutKeyCharacter: ; add:(something literalArrayEncoding) |
|
636 ]. |
|
637 (something := self font) notNil ifTrue:[ |
|
638 coll add:#font: ; add:(something literalArrayEncoding) |
|
639 ]. |
|
640 |
|
641 (something := self accessCharacterPosition) notNil ifTrue:[ |
|
642 coll add:#accessCharacterPosition: ; add:(something literalArrayEncoding) |
|
643 ]. |
|
644 |
|
645 (something := self horizontalLayout) == true ifTrue:[ |
|
646 coll add:#horizontalLayout: ; add:(something literalArrayEncoding) |
|
647 ]. |
|
648 |
|
649 (something := self showBusyCursorWhilePerforming) == true ifTrue:[ |
|
650 coll add:#showBusyCursorWhilePerforming: ; add:(something literalArrayEncoding) |
|
651 ]. |
|
652 |
|
653 (something := self argument) notNil ifTrue:[ |
|
654 "/ coll add:#argument: ; add:(something literalArrayEncoding) -- cg: wrong - see decoder part. |
|
655 something class == Array ifTrue:[ |
|
656 coll add:#argument: ; add:(something collect:[:each | each literalArrayEncoding]). |
|
657 ] ifFalse:[ |
|
658 coll add:#argument: ; add:(something literalArrayEncoding) |
|
659 ] |
|
660 ]. |
|
661 |
|
662 (something := self resourceRetriever) notNil ifTrue:[ |
|
663 "/ ParcPlace stores the ResourceRetriever under the labelImage key. |
|
664 coll add:#resourceRetriever: ; add:(something literalArrayEncoding) |
|
665 ]. |
|
666 |
|
667 (something := self indication) notNil ifTrue:[ |
|
668 coll add:#indication: ; add:(something literalArrayEncoding) |
|
669 ]. |
|
670 (something := self choice) notNil ifTrue:[ |
|
671 coll add:#choice: ; add:(something literalArrayEncoding). |
|
672 |
|
673 (something := self choiceValue) notNil ifTrue:[ |
|
674 coll add:#choiceValue: ; add:(something literalArrayEncoding) |
634 ]. |
675 ]. |
635 ] |
676 ]. |
636 |
677 (something := self auxValue) notNil ifTrue:[ |
637 "Modified: / 18.6.1998 / 16:54:25 / cg" |
678 coll add:#auxValue: ; add:(something literalArrayEncoding) |
638 ! ! |
679 ]. |
639 |
680 |
640 !MenuItem methodsFor:'converting'! |
681 (something := self submenuChannel) notNil ifTrue:[ |
|
682 coll add:#submenuChannel: ; add:(something literalArrayEncoding). |
|
683 |
|
684 (something := self keepLinkedMenu) ifTrue:[ |
|
685 coll add:#keepLinkedMenu: ; add:true |
|
686 ] |
|
687 ]. |
|
688 |
|
689 self hasSubmenu ifTrue:[ |
|
690 coll add:#submenu:; add:(self submenu literalArrayEncoding) |
|
691 ]. |
|
692 |
|
693 ^ coll asArray |
|
694 |
|
695 "Modified: / 14.8.1998 / 15:44:53 / cg" |
|
696 ! ! |
|
697 |
|
698 !MenuItem methodsFor:'encoding & decoding'! |
641 |
699 |
642 fromLiteralArrayEncoding:aLiteralEncodedArray |
700 fromLiteralArrayEncoding:aLiteralEncodedArray |
643 "read my contents from a aLiteralEncodedArray" |
701 "read my contents from a aLiteralEncodedArray" |
644 |
702 |
645 |selector value| |
703 |selector value| |
657 #( #MenuItem #rawLabel: 'left' #nameKey: 'identifier' #value: #left ) |
715 #( #MenuItem #rawLabel: 'left' #nameKey: 'identifier' #value: #left ) |
658 decodeAsLiteralArray |
716 decodeAsLiteralArray |
659 " |
717 " |
660 |
718 |
661 "Modified: / 4.2.2000 / 12:50:28 / cg" |
719 "Modified: / 4.2.2000 / 12:50:28 / cg" |
662 ! |
|
663 |
|
664 literalArrayEncoding |
|
665 "return myself encoded as a literal array" |
|
666 |
|
667 |coll something| |
|
668 |
|
669 coll := OrderedCollection new. |
|
670 coll add:#MenuItem. |
|
671 |
|
672 label notNil ifTrue:[ |
|
673 coll add:#label: ; add:(label literalArrayEncoding) |
|
674 ]. |
|
675 self translateLabel ifTrue:[ |
|
676 coll add:#translateLabel: ; add:true |
|
677 ]. |
|
678 self isButton ifTrue:[ |
|
679 coll add:#isButton:; add:true |
|
680 ]. |
|
681 |
|
682 triggerOnDown == true ifTrue:[ |
|
683 coll add:#triggerOnDown: ; add:triggerOnDown |
|
684 ]. |
|
685 hideMenuOnActivated == false ifTrue:[ |
|
686 coll add:#hideMenuOnActivated: ; add:hideMenuOnActivated |
|
687 ]. |
|
688 nameKey notNil ifTrue:[ |
|
689 coll add:#nameKey: ; add:(nameKey literalArrayEncoding) |
|
690 ]. |
|
691 isVisible notNil ifTrue:[ |
|
692 isVisible ~~ true ifTrue:[ |
|
693 coll add:#isVisible: ; add:(isVisible literalArrayEncoding) |
|
694 ] |
|
695 ]. |
|
696 (startGroup notNil and:[startGroup ~~ #left]) ifTrue:[ |
|
697 coll add:#startGroup: ; add:(startGroup literalArrayEncoding) |
|
698 ]. |
|
699 |
|
700 value notNil ifTrue:[ |
|
701 coll add:#value: ; add:(value literalArrayEncoding). |
|
702 ]. |
|
703 activeHelpKey notNil ifTrue:[ |
|
704 coll add:#activeHelpKey: ; add:(activeHelpKey literalArrayEncoding). |
|
705 ]. |
|
706 (something := self enabled) notNil ifTrue:[ |
|
707 coll add:#enabled: ; add:(enabled literalArrayEncoding). |
|
708 ]. |
|
709 |
|
710 adornment notNil ifTrue:[ |
|
711 (something := self shortcutKeyCharacter) notNil ifTrue:[ |
|
712 coll add:#shortcutKeyCharacter: ; add:(something literalArrayEncoding) |
|
713 ]. |
|
714 (something := self font) notNil ifTrue:[ |
|
715 coll add:#font: ; add:(something literalArrayEncoding) |
|
716 ]. |
|
717 |
|
718 (something := self accessCharacterPosition) notNil ifTrue:[ |
|
719 coll add:#accessCharacterPosition: ; add:(something literalArrayEncoding) |
|
720 ]. |
|
721 |
|
722 (something := self horizontalLayout) == true ifTrue:[ |
|
723 coll add:#horizontalLayout: ; add:(something literalArrayEncoding) |
|
724 ]. |
|
725 |
|
726 (something := self showBusyCursorWhilePerforming) == true ifTrue:[ |
|
727 coll add:#showBusyCursorWhilePerforming: ; add:(something literalArrayEncoding) |
|
728 ]. |
|
729 |
|
730 (something := self argument) notNil ifTrue:[ |
|
731 "/ coll add:#argument: ; add:(something literalArrayEncoding) -- cg: wrong - see decoder part. |
|
732 something class == Array ifTrue:[ |
|
733 coll add:#argument: ; add:(something collect:[:each | each literalArrayEncoding]). |
|
734 ] ifFalse:[ |
|
735 coll add:#argument: ; add:(something literalArrayEncoding) |
|
736 ] |
|
737 ]. |
|
738 |
|
739 adornment labelImage notNil ifTrue:[ |
|
740 coll add:#labelImage: ; add:(adornment labelImage literalArrayEncoding) |
|
741 ]. |
|
742 (something := self indication) notNil ifTrue:[ |
|
743 coll add:#indication: ; add:(something literalArrayEncoding) |
|
744 ]. |
|
745 (something := self choice) notNil ifTrue:[ |
|
746 coll add:#choice: ; add:(something literalArrayEncoding). |
|
747 |
|
748 (something := self choiceValue) notNil ifTrue:[ |
|
749 coll add:#choiceValue: ; add:(something literalArrayEncoding) |
|
750 ]. |
|
751 ]. |
|
752 (something := self auxValue) notNil ifTrue:[ |
|
753 coll add:#auxValue: ; add:(something literalArrayEncoding) |
|
754 ]. |
|
755 |
|
756 (something := self submenuChannel) notNil ifTrue:[ |
|
757 coll add:#submenuChannel: ; add:(something literalArrayEncoding). |
|
758 |
|
759 (something := self keepLinkedMenu) ifTrue:[ |
|
760 coll add:#keepLinkedMenu: ; add:true |
|
761 ] |
|
762 ]. |
|
763 |
|
764 self hasSubmenu ifTrue:[ |
|
765 coll add:#submenu:; add:(self submenu literalArrayEncoding) |
|
766 ]. |
|
767 ]. |
|
768 |
|
769 ^ coll asArray |
|
770 |
|
771 "Modified: / 14.8.1998 / 15:44:53 / cg" |
|
772 ! ! |
720 ! ! |
773 |
721 |
774 !MenuItem methodsFor:'printing & storing'! |
722 !MenuItem methodsFor:'printing & storing'! |
775 |
723 |
776 displayString |
724 displayString |
777 ^ self classNameWithArticle , '(' , label storeString , ')' |
725 ^ self classNameWithArticle , '(' , label storeString , ')' |
778 ! ! |
726 ! ! |
779 |
727 |
780 !MenuItem methodsFor:'private - accessing'! |
728 !MenuItem methodsFor:'private - accessing'! |
781 |
|
782 adornment |
|
783 adornment isNil ifTrue:[ |
|
784 adornment := MenuItemAdornment new |
|
785 ]. |
|
786 ^ adornment |
|
787 |
|
788 "Created: 25.2.1997 / 20:57:05 / cg" |
|
789 ! |
|
790 |
729 |
791 filteredLabel |
730 filteredLabel |
792 "return the label without any &-chars" |
731 "return the label without any &-chars" |
793 |
732 |
794 |rawLabel l in out c pos emp e| |
733 |rawLabel l in out c pos emp e| |
885 |
824 |
886 indication := self indication. |
825 indication := self indication. |
887 ^ indication value == true |
826 ^ indication value == true |
888 ! ! |
827 ! ! |
889 |
828 |
890 !MenuItem::MenuItemAdornment methodsFor:'accessing'! |
|
891 |
|
892 accessCharacterPosition |
|
893 "return the value of the instance variable 'accessCharacterPosition' (automatically generated)" |
|
894 |
|
895 ^ accessCharacterPosition |
|
896 ! |
|
897 |
|
898 accessCharacterPosition:something |
|
899 "set the value of the instance variable 'accessCharacterPosition' (automatically generated)" |
|
900 |
|
901 accessCharacterPosition := something. |
|
902 ! |
|
903 |
|
904 argument |
|
905 "return the value of the instance variable 'argument' (automatically generated)" |
|
906 |
|
907 ^ argument |
|
908 |
|
909 "Created: 25.2.1997 / 20:59:28 / cg" |
|
910 ! |
|
911 |
|
912 argument:something |
|
913 "set the value of the instance variable 'argument' (automatically generated)" |
|
914 |
|
915 argument := something. |
|
916 |
|
917 "Created: 25.2.1997 / 20:59:28 / cg" |
|
918 ! |
|
919 |
|
920 auxValue |
|
921 "return the value of the instance variable 'auxValue' (automatically generated)" |
|
922 |
|
923 ^ auxValue |
|
924 ! |
|
925 |
|
926 auxValue:something |
|
927 "set the value of the instance variable 'auxValue' (automatically generated)" |
|
928 |
|
929 auxValue := something. |
|
930 ! |
|
931 |
|
932 choice |
|
933 "return the value of the instance variable 'choice' (automatically generated)" |
|
934 |
|
935 ^ choice |
|
936 |
|
937 "Created: / 14.8.1998 / 14:32:06 / cg" |
|
938 ! |
|
939 |
|
940 choice:something |
|
941 "set the value of the instance variable 'choice' (automatically generated)" |
|
942 |
|
943 choice := something. |
|
944 |
|
945 "Created: / 14.8.1998 / 14:32:06 / cg" |
|
946 ! |
|
947 |
|
948 choiceValue |
|
949 "return the value of the instance variable 'choiceValue' (automatically generated)" |
|
950 |
|
951 ^ choiceValue |
|
952 |
|
953 "Created: / 14.8.1998 / 15:39:26 / cg" |
|
954 ! |
|
955 |
|
956 choiceValue:something |
|
957 "set the value of the instance variable 'choiceValue' (automatically generated)" |
|
958 |
|
959 choiceValue := something. |
|
960 |
|
961 "Created: / 14.8.1998 / 15:39:26 / cg" |
|
962 ! |
|
963 |
|
964 color |
|
965 "return the value of the instance variable 'color' (automatically generated)" |
|
966 |
|
967 ^ color |
|
968 |
|
969 "Created: 25.2.1997 / 20:59:28 / cg" |
|
970 ! |
|
971 |
|
972 color:something |
|
973 "set the value of the instance variable 'color' (automatically generated)" |
|
974 |
|
975 color := something. |
|
976 |
|
977 "Created: 25.2.1997 / 20:59:28 / cg" |
|
978 ! |
|
979 |
|
980 font |
|
981 "get the specific font for an item or nil |
|
982 " |
|
983 ^ font |
|
984 ! |
|
985 |
|
986 font:aFont |
|
987 "set a specific font for an item |
|
988 " |
|
989 font := aFont. |
|
990 ! |
|
991 |
|
992 horizontalLayout |
|
993 "on default submenus has a vertical layout; |
|
994 true, the submenu has a horizontal layout. |
|
995 " |
|
996 ^ horizontalLayout |
|
997 ! |
|
998 |
|
999 horizontalLayout:aBoolean |
|
1000 "on default submenus has a vertical layout; |
|
1001 true, the submenu has a horizontal layout. |
|
1002 " |
|
1003 horizontalLayout := aBoolean. |
|
1004 ! |
|
1005 |
|
1006 indication |
|
1007 "test whether the menu item has an on/off indicator (CheckToggle) |
|
1008 " |
|
1009 ^ indication |
|
1010 |
|
1011 "Created: 25.2.1997 / 20:59:28 / cg" |
|
1012 ! |
|
1013 |
|
1014 indication:something |
|
1015 "test whether the menu item has an on/off indicator (CheckToggle) |
|
1016 " |
|
1017 indication := something. |
|
1018 |
|
1019 "Created: 25.2.1997 / 20:59:28 / cg" |
|
1020 ! |
|
1021 |
|
1022 keepLinkedMenu |
|
1023 "return the value of the instance variable 'keepLinkedMenu' (automatically generated)" |
|
1024 |
|
1025 ^ keepLinkedMenu ? false |
|
1026 ! |
|
1027 |
|
1028 keepLinkedMenu:aBoolean |
|
1029 "set the value of the instance variable 'keepLinkedMenu' (automatically generated)" |
|
1030 |
|
1031 keepLinkedMenu := aBoolean ? false. |
|
1032 ! |
|
1033 |
|
1034 labelImage |
|
1035 "return the value of the instance variable 'labelImage' (automatically generated)" |
|
1036 |
|
1037 ^ labelImage |
|
1038 ! |
|
1039 |
|
1040 labelImage:something |
|
1041 "set the value of the instance variable 'labelImage' (automatically generated)" |
|
1042 |
|
1043 labelImage := something. |
|
1044 ! |
|
1045 |
|
1046 labelText |
|
1047 "get the text appear as the menu label |
|
1048 " |
|
1049 ^ labelText |
|
1050 ! |
|
1051 |
|
1052 labelText:something |
|
1053 "set the text appear as the menu label |
|
1054 " |
|
1055 labelText := something. |
|
1056 ! |
|
1057 |
|
1058 shortcutKeyCharacter |
|
1059 "get the key to press to select the menu item from the keyboard |
|
1060 " |
|
1061 ^ shortcutKey |
|
1062 ! |
|
1063 |
|
1064 shortcutKeyCharacter:something |
|
1065 "set the key to press to select the menu item from the keyboard |
|
1066 " |
|
1067 shortcutKey := something. |
|
1068 ! |
|
1069 |
|
1070 showBusyCursorWhilePerforming |
|
1071 "get the flag which controls if a busy cursor is to be shown |
|
1072 while performing the menu action. Defaults to false." |
|
1073 |
|
1074 ^ showBusyCursorWhilePerforming ? false |
|
1075 |
|
1076 ! |
|
1077 |
|
1078 showBusyCursorWhilePerforming:aBoolean |
|
1079 "set/clear the flag which controls if a busy cursor is to be shown |
|
1080 while performing the menu action. Defaults to false." |
|
1081 |
|
1082 showBusyCursorWhilePerforming := aBoolean |
|
1083 |
|
1084 ! |
|
1085 |
|
1086 staticSubmenu |
|
1087 "get the submenu or nil; |
|
1088 only returns the subMenu if its a static subMenu (i.e. not |
|
1089 provided by a valueHolder or block). |
|
1090 " |
|
1091 (submenu isValueModel or:[submenu isBlock]) ifTrue:[ |
|
1092 ^ nil |
|
1093 ]. |
|
1094 ^ submenu |
|
1095 |
|
1096 "Modified: / 5.2.2000 / 16:49:54 / cg" |
|
1097 ! |
|
1098 |
|
1099 submenu |
|
1100 "get the submenu or nil |
|
1101 " |
|
1102 ^ submenu value |
|
1103 |
|
1104 "Created: / 25.2.1997 / 20:59:28 / cg" |
|
1105 "Modified: / 19.6.1998 / 00:33:58 / cg" |
|
1106 ! |
|
1107 |
|
1108 submenu:something |
|
1109 "set the submenu or nil |
|
1110 " |
|
1111 (something isValueModel or:[something isBlock]) ifTrue:[ |
|
1112 submenuChannel notNil ifTrue:[ |
|
1113 "/ programmers error ? |
|
1114 "/ how can I decide which one to use if there is both |
|
1115 "/ a channel and a subMenu ... |
|
1116 self halt:'overwriting submenuchannel'. |
|
1117 ]. |
|
1118 submenuChannel := something |
|
1119 ] ifFalse:[ |
|
1120 submenu := something. |
|
1121 ] |
|
1122 |
|
1123 "Created: / 25.2.1997 / 20:59:28 / cg" |
|
1124 "Modified: / 5.2.2000 / 16:53:28 / cg" |
|
1125 ! |
|
1126 |
|
1127 submenuChannel |
|
1128 "get the submenuChannel or nil |
|
1129 " |
|
1130 ^ submenuChannel |
|
1131 ! |
|
1132 |
|
1133 submenuChannel:something |
|
1134 "set the submenuChannel or nil |
|
1135 " |
|
1136 submenuChannel := something. |
|
1137 ! |
|
1138 |
|
1139 submenuHolder |
|
1140 "get the submenuHolder or nil |
|
1141 " |
|
1142 ^ submenu |
|
1143 |
|
1144 "Modified: / 19.6.1998 / 00:33:58 / cg" |
|
1145 "Created: / 19.6.1998 / 00:34:32 / cg" |
|
1146 ! ! |
|
1147 |
|
1148 !MenuItem class methodsFor:'documentation'! |
829 !MenuItem class methodsFor:'documentation'! |
1149 |
830 |
1150 version |
831 version |
1151 ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.50 2002-09-19 16:55:57 ca Exp $' |
832 ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.51 2002-10-24 15:31:36 cg Exp $' |
1152 ! ! |
833 ! ! |