author | Claus Gittinger <cg@exept.de> |
Tue, 28 May 1996 21:19:41 +0200 | |
changeset 709 | a738bd76ace4 |
parent 706 | 54115626d33b |
child 710 | 4e1f1023d9ae |
permissions | -rw-r--r-- |
0 | 1 |
" |
5 | 2 |
COPYRIGHT (c) 1989 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 |
||
119 | 13 |
SimpleView subclass:#ScrollBar |
345 | 14 |
instanceVariableNames:'thumb button1 button2 buttonLayout elementSpacing' |
15 |
classVariableNames:'DefaultButtonPositions DefaultLevel DefaultElementSpacing |
|
16 |
DefaultScrollerBordered' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Views-Interactors' |
|
0 | 19 |
! |
20 |
||
38 | 21 |
!ScrollBar class methodsFor:'documentation'! |
0 | 22 |
|
38 | 23 |
copyright |
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
59 | 26 |
All Rights Reserved |
0 | 27 |
|
38 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
this class implements vertical scrollbars with scroller and |
|
40 |
2 step-scroll buttons. when moved or stepped, it performs a |
|
41 |
predefined action. |
|
42 |
||
43 |
The action is specified by: the block to be evaluated for step-up |
|
585 | 44 |
aScrollBar scrollUpAction:aBlock |
45 |
(scrollLeftAction for hor-Scrollbars) |
|
0 | 46 |
|
585 | 47 |
aScrollBar scrollDownAction:aBlock the block to be evaluated for step-down |
48 |
(scrollRightAction for hor-Scrollbars) |
|
38 | 49 |
|
585 | 50 |
aScrollbar scrollAction:aBlock the block to be evaluated for scroll |
51 |
passing percentage as argument. |
|
38 | 52 |
|
53 |
Scrollbars can scroll syncronous (i.e. every movement is notified immediately via the |
|
54 |
scrollAction) or asynchronous (i.e. only one notification takes place at the end of the movement). |
|
55 |
The choice is up to the user of the scrollbar (typically, views which are complicated to redraw, |
|
56 |
will set it to asynchronous.) |
|
57 |
||
58 |
Most often scrollbars are used hidden with ScrollableView or HVScrollableView (i.e. you |
|
59 |
dont have to care for all the details). |
|
128 | 60 |
|
61 |
The scrollBars and scrollers protocols have been made similar enough to |
|
62 |
allow transparent use of either a scroller or a scrollBar in applications. |
|
585 | 63 |
|
64 |
[author:] |
|
65 |
Claus Gittinger |
|
66 |
||
67 |
[see also:] |
|
68 |
Scroller Slider |
|
69 |
ScrollableView |
|
38 | 70 |
" |
0 | 71 |
! ! |
72 |
||
73 |
!ScrollBar class methodsFor:'style changes'! |
|
74 |
||
59 | 75 |
updateStyleCache |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
76 |
"extract values from the styleSheet and cache them in class variables" |
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
77 |
|
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
78 |
<resource: #style (#scrollBarButtonPositions #scrollBarLevel |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
79 |
#scrollBarScrollerBordered #scrollBarElementSpacing)> |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
80 |
|
59 | 81 |
DefaultButtonPositions := StyleSheet at:'scrollBarButtonPositions' default:#bottom. |
82 |
DefaultLevel := StyleSheet at:'scrollBarLevel'. |
|
83 |
DefaultScrollerBordered := StyleSheet at:'scrollBarScrollerBordered' default:false. |
|
84 |
DefaultElementSpacing := StyleSheet at:'scrollBarElementSpacing' |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
85 |
default:(StyleSheet is3D ifTrue:[1] ifFalse:[0]). |
440
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
86 |
|
2beb33cb0146
added style resource directive
Claus Gittinger <cg@exept.de>
parents:
345
diff
changeset
|
87 |
"Modified: 1.3.1996 / 13:46:29 / cg" |
0 | 88 |
! ! |
89 |
||
205 | 90 |
!ScrollBar methodsFor:'accessing'! |
0 | 91 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
92 |
thumbHeight |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
93 |
"return height of thumb in percent" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
94 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
95 |
^ thumb thumbHeight |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
96 |
! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
97 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
98 |
thumbHeight:newHeight |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
99 |
"set height of thumb in percent" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
100 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
101 |
thumb thumbHeight:newHeight. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
102 |
self enableDisableButtons |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
103 |
! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
104 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
105 |
thumbOrigin |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
106 |
"return position of (top of) thumb in percent" |
205 | 107 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
108 |
^ thumb thumbOrigin |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
109 |
! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
110 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
111 |
thumbOrigin:newOrigin |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
112 |
"set position of (top of) thumb in percent" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
113 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
114 |
thumb thumbOrigin:newOrigin. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
115 |
self enableDisableButtons |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
116 |
! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
117 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
118 |
thumbOrigin:newOrigin thumbHeight:newHeight |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
119 |
"set origin and height of thumb (both in percent)" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
120 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
121 |
thumb thumbOrigin:newOrigin thumbHeight:newHeight. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
122 |
self enableDisableButtons |
455 | 123 |
! ! |
124 |
||
125 |
!ScrollBar methodsFor:'accessing-behavior'! |
|
126 |
||
127 |
asynchronousOperation |
|
128 |
"set asynchronous-mode - scroll action is performed after movement |
|
129 |
of scroller (i.e. when mouse-button is finally released). |
|
130 |
This is forwarded to the scroller here." |
|
131 |
||
132 |
thumb asynchronousOperation |
|
133 |
! |
|
134 |
||
135 |
scrollAction:aBlock |
|
136 |
"set the action, aBlock to be performed when the scroller is moved. |
|
137 |
This is forwarded to the scroller here." |
|
138 |
||
139 |
thumb scrollAction:aBlock |
|
140 |
! |
|
141 |
||
142 |
scrollDownAction:aBlock |
|
143 |
"set the action, aBlock to be performed when the down-button is pressed." |
|
144 |
||
145 |
button2 action:aBlock |
|
146 |
! |
|
147 |
||
148 |
scrollUpAction:aBlock |
|
149 |
"set the action, aBlock to be performed when the up-button is pressed." |
|
150 |
||
151 |
button1 action:aBlock |
|
152 |
! |
|
153 |
||
154 |
synchronousOperation |
|
155 |
"set synchronous-mode - scroll action is performed for every movement |
|
156 |
of scroller. |
|
157 |
This is forwarded to the scroller here." |
|
158 |
||
159 |
thumb synchronousOperation |
|
160 |
! ! |
|
161 |
||
162 |
!ScrollBar methodsFor:'accessing-components'! |
|
163 |
||
164 |
downButton |
|
165 |
"return the down-button |
|
166 |
(Please: only use this direct access for special applications)" |
|
167 |
||
168 |
^ button2 |
|
169 |
||
170 |
" |
|
171 |
|v| |
|
172 |
||
173 |
v := ScrollableView for:EditTextView. |
|
174 |
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile). |
|
175 |
v scrollBar upButton activeForegroundColor:Color red. |
|
176 |
v scrollBar downButton activeForegroundColor:Color red. |
|
177 |
v open |
|
178 |
" |
|
179 |
! |
|
180 |
||
181 |
thumb |
|
182 |
"return the thumb (i.e. the scroller subview) |
|
183 |
(Please: only use this direct access for special applications)" |
|
184 |
||
185 |
^ thumb |
|
186 |
||
187 |
" |
|
188 |
|v| |
|
189 |
||
190 |
v := ScrollableView for:EditTextView. |
|
191 |
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile). |
|
192 |
v scrollBar thumb thumbColor:(Color red). |
|
193 |
v open |
|
194 |
" |
|
195 |
||
196 |
"Modified: 1.3.1996 / 19:15:50 / cg" |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
197 |
! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
198 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
199 |
upButton |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
200 |
"return the up-button |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
201 |
(Please: only use this direct access for special applications)" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
202 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
203 |
^ button1 |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
204 |
|
448
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
205 |
" |
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
206 |
|v| |
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
207 |
|
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
208 |
v := ScrollableView for:EditTextView. |
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
209 |
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile). |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
210 |
v scrollBar upButton foregroundColor:(Color red). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
211 |
v scrollBar upButton enteredForegroundColor:(Color red lightened). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
212 |
v scrollBar downButton foregroundColor:(Color green). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
213 |
v scrollBar downButton enteredForegroundColor:(Color green lightened). |
448
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
214 |
v open |
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
215 |
" |
455 | 216 |
! ! |
217 |
||
218 |
!ScrollBar methodsFor:'accessing-look'! |
|
219 |
||
220 |
thumbColor:aColor |
|
221 |
"set the thumbs color" |
|
222 |
||
223 |
thumb thumbColor:aColor |
|
205 | 224 |
! |
128 | 225 |
|
133 | 226 |
upButtonLabel:label1 downButtonLabel:label2 |
446 | 227 |
"set the labels shown in the buttons. |
228 |
Because of the fixed button sizes, this only makes sense with |
|
229 |
single-character strings or small bitmaps." |
|
133 | 230 |
|
231 |
button1 label:label1. |
|
232 |
button2 label:label2. |
|
233 |
self setElementPositions. |
|
234 |
||
446 | 235 |
"not bad: |
133 | 236 |
|v| |
237 |
||
238 |
v := ScrollableView for:EditTextView. |
|
239 |
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile). |
|
240 |
v scrollBar upButtonLabel:'+' downButtonLabel:'-'. |
|
241 |
v open |
|
242 |
" |
|
446 | 243 |
|
244 |
"also possible : |
|
245 |
|v| |
|
246 |
||
247 |
v := ScrollableView for:EditTextView. |
|
248 |
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile). |
|
249 |
v scrollBar upButtonLabel:'u' downButtonLabel:'d'. |
|
250 |
v open |
|
251 |
" |
|
252 |
||
253 |
"BAD example: |
|
254 |
|v| |
|
255 |
||
256 |
v := ScrollableView for:EditTextView. |
|
257 |
v scrolledView contents:('/etc/passwd' asFilename contentsOfEntireFile). |
|
258 |
v scrollBar upButtonLabel:'up' downButtonLabel:'down'. |
|
259 |
v open |
|
260 |
" |
|
261 |
||
262 |
"Modified: 1.3.1996 / 19:06:50 / cg" |
|
205 | 263 |
! ! |
264 |
||
265 |
!ScrollBar methodsFor:'change & update'! |
|
0 | 266 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
267 |
update:something with:aParameter from:changedObject |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
268 |
changedObject == thumb ifTrue:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
269 |
self enableDisableButtons |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
270 |
] |
0 | 271 |
! ! |
272 |
||
273 |
!ScrollBar methodsFor:'events'! |
|
274 |
||
482
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
275 |
keyPress:key x:x y:y |
491 | 276 |
|
277 |
<resource: #keyboard (#BeginOfText #EndOfText)> |
|
278 |
||
482
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
279 |
(key == #BeginOfText) ifTrue:[ |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
280 |
self scrollToBeginning. |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
281 |
^ self |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
282 |
]. |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
283 |
(key == #EndOfText) ifTrue:[ |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
284 |
self scrollToEnd. |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
285 |
^ self |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
286 |
]. |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
287 |
super keyPress:key x:x y:y |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
288 |
|
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
289 |
"Created: 6.3.1996 / 17:58:02 / cg" |
491 | 290 |
"Modified: 7.3.1996 / 13:18:19 / cg" |
482
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
291 |
! |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
292 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
293 |
sizeChanged:how |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
294 |
"when my size changes, I have to resize/reposition the subviews. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
295 |
Also, if I became too small, hide thumb/buttons." |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
296 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
297 |
|upHeight downHeight thumbHeight upAndDownHeight bwn sep2 |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
298 |
thumbWidth w style b1Hidden b2Hidden thumbHidden bY| |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
299 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
300 |
button1 isNil ifTrue:[^ self]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
301 |
thumb isNil ifTrue:[^ self]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
302 |
button2 isNil ifTrue:[^ self]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
303 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
304 |
style := styleSheet name. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
305 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
306 |
upHeight := button1 height + borderWidth. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
307 |
downHeight := button2 height + borderWidth. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
308 |
upAndDownHeight := upHeight + downHeight. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
309 |
bwn := borderWidth negated + margin. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
310 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
311 |
thumbHeight := height - upAndDownHeight - borderWidth - (elementSpacing * 3). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
312 |
" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
313 |
((buttonLayout ~~ #top) and:[buttonLayout ~~ #bottom]) ifTrue:[ |
613 | 314 |
thumbHeight := thumbHeight - borderWidth |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
315 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
316 |
" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
317 |
buttonLayout == #around ifTrue:[ |
613 | 318 |
thumbHeight := thumbHeight + borderWidth |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
319 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
320 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
321 |
"if I become too small, hide buttons and thumb" |
0 | 322 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
323 |
height < upAndDownHeight ifTrue:[ |
613 | 324 |
b1Hidden := b2Hidden := thumbHidden := true. |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
325 |
] ifFalse:[ |
613 | 326 |
b1Hidden := b2Hidden := thumbHidden := false. |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
327 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
328 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
329 |
(thumbHeight < 10) ifTrue:[ |
613 | 330 |
thumbHidden := true. |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
331 |
] ifFalse:[ |
613 | 332 |
thumbHidden := false. |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
333 |
]. |
130 | 334 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
335 |
button1 hiddenOnRealize:b1Hidden. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
336 |
b1Hidden ifTrue:[ |
613 | 337 |
button1 unmap |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
338 |
] ifFalse:[ |
613 | 339 |
shown ifTrue:[button1 realize] |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
340 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
341 |
button2 hiddenOnRealize:b1Hidden. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
342 |
b2Hidden ifTrue:[ |
613 | 343 |
button2 unmap |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
344 |
] ifFalse:[ |
613 | 345 |
shown ifTrue:[button2 realize] |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
346 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
347 |
thumb hiddenOnRealize:thumbHidden. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
348 |
thumbHidden ifTrue:[ |
613 | 349 |
thumb unmap |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
350 |
] ifFalse:[ |
613 | 351 |
shown ifTrue:[thumb realize] |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
352 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
353 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
354 |
"width of buttons is always my width" |
0 | 355 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
356 |
w := width - (margin * 2). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
357 |
(w ~~ button1 width) ifTrue:[ |
613 | 358 |
button1 width:w. |
359 |
button2 width:w |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
360 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
361 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
362 |
thumbWidth := w. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
363 |
style == #next ifTrue:[ |
613 | 364 |
thumbWidth := thumbWidth - (thumb borderWidth * 2). |
365 |
thumbHeight := thumbHeight - 1 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
366 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
367 |
style == #motif ifTrue:[ |
613 | 368 |
thumbHeight := thumbHeight - margin |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
369 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
370 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
371 |
" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
372 |
a kludge: views with width or height of 0 are illegal |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
373 |
avoid error from view-creation (it will be hidden anyway) |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
374 |
" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
375 |
thumbHeight <= 0 ifTrue:[ |
613 | 376 |
thumbHeight := 1 |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
377 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
378 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
379 |
(buttonLayout == #top) ifTrue:[ |
613 | 380 |
"buttons at top" |
381 |
thumb extent:(thumbWidth @ thumbHeight). |
|
382 |
^ self |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
383 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
384 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
385 |
sep2 := elementSpacing * 2. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
386 |
(buttonLayout == #bottom) ifTrue:[ |
613 | 387 |
"buttons at bottom" |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
388 |
"/ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
389 |
"/ XX: I thought, that viewGravity shuld fix things automatically |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
390 |
"/ XX: it seems not to do it (or I misused it ;-) |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
391 |
"/ XX: anyway, viewGravity is an X special feature which is probably |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
392 |
"/ XX: not available with other windowing systems. Therefore, |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
393 |
"/ XX: the viewGravity depending code below is disabled. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
394 |
"/ XX: resize is somewhat slower, though. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
395 |
|
613 | 396 |
thumbHeight := thumbHeight + borderWidth. |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
397 |
"/ XX thumbHidden ifTrue:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
398 |
"/ XX bY := elementSpacing |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
399 |
"/ XX ] ifFalse:[ |
613 | 400 |
bY := thumbHeight + sep2. |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
401 |
"/ XX ]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
402 |
"XX" button1 viewGravity:#North. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
403 |
"XX" button2 viewGravity:#North. |
613 | 404 |
(how == #smaller) ifTrue:[ |
405 |
thumb extent:(thumbWidth @ thumbHeight). |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
406 |
"XX" button1 origin:(bwn @ (thumbHeight + sep2)). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
407 |
"XX" button2 origin:(bwn @ (thumbHeight + sep2 + upHeight)) |
613 | 408 |
] ifFalse:[ |
409 |
button1 origin:(bwn @ bY). |
|
410 |
button2 origin:(bwn @ (bY + upHeight)). |
|
411 |
thumb extent:(thumbWidth @ thumbHeight) |
|
412 |
]. |
|
413 |
^ self |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
414 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
415 |
"buttons around thumb" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
416 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
417 |
style == #motif ifTrue:[ |
613 | 418 |
sep2 := sep2 + 1 |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
419 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
420 |
button1 origin:(bwn @ bwn). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
421 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
422 |
style == #os2 ifTrue:[ |
613 | 423 |
button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - margin "+ borderWidth")). |
424 |
thumb extent:(thumbWidth @ (thumbHeight - margin - margin "+ margin - (margin // 2)")). |
|
425 |
thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing + margin)) |
|
448
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
426 |
] ifFalse:[ |
613 | 427 |
button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - (margin // 2) "+ borderWidth")). |
428 |
thumb extent:(thumbWidth @ (thumbHeight + margin - (margin // 2))). |
|
429 |
thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing)) |
|
63 | 430 |
]. |
613 | 431 |
|
432 |
"Modified: 3.5.1996 / 23:49:02 / stefan" |
|
0 | 433 |
! ! |
110 | 434 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
435 |
!ScrollBar methodsFor:'forced scroll'! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
436 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
437 |
pageDown |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
438 |
"page down/right" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
439 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
440 |
thumb pageDown |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
441 |
! |
205 | 442 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
443 |
pageUp |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
444 |
"page up/left" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
445 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
446 |
thumb pageUp |
482
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
447 |
! |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
448 |
|
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
449 |
scrollToBeginning |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
450 |
"to top" |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
451 |
|
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
452 |
thumb scrollToBeginning |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
453 |
|
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
454 |
"Modified: 6.3.1996 / 17:54:45 / cg" |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
455 |
! |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
456 |
|
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
457 |
scrollToEnd |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
458 |
"to end" |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
459 |
|
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
460 |
thumb scrollToEnd |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
461 |
|
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
462 |
"Created: 6.3.1996 / 17:54:28 / cg" |
f4d7344ae396
added scrollToBeginning/scrollToEnd & key-handling for them
Claus Gittinger <cg@exept.de>
parents:
455
diff
changeset
|
463 |
"Modified: 6.3.1996 / 17:54:49 / cg" |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
464 |
! ! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
465 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
466 |
!ScrollBar methodsFor:'initialization'! |
205 | 467 |
|
455 | 468 |
createElements |
469 |
button1 := ArrowButton upIn:self. |
|
470 |
button2 := ArrowButton downIn:self. |
|
471 |
thumb := Scroller in:self. |
|
472 |
! |
|
473 |
||
448
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
474 |
defaultExtent |
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
475 |
"compute my extent from sub-components" |
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
476 |
|
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
477 |
^ self preferredExtent |
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
478 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
479 |
|
448
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
480 |
"Created: 1.3.1996 / 19:22:11 / cg" |
205 | 481 |
! |
482 |
||
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
483 |
initStyle |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
484 |
super initStyle. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
485 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
486 |
buttonLayout := DefaultButtonPositions. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
487 |
DefaultLevel notNil ifTrue:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
488 |
self level:DefaultLevel |
205 | 489 |
]. |
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
490 |
elementSpacing := DefaultElementSpacing |
205 | 491 |
! |
492 |
||
493 |
initialize |
|
494 |
"setup; create the 2 buttons and a scroller" |
|
495 |
||
496 |
|clr style| |
|
497 |
||
498 |
super initialize. |
|
499 |
||
500 |
self createElements. |
|
501 |
||
502 |
(styleSheet at:'scrollBarDisableButtons' default:false) ifTrue:[ |
|
706 | 503 |
thumb addDependent:self |
205 | 504 |
]. |
505 |
||
345 | 506 |
button1 autoRepeat:true. |
507 |
button2 autoRepeat:true. |
|
205 | 508 |
|
509 |
button1 borderWidth:borderWidth. |
|
510 |
DefaultScrollerBordered ifFalse:[ |
|
706 | 511 |
thumb borderWidth:borderWidth. |
205 | 512 |
]. |
513 |
button2 borderWidth:borderWidth. |
|
514 |
||
515 |
style := styleSheet name. |
|
709 | 516 |
((style = #iris) and:[Display hasGrayscales]) ifTrue:[ |
706 | 517 |
"have to change some of Buttons defaults" |
518 |
clr := (Color gray:25) on:device. |
|
519 |
button1 offLevel:2. |
|
520 |
button2 offLevel:2. |
|
521 |
button1 foregroundColor:clr. |
|
522 |
button1 activeForegroundColor:clr. |
|
523 |
button1 enteredForegroundColor:clr. |
|
524 |
button2 foregroundColor:clr. |
|
525 |
button2 activeForegroundColor:clr. |
|
526 |
button2 enteredForegroundColor:clr. |
|
205 | 527 |
]. |
528 |
||
529 |
self setElementPositions. |
|
530 |
||
531 |
style = #motif ifTrue:[ |
|
706 | 532 |
clr := thumb thumbColor. |
533 |
button1 foregroundColor:clr. |
|
534 |
button2 foregroundColor:clr. |
|
345 | 535 |
|
706 | 536 |
clr := thumb viewBackground. |
537 |
button1 viewBackground:clr. |
|
538 |
button2 viewBackground:clr. |
|
539 |
button1 backgroundColor:clr. |
|
540 |
button2 backgroundColor:clr. |
|
541 |
button1 activeBackgroundColor:clr. |
|
542 |
button2 activeBackgroundColor:clr. |
|
709 | 543 |
device hasGrayscales ifFalse:[ |
706 | 544 |
button1 activeForegroundColor:Black. |
545 |
button2 activeForegroundColor:Black. |
|
546 |
] |
|
448
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
547 |
] |
e23465aad9e8
use new defaultExtent protocol
Claus Gittinger <cg@exept.de>
parents:
446
diff
changeset
|
548 |
|
709 | 549 |
"Modified: 28.5.1996 / 21:13:25 / cg" |
205 | 550 |
! |
551 |
||
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
552 |
reinitialize |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
553 |
super reinitialize. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
554 |
self setElementPositions. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
555 |
! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
556 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
557 |
setElementPositions |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
558 |
"position sub-components" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
559 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
560 |
|bwn| |
205 | 561 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
562 |
bwn := borderWidth negated + margin. |
205 | 563 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
564 |
(buttonLayout == #top) ifTrue:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
565 |
button1 origin:(bwn @ bwn). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
566 |
button1 viewGravity:#North. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
567 |
button2 origin:(bwn @ (button1 height)). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
568 |
button2 viewGravity:#North. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
569 |
thumb origin:(bwn @ (button1 height |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
570 |
+ borderWidth |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
571 |
+ button2 height |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
572 |
+ elementSpacing |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
573 |
+ elementSpacing)). |
205 | 574 |
thumb viewGravity:#North. |
575 |
^ self |
|
576 |
]. |
|
577 |
(buttonLayout == #bottom) ifTrue:[ |
|
578 |
device supportsViewGravity ifTrue:[ |
|
579 |
button1 viewGravity:#South. |
|
580 |
button2 viewGravity:#South. |
|
581 |
thumb viewGravity:#North. |
|
582 |
]. |
|
583 |
thumb origin:(bwn @ bwn). |
|
584 |
^ self |
|
585 |
]. |
|
586 |
||
587 |
"buttonLayout == #around" |
|
588 |
button1 origin:(bwn @ bwn). |
|
589 |
button1 viewGravity:#North. |
|
590 |
"/ button2 viewGravity:#North. |
|
591 |
thumb origin:(bwn @ (button1 height + elementSpacing)). |
|
592 |
thumb viewGravity:#North |
|
593 |
! ! |
|
594 |
||
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
595 |
!ScrollBar methodsFor:'private'! |
205 | 596 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
597 |
enableDisableButtons |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
598 |
"only used with styles which disable their buttons if the |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
599 |
thumb is at either end. Check where the thumb is and enable/disable |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
600 |
as appropriate." |
205 | 601 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
602 |
|e1 e2 th to| |
205 | 603 |
|
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
604 |
(styleSheet at:'scrollBarDisableButtons' default:false) ifFalse:[^ self]. |
110 | 605 |
|
205 | 606 |
e1 := e2 := true. |
607 |
(th := thumb thumbHeight) notNil ifTrue:[ |
|
608 |
(th >= (thumb stop)) ifTrue:[ |
|
609 |
e1 := false. |
|
610 |
e2 := false |
|
611 |
] |
|
612 |
]. |
|
613 |
((to := thumb thumbOrigin) <= thumb start) ifTrue:[ |
|
614 |
e1 := false |
|
615 |
] ifFalse:[ |
|
616 |
th isNil ifTrue:[th := 0]. |
|
617 |
(to + th) >= thumb stop ifTrue:[ |
|
618 |
e2 := false |
|
619 |
] |
|
620 |
]. |
|
621 |
e1 ifTrue:[button1 enable] ifFalse:[button1 disable]. |
|
622 |
e2 ifTrue:[button2 enable] ifFalse:[button2 disable]. |
|
623 |
! ! |
|
624 |
||
455 | 625 |
!ScrollBar methodsFor:'private scrollview interface'! |
626 |
||
627 |
setThumbFor:aView |
|
628 |
"adjust thumb for aView |
|
629 |
(i.e. adjust thumbs origin & size for views size & views contents). |
|
630 |
This is forwarded to the scroller here." |
|
631 |
||
632 |
thumb setThumbFor:aView. |
|
633 |
self enableDisableButtons |
|
634 |
! |
|
635 |
||
636 |
setThumbHeightFor:aView |
|
637 |
"adjust thumbs height for aViews size & contents. |
|
638 |
This is forwarded to the scroller here." |
|
639 |
||
640 |
thumb setThumbHeightFor:aView. |
|
641 |
self enableDisableButtons |
|
642 |
! |
|
643 |
||
644 |
setThumbOriginFor:aView |
|
645 |
"adjust thumbs origin for aViews size & contents. |
|
646 |
This is forwarded to the scroller here." |
|
647 |
||
648 |
thumb setThumbOriginFor:aView. |
|
649 |
self enableDisableButtons |
|
650 |
! ! |
|
651 |
||
453
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
652 |
!ScrollBar methodsFor:'queries'! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
653 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
654 |
preferredExtent |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
655 |
"compute my extent from sub-components" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
656 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
657 |
|w h upForm downForm |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
658 |
upHeight "{ Class: SmallInteger }" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
659 |
downHeight "{ Class: SmallInteger }" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
660 |
upWidth downWidth style| |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
661 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
662 |
" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
663 |
need fix - this is a kludge; |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
664 |
the if should not be needed ... |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
665 |
" |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
666 |
style := styleSheet name. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
667 |
style == #mswindows ifTrue:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
668 |
w := button1 width max:button2 width. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
669 |
h := button1 height + button2 height + (Scroller defaultExtent y). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
670 |
] ifFalse:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
671 |
upForm := ArrowButton upArrowButtonForm:style on:device. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
672 |
downForm := ArrowButton downArrowButtonForm:style on:device. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
673 |
upForm isNil ifTrue:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
674 |
upHeight := upWidth := 16. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
675 |
] ifFalse:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
676 |
upHeight := upForm height. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
677 |
upWidth := upForm width |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
678 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
679 |
downForm isNil ifTrue:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
680 |
downHeight := downWidth := 16 |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
681 |
] ifFalse:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
682 |
downHeight := downForm height. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
683 |
downWidth := downForm width |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
684 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
685 |
h := upHeight + downHeight + (1 * 2) + (Scroller defaultExtent y). |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
686 |
w := upWidth max:downWidth. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
687 |
style ~~ #normal ifTrue:[ |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
688 |
h := h + 4. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
689 |
w := w + 4 |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
690 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
691 |
]. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
692 |
|
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
693 |
^ w @ h. |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
694 |
! ! |
dc035dd8b9eb
oops - checked in corrupted files
Claus Gittinger <cg@exept.de>
parents:
448
diff
changeset
|
695 |
|
205 | 696 |
!ScrollBar class methodsFor:'documentation'! |
697 |
||
698 |
version |
|
709 | 699 |
^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.32 1996-05-28 19:18:38 cg Exp $' |
205 | 700 |
! ! |