--- a/Scroller.st Wed Mar 06 18:02:39 1996 +0100
+++ b/Scroller.st Wed Mar 06 18:03:26 1996 +0100
@@ -15,9 +15,9 @@
orientation thumbFrame thumbLevel scrolling pressOffset
synchronousOperation shadowForm lightForm inset thumbShadowColor
thumbLightColor thumbEdgeStyle thumbHalfShadowColor
- thumbHalfLightColor thumbFrameSizeDifference tallyLevel
- tallyMarks fixThumbHeight frameBeforeMove ghostColor
- ghostFrameColor ghostLevel rangeStart rangeEnd rangeStep'
+ thumbHalfLightColor thumbEnteredColor thumbFrameSizeDifference
+ tallyLevel tallyMarks fixThumbHeight frameBeforeMove ghostColor
+ ghostFrameColor ghostLevel rangeStart rangeEnd rangeStep entered'
classVariableNames:'HandleShadowForm HandleLightForm DefaultViewBackground
DefaultShadowColor DefaultLightColor DefaultThumbColor
DefaultThumbShadowColor DefaultThumbLightColor
@@ -26,7 +26,8 @@
DefaultTallyLevel DefaultLevel DefaultBorderWidth
DefaultThumbLevel DefaultInset DefaultThumbFrameColor
DefaultGhostColor DefaultGhostFrameColor DefaultGhostLevel
- DefaultFixThumbHeight DefaultEdgeStyle DefaultFullViewBackground'
+ DefaultFixThumbHeight DefaultEdgeStyle DefaultFullViewBackground
+ DefaultThumbEnteredColor'
poolDictionaries:''
category:'Views-Interactors'
!
@@ -319,20 +320,21 @@
"extract values from the styleSheet and cache them in class variables"
<resource: #style (#scrollerViewBackground #scrollerFullViewBackground
- #scrollerThumbColor
- #scrollerShadowColor #scrollerLightColor
- #scrollerThumbShadowColor #scrollerThumbLightColor
- #scrollerThumbHalfShadowColor #scrollerThumbHalfLightColor
- #scrollerThumbFrameColor #scrollerGhostColor
- #scrollerGhostLevel #scrollerGhostFrameColor
- #scrollerNTallyMarks #scrollerTallyLevel
- #scrollerLevel #scrollerBorderWidth
- #scrollerThumbLevel #scrollerThumbInset
- #scrollerThumbFixHeight #scrollerThumbEdgeStyle)>
+ #scrollerThumbColor
+ #scrollerShadowColor #scrollerLightColor
+ #scrollerThumbShadowColor #scrollerThumbLightColor
+ #scrollerThumbHalfShadowColor #scrollerThumbHalfLightColor
+ #scrollerThumbFrameColor #scrollerGhostColor
+ #scrollerGhostLevel #scrollerGhostFrameColor
+ #scrollerNTallyMarks #scrollerTallyLevel
+ #scrollerLevel #scrollerBorderWidth
+ #scrollerThumbLevel #scrollerThumbInset
+ #scrollerThumbFixHeight #scrollerThumbEdgeStyle)>
DefaultViewBackground := StyleSheet colorAt:'scrollerViewBackground'.
DefaultFullViewBackground := StyleSheet colorAt:'scrollerFullViewBackground'.
DefaultThumbColor := StyleSheet colorAt:'scrollerThumbColor'.
+ DefaultThumbEnteredColor := StyleSheet colorAt:'scrollerThumbEnteredColor'.
DefaultShadowColor := StyleSheet colorAt:'scrollerShadowColor'.
DefaultLightColor := StyleSheet colorAt:'scrollerLightColor'.
DefaultThumbShadowColor := StyleSheet colorAt:'scrollerThumbShadowColor'.
@@ -346,7 +348,7 @@
DefaultTallyMarks := StyleSheet at:'scrollerNTallyMarks' default:0.
DefaultTallyLevel := 0.
DefaultTallyMarks ~~ 0 ifTrue:[
- DefaultTallyLevel := StyleSheet at:'scrollerTallyLevel' default:1.
+ DefaultTallyLevel := StyleSheet at:'scrollerTallyLevel' default:1.
].
DefaultLevel := StyleSheet at:'scrollerLevel' default:0.
DefaultBorderWidth := StyleSheet at:'scrollerBorderWidth' default:(StyleSheet at:'borderWidth').
@@ -356,13 +358,13 @@
DefaultEdgeStyle := StyleSheet at:'scrollerThumbEdgeStyle'.
StyleSheet fileReadFailed ifTrue:[
- DefaultViewBackground := Grey.
- DefaultThumbColor := White.
- DefaultThumbFrameColor := Black.
- DefaultInset := 1.
+ DefaultViewBackground := Grey.
+ DefaultThumbColor := White.
+ DefaultThumbFrameColor := Black.
+ DefaultInset := 1.
]
- "Modified: 1.3.1996 / 13:48:45 / cg"
+ "Modified: 6.3.1996 / 17:22:25 / cg"
! !
!Scroller methodsFor:'accessing'!
@@ -800,123 +802,126 @@
(thumbHeight >= 100) ifTrue:[^ self].
orientation == #vertical ifTrue:[
- thumbFrame height >= height ifTrue:[^ self].
+ thumbFrame height >= height ifTrue:[^ self].
] ifFalse:[
- thumbFrame width >= width ifTrue:[^ self].
+ thumbFrame width >= width ifTrue:[^ self].
].
l := thumbFrame left.
t := thumbFrame top.
w := thumbFrame width.
h := thumbFrame height.
- self paint:thumbColor.
+
+ self paint:(entered ifTrue:[thumbEnteredColor] ifFalse:[thumbColor]).
self fillRectangleX:l y:t width:w-1 height:h.
thumbLevel == 0 ifTrue:[
- thumbFrameColor notNil ifTrue:[
- self paint:thumbFrameColor.
- self displayRectangle:thumbFrame.
- ].
- ^ self
+ thumbFrameColor notNil ifTrue:[
+ self paint:thumbFrameColor.
+ self displayRectangle:thumbFrame.
+ ].
+ ^ self
].
"what a kludge - must be a parameter to drawEdge..."
self drawEdgesForX:l y:t width:w height:h level:thumbLevel
- shadow:thumbShadowColor light:thumbLightColor
- halfShadow:thumbHalfShadowColor halfLight:thumbHalfLightColor
- style:thumbEdgeStyle.
+ shadow:thumbShadowColor light:thumbLightColor
+ halfShadow:thumbHalfShadowColor halfLight:thumbHalfLightColor
+ style:thumbEdgeStyle.
thumbFrameColor notNil ifTrue:[
- self paint:thumbFrameColor.
- orientation == #vertical ifTrue:[
- self displayRectangleX:l y:t width:w"-1" height:h.
- ] ifFalse:[
- self displayRectangleX:l y:t width:w height:h"-1".
- ]
+ self paint:thumbFrameColor.
+ orientation == #vertical ifTrue:[
+ self displayRectangleX:l y:t width:w"-1" height:h.
+ ] ifFalse:[
+ self displayRectangleX:l y:t width:w height:h"-1".
+ ]
].
(tallyLevel == 0 or:[tallyMarks == 0]) ifTrue:[
- shadowForm notNil ifTrue:[
- handleX := l + ((w - 8) // 2).
- handleY := t + ((h - 8) // 2).
- self drawHandleFormAtX:handleX y:handleY
- ].
- ^ self
+ shadowForm notNil ifTrue:[
+ handleX := l + ((w - 8) // 2).
+ handleY := t + ((h - 8) // 2).
+ self drawHandleFormAtX:handleX y:handleY
+ ].
+ ^ self
].
"iris style - draw tallys"
tallyLevel > 0 ifTrue:[
- color1 := thumbLightColor.
- color2 := thumbShadowColor.
+ color1 := thumbLightColor.
+ color2 := thumbShadowColor.
] ifFalse:[
- color1 := thumbShadowColor.
- color2 := thumbLightColor.
+ color1 := thumbShadowColor.
+ color2 := thumbLightColor.
].
"draw tally marks"
(orientation == #vertical) ifTrue:[
- self paint:color1.
- y := t + (h // 2) - 1.
- xL := l + thumbLevel - 1.
- xR := l + w - thumbLevel "+ 1".
- self displayLineFromX:xL y:y toX:xR y:y.
- y := y + 1.
- self paint:color2.
- self displayLineFromX:xL y:y toX:xR y:y.
+ self paint:color1.
+ y := t + (h // 2) - 1.
+ xL := l + thumbLevel - 1.
+ xR := l + w - thumbLevel "+ 1".
+ self displayLineFromX:xL y:y toX:xR y:y.
+ y := y + 1.
+ self paint:color2.
+ self displayLineFromX:xL y:y toX:xR y:y.
- tallyMarks > 1 ifTrue:[
- "dont draw other marks if there is not enough space"
+ tallyMarks > 1 ifTrue:[
+ "dont draw other marks if there is not enough space"
- mm := device verticalPixelPerMillimeter rounded.
- h > (mm * (tallyMarks * 2)) ifTrue:[
- y := y - 1 - mm.
- self paint:color1.
- self displayLineFromX:xL y:y toX:xR y:y.
- y := y + 1.
- self paint:color2.
- self displayLineFromX:xL y:y toX:xR y:y.
+ mm := device verticalPixelPerMillimeter rounded.
+ h > (mm * (tallyMarks * 2)) ifTrue:[
+ y := y - 1 - mm.
+ self paint:color1.
+ self displayLineFromX:xL y:y toX:xR y:y.
+ y := y + 1.
+ self paint:color2.
+ self displayLineFromX:xL y:y toX:xR y:y.
- y := y - 1 + mm + mm.
- self paint:color1.
- self displayLineFromX:xL y:y toX:xR y:y.
- y := y + 1.
- self paint:color2.
- self displayLineFromX:xL y:y toX:xR y:y
- ]
- ]
+ y := y - 1 + mm + mm.
+ self paint:color1.
+ self displayLineFromX:xL y:y toX:xR y:y.
+ y := y + 1.
+ self paint:color2.
+ self displayLineFromX:xL y:y toX:xR y:y
+ ]
+ ]
] ifFalse:[
- x := l + (w // 2) - 1.
- yT := t + thumbLevel - 1.
- yB := t + h - thumbLevel "+ 1".
- self paint:color1.
- self displayLineFromX:x y:yT toX:x y:yB.
- self paint:color2.
- x := x + 1.
- self displayLineFromX:x y:yT toX:x y:yB.
+ x := l + (w // 2) - 1.
+ yT := t + thumbLevel - 1.
+ yB := t + h - thumbLevel "+ 1".
+ self paint:color1.
+ self displayLineFromX:x y:yT toX:x y:yB.
+ self paint:color2.
+ x := x + 1.
+ self displayLineFromX:x y:yT toX:x y:yB.
- tallyMarks > 1 ifTrue:[
- "dont draw other marks if there is not enough space"
+ tallyMarks > 1 ifTrue:[
+ "dont draw other marks if there is not enough space"
- mm := device horizontalPixelPerMillimeter rounded.
- w > (mm * (tallyMarks * 2)) ifTrue:[
- x := x - 1 - mm.
- self paint:color1.
- self displayLineFromX:x y:yT toX:x y:yB.
- x := x + 1.
- self paint:color2.
- self displayLineFromX:x y:yT toX:x y:yB.
+ mm := device horizontalPixelPerMillimeter rounded.
+ w > (mm * (tallyMarks * 2)) ifTrue:[
+ x := x - 1 - mm.
+ self paint:color1.
+ self displayLineFromX:x y:yT toX:x y:yB.
+ x := x + 1.
+ self paint:color2.
+ self displayLineFromX:x y:yT toX:x y:yB.
- x := x - 1 + mm + mm.
- self paint:color1.
- self displayLineFromX:x y:yT toX:x y:yB.
- x := x + 1.
- self paint:color2.
- self displayLineFromX:x y:yT toX:x y:yB
- ]
- ]
+ x := x - 1 + mm + mm.
+ self paint:color1.
+ self displayLineFromX:x y:yT toX:x y:yB.
+ x := x + 1.
+ self paint:color2.
+ self displayLineFromX:x y:yT toX:x y:yB
+ ]
+ ]
]
+
+ "Modified: 6.3.1996 / 17:27:43 / cg"
!
drawThumbBackgroundInX:x y:y width:w height:h
@@ -957,45 +962,51 @@
redraw thumb at its new position and, if scroll-mode is asynchronous,
the scroll action is performed"
- |pos curr limit prevOrigin newOrigin|
+ |pos curr limit prevOrigin newOrigin in|
- scrolling ifFalse: [^ self]. "should not happen"
+ scrolling ifFalse: [
+ self highlightThumbForPointerX:x y:y.
+ ^ self
+ ].
+ entered := true.
frameBeforeMove isNil ifTrue:[
- (ghostColor notNil
- or:[ghostFrameColor notNil
- or:[ghostLevel ~~ 0]]) ifTrue:[
- frameBeforeMove := thumbFrame insetBy:1@1
- ]
+ (ghostColor notNil
+ or:[ghostFrameColor notNil
+ or:[ghostLevel ~~ 0]]) ifTrue:[
+ frameBeforeMove := thumbFrame insetBy:1@1
+ ]
].
(orientation == #vertical) ifTrue:[
- curr := y.
- limit := height
+ curr := y.
+ limit := height
] ifFalse:[
- curr := x.
- limit := width
+ curr := x.
+ limit := width
].
(curr < 0) ifTrue:[ "check against limits"
- pos := 0
+ pos := 0
] ifFalse:[
- (curr > limit) ifTrue:[
- pos := limit
- ] ifFalse:[
- pos := curr
- ]
+ (curr > limit) ifTrue:[
+ pos := limit
+ ] ifFalse:[
+ pos := curr
+ ]
].
prevOrigin := self thumbOrigin.
newOrigin := self percentFromAbs:(pos - pressOffset).
prevOrigin ~= newOrigin ifTrue:[
- self thumbOrigin:newOrigin.
+ self thumbOrigin:newOrigin.
- synchronousOperation ifTrue: [
- self tellOthers.
- ]
+ synchronousOperation ifTrue: [
+ self tellOthers.
+ ]
]
+
+ "Modified: 6.3.1996 / 17:35:26 / cg"
!
buttonMultiPress:button x:x y:y
@@ -1011,27 +1022,30 @@
shown ifFalse:[^ self].
(orientation == #vertical) ifTrue:[
- curr := y.
- limit1 := thumbFrame top.
- limit2 := thumbFrame bottom
+ curr := y.
+ limit1 := thumbFrame top.
+ limit2 := thumbFrame bottom
] ifFalse:[
- curr := x.
- limit1 := thumbFrame left.
- limit2 := thumbFrame right
+ curr := x.
+ limit1 := thumbFrame left.
+ limit2 := thumbFrame right
].
(curr < limit1) ifTrue:[
- "page up/left"
- self pageUp
+ "page up/left"
+ self pageUp
] ifFalse:[
- (curr > limit2) ifTrue:[
- "page down/right"
- self pageDown
- ] ifFalse:[
- pressOffset := curr - limit1.
- scrolling := true
- ]
- ]
+ (curr > limit2) ifTrue:[
+ "page down/right"
+ self pageDown
+ ] ifFalse:[
+ pressOffset := curr - limit1.
+ scrolling := true
+ ]
+ ].
+ self highlightThumbForPointerX:x y:y
+
+ "Modified: 6.3.1996 / 17:34:01 / cg"
!
buttonRelease:button x:x y:y
@@ -1105,6 +1119,36 @@
scrolling := true
!
+highlightThumbForPointerX:x y:y
+ "if x/y is within the thumb frame, highlight it"
+
+ |in|
+
+ thumbColor ~~ thumbEnteredColor ifTrue: [
+ in := thumbFrame containsPoint:(x@y).
+ in ~~ entered ifTrue:[
+ entered := in.
+ self drawThumb
+ ].
+ ].
+
+ "Created: 6.3.1996 / 17:35:07 / cg"
+ "Modified: 6.3.1996 / 17:36:46 / cg"
+!
+
+pointerLeave:state
+ "mouse-button left view
+ redraw thumb if enteredColor ~~ thumbColor"
+
+ (entered and:[state == 0]) ifTrue: [
+ entered := false.
+ self drawThumb
+ ].
+
+ "Modified: 6.3.1996 / 17:27:12 / cg"
+ "Created: 6.3.1996 / 17:31:16 / cg"
+!
+
redraw
"redraw"
@@ -1165,6 +1209,24 @@
self thumbOrigin:(thumbOrigin - thumbHeight).
self tellOthers
+!
+
+scrollToBeginning
+ "scroll to the beginning"
+
+ self thumbOrigin:rangeStart.
+ self tellOthers
+
+ "Created: 6.3.1996 / 17:55:13 / cg"
+!
+
+scrollToEnd
+ "scroll to the end"
+
+ self thumbOrigin:rangeEnd.
+ self tellOthers
+
+ "Created: 6.3.1996 / 17:55:25 / cg"
! !
!Scroller methodsFor:'forwarding changed origin'!
@@ -1204,22 +1266,22 @@
super initStyle.
DefaultViewBackground notNil ifTrue:[
- viewBackground := DefaultViewBackground on:device.
+ viewBackground := DefaultViewBackground on:device.
].
DefaultShadowColor notNil ifTrue:[
- shadowColor := DefaultShadowColor on:device.
+ shadowColor := DefaultShadowColor on:device.
].
DefaultLightColor notNil ifTrue:[
- lightColor := DefaultLightColor on:device.
+ lightColor := DefaultLightColor on:device.
].
tallyMarks := DefaultTallyMarks.
tallyLevel := DefaultTallyLevel.
DefaultLevel ~~ level ifTrue:[
- self level:DefaultLevel.
+ self level:DefaultLevel.
].
DefaultBorderWidth ~~ borderWidth ifTrue:[
- self borderWidth:DefaultBorderWidth.
+ self borderWidth:DefaultBorderWidth.
].
thumbLevel := DefaultThumbLevel.
inset := DefaultInset.
@@ -1227,92 +1289,102 @@
thumbEdgeStyle := DefaultEdgeStyle.
DefaultGhostColor notNil ifTrue:[
- ghostColor := DefaultGhostColor on:device.
+ ghostColor := DefaultGhostColor on:device.
].
DefaultGhostFrameColor notNil ifTrue:[
- ghostFrameColor := DefaultGhostFrameColor on:device.
+ ghostFrameColor := DefaultGhostFrameColor on:device.
].
ghostLevel := DefaultGhostLevel.
DefaultThumbFrameColor notNil ifTrue:[
- thumbFrameColor := DefaultThumbFrameColor on:device.
+ thumbFrameColor := DefaultThumbFrameColor on:device.
].
DefaultThumbShadowColor notNil ifTrue:[
- thumbShadowColor := DefaultThumbShadowColor
+ thumbShadowColor := DefaultThumbShadowColor
] ifFalse:[
- thumbShadowColor := shadowColor.
+ thumbShadowColor := shadowColor.
].
DefaultThumbLightColor notNil ifTrue:[
- thumbLightColor := DefaultThumbLightColor
+ thumbLightColor := DefaultThumbLightColor
] ifFalse:[
- thumbLightColor := lightColor.
+ thumbLightColor := lightColor.
].
thumbEdgeStyle notNil ifTrue:[
- DefaultThumbHalfShadowColor notNil ifTrue:[
- thumbHalfShadowColor := DefaultThumbHalfShadowColor
- ].
- DefaultThumbHalfLightColor notNil ifTrue:[
- thumbHalfLightColor := DefaultThumbHalfLightColor
- ].
+ DefaultThumbHalfShadowColor notNil ifTrue:[
+ thumbHalfShadowColor := DefaultThumbHalfShadowColor
+ ].
+ DefaultThumbHalfLightColor notNil ifTrue:[
+ thumbHalfLightColor := DefaultThumbHalfLightColor
+ ].
].
device hasGreyscales ifFalse:[
- thumbEdgeStyle notNil ifTrue:[
- thumbHalfShadowColor := Color darkGrey.
- thumbHalfLightColor := White
- ].
+ thumbEdgeStyle notNil ifTrue:[
+ thumbHalfShadowColor := Color darkGrey.
+ thumbHalfLightColor := White
+ ].
- thumbShadowColor := Black.
+ thumbShadowColor := Black.
"/ thumbLightColor := White.
- styleSheet name = #motif ifTrue:[
- DefaultThumbColor isNil ifTrue:[
- thumbColor := White .
- ].
- ]
+ styleSheet name = #motif ifTrue:[
+ DefaultThumbColor isNil ifTrue:[
+ thumbColor := White .
+ ].
+ ]
].
DefaultThumbColor notNil ifTrue:[
- thumbColor := DefaultThumbColor on:device
+ thumbColor := DefaultThumbColor on:device
] ifFalse:[
- thumbColor := White.
- styleSheet name ~= #normal ifTrue:[
- device hasGreyscales ifFalse:[
- thumbColor := Color grey
- ].
- ].
+ thumbColor := White.
+ styleSheet name ~= #normal ifTrue:[
+ device hasGreyscales ifFalse:[
+ thumbColor := Color grey
+ ].
+ ].
].
thumbColor := thumbColor on:device.
thumbShadowColor notNil ifTrue:[
- thumbShadowColor := thumbShadowColor on:device.
+ thumbShadowColor := thumbShadowColor on:device.
].
thumbLightColor notNil ifTrue:[
- thumbLightColor := thumbLightColor on:device.
+ thumbLightColor := thumbLightColor on:device.
].
thumbHalfShadowColor notNil ifTrue:[
- thumbHalfShadowColor := thumbHalfShadowColor on:device.
+ thumbHalfShadowColor := thumbHalfShadowColor on:device.
].
thumbHalfLightColor notNil ifTrue:[
- thumbHalfLightColor := thumbHalfLightColor on:device.
+ thumbHalfLightColor := thumbHalfLightColor on:device.
].
thumbEdgeStyle notNil ifTrue:[
- thumbHalfShadowColor isNil ifTrue:[
- thumbHalfShadowColor := thumbShadowColor lightened on:device
- ]
+ thumbHalfShadowColor isNil ifTrue:[
+ thumbHalfShadowColor := thumbShadowColor lightened on:device
+ ]
+ ].
+
+ DefaultThumbEnteredColor notNil ifTrue:[
+ thumbEnteredColor := DefaultThumbEnteredColor on:device.
+ self enableMotionEvents.
+ self enableEnterLeaveEvents.
+ ] ifFalse:[
+ thumbEnteredColor := thumbColor.
].
styleSheet name = #next ifTrue:[
- shadowForm := self class handleShadowFormOn:device.
- lightForm := self class handleLightFormOn:device
+ shadowForm := self class handleShadowFormOn:device.
+ lightForm := self class handleLightFormOn:device
] ifFalse:[
- shadowForm := lightForm := nil
+ shadowForm := lightForm := nil
].
drawableId notNil ifTrue:[
- self computeThumbFrame
+ self computeThumbFrame
]
+
+ "Modified: 6.3.1996 / 17:31:35 / cg"
!
initialize
@@ -1323,6 +1395,7 @@
orientation := #vertical.
scrolling := false.
+ entered := false.
synchronousOperation := true.
thumbOrigin := 0.
@@ -1335,6 +1408,8 @@
"/ inset := 1.
"/ self computeThumbFrame
+
+ "Modified: 6.3.1996 / 17:25:59 / cg"
!
realize
@@ -1607,5 +1682,5 @@
!Scroller class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.40 1996-03-01 21:42:41 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.41 1996-03-06 17:03:26 cg Exp $'
! !