Scroller.st
changeset 1518 6d8e1461f119
parent 1514 b819aca5ab4b
child 1531 c5f2cfee9998
equal deleted inserted replaced
1517:bce92900f46d 1518:6d8e1461f119
    16 		synchronousOperation shadowForm lightForm inset thumbShadowColor
    16 		synchronousOperation shadowForm lightForm inset thumbShadowColor
    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'
    21 		thumbActiveLevel originBeforeMove thumbImage'
    22 	classVariableNames:'HandleShadowForm HandleLightForm DefaultViewBackground
    22 	classVariableNames:'HandleShadowForm HandleLightForm DefaultViewBackground
    23 		DefaultShadowColor DefaultLightColor DefaultThumbColor
    23 		DefaultShadowColor DefaultLightColor DefaultThumbColor
    24 		DefaultThumbShadowColor DefaultThumbLightColor
    24 		DefaultThumbShadowColor DefaultThumbLightColor
    25 		DefaultThumbHalfShadowColor DefaultThumbHalfLightColor
    25 		DefaultThumbHalfShadowColor DefaultThumbHalfLightColor
    26 		DefaultHalfShadowColor DefaultHalfLightColor DefaultTallyMarks
    26 		DefaultHalfShadowColor DefaultHalfLightColor DefaultTallyMarks
    27 		DefaultTallyLevel DefaultLevel DefaultBorderWidth
    27 		DefaultTallyLevel DefaultLevel DefaultBorderWidth
    28 		DefaultThumbLevel DefaultInset DefaultThumbFrameColor
    28 		DefaultThumbLevel DefaultInset DefaultThumbFrameColor
    29 		DefaultGhostColor DefaultGhostFrameColor DefaultGhostLevel
    29 		DefaultGhostColor DefaultGhostFrameColor DefaultGhostLevel
    30 		DefaultFixThumbHeight DefaultEdgeStyle DefaultFullViewBackground
    30 		DefaultFixThumbHeight DefaultEdgeStyle DefaultFullViewBackground
    31 		DefaultThumbEnteredColor DefaultThumbActiveLevel SnapBackDistance
    31 		DefaultThumbEnteredColor DefaultThumbActiveLevel SnapBackDistance
    32 		DefaultMiddleButtonJump NewCursors'
    32 		DefaultMiddleButtonJump NewCursors DefaultThumbImage'
    33 	poolDictionaries:''
    33 	poolDictionaries:''
    34 	category:'Views-Interactors'
    34 	category:'Views-Interactors'
    35 !
    35 !
    36 
    36 
    37 !Scroller class methodsFor:'documentation'!
    37 !Scroller class methodsFor:'documentation'!
   381     DefaultInset := StyleSheet at:'scroller.thumbInset' default:0.
   381     DefaultInset := StyleSheet at:'scroller.thumbInset' default:0.
   382     DefaultFixThumbHeight := StyleSheet at:'scroller.thumbFixHeight' default:false.
   382     DefaultFixThumbHeight := StyleSheet at:'scroller.thumbFixHeight' default:false.
   383     DefaultEdgeStyle := StyleSheet at:'scroller.thumbEdgeStyle'.
   383     DefaultEdgeStyle := StyleSheet at:'scroller.thumbEdgeStyle'.
   384     DefaultMiddleButtonJump := StyleSheet at:'scroller.middleButtonJump' default:false.
   384     DefaultMiddleButtonJump := StyleSheet at:'scroller.middleButtonJump' default:false.
   385     NewCursors := StyleSheet at:'scroller.newCursors' default:true.
   385     NewCursors := StyleSheet at:'scroller.newCursors' default:true.
       
   386     DefaultThumbImage := StyleSheet at:'scroller.thumbImage'.
   386 
   387 
   387     StyleSheet fileReadFailed ifTrue:[
   388     StyleSheet fileReadFailed ifTrue:[
   388         DefaultViewBackground := Grey.
   389         DefaultViewBackground := Grey.
   389         DefaultThumbColor := White.
   390         DefaultThumbColor := White.
   390         DefaultThumbFrameColor := Black.
   391         DefaultThumbFrameColor := Black.
   395 
   396 
   396     "
   397     "
   397      self updateStyleCache
   398      self updateStyleCache
   398     "
   399     "
   399 
   400 
   400     "Modified: 23.10.1997 / 04:00:44 / cg"
   401     "Modified: / 12.5.1998 / 20:24:54 / cg"
   401 ! !
   402 ! !
   402 
   403 
   403 !Scroller methodsFor:'accessing'!
   404 !Scroller methodsFor:'accessing'!
   404 
   405 
   405 start 
   406 start 
   979     lvl == 0 ifTrue:[
   980     lvl == 0 ifTrue:[
   980         thumbFrameColor notNil ifTrue:[
   981         thumbFrameColor notNil ifTrue:[
   981             self paint:thumbFrameColor.
   982             self paint:thumbFrameColor.
   982             self displayRectangle:thumbFrame.
   983             self displayRectangle:thumbFrame.
   983         ].
   984         ].
       
   985         thumbImage notNil ifTrue:[
       
   986             thumbImage displayOn:self x:l y:t
       
   987         ].
   984         ^ self
   988         ^ self
   985     ].
   989     ].
   986 
   990 
   987     self drawEdgesForX:l y:t width:w height:h level:lvl
   991     self drawEdgesForX:l y:t width:w height:h level:lvl
   988                 shadow:thumbShadowColor light:thumbLightColor
   992                 shadow:thumbShadowColor light:thumbLightColor
   994         orientation == #vertical ifTrue:[
   998         orientation == #vertical ifTrue:[
   995             self displayRectangleX:l y:t width:w"-1" height:h.
   999             self displayRectangleX:l y:t width:w"-1" height:h.
   996         ] ifFalse:[
  1000         ] ifFalse:[
   997             self displayRectangleX:l y:t width:w height:h"-1".
  1001             self displayRectangleX:l y:t width:w height:h"-1".
   998         ]
  1002         ]
       
  1003     ].
       
  1004 
       
  1005     thumbImage notNil ifTrue:[
       
  1006         thumbImage displayOn:self x:l y:t
   999     ].
  1007     ].
  1000 
  1008 
  1001     (tallyLevel == 0 or:[tallyMarks == 0]) ifTrue:[
  1009     (tallyLevel == 0 or:[tallyMarks == 0]) ifTrue:[
  1002         shadowForm notNil ifTrue:[
  1010         shadowForm notNil ifTrue:[
  1003             handleX := l + ((w - 8) // 2).
  1011             handleX := l + ((w - 8) // 2).
  1079                 self displayLineFromX:x y:yT toX:x y:yB
  1087                 self displayLineFromX:x y:yT toX:x y:yB
  1080             ]
  1088             ]
  1081         ]
  1089         ]
  1082     ]
  1090     ]
  1083 
  1091 
  1084     "Modified: 7.3.1997 / 17:02:50 / cg"
  1092     "Modified: / 12.5.1998 / 20:39:52 / cg"
  1085 !
  1093 !
  1086 
  1094 
  1087 drawThumbBackgroundInX:x y:y width:w height:h
  1095 drawThumbBackgroundInX:x y:y width:w height:h
  1088     "draw part of the thumbs background; defined as a separate
  1096     "draw part of the thumbs background; defined as a separate
  1089      method, to allow drawing of arbitrary patterns under thumb 
  1097      method, to allow drawing of arbitrary patterns under thumb 
  1736     (DefaultThumbEnteredColor notNil or:[NewCursors]) ifTrue:[
  1744     (DefaultThumbEnteredColor notNil or:[NewCursors]) ifTrue:[
  1737         self enableMotionEvents.
  1745         self enableMotionEvents.
  1738         self enableEnterLeaveEvents.
  1746         self enableEnterLeaveEvents.
  1739     ].
  1747     ].
  1740 
  1748 
       
  1749     DefaultThumbImage notNil ifTrue:[
       
  1750         thumbImage := DefaultThumbImage on:device.
       
  1751         fixThumbHeight := true.
       
  1752     ].
       
  1753 
  1741     nm = #next ifTrue:[
  1754     nm = #next ifTrue:[
  1742         shadowForm := self class handleShadowFormOn:device.
  1755         shadowForm := self class handleShadowFormOn:device.
  1743         lightForm := self class handleLightFormOn:device
  1756         lightForm := self class handleLightFormOn:device
  1744     ] ifFalse:[
  1757     ] ifFalse:[
  1745         shadowForm := lightForm := nil
  1758         shadowForm := lightForm := nil
  1747 
  1760 
  1748     drawableId notNil ifTrue:[
  1761     drawableId notNil ifTrue:[
  1749         self computeThumbFrame
  1762         self computeThumbFrame
  1750     ]
  1763     ]
  1751 
  1764 
  1752     "Modified: / 29.10.1997 / 01:34:45 / cg"
  1765     "Modified: / 12.5.1998 / 20:26:21 / cg"
  1753 !
  1766 !
  1754 
  1767 
  1755 initialize
  1768 initialize
  1756     "initialize - setup instvars from defaults"
  1769     "initialize - setup instvars from defaults"
  1757 
  1770 
  1855 
  1868 
  1856     fixThumbHeight ifTrue:[
  1869     fixThumbHeight ifTrue:[
  1857         "have a fix-size thumb (i.e. mswindows style)"
  1870         "have a fix-size thumb (i.e. mswindows style)"
  1858 
  1871 
  1859         newSize1 := sz2 - (2 * inset).   "make it square"
  1872         newSize1 := sz2 - (2 * inset).   "make it square"
       
  1873         thumbImage notNil ifTrue:[
       
  1874             newSize1 := (newSize1 max:(thumbImage height)) max:(thumbImage width)
       
  1875         ].
  1860         thumbFrameSizeDifference := newSize1 - computedSize.
  1876         thumbFrameSizeDifference := newSize1 - computedSize.
  1861     ].
  1877     ].
  1862 
  1878 
  1863     "
  1879     "
  1864      oops - if height does not relect real visibible area, we have to adjust the origin
  1880      oops - if height does not relect real visibible area, we have to adjust the origin
  1897             ]
  1913             ]
  1898           ]
  1914           ]
  1899         ]
  1915         ]
  1900     ].
  1916     ].
  1901     thumbFrame := Rectangle left:nx top:ny width:nw height:nh
  1917     thumbFrame := Rectangle left:nx top:ny width:nw height:nh
       
  1918 
       
  1919     "Modified: / 12.5.1998 / 20:58:51 / cg"
  1902 !
  1920 !
  1903 
  1921 
  1904 percentFromAbs:absValue
  1922 percentFromAbs:absValue
  1905     "given a number of pixels, compute percentage"
  1923     "given a number of pixels, compute percentage"
  1906 
  1924 
  2081     ^ preferredExtent.
  2099     ^ preferredExtent.
  2082 
  2100 
  2083     "Modified: 19.7.1996 / 20:45:35 / cg"
  2101     "Modified: 19.7.1996 / 20:45:35 / cg"
  2084 !
  2102 !
  2085 
  2103 
  2086 thumbUsable
  2104 thumbVisible
  2087     "return true, if the thumb is usable i.e. its visible & movable.
  2105     "return true, if the thumb is usable i.e. its visible & movable.
  2088      Used by the scrollBar to decide if it should hide the scroller."
  2106      Can be used by the scrollBar to decide if it should hide the scroller."
       
  2107 
       
  2108     |m2|
  2089 
  2109 
  2090     (thumbHeight >= 100) ifTrue:[^ false].
  2110     (thumbHeight >= 100) ifTrue:[^ false].
  2091     self computeThumbFrame.
  2111     self computeThumbFrame.
  2092     thumbFrame isNil ifTrue:[^ false].
  2112     thumbFrame isNil ifTrue:[^ false].
  2093 
  2113 
       
  2114     m2 := margin * 2.
  2094     orientation == #vertical ifTrue:[
  2115     orientation == #vertical ifTrue:[
  2095         thumbFrame height >= (height - margin - margin) ifTrue:[^ false].
  2116         thumbFrame height >= (height - m2) ifTrue:[^ false].
  2096     ] ifFalse:[
  2117     ] ifFalse:[
  2097         thumbFrame width >= (width - margin - margin) ifTrue:[^ false].
  2118         thumbFrame width >= (width - m2) ifTrue:[^ false].
  2098     ].
  2119     ].
  2099     ^ true
  2120     ^ true
  2100 
  2121 
  2101     "Modified: 7.3.1997 / 17:23:07 / cg"
  2122     "Created: / 7.3.1997 / 21:10:23 / cg"
  2102     "Created: 7.3.1997 / 21:09:51 / cg"
  2123     "Modified: / 12.5.1998 / 20:21:00 / cg"
  2103 !
       
  2104 
       
  2105 thumbVisible
       
  2106     "return true, if the thumb is usable i.e. its visible & movable.
       
  2107      Can be used by the scrollBar to decide if it should hide the scroller."
       
  2108 
       
  2109     (thumbHeight >= 100) ifTrue:[^ false].
       
  2110     self computeThumbFrame.
       
  2111     thumbFrame isNil ifTrue:[^ false].
       
  2112 
       
  2113     orientation == #vertical ifTrue:[
       
  2114         thumbFrame height >= (height - margin - margin) ifTrue:[^ false].
       
  2115     ] ifFalse:[
       
  2116         thumbFrame width >= (width - margin - margin) ifTrue:[^ false].
       
  2117     ].
       
  2118     ^ true
       
  2119 
       
  2120     "Modified: 7.3.1997 / 17:23:07 / cg"
       
  2121     "Created: 7.3.1997 / 21:10:23 / cg"
       
  2122 ! !
  2124 ! !
  2123 
  2125 
  2124 !Scroller class methodsFor:'documentation'!
  2126 !Scroller class methodsFor:'documentation'!
  2125 
  2127 
  2126 version
  2128 version
  2127     ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.103 1998-05-07 17:41:44 cg Exp $'
  2129     ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.104 1998-05-12 18:59:41 cg Exp $'
  2128 ! !
  2130 ! !