checkin from browser
authorClaus Gittinger <cg@exept.de>
Tue, 25 Feb 1997 20:42:53 +0100
changeset 454 539b7c318760
parent 453 e06bf3866328
child 455 3fc6633a62af
checkin from browser
Menu.st
--- a/Menu.st	Tue Feb 25 20:22:25 1997 +0100
+++ b/Menu.st	Tue Feb 25 20:42:53 1997 +0100
@@ -1,5 +1,5 @@
 Object subclass:#Menu
-	instanceVariableNames:'items'
+	instanceVariableNames:'items groupSizes'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Support'
@@ -34,15 +34,33 @@
     "Created: 25.2.1997 / 19:47:53 / cg"
 !
 
-menuItems:aCollectionOfMenuItems groups:groups values:values
+menuItems:aCollectionOfMenuItems groupsSizes:sizes values:values
+    |idx newItems|
+
     items := aCollectionOfMenuItems.
     values notNil ifTrue:[
         items with:values do:[:anItem :aValue |
             anItem value:aValue 
         ]
-    ]
+    ].
+
+    "/ add empty items for group-separating lines.
 
-    "Modified: 25.2.1997 / 19:36:28 / cg"
+    groupSizes := sizes.
+    groupSizes notNil ifTrue:[
+        idx := 1.
+        newItems := OrderedCollection new.
+        groupSizes do:[:aGroupSize |
+            items from:idx to:idx+aGroupSize-1 do:[:l | newItems add:l].
+            newItems add:(MenuItem new label:'-').
+            idx := idx + aGroupSize
+        ].
+        items from:idx to:items size do:[:l | newItems add:l].
+        items := newItems.
+    ].
+
+    "Created: 25.2.1997 / 20:28:12 / cg"
+    "Modified: 25.2.1997 / 20:41:19 / cg"
 !
 
 valueAt:index
@@ -71,7 +89,7 @@
     items := (aLiteralEncodedArray at:2) collect:[:item | item decodeAsLiteralArray].
     groups := aLiteralEncodedArray at:3.
     values := aLiteralEncodedArray at:4.
-    self menuItems:items groups:groups values:values.
+    self menuItems:items groupsSizes:groups values:values.
 
     "extract from PD folder.st:
      #(#Menu #(
@@ -102,7 +120,7 @@
             #(#straightenUp #inspect #halt ) 
        ) decodeAsLiteralArray startUp  
     "
-    "
+    "extract from iconicBrowser.st:
      #(#Menu #(
                 #(#MenuItem 
                         #label: 'Straighten Up' ) 
@@ -116,7 +134,40 @@
        ) decodeAsLiteralArray startUp  
     "
 
-    "Modified: 25.2.1997 / 20:00:18 / cg"
+    "extract from refactory213.st:
+     #(#Menu #(
+                #(#MenuItem 
+                    #label: 'File List' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'File Editor...' 
+                    #accessCharacterPosition: 6 ) 
+                #(#MenuItem #label: 'Refactoring Tool...' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'Workspace' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'New Canvas' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'Palette' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'Canvas Tool' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'Image Editor' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'Menu Editor' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'Advanced' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'DLL and C Connect' 
+                    #accessCharacterPosition: 1 ) 
+                #(#MenuItem #label: 'System Transcript' 
+                    #accessCharacterPosition: 8 ) 
+              ) 
+              #(4 5 2 1 ) 
+              #(#openFileList #openFileEditor #openRefactoringTool #toolsNewWorkspace #toolsNewCanvas #toolsPalette #toolsCanvasTool #toolsMaskEditor #toolsMenuEditor nil #openExternalFinder #toggleSystemTranscript ) 
+        ) decodeAsLiteralArray
+    "
+
+    "Modified: 25.2.1997 / 20:33:08 / cg"
 ! !
 
 !Menu methodsFor:'startup'!
@@ -125,13 +176,16 @@
     "display the menu as a popUp; return the value associated with the
      selected item, 0 if none was selected"
 
-    |m val index|
+    |menuView val index labels |
 
     "/ for now, use PopUpMenu ....
 
-    m := PopUpMenu labels:self labels.
-    index := m startUp. 
-    index ~~ 0 ifTrue:[
+    labels := self labels.
+
+    menuView := PopUpMenu labels:labels.
+    index := menuView startUp. 
+    menuView destroy.
+    (index notNil and:[index ~~ 0]) ifTrue:[
         val := self valueAt:index.
         val notNil ifTrue:[
             ^ val
@@ -151,17 +205,17 @@
                         #(#MenuItem 
                                 #rawLabel: 'right' 
                                 #value: #right ) ) 
-                 #(3 ) 
+                 #(1 1 ) 
                 nil 
         ) decodeAsLiteralArray.
         m startUp
     "
 
-    "Modified: 25.2.1997 / 19:59:35 / cg"
+    "Modified: 25.2.1997 / 20:42:29 / cg"
 ! !
 
 !Menu class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Menu.st,v 1.2 1997-02-25 19:21:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Menu.st,v 1.3 1997-02-25 19:42:53 cg Exp $'
 ! !