|
1 " |
|
2 COPYRIGHT (c) 1991-93 by Claus Gittinger |
|
3 All Rights Reserved |
|
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 |
|
22 COPYRIGHT (c) 1991-93 by Claus Gittinger |
|
23 All Rights Reserved |
|
24 |
|
25 a view containing both horizontal and vertical scrollbars |
|
26 and some other (slave-)view |
|
27 |
|
28 %W% %E% |
|
29 written jan 91 by claus |
|
30 '! |
|
31 |
|
32 !HVScrollableView methodsFor:'initialization'! |
|
33 |
|
34 initializeFor:aViewClass |
|
35 |negativeOffset halfMargin| |
|
36 |
|
37 super initializeFor:aViewClass. |
|
38 |
|
39 negativeOffset := borderWidth negated. |
|
40 halfMargin := innerMargin // 2. |
|
41 |
|
42 "create the horizontal scrollbar and change vertical scrollbars size" |
|
43 |
|
44 hScrollBar := HorizontalScrollBar in:self. |
|
45 |
|
46 self is3D ifTrue:[ |
|
47 scrollBar extent:[scrollBar width |
|
48 @ |
|
49 (height - hScrollBar height - innerMargin) |
|
50 ] |
|
51 ] ifFalse:[ |
|
52 aViewClass isNil ifTrue:[ |
|
53 scrollBar extent:[scrollBar width |
|
54 @ |
|
55 (height - hScrollBar height |
|
56 - (1 * hScrollBar borderWidth)) |
|
57 ] |
|
58 ] ifFalse:[ |
|
59 scrollBar extent:[scrollBar width |
|
60 @ |
|
61 (height - hScrollBar height |
|
62 - hScrollBar borderWidth |
|
63 - scrolledView borderWidth) |
|
64 ] |
|
65 ] |
|
66 ]. |
|
67 |
|
68 hScrollBar thumbOrigin:0 thumbHeight:100. |
|
69 hScrollBar scrollAction:[:position | |
|
70 scrolledView scrollHorizontalToPercent:position]. |
|
71 hScrollBar scrollLeftAction:[scrolledView scrollLeft]. |
|
72 hScrollBar scrollRightAction:[scrolledView scrollRight]. |
|
73 self is3D ifTrue:[ |
|
74 hScrollBar origin:[(scrollBar origin x + scrollBar width + innerMargin) |
|
75 @ |
|
76 (height - hScrollBar height - halfMargin) |
|
77 ] |
|
78 extent:[(width - scrollBar width - (innerMargin * 2)) |
|
79 @ |
|
80 hScrollBar height |
|
81 ] |
|
82 ] ifFalse:[ |
|
83 hScrollBar origin:[(scrollBar origin x + scrollBar width + scrollBar borderWidth) |
|
84 @ |
|
85 (height - hScrollBar height - (hScrollBar borderWidth "* 2")) |
|
86 ] |
|
87 extent:[(width - scrollBar width) @ hScrollBar height |
|
88 ] |
|
89 ]. |
|
90 |
|
91 "redefine subviews size" |
|
92 self is3D ifTrue:[ |
|
93 helpView extent:[(width - scrollBar width - (innerMargin * 2)) |
|
94 @ |
|
95 (height - hScrollBar height - (innerMargin * 2)) |
|
96 ] |
|
97 ] ifFalse:[ |
|
98 scrolledView notNil ifTrue:[ |
|
99 scrolledView |
|
100 extent:[(width |
|
101 - scrollBar width |
|
102 - scrollBar borderWidth |
|
103 - scrolledView borderWidth) |
|
104 @ |
|
105 (height |
|
106 - hScrollBar height |
|
107 - hScrollBar borderWidth |
|
108 - scrolledView borderWidth) |
|
109 ] |
|
110 ]. |
|
111 ]. |
|
112 |
|
113 scrolledView notNil ifTrue:[ |
|
114 scrolledView |
|
115 originChangeAction:[:aView | scrollBar setThumbOriginFor:aView. |
|
116 hScrollBar setThumbOriginFor:aView]. |
|
117 scrolledView |
|
118 contentsChangeAction:[:aView | scrollBar setThumbFor:aView. |
|
119 hScrollBar setThumbFor:aView] |
|
120 ] |
|
121 ! |
|
122 |
|
123 realize |
|
124 super realize. |
|
125 hScrollBar setThumbFor:scrolledView |
|
126 ! ! |
|
127 |
|
128 !HVScrollableView methodsFor:'accessing'! |
|
129 |
|
130 scrolledView:aView |
|
131 super scrolledView:aView. |
|
132 |
|
133 "redefine subviews size" |
|
134 self is3D ifFalse:[ |
|
135 scrolledView |
|
136 extent:[(width |
|
137 - scrollBar width |
|
138 - scrollBar borderWidth |
|
139 "- scrolledView borderWidth") |
|
140 @ |
|
141 (height |
|
142 - hScrollBar height |
|
143 - hScrollBar borderWidth |
|
144 "- scrolledView borderWidth") |
|
145 ] |
|
146 ]. |
|
147 |
|
148 scrolledView |
|
149 originChangeAction:[:aView | scrollBar setThumbOriginFor:aView. |
|
150 hScrollBar setThumbOriginFor:aView]. |
|
151 scrolledView |
|
152 contentsChangeAction:[:aView | scrollBar setThumbFor:aView. |
|
153 hScrollBar setThumbFor:aView] |
|
154 ! ! |
|
155 |
|
156 !HVScrollableView methodsFor:'event processing'! |
|
157 |
|
158 sizeChanged:how |
|
159 super sizeChanged:how. |
|
160 hScrollBar setThumbFor:scrolledView |
|
161 ! ! |