"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
'From Smalltalk/X, Version:2.10.8 on 20-nov-1995 at 14:11:21' !
SimpleView subclass:#SyncedMultiColumnTextView
instanceVariableNames:'textViews'
classVariableNames:''
poolDictionaries:''
category:'Views-Text'
!
!SyncedMultiColumnTextView class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1995 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
abstract superclass for multi-col textviews.
Scrolling is synced, by always scrolling all views.
This type of view is especially useful to show diff-lists,
code-versions, or other one-by-one viewable texts.
Usually, it does not make much sense, to put totally different
or unrelated texts into this kind of view.
See concrete examples in subclasses: TwoColumnTextView, DiffTextView etc.
"
!
version
^ '$Header: /cvs/stx/stx/libwidg2/Attic/SyncMCTxtV.st,v 1.3 1995-11-24 13:35:33 cg Exp $'
! !
!SyncedMultiColumnTextView methodsFor:'initialization'!
initialize
|n wEach org crn|
super initialize.
n := self class numberOfViews.
textViews := Array new:n.
wEach := (1 / n) asFloat.
org := 0.0.
1 to:n do:[:i |
|textView|
i == n ifTrue:[
crn := 1.0
] ifFalse:[
crn := org + wEach
].
textView:= TextView
origin:org @ 0.0
corner:crn @ 1.0
in:self.
textView borderWidth:1.
textView level:0.
textView addDependent:self.
textViews at:i put:textView.
org := org + wEach
].
"Created: 20.11.1995 / 13:06:16 / cg"
"Modified: 24.11.1995 / 11:08:31 / cg"
! !
!SyncedMultiColumnTextView methodsFor:'change & update'!
update:something with:someArgument from:changedObject
"/
"/ if any of my views changes its contents,
"/ I have logically changed my contents -> to give scrollbar
"/ a chance to update
"/
something == #sizeOfContents ifTrue:[
self changed:something
].
"Created: 24.11.1995 / 11:11:22 / cg"
! !
!SyncedMultiColumnTextView methodsFor:'queries'!
heightOfContents
^ textViews inject:0 into:[:maxSoFar :thisView | maxSoFar max:(thisView heightOfContents)]
"Created: 20.11.1995 / 13:08:25 / cg"
!
innerHeight
^ textViews inject:0 into:[:maxSoFar :thisView | maxSoFar max:(thisView innerHeight)]
"Created: 20.11.1995 / 13:08:42 / cg"
!
innerWidth
^ textViews inject:0 into:[:maxSoFar :thisView | maxSoFar max:(thisView innerWidth)]
"Created: 20.11.1995 / 13:08:49 / cg"
!
widthOfContents
^ textViews inject:0 into:[:maxSoFar :thisView | maxSoFar max:(thisView widthOfContents)]
"Created: 20.11.1995 / 13:08:59 / cg"
!
xOriginOfContents
^ textViews inject:0 into:[:maxSoFar :thisView | maxSoFar max:(thisView xOriginOfContents)]
"Created: 20.11.1995 / 13:09:11 / cg"
!
yOriginOfContents
^ textViews inject:0 into:[:maxSoFar :thisView | maxSoFar max:(thisView yOriginOfContents)]
"Created: 20.11.1995 / 13:09:18 / cg"
! !
!SyncedMultiColumnTextView methodsFor:'scrolling'!
scrollDown
self scrollDown:1.
"Created: 20.11.1995 / 13:01:16 / cg"
!
scrollDown:nLines
textViews do:[:thisView | thisView scrollDown:nLines].
"Created: 20.11.1995 / 13:09:40 / cg"
!
scrollHorizontalToPercent:p
"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|
(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"
!
scrollLeft
textViews do:[:thisView | thisView scrollLeft].
"Created: 20.11.1995 / 13:09:40 / cg"
"Modified: 20.11.1995 / 13:15:45 / cg"
!
scrollLeft:nPixels
textViews do:[:thisView | thisView scrollLeft:nPixels].
"Created: 20.11.1995 / 13:09:40 / cg"
"Modified: 20.11.1995 / 13:15:49 / cg"
!
scrollRight
textViews do:[:thisView | thisView scrollRight].
"Created: 20.11.1995 / 13:09:40 / cg"
"Modified: 20.11.1995 / 13:15:39 / cg"
!
scrollRight:nPixels
textViews do:[:thisView | thisView scrollRight:nPixels].
"Created: 20.11.1995 / 13:09:40 / cg"
"Modified: 20.11.1995 / 13:15:27 / cg"
!
scrollToLine:lineNr
textViews do:[:thisView | thisView scrollToLine:lineNr].
"Created: 20.11.1995 / 13:09:40 / cg"
"Modified: 20.11.1995 / 13:15:07 / cg"
!
scrollUp
self scrollUp:1.
"Created: 20.11.1995 / 13:01:16 / cg"
!
scrollUp:nLines
textViews do:[:thisView | thisView scrollUp:nLines].
"Created: 20.11.1995 / 13:09:40 / cg"
"Modified: 20.11.1995 / 13:14:51 / cg"
!
scrollVerticalToPercent:p
"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 |
|hThis|
(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"
! !