UIPainter.st
changeset 281 aabb4037f6a3
parent 280 1dd13e8107e2
child 282 bb88d92ae887
equal deleted inserted replaced
280:1dd13e8107e2 281:aabb4037f6a3
  1601     ^ self painter enabled
  1601     ^ self painter enabled
  1602 ! !
  1602 ! !
  1603 
  1603 
  1604 !UIPainter methodsFor:'selection'!
  1604 !UIPainter methodsFor:'selection'!
  1605 
  1605 
       
  1606 canvasSelected
       
  1607     |spec|
       
  1608 
       
  1609     self hasValidSelection value:false.
       
  1610     self canStepIn value:false.
       
  1611     self canStepOut value:false.
       
  1612     self hasSingleSelection value:false.
       
  1613 
       
  1614     spec := treeView canvasSpec.
       
  1615     (builder componentAt:#noteBook) setSelection:nil.
       
  1616     self setupSlicesFrom:spec hasLayout:false.
       
  1617     tabSelection := nil.
       
  1618 
       
  1619     layoutTool layoutView:nil.
       
  1620     specTool specification:spec.
       
  1621     self modifiedChannel value:false.
       
  1622     self tabSelection:(self tabList value first).
       
  1623     specTool selection:tabSelection.
       
  1624     (self noteBookView subViews at:2) raise.
       
  1625     (builder componentAt:#noteBook) setSelection:1.
       
  1626     self modifiedChannel value:false.
       
  1627 
       
  1628 !
       
  1629 
       
  1630 setupSlicesFrom:aSpec hasLayout:hasLayout
       
  1631 
       
  1632     |slices list|
       
  1633 
       
  1634     slices := aSpec class slices.
       
  1635     list   := slices collect:[:aSlice| aSlice first asString].
       
  1636 
       
  1637     hasLayout ifTrue:[
       
  1638         list add:(layoutTool class label)
       
  1639     ].
       
  1640     self tabList value:list.
       
  1641 !
       
  1642 
  1606 tabSelection
  1643 tabSelection
  1607     "returns current name of section
  1644     "returns current name of section
  1608     "
  1645     "
  1609     ^ tabSelection
  1646     ^ tabSelection
  1610 !
  1647 !
  1644     self isModified ifTrue:[
  1681     self isModified ifTrue:[
  1645         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
  1682         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
  1646             self accept
  1683             self accept
  1647         ]
  1684         ]
  1648     ].
  1685     ].
  1649 
  1686     treeView isCanvasSelected ifTrue:[
       
  1687         ^ self canvasSelected
       
  1688     ].
       
  1689         
  1650     props := treeView propertySelected.
  1690     props := treeView propertySelected.
  1651     oldSelection := tabSelection.
  1691     oldSelection := tabSelection.
  1652     tabSelection := nil.
  1692     tabSelection := nil.
  1653 
  1693 
  1654     self hasValidSelection value:(treeView hasValidSelection).
  1694     self hasValidSelection value:(treeView hasValidSelection).
  1659         self hasSingleSelection value:true.
  1699         self hasSingleSelection value:true.
  1660         view := props view.
  1700         view := props view.
  1661         spec := props spec copy.
  1701         spec := props spec copy.
  1662 
  1702 
  1663         layoutTool layoutView == view ifFalse:[
  1703         layoutTool layoutView == view ifFalse:[
  1664             slices := spec class slices.
  1704             self setupSlicesFrom:spec hasLayout:true.
  1665             size   := slices size + 1.
       
  1666             list   := Array new:size.
       
  1667             slices keysAndValuesDo:[:i :s|list at:i put:(s first asString)].
       
  1668             list at:size put:(layoutTool class label).
       
  1669             (self tabList) value:list.
       
  1670         ] ifTrue:[
       
  1671             list := self tabList value
       
  1672         ].
  1705         ].
       
  1706         list := self tabList value.
       
  1707 
  1673         (list findFirst:[:n| n = oldSelection ]) ~~ 0 ifTrue:[
  1708         (list findFirst:[:n| n = oldSelection ]) ~~ 0 ifTrue:[
  1674             tabSelection := oldSelection
  1709             tabSelection := oldSelection
  1675         ] ifFalse:[
  1710         ] ifFalse:[
  1676             tabSelection := list first
  1711             tabSelection := list first
  1677         ].
  1712         ].
  2285     props view:aCanvas.
  2320     props view:aCanvas.
  2286     model root:(TreeItem name:'Canvas' contents:props).
  2321     model root:(TreeItem name:'Canvas' contents:props).
  2287     model root expand.
  2322     model root expand.
  2288     self enableChannel:(aCanvas enableChannel).
  2323     self enableChannel:(aCanvas enableChannel).
  2289 
  2324 
       
  2325 !
       
  2326 
       
  2327 canvasName:aName
       
  2328     "change id of canvas
       
  2329     "
       
  2330     |name|
       
  2331 
       
  2332     (    aName size ~~ 0
       
  2333      and:[(name := aName string withoutSeparators) size ~~ 0
       
  2334      and:[(self propertyDetect:[:p| p name = name]) isNil
       
  2335      and:[(listOfNodes at:1) name ~= name]]]
       
  2336     ) ifTrue:[
       
  2337         (listOfNodes at:1) name:name.
       
  2338          self redrawLine:1.
       
  2339     ]
       
  2340 !
       
  2341 
       
  2342 canvasSpec
       
  2343     "returns spec assigned to canvas
       
  2344     "
       
  2345     |spec|
       
  2346 
       
  2347     spec := WindowSpec new.
       
  2348     spec fromView:(self canvas topView) callBack:nil.
       
  2349     spec name:(listOfNodes at:1) name.
       
  2350   ^ spec
  2290 ! !
  2351 ! !
  2291 
  2352 
  2292 !UIPainter::TreeView methodsFor:'accessing property'!
  2353 !UIPainter::TreeView methodsFor:'accessing property'!
  2293 
  2354 
  2294 propertiesDo:aOneArgBlock
  2355 propertiesDo:aOneArgBlock
  2475 
  2536 
  2476 
  2537 
  2477 ! !
  2538 ! !
  2478 
  2539 
  2479 !UIPainter::TreeView methodsFor:'change & update'!
  2540 !UIPainter::TreeView methodsFor:'change & update'!
       
  2541 
       
  2542 canvasNameChanged:aName
       
  2543     "called if identification name assigned to window (canvas) changed
       
  2544     "
       
  2545     |name node|
       
  2546 
       
  2547     node := listOfNodes at:1.
       
  2548 
       
  2549     (    aName size ~~ 0
       
  2550      and:[(name := aName string withoutSeparators) size ~~ 0
       
  2551      and:[(self propertyDetect:[:p| p name = name]) isNil
       
  2552      and:[node name ~= name]]]
       
  2553     ) ifTrue:[
       
  2554         node name:name.
       
  2555         self redrawLine:1.
       
  2556     ].
       
  2557 !
  2480 
  2558 
  2481 layoutChanged
  2559 layoutChanged
  2482     "layout of any component changed; in case of single selection, the
  2560     "layout of any component changed; in case of single selection, the
  2483      application will be informed to update its layout
  2561      application will be informed to update its layout
  2484     "
  2562     "
  2710         (size == 0 or:[self isInSelection:1]) ifTrue:[
  2788         (size == 0 or:[self isInSelection:1]) ifTrue:[
  2711             ^ false
  2789             ^ false
  2712         ]
  2790         ]
  2713     ].
  2791     ].
  2714   ^ true
  2792   ^ true
       
  2793 !
       
  2794 
       
  2795 isCanvasSelected
       
  2796     "returns true in case of a single selection and the
       
  2797      selection is the canvas (index 1)
       
  2798     "
       
  2799     ^ (selection size == 1 and:[self isInSelection:1])
  2715 ! !
  2800 ! !
  2716 
  2801 
  2717 !UIPainter::TreeView methodsFor:'user interactions'!
  2802 !UIPainter::TreeView methodsFor:'user interactions'!
  2718 
  2803 
  2719 doStepIn
  2804 doStepIn