TwoColumnTextView.st
author Claus Gittinger <cg@exept.de>
Mon, 20 Nov 1995 14:21:37 +0100
changeset 92 ca6389321c2a
parent 91 ef89e1292812
child 158 431e38dfc5ab
permissions -rw-r--r--
new (abstract) class for multiple sync-scrolled textviews (preparation for Diff3View ...)

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

    "Created: 20.11.1995 / 13:21:17 / cg"

'From Smalltalk/X, Version:2.10.8 on 20-nov-1995 at 14:12:35'                   !

SyncedMultiColumnTextView subclass:#TwoColumnTextView
	 instanceVariableNames:''
	 classVariableNames:''
	 poolDictionaries:''
	 category:'Views-Text'
!

!TwoColumnTextView class methodsFor:'documentation'!

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

    "Created: 20.11.1995 / 13:21:17 / cg"
!

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

    "Created: 20.11.1995 / 13:21:17 / cg"
!

examples
"
     TwoColumnTextView are currently not directly used by the system.
     However, it is used as an abstract superclass for DiffTextView.
     See more examples there.
     (you may find nice uses for it anyway ...)

     TwoColumnTextView
        openOn:('smalltalk.rc' asFilename contentsOfEntireFile)
        and:('display.rc' asFilename contentsOfEntireFile)


     TwoColumnTextView
        openOn:('display.rc' asFilename contentsOfEntireFile)
        and:('smalltalk.rc' asFilename contentsOfEntireFile)


     TwoColumnTextView
        openOn:('smalltalk.rc' asFilename contentsOfEntireFile)
        label:'smalltalk.rc'
        and:('display.rc' asFilename contentsOfEntireFile)
        label:'display.rc'
"

    "Created: 20.11.1995 / 13:21:42 / cg"
    "Modified: 20.11.1995 / 13:23:12 / cg"
!

version
^ '$Header: /cvs/stx/stx/libwidg2/TwoColumnTextView.st,v 1.10 1995-11-20 13:21:37 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:'two texts'.
    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
        openOn:('smalltalk.rc' asFilename contentsOfEntireFile)
        and:('display.rc' asFilename contentsOfEntireFile)


     TwoColumnTextView
        openOn:('display.rc' asFilename contentsOfEntireFile)
        and:('smalltalk.rc' asFilename contentsOfEntireFile)
    "

    "Modified: 20.11.1995 / 13:36:15 / cg"
!

openOn:firstText label:firstLabel and:secondText label:secondLabel
    "open up a view showing firstText and secondText side-by-side,
     and labels for both views."

    |top v l1 l2|

    top := StandardSystemView label:'two texts'.
    l1 := Label label:firstLabel in:top.
    l1 origin:0.0@0.0 corner:0.5@(l1 height).
    l2 := Label label:secondLabel in:top.
    l2 origin:0.5@0.0 corner:1.0@(l1 height).

    v := HVScrollableView 
               for:self 
               miniScrollerH:true miniScrollerV:false
               in:top.
    v origin:0.0 @ (l1 height + ViewSpacing) corner:1.0 @ 1.0.
    v scrolledView text1:firstText text2:secondText.
    ^ top open

    "
     TwoColumnTextView
        openOn:('smalltalk.rc' asFilename contentsOfEntireFile)
        label:'smalltalk.rc'
        and:('display.rc' asFilename contentsOfEntireFile)
        label:'display.rc'
    "

    "Modified: 20.11.1995 / 13:36:20 / cg"
! !

!TwoColumnTextView class methodsFor:'specification'!

numberOfViews
    ^ 2

    "Created: 20.11.1995 / 13:17:00 / cg"
! !

!TwoColumnTextView methodsFor:'accessing'!

text1:t1 text2:t2
    (textViews at:1) list:t1 asText.
    (textViews at:2) list:t2 asText.

    "Created: 20.11.1995 / 13:20:39 / cg"
! !