MenuEditor.st
changeset 356 269c117830ba
parent 340 1de048872d5e
child 359 6193ef5b6e74
equal deleted inserted replaced
355:0be3ff56e799 356:269c117830ba
    11 "
    11 "
    12 
    12 
    13 
    13 
    14 
    14 
    15 ApplicationModel subclass:#MenuEditor
    15 ApplicationModel subclass:#MenuEditor
    16 	instanceVariableNames:'specClass specCanvas helpCanvas tabSelection aspects slices
    16 	instanceVariableNames:'isModified specClass specCanvas helpCanvas tabSelection aspects
    17 		didInstall'
    17 		slices didInstall'
    18 	classVariableNames:''
    18 	classVariableNames:''
    19 	poolDictionaries:''
    19 	poolDictionaries:''
    20 	category:'Interface-UIPainter'
    20 	category:'Interface-UIPainter'
    21 !
    21 !
    22 
    22 
   464            #(
   464            #(
   465              #(#MenuItem
   465              #(#MenuItem
   466                 #'label:' 'copy'
   466                 #'label:' 'copy'
   467                 #'value:' #doCopy
   467                 #'value:' #doCopy
   468                 #'enabled:' #hasValidSelection
   468                 #'enabled:' #hasValidSelection
       
   469                 #'shortcutKeyCharacter:' #Copy
   469             )
   470             )
   470              #(#MenuItem
   471              #(#MenuItem
   471                 #'label:' 'cut'
   472                 #'label:' 'cut'
   472                 #'value:' #doCut
   473                 #'value:' #doCut
   473                 #'enabled:' #hasValidSelection
   474                 #'enabled:' #hasValidSelection
       
   475                 #'shortcutKeyCharacter:' #Cut
   474             )
   476             )
   475              #(#MenuItem
   477              #(#MenuItem
   476                 #'label:' 'paste'
   478                 #'label:' 'paste'
   477                 #'value:' #doPaste
   479                 #'value:' #doPaste
   478                 #'enabled:' #hasAnySingleSelection
   480                 #'enabled:' #hasAnySingleSelection
       
   481                 #'shortcutKeyCharacter:' #Paste
   479             )
   482             )
   480              #(#MenuItem
   483              #(#MenuItem
   481                 #'label:' '-'
   484                 #'label:' '-'
   482             )
   485             )
   483              #(#MenuItem
   486              #(#MenuItem
  1378             cont := node contents buildFromAspects:aspects.
  1381             cont := node contents buildFromAspects:aspects.
  1379             painter selectedNodeChanged
  1382             painter selectedNodeChanged
  1380         ]
  1383         ]
  1381     ].
  1384     ].
  1382     self modifiedChannel value:false.
  1385     self modifiedChannel value:false.
  1383     didInstall := true
  1386     isModified := true.
  1384 !
  1387 !
  1385 
  1388 
  1386 cancel
  1389 cancel
  1387     |node|
  1390     |node|
  1388 
  1391 
  1500 !MenuEditor methodsFor:'change & update'!
  1503 !MenuEditor methodsFor:'change & update'!
  1501 
  1504 
  1502 update:something with:aParameter from:changedObject
  1505 update:something with:aParameter from:changedObject
  1503     "one of my models changed its value
  1506     "one of my models changed its value
  1504     "
  1507     "
  1505     self modifiedChannel value:true
  1508     self modifiedChannel value:true.
  1506 !
  1509 !
  1507 
  1510 
  1508 updateEnabledChannels
  1511 updateEnabledChannels
  1509     "update enabled channels
  1512     "update enabled channels
  1510     "
  1513     "
  1574 
  1577 
  1575 didInstall
  1578 didInstall
  1576     "returns true if the menu was installed
  1579     "returns true if the menu was installed
  1577     "
  1580     "
  1578 
  1581 
  1579     ^ didInstall ? false
  1582     ^ didInstall
  1580 
       
  1581     "Created: 31.7.1997 / 14:24:24 / cg"
       
  1582 !
  1583 !
  1583 
  1584 
  1584 isHelpToolSelected
  1585 isHelpToolSelected
  1585     "returns true if current selection is help tool
  1586     "returns true if current selection is help tool
  1586     "
  1587     "
  1693         self helpTool helpSpecFrom:newClass
  1694         self helpTool helpSpecFrom:newClass
  1694     ].
  1695     ].
  1695     self painter buildFrom:newClass andSelector:aSelector.
  1696     self painter buildFrom:newClass andSelector:aSelector.
  1696 !
  1697 !
  1697 
  1698 
       
  1699 closeRequest
       
  1700     "close request
       
  1701     "
       
  1702     isModified ifTrue:[
       
  1703         (self confirm:'quit without without saving your modifications ?') ifFalse:[
       
  1704             ^ self
       
  1705         ]
       
  1706     ].
       
  1707     super closeRequest.
       
  1708 
       
  1709 
       
  1710 
       
  1711 
       
  1712 
       
  1713 !
       
  1714 
  1698 initialize
  1715 initialize
  1699     "initialize channels
  1716     "initialize channels
  1700     "
  1717     "
  1701     |holder|
  1718     |holder|
  1702 
  1719 
  1744 !
  1761 !
  1745 
  1762 
  1746 postBuildWith:builder
  1763 postBuildWith:builder
  1747     |cls sel|
  1764     |cls sel|
  1748 
  1765 
       
  1766     didInstall := false.
       
  1767     isModified := false.
       
  1768 
  1749     specClass isAssociation ifTrue:[
  1769     specClass isAssociation ifTrue:[
  1750         cls := specClass key.
  1770         cls := specClass key.
  1751         sel := specClass value.
  1771         sel := specClass value.
  1752 
  1772 
  1753         specClass := nil.
  1773         specClass := nil.
  1760     ].
  1780     ].
  1761     self buildFrom:cls andSelector:sel.
  1781     self buildFrom:cls andSelector:sel.
  1762 ! !
  1782 ! !
  1763 
  1783 
  1764 !MenuEditor methodsFor:'user interactions'!
  1784 !MenuEditor methodsFor:'user interactions'!
  1765 
       
  1766 closeRequest
       
  1767     "close the window - confirm if changed without saving
       
  1768     "
       
  1769     self modifiedChannel value ifTrue:[
       
  1770         (self confirm:'quit without without saving your modifications ?') ifFalse:[
       
  1771             ^ self
       
  1772         ]
       
  1773     ].
       
  1774 
       
  1775     super closeRequest.
       
  1776 
       
  1777     "Modified: 31.7.1997 / 14:29:10 / cg"
       
  1778 !
       
  1779 
  1785 
  1780 doBrowseAppClass
  1786 doBrowseAppClass
  1781     "open a browser on the class"
  1787     "open a browser on the class"
  1782 
  1788 
  1783     |cls|
  1789     |cls|
  1877     (cls compiledMethodAt:selector) isNil ifTrue:[
  1883     (cls compiledMethodAt:selector) isNil ifTrue:[
  1878         code := self class generateCodeFor:cls menuSelector:selector.
  1884         code := self class generateCodeFor:cls menuSelector:selector.
  1879         code := code withCRs.
  1885         code := code withCRs.
  1880         (ReadStream on:code) fileIn.
  1886         (ReadStream on:code) fileIn.
  1881     ].
  1887     ].
  1882 
  1888     didInstall := true.
       
  1889     isModified := false.
  1883 
  1890 
  1884 !
  1891 !
  1885 
  1892 
  1886 doNew
  1893 doNew
  1887     self buildFrom:nil andSelector:(self painter selectorName)
  1894     self buildFrom:nil andSelector:(self painter selectorName)
  2404         ^ images at:#menuClosed
  2411         ^ images at:#menuClosed
  2405     ].
  2412     ].
  2406     ^ images at:#menuOpen
  2413     ^ images at:#menuOpen
  2407 ! !
  2414 ! !
  2408 
  2415 
       
  2416 !MenuEditor::Painter methodsFor:'event handling'!
       
  2417 
       
  2418 keyPress:key x:x y:y
       
  2419     "any key pressed
       
  2420     "
       
  2421     <resource: #keyboard ( #Delete #BackSpace #Cut #Copy #Paste ) >
       
  2422 
       
  2423     (key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
       
  2424         ^ self doCut
       
  2425     ].
       
  2426 
       
  2427     key == #Copy  ifTrue:[ ^ self doCopy].
       
  2428     key == #Paste ifTrue:[ ^ self doPaste].
       
  2429 
       
  2430     super keyPress:key x:x y:y.
       
  2431 
       
  2432 ! !
       
  2433 
  2409 !MenuEditor::Painter methodsFor:'initialization'!
  2434 !MenuEditor::Painter methodsFor:'initialization'!
  2410 
  2435 
  2411 fetchImageResources
  2436 fetchImageResources
  2412     "initialize heavily used device resources - to avoid rendering
  2437     "initialize heavily used device resources - to avoid rendering
  2413      images again and again later; returns maximum extent of the images used.
  2438      images again and again later; returns maximum extent of the images used.