Add #scrollUpPixel: and #scrollDownPixel: (needed for TableView).
authorah
Wed, 31 Jul 1996 17:18:35 +0200
changeset 808 0fb219efdfa2
parent 807 3f9980053be4
child 809 e8c93a70bfd1
Add #scrollUpPixel: and #scrollDownPixel: (needed for TableView).
ListView.st
--- a/ListView.st	Fri Jul 26 18:11:47 1996 +0200
+++ b/ListView.st	Wed Jul 31 17:18:35 1996 +0200
@@ -10,6 +10,8 @@
  hereby transferred.
 "
 
+'From Smalltalk/X, Version:2.10.9 on 31-jul-1996 at 17:14:48'                   !
+
 View subclass:#ListView
 	instanceVariableNames:'list firstLineShown leftOffset nFullLinesShown nLinesShown
 		fgColor bgColor partialLines leftMargin topMargin textStartLeft
@@ -2538,6 +2540,78 @@
     "Modified: 26.5.1996 / 15:59:29 / cg"
 !
 
+scrollDownPixels:pix
+    "change origin to scroll down some pixels 
+     (towards the bottom of the text)
+     THIS WILL VANISH!!"
+
+    |w     "{ Class:SmallInteger }"
+     h     "{ Class:SmallInteger }"
+     n     "{ Class:SmallInteger }"
+     m2    "{ Class:SmallInteger }"
+     count "{ Class:SmallInteger }"
+     y0    "{ Class:SmallInteger }"
+     y1    "{ Class:SmallInteger }"
+     nLines nPixel sz sH partialCopy|
+
+    nLines := pix / fontHeight.
+    count := nLines.
+    sz := self size.
+    (firstLineShown + nLines + nFullLinesShown > sz) ifTrue:[
+        count := sz - firstLineShown - nFullLinesShown + 1
+    ].
+    count <= 0 ifTrue:[^ self].
+
+    self originWillChange.
+    nPixel := fontHeight * count.
+
+    shown ifFalse:[
+        firstLineShown := firstLineShown + count.
+        viewOrigin := viewOrigin x @ (viewOrigin y + nPixel).
+    ] ifTrue:[
+        (count >= nLinesShown) ifTrue:[
+            firstLineShown := firstLineShown + count.
+            viewOrigin := viewOrigin x @ (viewOrigin y + nPixel).
+            self redrawFromVisibleLine:1 to:nLinesShown.
+        ] ifFalse:[
+            m2 := margin * 2.
+            w := self widthForScrollBetween:firstLineShown 
+                                        and:(firstLineShown + nLinesShown).
+            w := w + leftMargin.
+
+            sH := lineSpacing // 2.    
+            y0 := textStartTop - sH.
+            h := nPixel + y0.
+            n := height - h + (lineSpacing " //2 ").   
+
+            y1 := h + n - 1.
+            y1 >= (height - margin) ifTrue:[
+                partialCopy := true.
+                y1 := height - margin - 1
+            ].
+
+            self catchExpose.
+            self copyFrom:self x:margin y:h
+                             toX:margin y:y0
+                           width:w height:(y1 - h + 1).
+
+            firstLineShown := firstLineShown + count.
+            viewOrigin := viewOrigin x @ (viewOrigin y + nPixel).
+
+            (partialCopy == true and:[lineSpacing ~~ 0]) ifTrue:[
+                self paint:bgColor.
+                self fillRectangleX:margin y:(y0 + (y1 - h + 1))
+                              width:w height:sH.
+            ].
+            self redrawFromVisibleLine:(nFullLinesShown - count + 1) to:nLinesShown.
+            self waitForExpose.
+        ].
+    ].
+    self originChanged:(0 @ nPixel).
+
+    "Modified: 26.5.1996 / 15:59:29 / cg"
+!
+
 scrollHorizontalTo:aPixelOffset
     "change origin to make aPixelOffset be the left col"
 
@@ -2740,6 +2814,54 @@
     "Modified: 26.5.1996 / 15:59:34 / cg"
 !
 
+scrollUpPixels:pix
+    "change origin to scroll up some pixels 
+     (towards the top of the text)
+    THIS WILL VANISH!!"
+
+    |w      "{ Class:SmallInteger }"
+     h      "{ Class:SmallInteger }"
+     count  "{ Class:SmallInteger }"
+     nLines nPixel|
+
+    nLines := pix / fontHeight.
+
+    count := nLines.
+    count >= firstLineShown ifTrue:[
+        count := firstLineShown - 1
+    ].
+    (count == 0) ifTrue:[^ self].
+
+    self originWillChange.
+    nPixel := fontHeight * count.
+    shown ifFalse:[
+        firstLineShown := firstLineShown - count.
+        viewOrigin := viewOrigin x @ (viewOrigin y - nPixel).
+    ] ifTrue:[
+        (count >= nLinesShown) ifTrue:[
+            firstLineShown := firstLineShown - count.
+            viewOrigin := viewOrigin x @ (viewOrigin y - nPixel).
+            self redrawFromVisibleLine:1 to:nLinesShown.
+        ] ifFalse:[
+            w := self widthForScrollBetween:firstLineShown
+                                        and:(firstLineShown + nLinesShown).
+            w := w + leftMargin.
+            h := nPixel + margin.
+            self catchExpose.
+            self copyFrom:self x:margin y:margin 
+                             toX:margin y:h
+                           width:w height:(height - h).
+            firstLineShown := firstLineShown - count.
+            viewOrigin := viewOrigin x @ (viewOrigin y - nPixel).
+            self redrawFromVisibleLine:1 to:count.
+            self waitForExpose.
+        ].
+    ].
+    self originChanged:(0 @ (nPixel negated)).
+
+    "Modified: 26.5.1996 / 15:59:34 / cg"
+!
+
 scrollVerticalToPercent:percent
     "scroll to a position given in percent of total"
 
@@ -3263,5 +3385,5 @@
 !ListView  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.98 1996-07-19 18:53:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.99 1996-07-31 15:18:35 ah Exp $'
 ! !