UIPainter.st
changeset 2310 ac9be9035f2c
parent 2296 365b3a73cd28
child 2313 c60fe56ab5bf
equal deleted inserted replaced
2309:777065a9ff59 2310:ac9be9035f2c
   267 'Generates aspect methods for defined aspect selectors of the widgets.'
   267 'Generates aspect methods for defined aspect selectors of the widgets.'
   268 
   268 
   269 #generateHookMethods
   269 #generateHookMethods
   270 'Generates startup/release methods. (#closeRequest, #postBuildWith:, #postOpenWith:)'
   270 'Generates startup/release methods. (#closeRequest, #postBuildWith:, #postOpenWith:)'
   271 
   271 
       
   272 #group
       
   273 ''
       
   274 
   272 #helpExamples
   275 #helpExamples
   273 'Show some examples uses of the GUI Painter.'
   276 'Show some examples uses of the GUI Painter.'
   274 
   277 
   275 #helpFunctions
   278 #helpFunctions
   276 'Show the documentation on the GUI Painters menu and button functions.'
   279 'Show the documentation on the GUI Painters menu and button functions.'
   329 #settingsTranscriptHelp
   332 #settingsTranscriptHelp
   330 'Toggles display of help texts (after opening a new GUI Painter).'
   333 'Toggles display of help texts (after opening a new GUI Painter).'
   331 
   334 
   332 #settingsUndoManager
   335 #settingsUndoManager
   333 'Opens a dialog to undo modifications.'
   336 'Opens a dialog to undo modifications.'
       
   337 
       
   338 #sortItems
       
   339 'Sort the selected items by position (left to right, top to bottom)'
   334 
   340 
   335 #spreadSelectionHor
   341 #spreadSelectionHor
   336 'Sets the horizontal spaces between the selected widgets to the same value.'
   342 'Sets the horizontal spaces between the selected widgets to the same value.'
   337 
   343 
   338 #spreadSelectionVer
   344 #spreadSelectionVer
  1679             translateLabel: true
  1685             translateLabel: true
  1680           )
  1686           )
  1681          (MenuItem
  1687          (MenuItem
  1682             activeHelpKey: pasteWithLayout
  1688             activeHelpKey: pasteWithLayout
  1683             enabled: canPasteKeepingLayoutHolder
  1689             enabled: canPasteKeepingLayoutHolder
  1684             label: 'Paste with Layout'
  1690             label: 'Paste without Layout'
  1685             itemValue: pasteWithLayout
  1691             itemValue: pasteWithoutLayout
  1686             translateLabel: true
  1692             translateLabel: true
  1687           )
  1693           )
  1688          (MenuItem
  1694          (MenuItem
  1689             activeHelpKey: editPaste
  1695             activeHelpKey: editPaste
  1690             enabled: canPasteKeepingLayoutHolder
  1696             enabled: canPasteKeepingLayoutHolder
  1832           )
  1838           )
  1833          (MenuItem
  1839          (MenuItem
  1834             label: '-'
  1840             label: '-'
  1835           )
  1841           )
  1836          (MenuItem
  1842          (MenuItem
  1837             activeHelpKey: group
  1843             activeHelpKey: sortItems
  1838             enabled: enGroup
  1844             label: 'Sort Selected Items'
  1839             label: 'Group'
  1845             itemValue: doSortItems
  1840             itemValue: group
  1846             translateLabel: true
       
  1847           )
       
  1848          (MenuItem
       
  1849             label: 'Action'
  1841             translateLabel: true
  1850             translateLabel: true
  1842           )
  1851           )
  1843          (MenuItem
  1852          (MenuItem
  1844             activeHelpKey: groupWithLayout
  1853             activeHelpKey: groupWithLayout
  1845             enabled: enGroup
  1854             enabled: enGroup
  1874          (MenuItem
  1883          (MenuItem
  1875             activeHelpKey: editInspectView
  1884             activeHelpKey: editInspectView
  1876             enabled: hasOneSelectionOtherThanCanvas
  1885             enabled: hasOneSelectionOtherThanCanvas
  1877             label: 'Inspect Widget'
  1886             label: 'Inspect Widget'
  1878             itemValue: doInspectView
  1887             itemValue: doInspectView
       
  1888             translateLabel: true
       
  1889           )
       
  1890          (MenuItem
       
  1891             activeHelpKey: editBrowseViewClass
       
  1892             label: 'Browse Specification Class'
       
  1893             itemValue: doBrowseSpecificationClass
  1879             translateLabel: true
  1894             translateLabel: true
  1880           )
  1895           )
  1881          (MenuItem
  1896          (MenuItem
  1882             activeHelpKey: editInspectSpec
  1897             activeHelpKey: editInspectSpec
  1883             label: 'Inspect Spec'
  1898             label: 'Inspect Spec'
  2602 
  2617 
  2603     ^ treeView
  2618     ^ treeView
  2604 !
  2619 !
  2605 
  2620 
  2606 valueOfCanPasteWithKeepingLayout
  2621 valueOfCanPasteWithKeepingLayout
       
  2622     <resource: #obsolete>
  2607     self obsoleteMethodWarning:'stupid name - use #canPasteKeepingLayoutHolder'.
  2623     self obsoleteMethodWarning:'stupid name - use #canPasteKeepingLayoutHolder'.
  2608     ^ self canPasteKeepingLayoutHolder
  2624     ^ self canPasteKeepingLayoutHolder
  2609 ! !
  2625 ! !
  2610 
  2626 
  2611 !UIPainter methodsFor:'building editors'!
  2627 !UIPainter methodsFor:'building editors'!
  2898     self canChangeOrderInContainer      value:(treeView canChangeOrderInContainer).
  2914     self canChangeOrderInContainer      value:(treeView canChangeOrderInContainer).
  2899     self canMoveSelectionIntoContainer  value:(treeView canMoveSelectionIntoContainer).
  2915     self canMoveSelectionIntoContainer  value:(treeView canMoveSelectionIntoContainer).
  2900     self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
  2916     self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
  2901     self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
  2917     self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).
  2902 
  2918 
  2903     treeView notNil
  2919     painterView notNil ifTrue:[
  2904     ifTrue:
       
  2905     [
       
  2906         treeSelection := treeView selection.
  2920         treeSelection := treeView selection.
  2907         "/ the top-node cannot be cut, copied or pasted.
  2921         "/ the top-node cannot be cut, copied or pasted.
  2908         canCutOrCopy := treeSelection size >= 1 and:[treeSelection first ~~ 1].
  2922         canCutOrCopy := treeSelection size >= 1 and:[treeSelection first ~~ 1].
  2909         clipboard := self getClipboardObject.
  2923         clipboard := painterView getClipboardObject.
  2910 
  2924 
  2911         clipboard isCollection 
  2925         clipboard notEmptyOrNil 
  2912                 ifTrue:[clipboard notEmpty ifTrue:[sel := clipboard first]]
  2926                 ifTrue:[sel := clipboard first]
  2913                 ifFalse:[sel := clipboard].
  2927                 ifFalse:[sel := clipboard].
  2914 
  2928 
  2915         canPaste := (sel isKindOf:UISpecification) 
  2929         canPaste := (sel isKindOf:UISpecification) 
  2916 "/                    and:[treeSelection size  = 1 
  2930 "/                    and:[treeSelection size  = 1 
  2917 "/                    and:[treeSelection first == 1 
  2931 "/                    and:[treeSelection first == 1 
  4306     self painter isModified ifTrue:[
  4320     self painter isModified ifTrue:[
  4307         self warn:'The current window spec has not yet been saved!!\\The System Browser will show the code of the old window spec.' withCRs.
  4321         self warn:'The current window spec has not yet been saved!!\\The System Browser will show the code of the old window spec.' withCRs.
  4308     ].
  4322     ].
  4309 
  4323 
  4310     UserPreferences systemBrowserClass openInClass:(self resolveName:specClassName)
  4324     UserPreferences systemBrowserClass openInClass:(self resolveName:specClassName)
       
  4325 !
       
  4326 
       
  4327 doBrowseSpecificationClass
       
  4328     "opens an browser on the spec class of the selected widget"
       
  4329 
       
  4330     |spec|
       
  4331 
       
  4332     (spec := self painter specForSelection) isNil ifTrue:[
       
  4333         treeView isCanvasSelected ifTrue:[
       
  4334             spec := treeView canvasSpec.
       
  4335         ]
       
  4336     ].
       
  4337     spec notNil ifTrue:[
       
  4338         spec class browse
       
  4339     ]
  4311 !
  4340 !
  4312 
  4341 
  4313 doBrowseViewClass
  4342 doBrowseViewClass
  4314     "opens a browser on the selected widgets class"
  4343     "opens a browser on the selected widgets class"
  4315 
  4344 
  4882 "/        code readStream fileIn.
  4911 "/        code readStream fileIn.
  4883 "/    ].
  4912 "/    ].
  4884 "/    UserPreferences current systemBrowserClass openInClass:cls selector:aspect
  4913 "/    UserPreferences current systemBrowserClass openInClass:cls selector:aspect
  4885 !
  4914 !
  4886 
  4915 
       
  4916 doSortItems
       
  4917     "sort the selected items by position"
       
  4918 
       
  4919     treeView doSortItems
       
  4920 !
       
  4921 
  4887 doStartApplication
  4922 doStartApplication
  4888     "starts the application on the editing window spec"
  4923     "starts the application on the editing window spec"
  4889 
  4924 
  4890     |cls application|
  4925     |cls application|
  4891 
  4926 
  5728     canvas deleteSelection.
  5763     canvas deleteSelection.
  5729     canvas setSelection:(anItem contents view) withRedraw:false.
  5764     canvas setSelection:(anItem contents view) withRedraw:false.
  5730     canvas pasteWithLayout.
  5765     canvas pasteWithLayout.
  5731 !
  5766 !
  5732 
  5767 
       
  5768 doSortItems
       
  5769     "moves child 'anOffset' forward or backward in list of children"
       
  5770 
       
  5771     |selectedItems parent sortedItems newChildren itemList parentView|
       
  5772 
       
  5773     self askForSelectionChangeAllowed ifFalse:[^ self].
       
  5774 
       
  5775     selectedItems := self selectedNodes.
       
  5776     selectedItems size <= 1 ifTrue:[^ self].
       
  5777     parent := selectedItems first parent.
       
  5778     (parent isNil or:[(selectedItems conform:[:e| e parent == parent]) not]) ifTrue:[^ self].
       
  5779 
       
  5780     sortedItems := selectedItems sort:[:a :b| a contents view origin isLeftOrAbove:(b contents view origin)].
       
  5781     itemList := selectedItems asIdentitySet.
       
  5782 
       
  5783     newChildren := parent children collect:[:eachChild|
       
  5784         (itemList includes:eachChild) ifTrue:[
       
  5785             sortedItems removeFirst.
       
  5786         ] ifFalse:[
       
  5787             eachChild.
       
  5788         ].
       
  5789     ].
       
  5790 
       
  5791     self setSelection:nil.
       
  5792     model remove:parent children.
       
  5793     model add:newChildren beforeIndex:1 below:parent.
       
  5794 
       
  5795     parentView := parent contents view.
       
  5796 
       
  5797     self canvas hideSelection.
       
  5798     newChildren keysAndValuesDo:[:idx :eachItem|
       
  5799         parentView changeSequenceOrderFor:eachItem contents view to:idx.
       
  5800     ].
       
  5801     parentView specClass isLayoutContainer ifFalse:[
       
  5802         parentView subViews do:[:v| v raise ].
       
  5803     ].
       
  5804     self canvas showSelection.
       
  5805 
       
  5806     self selectNodes:itemList.
       
  5807 !
       
  5808 
  5733 doStepIn
  5809 doStepIn
  5734     "move the currently selected widget into the next available container below"
  5810     "move the currently selected widget into the next available container below"
  5735 
  5811 
  5736     |item oldParentItem newParentItem idx|
  5812     |item oldParentItem newParentItem idx|
  5737 
  5813