method comments added
authortz
Thu, 12 Mar 1998 23:02:28 +0100
changeset 728 638ae95885e1
parent 727 bbe063ccf4a3
child 729 12f157d5e017
method comments added
MenuEditor.st
--- a/MenuEditor.st	Thu Mar 12 15:01:32 1998 +0100
+++ b/MenuEditor.st	Thu Mar 12 23:02:28 1998 +0100
@@ -55,18 +55,15 @@
 
 documentation
 "
-    create and modify or inspect popup and pullDown menus of the
-    new style( derives from Menu).
+    The MenuEditor allows you to create, modify or just inspect
+    hierarchical menus of menu bars, popup menu, or tool bar menus.
 
     [start with:]
         MenuEditor open
-        MenuEditor new openOnClass:MenuEditor andSelector:#menuPullDown
+        MenuEditor openOnClass:MenuEditor andSelector:#menu
 
     [see also:]
         UIPainter
-        UIHelpTool
-        UISpecificationTool
-        SelectionInTreeView
 
     [author:]
         Claus Atzkern, eXept Software AG
@@ -75,25 +72,29 @@
 
 ! !
 
-!MenuEditor class methodsFor:'initialization'!
-
-initialize
-
-    super initialize.
-
-    TreeView initialize
-! !
-
 !MenuEditor class methodsFor:'instance creation'!
 
 openModalOnClass:aClass andSelector:aSelector
-    ^ self new openModalOnClass:aClass andSelector:aSelector
+    "Open modal a MenuEditor on aClass and aSelector"
+    "self openModalOnClass:self andSelector:#menu"
+
+    ^self new openModalOnClass:aClass andSelector:aSelector
 
 
 !
 
+openModalOnMenu: aMenu
+    "Open a MenuEditor modal on aMenu"
+    "self openModalOnMenu: (self perform: #menu) decodeAsLiteralArray"
+
+    ^self new openModalOnMenu: aMenu
+!
+
 openOnClass:aClass andSelector:aSelector
-    ^ self new openOnClass:aClass andSelector:aSelector
+    "Open a MenuEditor on aClass and aSelector"
+    "self openOnClass:self andSelector:#menu"
+
+    ^self new openOnClass:aClass andSelector:aSelector
 
 
 ! !
@@ -101,6 +102,7 @@
 !MenuEditor class methodsFor:'accessing'!
 
 resourceType
+    "get the type of resource of the method generated by the MenuEditor"
 
     ^#menu
 
@@ -112,8 +114,9 @@
 !MenuEditor class methodsFor:'aspects'!
 
 aspects
-
-^#(
+    "get the aspects for the attributes of the menu components"
+
+    ^#(
         label
         accessCharacterPos
         argument
@@ -130,19 +133,10 @@
         iconAndLabel
         icon
         isVisible
-
      )
 
 ! !
 
-!MenuEditor class methodsFor:'code generation'!
-
-sourceCategory
-    "returns the category where to install the menu
-    "
-    ^ 'accessing menu'
-! !
-
 !MenuEditor class methodsFor:'help specs'!
 
 helpSpec
@@ -262,12 +256,12 @@
        #(#FullSpec
           #window: 
            #(#WindowSpec
-              #name: 'unnamed canvas'
-              #layout: #(#LayoutFrame 72 0 301 0 338 0 619 0)
-              #label: 'unnamed canvas'
+              #name: 'Basics Item'
+              #layout: #(#LayoutFrame 212 0 351 0 478 0 669 0)
+              #label: 'Basics Item'
               #min: #(#Point 10 10)
               #max: #(#Point 1160 870)
-              #bounds: #(#Rectangle 72 301 339 620)
+              #bounds: #(#Rectangle 212 351 479 670)
               #usePreferredExtent: false
           )
           #component: 
@@ -359,7 +353,7 @@
                 )
                  #(#CheckBoxSpec
                     #name: 'translateLabelCheckBox'
-                    #layout: #(#Point 20 192)
+                    #layout: #(#Point 20 190)
                     #activeHelpKey: #basicsTranslateLabel
                     #tabable: true
                     #model: #translateLabel
@@ -367,7 +361,7 @@
                 )
                  #(#CheckBoxSpec
                     #name: 'isButtonCheckBox'
-                    #layout: #(#Point 20 221)
+                    #layout: #(#Point 20 219)
                     #activeHelpKey: #basicsIsButton
                     #tabable: true
                     #model: #isButton
@@ -396,12 +390,12 @@
        #(#FullSpec
           #window: 
            #(#WindowSpec
-              #name: 'unnamed canvas'
-              #layout: #(#LayoutFrame 478 0 279 0 744 0 597 0)
-              #label: 'unnamed canvas'
+              #name: 'Basics Link'
+              #layout: #(#LayoutFrame 212 0 351 0 478 0 669 0)
+              #label: 'Basics Link'
               #min: #(#Point 10 10)
               #max: #(#Point 1280 1024)
-              #bounds: #(#Rectangle 478 279 745 598)
+              #bounds: #(#Rectangle 212 351 479 670)
               #usePreferredExtent: false
           )
           #component: 
@@ -474,7 +468,7 @@
                 )
                  #(#CheckBoxSpec
                     #name: 'translateLabelCheckBox'
-                    #layout: #(#Point 20 128)
+                    #layout: #(#Point 20 190)
                     #activeHelpKey: #basicsTranslateLabel
                     #tabable: true
                     #model: #translateLabel
@@ -503,12 +497,12 @@
        #(#FullSpec
           #window: 
            #(#WindowSpec
-              #name: 'unnamed canvas'
-              #layout: #(#LayoutFrame 484 0 274 0 750 0 592 0)
-              #label: 'unnamed canvas'
+              #name: 'Basics Menu'
+              #layout: #(#LayoutFrame 212 0 351 0 478 0 669 0)
+              #label: 'Basics Menu'
               #min: #(#Point 10 10)
               #max: #(#Point 1280 1024)
-              #bounds: #(#Rectangle 484 274 751 593)
+              #bounds: #(#Rectangle 212 351 479 670)
               #usePreferredExtent: false
           )
           #component: 
@@ -550,7 +544,7 @@
                 )
                  #(#CheckBoxSpec
                     #name: 'translateLabelCheckBox'
-                    #layout: #(#Point 20 100)
+                    #layout: #(#Point 20 190)
                     #activeHelpKey: #basicsTranslateLabel
                     #tabable: true
                     #model: #translateLabel
@@ -579,12 +573,12 @@
        #(#FullSpec
           #window: 
            #(#WindowSpec
-              #name: 'unnamed canvas'
-              #layout: #(#LayoutFrame 448 0 290 0 714 0 608 0)
-              #label: 'unnamed canvas'
+              #name: 'Basics Root'
+              #layout: #(#LayoutFrame 424 0 293 0 690 0 611 0)
+              #label: 'Basics Root'
               #min: #(#Point 10 10)
               #max: #(#Point 1280 1024)
-              #bounds: #(#Rectangle 448 290 715 609)
+              #bounds: #(#Rectangle 424 293 691 612)
               #usePreferredExtent: false
           )
           #component: 
@@ -630,12 +624,12 @@
        #(#FullSpec
           #window: 
            #(#WindowSpec
-              #name: 'unnamed canvas'
-              #layout: #(#LayoutFrame 467 0 304 0 733 0 622 0)
-              #label: 'unnamed canvas'
+              #name: 'Basics Separator'
+              #layout: #(#LayoutFrame 297 0 354 0 563 0 672 0)
+              #label: 'Basics Separator'
               #min: #(#Point 10 10)
               #max: #(#Point 1160 870)
-              #bounds: #(#Rectangle 467 304 734 623)
+              #bounds: #(#Rectangle 297 354 564 673)
               #usePreferredExtent: false
           )
           #component: 
@@ -665,7 +659,7 @@
                     #resizeForLabel: true
                 )
                  #(#InputFieldSpec
-                    #name: 'isVisibleInputField'
+                    #name: 'visibilityInputField'
                     #layout: #(#LayoutFrame 132 0 65 0 -5 1.0 87 0)
                     #activeHelpKey: #detailsVisibility
                     #tabable: true
@@ -697,12 +691,12 @@
        #(#FullSpec
           #window: 
            #(#WindowSpec
-              #name: 'unnamed canvas'
-              #layout: #(#LayoutFrame 449 0 329 0 707 0 616 0)
-              #label: 'unnamed canvas'
+              #name: 'Details Edit'
+              #layout: #(#LayoutFrame 263 0 364 0 521 0 651 0)
+              #label: 'Details Edit'
               #min: #(#Point 10 10)
               #max: #(#Point 1280 1024)
-              #bounds: #(#Rectangle 449 329 708 617)
+              #bounds: #(#Rectangle 263 364 522 652)
               #usePreferredExtent: false
           )
           #component: 
@@ -818,12 +812,12 @@
        #(#FullSpec
           #window: 
            #(#WindowSpec
-              #name: 'unnamed canvas'
-              #layout: #(#LayoutFrame 462 0 313 0 706 0 454 0)
-              #label: 'unnamed canvas'
+              #name: 'Image Item'
+              #layout: #(#LayoutFrame 263 0 364 0 507 0 505 0)
+              #label: 'Image Item'
               #min: #(#Point 10 10)
               #max: #(#Point 1280 1024)
-              #bounds: #(#Rectangle 462 313 707 455)
+              #bounds: #(#Rectangle 263 364 508 506)
               #usePreferredExtent: false
           )
           #component: 
@@ -1007,7 +1001,6 @@
             )
              #(#MenuItem
                 #label: 'File'
-                #translateLabel: true
                 #activeHelpKey: #file
                 #submenu: 
                  #(#Menu
@@ -1026,7 +1019,6 @@
                           #translateLabel: true
                           #value: #doLoad
                           #activeHelpKey: #fileLoad
-                          #enabled: #isStandAlone
                       )
                        #(#MenuItem
                           #label: '-'
@@ -1048,7 +1040,6 @@
                           #label: 'Pick A Menu...'
                           #value: #doPickAMenu
                           #activeHelpKey: #filePickAMenu
-                          #enabled: #isStandAlone
                       )
                        #(#MenuItem
                           #label: '-'
@@ -1407,6 +1398,16 @@
 
 !MenuEditor class methodsFor:'resources'!
 
+iconUnknown
+    "returns an image used for picked items containing an image
+    "
+
+    <resource: #fileImage>
+
+
+    ^ Image fromFile:'brokenImage.xpm'
+!
+
 linkSubmenuImage
     "Generated by the Image Editor"
     "
@@ -1501,7 +1502,7 @@
 !MenuEditor methodsFor:'accessing'!
 
 submenuTest
-    "returns submenu assigned to item test"
+    "return submenu assigned to item test"
 
     |menu|
 
@@ -1514,6 +1515,7 @@
 !
 
 useHelpTool: aHelpTool
+    "take the help dictionaries from aHelpTool into my helpTool"
 
     self noteBookView.
 
@@ -1540,6 +1542,7 @@
 !
 
 noteBookView
+    "create the note book view containing the attibute sections and the help tool"
 
     |noteBook helpTool|
 
@@ -1561,10 +1564,11 @@
 !
 
 tabList
+    "get a value holder with the list of the attribute sections (slices)"
 
     |holder|
     (holder := builder bindingAt:#tabList) isNil ifTrue:[
-        builder aspectAt:#tabList put:(holder := #('Properties') asValue).
+        builder aspectAt:#tabList put:(holder := self class slicesRootMenu asValue).
     ].
     ^ holder
 
@@ -1572,7 +1576,7 @@
 !
 
 treeView
-    "returns the tree view representing hierarchically all the menu items"
+    "get a tree view representing hierarchically the menu items"
 
     |treeView|
     (treeView := builder bindingAt:#treeView) isNil ifTrue:[
@@ -1583,6 +1587,13 @@
     ^treeView
 ! !
 
+!MenuEditor methodsFor:'building'!
+
+buildFromListSpec: aListSpec
+
+    self buildFromMenu: aListSpec
+! !
+
 !MenuEditor methodsFor:'change & update'!
 
 updateEnabledChannels
@@ -1648,7 +1659,7 @@
 !MenuEditor methodsFor:'initialization'!
 
 initialize
-    "initialize value holders for the menu item properties"
+    "initialize value holders for the attributes of the menu components"
 
     |holder|
 
@@ -1656,13 +1667,14 @@
 
     aspects at:#seperatorSelection put:(holder := SelectionInList new).
     holder list: Item separatorList.
-    holder addDependent:self.
+    holder addDependent:self.   
 
 ! !
 
 !MenuEditor methodsFor:'private'!
 
 helpKey
+    "get the help key of the selected menu item"
 
     |node|
     (node := self treeView selectedNode) notNil ifTrue:[
@@ -1672,6 +1684,7 @@
 !
 
 helpTool
+    "get the help tool"
 
     ^helpCanvas application
 ! !
@@ -1679,7 +1692,7 @@
 !MenuEditor methodsFor:'queries'!
 
 isHelpToolSelected
-    "returns true if current selection is help tool"
+    "return true if current selection is help tool"
 
     (tabSelection ~~ 0 and:[slices notNil]) ifTrue:[
         ^(slices at:tabSelection) first = UIHelpTool label
@@ -1687,12 +1700,6 @@
     ^false
 !
 
-isStandAlone
-    "returns true in case of owner of the helptool"
-
-    ^self masterApplication isNil
-!
-
 preferredExtent
 
     ^super preferredExtent max: (Screen current width//3)@(Screen current height//2.5)
@@ -1704,7 +1711,7 @@
 
 menuChanged
 
-    |node item slc sel old dep|
+    |node item slc sel old|
 
     aspects do: [:holder| holder removeDependent:self].
     (node := self treeView selectedNode) notNil ifTrue:[
@@ -1741,7 +1748,7 @@
 
         (slices := slc) notNil ifTrue:[
             sel := slices collect:[:s| s first].
-            tabSelection := 0.
+            tabSelection := 0.     
             self tabList value:sel.
 
             (old notNil and:[(sel := sel findFirst:[:n|n = old]) ~~ 0]) ifFalse:[
@@ -1758,8 +1765,8 @@
 !
 
 tabSelection: aSelection
-
-    |sel|                   
+    "put the section aSelection into the note book"
+
     tabSelection = aSelection ifTrue:[
         ^ self
     ].
@@ -1778,12 +1785,11 @@
     self isHelpToolSelected ifTrue:[  
         self helpTool helpKey:(self helpKey).
         helpCanvas raise.
-    ] ifFalse:[                       
-        sel := (slices at:tabSelection) last.   
+    ] ifFalse:[       
         aspects do: [:holder| holder release].
-        specCanvas client:self spec:(self class perform:sel) builder:builder.
+        specCanvas client:self spec:(self class perform:(slices at:tabSelection) last) builder:builder.
         aspects do: [:holder| holder addDependent:self].
-        specCanvas raise.  
+        specCanvas raise.
     ]    
 
 ! !
@@ -1804,6 +1810,12 @@
 
 !
 
+openModalOnMenu: aMenu
+    "build a tree from aMenu open it modal"
+
+    super openModalOnListSpec: aMenu
+!
+
 postOpenWith:aBuilder
 
     super postOpenWith:aBuilder.
@@ -2293,7 +2305,10 @@
 
 buildFromClass:aClass andSelector:aSelector
 
-    |spec cls menu node|
+    |spec cls menu firstNode firstNodeLabel|
+
+    "if opened on a menu"
+    (aClass isNil and: [aSelector isNil and: [listOfNodes size > 0]]) ifTrue: [^nil].
 
     (aClass notNil and:[aSelector notNil]) ifTrue:[
         cls := self application resolveName:aClass.
@@ -2309,22 +2324,29 @@
         ] ifTrue:[
             menu := spec.
         ].
-        node := self nodeLabel:(aSelector asString).
-        self subMenu:menu parent:node.
+        firstNode := self nodeLabel:(aSelector asString).
+        self subMenu:menu parent:firstNode.
     ] ifTrue:[
-        aSelector notNil ifTrue:[cls := aSelector asString]
-                        ifFalse:[cls := 'menu'].
-
-        node := self nodeLabel:cls.
+        (aClass notNil and: [aSelector isNil and: [listOfNodes size > 0]])
+        ifTrue:
+        [
+            firstNode := listOfNodes first
+        ]
+        ifFalse:
+        [
+            aSelector notNil ifTrue:[firstNodeLabel := aSelector asString]
+                        ifFalse:[firstNodeLabel := 'menu'].
+            firstNode := self nodeLabel:firstNodeLabel.
+        ]
     ].
-    node expand.
-    model root:node.
-
-    node hasChildren ifFalse:[
-        |n|              
-        n := self nodeLabel:'Item 1'.   
-        n parent: node.
-        node add: n.
+    firstNode expand.
+    model root: firstNode.
+
+    firstNode hasChildren ifFalse:[
+        |firstChildNode|              
+        firstChildNode := self nodeLabel:'Item 1'.   
+        firstChildNode parent: firstNode.
+        firstNode add: firstChildNode.
         model recomputeList
     ].
 
@@ -2339,11 +2361,12 @@
     self subMenu:aMenu parent:node.
 
     node hasChildren ifFalse:[
-        node add:(self nodeLabel:'Item')
+        node add:(self nodeLabel:'Item 1')
     ].
     node expand.
     model root:node.
 
+    model recomputeList
 !
 
 menuItem:anItem
@@ -2622,4 +2645,3 @@
 version
     ^ '$Header$'
 ! !
-MenuEditor initialize!