MenuEditor.st
changeset 1322 fbc9a32078b5
parent 1321 7894e542c64b
child 1330 45983bc2efe1
equal deleted inserted replaced
1321:7894e542c64b 1322:fbc9a32078b5
  1277        #(#WindowSpec
  1277        #(#WindowSpec
  1278           #label: 'Menu Editor'
  1278           #label: 'Menu Editor'
  1279           #name: 'Menu Editor'
  1279           #name: 'Menu Editor'
  1280           #min: #(#Point 550 440)
  1280           #min: #(#Point 550 440)
  1281           #max: #(#Point 1152 900)
  1281           #max: #(#Point 1152 900)
  1282           #bounds: #(#Rectangle 37 413 594 853)
  1282           #bounds: #(#Rectangle 12 22 569 462)
  1283           #menu: #menu
  1283           #menu: #menu
  1284           #returnIsOKInDialog: false
  1284           #returnIsOKInDialog: false
  1285           #escapeIsCancelInDialog: false
  1285           #escapeIsCancelInDialog: false
  1286         )
  1286         )
  1287         #component: 
  1287         #component: 
  1288        #(#SpecCollection
  1288        #(#SpecCollection
  1289           #collection: #(
  1289           #collection: #(
  1290            #(#MenuPanelSpec
  1290            #(#MenuPanelSpec
       
  1291               #attributes: 
       
  1292              #(#tabable
       
  1293                 true
       
  1294               )
  1291               #name: 'menuToolbarView'
  1295               #name: 'menuToolbarView'
  1292               #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0)
  1296               #layout: #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0)
       
  1297               #tabable: true
  1293               #menu: #menuToolbar
  1298               #menu: #menuToolbar
  1294               #showSeparatingLines: true
  1299               #showSeparatingLines: true
  1295             )
  1300             )
  1296            #(#VariableHorizontalPanelSpec
  1301            #(#VariableHorizontalPanelSpec
  1297               #name: 'VariableHorizontalPanel'
  1302               #name: 'VariableHorizontalPanel'
  1312                     #level: -1
  1317                     #level: -1
  1313                     #component: 
  1318                     #component: 
  1314                    #(#SpecCollection
  1319                    #(#SpecCollection
  1315                       #collection: #(
  1320                       #collection: #(
  1316                        #(#NoteBookViewSpec
  1321                        #(#NoteBookViewSpec
       
  1322                           #attributes: 
       
  1323                          #(#tabable
       
  1324                             true
       
  1325                           )
  1317                           #name: 'NoteBook'
  1326                           #name: 'NoteBook'
  1318                           #layout: #(#LayoutFrame 1 0.0 0 0.0 1 1.0 -30 1.0)
  1327                           #layout: #(#LayoutFrame 1 0.0 0 0.0 1 1.0 -30 1.0)
  1319                           #enableChannel: #hasAnySingleSelection
  1328                           #enableChannel: #hasAnySingleSelection
  1320                           #tabable: true
  1329                           #tabable: true
  1321                           #model: #tabModel
  1330                           #model: #tabModel
  1788      (Menu new fromLiteralArrayEncoding:(MenuEditor menuToolbar)) startUp
  1797      (Menu new fromLiteralArrayEncoding:(MenuEditor menuToolbar)) startUp
  1789     "
  1798     "
  1790 
  1799 
  1791     <resource: #menu>
  1800     <resource: #menu>
  1792 
  1801 
  1793     ^
  1802     ^ 
  1794      
  1803      #(#Menu
  1795        #(#Menu
  1804         #(
  1796           
  1805          #(#MenuItem
  1797            #(
  1806             #label: 'New'
  1798              #(#MenuItem
  1807             #isButton: true
  1799                 #label: 'New'
  1808             #value: #doNew
  1800                 #isButton: true
  1809             #activeHelpKey: #fileNew
  1801                 #value: #doNew
  1810             #labelImage: #(#ResourceRetriever #Icon #newIcon)
  1802                 #activeHelpKey: #fileNew
  1811           )
  1803                 #labelImage: #(#ResourceRetriever #Icon #newIcon)
  1812          #(#MenuItem
  1804             )
  1813             #label: 'Load'
  1805              #(#MenuItem
  1814             #isButton: true
  1806                 #label: 'Load'
  1815             #value: #doLoad
  1807                 #isButton: true
  1816             #activeHelpKey: #fileLoad
  1808                 #value: #doLoad
  1817             #labelImage: #(#ResourceRetriever #Icon #loadIcon)
  1809                 #activeHelpKey: #fileLoad
  1818           )
  1810                 #labelImage: #(#ResourceRetriever #Icon #loadIcon)
  1819          #(#MenuItem
  1811             )
  1820             #label: 'Save'
  1812              #(#MenuItem
  1821             #isButton: true
  1813                 #label: 'Save'
  1822             #value: #doSave
  1814                 #isButton: true
  1823             #activeHelpKey: #fileSave
  1815                 #value: #doSave
  1824             #labelImage: #(#ResourceRetriever #Icon #saveIcon)
  1816                 #activeHelpKey: #fileSave
  1825           )
  1817                 #labelImage: #(#ResourceRetriever #Icon #saveIcon)
  1826          #(#MenuItem
  1818             )
  1827             #label: ''
  1819              #(#MenuItem
  1828           )
  1820                 #label: ''
  1829          #(#MenuItem
  1821             )
  1830             #label: 'Cut'
  1822              #(#MenuItem
  1831             #isButton: true
  1823                 #label: 'Cut'
  1832             #value: #doCut
  1824                 #isButton: true
  1833             #activeHelpKey: #editCut
  1825                 #value: #doCut
  1834             #enabled: #hasValidSelection
  1826                 #activeHelpKey: #editCut
  1835             #labelImage: #(#ResourceRetriever #Icon #cutIcon)
  1827                 #enabled: #hasValidSelection
  1836           )
  1828                 #labelImage: #(#ResourceRetriever #Icon #cutIcon)
  1837          #(#MenuItem
  1829             )
  1838             #label: 'Copy'
  1830              #(#MenuItem
  1839             #isButton: true
  1831                 #label: 'Copy'
  1840             #value: #doCopy
  1832                 #isButton: true
  1841             #activeHelpKey: #editCopy
  1833                 #value: #doCopy
  1842             #enabled: #hasValidSelection
  1834                 #activeHelpKey: #editCopy
  1843             #labelImage: #(#ResourceRetriever #Icon #copyIcon)
  1835                 #enabled: #hasValidSelection
  1844           )
  1836                 #labelImage: #(#ResourceRetriever #Icon #copyIcon)
  1845          #(#MenuItem
  1837             )
  1846             #label: 'Paste'
  1838              #(#MenuItem
  1847             #isButton: true
  1839                 #label: 'Paste'
  1848             #value: #doPaste
  1840                 #isButton: true
  1849             #activeHelpKey: #editPaste
  1841                 #value: #doPaste
  1850             #enabled: #valueOfCanPaste
  1842                 #activeHelpKey: #editPaste
  1851             #labelImage: #(#ResourceRetriever #Icon #pasteIcon)
  1843                 #enabled: #valueOfCanPaste
  1852           )
  1844                 #labelImage: #(#ResourceRetriever #Icon #pasteIcon)
  1853          #(#MenuItem
  1845             )
  1854             #label: 'Delete'
  1846              #(#MenuItem
  1855             #isButton: true
  1847                 #label: 'Delete'
  1856             #value: #doDelete
  1848                 #isButton: true
  1857             #activeHelpKey: #editDelete
  1849                 #value: #doDelete
  1858             #enabled: #hasValidSelection
  1850                 #activeHelpKey: #editDelete
  1859             #labelImage: #(#ResourceRetriever #Icon #deleteIcon)
  1851                 #enabled: #hasValidSelection
  1860           )
  1852                 #labelImage: #(#ResourceRetriever #Icon #deleteIcon)
  1861          #(#MenuItem
  1853             )
  1862             #label: ''
  1854              #(#MenuItem
  1863           )
  1855                 #label: ''
  1864          #(#MenuItem
  1856             )
  1865             #label: 'Add Item'
  1857              #(#MenuItem
  1866             #isButton: true
  1858                 #label: 'Add Item'
  1867             #value: #doCreateItem
  1859                 #isButton: true
  1868             #activeHelpKey: #addMenuItem
  1860                 #value: #doCreateItem
  1869             #enabled: #hasAnySingleSelection
  1861                 #activeHelpKey: #addMenuItem
  1870             #labelImage: #(#ResourceRetriever nil #menuItemImage)
  1862                 #enabled: #hasAnySingleSelection
  1871           )
  1863                 #labelImage: #(#ResourceRetriever nil #menuItemImage)
  1872          #(#MenuItem
  1864             )
  1873             #label: 'Add Separator'
  1865              #(#MenuItem
  1874             #isButton: true
  1866                 #label: 'Add Separator'
  1875             #value: #doCreateSep
  1867                 #isButton: true
  1876             #activeHelpKey: #addMenuSeparator
  1868                 #value: #doCreateSep
  1877             #enabled: #hasAnySingleSelection
  1869                 #activeHelpKey: #addMenuSeparator
  1878             #labelImage: #(#ResourceRetriever nil #menuSeparatorImage)
  1870                 #enabled: #hasAnySingleSelection
  1879           )
  1871                 #labelImage: #(#ResourceRetriever nil #menuSeparatorImage)
  1880          #(#MenuItem
  1872             )
  1881             #label: 'Add Submenu'
  1873              #(#MenuItem
  1882             #isButton: true
  1874                 #label: 'Add Submenu'
  1883             #value: #doCreateMenu
  1875                 #isButton: true
  1884             #activeHelpKey: #addSubMenu
  1876                 #value: #doCreateMenu
  1885             #enabled: #hasAnySingleSelection
  1877                 #activeHelpKey: #addSubMenu
  1886             #labelImage: #(#ResourceRetriever nil #submenuImage)
  1878                 #enabled: #hasAnySingleSelection
  1887           )
  1879                 #labelImage: #(#ResourceRetriever nil #submenuImage)
  1888          #(#MenuItem
  1880             )
  1889             #label: 'Add Linked Submenu'
  1881              #(#MenuItem
  1890             #isButton: true
  1882                 #label: 'Add Linked Submenu'
  1891             #value: #doCreateLink
  1883                 #isButton: true
  1892             #activeHelpKey: #addSubMenuLink
  1884                 #value: #doCreateLink
  1893             #enabled: #hasAnySingleSelection
  1885                 #activeHelpKey: #addSubMenuLink
  1894             #labelImage: #(#ResourceRetriever nil #linkSubmenuImage)
  1886                 #enabled: #hasAnySingleSelection
  1895           )
  1887                 #labelImage: #(#ResourceRetriever nil #linkSubmenuImage)
  1896          #(#MenuItem
  1888             )
  1897             #label: ''
  1889              #(#MenuItem
  1898           )
  1890                 #label: ''
  1899          #(#MenuItem
  1891             )
  1900             #label: 'Move Up'
  1892              #(#MenuItem
  1901             #isButton: true
  1893                 #label: 'Move Up'
  1902             #value: #doStepUp
  1894                 #isButton: true
  1903             #activeHelpKey: #editMoveUp
  1895                 #value: #doStepUp
  1904             #enabled: #valueOfEnableMovingUpOrDown
  1896                 #activeHelpKey: #editMoveUp
  1905             #labelImage: #(#ResourceRetriever #Icon #upIcon)
  1897                 #enabled: #valueOfEnableMovingUpOrDown
  1906           )
  1898                 #labelImage: #(#ResourceRetriever #Icon #upIcon)
  1907          #(#MenuItem
  1899             )
  1908             #label: 'Move Down'
  1900              #(#MenuItem
  1909             #isButton: true
  1901                 #label: 'Move Down'
  1910             #value: #doStepDown
  1902                 #isButton: true
  1911             #activeHelpKey: #editMoveDown
  1903                 #value: #doStepDown
  1912             #enabled: #valueOfEnableMovingUpOrDown
  1904                 #activeHelpKey: #editMoveDown
  1913             #labelImage: #(#ResourceRetriever #Icon #downIcon)
  1905                 #enabled: #valueOfEnableMovingUpOrDown
  1914           )
  1906                 #labelImage: #(#ResourceRetriever #Icon #downIcon)
  1915          #(#MenuItem
  1907             )
  1916             #label: 'Move In'
  1908              #(#MenuItem
  1917             #isButton: true
  1909                 #label: 'Move In'
  1918             #value: #doStepIn
  1910                 #isButton: true
  1919             #activeHelpKey: #editMoveIn
  1911                 #value: #doStepIn
  1920             #enabled: #valueOfEnableMovingIn
  1912                 #activeHelpKey: #editMoveIn
  1921             #labelImage: #(#ResourceRetriever #Icon #downRightIcon)
  1913                 #enabled: #valueOfEnableMovingIn
  1922           )
  1914                 #labelImage: #(#ResourceRetriever #Icon #downRightIcon)
  1923          #(#MenuItem
  1915             )
  1924             #label: 'Move Out'
  1916              #(#MenuItem
  1925             #isButton: true
  1917                 #label: 'Move Out'
  1926             #value: #doStepOut
  1918                 #isButton: true
  1927             #activeHelpKey: #editMoveOut
  1919                 #value: #doStepOut
  1928             #enabled: #valueOfEnableMovingOut
  1920                 #activeHelpKey: #editMoveOut
  1929             #labelImage: #(#ResourceRetriever #Icon #leftDownIcon)
  1921                 #enabled: #valueOfEnableMovingOut
  1930           )
  1922                 #labelImage: #(#ResourceRetriever #Icon #leftDownIcon)
  1931          )
  1923             )
  1932         nil
  1924           ) nil
  1933         nil
  1925           nil
       
  1926       )
  1934       )
  1927 ! !
  1935 ! !
  1928 
  1936 
  1929 !MenuEditor class methodsFor:'queries'!
  1937 !MenuEditor class methodsFor:'queries'!
  1930 
  1938 
  2305 
  2313 
  2306 
  2314 
  2307 ! !
  2315 ! !
  2308 
  2316 
  2309 !MenuEditor methodsFor:'selection'!
  2317 !MenuEditor methodsFor:'selection'!
  2310 
       
  2311 clearSelection
       
  2312 
       
  2313     tabSelection ~~ 0 ifTrue:[
       
  2314         tabSelection := 0.
       
  2315         self tabCanvasHolder value:nil
       
  2316     ].
       
  2317     typeOfCanvas := nil.
       
  2318 !
       
  2319 
  2318 
  2320 imageSelected
  2319 imageSelected
  2321     |imgSel|
  2320     |imgSel|
  2322 
  2321 
  2323     imgSel := self selectionOfImage value.
  2322     imgSel := self selectionOfImage value.
  2356             ].
  2355             ].
  2357         ] ifTrue:[
  2356         ] ifTrue:[
  2358             slices := myClass perform:#slicesSeparatorMenu.
  2357             slices := myClass perform:#slicesSeparatorMenu.
  2359         ].
  2358         ].
  2360         index := tabSelection ? 0.
  2359         index := tabSelection ? 0.
  2361         self clearSelection.
       
  2362 
  2360 
  2363         slices ~~ oldSlices ifTrue:[
  2361         slices ~~ oldSlices ifTrue:[
       
  2362             tabSelection := 0.
       
  2363             typeOfCanvas := 0.
       
  2364 
       
  2365             self tabCanvasHolder value:nil.
       
  2366 
  2364             newList := slices collect:[:el| el first].
  2367             newList := slices collect:[:el| el first].
  2365 
  2368 
  2366             index ~~ 0 ifTrue:[
  2369             index ~~ 0 ifTrue:[
  2367                 oldLabel := self tabList value at:index ifAbsent:nil.
  2370                 oldLabel := self tabList value at:index ifAbsent:nil.
  2368 
  2371 
  2385 tabSelection:aSelection
  2388 tabSelection:aSelection
  2386     "put the section aSelection into the note book
  2389     "put the section aSelection into the note book
  2387     "
  2390     "
  2388     |view spec|
  2391     |view spec|
  2389 
  2392 
  2390     aSelection == tabSelection ifTrue:[^self].
  2393     aSelection = tabSelection ifTrue:[^self].
  2391 
  2394 
  2392     (tabSelection := aSelection) isNil ifTrue:[
  2395     (tabSelection := aSelection) isNil ifTrue:[
  2393         tabSelection == 0 ifTrue:[^ self].
  2396         tabSelection == 0 ifTrue:[^ self].
  2394         tabSelection := 0.
  2397         tabSelection := 0.
  2395     ].
  2398     ].
  3050 "
  3053 "
  3051 ! !
  3054 ! !
  3052 
  3055 
  3053 !MenuEditor::TreeView methodsFor:'accessing'!
  3056 !MenuEditor::TreeView methodsFor:'accessing'!
  3054 
  3057 
       
  3058 canTab
       
  3059     ^ true
       
  3060 !
       
  3061 
  3055 selectorName
  3062 selectorName
  3056     "get the selector of the menu spec"
  3063     "get the selector of the menu spec"
  3057 
  3064 
  3058     ^(listOfNodes first contents label) asSymbol
  3065     ^(listOfNodes first contents label) asSymbol
  3059 !
  3066 !