DiffTextView.st
changeset 13793 bbc2c030ce04
parent 13786 715593f8ad46
child 13954 2f695adffde6
--- a/DiffTextView.st	Wed Feb 05 11:02:29 2014 +0100
+++ b/DiffTextView.st	Wed Feb 05 14:29:29 2014 +0100
@@ -20,6 +20,13 @@
 	category:'Views-Text'
 !
 
+AbstractBackground subclass:#DiffTextScrollerBackground
+	instanceVariableNames:'diffView'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:DiffTextView
+!
+
 !DiffTextView class methodsFor:'documentation'!
 
 copyright
@@ -587,51 +594,77 @@
     (container := self container) isScrollWrapper ifTrue:[
         (vScroller := container verticalScrollBar) notNil ifTrue:[
             (thumb := vScroller thumb) notNil ifTrue:[
-                thumb 
-                    backgroundDrawHook:[:x :y :w :h |
-                        |overAllHeight|
-
-                        overAllHeight := textViews first numberOfLines.
-                        1 to:overAllHeight do:[:lineNr |
-                            |l1 l2 isDiff yThumb clr e|
-
-                            yThumb := (thumb height * (lineNr / overAllHeight)) rounded.
-                            (yThumb >= y and:[yThumb <= (y+h)]) ifTrue:[
-                                l1 := textViews first listAt:lineNr.
-                                l2 := textViews second listAt:lineNr.
-                                (l1 notNil and:[l1 isText]) ifTrue:[
-                                    e := l1 emphasis
-                                ] ifFalse:[
-                                    (l2 notNil and:[l2 isText ]) ifTrue:[
-                                        e := l2 emphasis
-                                    ]
-                                ].
-                                e size > 0 ifTrue:[
-                                    |el|
-
-                                    el := e detect:[:el | (Text extractEmphasis:#backgroundColor from:el) notNil] ifNone:nil.
-                                    el notNil ifTrue:[
-                                        clr := Text extractEmphasis:#backgroundColor from:el.
-                                        (clr brightness > 0.5) ifTrue:[ clr := clr darkened ].
-                                        thumb paint:clr.
-                                        thumb displayLineFromX:1 y:yThumb toX:thumb width-2 y:yThumb.
-                                    ].
-                                ].
-                            ].
-                        ]
-                    ]
+                thumb viewBackground:(DiffTextScrollerBackground new diffView:self).
             ]
         ]
     ].
 ! !
 
+!DiffTextView::DiffTextScrollerBackground methodsFor:'accessing'!
+
+diffView:something
+    diffView := something.
+! !
+
+!DiffTextView::DiffTextScrollerBackground methodsFor:'drawing'!
+
+fillRectangleX:x y:y width:w height:h in:aScroller
+    |leftTextView rightTextView overAllHeight|
+
+    leftTextView := diffView textViews first.
+    rightTextView := diffView textViews second.
+
+    overAllHeight := leftTextView numberOfLines.
+    1 to:overAllHeight do:[:lineNr |
+        |l1 l2 isDiff yThumb clr e|
+
+        yThumb := (aScroller height * (lineNr / overAllHeight)) rounded.
+        (yThumb >= y and:[yThumb <= (y+h)]) ifTrue:[
+            l1 := leftTextView listAt:lineNr.
+            l2 := rightTextView listAt:lineNr.
+            (l1 notNil and:[l1 isText]) ifTrue:[
+                e := l1 emphasis
+            ] ifFalse:[
+                (l2 notNil and:[l2 isText ]) ifTrue:[
+                    e := l2 emphasis
+                ]
+            ].
+            e size > 0 ifTrue:[
+                |el|
+
+                el := e detect:[:el | (Text extractEmphasis:#backgroundColor from:el) notNil] ifNone:nil.
+                el notNil ifTrue:[
+                    clr := Text extractEmphasis:#backgroundColor from:el.
+                    (clr brightness > 0.5) ifTrue:[ clr := clr darkened ].
+                    aScroller paint:clr.
+                    aScroller displayLineFromX:1 y:yThumb toX:aScroller width-2 y:yThumb.
+                ].
+            ].
+        ].
+    ]
+! !
+
+!DiffTextView::DiffTextScrollerBackground methodsFor:'ignored conversion'!
+
+asFormOn:aDevice
+    "superclass AbstractBackground says that I am responsible to implement this method"
+
+    ^ self 
+!
+
+onDevice:aDevice
+    "superclass AbstractBackground says that I am responsible to implement this method"
+
+    ^ self 
+! !
+
 !DiffTextView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.61 2014-01-26 14:10:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.62 2014-02-05 13:29:29 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.61 2014-01-26 14:10:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/DiffTextView.st,v 1.62 2014-02-05 13:29:29 cg Exp $'
 ! !