23 All Rights Reserved |
23 All Rights Reserved |
24 |
24 |
25 a view containing both horizontal and vertical scrollbars |
25 a view containing both horizontal and vertical scrollbars |
26 and some other (slave-)view |
26 and some other (slave-)view |
27 |
27 |
28 $Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.3 1993-10-13 02:48:04 claus Exp $ |
28 $Header: /cvs/stx/stx/libwidg/HVScrollableView.st,v 1.4 1993-12-11 01:44:59 claus Exp $ |
29 written jan 91 by claus |
29 written jan 91 by claus |
30 '! |
30 '! |
31 |
31 |
32 !HVScrollableView methodsFor:'initialization'! |
32 !HVScrollableView methodsFor:'initialization'! |
33 |
33 |
34 initializeFor:aViewClass |
34 initializeFor:aViewClass |
35 |negativeOffset halfMargin| |
35 |negativeOffset halfMargin lock| |
|
36 |
|
37 hScrollBar := HorizontalScrollBar in:self. |
36 |
38 |
37 super initializeFor:aViewClass. |
39 super initializeFor:aViewClass. |
38 |
40 |
39 negativeOffset := borderWidth negated. |
41 negativeOffset := borderWidth negated. |
40 halfMargin := innerMargin // 2. |
42 halfMargin := innerMargin // 2. |
41 |
43 |
42 "create the horizontal scrollbar and change vertical scrollbars size" |
44 "change vertical scrollbars size" |
43 |
|
44 hScrollBar := HorizontalScrollBar in:self. |
|
45 |
45 |
46 self is3D ifTrue:[ |
46 self is3D ifTrue:[ |
47 scrollBar extent:[scrollBar width |
47 scrollBar extent:[scrollBar width |
48 @ |
48 @ |
49 (height - hScrollBar height - innerMargin) |
49 (height - hScrollBar height - innerMargin) |
50 ] |
50 ] |
51 ] ifFalse:[ |
51 ] ifFalse:[ |
|
52 " |
52 aViewClass isNil ifTrue:[ |
53 aViewClass isNil ifTrue:[ |
|
54 " |
53 scrollBar extent:[scrollBar width |
55 scrollBar extent:[scrollBar width |
54 @ |
56 @ |
55 (height - hScrollBar height |
57 (height - hScrollBar height |
56 - (1 * hScrollBar borderWidth)) |
58 - (1 * hScrollBar borderWidth)) |
57 ] |
59 ] |
|
60 " |
58 ] ifFalse:[ |
61 ] ifFalse:[ |
59 scrollBar extent:[scrollBar width |
62 scrollBar extent:[scrollBar width |
60 @ |
63 @ |
61 (height - hScrollBar height |
64 (height - hScrollBar height |
62 - hScrollBar borderWidth |
65 - hScrollBar borderWidth |
63 - scrolledView borderWidth) |
66 - scrolledView borderWidth) |
64 ] |
67 ] |
65 ] |
68 ] |
|
69 " |
66 ]. |
70 ]. |
67 |
71 |
68 hScrollBar thumbOrigin:0 thumbHeight:100. |
72 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:[ |
73 self is3D ifTrue:[ |
74 hScrollBar origin:[(scrollBar origin x + scrollBar width + innerMargin) |
74 hScrollBar origin:[(scrollBar origin x + scrollBar width + innerMargin) |
75 @ |
75 @ |
76 (height - hScrollBar height - halfMargin) |
76 (height - hScrollBar height - halfMargin) |
77 ] |
77 ] |
98 scrolledView notNil ifTrue:[ |
98 scrolledView notNil ifTrue:[ |
99 scrolledView |
99 scrolledView |
100 extent:[(width |
100 extent:[(width |
101 - scrollBar width |
101 - scrollBar width |
102 - scrollBar borderWidth |
102 - scrollBar borderWidth |
103 - scrolledView borderWidth) |
103 "- scrolledView borderWidth") |
104 @ |
104 @ |
105 (height |
105 (height |
106 - hScrollBar height |
106 - hScrollBar height |
107 - hScrollBar borderWidth |
107 - hScrollBar borderWidth |
108 - scrolledView borderWidth) |
108 "- scrolledView borderWidth") |
109 ] |
109 ] |
110 ]. |
110 ]. |
111 ]. |
111 ]. |
112 |
112 |
113 scrolledView notNil ifTrue:[ |
113 scrolledView notNil ifTrue:[ |
114 scrolledView |
114 self setScrollActions |
115 originChangeAction:[:aView | scrollBar setThumbOriginFor:aView. |
|
116 hScrollBar setThumbOriginFor:aView]. |
|
117 scrolledView |
|
118 contentsChangeAction:[:aView | scrollBar setThumbFor:aView. |
|
119 hScrollBar setThumbFor:aView] |
|
120 ] |
115 ] |
121 ! |
116 ! |
122 |
117 |
123 realize |
118 realize |
124 super realize. |
119 super realize. |
125 hScrollBar setThumbFor:scrolledView |
120 hScrollBar setThumbFor:scrolledView |
126 ! ! |
121 ! ! |
127 |
122 |
|
123 !HVScrollableView methodsFor:'private'! |
|
124 |
|
125 setScrollActions |
|
126 |lock| |
|
127 |
|
128 lock := false. |
|
129 |
|
130 scrollBar scrollAction:[:position | |
|
131 lock := true. |
|
132 scrolledView scrollVerticalToPercent:position. |
|
133 lock := false |
|
134 ]. |
|
135 scrollBar scrollUpAction:[scrolledView scrollUp]. |
|
136 scrollBar scrollDownAction:[scrolledView scrollDown]. |
|
137 |
|
138 hScrollBar scrollAction:[:position | |
|
139 lock := true. |
|
140 scrolledView scrollHorizontalToPercent:position. |
|
141 lock := false |
|
142 ]. |
|
143 hScrollBar scrollLeftAction:[scrolledView scrollLeft]. |
|
144 hScrollBar scrollRightAction:[scrolledView scrollRight]. |
|
145 |
|
146 scrolledView originChangeAction:[:aView | |
|
147 lock ifFalse:[ |
|
148 scrollBar setThumbOriginFor:aView. |
|
149 hScrollBar setThumbOriginFor:aView |
|
150 ] |
|
151 ]. |
|
152 scrolledView contentsChangeAction:[:aView | |
|
153 scrollBar setThumbFor:aView. |
|
154 hScrollBar setThumbFor:aView |
|
155 ] |
|
156 ! ! |
|
157 |
128 !HVScrollableView methodsFor:'accessing'! |
158 !HVScrollableView methodsFor:'accessing'! |
129 |
159 |
|
160 horizontalScrollBar |
|
161 "return the horizontal scrollbar" |
|
162 |
|
163 ^ hScrollBar |
|
164 ! |
|
165 |
130 scrolledView:aView |
166 scrolledView:aView |
|
167 "set the scrolled view" |
|
168 |
131 super scrolledView:aView. |
169 super scrolledView:aView. |
132 |
170 |
133 "redefine subviews size" |
171 "redefine subviews size" |
134 self is3D ifFalse:[ |
172 self is3D ifFalse:[ |
135 scrolledView |
173 scrolledView |