Scroller.st
changeset 1794 f3dd5bcc9876
parent 1768 32eb81e67be1
child 1799 7d3daeab6afe
equal deleted inserted replaced
1793:769bcc27886b 1794:f3dd5bcc9876
    17 		thumbLightColor thumbEdgeStyle thumbHalfShadowColor
    17 		thumbLightColor thumbEdgeStyle thumbHalfShadowColor
    18 		thumbHalfLightColor thumbEnteredColor thumbFrameSizeDifference
    18 		thumbHalfLightColor thumbEnteredColor thumbFrameSizeDifference
    19 		tallyLevel tallyMarks fixThumbHeight frameBeforeMove ghostColor
    19 		tallyLevel tallyMarks fixThumbHeight frameBeforeMove ghostColor
    20 		ghostFrameColor ghostLevel rangeStart rangeEnd rangeStep entered
    20 		ghostFrameColor ghostLevel rangeStart rangeEnd rangeStep entered
    21 		thumbActiveLevel originBeforeMove thumbImage enabled
    21 		thumbActiveLevel originBeforeMove thumbImage enabled
    22 		enableChannel keyboardStep'
    22 		enableChannel keyboardStep autoRepeat repeatBlock
       
    23 		initialRepeatDelay repeatDelay'
    23 	classVariableNames:'HandleShadowForm HandleLightForm DefaultViewBackground
    24 	classVariableNames:'HandleShadowForm HandleLightForm DefaultViewBackground
    24 		DefaultShadowColor DefaultLightColor DefaultThumbColor
    25 		DefaultShadowColor DefaultLightColor DefaultThumbColor
    25 		DefaultThumbShadowColor DefaultThumbLightColor
    26 		DefaultThumbShadowColor DefaultThumbLightColor
    26 		DefaultThumbHalfShadowColor DefaultThumbHalfLightColor
    27 		DefaultThumbHalfShadowColor DefaultThumbHalfLightColor
    27 		DefaultHalfShadowColor DefaultHalfLightColor DefaultTallyMarks
    28 		DefaultHalfShadowColor DefaultHalfLightColor DefaultTallyMarks
   999     self invalidate
  1000     self invalidate
  1000 
  1001 
  1001     "Modified: 8.2.1997 / 15:15:58 / cg"
  1002     "Modified: 8.2.1997 / 15:15:58 / cg"
  1002 ! !
  1003 ! !
  1003 
  1004 
       
  1005 !Scroller methodsFor:'autoRepeat'!
       
  1006 
       
  1007 repeatPageDown
       
  1008     self pageDown.
       
  1009     Processor addTimedBlock:repeatBlock afterSeconds:repeatDelay
       
  1010 
       
  1011 !
       
  1012 
       
  1013 repeatPageUp
       
  1014     self pageUp.
       
  1015     Processor addTimedBlock:repeatBlock afterSeconds:repeatDelay
       
  1016 
       
  1017 ! !
       
  1018 
  1004 !Scroller methodsFor:'drawing'!
  1019 !Scroller methodsFor:'drawing'!
  1005 
  1020 
  1006 drawHandleFormAtX:x y:y
  1021 drawHandleFormAtX:x y:y
  1007     thumbShadowColor := thumbShadowColor on:device.
  1022     thumbShadowColor := thumbShadowColor on:device.
  1008 
  1023 
  1289     scrolling ifTrue:[^ self].
  1304     scrolling ifTrue:[^ self].
  1290 
  1305 
  1291     sensor := self sensor.
  1306     sensor := self sensor.
  1292     (((sensor notNil and:[sensor shiftDown]))
  1307     (((sensor notNil and:[sensor shiftDown]))
  1293     or:[DefaultMiddleButtonJump and:[button == 2]]) ifTrue:[
  1308     or:[DefaultMiddleButtonJump and:[button == 2]]) ifTrue:[
  1294 	^ self buttonShiftPress:button x:x y:y
  1309         ^ self buttonShiftPress:button x:x y:y
  1295     ].
  1310     ].
  1296     button ~~ 1 ifTrue:[
  1311     button ~~ 1 ifTrue:[
  1297 	^ self
  1312         ^ self
  1298     ].
  1313     ].
  1299 
  1314 
  1300     thumbFrame isNil ifTrue:[
  1315     thumbFrame isNil ifTrue:[
  1301 	self computeThumbFrame.
  1316         self computeThumbFrame.
  1302 	thumbFrame isNil ifTrue:[^ self].
  1317         thumbFrame isNil ifTrue:[^ self].
  1303     ].
  1318     ].
  1304 
  1319 
  1305     (orientation == #vertical) ifTrue:[
  1320     (orientation == #vertical) ifTrue:[
  1306 	curr := y.
  1321         curr := y.
  1307 	limit1 := thumbFrame top.
  1322         limit1 := thumbFrame top.
  1308 	limit2 := thumbFrame bottom
  1323         limit2 := thumbFrame bottom
  1309     ] ifFalse:[
  1324     ] ifFalse:[
  1310 	curr := x.
  1325         curr := x.
  1311 	limit1 := thumbFrame left.
  1326         limit1 := thumbFrame left.
  1312 	limit2 := thumbFrame right
  1327         limit2 := thumbFrame right
  1313     ].
  1328     ].
  1314 
  1329 
  1315     (curr < limit1) ifTrue:[
  1330     (curr < limit1) ifTrue:[
  1316 	"page up/left"
  1331         "page up/left"
  1317 	self pageUp
  1332         self pageUp.
  1318     ] ifFalse:[
  1333         autoRepeat ifTrue:[
  1319 	(curr > limit2) ifTrue:[
  1334             repeatBlock notNil ifTrue:[
  1320 	    "page down/right"
  1335                 Processor removeTimedBlock:repeatBlock.
  1321 	    self pageDown
  1336             ].
  1322 	] ifFalse:[
  1337             repeatBlock := [self repeatPageUp].
  1323 	    pressOffset := curr - limit1.
  1338             Processor addTimedBlock:repeatBlock afterSeconds:initialRepeatDelay
  1324 	    scrolling := true
  1339         ]
  1325 	]
  1340     ] ifFalse:[
       
  1341         (curr > limit2) ifTrue:[
       
  1342             "page down/right"
       
  1343             self pageDown.
       
  1344             autoRepeat ifTrue:[
       
  1345                 repeatBlock notNil ifTrue:[
       
  1346                     Processor removeTimedBlock:repeatBlock.
       
  1347                 ].
       
  1348                 repeatBlock := [self repeatPageDown].
       
  1349                 Processor addTimedBlock:repeatBlock afterSeconds:initialRepeatDelay
       
  1350             ]
       
  1351         ] ifFalse:[
       
  1352             pressOffset := curr - limit1.
       
  1353             scrolling := true
       
  1354         ]
  1326     ].
  1355     ].
  1327     self highlightThumbForPointerX:x y:y.
  1356     self highlightThumbForPointerX:x y:y.
  1328     self changeCursorFor:(x@y).
  1357     self changeCursorFor:(x@y).
  1329 
  1358 
  1330     "Modified: / 2.2.1998 / 23:30:26 / stefan"
  1359     "Modified: / 2.2.1998 / 23:30:26 / stefan"
  1335     "mouse-button was released - if scroll-mode is asynchronous, the scroll
  1364     "mouse-button was released - if scroll-mode is asynchronous, the scroll
  1336      action is now performed"
  1365      action is now performed"
  1337 
  1366 
  1338     |rect mustDrawThumb|
  1367     |rect mustDrawThumb|
  1339 
  1368 
       
  1369     repeatBlock notNil ifTrue:[
       
  1370         Processor removeTimedBlock:repeatBlock.
       
  1371         repeatBlock := nil
       
  1372     ].
       
  1373 
  1340     (button == 1 or:[DefaultMiddleButtonJump and:[button == 2]])
  1374     (button == 1 or:[DefaultMiddleButtonJump and:[button == 2]])
  1341 	ifFalse:[^ super buttonRelease:button x:x y:y].
  1375         ifFalse:[^ super buttonRelease:button x:x y:y].
  1342 
  1376 
  1343     scrolling ifTrue:[
  1377     scrolling ifTrue:[
  1344 	scrolling := false.
  1378         scrolling := false.
  1345 	thumbFrame notNil ifTrue:[
  1379         thumbFrame notNil ifTrue:[
  1346 	    mustDrawThumb := false.
  1380             mustDrawThumb := false.
  1347 
  1381 
  1348 	    frameBeforeMove notNil ifTrue:[
  1382             frameBeforeMove notNil ifTrue:[
  1349 		rect := frameBeforeMove.
  1383                 rect := frameBeforeMove.
  1350 		frameBeforeMove := nil.
  1384                 frameBeforeMove := nil.
  1351 		self drawThumbBackgroundInX:rect left
  1385                 self drawThumbBackgroundInX:rect left
  1352 					  y:rect top
  1386                                           y:rect top
  1353 				      width:rect width 
  1387                                       width:rect width 
  1354 				     height:rect height.
  1388                                      height:rect height.
  1355 
  1389 
  1356 		(rect intersects:thumbFrame) ifTrue:[
  1390                 (rect intersects:thumbFrame) ifTrue:[
  1357 		    mustDrawThumb := true.
  1391                     mustDrawThumb := true.
  1358 		]
  1392                 ]
  1359 	    ].
  1393             ].
  1360 	    thumbLevel ~~ thumbActiveLevel ifTrue:[
  1394             thumbLevel ~~ thumbActiveLevel ifTrue:[
  1361 		mustDrawThumb := true
  1395                 mustDrawThumb := true
  1362 	    ].
  1396             ].
  1363 	    mustDrawThumb ifTrue:[
  1397             mustDrawThumb ifTrue:[
  1364 		self drawThumb
  1398                 self drawThumb
  1365 	    ].    
  1399             ].    
  1366 
  1400 
  1367 "/            scrolling := false.
  1401 "/            scrolling := false.
  1368 	    synchronousOperation ifFalse: [
  1402             synchronousOperation ifFalse: [
  1369 		self tellOthers.
  1403                 self tellOthers.
  1370 	    ]
  1404             ]
  1371 	]
  1405         ]
  1372     ].
  1406     ].
  1373     self changeCursorFor:(x@y)
  1407     self changeCursorFor:(x@y)
  1374 
  1408 
  1375     "Modified: / 19.1.1998 / 13:45:59 / cg"
  1409     "Modified: / 19.1.1998 / 13:45:59 / cg"
  1376     "Modified: / 2.2.1998 / 23:37:27 / stefan"
  1410     "Modified: / 2.2.1998 / 23:37:27 / stefan"
  1740 !
  1774 !
  1741 
  1775 
  1742 initStyle
  1776 initStyle
  1743     "initialize style dep. stuff"
  1777     "initialize style dep. stuff"
  1744 
  1778 
  1745     <resource: #style (#name)>
  1779     <resource: #style (#name 
       
  1780                        #'scroller.autoRepeat'
       
  1781                        #'scroller.initialRepeatDelay'
       
  1782                        #'scroller.repeatDelay')>
  1746 
  1783 
  1747     |nm|
  1784     |nm|
  1748 
  1785 
  1749     super initStyle.
  1786     super initStyle.
  1750 
  1787 
  1751     DefaultViewBackground notNil ifTrue:[
  1788     DefaultViewBackground notNil ifTrue:[
  1752 	viewBackground := DefaultViewBackground onDevice:device.
  1789         viewBackground := DefaultViewBackground onDevice:device.
  1753     ].
  1790     ].
  1754     DefaultShadowColor notNil ifTrue:[
  1791     DefaultShadowColor notNil ifTrue:[
  1755 	shadowColor := DefaultShadowColor onDevice:device.
  1792         shadowColor := DefaultShadowColor onDevice:device.
  1756     ].
  1793     ].
  1757     DefaultLightColor notNil ifTrue:[
  1794     DefaultLightColor notNil ifTrue:[
  1758 	lightColor := DefaultLightColor onDevice:device.
  1795         lightColor := DefaultLightColor onDevice:device.
  1759     ].
  1796     ].
  1760 
  1797 
  1761     tallyMarks := DefaultTallyMarks.
  1798     tallyMarks := DefaultTallyMarks.
  1762     tallyLevel := DefaultTallyLevel.
  1799     tallyLevel := DefaultTallyLevel.
  1763     DefaultLevel ~~ level ifTrue:[
  1800     DefaultLevel ~~ level ifTrue:[
  1764 	self level:DefaultLevel.
  1801         self level:DefaultLevel.
  1765     ].
  1802     ].
  1766     DefaultBorderWidth ~~ borderWidth ifTrue:[
  1803     DefaultBorderWidth ~~ borderWidth ifTrue:[
  1767 	self borderWidth:DefaultBorderWidth.
  1804         self borderWidth:DefaultBorderWidth.
  1768     ].
  1805     ].
  1769     thumbLevel := DefaultThumbLevel.
  1806     thumbLevel := DefaultThumbLevel.
  1770     thumbActiveLevel := DefaultThumbActiveLevel.
  1807     thumbActiveLevel := DefaultThumbActiveLevel.
  1771     inset := DefaultInset.
  1808     inset := DefaultInset.
  1772     fixThumbHeight := DefaultFixThumbHeight.
  1809     fixThumbHeight := DefaultFixThumbHeight.
  1773     thumbEdgeStyle := DefaultEdgeStyle.
  1810     thumbEdgeStyle := DefaultEdgeStyle.
  1774 
  1811 
  1775     DefaultGhostColor notNil ifTrue:[
  1812     DefaultGhostColor notNil ifTrue:[
  1776 	ghostColor := DefaultGhostColor onDevice:device.
  1813         ghostColor := DefaultGhostColor onDevice:device.
  1777     ].
  1814     ].
  1778     DefaultGhostFrameColor notNil ifTrue:[
  1815     DefaultGhostFrameColor notNil ifTrue:[
  1779 	ghostFrameColor := DefaultGhostFrameColor onDevice:device.
  1816         ghostFrameColor := DefaultGhostFrameColor onDevice:device.
  1780     ].
  1817     ].
  1781     ghostLevel := DefaultGhostLevel.
  1818     ghostLevel := DefaultGhostLevel.
  1782 
  1819 
  1783     DefaultThumbFrameColor notNil ifTrue:[
  1820     DefaultThumbFrameColor notNil ifTrue:[
  1784 	thumbFrameColor := DefaultThumbFrameColor onDevice:device.
  1821         thumbFrameColor := DefaultThumbFrameColor onDevice:device.
  1785     ].
  1822     ].
  1786     DefaultThumbShadowColor notNil ifTrue:[
  1823     DefaultThumbShadowColor notNil ifTrue:[
  1787 	thumbShadowColor := DefaultThumbShadowColor
  1824         thumbShadowColor := DefaultThumbShadowColor
  1788     ] ifFalse:[
  1825     ] ifFalse:[
  1789 	thumbShadowColor := shadowColor.
  1826         thumbShadowColor := shadowColor.
  1790     ].
  1827     ].
  1791     DefaultThumbLightColor notNil ifTrue:[
  1828     DefaultThumbLightColor notNil ifTrue:[
  1792 	thumbLightColor := DefaultThumbLightColor
  1829         thumbLightColor := DefaultThumbLightColor
  1793     ] ifFalse:[
  1830     ] ifFalse:[
  1794 	thumbLightColor := lightColor.
  1831         thumbLightColor := lightColor.
  1795     ].
  1832     ].
  1796 
  1833 
  1797     thumbEdgeStyle notNil ifTrue:[
  1834     thumbEdgeStyle notNil ifTrue:[
  1798 	DefaultThumbHalfShadowColor notNil ifTrue:[
  1835         DefaultThumbHalfShadowColor notNil ifTrue:[
  1799 	    thumbHalfShadowColor := DefaultThumbHalfShadowColor
  1836             thumbHalfShadowColor := DefaultThumbHalfShadowColor
  1800 	].
  1837         ].
  1801 
  1838 
  1802 	DefaultThumbHalfLightColor notNil ifTrue:[
  1839         DefaultThumbHalfLightColor notNil ifTrue:[
  1803 	    thumbHalfLightColor := DefaultThumbHalfLightColor
  1840             thumbHalfLightColor := DefaultThumbHalfLightColor
  1804 	].
  1841         ].
  1805     ].
  1842     ].
  1806 
  1843 
  1807     nm := styleSheet name.
  1844     nm := styleSheet name.
  1808 
  1845 
  1809     device hasGrayscales ifFalse:[
  1846     device hasGrayscales ifFalse:[
  1810 	thumbEdgeStyle notNil ifTrue:[
  1847         thumbEdgeStyle notNil ifTrue:[
  1811 	    thumbHalfShadowColor := Color darkGray.
  1848             thumbHalfShadowColor := Color darkGray.
  1812 	    thumbHalfLightColor := White
  1849             thumbHalfLightColor := White
  1813 	].
  1850         ].
  1814 
  1851 
  1815 	thumbShadowColor := Black.
  1852         thumbShadowColor := Black.
  1816 "/        thumbLightColor := White.
  1853 "/        thumbLightColor := White.
  1817 
  1854 
  1818 	nm = #motif ifTrue:[
  1855         nm = #motif ifTrue:[
  1819 	    DefaultThumbColor isNil ifTrue:[
  1856             DefaultThumbColor isNil ifTrue:[
  1820 		thumbColor := White .
  1857                 thumbColor := White .
  1821 	    ].
  1858             ].
  1822 	]
  1859         ]
  1823     ].
  1860     ].
  1824 
  1861 
  1825     DefaultThumbColor notNil ifTrue:[
  1862     DefaultThumbColor notNil ifTrue:[
  1826 	thumbColor := DefaultThumbColor onDevice:device
  1863         thumbColor := DefaultThumbColor onDevice:device
  1827     ] ifFalse:[
  1864     ] ifFalse:[
  1828 	thumbColor := White.
  1865         thumbColor := White.
  1829 	nm ~= #normal ifTrue:[
  1866         nm ~= #normal ifTrue:[
  1830 	    device hasGrayscales ifFalse:[
  1867             device hasGrayscales ifFalse:[
  1831 		thumbColor := Color grey
  1868                 thumbColor := Color grey
  1832 	    ].
  1869             ].
  1833 	].
  1870         ].
  1834     ].
  1871     ].
  1835 
  1872 
  1836     thumbColor := thumbColor on:device.
  1873     thumbColor := thumbColor on:device.
  1837     thumbShadowColor notNil ifTrue:[
  1874     thumbShadowColor notNil ifTrue:[
  1838 	thumbShadowColor := thumbShadowColor onDevice:device.
  1875         thumbShadowColor := thumbShadowColor onDevice:device.
  1839     ].
  1876     ].
  1840     thumbLightColor notNil ifTrue:[
  1877     thumbLightColor notNil ifTrue:[
  1841 	thumbLightColor := thumbLightColor onDevice:device.
  1878         thumbLightColor := thumbLightColor onDevice:device.
  1842     ].
  1879     ].
  1843     thumbHalfShadowColor notNil ifTrue:[
  1880     thumbHalfShadowColor notNil ifTrue:[
  1844 	thumbHalfShadowColor := thumbHalfShadowColor onDevice:device.
  1881         thumbHalfShadowColor := thumbHalfShadowColor onDevice:device.
  1845     ].
  1882     ].
  1846     thumbHalfLightColor notNil ifTrue:[
  1883     thumbHalfLightColor notNil ifTrue:[
  1847 	thumbHalfLightColor := thumbHalfLightColor onDevice:device.
  1884         thumbHalfLightColor := thumbHalfLightColor onDevice:device.
  1848     ].
  1885     ].
  1849     thumbEdgeStyle notNil ifTrue:[
  1886     thumbEdgeStyle notNil ifTrue:[
  1850 	thumbHalfShadowColor isNil ifTrue:[
  1887         thumbHalfShadowColor isNil ifTrue:[
  1851 	    thumbHalfShadowColor := thumbShadowColor lightened onDevice:device
  1888             thumbHalfShadowColor := thumbShadowColor lightened onDevice:device
  1852 	]
  1889         ]
  1853     ].
  1890     ].
  1854 
  1891 
  1855     DefaultThumbEnteredColor notNil ifTrue:[
  1892     DefaultThumbEnteredColor notNil ifTrue:[
  1856 	thumbEnteredColor := DefaultThumbEnteredColor onDevice:device.
  1893         thumbEnteredColor := DefaultThumbEnteredColor onDevice:device.
  1857     ] ifFalse:[
  1894     ] ifFalse:[
  1858 	thumbEnteredColor := thumbColor.
  1895         thumbEnteredColor := thumbColor.
  1859     ].
  1896     ].
  1860 
  1897 
  1861     (DefaultThumbEnteredColor notNil or:[NewCursors]) ifTrue:[
  1898     (DefaultThumbEnteredColor notNil or:[NewCursors]) ifTrue:[
  1862 	self enableMotionEvents.
  1899         self enableMotionEvents.
  1863 	self enableEnterLeaveEvents.
  1900         self enableEnterLeaveEvents.
  1864     ].
  1901     ].
  1865 
  1902 
  1866     DefaultThumbImage notNil ifTrue:[
  1903     DefaultThumbImage notNil ifTrue:[
  1867 	thumbImage := DefaultThumbImage onDevice:device.
  1904         thumbImage := DefaultThumbImage onDevice:device.
  1868 	fixThumbHeight := true.
  1905         fixThumbHeight := true.
  1869     ].
  1906     ].
  1870 
  1907 
  1871     HandleImage notNil ifTrue:[
  1908     HandleImage notNil ifTrue:[
  1872 	shadowForm := HandleImage onDevice:device.
  1909         shadowForm := HandleImage onDevice:device.
  1873     ] ifFalse:[
  1910     ] ifFalse:[
  1874 	nm = #next ifTrue:[
  1911         nm = #next ifTrue:[
  1875 	    shadowForm := self class handleShadowFormOn:device.
  1912             shadowForm := self class handleShadowFormOn:device.
  1876 	    lightForm := self class handleLightFormOn:device
  1913             lightForm := self class handleLightFormOn:device
  1877 	] ifFalse:[
  1914         ] ifFalse:[
  1878 	    shadowForm := lightForm := nil
  1915             shadowForm := lightForm := nil
  1879 	].
  1916         ].
  1880     ].
  1917     ].
  1881     drawableId notNil ifTrue:[
  1918     drawableId notNil ifTrue:[
  1882 	self computeThumbFrame
  1919         self computeThumbFrame
  1883     ]
  1920     ].
       
  1921 
       
  1922     autoRepeat := styleSheet at:#'scroller.autoRepeat' default:true.
       
  1923     initialRepeatDelay := styleSheet at:#'scroller.initialRepeatDelay' default:0.2.
       
  1924     repeatDelay := styleSheet at:#'scroller.repeatDelay' default:0.1.
  1884 
  1925 
  1885     "Modified: / 5.9.1998 / 20:21:41 / cg"
  1926     "Modified: / 5.9.1998 / 20:21:41 / cg"
  1886 !
  1927 !
  1887 
  1928 
  1888 initialize
  1929 initialize
  2267 ! !
  2308 ! !
  2268 
  2309 
  2269 !Scroller class methodsFor:'documentation'!
  2310 !Scroller class methodsFor:'documentation'!
  2270 
  2311 
  2271 version
  2312 version
  2272     ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.115 1999-03-07 13:26:10 cg Exp $'
  2313     ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.116 1999-03-16 13:04:59 cg Exp $'
  2273 ! !
  2314 ! !