MenuEditor.st
changeset 728 638ae95885e1
parent 725 9d3fa75a40e4
child 734 9fdcc26c458f
equal deleted inserted replaced
727:bbe063ccf4a3 728:638ae95885e1
    53 
    53 
    54 !
    54 !
    55 
    55 
    56 documentation
    56 documentation
    57 "
    57 "
    58     create and modify or inspect popup and pullDown menus of the
    58     The MenuEditor allows you to create, modify or just inspect
    59     new style( derives from Menu).
    59     hierarchical menus of menu bars, popup menu, or tool bar menus.
    60 
    60 
    61     [start with:]
    61     [start with:]
    62         MenuEditor open
    62         MenuEditor open
    63         MenuEditor new openOnClass:MenuEditor andSelector:#menuPullDown
    63         MenuEditor openOnClass:MenuEditor andSelector:#menu
    64 
    64 
    65     [see also:]
    65     [see also:]
    66         UIPainter
    66         UIPainter
    67         UIHelpTool
       
    68         UISpecificationTool
       
    69         SelectionInTreeView
       
    70 
    67 
    71     [author:]
    68     [author:]
    72         Claus Atzkern, eXept Software AG
    69         Claus Atzkern, eXept Software AG
    73         Thomas Zwick, eXept Software AG
    70         Thomas Zwick, eXept Software AG
    74 "
    71 "
    75 
    72 
    76 ! !
    73 ! !
    77 
    74 
    78 !MenuEditor class methodsFor:'initialization'!
       
    79 
       
    80 initialize
       
    81 
       
    82     super initialize.
       
    83 
       
    84     TreeView initialize
       
    85 ! !
       
    86 
       
    87 !MenuEditor class methodsFor:'instance creation'!
    75 !MenuEditor class methodsFor:'instance creation'!
    88 
    76 
    89 openModalOnClass:aClass andSelector:aSelector
    77 openModalOnClass:aClass andSelector:aSelector
    90     ^ self new openModalOnClass:aClass andSelector:aSelector
    78     "Open modal a MenuEditor on aClass and aSelector"
    91 
    79     "self openModalOnClass:self andSelector:#menu"
    92 
    80 
       
    81     ^self new openModalOnClass:aClass andSelector:aSelector
       
    82 
       
    83 
       
    84 !
       
    85 
       
    86 openModalOnMenu: aMenu
       
    87     "Open a MenuEditor modal on aMenu"
       
    88     "self openModalOnMenu: (self perform: #menu) decodeAsLiteralArray"
       
    89 
       
    90     ^self new openModalOnMenu: aMenu
    93 !
    91 !
    94 
    92 
    95 openOnClass:aClass andSelector:aSelector
    93 openOnClass:aClass andSelector:aSelector
    96     ^ self new openOnClass:aClass andSelector:aSelector
    94     "Open a MenuEditor on aClass and aSelector"
       
    95     "self openOnClass:self andSelector:#menu"
       
    96 
       
    97     ^self new openOnClass:aClass andSelector:aSelector
    97 
    98 
    98 
    99 
    99 ! !
   100 ! !
   100 
   101 
   101 !MenuEditor class methodsFor:'accessing'!
   102 !MenuEditor class methodsFor:'accessing'!
   102 
   103 
   103 resourceType
   104 resourceType
       
   105     "get the type of resource of the method generated by the MenuEditor"
   104 
   106 
   105     ^#menu
   107     ^#menu
   106 
   108 
   107 
   109 
   108 
   110 
   110 ! !
   112 ! !
   111 
   113 
   112 !MenuEditor class methodsFor:'aspects'!
   114 !MenuEditor class methodsFor:'aspects'!
   113 
   115 
   114 aspects
   116 aspects
   115 
   117     "get the aspects for the attributes of the menu components"
   116 ^#(
   118 
       
   119     ^#(
   117         label
   120         label
   118         accessCharacterPos
   121         accessCharacterPos
   119         argument
   122         argument
   120         submenuChannel
   123         submenuChannel
   121         enabled
   124         enabled
   128         startGroup
   131         startGroup
   129         retriever
   132         retriever
   130         iconAndLabel
   133         iconAndLabel
   131         icon
   134         icon
   132         isVisible
   135         isVisible
   133 
       
   134      )
   136      )
   135 
   137 
   136 ! !
       
   137 
       
   138 !MenuEditor class methodsFor:'code generation'!
       
   139 
       
   140 sourceCategory
       
   141     "returns the category where to install the menu
       
   142     "
       
   143     ^ 'accessing menu'
       
   144 ! !
   138 ! !
   145 
   139 
   146 !MenuEditor class methodsFor:'help specs'!
   140 !MenuEditor class methodsFor:'help specs'!
   147 
   141 
   148 helpSpec
   142 helpSpec
   260     ^
   254     ^
   261      
   255      
   262        #(#FullSpec
   256        #(#FullSpec
   263           #window: 
   257           #window: 
   264            #(#WindowSpec
   258            #(#WindowSpec
   265               #name: 'unnamed canvas'
   259               #name: 'Basics Item'
   266               #layout: #(#LayoutFrame 72 0 301 0 338 0 619 0)
   260               #layout: #(#LayoutFrame 212 0 351 0 478 0 669 0)
   267               #label: 'unnamed canvas'
   261               #label: 'Basics Item'
   268               #min: #(#Point 10 10)
   262               #min: #(#Point 10 10)
   269               #max: #(#Point 1160 870)
   263               #max: #(#Point 1160 870)
   270               #bounds: #(#Rectangle 72 301 339 620)
   264               #bounds: #(#Rectangle 212 351 479 670)
   271               #usePreferredExtent: false
   265               #usePreferredExtent: false
   272           )
   266           )
   273           #component: 
   267           #component: 
   274            #(#SpecCollection
   268            #(#SpecCollection
   275               #collection: 
   269               #collection: 
   357                     #acceptOnReturn: false
   351                     #acceptOnReturn: false
   358                     #acceptOnTab: false
   352                     #acceptOnTab: false
   359                 )
   353                 )
   360                  #(#CheckBoxSpec
   354                  #(#CheckBoxSpec
   361                     #name: 'translateLabelCheckBox'
   355                     #name: 'translateLabelCheckBox'
   362                     #layout: #(#Point 20 192)
   356                     #layout: #(#Point 20 190)
   363                     #activeHelpKey: #basicsTranslateLabel
   357                     #activeHelpKey: #basicsTranslateLabel
   364                     #tabable: true
   358                     #tabable: true
   365                     #model: #translateLabel
   359                     #model: #translateLabel
   366                     #label: 'Translate Label'
   360                     #label: 'Translate Label'
   367                 )
   361                 )
   368                  #(#CheckBoxSpec
   362                  #(#CheckBoxSpec
   369                     #name: 'isButtonCheckBox'
   363                     #name: 'isButtonCheckBox'
   370                     #layout: #(#Point 20 221)
   364                     #layout: #(#Point 20 219)
   371                     #activeHelpKey: #basicsIsButton
   365                     #activeHelpKey: #basicsIsButton
   372                     #tabable: true
   366                     #tabable: true
   373                     #model: #isButton
   367                     #model: #isButton
   374                     #label: 'Is Button'
   368                     #label: 'Is Button'
   375                 )
   369                 )
   394     ^
   388     ^
   395      
   389      
   396        #(#FullSpec
   390        #(#FullSpec
   397           #window: 
   391           #window: 
   398            #(#WindowSpec
   392            #(#WindowSpec
   399               #name: 'unnamed canvas'
   393               #name: 'Basics Link'
   400               #layout: #(#LayoutFrame 478 0 279 0 744 0 597 0)
   394               #layout: #(#LayoutFrame 212 0 351 0 478 0 669 0)
   401               #label: 'unnamed canvas'
   395               #label: 'Basics Link'
   402               #min: #(#Point 10 10)
   396               #min: #(#Point 10 10)
   403               #max: #(#Point 1280 1024)
   397               #max: #(#Point 1280 1024)
   404               #bounds: #(#Rectangle 478 279 745 598)
   398               #bounds: #(#Rectangle 212 351 479 670)
   405               #usePreferredExtent: false
   399               #usePreferredExtent: false
   406           )
   400           )
   407           #component: 
   401           #component: 
   408            #(#SpecCollection
   402            #(#SpecCollection
   409               #collection: 
   403               #collection: 
   472                     #acceptOnReturn: false
   466                     #acceptOnReturn: false
   473                     #acceptOnTab: false
   467                     #acceptOnTab: false
   474                 )
   468                 )
   475                  #(#CheckBoxSpec
   469                  #(#CheckBoxSpec
   476                     #name: 'translateLabelCheckBox'
   470                     #name: 'translateLabelCheckBox'
   477                     #layout: #(#Point 20 128)
   471                     #layout: #(#Point 20 190)
   478                     #activeHelpKey: #basicsTranslateLabel
   472                     #activeHelpKey: #basicsTranslateLabel
   479                     #tabable: true
   473                     #tabable: true
   480                     #model: #translateLabel
   474                     #model: #translateLabel
   481                     #label: 'Translate Label'
   475                     #label: 'Translate Label'
   482                 )
   476                 )
   501     ^
   495     ^
   502      
   496      
   503        #(#FullSpec
   497        #(#FullSpec
   504           #window: 
   498           #window: 
   505            #(#WindowSpec
   499            #(#WindowSpec
   506               #name: 'unnamed canvas'
   500               #name: 'Basics Menu'
   507               #layout: #(#LayoutFrame 484 0 274 0 750 0 592 0)
   501               #layout: #(#LayoutFrame 212 0 351 0 478 0 669 0)
   508               #label: 'unnamed canvas'
   502               #label: 'Basics Menu'
   509               #min: #(#Point 10 10)
   503               #min: #(#Point 10 10)
   510               #max: #(#Point 1280 1024)
   504               #max: #(#Point 1280 1024)
   511               #bounds: #(#Rectangle 484 274 751 593)
   505               #bounds: #(#Rectangle 212 351 479 670)
   512               #usePreferredExtent: false
   506               #usePreferredExtent: false
   513           )
   507           )
   514           #component: 
   508           #component: 
   515            #(#SpecCollection
   509            #(#SpecCollection
   516               #collection: 
   510               #collection: 
   548                     #acceptOnReturn: false
   542                     #acceptOnReturn: false
   549                     #acceptOnTab: false
   543                     #acceptOnTab: false
   550                 )
   544                 )
   551                  #(#CheckBoxSpec
   545                  #(#CheckBoxSpec
   552                     #name: 'translateLabelCheckBox'
   546                     #name: 'translateLabelCheckBox'
   553                     #layout: #(#Point 20 100)
   547                     #layout: #(#Point 20 190)
   554                     #activeHelpKey: #basicsTranslateLabel
   548                     #activeHelpKey: #basicsTranslateLabel
   555                     #tabable: true
   549                     #tabable: true
   556                     #model: #translateLabel
   550                     #model: #translateLabel
   557                     #label: 'Translate Label'
   551                     #label: 'Translate Label'
   558                 )
   552                 )
   577     ^
   571     ^
   578      
   572      
   579        #(#FullSpec
   573        #(#FullSpec
   580           #window: 
   574           #window: 
   581            #(#WindowSpec
   575            #(#WindowSpec
   582               #name: 'unnamed canvas'
   576               #name: 'Basics Root'
   583               #layout: #(#LayoutFrame 448 0 290 0 714 0 608 0)
   577               #layout: #(#LayoutFrame 424 0 293 0 690 0 611 0)
   584               #label: 'unnamed canvas'
   578               #label: 'Basics Root'
   585               #min: #(#Point 10 10)
   579               #min: #(#Point 10 10)
   586               #max: #(#Point 1280 1024)
   580               #max: #(#Point 1280 1024)
   587               #bounds: #(#Rectangle 448 290 715 609)
   581               #bounds: #(#Rectangle 424 293 691 612)
   588               #usePreferredExtent: false
   582               #usePreferredExtent: false
   589           )
   583           )
   590           #component: 
   584           #component: 
   591            #(#SpecCollection
   585            #(#SpecCollection
   592               #collection: 
   586               #collection: 
   628     ^
   622     ^
   629      
   623      
   630        #(#FullSpec
   624        #(#FullSpec
   631           #window: 
   625           #window: 
   632            #(#WindowSpec
   626            #(#WindowSpec
   633               #name: 'unnamed canvas'
   627               #name: 'Basics Separator'
   634               #layout: #(#LayoutFrame 467 0 304 0 733 0 622 0)
   628               #layout: #(#LayoutFrame 297 0 354 0 563 0 672 0)
   635               #label: 'unnamed canvas'
   629               #label: 'Basics Separator'
   636               #min: #(#Point 10 10)
   630               #min: #(#Point 10 10)
   637               #max: #(#Point 1160 870)
   631               #max: #(#Point 1160 870)
   638               #bounds: #(#Rectangle 467 304 734 623)
   632               #bounds: #(#Rectangle 297 354 564 673)
   639               #usePreferredExtent: false
   633               #usePreferredExtent: false
   640           )
   634           )
   641           #component: 
   635           #component: 
   642            #(#SpecCollection
   636            #(#SpecCollection
   643               #collection: 
   637               #collection: 
   663                     #label: 'Visibility:'
   657                     #label: 'Visibility:'
   664                     #adjust: #right
   658                     #adjust: #right
   665                     #resizeForLabel: true
   659                     #resizeForLabel: true
   666                 )
   660                 )
   667                  #(#InputFieldSpec
   661                  #(#InputFieldSpec
   668                     #name: 'isVisibleInputField'
   662                     #name: 'visibilityInputField'
   669                     #layout: #(#LayoutFrame 132 0 65 0 -5 1.0 87 0)
   663                     #layout: #(#LayoutFrame 132 0 65 0 -5 1.0 87 0)
   670                     #activeHelpKey: #detailsVisibility
   664                     #activeHelpKey: #detailsVisibility
   671                     #tabable: true
   665                     #tabable: true
   672                     #model: #isVisible
   666                     #model: #isVisible
   673                     #type: #symbolOrNil
   667                     #type: #symbolOrNil
   695     ^
   689     ^
   696      
   690      
   697        #(#FullSpec
   691        #(#FullSpec
   698           #window: 
   692           #window: 
   699            #(#WindowSpec
   693            #(#WindowSpec
   700               #name: 'unnamed canvas'
   694               #name: 'Details Edit'
   701               #layout: #(#LayoutFrame 449 0 329 0 707 0 616 0)
   695               #layout: #(#LayoutFrame 263 0 364 0 521 0 651 0)
   702               #label: 'unnamed canvas'
   696               #label: 'Details Edit'
   703               #min: #(#Point 10 10)
   697               #min: #(#Point 10 10)
   704               #max: #(#Point 1280 1024)
   698               #max: #(#Point 1280 1024)
   705               #bounds: #(#Rectangle 449 329 708 617)
   699               #bounds: #(#Rectangle 263 364 522 652)
   706               #usePreferredExtent: false
   700               #usePreferredExtent: false
   707           )
   701           )
   708           #component: 
   702           #component: 
   709            #(#SpecCollection
   703            #(#SpecCollection
   710               #collection: 
   704               #collection: 
   816     ^
   810     ^
   817      
   811      
   818        #(#FullSpec
   812        #(#FullSpec
   819           #window: 
   813           #window: 
   820            #(#WindowSpec
   814            #(#WindowSpec
   821               #name: 'unnamed canvas'
   815               #name: 'Image Item'
   822               #layout: #(#LayoutFrame 462 0 313 0 706 0 454 0)
   816               #layout: #(#LayoutFrame 263 0 364 0 507 0 505 0)
   823               #label: 'unnamed canvas'
   817               #label: 'Image Item'
   824               #min: #(#Point 10 10)
   818               #min: #(#Point 10 10)
   825               #max: #(#Point 1280 1024)
   819               #max: #(#Point 1280 1024)
   826               #bounds: #(#Rectangle 462 313 707 455)
   820               #bounds: #(#Rectangle 263 364 508 506)
   827               #usePreferredExtent: false
   821               #usePreferredExtent: false
   828           )
   822           )
   829           #component: 
   823           #component: 
   830            #(#SpecCollection
   824            #(#SpecCollection
   831               #collection: 
   825               #collection: 
  1005                 #labelImage: #(#ResourceRetriever nil #menuIcon)
   999                 #labelImage: #(#ResourceRetriever nil #menuIcon)
  1006                 #submenuChannel: #menuAbout
  1000                 #submenuChannel: #menuAbout
  1007             )
  1001             )
  1008              #(#MenuItem
  1002              #(#MenuItem
  1009                 #label: 'File'
  1003                 #label: 'File'
  1010                 #translateLabel: true
       
  1011                 #activeHelpKey: #file
  1004                 #activeHelpKey: #file
  1012                 #submenu: 
  1005                 #submenu: 
  1013                  #(#Menu
  1006                  #(#Menu
  1014                     
  1007                     
  1015                      #(
  1008                      #(
  1024                        #(#MenuItem
  1017                        #(#MenuItem
  1025                           #label: 'Load...'
  1018                           #label: 'Load...'
  1026                           #translateLabel: true
  1019                           #translateLabel: true
  1027                           #value: #doLoad
  1020                           #value: #doLoad
  1028                           #activeHelpKey: #fileLoad
  1021                           #activeHelpKey: #fileLoad
  1029                           #enabled: #isStandAlone
       
  1030                       )
  1022                       )
  1031                        #(#MenuItem
  1023                        #(#MenuItem
  1032                           #label: '-'
  1024                           #label: '-'
  1033                       )
  1025                       )
  1034                        #(#MenuItem
  1026                        #(#MenuItem
  1046                       )
  1038                       )
  1047                        #(#MenuItem
  1039                        #(#MenuItem
  1048                           #label: 'Pick A Menu...'
  1040                           #label: 'Pick A Menu...'
  1049                           #value: #doPickAMenu
  1041                           #value: #doPickAMenu
  1050                           #activeHelpKey: #filePickAMenu
  1042                           #activeHelpKey: #filePickAMenu
  1051                           #enabled: #isStandAlone
       
  1052                       )
  1043                       )
  1053                        #(#MenuItem
  1044                        #(#MenuItem
  1054                           #label: '-'
  1045                           #label: '-'
  1055                       )
  1046                       )
  1056                        #(#MenuItem
  1047                        #(#MenuItem
  1405       )
  1396       )
  1406 ! !
  1397 ! !
  1407 
  1398 
  1408 !MenuEditor class methodsFor:'resources'!
  1399 !MenuEditor class methodsFor:'resources'!
  1409 
  1400 
       
  1401 iconUnknown
       
  1402     "returns an image used for picked items containing an image
       
  1403     "
       
  1404 
       
  1405     <resource: #fileImage>
       
  1406 
       
  1407 
       
  1408     ^ Image fromFile:'brokenImage.xpm'
       
  1409 !
       
  1410 
  1410 linkSubmenuImage
  1411 linkSubmenuImage
  1411     "Generated by the Image Editor"
  1412     "Generated by the Image Editor"
  1412     "
  1413     "
  1413     ImageEditor openOnClass:self andSelector:#linkSubmenuImage
  1414     ImageEditor openOnClass:self andSelector:#linkSubmenuImage
  1414     "
  1415     "
  1499 ! !
  1500 ! !
  1500 
  1501 
  1501 !MenuEditor methodsFor:'accessing'!
  1502 !MenuEditor methodsFor:'accessing'!
  1502 
  1503 
  1503 submenuTest
  1504 submenuTest
  1504     "returns submenu assigned to item test"
  1505     "return submenu assigned to item test"
  1505 
  1506 
  1506     |menu|
  1507     |menu|
  1507 
  1508 
  1508     (menu := self treeView asMenu) allItemsDo:
  1509     (menu := self treeView asMenu) allItemsDo:
  1509     [:anItem|
  1510     [:anItem|
  1512     ].
  1513     ].
  1513     ^menu
  1514     ^menu
  1514 !
  1515 !
  1515 
  1516 
  1516 useHelpTool: aHelpTool
  1517 useHelpTool: aHelpTool
       
  1518     "take the help dictionaries from aHelpTool into my helpTool"
  1517 
  1519 
  1518     self noteBookView.
  1520     self noteBookView.
  1519 
  1521 
  1520     self helpTool helpSpecFrom: aHelpTool specClass.
  1522     self helpTool helpSpecFrom: aHelpTool specClass.
  1521     self helpTool dictionaries: aHelpTool dictionaries.
  1523     self helpTool dictionaries: aHelpTool dictionaries.
  1538 
  1540 
  1539     ^builder booleanValueAspectFor: #hasValidSingleSelection
  1541     ^builder booleanValueAspectFor: #hasValidSingleSelection
  1540 !
  1542 !
  1541 
  1543 
  1542 noteBookView
  1544 noteBookView
       
  1545     "create the note book view containing the attibute sections and the help tool"
  1543 
  1546 
  1544     |noteBook helpTool|
  1547     |noteBook helpTool|
  1545 
  1548 
  1546     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
  1549     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
  1547         noteBook := View new.
  1550         noteBook := View new.
  1559     ].
  1562     ].
  1560     ^ noteBook
  1563     ^ noteBook
  1561 !
  1564 !
  1562 
  1565 
  1563 tabList
  1566 tabList
       
  1567     "get a value holder with the list of the attribute sections (slices)"
  1564 
  1568 
  1565     |holder|
  1569     |holder|
  1566     (holder := builder bindingAt:#tabList) isNil ifTrue:[
  1570     (holder := builder bindingAt:#tabList) isNil ifTrue:[
  1567         builder aspectAt:#tabList put:(holder := #('Properties') asValue).
  1571         builder aspectAt:#tabList put:(holder := self class slicesRootMenu asValue).
  1568     ].
  1572     ].
  1569     ^ holder
  1573     ^ holder
  1570 
  1574 
  1571 
  1575 
  1572 !
  1576 !
  1573 
  1577 
  1574 treeView
  1578 treeView
  1575     "returns the tree view representing hierarchically all the menu items"
  1579     "get a tree view representing hierarchically the menu items"
  1576 
  1580 
  1577     |treeView|
  1581     |treeView|
  1578     (treeView := builder bindingAt:#treeView) isNil ifTrue:[
  1582     (treeView := builder bindingAt:#treeView) isNil ifTrue:[
  1579         treeView := TreeView new.
  1583         treeView := TreeView new.
  1580         treeView action:[:dummy|self menuChanged].
  1584         treeView action:[:dummy|self menuChanged].
  1581         builder aspectAt: #treeView put: treeView
  1585         builder aspectAt: #treeView put: treeView
  1582     ].
  1586     ].
  1583     ^treeView
  1587     ^treeView
       
  1588 ! !
       
  1589 
       
  1590 !MenuEditor methodsFor:'building'!
       
  1591 
       
  1592 buildFromListSpec: aListSpec
       
  1593 
       
  1594     self buildFromMenu: aListSpec
  1584 ! !
  1595 ! !
  1585 
  1596 
  1586 !MenuEditor methodsFor:'change & update'!
  1597 !MenuEditor methodsFor:'change & update'!
  1587 
  1598 
  1588 updateEnabledChannels
  1599 updateEnabledChannels
  1646 ! !
  1657 ! !
  1647 
  1658 
  1648 !MenuEditor methodsFor:'initialization'!
  1659 !MenuEditor methodsFor:'initialization'!
  1649 
  1660 
  1650 initialize
  1661 initialize
  1651     "initialize value holders for the menu item properties"
  1662     "initialize value holders for the attributes of the menu components"
  1652 
  1663 
  1653     |holder|
  1664     |holder|
  1654 
  1665 
  1655     super initialize.
  1666     super initialize.
  1656 
  1667 
  1657     aspects at:#seperatorSelection put:(holder := SelectionInList new).
  1668     aspects at:#seperatorSelection put:(holder := SelectionInList new).
  1658     holder list: Item separatorList.
  1669     holder list: Item separatorList.
  1659     holder addDependent:self.
  1670     holder addDependent:self.   
  1660 
  1671 
  1661 ! !
  1672 ! !
  1662 
  1673 
  1663 !MenuEditor methodsFor:'private'!
  1674 !MenuEditor methodsFor:'private'!
  1664 
  1675 
  1665 helpKey
  1676 helpKey
       
  1677     "get the help key of the selected menu item"
  1666 
  1678 
  1667     |node|
  1679     |node|
  1668     (node := self treeView selectedNode) notNil ifTrue:[
  1680     (node := self treeView selectedNode) notNil ifTrue:[
  1669         ^ node contents activeHelpKey
  1681         ^ node contents activeHelpKey
  1670     ].
  1682     ].
  1671     ^ nil
  1683     ^ nil
  1672 !
  1684 !
  1673 
  1685 
  1674 helpTool
  1686 helpTool
       
  1687     "get the help tool"
  1675 
  1688 
  1676     ^helpCanvas application
  1689     ^helpCanvas application
  1677 ! !
  1690 ! !
  1678 
  1691 
  1679 !MenuEditor methodsFor:'queries'!
  1692 !MenuEditor methodsFor:'queries'!
  1680 
  1693 
  1681 isHelpToolSelected
  1694 isHelpToolSelected
  1682     "returns true if current selection is help tool"
  1695     "return true if current selection is help tool"
  1683 
  1696 
  1684     (tabSelection ~~ 0 and:[slices notNil]) ifTrue:[
  1697     (tabSelection ~~ 0 and:[slices notNil]) ifTrue:[
  1685         ^(slices at:tabSelection) first = UIHelpTool label
  1698         ^(slices at:tabSelection) first = UIHelpTool label
  1686     ].
  1699     ].
  1687     ^false
  1700     ^false
  1688 !
  1701 !
  1689 
  1702 
  1690 isStandAlone
       
  1691     "returns true in case of owner of the helptool"
       
  1692 
       
  1693     ^self masterApplication isNil
       
  1694 !
       
  1695 
       
  1696 preferredExtent
  1703 preferredExtent
  1697 
  1704 
  1698     ^super preferredExtent max: (Screen current width//3)@(Screen current height//2.5)
  1705     ^super preferredExtent max: (Screen current width//3)@(Screen current height//2.5)
  1699 
  1706 
  1700 
  1707 
  1702 
  1709 
  1703 !MenuEditor methodsFor:'selection'!
  1710 !MenuEditor methodsFor:'selection'!
  1704 
  1711 
  1705 menuChanged
  1712 menuChanged
  1706 
  1713 
  1707     |node item slc sel old dep|
  1714     |node item slc sel old|
  1708 
  1715 
  1709     aspects do: [:holder| holder removeDependent:self].
  1716     aspects do: [:holder| holder removeDependent:self].
  1710     (node := self treeView selectedNode) notNil ifTrue:[
  1717     (node := self treeView selectedNode) notNil ifTrue:[
  1711         aspects do:[:anAspect| anAspect value:nil ].
  1718         aspects do:[:anAspect| anAspect value:nil ].
  1712         item := node contents.
  1719         item := node contents.
  1739             old := (slices at:tabSelection) first
  1746             old := (slices at:tabSelection) first
  1740         ].
  1747         ].
  1741 
  1748 
  1742         (slices := slc) notNil ifTrue:[
  1749         (slices := slc) notNil ifTrue:[
  1743             sel := slices collect:[:s| s first].
  1750             sel := slices collect:[:s| s first].
  1744             tabSelection := 0.
  1751             tabSelection := 0.     
  1745             self tabList value:sel.
  1752             self tabList value:sel.
  1746 
  1753 
  1747             (old notNil and:[(sel := sel findFirst:[:n|n = old]) ~~ 0]) ifFalse:[
  1754             (old notNil and:[(sel := sel findFirst:[:n|n = old]) ~~ 0]) ifFalse:[
  1748                 sel := 1
  1755                 sel := 1
  1749             ].
  1756             ].
  1756     self updateEnabledChannels.
  1763     self updateEnabledChannels.
  1757     aspects do: [:holder| holder addDependent:self].
  1764     aspects do: [:holder| holder addDependent:self].
  1758 !
  1765 !
  1759 
  1766 
  1760 tabSelection: aSelection
  1767 tabSelection: aSelection
  1761 
  1768     "put the section aSelection into the note book"
  1762     |sel|                   
  1769 
  1763     tabSelection = aSelection ifTrue:[
  1770     tabSelection = aSelection ifTrue:[
  1764         ^ self
  1771         ^ self
  1765     ].
  1772     ].
  1766     (aSelection ~~ 0 and:[slices isNil]) ifTrue:[
  1773     (aSelection ~~ 0 and:[slices isNil]) ifTrue:[
  1767         ^ self
  1774         ^ self
  1776     ].
  1783     ].
  1777 
  1784 
  1778     self isHelpToolSelected ifTrue:[  
  1785     self isHelpToolSelected ifTrue:[  
  1779         self helpTool helpKey:(self helpKey).
  1786         self helpTool helpKey:(self helpKey).
  1780         helpCanvas raise.
  1787         helpCanvas raise.
  1781     ] ifFalse:[                       
  1788     ] ifFalse:[       
  1782         sel := (slices at:tabSelection) last.   
       
  1783         aspects do: [:holder| holder release].
  1789         aspects do: [:holder| holder release].
  1784         specCanvas client:self spec:(self class perform:sel) builder:builder.
  1790         specCanvas client:self spec:(self class perform:(slices at:tabSelection) last) builder:builder.
  1785         aspects do: [:holder| holder addDependent:self].
  1791         aspects do: [:holder| holder addDependent:self].
  1786         specCanvas raise.  
  1792         specCanvas raise.
  1787     ]    
  1793     ]    
  1788 
  1794 
  1789 ! !
  1795 ! !
  1790 
  1796 
  1791 !MenuEditor methodsFor:'startup / release'!
  1797 !MenuEditor methodsFor:'startup / release'!
  1800     self updateHistory.
  1806     self updateHistory.
  1801     self updateInfoLabel.
  1807     self updateInfoLabel.
  1802     self treeView selection: 2.
  1808     self treeView selection: 2.
  1803     self menuChanged
  1809     self menuChanged
  1804 
  1810 
       
  1811 !
       
  1812 
       
  1813 openModalOnMenu: aMenu
       
  1814     "build a tree from aMenu open it modal"
       
  1815 
       
  1816     super openModalOnListSpec: aMenu
  1805 !
  1817 !
  1806 
  1818 
  1807 postOpenWith:aBuilder
  1819 postOpenWith:aBuilder
  1808 
  1820 
  1809     super postOpenWith:aBuilder.
  1821     super postOpenWith:aBuilder.
  2291 
  2303 
  2292 !MenuEditor::TreeView methodsFor:'building'!
  2304 !MenuEditor::TreeView methodsFor:'building'!
  2293 
  2305 
  2294 buildFromClass:aClass andSelector:aSelector
  2306 buildFromClass:aClass andSelector:aSelector
  2295 
  2307 
  2296     |spec cls menu node|
  2308     |spec cls menu firstNode firstNodeLabel|
       
  2309 
       
  2310     "if opened on a menu"
       
  2311     (aClass isNil and: [aSelector isNil and: [listOfNodes size > 0]]) ifTrue: [^nil].
  2297 
  2312 
  2298     (aClass notNil and:[aSelector notNil]) ifTrue:[
  2313     (aClass notNil and:[aSelector notNil]) ifTrue:[
  2299         cls := self application resolveName:aClass.
  2314         cls := self application resolveName:aClass.
  2300 
  2315 
  2301         (cls respondsTo:aSelector) ifTrue:[
  2316         (cls respondsTo:aSelector) ifTrue:[
  2307         (spec isMemberOf:Menu) ifFalse:[
  2322         (spec isMemberOf:Menu) ifFalse:[
  2308             menu := Menu new fromLiteralArrayEncoding:spec.
  2323             menu := Menu new fromLiteralArrayEncoding:spec.
  2309         ] ifTrue:[
  2324         ] ifTrue:[
  2310             menu := spec.
  2325             menu := spec.
  2311         ].
  2326         ].
  2312         node := self nodeLabel:(aSelector asString).
  2327         firstNode := self nodeLabel:(aSelector asString).
  2313         self subMenu:menu parent:node.
  2328         self subMenu:menu parent:firstNode.
  2314     ] ifTrue:[
  2329     ] ifTrue:[
  2315         aSelector notNil ifTrue:[cls := aSelector asString]
  2330         (aClass notNil and: [aSelector isNil and: [listOfNodes size > 0]])
  2316                         ifFalse:[cls := 'menu'].
  2331         ifTrue:
  2317 
  2332         [
  2318         node := self nodeLabel:cls.
  2333             firstNode := listOfNodes first
       
  2334         ]
       
  2335         ifFalse:
       
  2336         [
       
  2337             aSelector notNil ifTrue:[firstNodeLabel := aSelector asString]
       
  2338                         ifFalse:[firstNodeLabel := 'menu'].
       
  2339             firstNode := self nodeLabel:firstNodeLabel.
       
  2340         ]
       
  2341     ].
       
  2342     firstNode expand.
       
  2343     model root: firstNode.
       
  2344 
       
  2345     firstNode hasChildren ifFalse:[
       
  2346         |firstChildNode|              
       
  2347         firstChildNode := self nodeLabel:'Item 1'.   
       
  2348         firstChildNode parent: firstNode.
       
  2349         firstNode add: firstChildNode.
       
  2350         model recomputeList
       
  2351     ].
       
  2352 
       
  2353 
       
  2354 !
       
  2355 
       
  2356 buildFromMenu:aMenu
       
  2357 
       
  2358     |node|
       
  2359 
       
  2360     node := self nodeLabel:'menu'.
       
  2361     self subMenu:aMenu parent:node.
       
  2362 
       
  2363     node hasChildren ifFalse:[
       
  2364         node add:(self nodeLabel:'Item 1')
  2319     ].
  2365     ].
  2320     node expand.
  2366     node expand.
  2321     model root:node.
  2367     model root:node.
  2322 
  2368 
  2323     node hasChildren ifFalse:[
  2369     model recomputeList
  2324         |n|              
       
  2325         n := self nodeLabel:'Item 1'.   
       
  2326         n parent: node.
       
  2327         node add: n.
       
  2328         model recomputeList
       
  2329     ].
       
  2330 
       
  2331 
       
  2332 !
       
  2333 
       
  2334 buildFromMenu:aMenu
       
  2335 
       
  2336     |node|
       
  2337 
       
  2338     node := self nodeLabel:'menu'.
       
  2339     self subMenu:aMenu parent:node.
       
  2340 
       
  2341     node hasChildren ifFalse:[
       
  2342         node add:(self nodeLabel:'Item')
       
  2343     ].
       
  2344     node expand.
       
  2345     model root:node.
       
  2346 
       
  2347 !
  2370 !
  2348 
  2371 
  2349 menuItem:anItem
  2372 menuItem:anItem
  2350 
  2373 
  2351     |node|
  2374     |node|
  2620 !MenuEditor class methodsFor:'documentation'!
  2643 !MenuEditor class methodsFor:'documentation'!
  2621 
  2644 
  2622 version
  2645 version
  2623     ^ '$Header$'
  2646     ^ '$Header$'
  2624 ! !
  2647 ! !
  2625 MenuEditor initialize!