support of arguments
authorca
Tue, 26 Aug 1997 17:42:47 +0200
changeset 502 dedc1b29b6ac
parent 501 0f047737ba92
child 503 0a3ef2d34d9d
support of arguments
MenuPanel.st
--- a/MenuPanel.st	Tue Aug 26 17:35:43 1997 +0200
+++ b/MenuPanel.st	Tue Aug 26 17:42:47 1997 +0200
@@ -63,12 +63,17 @@
     most of the MenuView and PopUpMenu stuff.
     (and hopefully be ST-80 compatible ...)
 
+    To create a menu, there exists a MenuEditor which will generate
+    a menu specification.
+
+
     [author:]
         Claus Atzkern
 
     [see also:]
         Menu
         MenuItem
+        MenuEditor
 "
 
 !
@@ -84,11 +89,11 @@
 
     mview := MenuPanel in:top.
 
-    labels := #( '\b foo' 'bar' 'baz' 'test' 'claus' ).
+    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
     mview level:2.
     mview verticalLayout:false.
     img := Image fromFile:'bitmaps/SBrowser.xbm'.
-    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'\b test' with:'ludwig \t'.
+    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
     mview labels:lbs.
     mview shortcutKeyAt:2 put:#Cut.
     mview accessCharacterPositionAt:1 put:1.
@@ -126,11 +131,11 @@
     |subView mview desc s1 s2 s3 img lbs labels|
 
     mview := MenuPanel new.
-    labels := #( '\b foo' 'bar' 'baz' ).
+    labels := #( 'foo' 'bar' 'baz' ).
     mview level:2.
 
     img := Image fromFile:'bitmaps/SBrowser.xbm'.
-    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'\b test'.
+    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test'.
     mview labels:lbs.
 
     s1 := MenuPanel labels:labels.
@@ -235,6 +240,10 @@
 
 !
 
+labels:labels receiver:aReceiver
+    ^ self labels:labels nameKeys:nil receiver:aReceiver
+!
+
 menu:aMenu
     ^ self menu:aMenu receiver:nil
 !
@@ -287,7 +296,6 @@
     DefaultStyle := IdentityDictionary new.
 
     DefaultStyle at:#foregroundColor         put:(Color black).
-    DefaultStyle at:#backgroundColor         put:(DefaultViewBackgroundColor ? (Color gray:50)).
     DefaultStyle at:#activeBackgroundColor   put:(Color white).
     DefaultStyle at:#disabledForegroundColor put:(Color gray:25).
     DefaultStyle at:#groupDividerSize        put:3.
@@ -308,55 +316,6 @@
 
 ! !
 
-!MenuPanel class methodsFor:'tests'!
-
-test
-"
-self test
-"
-    |top mview s1 s2 s3 img lbs labels|
-
-    top := StandardSystemView new.
-
-    mview := self in:top.
-
-    labels := #( 'foo' 'bar' 'baz' 'test' 'claus' ).
-    mview level:2.
-    mview verticalLayout:false.
-    img := Image fromFile:'bitmaps/SBrowser.xbm'.
-    lbs := Array with:'foo' with:'bar' with:img with:'baz' with:'test' with:'ludwig'.
-    mview labels:lbs.
-    mview shortcutKeyAt:2 put:#Cut.
-    mview accessCharacterPositionAt:1 put:1.
-    mview accessCharacterPositionAt:2 put:2.
-
-    mview enabledAt:5 put:false.
-    mview groupSizes:#( 2 2 ).
-    s1 := self labels:labels.
-    s1 accessCharacterPositionAt:1 put:1.
-    s1 accessCharacterPositionAt:2 put:2.
-    s1 groupSizes:#( 2 2 ).
-    s2 := self labels:#( '1' nil '2' '-' '3' '=' '4' ' ' '5' ).
-    s3 := self labels:lbs.
-
-    s1 subMenuAt:2 put:s2.
-    s1 subMenuAt:3 put:(self labels:lbs).
-    s2 subMenuAt:3 put:s3.
-    s3 subMenuAt:3 put:(self labels:labels).
-    s3 shortcutKeyAt:3 put:$q.
-
-    mview subMenuAt:1 put:s1.
-    mview subMenuAt:4 put:(self labels:lbs).
-    (mview subMenuAt:4) shortcutKeyAt:3 put:#Copy.
-    s1 shortcutKeyAt:1 put:#Copy.
-    s1 shortcutKeyAt:3 put:#Paste.
-
-    mview subMenuAt:2 put:(self labels:labels).
-    top extent:(400 @ (mview height)).
-    top open.
-
-! !
-
 !MenuPanel methodsFor:'accept'!
 
 accept
@@ -750,14 +709,14 @@
 backgroundColor
     "return the background color
     "
-    ^ self styleAt:#backgroundColor
+    ^ super viewBackground
 !
 
 backgroundColor:aColor
     "set the background drawing color. You should not use this method;
      instead leave the value as defined in the styleSheet.
     "
-    self styleAt:#backgroundColor put:aColor
+    super viewBackground:aColor
 !
 
 disabledForegroundColor
@@ -2608,6 +2567,13 @@
     "could be a value holder, an action or selector
     "
     value := something.
+!
+
+value:aValue argument:anArgument
+    "set the value and an argument
+    "
+    self value:aValue.
+    self argument:anArgument.
 ! !
 
 !MenuPanel::Item methodsFor:'accessing behavior'!
@@ -2633,8 +2599,10 @@
                 ]
             ]                
         ].
-        
         (self isKindOfValueHolder:state) ifTrue:[
+            enableChannel notNil ifTrue:[
+                enableChannel removeDependent:self
+            ].
             enableChannel := state.
             enableChannel addDependent:self.
             state := enableChannel value.
@@ -2911,6 +2879,7 @@
     ].
 
     item accessCharacterPosition:(self accessCharacterPosition).
+    item argument:(self argument).
     item nameKey:(self nameKey).
     item shortcutKeyCharacter:(self shortcutKey).
     item value:(value value).
@@ -2930,7 +2899,7 @@
 menuItem:aMenuItem
     "setup attributes from a MenuItem
     "
-    |acp lbl|
+    |var lbl|
 
     menuPanel disabledRedrawDo:[
         label := nil.
@@ -2946,8 +2915,12 @@
 
         self shortcutKey:(aMenuItem shortcutKeyCharacter).
 
-        (acp := aMenuItem accessCharacterPosition) notNil ifTrue:[
-            self accessCharacterPosition:acp.
+        (var := aMenuItem argument) notNil ifTrue:[
+            self argument:var.
+        ].
+
+        (var := aMenuItem accessCharacterPosition) notNil ifTrue:[
+            self accessCharacterPosition:var.
         ].
 
         submenuChannel := aMenuItem submenuChannel.
@@ -3275,8 +3248,14 @@
     ].
 
     Object messageNotUnderstoodSignal handle:[:ex| idct := false]
-                                          do:[ idct := (rcv perform:idct) == true].
-  ^ idct
+                                          do:[ idct := rcv perform:idct ].
+
+    (self isKindOfValueHolder:idct) ifTrue:[
+        self adornment indication:idct.
+        idct addDependent:self
+    ].
+
+  ^ idct value
 !
 
 indicationValue:aValue
@@ -3610,6 +3589,6 @@
 !MenuPanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.25 1997-08-18 11:06:59 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/MenuPanel.st,v 1.26 1997-08-26 15:42:47 ca Exp $'
 ! !
 MenuPanel initialize!