UIPainter.st
changeset 272 99de6af43afa
parent 271 ca85216907a4
child 274 2db2e583b3b4
equal deleted inserted replaced
271:ca85216907a4 272:99de6af43afa
  1220 !
  1220 !
  1221 
  1221 
  1222 cancel
  1222 cancel
  1223     "cancel all changes and read back attributes from current view
  1223     "cancel all changes and read back attributes from current view
  1224     "
  1224     "
  1225     self modifiedChannel value ifTrue:[
  1225     self isModified ifTrue:[
  1226         specTool specification:(self painter specForSelection).
  1226         specTool specification:(self painter specForSelection).
  1227         layoutTool layoutView:(layoutTool layoutView).
  1227         layoutTool layoutView:(layoutTool layoutView).
  1228         self modifiedChannel value:false.
  1228         self modifiedChannel value:false.
  1229     ]
  1229     ]
  1230 !
  1230 !
  1461 ! !
  1461 ! !
  1462 
  1462 
  1463 !UIPainter methodsFor:'change & update'!
  1463 !UIPainter methodsFor:'change & update'!
  1464 
  1464 
  1465 layoutChanged
  1465 layoutChanged
  1466     self modifiedChannel value ifFalse:[
  1466     self isModified ifFalse:[
  1467         layoutTool update.
  1467         layoutTool update.
  1468         self modifiedChannel value:false
  1468         self modifiedChannel value:false
  1469     ]
  1469     ]
  1470 !
  1470 !
  1471 
  1471 
  1472 treeViewChanged
  1472 propertyChanged
  1473     "property or selection in the treeView changed
  1473     "property changed
       
  1474     "
       
  1475     |p|
       
  1476 
       
  1477     (p := treeView propertySelected) notNil ifTrue:[
       
  1478         specTool specification:(p spec copy).
       
  1479         layoutTool  layoutView:(p view).
       
  1480         self modifiedChannel value:false
       
  1481     ] ifFalse:[
       
  1482         layoutTool layoutView notNil ifTrue:[
       
  1483             self modifiedChannel value:false.
       
  1484             self treeSelection
       
  1485         ]
       
  1486     ]
       
  1487 !
       
  1488 
       
  1489 update:something with:aParameter from:someObject
       
  1490 
       
  1491     someObject == treeView model ifTrue:[
       
  1492         something == #selection ifTrue:[self treeSelection].
       
  1493       ^ self
       
  1494     ].
       
  1495 
       
  1496     self galleryShown == someObject ifTrue:[
       
  1497         (self galleryShown value) ifTrue:[
       
  1498             self raiseUIView:(selectionPanel window)
       
  1499         ] ifFalse:[
       
  1500             self hideUIView:(selectionPanel window)
       
  1501         ].
       
  1502       ^ self
       
  1503     ].
       
  1504 
       
  1505     self painterShown == someObject ifTrue:[
       
  1506         (self painterShown value) ifTrue:[
       
  1507             self raiseUIView:(self painter topView)
       
  1508         ] ifFalse:[
       
  1509             self hideUIView:(self painter topView)
       
  1510         ].
       
  1511       ^ self
       
  1512     ].
       
  1513 
       
  1514 ! !
       
  1515 
       
  1516 !UIPainter methodsFor:'event handling'!
       
  1517 
       
  1518 doesNotUnderstand:aMessage
       
  1519    |painter|
       
  1520 
       
  1521    painter := self painter.
       
  1522 
       
  1523    (painter respondsTo:(aMessage selector)) ifTrue:[
       
  1524         ^ aMessage sendTo:painter
       
  1525    ].
       
  1526    super doesNotUnderstand:aMessage
       
  1527 
       
  1528 ! !
       
  1529 
       
  1530 !UIPainter methodsFor:'private'!
       
  1531 
       
  1532 hideUIView:aView
       
  1533     aView beIndependent.
       
  1534     aView unmap.
       
  1535 !
       
  1536 
       
  1537 painter
       
  1538     ^ treeView canvas
       
  1539 !
       
  1540 
       
  1541 raiseUIView:aView
       
  1542     aView map.
       
  1543     aView bePartner.
       
  1544 !
       
  1545 
       
  1546 setClass:cls selector:selector
       
  1547     |clsName superClassName|
       
  1548 
       
  1549     clsName := cls name.
       
  1550     superClassName := cls superclass name.
       
  1551 
       
  1552     (self aspectFor:#classNameChannel) value:clsName.
       
  1553     (self aspectFor:#methodNameChannel) value:(selector ? '').
       
  1554     (self aspectFor:#superclassNameChannel) value:superClassName.
       
  1555 
       
  1556     self painter 
       
  1557             className:clsName 
       
  1558             superclassName:superClassName
       
  1559             selector:(selector ? '').
       
  1560 
       
  1561     specClass := clsName.
       
  1562     specSelector := (selector ? '').
       
  1563     specSuperclass := superClassName.
       
  1564 
       
  1565     "Modified: 24.6.1997 / 19:07:01 / cg"
       
  1566 ! !
       
  1567 
       
  1568 !UIPainter methodsFor:'queries'!
       
  1569 
       
  1570 hasSpecClass
       
  1571 
       
  1572     specClass notNil ifTrue:[
       
  1573         ^ (specClass isBehavior or:[(Smalltalk at:specClass asSymbol) notNil])
       
  1574     ].
       
  1575   ^ false
       
  1576 !
       
  1577 
       
  1578 hasSpecClassAndSelector
       
  1579 
       
  1580     specSelector size > 1 ifTrue:[
       
  1581         ^ self hasSpecClass
       
  1582     ].
       
  1583   ^ false
       
  1584 !
       
  1585 
       
  1586 isHelpToolSelected
       
  1587     ^ tabSelection = 'Help'
       
  1588 !
       
  1589 
       
  1590 isLayoutToolSelected
       
  1591     ^ tabSelection = layoutTool class label
       
  1592 !
       
  1593 
       
  1594 isModified
       
  1595     "returns true if current spec. is modified
       
  1596     "
       
  1597     ^ self modifiedChannel value
       
  1598 !
       
  1599 
       
  1600 isPainterEnabled
       
  1601     ^ self painter enabled
       
  1602 ! !
       
  1603 
       
  1604 !UIPainter methodsFor:'selection'!
       
  1605 
       
  1606 tabSelection
       
  1607     "returns current name of section
       
  1608     "
       
  1609     ^ tabSelection
       
  1610 !
       
  1611 
       
  1612 tabSelection:something
       
  1613     "section changed
       
  1614     "
       
  1615     |raiseViewIdx|
       
  1616 
       
  1617     (something isNil or:[tabSelection = something]) ifTrue:[
       
  1618         ^ self
       
  1619     ].
       
  1620 
       
  1621     self isModified ifTrue:[
       
  1622         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifFalse:[
       
  1623             ^ self
       
  1624         ].
       
  1625         self accept
       
  1626     ].
       
  1627 
       
  1628     raiseViewIdx := 1.
       
  1629     tabSelection := something.
       
  1630 
       
  1631     self isLayoutToolSelected ifFalse:[
       
  1632         specTool selection:tabSelection.
       
  1633         raiseViewIdx := 2
       
  1634     ].
       
  1635     (self noteBookView subViews at:raiseViewIdx) raise.
       
  1636     self cancel.
       
  1637 !
       
  1638 
       
  1639 treeSelection
       
  1640     "called whenever tree-selection changed
  1474     "
  1641     "
  1475     |oldSelection view slices list spec props size nameOfSpec|
  1642     |oldSelection view slices list spec props size nameOfSpec|
       
  1643 
       
  1644     self isModified ifTrue:[
       
  1645         (self confirm:'accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
       
  1646             self accept
       
  1647         ]
       
  1648     ].
  1476 
  1649 
  1477     props := treeView propertySelected.
  1650     props := treeView propertySelected.
  1478     oldSelection := tabSelection.
  1651     oldSelection := tabSelection.
  1479     tabSelection := nil.
  1652     tabSelection := nil.
  1480 
  1653 
  1522         ]
  1695         ]
  1523     ].
  1696     ].
  1524 
  1697 
  1525     (builder componentAt:#noteBook) setSelection:tabSelection.
  1698     (builder componentAt:#noteBook) setSelection:tabSelection.
  1526     self modifiedChannel value:false.
  1699     self modifiedChannel value:false.
  1527 !
  1700 
  1528 
       
  1529 update:something with:aParameter from:someObject
       
  1530 
       
  1531     someObject == treeView model ifTrue:[
       
  1532         something == #selection ifTrue:[self treeViewChanged].
       
  1533       ^ self
       
  1534     ].
       
  1535 
       
  1536     self galleryShown == someObject ifTrue:[
       
  1537         (self galleryShown value) ifTrue:[
       
  1538             self raiseUIView:(selectionPanel window)
       
  1539         ] ifFalse:[
       
  1540             self hideUIView:(selectionPanel window)
       
  1541         ].
       
  1542       ^ self
       
  1543     ].
       
  1544 
       
  1545     self painterShown == someObject ifTrue:[
       
  1546         (self painterShown value) ifTrue:[
       
  1547             self raiseUIView:(self painter topView)
       
  1548         ] ifFalse:[
       
  1549             self hideUIView:(self painter topView)
       
  1550         ].
       
  1551       ^ self
       
  1552     ].
       
  1553 
       
  1554 ! !
       
  1555 
       
  1556 !UIPainter methodsFor:'event handling'!
       
  1557 
       
  1558 doesNotUnderstand:aMessage
       
  1559    |painter|
       
  1560 
       
  1561    painter := self painter.
       
  1562 
       
  1563    (painter respondsTo:(aMessage selector)) ifTrue:[
       
  1564         ^ aMessage sendTo:painter
       
  1565    ].
       
  1566    super doesNotUnderstand:aMessage
       
  1567 
       
  1568 ! !
       
  1569 
       
  1570 !UIPainter methodsFor:'private'!
       
  1571 
       
  1572 hideUIView:aView
       
  1573     aView beIndependent.
       
  1574     aView unmap.
       
  1575 !
       
  1576 
       
  1577 painter
       
  1578     ^ treeView canvas
       
  1579 !
       
  1580 
       
  1581 raiseUIView:aView
       
  1582     aView map.
       
  1583     aView bePartner.
       
  1584 !
       
  1585 
       
  1586 setClass:cls selector:selector
       
  1587     |clsName superClassName|
       
  1588 
       
  1589     clsName := cls name.
       
  1590     superClassName := cls superclass name.
       
  1591 
       
  1592     (self aspectFor:#classNameChannel) value:clsName.
       
  1593     (self aspectFor:#methodNameChannel) value:(selector ? '').
       
  1594     (self aspectFor:#superclassNameChannel) value:superClassName.
       
  1595 
       
  1596     self painter 
       
  1597             className:clsName 
       
  1598             superclassName:superClassName
       
  1599             selector:(selector ? '').
       
  1600 
       
  1601     specClass := clsName.
       
  1602     specSelector := (selector ? '').
       
  1603     specSuperclass := superClassName.
       
  1604 
       
  1605     "Modified: 24.6.1997 / 19:07:01 / cg"
       
  1606 ! !
       
  1607 
       
  1608 !UIPainter methodsFor:'queries'!
       
  1609 
       
  1610 hasSpecClass
       
  1611 
       
  1612     specClass notNil ifTrue:[
       
  1613         ^ (specClass isBehavior or:[(Smalltalk at:specClass asSymbol) notNil])
       
  1614     ].
       
  1615   ^ false
       
  1616 !
       
  1617 
       
  1618 hasSpecClassAndSelector
       
  1619 
       
  1620     specSelector size > 1 ifTrue:[
       
  1621         ^ self hasSpecClass
       
  1622     ].
       
  1623   ^ false
       
  1624 !
       
  1625 
       
  1626 isHelpToolSelected
       
  1627     ^ tabSelection = 'Help'
       
  1628 !
       
  1629 
       
  1630 isLayoutToolSelected
       
  1631     ^ tabSelection = layoutTool class label
       
  1632 !
       
  1633 
       
  1634 isPainterEnabled
       
  1635     ^ self painter enabled
       
  1636 ! !
       
  1637 
       
  1638 !UIPainter methodsFor:'selection'!
       
  1639 
       
  1640 tabSelection
       
  1641     ^ tabSelection
       
  1642 !
       
  1643 
       
  1644 tabSelection:something
       
  1645     |raiseViewIdx|
       
  1646 
       
  1647     something notNil ifTrue:[
       
  1648         raiseViewIdx := 1.
       
  1649         tabSelection := something.
       
  1650 
       
  1651         self isLayoutToolSelected ifFalse:[
       
  1652             specTool selection:tabSelection.
       
  1653             raiseViewIdx := 2
       
  1654         ].
       
  1655         (self noteBookView subViews at:raiseViewIdx) raise.
       
  1656         self cancel.
       
  1657     ]
       
  1658 ! !
  1701 ! !
  1659 
  1702 
  1660 !UIPainter methodsFor:'startup / release'!
  1703 !UIPainter methodsFor:'startup / release'!
  1661 
  1704 
  1662 closeRequest
  1705 closeRequest
  2471                 ]
  2514                 ]
  2472             ]
  2515             ]
  2473         ].
  2516         ].
  2474 
  2517 
  2475         self selectedNode == item ifTrue:[              "/ inform application
  2518         self selectedNode == item ifTrue:[              "/ inform application
  2476             self application treeViewChanged
  2519             self application propertyChanged
  2477         ]
  2520         ]
  2478     ].
  2521     ].
  2479 
  2522 
  2480 
  2523 
  2481 ! !
  2524 ! !