TwoColumnTextView.st
author Claus Gittinger <cg@exept.de>
Sat, 11 Nov 1995 17:30:31 +0100
changeset 86 4d7dbb5f1719
parent 71 9f9243f5813b
child 91 ef89e1292812
permissions -rw-r--r--
uff - version methods changed to return stings

"
 COPYRIGHT (c) 1994 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.
"

SimpleView subclass:#TwoColumnTextView
	 instanceVariableNames:'textView1 textView2'
	 classVariableNames:''
	 poolDictionaries:''
	 category:'Views-Text'
!

!TwoColumnTextView class methodsFor:'documentation'!

documentation
"
    a view showing two texts side-by-side.
    Scrolling is synced, by always scrolling both views.
    This type of view is especially useful to show diff-lists,
    code-versions, or other one-by-one vievable texts.

    Usually, it does not make much sense, to put totally different
    or unrelated texts into this kind of view.

    See subclass DiffTextView for a real class;
    see ChangesBrowsers compare operation for a real application
    of this kind of views.
"
!

copyright
"
 COPYRIGHT (c) 1994 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.
"
!

version
    ^ '$Header: /cvs/stx/stx/libwidg2/TwoColumnTextView.st,v 1.8 1995-11-11 16:28:50 cg Exp $'
! !

!TwoColumnTextView class methodsFor:'instance creation'!

openOn:firstText and:secondText
    "open up a view showing firstText and secondText side-by-side"

     |top v|

     top := StandardSystemView label:'differences'.
     v := HVScrollableView 
		for:self 
		miniScrollerH:true miniScrollerV:false
		in:top.
     v origin:0.0 @ 0.0 corner:1.0 @ 1.0.
     v scrolledView text1:firstText text2:secondText.
     ^ top open
! !

!TwoColumnTextView methodsFor:'queries'!

heightOfContents
    ^ textView1 heightOfContents
!

widthOfContents
    ^ textView1 widthOfContents
!

xOriginOfContents
    ^ textView1 xOriginOfContents
!

yOriginOfContents
    ^ textView1 yOriginOfContents
!

innerWidth
    ^ textView1 innerWidth
!

innerHeight
    ^ textView1 innerHeight
! !

!TwoColumnTextView methodsFor:'scrolling'!

scrollVerticalToPercent:p
    textView1 scrollVerticalToPercent:p.
    textView2 scrollToLine:textView1 firstLineShown.
!

scrollDown:nLines
    textView1 scrollDown:nLines.
    textView2 scrollDown:nLines
!

scrollDown
    self scrollDown:1.
!

scrollUp
    self scrollUp:1.
!

scrollUp:nLines
    textView1 scrollUp:nLines.
    textView2 scrollUp:nLines
!

scrollLeft:nPixels
    textView1 scrollLeft:nPixels.
    textView2 scrollLeft:nPixels
!

scrollRight:nPixels
    textView1 scrollRight:nPixels.
    textView2 scrollRight:nPixels
!

scrollRight
    textView1 scrollRight.
    textView2 scrollRight
!

scrollToLine:lineNr
    textView1 scrollToLine:lineNr.
    textView2 scrollToLine:lineNr
!

scrollHorizontalToPercent:p
    textView1 scrollHorizontalToPercent:p.
    textView2 scrollHorizontalTo:textView1 xOriginOfContents.
!

scrollLeft
    textView1 scrollLeft.
    textView2 scrollLeft
! !

!TwoColumnTextView methodsFor:'initialization'!

initialize
    super initialize.

    textView1 := TextView origin:0.0 @ 0.0
			  corner:0.5 @ 1.0
			      in:self.

    textView1 borderWidth:1.
    textView1 level:0. 

    textView2 := TextView origin:0.5 @ 0.0
			  corner:1.0 @ 1.0
			      in:self.

    textView2 borderWidth:1.
    textView2 level:0. 

    "
     |v|

     v := HVScrollableView for:TwoColumnTextView.
     v scrolledView text1:('smalltalk.rc' asFilename readStream contents)
		    text2:('smalltalk_r.rc' asFilename readStream contents).
     v open
    "
! !

!TwoColumnTextView methodsFor:'accessing'!

text1:t1 text2:t2
    textView1 list:t1 asText.
    textView2 list:t2 asText.
! !