TwoColumnTextView.st
author claus
Fri, 05 Aug 1994 03:24:12 +0200
changeset 12 30f48431927b
child 14 66a5cdf0adea
permissions -rw-r--r--
Initial revision

"
 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.
"

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

TwoColumnTextView comment:'
COPYRIGHT (c) 1994 by Claus Gittinger
              All Rights Reserved

$Header: /cvs/stx/stx/libwidg2/TwoColumnTextView.st,v 1.1 1994-08-05 01:23:47 claus Exp $
'!

!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,
    or other one-by-one vievable texts.

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

!TwoColumnTextView class methodsFor:'instance creation'!

openOn:firstText and:secondText
    "open up a view showing firstText and secondText"

     |top v|

     top := StandardSystemView label:'differences'.
     v := HVScrollableView for:self 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
    |panel|

    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.
! !