VariablePanel.st
changeset 6061 b93fe69702df
parent 5997 3bfbd15008fe
child 6161 6763327fd155
equal deleted inserted replaced
6060:fcd81f4fe76c 6061:b93fe69702df
  1437         ] ifFalse:[
  1437         ] ifFalse:[
  1438             w := h := maxKnob - 4.
  1438             w := h := maxKnob - 4.
  1439         ]
  1439         ]
  1440     ].
  1440     ].
  1441 
  1441 
  1442     self paint:viewBackground.
  1442     gc paint:viewBackground.
  1443     self lineStyle:#solid.
  1443     gc lineStyle:#solid.
  1444 
  1444 
  1445     orientation == #vertical ifTrue:[
  1445     orientation == #vertical ifTrue:[
  1446         self fillRectangleX:mar y:hy 
  1446         gc fillRectangleX:mar y:hy width:(width - mar - mar) height:barHeightInt.
  1447                       width:(width - mar - mar) 
       
  1448                      height:barHeightInt.
       
  1449         (handleStyle notNil
  1447         (handleStyle notNil
  1450         and:[handleStyle ~~ #none]) ifTrue:[
  1448         and:[handleStyle ~~ #none]) ifTrue:[
  1451             (handleStyle ~~ #normal 
  1449             (handleStyle ~~ #normal 
  1452             and:[handleStyle ~~ #mswindows]) ifTrue:[
  1450             and:[handleStyle ~~ #mswindows]) ifTrue:[
  1453                 m := (maxKnob - h) // 2.
  1451                 m := (maxKnob - h) // 2.
  1455                 shadowForm isNil ifTrue:[
  1453                 shadowForm isNil ifTrue:[
  1456 
  1454 
  1457                     y := hy + (barHeightInt // 2).   "/ center of the bar
  1455                     y := hy + (barHeightInt // 2).   "/ center of the bar
  1458 
  1456 
  1459                     separatingLine ifTrue:[
  1457                     separatingLine ifTrue:[
  1460                         self paint:shadowColor.
  1458                         gc paint:shadowColor.
  1461                         self displayLineFromX:mar y:y toX:(width - mar) y:y.
  1459                         gc displayLineFromX:mar y:y toX:(width - mar) y:y.
  1462                         y := y + 1.
  1460                         y := y + 1.
  1463                         self paint:lightColor.
  1461                         gc paint:lightColor.
  1464                         self displayLineFromX:mar y:y toX:(width - mar) y:y.
  1462                         gc displayLineFromX:mar y:y toX:(width - mar) y:y.
  1465                         self paint:viewBackground.
  1463                         gc paint:viewBackground.
  1466                     ].
  1464                     ].
  1467 
  1465 
  1468                     self fillRectangleX:(hx - barWidthInt) 
  1466                     gc fillRectangleX:(hx - barWidthInt) y:hy 
  1469                                       y:hy 
  1467                        width:(barWidthInt + barWidthInt) height:h.
  1470                                   width:(barWidthInt + barWidthInt) 
       
  1471                                  height:h.
       
  1472 
  1468 
  1473                     handleStyle == #line ifTrue:[
  1469                     handleStyle == #line ifTrue:[
  1474                         self paint:handleColor.
  1470                         gc paint:handleColor.
  1475                         self displayLineFromX:hx - barWidthInt y:y toX:hx + barWidthInt y:y
  1471                         gc displayLineFromX:hx - barWidthInt y:y toX:hx + barWidthInt y:y
  1476                     ] ifFalse:[
  1472                     ] ifFalse:[
  1477                         y := hy.   
  1473                         y := hy.   
  1478                         handleStyle == #st80 ifTrue:[
  1474                         handleStyle == #st80 ifTrue:[
  1479                             y := y - 1
  1475                             y := y - 1
  1480                         ].
  1476                         ].
  1502                                             height:h 
  1498                                             height:h 
  1503                                              level:handleLevel.
  1499                                              level:handleLevel.
  1504                             ].
  1500                             ].
  1505 
  1501 
  1506                             handleStyle == #iris ifTrue:[
  1502                             handleStyle == #iris ifTrue:[
  1507                                 self paint:handleColor.
  1503                                 gc paint:handleColor.
  1508                                 self fillDeviceRectangleX:(hx - barWidthInt + 2)
  1504                                 gc fillDeviceRectangleX:(hx - barWidthInt + 2) y:(ym + 2)
  1509                                                         y:(ym + 2)
  1505                                    width:(barWidthInt + barWidthInt - 4) height:h - 4
  1510                                                     width:(barWidthInt + barWidthInt - 4)
       
  1511                                                    height:h - 4
       
  1512                             ]
  1506                             ]
  1513                         ]
  1507                         ]
  1514                     ].
  1508                     ].
  1515                 ] ifFalse:[
  1509                 ] ifFalse:[
  1516                     y := hy.
  1510                     y := hy.
  1519                     ]
  1513                     ]
  1520                 ].
  1514                 ].
  1521 
  1515 
  1522                 handleStyle == #st80 ifTrue:[
  1516                 handleStyle == #st80 ifTrue:[
  1523                     y := hy - 1.
  1517                     y := hy - 1.
  1524                     self paint:lightColor.
  1518                     gc paint:lightColor.
  1525                     self displayLineFromX:mar y:y toX:(width - mar - mar - 1) y:y.
  1519                     gc displayLineFromX:mar y:y toX:(width - mar - mar - 1) y:y.
  1526                     self displayLineFromX:0 y:hy toX:0 y:(hy + knobHeight - 1).
  1520                     gc displayLineFromX:0 y:hy toX:0 y:(hy + knobHeight - 1).
  1527                     y := hy + knobHeight - 2.
  1521                     y := hy + knobHeight - 2.
  1528                     self paint:shadowColor.
  1522                     gc paint:shadowColor.
  1529                     self displayLineFromX:mar y:y toX:(width - mar) y:y.
  1523                     gc displayLineFromX:mar y:y toX:(width - mar) y:y.
  1530                         "uncomment the -1 if you don't like the notch at the right end"
  1524                         "uncomment the -1 if you don't like the notch at the right end"
  1531                         "                            VVV"
  1525                         "                            VVV"
  1532                     self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + knobHeight - 1 - 1).
  1526                     gc displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + knobHeight - 1 - 1).
  1533                 ].
  1527                 ].
  1534             ] ifFalse:[
  1528             ] ifFalse:[
  1535                 y := hy + barHeightInt - 1.
  1529                 y := hy + barHeightInt - 1.
  1536                 self paint:handleColor.
  1530                 gc paint:handleColor.
  1537                 separatingLine ifTrue:[
  1531                 separatingLine ifTrue:[
  1538                     self displayLineFromX:0 y:hy+1 toX:width y:hy+1.
  1532                     gc displayLineFromX:0 y:hy+1 toX:width y:hy+1.
  1539                     self displayLineFromX:0 y:y toX:width y:y.
  1533                     gc displayLineFromX:0 y:y toX:width y:y.
  1540                 ].
  1534                 ].
  1541                 self fillRectangleX:hx y:hy width:barWidthInt height:barHeightInt.
  1535                 gc fillRectangleX:hx y:hy width:barWidthInt height:barHeightInt.
  1542             ].
  1536             ].
  1543         ].
  1537         ].
  1544         lbl := self handleLabelAt:hIndex.
  1538         lbl := self handleLabelAt:hIndex.
  1545         lbl notNil ifTrue:[
  1539         lbl notNil ifTrue:[
  1546             hIndex ~~ 1 ifTrue:[
  1540             hIndex ~~ 1 ifTrue:[
  1547                 self paint:self blackColor.
  1541                 gc paint:self blackColor.
  1548                 lbl displayOn:self x:mar y:hy + (lbl ascentOn:self)
  1542                 lbl displayOn:self x:mar y:hy + (lbl ascentOn:self)
  1549 "/                lbl isImageOrForm ifTrue:[
  1543 "/                lbl isImageOrForm ifTrue:[
  1550 "/                    lbl displayOn:self x:mar y:hy
  1544 "/                    lbl displayOn:self x:mar y:hy
  1551 "/                ] ifFalse:[
  1545 "/                ] ifFalse:[
  1552 "/                    lbl displayOn:self x:mar y:hy + font ascent + 1
  1546 "/                    lbl displayOn:self x:mar y:hy + font ascent + 1
  1553 "/                ]
  1547 "/                ]
  1554             ]
  1548             ]
  1555         ].
  1549         ].
  1556 
  1550 
  1557     ] ifFalse:[
  1551     ] ifFalse:[
  1558         self fillRectangleX:hx y:mar 
  1552         gc fillRectangleX:hx y:mar width:barHeightInt height:(height - mar - mar).
  1559                       width:barHeightInt
       
  1560                      height:(height - mar - mar).
       
  1561 
  1553 
  1562         (handleStyle notNil
  1554         (handleStyle notNil
  1563         and:[handleStyle ~~ #none]) ifTrue:[
  1555         and:[handleStyle ~~ #none]) ifTrue:[
  1564             (handleStyle ~~ #normal
  1556             (handleStyle ~~ #normal
  1565             and:[handleStyle ~~ #mswindows]) ifTrue:[
  1557             and:[handleStyle ~~ #mswindows]) ifTrue:[
  1566                  m := (barHeightInt - w) // 2.
  1558                 "/ m := (barHeightInt - w) // 2.
  1567                 m := (maxKnob - w) // 2.
  1559                 m := (maxKnob - w) // 2.
  1568                  shadowForm isNil ifTrue:[
  1560                 shadowForm isNil ifTrue:[
  1569                     x := hx + (barHeightInt // 2).
  1561                     x := hx + (barHeightInt // 2).
  1570                     separatingLine ifTrue:[
  1562                     separatingLine ifTrue:[
  1571                         self paint:shadowColor.
  1563                         gc paint:shadowColor.
  1572                         self displayLineFromX:x y:mar toX:x y:(height - mar).
  1564                         gc displayLineFromX:x y:mar toX:x y:(height - mar).
  1573                         x := x + 1.
  1565                         x := x + 1.
  1574                         self paint:lightColor.
  1566                         gc paint:lightColor.
  1575                         self displayLineFromX:x y:mar toX:x y:(height - mar).
  1567                         gc displayLineFromX:x y:mar toX:x y:(height - mar).
  1576                         self paint:viewBackground.
  1568                         gc paint:viewBackground.
  1577                     ].
  1569                     ].
  1578                     self fillRectangleX:hx y:(hy - barWidthInt) 
  1570                     gc fillRectangleX:hx y:(hy - barWidthInt) 
  1579                                   width:w 
  1571                        width:w height:(barWidthInt + barWidthInt).
  1580                                  height:(barWidthInt + barWidthInt).
       
  1581 
  1572 
  1582                     handleStyle == #line ifTrue:[
  1573                     handleStyle == #line ifTrue:[
  1583                         self paint:handleColor.
  1574                         gc paint:handleColor.
  1584                         self displayLineFromX:x y:hy - barWidthInt toX:x y:hy + barWidthInt.
  1575                         gc displayLineFromX:x y:hy - barWidthInt toX:x y:hy + barWidthInt.
  1585                     ] ifFalse:[
  1576                     ] ifFalse:[
  1586                         x := hx.
  1577                         x := hx.
  1587                         handleStyle == #st80 ifTrue:[
  1578                         handleStyle == #st80 ifTrue:[
  1588                             x := x - 1.
  1579                             x := x - 1.
  1589                         ].
  1580                         ].
  1602                                     halfLight:nil 
  1593                                     halfLight:nil 
  1603                                     style:nil
  1594                                     style:nil
  1604                             ]
  1595                             ]
  1605                         ] ifFalse:[
  1596                         ] ifFalse:[
  1606                             handleLevel ~~ 0 ifTrue:[
  1597                             handleLevel ~~ 0 ifTrue:[
  1607                                 self drawEdgesForX:xm
  1598                                 self drawEdgesForX:xm y:(hy - barWidthInt)
  1608                                                  y:(hy - barWidthInt)
  1599                                      width:w height:(barWidthInt + barWidthInt)
  1609                                              width:w 
  1600                                      level:handleLevel.
  1610                                             height:(barWidthInt + barWidthInt)
       
  1611                                              level:handleLevel.
       
  1612                             ].
  1601                             ].
  1613                             handleStyle == #iris ifTrue:[
  1602                             handleStyle == #iris ifTrue:[
  1614                                 self paint:handleColor.
  1603                                 gc paint:handleColor.
  1615                                 self fillDeviceRectangleX:(xm + 2)
  1604                                 gc fillDeviceRectangleX:(xm + 2) y:(hy - barWidthInt + 2)
  1616                                                         y:(hy - barWidthInt + 2)
  1605                                    width:w - 4 height:(barWidthInt + barWidthInt - 4)
  1617                                                     width:w - 4
       
  1618                                                    height:(barWidthInt + barWidthInt - 4)
       
  1619                             ].
  1606                             ].
  1620                         ].
  1607                         ].
  1621                     ]
  1608                     ]
  1622                 ] ifFalse:[
  1609                 ] ifFalse:[
  1623                     x := hx.
  1610                     x := hx.
  1625                         self drawHandleFormAtX:(x + m) y:hy
  1612                         self drawHandleFormAtX:(x + m) y:hy
  1626                     ]
  1613                     ]
  1627                 ].
  1614                 ].
  1628                 handleStyle == #st80 ifTrue:[
  1615                 handleStyle == #st80 ifTrue:[
  1629                     x := hx - 1.
  1616                     x := hx - 1.
  1630                     self paint:lightColor.
  1617                     gc paint:lightColor.
  1631                     self displayLineFromX:x y:mar toX:x y:(height - mar).
  1618                     gc displayLineFromX:x y:mar toX:x y:(height - mar).
  1632                     self displayLineFromX:hx y:0 toX:(hx + barHeightInt - 1) y:0.
  1619                     gc displayLineFromX:hx y:0 toX:(hx + barHeightInt - 1) y:0.
  1633                     x := hx + barHeightInt - 2.
  1620                     x := hx + barHeightInt - 2.
  1634                     self paint:shadowColor.
  1621                     gc paint:shadowColor.
  1635                     self displayLineFromX:x y:mar toX:x y:(height - mar).
  1622                     gc displayLineFromX:x y:mar toX:x y:(height - mar).
  1636                         "uncomment the -1 if you dont like the notch at the bottom end"
  1623                         "uncomment the -1 if you dont like the notch at the bottom end"
  1637                         "                   VVV"
  1624                         "                   VVV"
  1638                     self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeightInt - 1) y:height-1.
  1625                     gc displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeightInt - 1) y:height-1.
  1639                 ].
  1626                 ].
  1640             ] ifFalse:[
  1627             ] ifFalse:[
  1641                 x := hx + barHeightInt - 1.
  1628                 x := hx + barHeightInt - 1.
  1642                 self paint:handleColor.
  1629                 gc paint:handleColor.
  1643                 separatingLine ifTrue:[
  1630                 separatingLine ifTrue:[
  1644                     self displayLineFromX:hx+1 y:0 toX:hx+1 y:height.
  1631                     gc displayLineFromX:hx+1 y:0 toX:hx+1 y:height.
  1645                     self displayLineFromX:x y:0 toX:x y:height.
  1632                     gc displayLineFromX:x y:0 toX:x y:height.
  1646                 ].
  1633                 ].
  1647                 self fillRectangleX:hx y:hy width:barHeightInt height:barWidthInt
  1634                 gc fillRectangleX:hx y:hy width:barHeightInt height:barWidthInt
  1648             ]
  1635             ]
  1649         ]
  1636         ]
  1650     ].
  1637     ].
  1651 
  1638 
  1652     "Modified: / 29.7.1998 / 22:48:33 / cg"
  1639     "Modified: / 29.7.1998 / 22:48:33 / cg"
  1653 !
  1640 !
  1654 
  1641 
  1655 drawHandleFormAtX:hx y:hy
  1642 drawHandleFormAtX:hx y:hy
  1656     "draw a handles bitmap at hx/hy"
  1643     "draw a handle's bitmap at hx/hy"
  1657 
  1644 
  1658     shadowForm notNil ifTrue:[
  1645     shadowForm notNil ifTrue:[
  1659         self paint:shadowColor.
  1646         gc paint:shadowColor.
  1660         self displayForm:shadowForm x:hx y:hy.
  1647         gc displayForm:shadowForm x:hx y:hy.
  1661     ].
  1648     ].
  1662     lightForm notNil ifTrue:[
  1649     lightForm notNil ifTrue:[
  1663         self paint:lightColor.
  1650         gc paint:lightColor.
  1664         self displayForm:lightForm x:hx y:hy.
  1651         gc displayForm:lightForm x:hx y:hy.
  1665     ].
  1652     ].
  1666     self paint:viewBackground
  1653     gc paint:viewBackground
  1667 
  1654 
  1668     "Modified: 7.11.1996 / 20:25:33 / cg"
  1655     "Modified: 7.11.1996 / 20:25:33 / cg"
  1669 !
  1656 !
  1670 
  1657 
  1671 drawSnapAt:anIndex
  1658 drawSnapAt:anIndex
  1705     ].
  1692     ].
  1706     paint isNil ifTrue:[
  1693     paint isNil ifTrue:[
  1707         paint := viewBackground.
  1694         paint := viewBackground.
  1708     ].
  1695     ].
  1709 
  1696 
  1710     self paint:paint.
  1697     gc paint:paint.
  1711 
  1698 
  1712 "/    level == 0 ifTrue:[
  1699 "/    level == 0 ifTrue:[
  1713 "/    ].
  1700 "/    ].
  1714 
  1701 
  1715     self fillRectangleX:left+1 y:top+1 width:width-2 height:height-2.
  1702     gc fillRectangleX:left+1 y:top+1 width:width-2 height:height-2.
  1716 
  1703 
  1717     level ~~ 0 ifTrue:[
  1704     level ~~ 0 ifTrue:[
  1718         leftEdge := left + 1.
  1705         leftEdge := left + 1.
  1719         wEdge := wPart := width - 2.
  1706         wEdge := wPart := width - 2.
  1720         topEdge := top + 1.
  1707         topEdge := top + 1.
  1788                or:[trackLine == #dashedLine
  1775                or:[trackLine == #dashedLine
  1789                or:[trackLine == #dottedLine]]).
  1776                or:[trackLine == #dottedLine]]).
  1790 
  1777 
  1791     trackLine == #dashedLine ifTrue:[
  1778     trackLine == #dashedLine ifTrue:[
  1792         oldStyle := gc lineStyle.
  1779         oldStyle := gc lineStyle.
  1793         self lineStyle:#dashed.
  1780         gc lineStyle:#dashed.
  1794     ] ifFalse:[
  1781     ] ifFalse:[
  1795         trackLine == #dottedLine ifTrue:[
  1782         trackLine == #dottedLine ifTrue:[
  1796             oldStyle := gc lineStyle.
  1783             oldStyle := gc lineStyle.
  1797             self lineStyle:#dotted.
  1784             gc lineStyle:#dotted.
  1798         ]
  1785         ]
  1799     ].
  1786     ].
  1800 
  1787 
  1801     self clippedByChildren:false.
  1788     gc clippedByChildren:false.
  1802 
  1789 
  1803     self xoring:[
  1790     self xoring:[
  1804         |yL xL halfHeight|
  1791         |yL xL halfHeight|
  1805 
  1792 
  1806         halfHeight := (barHeight // 2) - 1.
  1793         halfHeight := (barHeight // 2) - 1.
  1807 
  1794 
  1808         orientation == #vertical ifTrue:[
  1795         orientation == #vertical ifTrue:[
  1809             yL := hy + halfHeight.
  1796             yL := hy + halfHeight.
  1810             doLine ifTrue:[
  1797             doLine ifTrue:[
  1811                 self displayLineFromX:0 y:yL toX:width y:yL.
  1798                 gc displayLineFromX:0 y:yL toX:width y:yL.
  1812             ] ifFalse:[
  1799             ] ifFalse:[
  1813                 self fillRectangleX:0 y:hy width:width height:barHeight
  1800                 gc fillRectangleX:0 y:hy width:width height:barHeight
  1814             ]
  1801             ]
  1815         ] ifFalse:[
  1802         ] ifFalse:[
  1816             xL := hx + halfHeight.
  1803             xL := hx + halfHeight.
  1817             doLine ifTrue:[
  1804             doLine ifTrue:[
  1818                 self displayLineFromX:xL y:0 toX:xL y:height.
  1805                 gc displayLineFromX:xL y:0 toX:xL y:height.
  1819             ] ifFalse:[
  1806             ] ifFalse:[
  1820                 self fillRectangleX:hx y:0 width:barHeight height:height
  1807                 gc fillRectangleX:hx y:0 width:barHeight height:height
  1821             ]
  1808             ]
  1822         ].
  1809         ].
  1823     ].
  1810     ].
  1824     self clippedByChildren:true.
  1811     gc clippedByChildren:true.
  1825 
  1812 
  1826     oldStyle notNil ifTrue:[
  1813     oldStyle notNil ifTrue:[
  1827         self lineStyle:oldStyle.
  1814         gc lineStyle:oldStyle.
  1828     ].
  1815     ].
  1829 
  1816 
  1830     "Modified: / 28.4.1997 / 14:56:26 / dq"
  1817     "Modified: / 28.4.1997 / 14:56:26 / dq"
  1831     "Modified: / 3.5.1999 / 18:49:04 / cg"
  1818     "Modified: / 3.5.1999 / 18:49:04 / cg"
  1832 !
  1819 !