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