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