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