0
|
1 |
"
|
5
|
2 |
COPYRIGHT (c) 1991 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
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
|
0
|
23 |
All Rights Reserved
|
|
24 |
|
38
|
25 |
$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.6 1994-08-07 13:22:38 claus Exp $
|
0
|
26 |
written jan 91 by claus
|
|
27 |
'!
|
|
28 |
|
38
|
29 |
!HVScrollableView methodsFor:'documentation'!
|
|
30 |
|
|
31 |
documentation
|
|
32 |
"
|
|
33 |
a view containing both horizontal and vertical scrollbars
|
|
34 |
and some other (slave-)view
|
|
35 |
"
|
|
36 |
! !
|
|
37 |
|
0
|
38 |
!HVScrollableView methodsFor:'initialization'!
|
|
39 |
|
38
|
40 |
initializeFor:aViewClass miniScrollerH:miniH miniScrollerV:miniV
|
|
41 |
|negativeOffset halfMargin orgX mrg halfSpacing is3D cls|
|
|
42 |
|
|
43 |
"/ self initStyle.
|
7
|
44 |
|
38
|
45 |
cls := miniH ifTrue:[HorizontalMiniScroller] ifFalse:[HorizontalScrollBar].
|
|
46 |
style == #st80 ifTrue:[cls := HorizontalScrollBar].
|
|
47 |
|
|
48 |
hScrollBar := cls in:self.
|
0
|
49 |
|
38
|
50 |
super
|
|
51 |
initializeFor:aViewClass
|
|
52 |
miniScrollerH:miniH
|
|
53 |
miniScrollerV:miniV.
|
0
|
54 |
|
|
55 |
negativeOffset := borderWidth negated.
|
|
56 |
halfMargin := innerMargin // 2.
|
38
|
57 |
is3D := (style ~~ #normal) and:[style ~~ #mswindows].
|
0
|
58 |
|
38
|
59 |
"
|
|
60 |
change vertical scrollbars size
|
|
61 |
"
|
|
62 |
is3D ifTrue:[
|
|
63 |
mrg := innerMargin + innerMargin + hScrollBar borderWidth.
|
|
64 |
halfSpacing := ViewSpacing // 2.
|
0
|
65 |
] ifFalse:[
|
38
|
66 |
mrg := hScrollBar borderWidth
|
0
|
67 |
].
|
38
|
68 |
scrollBar extent:[scrollBar width @ (height - hScrollBar height - mrg)].
|
0
|
69 |
|
|
70 |
hScrollBar thumbOrigin:0 thumbHeight:100.
|
38
|
71 |
|
|
72 |
scrollBarPosition == #left ifTrue:[
|
|
73 |
orgX := scrollBar origin x + scrollBar width.
|
|
74 |
is3D ifTrue:[
|
|
75 |
orgX := orgX + halfSpacing + 1.
|
|
76 |
style == #st80 ifTrue:[
|
|
77 |
orgX := orgX - (scrolledView margin)
|
|
78 |
]
|
|
79 |
]
|
|
80 |
] ifFalse:[
|
|
81 |
orgX := 0 - hScrollBar borderWidth
|
|
82 |
].
|
|
83 |
is3D ifTrue:[
|
|
84 |
hScrollBar origin:[(orgX + innerMargin - halfSpacing - hScrollBar margin)
|
0
|
85 |
@
|
|
86 |
(height - hScrollBar height - halfMargin)
|
|
87 |
]
|
38
|
88 |
extent:[(width -
|
|
89 |
scrollBar width -
|
|
90 |
(innerMargin * 2))
|
0
|
91 |
@
|
|
92 |
hScrollBar height
|
|
93 |
]
|
|
94 |
] ifFalse:[
|
38
|
95 |
scrollBarPosition == #left ifTrue:[
|
|
96 |
hScrollBar
|
|
97 |
origin:[(orgX + scrollBar borderWidth)
|
|
98 |
@
|
|
99 |
(height - hScrollBar height - (hScrollBar borderWidth "* 2"))
|
|
100 |
]
|
|
101 |
extent:[(width -
|
|
102 |
scrollBar width "- (2 * hScrollBar borderWidth)")
|
|
103 |
@
|
|
104 |
hScrollBar height
|
|
105 |
]
|
|
106 |
] ifFalse:[
|
|
107 |
hScrollBar
|
|
108 |
origin:[(orgX)
|
|
109 |
@
|
|
110 |
(height - hScrollBar height - (hScrollBar borderWidth "* 2"))
|
|
111 |
]
|
|
112 |
extent:[(width - scrollBar width - hScrollBar borderWidth)
|
|
113 |
@
|
|
114 |
hScrollBar height
|
|
115 |
]
|
|
116 |
]
|
0
|
117 |
].
|
|
118 |
|
38
|
119 |
scrolledView notNil ifTrue:[
|
|
120 |
"redefine subviews size"
|
|
121 |
is3D ifTrue:[
|
|
122 |
scrolledView
|
|
123 |
extent:[(width
|
|
124 |
- scrollBar width
|
|
125 |
- (innerMargin * 2))
|
|
126 |
@
|
|
127 |
(height
|
|
128 |
- hScrollBar height
|
|
129 |
- (innerMargin * 2))
|
0
|
130 |
]
|
38
|
131 |
] ifFalse:[
|
0
|
132 |
scrolledView
|
|
133 |
extent:[(width
|
|
134 |
- scrollBar width
|
|
135 |
- scrollBar borderWidth
|
7
|
136 |
"- scrolledView borderWidth")
|
0
|
137 |
@
|
|
138 |
(height
|
|
139 |
- hScrollBar height
|
|
140 |
- hScrollBar borderWidth
|
7
|
141 |
"- scrolledView borderWidth")
|
0
|
142 |
]
|
|
143 |
].
|
38
|
144 |
self setScrollActions
|
0
|
145 |
].
|
38
|
146 |
self viewGravity:#south
|
0
|
147 |
!
|
|
148 |
|
|
149 |
realize
|
|
150 |
super realize.
|
38
|
151 |
scrolledView notNil ifTrue:[
|
|
152 |
hScrollBar setThumbFor:scrolledView
|
|
153 |
]
|
0
|
154 |
! !
|
|
155 |
|
7
|
156 |
!HVScrollableView methodsFor:'private'!
|
|
157 |
|
|
158 |
setScrollActions
|
|
159 |
|lock|
|
|
160 |
|
|
161 |
lock := false.
|
|
162 |
|
|
163 |
scrollBar scrollAction:[:position |
|
|
164 |
lock := true.
|
|
165 |
scrolledView scrollVerticalToPercent:position.
|
|
166 |
lock := false
|
|
167 |
].
|
|
168 |
scrollBar scrollUpAction:[scrolledView scrollUp].
|
|
169 |
scrollBar scrollDownAction:[scrolledView scrollDown].
|
|
170 |
|
|
171 |
hScrollBar scrollAction:[:position |
|
|
172 |
lock := true.
|
|
173 |
scrolledView scrollHorizontalToPercent:position.
|
|
174 |
lock := false
|
|
175 |
].
|
|
176 |
hScrollBar scrollLeftAction:[scrolledView scrollLeft].
|
|
177 |
hScrollBar scrollRightAction:[scrolledView scrollRight].
|
|
178 |
|
|
179 |
scrolledView originChangeAction:[:aView |
|
|
180 |
lock ifFalse:[
|
|
181 |
scrollBar setThumbOriginFor:aView.
|
|
182 |
hScrollBar setThumbOriginFor:aView
|
|
183 |
]
|
|
184 |
].
|
|
185 |
scrolledView contentsChangeAction:[:aView |
|
|
186 |
scrollBar setThumbFor:aView.
|
|
187 |
hScrollBar setThumbFor:aView
|
|
188 |
]
|
|
189 |
! !
|
|
190 |
|
0
|
191 |
!HVScrollableView methodsFor:'accessing'!
|
|
192 |
|
7
|
193 |
horizontalScrollBar
|
|
194 |
"return the horizontal scrollbar"
|
|
195 |
|
|
196 |
^ hScrollBar
|
|
197 |
!
|
|
198 |
|
0
|
199 |
scrolledView:aView
|
38
|
200 |
|is3D|
|
|
201 |
|
7
|
202 |
"set the scrolled view"
|
|
203 |
|
0
|
204 |
super scrolledView:aView.
|
|
205 |
|
38
|
206 |
is3D := (style ~~ #normal) and:[style ~~ #mswindows].
|
|
207 |
|
0
|
208 |
"redefine subviews size"
|
38
|
209 |
is3D ifTrue:[
|
|
210 |
scrolledView
|
|
211 |
extent:[(width
|
|
212 |
- scrollBar width
|
|
213 |
- (innerMargin * 2))
|
|
214 |
@
|
|
215 |
(height
|
|
216 |
- hScrollBar height
|
|
217 |
- (innerMargin * 2))
|
|
218 |
]
|
|
219 |
] ifFalse:[
|
0
|
220 |
scrolledView
|
|
221 |
extent:[(width
|
|
222 |
- scrollBar width
|
|
223 |
- scrollBar borderWidth
|
|
224 |
"- scrolledView borderWidth")
|
|
225 |
@
|
|
226 |
(height
|
|
227 |
- hScrollBar height
|
|
228 |
- hScrollBar borderWidth
|
|
229 |
"- scrolledView borderWidth")
|
|
230 |
]
|
|
231 |
].
|
7
|
232 |
self setScrollActions
|
0
|
233 |
! !
|
|
234 |
|
|
235 |
!HVScrollableView methodsFor:'event processing'!
|
|
236 |
|
|
237 |
sizeChanged:how
|
|
238 |
super sizeChanged:how.
|
38
|
239 |
scrolledView notNil ifTrue:[
|
|
240 |
hScrollBar setThumbFor:scrolledView
|
|
241 |
]
|
0
|
242 |
! !
|