SyncedMultiColumnTextView.st
changeset 102 f85d1c7ca56f
parent 101 85422b262e51
child 158 431e38dfc5ab
--- a/SyncedMultiColumnTextView.st	Fri Nov 24 11:29:44 1995 +0100
+++ b/SyncedMultiColumnTextView.st	Fri Nov 24 14:35:33 1995 +0100
@@ -45,12 +45,12 @@
     Usually, it does not make much sense, to put totally different
     or unrelated texts into this kind of view.
 
-    See concrete examples as TwoColumnTextView, DiffTextView etc.
+    See concrete examples in subclasses: TwoColumnTextView, DiffTextView etc.
 "
 !
 
 version
-^ '$Header: /cvs/stx/stx/libwidg2/SyncedMultiColumnTextView.st,v 1.2 1995-11-24 10:29:44 cg Exp $'
+^ '$Header: /cvs/stx/stx/libwidg2/SyncedMultiColumnTextView.st,v 1.3 1995-11-24 13:35:33 cg Exp $'
 ! !
 
 !SyncedMultiColumnTextView methodsFor:'initialization'!
@@ -156,12 +156,31 @@
 !
 
 scrollHorizontalToPercent:p
-    |v1|
+    "since the percentage given is based on the widest text
+     of my subvies, scroll the view containing the widest first,
+     and take that scroll-offset for the others."
+
+    |master max x|
+
+    max := 0.
+    textViews do:[:thisView |
+	|wThis|
 
-    (v1 := textViews at:1) scrollHorizontalToPercent:p.
-    textViews from:2 to:(textViews size) do:[:thisView | thisView scrollHorizontalTo:v1 xOriginOfContents]
+	(wThis := thisView widthOfContents) > max ifTrue:[
+	    max := wThis.
+	    master := thisView
+	]
+    ].
+    master scrollHorizontalToPercent:p.
+    x := master viewOrigin x.
+    textViews do:[:v |
+	v ~~ master ifTrue:[
+	    v scrollHorizontalTo:x.
+	]
+    ]
 
-    "Created: 20.11.1995 / 13:12:16 / cg"
+    "Created: 20.11.1995 / 13:14:41 / cg"
+    "Modified: 24.11.1995 / 14:22:27 / cg"
 !
 
 scrollLeft
@@ -213,23 +232,32 @@
 !
 
 scrollVerticalToPercent:p
-    |master max|
+    "since the percentage given is based on the longest text
+     of my subvies, scroll the view containing the longest first,
+     and take that scroll-offset for the others."
+
+    |master max y|
 
     max := 0.
     textViews do:[:thisView |
-	thisView heightOfContents > max ifTrue:[
-	    max := thisView heightOfContents.
+	|hThis|
+
+	(hThis := thisView heightOfContents) > max ifTrue:[
+	    max := hThis.
 	    master := thisView
 	]
     ].
+
+    master scrollVerticalToPercent:p.
+    y := master firstLineShown.
+
     textViews do:[:v |
-	v == master ifTrue:[
-	    master scrollVerticalToPercent:p.
-	] ifFalse:[
-	    v scrollToLine:master firstLineShown.
+	v ~~ master ifTrue:[
+	    v scrollToLine:y.
 	]
     ]
 
     "Created: 20.11.1995 / 13:14:41 / cg"
+    "Modified: 24.11.1995 / 14:22:19 / cg"
 ! !