Scroller.st
changeset 5218 06e5b79c3f3f
parent 5101 0795f1b2c7e5
child 5420 40136151fb83
--- a/Scroller.st	Mon Dec 08 18:31:05 2014 +0100
+++ b/Scroller.st	Mon Dec 08 23:13:13 2014 +0100
@@ -35,7 +35,8 @@
 		DefaultThumbActiveLevel SnapBackDistance DefaultMiddleButtonJump
 		NewCursors DefaultThumbImage HandleImage DefaultHScrollerHeight
 		DefaultVScrollerWidth DefaultStopPagerAtThumb DefaultTallyInset
-		MinThumbSize DefaultTallyDistance'
+		MinThumbSize DefaultTallyDistance DefaultVerticalThumbFrameImage
+		DefaultHorizontalThumbFrameImage'
 	poolDictionaries:''
 	category:'Views-Interactors'
 !
@@ -367,7 +368,8 @@
                        #'scroller.newCursors' 
                        #'scroller.thumbImage' #'scroller.handleImage'
                        #'scroller.vScrollerWidth' #'scroller.hScrollerHeight'
-                       #'scroller.stopPagerAtThumb' 
+                       #'scroller.stopPagerAtThumb'
+                       #'scroller.verticalThumbFrameImage' #'scroller.horizontalThumbFrameImage' 
                      )>
 
     DefaultViewBackground := StyleSheet colorAt:#'scroller.viewBackground'.
@@ -404,6 +406,8 @@
     NewCursors := StyleSheet at:#'scroller.newCursors' default:true.
     DefaultThumbImage := StyleSheet at:#'scroller.thumbImage'.
     HandleImage := StyleSheet at:#'scroller.handleImage'.
+    DefaultVerticalThumbFrameImage := StyleSheet at:#'scroller.verticalThumbFrameImage'.
+    DefaultHorizontalThumbFrameImage := StyleSheet at:#'scroller.horizontalThumbFrameImage'.
 
     DefaultVScrollerWidth  := StyleSheet at:#'scroller.vScrollerWidth' default:nil.
     DefaultHScrollerHeight := StyleSheet at:#'scroller.hScrollerHeight' default:nil.
@@ -1223,7 +1227,7 @@
     |handleX handleY l t lvl
      w "{ Class: SmallInteger }"
      h "{ Class: SmallInteger }"
-     clr clr2 xpStyle vistaStyle n|
+     clr clr2 xpStyle vistaStyle n frameImageOrNil frameImage|
 
     (thumbHeight >= 100) ifTrue:[^ self].
     thumbFrame isNil ifTrue:[^ self].
@@ -1238,66 +1242,66 @@
 
     clr := entered ifTrue:[thumbEnteredColor] ifFalse:[thumbColor].
     (scrolling and:[thumbActiveColor notNil]) ifTrue:[clr := thumbActiveColor].
-
-    (styleSheet at:#'scroller.vista3DStyle' default:false) ifTrue:[
-        "/ 243   242  240  236  234   233   215  211  207   205     200   192 206
-        (orientation == #vertical) ifTrue:[
-            n := w
-        ] ifFalse:[
-            n := h
-        ].
-        1 to:n-1 do:[:i |
-            |m|
-
-            i == (n-1) ifTrue:[
-                m := 0.4.
+    clr notNil ifTrue:[
+        (styleSheet at:#'scroller.vista3DStyle' default:false) ifTrue:[
+            "/ 243   242  240  236  234   233   215  211  207   205     200   192 206
+            (orientation == #vertical) ifTrue:[
+                n := w
             ] ifFalse:[
-                i <= (n//2) ifTrue:[
-                    i <= (n//4) ifTrue:[
-                        m := 3.
+                n := h
+            ].
+            1 to:n-1 do:[:i |
+                |m|
+
+                i == (n-1) ifTrue:[
+                    m := 0.4.
+                ] ifFalse:[
+                    i <= (n//2) ifTrue:[
+                        i <= (n//4) ifTrue:[
+                            m := 3.
+                        ] ifFalse:[
+                            i <= (n//3) ifTrue:[
+                                m := 2.5.
+                            ] ifFalse:[
+                                m := 2.
+                            ].
+                        ].
                     ] ifFalse:[
-                        i <= (n//3) ifTrue:[
-                            m := 2.5.
+                        i > (n*3//4) ifTrue:[
+                            i > (n*4//5) ifTrue:[
+                                m := 0.
+                            ] ifFalse:[
+                                m := 0.2.
+                            ]
                         ] ifFalse:[
-                            m := 2.
-                        ].
-                    ].
-                ] ifFalse:[
-                    i > (n*3//4) ifTrue:[
-                        i > (n*4//5) ifTrue:[
-                            m := 0.
-                        ] ifFalse:[
-                            m := 0.2.
-                        ]
-                    ] ifFalse:[
-                        i > (n*2//3) ifTrue:[
-                            m := 0.4
-                        ] ifFalse:[
-                            m := 0.8.
+                            i > (n*2//3) ifTrue:[
+                                m := 0.4
+                            ] ifFalse:[
+                                m := 0.8.
+                            ].
                         ].
                     ].
                 ].
+                self paint:(Color white mixed:m with:clr).
+                (orientation == #vertical) ifTrue:[
+                    self displayLineFromX:(l+i-1) y:t+1 toX:(l+i-1) y:(t+h-2)
+                ] ifFalse:[
+                    self displayLineFromX:(l+1) y:(t+i-1) toX:(l+w-2) y:(t+i-1)
+                ].
             ].
-            self paint:(Color white mixed:m with:clr).
-            (orientation == #vertical) ifTrue:[
-                self displayLineFromX:(l+i-1) y:t+1 toX:(l+i-1) y:(t+h-2)
+        ] ifFalse:[
+            self paint:clr.
+            (xpStyle and:[self isMiniScroller not]) ifTrue:[
+                (orientation == #vertical) ifTrue:[
+                    self fillRectangleX:l y:t+1 width:w-2 height:h-4.
+                ] ifFalse:[
+                    self fillRectangleX:l+1 y:t width:w-4 height:h-2.
+                ]
             ] ifFalse:[
-                self displayLineFromX:(l+1) y:(t+i-1) toX:(l+w-2) y:(t+i-1)
+                self fillRectangleX:l y:t width:w height:h.
             ].
         ].
-    ] ifFalse:[
-        self paint:clr.
-        (xpStyle and:[self isMiniScroller not]) ifTrue:[
-            (orientation == #vertical) ifTrue:[
-                self fillRectangleX:l y:t+1 width:w-2 height:h-4.
-            ] ifFalse:[
-                self fillRectangleX:l+1 y:t width:w-4 height:h-2.
-            ]
-        ] ifFalse:[
-            self fillRectangleX:l y:t width:w height:h.
-        ].
     ].
-
     lvl := thumbLevel.
     scrolling ifTrue:[
         lvl := thumbActiveLevel
@@ -1309,6 +1313,13 @@
                     halfShadow:thumbHalfShadowColor halfLight:thumbHalfLightColor
                     style:thumbEdgeStyle.
     ].
+    frameImageOrNil := (orientation == #vertical) 
+                        ifTrue:[ DefaultVerticalThumbFrameImage ]
+                        ifFalse:[ DefaultHorizontalThumbFrameImage ].
+    frameImageOrNil notNil ifTrue:[
+        frameImage  := frameImageOrNil magnifiedTo:(w @ h).
+        frameImage displayOn:self x:l y:t
+    ].
 
     self isMiniScroller ifTrue:[^ self].
 
@@ -2238,15 +2249,19 @@
     DefaultThumbColor notNil ifTrue:[
         thumbColor := DefaultThumbColor onDevice:graphicsDevice
     ] ifFalse:[
-        thumbColor := self whiteColor.
-        nm ~= #normal ifTrue:[
-            graphicsDevice hasGrayscales ifFalse:[
-                thumbColor := Color gray
+        nm ~= #napkin ifTrue:[
+            thumbColor := self whiteColor.
+            nm ~= #normal ifTrue:[
+                graphicsDevice hasGrayscales ifFalse:[
+                    thumbColor := Color gray
+                ].
             ].
         ].
     ].
-
-    thumbColor := thumbColor onDevice:graphicsDevice.
+    thumbColor notNil ifTrue:[  
+        thumbColor := thumbColor onDevice:graphicsDevice.
+    ].
+
     thumbShadowColor notNil ifTrue:[
         thumbShadowColor := thumbShadowColor onDevice:graphicsDevice.
     ].
@@ -2757,10 +2772,10 @@
 !Scroller class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.207 2014-07-08 21:42:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.208 2014-12-08 22:13:13 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.207 2014-07-08 21:42:06 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Scroller.st,v 1.208 2014-12-08 22:13:13 cg Exp $'
 ! !