author | Claus Gittinger <cg@exept.de> |
Mon, 22 Jul 1996 10:56:41 +0200 | |
changeset 802 | 332e7013a9f5 |
parent 713 | 0c38ad51016d |
child 814 | 5b80bc44f52b |
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 |
|
572 | 14 |
instanceVariableNames:'hScrollBar' |
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Basic' |
|
0 | 18 |
! |
19 |
||
802 | 20 |
!HVScrollableView class methodsFor:'documentation'! |
63 | 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 |
||
38 | 36 |
documentation |
37 |
" |
|
38 |
a view containing both horizontal and vertical scrollbars |
|
130 | 39 |
and some other (slave-)view. |
40 |
||
41 |
Please see the documentation and examples in my superclass, ScrollableView |
|
584 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
38 | 45 |
" |
46 |
! ! |
|
47 |
||
678
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
48 |
!HVScrollableView methodsFor:'accessing - components'! |
216 | 49 |
|
50 |
horizontalScrollBar |
|
51 |
"return the horizontal scrollbar" |
|
52 |
||
53 |
^ hScrollBar |
|
54 |
! |
|
55 |
||
56 |
scrolledView:aView |
|
57 |
"set the scrolled view" |
|
58 |
||
59 |
super scrolledView:aView. |
|
60 |
||
61 |
"redefine subviews size" |
|
62 |
styleSheet is3D ifTrue:[ |
|
63 |
scrolledView |
|
64 |
extent:[(width |
|
65 |
- scrollBar width |
|
66 |
- (innerMargin * 2)) |
|
67 |
@ |
|
68 |
(height |
|
69 |
- hScrollBar height |
|
70 |
- (innerMargin * 2)) |
|
71 |
] |
|
72 |
] ifFalse:[ |
|
73 |
scrolledView |
|
74 |
extent:[(width |
|
75 |
- scrollBar width |
|
76 |
- scrollBar borderWidth |
|
77 |
"- scrolledView borderWidth") |
|
78 |
@ |
|
79 |
(height |
|
80 |
- hScrollBar height |
|
81 |
- hScrollBar borderWidth |
|
82 |
"- scrolledView borderWidth") |
|
83 |
] |
|
84 |
]. |
|
85 |
self setScrollActions |
|
86 |
! ! |
|
87 |
||
88 |
!HVScrollableView methodsFor:'changes '! |
|
89 |
||
90 |
update:something with:argument from:changedObject |
|
91 |
"whenever the scrolledview changes its contents, we have to |
|
92 |
update the scrollers too" |
|
93 |
||
94 |
changedObject == scrolledView ifTrue:[ |
|
95 |
something == #sizeOfContents ifTrue:[ |
|
96 |
scrollBar setThumbFor:scrolledView. |
|
97 |
hScrollBar setThumbFor:scrolledView. |
|
98 |
^ self |
|
99 |
]. |
|
100 |
something == #originOfContents ifTrue:[ |
|
101 |
lockUpdates ifFalse:[ |
|
102 |
scrollBar setThumbOriginFor:scrolledView. |
|
103 |
hScrollBar setThumbOriginFor:scrolledView. |
|
104 |
]. |
|
105 |
^ self |
|
106 |
]. |
|
107 |
]. |
|
108 |
! ! |
|
109 |
||
110 |
!HVScrollableView methodsFor:'event processing'! |
|
111 |
||
112 |
sizeChanged:how |
|
113 |
super sizeChanged:how. |
|
114 |
scrolledView notNil ifTrue:[ |
|
115 |
hScrollBar setThumbFor:scrolledView |
|
116 |
]. |
|
117 |
hScrollBar thumbOrigin + hScrollBar thumbHeight >= 100 ifTrue:[ |
|
118 |
hScrollBar thumbOrigin:(100 - hScrollBar thumbHeight). |
|
119 |
scrolledView scrollHorizontalToPercent:hScrollBar thumbOrigin. |
|
120 |
]. |
|
121 |
||
122 |
"Modified: 8.9.1995 / 12:46:36 / claus" |
|
123 |
! ! |
|
124 |
||
0 | 125 |
!HVScrollableView methodsFor:'initialization'! |
126 |
||
38 | 127 |
initializeFor:aViewClass miniScrollerH:miniH miniScrollerV:miniV |
130 | 128 |
|negativeOffset halfMargin orgX mrg halfSpacing |
129 |
is3D cls hBorderWidth isST80 isOpenWin extra| |
|
59 | 130 |
|
131 |
isST80 := StyleSheet name = #st80. "leftover - remove it" |
|
38 | 132 |
|
59 | 133 |
isST80 ifTrue:[ |
134 |
cls := HorizontalScrollBar |
|
135 |
] ifFalse:[ |
|
136 |
cls := miniH ifTrue:[HorizontalMiniScroller] ifFalse:[HorizontalScrollBar]. |
|
137 |
]. |
|
38 | 138 |
|
139 |
hScrollBar := cls in:self. |
|
0 | 140 |
|
38 | 141 |
super |
59 | 142 |
initializeFor:aViewClass |
143 |
miniScrollerH:miniH |
|
144 |
miniScrollerV:miniV. |
|
0 | 145 |
|
146 |
negativeOffset := borderWidth negated. |
|
147 |
halfMargin := innerMargin // 2. |
|
130 | 148 |
is3D := styleSheet is3D. |
149 |
isOpenWin := styleSheet name = #openwin. |
|
0 | 150 |
|
38 | 151 |
" |
152 |
change vertical scrollbars size |
|
153 |
" |
|
59 | 154 |
mrg := hScrollBar borderWidth. |
155 |
mrg isNil ifTrue:[mrg := 0]. |
|
156 |
hBorderWidth := mrg. |
|
157 |
||
38 | 158 |
is3D ifTrue:[ |
59 | 159 |
isST80 ifTrue:[ |
160 |
halfSpacing := 0 |
|
161 |
] ifFalse:[ |
|
162 |
mrg := mrg + innerMargin + innerMargin. |
|
163 |
halfSpacing := ViewSpacing // 2. |
|
164 |
]. |
|
0 | 165 |
]. |
130 | 166 |
|
167 |
extra := 0. |
|
168 |
isOpenWin ifTrue:[ |
|
169 |
extra := 2. |
|
170 |
]. |
|
171 |
||
172 |
scrollBar extent:[scrollBar width |
|
173 |
@ |
|
174 |
(height - hScrollBar height - mrg + extra)]. |
|
0 | 175 |
|
176 |
hScrollBar thumbOrigin:0 thumbHeight:100. |
|
38 | 177 |
|
178 |
scrollBarPosition == #left ifTrue:[ |
|
59 | 179 |
orgX := scrollBar origin x + scrollBar width. |
180 |
is3D ifTrue:[ |
|
181 |
orgX := orgX + halfSpacing + 1. |
|
182 |
isST80 ifTrue:[ |
|
183 |
orgX := orgX - (scrolledView margin) |
|
184 |
] |
|
185 |
] |
|
0 | 186 |
] ifFalse:[ |
59 | 187 |
orgX := 0 - hBorderWidth. |
130 | 188 |
"/ isST80 ifTrue:[ |
59 | 189 |
"/ orgX := orgX + 1 |
130 | 190 |
"/ ] |
191 |
]. |
|
192 |
isOpenWin ifTrue:[ |
|
193 |
orgX := orgX + 1 |
|
59 | 194 |
]. |
195 |
||
196 |
is3D ifTrue:[ |
|
197 |
hScrollBar origin:[(orgX + innerMargin - halfSpacing - hScrollBar margin) |
|
198 |
@ |
|
199 |
(height - hScrollBar height - halfMargin) |
|
200 |
] |
|
130 | 201 |
extent:[(width - scrollBar width - (innerMargin * 2) + extra) |
59 | 202 |
@ |
203 |
hScrollBar height |
|
204 |
] |
|
205 |
] ifFalse:[ |
|
206 |
scrollBarPosition == #left ifTrue:[ |
|
207 |
hScrollBar |
|
208 |
origin:[(orgX + scrollBar borderWidth) |
|
209 |
@ |
|
210 |
(height - hScrollBar height - hBorderWidth) |
|
211 |
] |
|
212 |
extent:[(width - scrollBar width) @ hScrollBar height] |
|
213 |
] ifFalse:[ |
|
214 |
hScrollBar |
|
215 |
origin:[orgX @ (height - hScrollBar height - hBorderWidth) ] |
|
216 |
extent:[(width - scrollBar width - hBorderWidth) @ hScrollBar height] |
|
217 |
] |
|
0 | 218 |
]. |
219 |
||
38 | 220 |
scrolledView notNil ifTrue:[ |
59 | 221 |
"redefine subviews size" |
222 |
is3D ifTrue:[ |
|
223 |
scrolledView |
|
224 |
extent:[(width - scrollBar width - (innerMargin * 2)) |
|
225 |
@ |
|
226 |
(height - hScrollBar height - (innerMargin * 2)) ] |
|
227 |
] ifFalse:[ |
|
228 |
scrolledView |
|
229 |
extent:[(width - scrollBar width - scrollBar borderWidth) |
|
230 |
@ |
|
231 |
(height - hScrollBar height - hScrollBar borderWidth) |
|
232 |
] |
|
233 |
]. |
|
234 |
self setScrollActions |
|
63 | 235 |
] |
0 | 236 |
! |
237 |
||
238 |
realize |
|
239 |
super realize. |
|
38 | 240 |
scrolledView notNil ifTrue:[ |
59 | 241 |
hScrollBar setThumbFor:scrolledView |
38 | 242 |
] |
0 | 243 |
! ! |
244 |
||
7 | 245 |
!HVScrollableView methodsFor:'private'! |
246 |
||
247 |
setScrollActions |
|
248 |
scrollBar scrollAction:[:position | |
|
65 | 249 |
lockUpdates := true. |
59 | 250 |
scrolledView scrollVerticalToPercent:position. |
65 | 251 |
lockUpdates := false |
7 | 252 |
]. |
253 |
scrollBar scrollUpAction:[scrolledView scrollUp]. |
|
254 |
scrollBar scrollDownAction:[scrolledView scrollDown]. |
|
255 |
||
256 |
hScrollBar scrollAction:[:position | |
|
65 | 257 |
lockUpdates := true. |
59 | 258 |
scrolledView scrollHorizontalToPercent:position. |
65 | 259 |
lockUpdates := false |
7 | 260 |
]. |
261 |
hScrollBar scrollLeftAction:[scrolledView scrollLeft]. |
|
262 |
hScrollBar scrollRightAction:[scrolledView scrollRight]. |
|
263 |
||
65 | 264 |
scrolledView addDependent:self. |
7 | 265 |
! ! |
266 |
||
105 | 267 |
!HVScrollableView methodsFor:'queries'! |
268 |
||
130 | 269 |
preferredExtent |
572 | 270 |
"return the components preferredExtent." |
271 |
||
130 | 272 |
|pref m2| |
273 |
||
802 | 274 |
"/ If I have an explicit preferredExtent .. |
275 |
||
713
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
276 |
preferredExtent notNil ifTrue:[ |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
277 |
^ preferredExtent |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
278 |
]. |
0c38ad51016d
care for preSet preferredExtent
Claus Gittinger <cg@exept.de>
parents:
678
diff
changeset
|
279 |
|
105 | 280 |
scrolledView notNil ifTrue:[ |
572 | 281 |
m2 := innerMargin * 2. |
282 |
pref := scrolledView preferredExtent. |
|
283 |
^ (pref x + scrollBar width + m2) |
|
284 |
@ |
|
285 |
(pref y + hScrollBar height + m2). |
|
105 | 286 |
]. |
130 | 287 |
^ super preferredExtent. |
572 | 288 |
|
802 | 289 |
"Modified: 19.7.1996 / 20:44:16 / cg" |
678
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
290 |
! |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
291 |
|
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
292 |
preferredExtentForLines:numLines cols:numCols |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
293 |
"return my preferredExtent for given number of lines and cols." |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
294 |
|
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
295 |
|pref m2| |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
296 |
|
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
297 |
scrolledView notNil ifTrue:[ |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
298 |
m2 := innerMargin * 2. |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
299 |
pref := scrolledView preferredExtentForLines:numLines cols:numCols. |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
300 |
^ (pref x + scrollBar width + m2) |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
301 |
@ |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
302 |
(pref y + hScrollBar height + m2). |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
303 |
]. |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
304 |
^ super preferredExtent. |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
305 |
|
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
306 |
"Modified: 23.4.1996 / 00:15:25 / cg" |
c1967a46b2c1
added query for lines/cols - prefExt
Claus Gittinger <cg@exept.de>
parents:
584
diff
changeset
|
307 |
"Created: 24.5.1996 / 17:15:43 / cg" |
105 | 308 |
! ! |
309 |
||
802 | 310 |
!HVScrollableView class methodsFor:'documentation'! |
65 | 311 |
|
216 | 312 |
version |
802 | 313 |
^ '$Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.19 1996-07-22 08:56:41 cg Exp $' |
65 | 314 |
! ! |