0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
59
|
3 |
All Rights Reserved
|
0
|
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 |
|
|
13 |
ScrollableView subclass:#HVScrollableView
|
|
14 |
instanceVariableNames:'hScrollBar'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Basic'
|
|
18 |
!
|
|
19 |
|
|
20 |
HVScrollableView comment:'
|
|
21 |
|
5
|
22 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
59
|
23 |
All Rights Reserved
|
0
|
24 |
|
130
|
25 |
$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.11 1995-06-06 04:13:58 claus Exp $
|
0
|
26 |
written jan 91 by claus
|
|
27 |
'!
|
|
28 |
|
63
|
29 |
!HVScrollableView class methodsFor:'documentation'!
|
|
30 |
|
|
31 |
copyright
|
|
32 |
"
|
|
33 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
|
34 |
All Rights Reserved
|
|
35 |
|
|
36 |
This software is furnished under a license and may be used
|
|
37 |
only in accordance with the terms of that license and with the
|
|
38 |
inclusion of the above copyright notice. This software may not
|
|
39 |
be provided or otherwise made available to, or used by, any
|
|
40 |
other person. No title to or ownership of the software is
|
|
41 |
hereby transferred.
|
|
42 |
"
|
|
43 |
!
|
|
44 |
|
|
45 |
version
|
|
46 |
"
|
130
|
47 |
$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.11 1995-06-06 04:13:58 claus Exp $
|
63
|
48 |
"
|
|
49 |
!
|
38
|
50 |
|
|
51 |
documentation
|
|
52 |
"
|
|
53 |
a view containing both horizontal and vertical scrollbars
|
130
|
54 |
and some other (slave-)view.
|
|
55 |
|
|
56 |
Please see the documentation and examples in my superclass, ScrollableView
|
38
|
57 |
"
|
|
58 |
! !
|
|
59 |
|
0
|
60 |
!HVScrollableView methodsFor:'initialization'!
|
|
61 |
|
38
|
62 |
initializeFor:aViewClass miniScrollerH:miniH miniScrollerV:miniV
|
130
|
63 |
|negativeOffset halfMargin orgX mrg halfSpacing
|
|
64 |
is3D cls hBorderWidth isST80 isOpenWin extra|
|
59
|
65 |
|
|
66 |
isST80 := StyleSheet name = #st80. "leftover - remove it"
|
38
|
67 |
|
59
|
68 |
isST80 ifTrue:[
|
|
69 |
cls := HorizontalScrollBar
|
|
70 |
] ifFalse:[
|
|
71 |
cls := miniH ifTrue:[HorizontalMiniScroller] ifFalse:[HorizontalScrollBar].
|
|
72 |
].
|
38
|
73 |
|
|
74 |
hScrollBar := cls in:self.
|
0
|
75 |
|
38
|
76 |
super
|
59
|
77 |
initializeFor:aViewClass
|
|
78 |
miniScrollerH:miniH
|
|
79 |
miniScrollerV:miniV.
|
0
|
80 |
|
|
81 |
negativeOffset := borderWidth negated.
|
|
82 |
halfMargin := innerMargin // 2.
|
130
|
83 |
is3D := styleSheet is3D.
|
|
84 |
isOpenWin := styleSheet name = #openwin.
|
0
|
85 |
|
38
|
86 |
"
|
|
87 |
change vertical scrollbars size
|
|
88 |
"
|
59
|
89 |
mrg := hScrollBar borderWidth.
|
|
90 |
mrg isNil ifTrue:[mrg := 0].
|
|
91 |
hBorderWidth := mrg.
|
|
92 |
|
38
|
93 |
is3D ifTrue:[
|
59
|
94 |
isST80 ifTrue:[
|
|
95 |
halfSpacing := 0
|
|
96 |
] ifFalse:[
|
|
97 |
mrg := mrg + innerMargin + innerMargin.
|
|
98 |
halfSpacing := ViewSpacing // 2.
|
|
99 |
].
|
0
|
100 |
].
|
130
|
101 |
|
|
102 |
extra := 0.
|
|
103 |
isOpenWin ifTrue:[
|
|
104 |
extra := 2.
|
|
105 |
].
|
|
106 |
|
|
107 |
scrollBar extent:[scrollBar width
|
|
108 |
@
|
|
109 |
(height - hScrollBar height - mrg + extra)].
|
0
|
110 |
|
|
111 |
hScrollBar thumbOrigin:0 thumbHeight:100.
|
38
|
112 |
|
|
113 |
scrollBarPosition == #left ifTrue:[
|
59
|
114 |
orgX := scrollBar origin x + scrollBar width.
|
|
115 |
is3D ifTrue:[
|
|
116 |
orgX := orgX + halfSpacing + 1.
|
|
117 |
isST80 ifTrue:[
|
|
118 |
orgX := orgX - (scrolledView margin)
|
|
119 |
]
|
|
120 |
]
|
0
|
121 |
] ifFalse:[
|
59
|
122 |
orgX := 0 - hBorderWidth.
|
130
|
123 |
"/ isST80 ifTrue:[
|
59
|
124 |
"/ orgX := orgX + 1
|
130
|
125 |
"/ ]
|
|
126 |
].
|
|
127 |
isOpenWin ifTrue:[
|
|
128 |
orgX := orgX + 1
|
59
|
129 |
].
|
|
130 |
|
|
131 |
is3D ifTrue:[
|
|
132 |
hScrollBar origin:[(orgX + innerMargin - halfSpacing - hScrollBar margin)
|
|
133 |
@
|
|
134 |
(height - hScrollBar height - halfMargin)
|
|
135 |
]
|
130
|
136 |
extent:[(width - scrollBar width - (innerMargin * 2) + extra)
|
59
|
137 |
@
|
|
138 |
hScrollBar height
|
|
139 |
]
|
|
140 |
] ifFalse:[
|
|
141 |
scrollBarPosition == #left ifTrue:[
|
|
142 |
hScrollBar
|
|
143 |
origin:[(orgX + scrollBar borderWidth)
|
|
144 |
@
|
|
145 |
(height - hScrollBar height - hBorderWidth)
|
|
146 |
]
|
|
147 |
extent:[(width - scrollBar width) @ hScrollBar height]
|
|
148 |
] ifFalse:[
|
|
149 |
hScrollBar
|
|
150 |
origin:[orgX @ (height - hScrollBar height - hBorderWidth) ]
|
|
151 |
extent:[(width - scrollBar width - hBorderWidth) @ hScrollBar height]
|
|
152 |
]
|
0
|
153 |
].
|
|
154 |
|
38
|
155 |
scrolledView notNil ifTrue:[
|
59
|
156 |
"redefine subviews size"
|
|
157 |
is3D ifTrue:[
|
|
158 |
scrolledView
|
|
159 |
extent:[(width - scrollBar width - (innerMargin * 2))
|
|
160 |
@
|
|
161 |
(height - hScrollBar height - (innerMargin * 2)) ]
|
|
162 |
] ifFalse:[
|
|
163 |
scrolledView
|
|
164 |
extent:[(width - scrollBar width - scrollBar borderWidth)
|
|
165 |
@
|
|
166 |
(height - hScrollBar height - hScrollBar borderWidth)
|
|
167 |
]
|
|
168 |
].
|
|
169 |
self setScrollActions
|
63
|
170 |
]
|
0
|
171 |
!
|
|
172 |
|
|
173 |
realize
|
|
174 |
super realize.
|
38
|
175 |
scrolledView notNil ifTrue:[
|
59
|
176 |
hScrollBar setThumbFor:scrolledView
|
38
|
177 |
]
|
0
|
178 |
! !
|
|
179 |
|
7
|
180 |
!HVScrollableView methodsFor:'private'!
|
|
181 |
|
|
182 |
setScrollActions
|
|
183 |
scrollBar scrollAction:[:position |
|
65
|
184 |
lockUpdates := true.
|
59
|
185 |
scrolledView scrollVerticalToPercent:position.
|
65
|
186 |
lockUpdates := false
|
7
|
187 |
].
|
|
188 |
scrollBar scrollUpAction:[scrolledView scrollUp].
|
|
189 |
scrollBar scrollDownAction:[scrolledView scrollDown].
|
|
190 |
|
|
191 |
hScrollBar scrollAction:[:position |
|
65
|
192 |
lockUpdates := true.
|
59
|
193 |
scrolledView scrollHorizontalToPercent:position.
|
65
|
194 |
lockUpdates := false
|
7
|
195 |
].
|
|
196 |
hScrollBar scrollLeftAction:[scrolledView scrollLeft].
|
|
197 |
hScrollBar scrollRightAction:[scrolledView scrollRight].
|
|
198 |
|
65
|
199 |
scrolledView addDependent:self.
|
7
|
200 |
! !
|
|
201 |
|
0
|
202 |
!HVScrollableView methodsFor:'accessing'!
|
|
203 |
|
7
|
204 |
horizontalScrollBar
|
|
205 |
"return the horizontal scrollbar"
|
|
206 |
|
|
207 |
^ hScrollBar
|
|
208 |
!
|
|
209 |
|
0
|
210 |
scrolledView:aView
|
7
|
211 |
"set the scrolled view"
|
|
212 |
|
0
|
213 |
super scrolledView:aView.
|
|
214 |
|
|
215 |
"redefine subviews size"
|
130
|
216 |
styleSheet is3D ifTrue:[
|
59
|
217 |
scrolledView
|
|
218 |
extent:[(width
|
|
219 |
- scrollBar width
|
|
220 |
- (innerMargin * 2))
|
|
221 |
@
|
|
222 |
(height
|
|
223 |
- hScrollBar height
|
|
224 |
- (innerMargin * 2))
|
|
225 |
]
|
38
|
226 |
] ifFalse:[
|
59
|
227 |
scrolledView
|
|
228 |
extent:[(width
|
|
229 |
- scrollBar width
|
|
230 |
- scrollBar borderWidth
|
|
231 |
"- scrolledView borderWidth")
|
|
232 |
@
|
|
233 |
(height
|
|
234 |
- hScrollBar height
|
|
235 |
- hScrollBar borderWidth
|
|
236 |
"- scrolledView borderWidth")
|
|
237 |
]
|
0
|
238 |
].
|
7
|
239 |
self setScrollActions
|
0
|
240 |
! !
|
|
241 |
|
105
|
242 |
!HVScrollableView methodsFor:'queries'!
|
|
243 |
|
130
|
244 |
preferredExtent
|
|
245 |
|pref m2|
|
|
246 |
|
105
|
247 |
scrolledView notNil ifTrue:[
|
130
|
248 |
m2 := innerMargin * 2.
|
|
249 |
pref := scrolledView preferredExtent.
|
|
250 |
^ (pref x + scrollBar width + m2)
|
|
251 |
@
|
|
252 |
(pref y + hScrollBar height + m2).
|
105
|
253 |
].
|
130
|
254 |
^ super preferredExtent.
|
105
|
255 |
! !
|
|
256 |
|
65
|
257 |
!HVScrollableView methodsFor:'changes '!
|
|
258 |
|
|
259 |
update:something with:argument from:changedObject
|
|
260 |
"whenever the scrolledview changes its contents, we have to
|
|
261 |
update the scrollers too"
|
|
262 |
|
|
263 |
changedObject == scrolledView ifTrue:[
|
|
264 |
something == #sizeOfContents ifTrue:[
|
|
265 |
scrollBar setThumbFor:scrolledView.
|
|
266 |
hScrollBar setThumbFor:scrolledView.
|
|
267 |
^ self
|
|
268 |
].
|
|
269 |
something == #originOfContents ifTrue:[
|
|
270 |
lockUpdates ifFalse:[
|
|
271 |
scrollBar setThumbOriginFor:scrolledView.
|
|
272 |
hScrollBar setThumbOriginFor:scrolledView.
|
|
273 |
].
|
|
274 |
^ self
|
|
275 |
].
|
|
276 |
].
|
|
277 |
! !
|
|
278 |
|
0
|
279 |
!HVScrollableView methodsFor:'event processing'!
|
|
280 |
|
|
281 |
sizeChanged:how
|
|
282 |
super sizeChanged:how.
|
38
|
283 |
scrolledView notNil ifTrue:[
|
59
|
284 |
hScrollBar setThumbFor:scrolledView
|
38
|
285 |
]
|
0
|
286 |
! !
|