Now sync origin of views even when searching or selecting.
authorStefan Vogel <sv@exept.de>
Thu, 25 Sep 1997 13:12:39 +0200
changeset 537 cd6bc3d8f9f6
parent 536 918612416568
child 538 97a7619024fe
Now sync origin of views even when searching or selecting.
SyncMCTxtV.st
SyncedMultiColumnTextView.st
--- a/SyncMCTxtV.st	Wed Sep 24 14:23:49 1997 +0200
+++ b/SyncMCTxtV.st	Thu Sep 25 13:12:39 1997 +0200
@@ -11,7 +11,7 @@
 "
 
 SimpleView subclass:#SyncedMultiColumnTextView
-	instanceVariableNames:'textViews'
+	instanceVariableNames:'textViews scrollLock'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Text'
@@ -78,10 +78,30 @@
     "/ a chance to update
     "/
     something == #sizeOfContents ifTrue:[
-	self changed:something
+        self changed:something
+    ].
+
+    "/
+    "/ if any of my views' changes the origin its contents,
+    "/ I have logically changed my origin -> give the scrollbar
+    "/ a chance to update and sync my views.
+    "/
+    something == #originOfContents ifTrue:[
+        "/ beware of recursive calls
+        scrollLock == true ifFalse:[
+            scrollLock := true.
+            textViews do:[:v|
+                v ~~ changedObject ifTrue:[
+                    v scrollTo:changedObject viewOrigin.
+                ].
+            ].
+            self changed:something.
+            scrollLock := false.
+        ].
     ].
 
     "Created: 24.11.1995 / 11:11:22 / cg"
+    "Modified: 25.9.1997 / 11:46:32 / stefan"
 ! !
 
 !SyncedMultiColumnTextView methodsFor:'initialization'!
@@ -168,9 +188,10 @@
 !
 
 scrollDown:nLines
-    textViews do:[:thisView | thisView scrollDown:nLines].
+    textViews first scrollDown:nLines.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
+    "Modified: 25.9.1997 / 11:39:59 / stefan"
 !
 
 scrollHorizontalToPercent:p
@@ -178,62 +199,62 @@
      of my subvies, scroll the view containing the widest first,
      and take that scroll-offset for the others."
 
-    |master max x|
+    |master max|
 
     max := 0.
     textViews do:[:thisView |
-	|wThis|
+        |wThis|
 
-	(wThis := thisView widthOfContents) > max ifTrue:[
-	    max := wThis.
-	    master := thisView
-	]
+        (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:14:41 / cg"
     "Modified: 24.11.1995 / 14:22:27 / cg"
+    "Modified: 25.9.1997 / 11:42:46 / stefan"
 !
 
 scrollLeft
-    textViews do:[:thisView | thisView scrollLeft].
+    textViews first scrollLeft.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:45 / cg"
+    "Modified: 25.9.1997 / 11:41:04 / stefan"
 !
 
 scrollLeft:nPixels
-    textViews do:[:thisView | thisView scrollLeft:nPixels].
+    textViews first scrollLeft:nPixels.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:49 / cg"
+    "Modified: 25.9.1997 / 11:41:17 / stefan"
 !
 
 scrollRight
-    textViews do:[:thisView | thisView scrollRight].
+    textViews first scrollRight.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:39 / cg"
+    "Modified: 25.9.1997 / 11:41:30 / stefan"
 !
 
 scrollRight:nPixels
-    textViews do:[:thisView | thisView scrollRight:nPixels].
+    textViews first scrollRight:nPixels.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:27 / cg"
+    "Modified: 25.9.1997 / 11:41:43 / stefan"
 !
 
 scrollToLine:lineNr
-    textViews do:[:thisView | thisView scrollToLine:lineNr].
+    textViews first scrollToLine:lineNr.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:07 / cg"
+    "Modified: 25.9.1997 / 11:41:56 / stefan"
 !
 
 scrollUp
@@ -243,10 +264,11 @@
 !
 
 scrollUp:nLines
-    textViews do:[:thisView | thisView scrollUp:nLines].
+    textViews first scrollUp:nLines.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:14:51 / cg"
+    "Modified: 25.9.1997 / 11:42:10 / stefan"
 !
 
 scrollVerticalToPercent:p
@@ -254,33 +276,27 @@
      of my subvies, scroll the view containing the longest first,
      and take that scroll-offset for the others."
 
-    |master max y|
+    |master max|
 
     max := 0.
     textViews do:[:thisView |
-	|hThis|
+        |hThis|
 
-	(hThis := thisView heightOfContents) > max ifTrue:[
-	    max := hThis.
-	    master := thisView
-	]
+        (hThis := thisView heightOfContents) > max ifTrue:[
+            max := hThis.
+            master := thisView
+        ]
     ].
 
     master scrollVerticalToPercent:p.
-    y := master firstLineShown.
-
-    textViews do:[:v |
-	v ~~ master ifTrue:[
-	    v scrollToLine:y.
-	]
-    ]
 
     "Created: 20.11.1995 / 13:14:41 / cg"
     "Modified: 24.11.1995 / 14:22:19 / cg"
+    "Modified: 25.9.1997 / 11:42:34 / stefan"
 ! !
 
 !SyncedMultiColumnTextView class methodsFor:'documentation'!
 
 version
-^ '$Header: /cvs/stx/stx/libwidg2/Attic/SyncMCTxtV.st,v 1.5 1996-05-08 15:00:54 cg Exp $'
+^ '$Header: /cvs/stx/stx/libwidg2/Attic/SyncMCTxtV.st,v 1.6 1997-09-25 11:12:39 stefan Exp $'
 ! !
--- a/SyncedMultiColumnTextView.st	Wed Sep 24 14:23:49 1997 +0200
+++ b/SyncedMultiColumnTextView.st	Thu Sep 25 13:12:39 1997 +0200
@@ -11,7 +11,7 @@
 "
 
 SimpleView subclass:#SyncedMultiColumnTextView
-	instanceVariableNames:'textViews'
+	instanceVariableNames:'textViews scrollLock'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Text'
@@ -78,10 +78,30 @@
     "/ a chance to update
     "/
     something == #sizeOfContents ifTrue:[
-	self changed:something
+        self changed:something
+    ].
+
+    "/
+    "/ if any of my views' changes the origin its contents,
+    "/ I have logically changed my origin -> give the scrollbar
+    "/ a chance to update and sync my views.
+    "/
+    something == #originOfContents ifTrue:[
+        "/ beware of recursive calls
+        scrollLock == true ifFalse:[
+            scrollLock := true.
+            textViews do:[:v|
+                v ~~ changedObject ifTrue:[
+                    v scrollTo:changedObject viewOrigin.
+                ].
+            ].
+            self changed:something.
+            scrollLock := false.
+        ].
     ].
 
     "Created: 24.11.1995 / 11:11:22 / cg"
+    "Modified: 25.9.1997 / 11:46:32 / stefan"
 ! !
 
 !SyncedMultiColumnTextView methodsFor:'initialization'!
@@ -168,9 +188,10 @@
 !
 
 scrollDown:nLines
-    textViews do:[:thisView | thisView scrollDown:nLines].
+    textViews first scrollDown:nLines.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
+    "Modified: 25.9.1997 / 11:39:59 / stefan"
 !
 
 scrollHorizontalToPercent:p
@@ -178,62 +199,62 @@
      of my subvies, scroll the view containing the widest first,
      and take that scroll-offset for the others."
 
-    |master max x|
+    |master max|
 
     max := 0.
     textViews do:[:thisView |
-	|wThis|
+        |wThis|
 
-	(wThis := thisView widthOfContents) > max ifTrue:[
-	    max := wThis.
-	    master := thisView
-	]
+        (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:14:41 / cg"
     "Modified: 24.11.1995 / 14:22:27 / cg"
+    "Modified: 25.9.1997 / 11:42:46 / stefan"
 !
 
 scrollLeft
-    textViews do:[:thisView | thisView scrollLeft].
+    textViews first scrollLeft.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:45 / cg"
+    "Modified: 25.9.1997 / 11:41:04 / stefan"
 !
 
 scrollLeft:nPixels
-    textViews do:[:thisView | thisView scrollLeft:nPixels].
+    textViews first scrollLeft:nPixels.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:49 / cg"
+    "Modified: 25.9.1997 / 11:41:17 / stefan"
 !
 
 scrollRight
-    textViews do:[:thisView | thisView scrollRight].
+    textViews first scrollRight.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:39 / cg"
+    "Modified: 25.9.1997 / 11:41:30 / stefan"
 !
 
 scrollRight:nPixels
-    textViews do:[:thisView | thisView scrollRight:nPixels].
+    textViews first scrollRight:nPixels.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:27 / cg"
+    "Modified: 25.9.1997 / 11:41:43 / stefan"
 !
 
 scrollToLine:lineNr
-    textViews do:[:thisView | thisView scrollToLine:lineNr].
+    textViews first scrollToLine:lineNr.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:15:07 / cg"
+    "Modified: 25.9.1997 / 11:41:56 / stefan"
 !
 
 scrollUp
@@ -243,10 +264,11 @@
 !
 
 scrollUp:nLines
-    textViews do:[:thisView | thisView scrollUp:nLines].
+    textViews first scrollUp:nLines.
 
     "Created: 20.11.1995 / 13:09:40 / cg"
     "Modified: 20.11.1995 / 13:14:51 / cg"
+    "Modified: 25.9.1997 / 11:42:10 / stefan"
 !
 
 scrollVerticalToPercent:p
@@ -254,33 +276,27 @@
      of my subvies, scroll the view containing the longest first,
      and take that scroll-offset for the others."
 
-    |master max y|
+    |master max|
 
     max := 0.
     textViews do:[:thisView |
-	|hThis|
+        |hThis|
 
-	(hThis := thisView heightOfContents) > max ifTrue:[
-	    max := hThis.
-	    master := thisView
-	]
+        (hThis := thisView heightOfContents) > max ifTrue:[
+            max := hThis.
+            master := thisView
+        ]
     ].
 
     master scrollVerticalToPercent:p.
-    y := master firstLineShown.
-
-    textViews do:[:v |
-	v ~~ master ifTrue:[
-	    v scrollToLine:y.
-	]
-    ]
 
     "Created: 20.11.1995 / 13:14:41 / cg"
     "Modified: 24.11.1995 / 14:22:19 / cg"
+    "Modified: 25.9.1997 / 11:42:34 / stefan"
 ! !
 
 !SyncedMultiColumnTextView class methodsFor:'documentation'!
 
 version
-^ '$Header: /cvs/stx/stx/libwidg2/SyncedMultiColumnTextView.st,v 1.5 1996-05-08 15:00:54 cg Exp $'
+^ '$Header: /cvs/stx/stx/libwidg2/SyncedMultiColumnTextView.st,v 1.6 1997-09-25 11:12:39 stefan Exp $'
 ! !