MenuEditor.st
changeset 287 1ecabfd468dc
parent 275 cdecb5b5d356
child 290 1428bab2aa68
equal deleted inserted replaced
286:23712b1d3f3d 287:1ecabfd468dc
    11 "
    11 "
    12 
    12 
    13 
    13 
    14 
    14 
    15 ApplicationModel subclass:#MenuEditor
    15 ApplicationModel subclass:#MenuEditor
    16 	instanceVariableNames:'specClass tabSelection aspects slices activeHelpTool didInstall'
    16 	instanceVariableNames:'specClass specCanvas helpCanvas tabSelection aspects slices
       
    17 		didInstall'
    17 	classVariableNames:''
    18 	classVariableNames:''
    18 	poolDictionaries:''
    19 	poolDictionaries:''
    19 	category:'Interface-UIPainter'
    20 	category:'Interface-UIPainter'
    20 !
    21 !
    21 
    22 
   122     ^
   123     ^
   123      
   124      
   124        #(#FullSpec
   125        #(#FullSpec
   125           #'window:' 
   126           #'window:' 
   126            #(#WindowSpec
   127            #(#WindowSpec
   127               #'name:' 'uIPainterView'
   128               #'name:' 'ClassAndMethodSpec'
   128               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   129               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   129               #'label:' 'Painter'
   130               #'label:' 'Painter'
   130               #'bounds:' #(#Rectangle 0 0 391 170)
   131               #'bounds:' #(#Rectangle 0 0 391 170)
   131           )
   132           )
   132           #'component:' 
   133           #'component:' 
   218     ^
   219     ^
   219      
   220      
   220        #(#FullSpec
   221        #(#FullSpec
   221           #'window:' 
   222           #'window:' 
   222            #(#WindowSpec
   223            #(#WindowSpec
   223               #'name:' 'uIPainterView'
   224               #'name:' 'ClassDefineSpec'
   224               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   225               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   225               #'label:' 'Painter'
   226               #'label:' 'Painter'
   226               #'bounds:' #(#Rectangle 0 0 383 128)
   227               #'bounds:' #(#Rectangle 0 0 383 128)
   227           )
   228           )
   228           #'component:' 
   229           #'component:' 
   530                           #'value:' #doNew
   531                           #'value:' #doNew
   531                       )
   532                       )
   532                        #(#MenuItem
   533                        #(#MenuItem
   533                           #'label:' 'from class ...'
   534                           #'label:' 'from class ...'
   534                           #'value:' #doFromClass
   535                           #'value:' #doFromClass
   535                           #'enabled:' #isOwnerOfHelpTool
   536                           #'enabled:' #isStandAlone
   536                       )
   537                       )
   537                        #(#MenuItem
   538                        #(#MenuItem
   538                           #'label:' 'pick a menu'
   539                           #'label:' 'pick a menu'
   539                           #'value:' #doPickAMenu
   540                           #'value:' #doPickAMenu
   540                           #'enabled:' #isOwnerOfHelpTool
   541                           #'enabled:' #isStandAlone
   541                       )
   542                       )
   542                        #(#MenuItem
   543                        #(#MenuItem
   543                           #'label:' '='
   544                           #'label:' '='
   544                       )
   545                       )
   545                        #(#MenuItem
   546                        #(#MenuItem
   594                     
   595                     
   595                      #(
   596                      #(
   596                        #(#MenuItem
   597                        #(#MenuItem
   597                           #'label:' 'class'
   598                           #'label:' 'class'
   598                           #'value:' #doDefineClass
   599                           #'value:' #doDefineClass
   599                           #'enabled:' #isOwnerOfHelpTool
   600                           #'enabled:' #isStandAlone
   600                       )
   601                       )
   601                        #(#MenuItem
   602                        #(#MenuItem
   602                           #'label:' '-'
   603                           #'label:' '-'
   603                       )
   604                       )
   604                        #(#MenuItem
   605                        #(#MenuItem
   606                           #'value:' #doInstallSpec
   607                           #'value:' #doInstallSpec
   607                       )
   608                       )
   608                        #(#MenuItem
   609                        #(#MenuItem
   609                           #'label:' 'install help spec.'
   610                           #'label:' 'install help spec.'
   610                           #'value:' #doInstallHelp
   611                           #'value:' #doInstallHelp
   611                           #'enabled:' #isOwnerOfHelpTool
   612                           #'enabled:' #isStandAlone
   612                       )
   613                       )
   613                        #(#MenuItem
   614                        #(#MenuItem
   614                           #'label:' '='
   615                           #'label:' '='
   615                       )
   616                       )
   616                        #(#MenuItem
   617                        #(#MenuItem
   649     ^
   650     ^
   650      
   651      
   651        #(#FullSpec
   652        #(#FullSpec
   652           #'window:' 
   653           #'window:' 
   653            #(#WindowSpec
   654            #(#WindowSpec
   654               #'name:' 'uIPainterView'
   655               #'name:' 'MenuEditor'
   655               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   656               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   656               #'label:' 'Menu Builder'
   657               #'label:' 'Menu Builder'
   657               #'bounds:' #(#Rectangle 0 0 580 384)
   658               #'bounds:' #(#Rectangle 0 0 580 384)
   658           )
   659           )
   659           #'component:' 
   660           #'component:' 
   675                     #'tabable:' true
   676                     #'tabable:' true
   676                     #'menu:' #tabList
   677                     #'menu:' #tabList
   677                     #'model:' #tabModel
   678                     #'model:' #tabModel
   678                     #'tabWidget:' #Window
   679                     #'tabWidget:' #Window
   679                     #'useIndex:' true
   680                     #'useIndex:' true
   680                     #'canvas:' #tabCanvas
   681                     #'canvas:' #noteBookView
   681                 )
   682                 )
   682                  #(#HorizontalPanelViewSpec
   683                  #(#HorizontalPanelViewSpec
   683                     #'name:' 'confirmationPanel'
   684                     #'name:' 'confirmationPanel'
   684                     #'layout:' #(#LayoutFrame 0 0.5 -24 1.0 0 1.0 0 1.0)
   685                     #'layout:' #(#LayoutFrame 0 0.5 -24 1.0 0 1.0 0 1.0)
   685                     #'component:' 
   686                     #'component:' 
   729 slicesItem
   730 slicesItem
   730     ^#(
   731     ^#(
   731             (Basics     basicsItemSpec)
   732             (Basics     basicsItemSpec)
   732             (Details    detailsEditSpec)
   733             (Details    detailsEditSpec)
   733             (Misc       miscEditSpec)
   734             (Misc       miscEditSpec)
   734             (Help       help)
       
   735       )
   735       )
   736 
   736 
   737 !
   737 !
   738 
   738 
   739 slicesLink
   739 slicesLink
   740     ^#(
   740     ^#(
   741             (Basics     basicsLinkSpec)
   741             (Basics     basicsLinkSpec)
   742             (Details    detailsEditSpec)
   742             (Details    detailsEditSpec)
   743             (Misc       miscEditSpec)
   743             (Misc       miscEditSpec)
   744             (Help       help)
       
   745       )
   744       )
   746 
   745 
   747 !
   746 !
   748 
   747 
   749 slicesMenu
   748 slicesMenu
   750     ^#(
   749     ^#(
   751             (Basics     basicsMenuSpec)
   750             (Basics     basicsMenuSpec)
   752             (Details    detailsEditSpec)
   751             (Details    detailsEditSpec)
   753             (Misc       miscEditSpec)
   752             (Misc       miscEditSpec)
   754             (Help       help)
       
   755       )
   753       )
   756 
   754 
   757 !
   755 !
   758 
   756 
   759 slicesRootMenu
   757 slicesRootMenu
   788     ^
   786     ^
   789      
   787      
   790        #(#FullSpec
   788        #(#FullSpec
   791           #'window:' 
   789           #'window:' 
   792            #(#WindowSpec
   790            #(#WindowSpec
   793               #'name:' 'uIPainterView'
   791               #'name:' 'BasicsItemSpec'
   794               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   792               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   795               #'label:' 'unnamed canvas'
   793               #'label:' 'unnamed canvas'
   796               #'bounds:' #(#Rectangle 0 0 267 319)
   794               #'bounds:' #(#Rectangle 0 0 267 319)
   797           )
   795           )
   798           #'component:' 
   796           #'component:' 
   877     ^
   875     ^
   878      
   876      
   879        #(#FullSpec
   877        #(#FullSpec
   880           #'window:' 
   878           #'window:' 
   881            #(#WindowSpec
   879            #(#WindowSpec
   882               #'name:' 'uIPainterView'
   880               #'name:' 'BasicsLinkSpec'
   883               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   881               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   884               #'label:' 'unnamed canvas'
   882               #'label:' 'unnamed canvas'
   885               #'bounds:' #(#Rectangle 0 0 267 319)
   883               #'bounds:' #(#Rectangle 0 0 267 319)
   886           )
   884           )
   887           #'component:' 
   885           #'component:' 
   950     ^
   948     ^
   951      
   949      
   952        #(#FullSpec
   950        #(#FullSpec
   953           #'window:' 
   951           #'window:' 
   954            #(#WindowSpec
   952            #(#WindowSpec
   955               #'name:' 'uIPainterView'
   953               #'name:' 'BasicsMenuSpec'
   956               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   954               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
   957               #'label:' 'unnamed canvas'
   955               #'label:' 'unnamed canvas'
   958               #'bounds:' #(#Rectangle 0 0 267 319)
   956               #'bounds:' #(#Rectangle 0 0 267 319)
   959           )
   957           )
   960           #'component:' 
   958           #'component:' 
  1011     ^
  1009     ^
  1012      
  1010      
  1013        #(#FullSpec
  1011        #(#FullSpec
  1014           #'window:' 
  1012           #'window:' 
  1015            #(#WindowSpec
  1013            #(#WindowSpec
  1016               #'name:' 'uIPainterView'
  1014               #'name:' 'BasicsRootSpec'
  1017               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1015               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1018               #'label:' 'unnamed canvas'
  1016               #'label:' 'unnamed canvas'
  1019               #'bounds:' #(#Rectangle 0 0 267 319)
  1017               #'bounds:' #(#Rectangle 0 0 267 319)
  1020           )
  1018           )
  1021           #'component:' 
  1019           #'component:' 
  1058     ^
  1056     ^
  1059      
  1057      
  1060        #(#FullSpec
  1058        #(#FullSpec
  1061           #'window:' 
  1059           #'window:' 
  1062            #(#WindowSpec
  1060            #(#WindowSpec
  1063               #'name:' 'uIPainterView'
  1061               #'name:' 'BasicsSeparatorSpec'
  1064               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1062               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1065               #'label:' 'unnamed canvas'
  1063               #'label:' 'unnamed canvas'
  1066               #'bounds:' #(#Rectangle 0 0 267 319)
  1064               #'bounds:' #(#Rectangle 0 0 267 319)
  1067           )
  1065           )
  1068           #'component:' 
  1066           #'component:' 
  1105     ^
  1103     ^
  1106      
  1104      
  1107        #(#FullSpec
  1105        #(#FullSpec
  1108           #'window:' 
  1106           #'window:' 
  1109            #(#WindowSpec
  1107            #(#WindowSpec
  1110               #'name:' 'uIPainterView'
  1108               #'name:' 'DetailsEditSpec'
  1111               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1109               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1112               #'label:' 'unnamed canvas'
  1110               #'label:' 'unnamed canvas'
  1113               #'bounds:' #(#Rectangle 0 0 259 288)
  1111               #'bounds:' #(#Rectangle 0 0 259 288)
  1114           )
  1112           )
  1115           #'component:' 
  1113           #'component:' 
  1181     ^
  1179     ^
  1182      
  1180      
  1183        #(#FullSpec
  1181        #(#FullSpec
  1184           #'window:' 
  1182           #'window:' 
  1185            #(#WindowSpec
  1183            #(#WindowSpec
  1186               #'name:' 'uIPainterView'
  1184               #'name:' 'MiscEditSpec'
  1187               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1185               #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
  1188               #'label:' 'unnamed canvas'
  1186               #'label:' 'unnamed canvas'
  1189               #'bounds:' #(#Rectangle 0 0 245 142)
  1187               #'bounds:' #(#Rectangle 0 0 245 142)
  1190           )
  1188           )
  1191           #'component:' 
  1189           #'component:' 
  1279     menu allItemsDo:[:anItem|
  1277     menu allItemsDo:[:anItem|
  1280         anItem value:nil.
  1278         anItem value:nil.
  1281         anItem enabled:true.
  1279         anItem enabled:true.
  1282     ].
  1280     ].
  1283   ^ menu
  1281   ^ menu
       
  1282 !
       
  1283 
       
  1284 useHelpDictionary:aDictionary
       
  1285     |tool|
       
  1286 
       
  1287     self noteBookView.
       
  1288     self helpTool dictionary:aDictionary.
  1284 ! !
  1289 ! !
  1285 
  1290 
  1286 !MenuEditor methodsFor:'accessing menu'!
  1291 !MenuEditor methodsFor:'accessing menu'!
  1287 
  1292 
  1288 menuButtons
  1293 menuButtons
  1311     painter := self painter.
  1316     painter := self painter.
  1312     node := painter selectedNode.
  1317     node := painter selectedNode.
  1313 
  1318 
  1314     node notNil ifTrue:[
  1319     node notNil ifTrue:[
  1315         self isHelpToolSelected ifTrue:[
  1320         self isHelpToolSelected ifTrue:[
  1316             self activeHelpTool accept
  1321             self helpTool accept.
  1317         ].
  1322             node contents activeHelpKey:(self helpTool helpKey)
  1318         cont := node contents buildFromAspects:aspects.
  1323         ] ifFalse:[
  1319         painter selectedNodeChanged
  1324             cont := node contents buildFromAspects:aspects.
       
  1325             painter selectedNodeChanged
       
  1326         ]
  1320     ].
  1327     ].
  1321     self modifiedChannel value:false.
  1328     self modifiedChannel value:false.
  1322     didInstall := true
  1329     didInstall := true
  1323 
       
  1324     "Modified: 31.7.1997 / 14:25:34 / cg"
       
  1325 !
  1330 !
  1326 
  1331 
  1327 cancel
  1332 cancel
  1328     |node|
  1333     |node|
  1329 
  1334 
  1330     (node := self painter selectedNode) notNil ifTrue:[
  1335     (node := self painter selectedNode) notNil ifTrue:[
       
  1336         self helpTool helpKey:(self helpKey).
  1331         aspects do:[:anAspect| anAspect value:nil ].
  1337         aspects do:[:anAspect| anAspect value:nil ].
  1332         node contents toAspects:aspects.
  1338         node contents toAspects:aspects.
  1333     ].
  1339     ].
  1334     self modifiedChannel value:false.
  1340     self modifiedChannel value:false.
  1335 
  1341 
  1336 ! !
  1342 ! !
  1337 
  1343 
  1338 !MenuEditor methodsFor:'active help'!
       
  1339 
       
  1340 activeHelpTool
       
  1341     "access current active help editor
       
  1342     "
       
  1343     activeHelpTool isNil ifTrue:[
       
  1344         self activeHelpTool:(UIHelpTool new)
       
  1345     ].
       
  1346   ^ activeHelpTool
       
  1347 !
       
  1348 
       
  1349 activeHelpTool:anApplication
       
  1350     "change current active help editor
       
  1351     "
       
  1352     activeHelpTool := anApplication.
       
  1353 
       
  1354     activeHelpTool masterApplication isNil ifTrue:[
       
  1355         activeHelpTool masterApplication:self.
       
  1356     ].
       
  1357 !
       
  1358 
       
  1359 isOwnerOfHelpTool
       
  1360     "returns true in case of owner of the helptool
       
  1361     "
       
  1362   ^ self activeHelpTool masterApplication == self
       
  1363 ! !
       
  1364 
       
  1365 !MenuEditor methodsFor:'aspects'!
  1344 !MenuEditor methodsFor:'aspects'!
  1366 
  1345 
  1367 aspectFor:aKey
  1346 aspectFor:aKey
  1368     "returns aspect for a key or nil
  1347     "returns aspect for a key or nil
  1369     "
  1348     "
  1406     ^ builder booleanValueAspectFor:#hasValidSingleSelection
  1385     ^ builder booleanValueAspectFor:#hasValidSingleSelection
  1407 
  1386 
  1408     "Modified: 28.7.1997 / 12:52:13 / cg"
  1387     "Modified: 28.7.1997 / 12:52:13 / cg"
  1409 !
  1388 !
  1410 
  1389 
  1411 menuPullDown
       
  1412     |menu|
       
  1413 
       
  1414     menu := Menu new.
       
  1415     menu fromLiteralArrayEncoding:(self class menuPullDown).
       
  1416     menu receiver:self.
       
  1417   ^ menu
       
  1418 
       
  1419 
       
  1420 !
       
  1421 
       
  1422 modifiedChannel
  1390 modifiedChannel
  1423     "automatically generated by UIPainter ..."
  1391     "automatically generated by UIPainter ..."
  1424 
  1392 
  1425     ^ builder booleanValueAspectFor:#modifiedChannel
  1393     ^ builder booleanValueAspectFor:#modifiedChannel
  1426 
  1394 
  1427     "Modified: 28.7.1997 / 12:52:14 / cg"
  1395     "Modified: 28.7.1997 / 12:52:14 / cg"
  1428 !
  1396 !
  1429 
  1397 
  1430 tabCanvas
  1398 noteBookView
  1431     "automatically generated by UIPainter ..."
  1399     "automatically generated by UIPainter ..."
  1432 
  1400 
  1433     |holder|
  1401     |noteBook helpTool|
  1434 
  1402 
  1435     (holder := builder bindingAt:#tabCanvas) isNil ifTrue:[
  1403     (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
  1436         builder aspectAt:#tabCanvas put:(holder :=  SubCanvas new).
  1404         noteBook := View new.
  1437     ].
  1405         helpTool := UIHelpTool new.
  1438     ^ holder
  1406 
       
  1407         helpTool masterApplication:self.
       
  1408         helpCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
       
  1409         specCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
       
  1410 
       
  1411         helpCanvas client:helpTool.
       
  1412         helpTool   masterApplication:self.
       
  1413         helpTool   modifiedHolder:(self modifiedChannel).
       
  1414 
       
  1415         builder aspectAt:#noteBookView put:noteBook.
       
  1416     ].
       
  1417     ^ noteBook
  1439 !
  1418 !
  1440 
  1419 
  1441 tabList
  1420 tabList
  1442     "automatically generated by UIPainter ..."
  1421     "automatically generated by UIPainter ..."
  1443 
  1422 
  1515    super doesNotUnderstand:aMessage
  1494    super doesNotUnderstand:aMessage
  1516 
  1495 
  1517 
  1496 
  1518 ! !
  1497 ! !
  1519 
  1498 
       
  1499 !MenuEditor methodsFor:'interface specs'!
       
  1500 
       
  1501 menuPullDown
       
  1502     "this window spec was automatically generated by the ST/X MenuEditor"
       
  1503 
       
  1504     "do not manually edit this - the builder may not be able to
       
  1505      handle the specification if its corrupted."
       
  1506 
       
  1507     "
       
  1508      MenuEditor new openOnClass:MenuEditor andSelector:#menuPullDown
       
  1509      (Menu new fromLiteralArrayEncoding:(MenuEditor menuPullDown)) startUp
       
  1510     "
       
  1511 
       
  1512     <resource: #menu>
       
  1513 
       
  1514     ^
       
  1515      
       
  1516        #(#Menu
       
  1517           
       
  1518            #(
       
  1519              #(#MenuItem
       
  1520                 #'label:' 'file'
       
  1521                 #'value:' #file
       
  1522                 #'submenu:' 
       
  1523                  #(#Menu
       
  1524                     
       
  1525                      #(
       
  1526                        #(#MenuItem
       
  1527                           #'label:' 'new'
       
  1528                           #'value:' #doNew
       
  1529                       )
       
  1530                        #(#MenuItem
       
  1531                           #'label:' 'from class ...'
       
  1532                           #'value:' #doFromClass
       
  1533                           #'enabled:' #isStandAlone
       
  1534                       )
       
  1535                        #(#MenuItem
       
  1536                           #'label:' 'pick a menu'
       
  1537                           #'value:' #doPickAMenu
       
  1538                           #'enabled:' #isStandAlone
       
  1539                       )
       
  1540                        #(#MenuItem
       
  1541                           #'label:' '='
       
  1542                       )
       
  1543                        #(#MenuItem
       
  1544                           #'label:' 'quit'
       
  1545                           #'value:' #closeRequest
       
  1546                       )
       
  1547                     ) nil
       
  1548                     nil
       
  1549                 )
       
  1550             )
       
  1551              #(#MenuItem
       
  1552                 #'label:' 'edit'
       
  1553                 #'submenu:' 
       
  1554                  #(#Menu
       
  1555                     
       
  1556                      #(
       
  1557                        #(#MenuItem
       
  1558                           #'label:' 'cut'
       
  1559                           #'value:' #doCut
       
  1560                       )
       
  1561                        #(#MenuItem
       
  1562                           #'label:' '='
       
  1563                       )
       
  1564                        #(#MenuItem
       
  1565                           #'label:' 'create submenu static'
       
  1566                           #'value:' #doCreateMenu
       
  1567                       )
       
  1568                        #(#MenuItem
       
  1569                           #'label:' 'create summenu dynamic'
       
  1570                           #'value:' #doCreateLink
       
  1571                       )
       
  1572                        #(#MenuItem
       
  1573                           #'label:' '-'
       
  1574                       )
       
  1575                        #(#MenuItem
       
  1576                           #'label:' 'create item'
       
  1577                           #'value:' #doCreateItem
       
  1578                       )
       
  1579                        #(#MenuItem
       
  1580                           #'label:' 'create separator'
       
  1581                           #'value:' #doCreateSep
       
  1582                       )
       
  1583                     ) nil
       
  1584                     nil
       
  1585                 )
       
  1586             )
       
  1587              #(#MenuItem
       
  1588                 #'label:' 'code'
       
  1589                 #'value:' #code
       
  1590                 #'submenu:' 
       
  1591                  #(#Menu
       
  1592                     
       
  1593                      #(
       
  1594                        #(#MenuItem
       
  1595                           #'label:' 'class'
       
  1596                           #'value:' #doDefineClass
       
  1597                           #'enabled:' #isStandAlone
       
  1598                       )
       
  1599                        #(#MenuItem
       
  1600                           #'label:' '-'
       
  1601                       )
       
  1602                        #(#MenuItem
       
  1603                           #'label:' 'install menu spec.'
       
  1604                           #'value:' #doInstallSpec
       
  1605                       )
       
  1606                        #(#MenuItem
       
  1607                           #'label:' 'install help spec.'
       
  1608                           #'value:' #doInstallHelp
       
  1609                           #'enabled:' #isStandAlone
       
  1610                       )
       
  1611                        #(#MenuItem
       
  1612                           #'label:' '='
       
  1613                       )
       
  1614                        #(#MenuItem
       
  1615                           #'label:' 'browse application'
       
  1616                           #'value:' #doBrowseAppClass
       
  1617                       )
       
  1618                     ) nil
       
  1619                     nil
       
  1620                 )
       
  1621             )
       
  1622              #(#MenuItem
       
  1623                 #'label:' 'test'
       
  1624                 #'submenuChannel:' #submenuTest
       
  1625             )
       
  1626           ) nil
       
  1627           nil
       
  1628       )
       
  1629 
       
  1630     "Modified: 28.7.1997 / 18:12:10 / cg"
       
  1631 ! !
       
  1632 
       
  1633 !MenuEditor methodsFor:'private'!
       
  1634 
       
  1635 helpKey
       
  1636     |node|
       
  1637 
       
  1638     (node := self painter selectedNode) notNil ifTrue:[
       
  1639         ^ node contents activeHelpKey
       
  1640     ].
       
  1641     ^ nil
       
  1642 !
       
  1643 
       
  1644 helpTool
       
  1645     ^ helpCanvas application
       
  1646 ! !
       
  1647 
  1520 !MenuEditor methodsFor:'queries'!
  1648 !MenuEditor methodsFor:'queries'!
  1521 
  1649 
  1522 didInstall
  1650 didInstall
  1523     "returns true if the menu was installed
  1651     "returns true if the menu was installed
  1524     "
  1652     "
  1529 !
  1657 !
  1530 
  1658 
  1531 isHelpToolSelected
  1659 isHelpToolSelected
  1532     "returns true if current selection is help tool
  1660     "returns true if current selection is help tool
  1533     "
  1661     "
  1534     (slices notNil and:[tabSelection notNil]) ifTrue:[
  1662     slices notNil ifTrue:[
  1535         ^ (slices at:tabSelection) last == #help
  1663         ^ (slices at:tabSelection) first = UIHelpTool label
  1536     ].
  1664     ].
  1537   ^ false
  1665     ^ false
       
  1666 !
       
  1667 
       
  1668 isStandAlone
       
  1669     "returns true in case of owner of the helptool
       
  1670     "
       
  1671     ^ self masterApplication isNil
  1538 ! !
  1672 ! !
  1539 
  1673 
  1540 !MenuEditor methodsFor:'selection'!
  1674 !MenuEditor methodsFor:'selection'!
  1541 
  1675 
  1542 menuChanged
  1676 menuChanged
  1543     |node item slc sel|
  1677     |node item slc sel old|
  1544 
  1678 
  1545     (node := self painter selectedNode) notNil ifTrue:[
  1679     (node := self painter selectedNode) notNil ifTrue:[
  1546         aspects do:[:anAspect| anAspect value:nil ].
  1680         aspects do:[:anAspect| anAspect value:nil ].
  1547         item := node contents.
  1681         item := node contents.
  1548         item toAspects:aspects.
  1682         item toAspects:aspects.
  1553                     slc := #slicesMenu
  1687                     slc := #slicesMenu
  1554                 ] ifFalse:[
  1688                 ] ifFalse:[
  1555                     item submenuChannel isNil ifTrue:[slc := #slicesItem]
  1689                     item submenuChannel isNil ifTrue:[slc := #slicesItem]
  1556                                              ifFalse:[slc := #slicesLink]
  1690                                              ifFalse:[slc := #slicesLink]
  1557                 ].
  1691                 ].
       
  1692                 slc := (self class perform:slc) copyWith:#( 'Help' #dummy ).
  1558             ] ifTrue:[
  1693             ] ifTrue:[
  1559                 slc := #slicesRootMenu
  1694                 slc := self class perform:#slicesRootMenu
  1560             ]
  1695             ].
  1561         ] ifTrue:[
  1696         ] ifTrue:[
  1562             slc := #slicesSeparatorMenu
  1697             slc := self class perform:#slicesSeparatorMenu.
       
  1698         ]
       
  1699     ].
       
  1700     self helpTool helpKey:(self helpKey).
       
  1701     self modifiedChannel value:false.
       
  1702 
       
  1703     slc ~= slices  ifTrue:[
       
  1704         tabSelection notNil ifTrue:[
       
  1705             old := (slices at:tabSelection) first
  1563         ].
  1706         ].
  1564         slc := self class perform:slc.
  1707 
  1565     ].
       
  1566     self modifiedChannel value:false.
       
  1567 
       
  1568     slc ~= slices  ifTrue:[
       
  1569         (slices := slc) notNil ifTrue:[
  1708         (slices := slc) notNil ifTrue:[
  1570             tabSelection notNil ifTrue:[sel := tabSelection min:(slices size)]
  1709             sel := slices collect:[:s| s first].
  1571                                ifFalse:[sel := 1].
  1710             tabSelection := nil.
  1572 
  1711             self tabList value:sel.
  1573             self tabList value:(slices collect:[:s| s first]).
  1712 
  1574             self tabModel setValue:nil.
  1713             (old notNil and:[(sel := sel findFirst:[:n|n = old]) ~~ 0]) ifFalse:[
  1575             self tabModel value:sel.
  1714                 sel := 1
       
  1715             ].
       
  1716             self tabModel value:sel
  1576         ] ifFalse:[
  1717         ] ifFalse:[
  1577             self tabList value:nil.
  1718             self tabList value:nil.
  1578             self tabSelection:nil.
  1719             self tabSelection:nil.
  1579         ]
  1720         ]
  1580     ].
  1721     ].
  1586 !
  1727 !
  1587 
  1728 
  1588 tabSelection:aSelection
  1729 tabSelection:aSelection
  1589     |tool sel|
  1730     |tool sel|
  1590 
  1731 
  1591     tabSelection == aSelection ifTrue:[
  1732     tabSelection = aSelection ifTrue:[
  1592         ^ self
  1733         ^ self
  1593     ].
  1734     ].
  1594 
  1735 
  1595     (tabSelection := aSelection) isNil ifTrue:[
  1736     (tabSelection := aSelection) isNil ifTrue:[
  1596       ^ self tabCanvas client:nil
  1737         slices isNil ifTrue:[
  1597     ].
  1738             specCanvas client:nil.
       
  1739             ^ specCanvas raise.
       
  1740         ].
       
  1741         tabSelection == 1 ifTrue:[^ self].
       
  1742         tabSelection := 1
       
  1743     ].
       
  1744 
  1598     self isHelpToolSelected ifTrue:[
  1745     self isHelpToolSelected ifTrue:[
  1599         self tabCanvas client:(tool := self activeHelpTool).
  1746         self helpTool helpKey:(self helpKey).
  1600         tool model:(self aspectFor:#activeHelpKey)
  1747         helpCanvas raise.
  1601     ] ifFalse:[
  1748     ] ifFalse:[
  1602         sel := (slices at:tabSelection) last.
  1749         sel := (slices at:tabSelection) last.
  1603         self tabCanvas client:self spec:(self class perform:sel) builder:builder
  1750         specCanvas client:self spec:(self class perform:sel) builder:builder.
       
  1751         specCanvas raise.
  1604     ]    
  1752     ]    
  1605 ! !
  1753 ! !
  1606 
  1754 
  1607 !MenuEditor methodsFor:'startup / release'!
  1755 !MenuEditor methodsFor:'startup / release'!
  1608 
  1756 
  1611 
  1759 
  1612     oldClass := self specClass.
  1760     oldClass := self specClass.
  1613     self specClass:aClass.
  1761     self specClass:aClass.
  1614     newClass := self specClass.
  1762     newClass := self specClass.
  1615 
  1763 
  1616     (self isOwnerOfHelpTool and:[oldClass ~= newClass]) ifTrue:[
  1764     (self isStandAlone and:[oldClass ~= newClass]) ifTrue:[
  1617         self activeHelpTool helpSpecFrom:newClass
  1765         self helpTool helpSpecFrom:newClass
  1618     ].
  1766     ].
  1619     self painter buildFrom:newClass andSelector:aSelector.
  1767     self painter buildFrom:newClass andSelector:aSelector.
  1620 !
  1768 !
  1621 
  1769 
  1622 initialize
  1770 initialize
  1629 
  1777 
  1630     #(
  1778     #(
  1631         label
  1779         label
  1632         accessCharaterPos
  1780         accessCharaterPos
  1633         submenuChannel
  1781         submenuChannel
  1634         activeHelpKey
       
  1635         enabled
  1782         enabled
  1636         value
  1783         value
  1637         nameKey
  1784         nameKey
  1638         indication
  1785         indication
  1639         shortcutKey
  1786         shortcutKey
  1740 !
  1887 !
  1741 
  1888 
  1742 doInstallHelp
  1889 doInstallHelp
  1743     "install help text
  1890     "install help text
  1744     "
  1891     "
  1745     self activeHelpTool installHelpSpecInto:(self specClass)
  1892     self isStandAlone ifTrue:[
       
  1893         self helpTool installHelpSpecInto:(self specClass)
       
  1894     ]
  1746 !
  1895 !
  1747 
  1896 
  1748 doInstallSpec
  1897 doInstallSpec
  1749     |cls selector painter menu spec mthd category code|
  1898     |cls selector painter menu spec mthd category code|
  1750 
  1899 
  1912 
  2061 
  1913 ! !
  2062 ! !
  1914 
  2063 
  1915 !MenuEditor::Item methodsFor:'accessing'!
  2064 !MenuEditor::Item methodsFor:'accessing'!
  1916 
  2065 
       
  2066 activeHelpKey
       
  2067     ^ activeHelpKey
       
  2068 !
       
  2069 
       
  2070 activeHelpKey:aKey
       
  2071     activeHelpKey := aKey
       
  2072 !
       
  2073 
  1917 label
  2074 label
  1918     "return the value of the instance variable 'label' (automatically generated)"
  2075     "return the value of the instance variable 'label' (automatically generated)"
  1919 
  2076 
  1920     ^ label!
  2077     ^ label!
  1921 
  2078 
  1995 
  2152 
  1996         (label isNil or:[self isSeparator]) ifTrue:[
  2153         (label isNil or:[self isSeparator]) ifTrue:[
  1997             (aspects at:#label) value:(label := name)
  2154             (aspects at:#label) value:(label := name)
  1998         ].
  2155         ].
  1999 
  2156 
  2000         activeHelpKey       := (aspects at:#activeHelpKey) value.
       
  2001         enabled             := (aspects at:#enabled) value.
  2157         enabled             := (aspects at:#enabled) value.
  2002         value               := (aspects at:#value) value.
  2158         value               := (aspects at:#value) value.
  2003         nameKey             := (aspects at:#nameKey) value.
  2159         nameKey             := (aspects at:#nameKey) value.
  2004         indication          := (aspects at:#indication) value.
  2160         indication          := (aspects at:#indication) value.
  2005         shortcutKey         := (aspects at:#shortcutKey) value.
  2161         shortcutKey         := (aspects at:#shortcutKey) value.
  2055     (type := self separatorType) notNil ifTrue:[
  2211     (type := self separatorType) notNil ifTrue:[
  2056         type := self class separatorSlices findFirst:[:el| el first == type ].
  2212         type := self class separatorSlices findFirst:[:el| el first == type ].
  2057         (aspects at:#seperatorSelection) selectionIndex:type.
  2213         (aspects at:#seperatorSelection) selectionIndex:type.
  2058     ] ifFalse:[
  2214     ] ifFalse:[
  2059         (aspects at:#label)                 value:label.
  2215         (aspects at:#label)                 value:label.
  2060         (aspects at:#activeHelpKey)         value:activeHelpKey.
       
  2061         (aspects at:#enabled)               value:enabled.
  2216         (aspects at:#enabled)               value:enabled.
  2062         (aspects at:#value)                 value:value.
  2217         (aspects at:#value)                 value:value.
  2063         (aspects at:#nameKey)               value:nameKey.
  2218         (aspects at:#nameKey)               value:nameKey.
  2064         (aspects at:#indication)            value:indication.
  2219         (aspects at:#indication)            value:indication.
  2065         (aspects at:#shortcutKey)           value:shortcutKey.
  2220         (aspects at:#shortcutKey)           value:shortcutKey.