MenuItem.st
changeset 1986 f819e439d917
parent 1885 860b47f2535f
child 1990 dca233a39477
--- a/MenuItem.st	Mon May 24 19:45:01 2004 +0200
+++ b/MenuItem.st	Fri Jun 04 14:37:58 2004 +0200
@@ -20,7 +20,7 @@
 		labelImage accessCharacterPosition argument choice choiceValue
 		font auxValue showBusyCursorWhilePerforming keepLinkedMenu
 		horizontalLayout sendToOriginator ignoreMnemonicKeys
-		ignoreShortcutKeys'
+		ignoreShortcutKeys isMenuSlice'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Support'
@@ -268,6 +268,10 @@
     "Created: 25.2.1997 / 20:59:28 / cg"
 !
 
+isMenuSlice:aBoolean
+    isMenuSlice := aBoolean.
+!
+
 isVisible
     ^ isVisible ? true
 !
@@ -604,6 +608,10 @@
     "
     |retriever m|
 
+    (aResourceContainerOrApplication isNil or:[self isMenuSlice]) ifTrue:[
+        ^ self.
+    ].
+
     self translateLabel ifTrue:[
         label := ResourceRetriever 
                         findResourceLabel:label 
@@ -623,6 +631,53 @@
     ]
 
     "Modified: / 18.6.1998 / 16:54:25 / cg"
+!
+
+receiver:aReceiver perform:aSelector with:anArgument ifNone:aBlock
+    "send the one-arg-message aSelector to the application;
+     the result returned from the send or nil is returned
+    "
+    |result|
+
+    MessageNotUnderstood handle:[:ex|
+        ex selector ~~ aSelector ifTrue:[
+            ex reject
+        ].
+        result := aBlock value.
+    ] do:[
+        aSelector numArgs == 0 ifTrue:[
+            result := aReceiver perform:aSelector.
+        ] ifFalse:[
+            result := aReceiver perform:aSelector with:anArgument.
+        ].
+    ].
+    ^ result
+!
+
+resolveSliceMenuItemsIn:aReceiver rememberResourcesIn:aValueHolderOrNil
+    |menu|
+
+    self isMenuSlice ifFalse:[
+        self error:'not a slice menu'.
+        ^ Array with:self.
+    ].
+
+    aReceiver isNil ifTrue:[
+        ^ nil
+    ].
+
+    menu := self receiver:aReceiver perform:submenuChannel with:argument
+        ifNone:[ self receiver:(aReceiver class) perform:submenuChannel with:argument ifNone:nil ].
+
+    menu isNil ifTrue:[^ nil].
+    menu := menu value.
+
+    menu isArray ifTrue:[
+        menu := Menu new fromLiteralArrayEncoding:menu.
+    ].
+
+    menu findGuiResourcesIn:aReceiver rememberResourcesIn:aValueHolderOrNil.
+    ^ menu items
 ! !
 
 !MenuItem methodsFor:'converting'!
@@ -662,6 +717,7 @@
     self ignoreShortcutKeys ifFalse:[coll add:#ignoreShortcutKeys ].
     self ignoreMnemonicKeys ifFalse:[coll add:#ignoreMnemonicKeys ].
 
+    self isMenuSlice ifFalse:[coll add:#isMenuSlice].
 
     ^ coll
 ! !
@@ -783,6 +839,13 @@
     ^ true
 !
 
+isMenuSlice
+    "returns true if the menu is a slice buildin its items
+     into its container menu
+    "
+    ^ submenuChannel notNil and:[isMenuSlice == true].
+!
+
 isOff
     "test whether indication on/off exists and is off
     "
@@ -804,5 +867,5 @@
 !MenuItem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.64 2004-01-13 16:30:44 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/MenuItem.st,v 1.65 2004-06-04 12:37:58 ca Exp $'
 ! !