author | Claus Gittinger <cg@exept.de> |
Sat, 18 Nov 1995 18:03:34 +0100 | |
changeset 91 | ef89e1292812 |
parent 86 | 4d7dbb5f1719 |
child 92 | ca6389321c2a |
permissions | -rw-r--r-- |
12 | 1 |
" |
2 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
24 | 3 |
All Rights Reserved |
12 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
49 | 13 |
SimpleView subclass:#TwoColumnTextView |
24 | 14 |
instanceVariableNames:'textView1 textView2' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Text' |
|
12 | 18 |
! |
19 |
||
20 |
!TwoColumnTextView class methodsFor:'documentation'! |
|
21 |
||
22 |
documentation |
|
23 |
" |
|
24 |
a view showing two texts side-by-side. |
|
25 |
Scrolling is synced, by always scrolling both views. |
|
26 |
This type of view is especially useful to show diff-lists, |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
27 |
code-versions, or other one-by-one viewable texts. |
12 | 28 |
|
29 |
Usually, it does not make much sense, to put totally different |
|
24 | 30 |
or unrelated texts into this kind of view. |
31 |
||
32 |
See subclass DiffTextView for a real class; |
|
33 |
see ChangesBrowsers compare operation for a real application |
|
34 |
of this kind of views. |
|
12 | 35 |
" |
34 | 36 |
! |
37 |
||
38 |
copyright |
|
39 |
" |
|
40 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
41 |
All Rights Reserved |
|
42 |
||
43 |
This software is furnished under a license and may be used |
|
44 |
only in accordance with the terms of that license and with the |
|
45 |
inclusion of the above copyright notice. This software may not |
|
46 |
be provided or otherwise made available to, or used by, any |
|
47 |
other person. No title to or ownership of the software is |
|
48 |
hereby transferred. |
|
49 |
" |
|
50 |
! |
|
51 |
||
52 |
version |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
53 |
^ '$Header: /cvs/stx/stx/libwidg2/TwoColumnTextView.st,v 1.9 1995-11-18 17:03:34 cg Exp $' |
12 | 54 |
! ! |
55 |
||
56 |
!TwoColumnTextView class methodsFor:'instance creation'! |
|
57 |
||
58 |
openOn:firstText and:secondText |
|
24 | 59 |
"open up a view showing firstText and secondText side-by-side" |
12 | 60 |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
61 |
|top v| |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
62 |
|
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
63 |
top := StandardSystemView label:'differences'. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
64 |
v := HVScrollableView |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
65 |
for:self |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
66 |
miniScrollerH:true miniScrollerV:false |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
67 |
in:top. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
68 |
v origin:0.0 @ 0.0 corner:1.0 @ 1.0. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
69 |
v scrolledView text1:firstText text2:secondText. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
70 |
^ top open |
12 | 71 |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
72 |
" |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
73 |
TwoColumnTextView |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
74 |
openOn:('smalltalk.rc' asFilename contentsOfEntireFile) |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
75 |
and:('display.rc' asFilename contentsOfEntireFile) |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
76 |
|
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
77 |
|
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
78 |
TwoColumnTextView |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
79 |
openOn:('display.rc' asFilename contentsOfEntireFile) |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
80 |
and:('smalltalk.rc' asFilename contentsOfEntireFile) |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
81 |
" |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
82 |
|
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
83 |
"Modified: 18.11.1995 / 15:27:25 / cg" |
12 | 84 |
! ! |
85 |
||
86 |
!TwoColumnTextView methodsFor:'queries'! |
|
87 |
||
88 |
heightOfContents |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
89 |
^ textView1 heightOfContents max:textView2 heightOfContents |
12 | 90 |
! |
91 |
||
92 |
widthOfContents |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
93 |
^ textView1 widthOfContents max:textView2 widthOfContents |
12 | 94 |
! |
95 |
||
96 |
xOriginOfContents |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
97 |
^ textView1 xOriginOfContents max:textView2 xOriginOfContents |
12 | 98 |
! |
99 |
||
100 |
yOriginOfContents |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
101 |
^ textView1 yOriginOfContents max:textView2 yOriginOfContents |
12 | 102 |
! |
103 |
||
104 |
innerWidth |
|
105 |
^ textView1 innerWidth |
|
106 |
! |
|
107 |
||
108 |
innerHeight |
|
109 |
^ textView1 innerHeight |
|
110 |
! ! |
|
111 |
||
112 |
!TwoColumnTextView methodsFor:'scrolling'! |
|
113 |
||
114 |
scrollVerticalToPercent:p |
|
91
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
115 |
|master slave| |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
116 |
|
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
117 |
textView1 heightOfContents > textView2 heightOfContents ifTrue:[ |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
118 |
master := textView1. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
119 |
slave := textView2. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
120 |
] ifFalse:[ |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
121 |
master := textView2. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
122 |
slave := textView1. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
123 |
]. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
124 |
|
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
125 |
master scrollVerticalToPercent:p. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
126 |
slave scrollToLine:master firstLineShown. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
127 |
|
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
128 |
"Modified: 18.11.1995 / 15:25:53 / cg" |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
129 |
! |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
130 |
|
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
131 |
scrollHorizontalToPercent:p |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
132 |
textView1 scrollHorizontalToPercent:p. |
ef89e1292812
fixes for different text sizes
Claus Gittinger <cg@exept.de>
parents:
86
diff
changeset
|
133 |
textView2 scrollHorizontalTo:textView1 xOriginOfContents. |
12 | 134 |
! |
135 |
||
136 |
scrollDown:nLines |
|
137 |
textView1 scrollDown:nLines. |
|
138 |
textView2 scrollDown:nLines |
|
139 |
! |
|
140 |
||
141 |
scrollDown |
|
142 |
self scrollDown:1. |
|
143 |
! |
|
144 |
||
145 |
scrollUp |
|
146 |
self scrollUp:1. |
|
147 |
! |
|
148 |
||
149 |
scrollUp:nLines |
|
150 |
textView1 scrollUp:nLines. |
|
151 |
textView2 scrollUp:nLines |
|
152 |
! |
|
153 |
||
154 |
scrollLeft:nPixels |
|
155 |
textView1 scrollLeft:nPixels. |
|
156 |
textView2 scrollLeft:nPixels |
|
157 |
! |
|
158 |
||
159 |
scrollRight:nPixels |
|
160 |
textView1 scrollRight:nPixels. |
|
161 |
textView2 scrollRight:nPixels |
|
162 |
! |
|
163 |
||
164 |
scrollRight |
|
165 |
textView1 scrollRight. |
|
166 |
textView2 scrollRight |
|
167 |
! |
|
168 |
||
169 |
scrollToLine:lineNr |
|
170 |
textView1 scrollToLine:lineNr. |
|
171 |
textView2 scrollToLine:lineNr |
|
172 |
! |
|
173 |
||
174 |
scrollLeft |
|
175 |
textView1 scrollLeft. |
|
176 |
textView2 scrollLeft |
|
177 |
! ! |
|
178 |
||
179 |
!TwoColumnTextView methodsFor:'initialization'! |
|
180 |
||
181 |
initialize |
|
182 |
super initialize. |
|
183 |
||
184 |
textView1 := TextView origin:0.0 @ 0.0 |
|
24 | 185 |
corner:0.5 @ 1.0 |
186 |
in:self. |
|
12 | 187 |
|
188 |
textView1 borderWidth:1. |
|
189 |
textView1 level:0. |
|
190 |
||
191 |
textView2 := TextView origin:0.5 @ 0.0 |
|
24 | 192 |
corner:1.0 @ 1.0 |
193 |
in:self. |
|
12 | 194 |
|
195 |
textView2 borderWidth:1. |
|
196 |
textView2 level:0. |
|
197 |
||
198 |
" |
|
199 |
|v| |
|
200 |
||
201 |
v := HVScrollableView for:TwoColumnTextView. |
|
202 |
v scrolledView text1:('smalltalk.rc' asFilename readStream contents) |
|
24 | 203 |
text2:('smalltalk_r.rc' asFilename readStream contents). |
12 | 204 |
v open |
205 |
" |
|
206 |
! ! |
|
207 |
||
208 |
!TwoColumnTextView methodsFor:'accessing'! |
|
209 |
||
210 |
text1:t1 text2:t2 |
|
211 |
textView1 list:t1 asText. |
|
212 |
textView2 list:t2 asText. |
|
213 |
! ! |