33 " |
33 " |
34 ! |
34 ! |
35 |
35 |
36 documentation |
36 documentation |
37 " |
37 " |
38 This wrapper view allows scrolling of views (in contrast |
38 This wrapper view allows scrolling of views (in contrast to scrolling |
39 to scrolling of contents which can be done by any view). |
39 of contents which can be done by any view). |
40 |
40 |
41 Normally, scrolling is done by putting a view into a ScrollableView |
41 Normally, scrolling is done by putting a view into a ScrollableView (which |
42 (which simply wraps the scrollbars around) and have the scrollbars |
42 simply wraps the scrollbars around) and have the scrollbars send scrollUp:/ |
43 send scrollUp:/scrollDown: etc. send to the scrolledView. |
43 scrollDown: etc. send to the scrolledView. |
44 |
44 The default implementation of scrolling (in View) modifies the transformation, |
45 The default implementation of scrolling (in View) modifies the |
45 and does a bit-copy of the contents with redraw of the exposed area. |
46 transformation and does a bit-copy of the contents with redraw |
46 |
47 of the exposed area. |
47 However, there are situations, where you want to scroll a view itself. |
48 |
48 For example, if you need many buttons in a panel, which do not fit. |
49 However, there are situations, where you want to scroll a view itself. |
49 |
50 For example, if you need many buttons in a panel, which do not fit. |
50 This class provides the basic mechanism to implement this. |
51 |
51 It is a wrapper, which implements scrolling by modifying the origin of its |
52 This class provides the basic mechanism to implement this. |
52 single subview when asked to scroll. Thus, it can be put into a ScrollableView |
53 It is a wrapper, which implements scrolling by modifying the origin |
53 like any other, but will move its subview when asked to scroll instead. |
54 of its single subview when asked to scroll. Thus, it can be put |
54 (i.e. reimplement all scroll messages by manipulating its subviews origin |
55 into a ScrollableView like any other, but will move its subview |
55 instead of its contents' transformation offset) |
56 when asked to scroll instead (i.e. reimplement all scroll messages |
56 |
57 by manipulating its subviews origininstead of its contents' |
57 The subview should have a constant extent, which will be taken for the |
58 transformation offset). |
58 scrollbar position/height computation. |
59 |
59 Since the subview is represented directly by the underlying window systems view |
60 The subview should have a constant extent, which will be taken for |
60 implementation, there may be a limit on the maximum size of that view. For |
61 the scrollbar position/height computation. |
61 example, in X, dimensions may not be larger than 32767 pixels. |
62 Since the subview is represented directly by the underlying window |
62 |
63 systems view implementation, there may be a limit on the maximum size |
63 [see also:] |
64 of that view. For example, in X, dimensions may not be larger |
64 ScrollableView HVScrollableView |
65 than 32767 pixels. |
65 |
|
66 [author:] |
|
67 Claus Gittinger |
66 " |
68 " |
67 ! |
69 ! |
68 |
70 |
69 examples |
71 examples |
70 " |
72 " |
85 Button label:(i printString) in:panel |
87 Button label:(i printString) in:panel |
86 ]. |
88 ]. |
87 vscroller scrolledView:panel. |
89 vscroller scrolledView:panel. |
88 top open. |
90 top open. |
89 [exEnd] |
91 [exEnd] |
|
92 |
90 |
93 |
91 same, horizontally. Also change layout in panel for nicer look |
94 same, horizontally. Also change layout in panel for nicer look |
92 and make panel adjust its height: |
95 and make panel adjust its height: |
93 (since the buttons are defined to fill vertically, the vertical |
96 (since the buttons are defined to fill vertically, the vertical |
94 scrollbar is useless here - its here as example; not for its function) |
97 scrollbar is useless here - its here as example; not for its function) |
128 |
131 |
129 panel := VerticalPanelView new. |
132 panel := VerticalPanelView new. |
130 panel horizontalLayout:#leftSpace. |
133 panel horizontalLayout:#leftSpace. |
131 |
134 |
132 textView1 := ScrollableView for:EditTextView in:panel. |
135 textView1 := ScrollableView for:EditTextView in:panel. |
133 textView1 extent:1000 @ 300. |
136 textView1 extent:2000 @ 300. |
134 textView1 scrolledView contents:('Makefile' asFilename readStream contents). |
137 textView1 scrolledView contents:('Makefile' asFilename readStream contents). |
135 |
138 |
136 textView2 := ScrollableView for:EditTextView in:panel. |
139 textView2 := ScrollableView for:EditTextView in:panel. |
137 textView2 extent:1000 @ 300. |
140 textView2 extent:500 @ 300. |
138 textView2 scrolledView contents:('Make.proto' asFilename readStream contents). |
141 textView2 scrolledView contents:('Make.proto' asFilename readStream contents). |
139 |
142 |
140 1 to:100 do:[:i | |
143 1 to:100 do:[:i | |
141 Button label:(i printString) in:panel |
144 Button label:(i printString) in:panel |
142 ]. |
145 ]. |
191 newOrigin := 0 |
195 newOrigin := 0 |
192 ]. |
196 ]. |
193 self scrollHorizontalTo: newOrigin. |
197 self scrollHorizontalTo: newOrigin. |
194 ]. |
198 ]. |
195 |
199 |
196 "Modified: 24.5.1996 / 00:18:25 / stefan" |
200 "Modified: 24.5.1996 / 17:48:44 / cg" |
197 ! ! |
201 ! ! |
198 |
202 |
199 !ViewScroller methodsFor:'queries-contents'! |
203 !ViewScroller methodsFor:'queries-contents'! |
200 |
204 |
201 heightOfContents |
205 heightOfContents |
202 "return the height of the scrolledView" |
206 "return my contents' height; this is the scrolledViews height" |
203 |
207 |
204 ^ scrolledView height |
208 ^ scrolledView height |
205 |
209 |
206 "Modified: 24.5.1996 / 00:15:13 / stefan" |
210 "Modified: 24.5.1996 / 17:34:48 / cg" |
207 ! |
211 ! |
208 |
212 |
209 viewOrigin |
213 viewOrigin |
210 "return our origin relative to the scrolled view" |
214 "the viewOrigin (for scrollBars) is based upon the scrolledViews origin" |
211 |
215 |
212 ^ scrolledView origin negated |
216 ^ scrolledView origin negated |
213 |
217 |
214 "Modified: 24.5.1996 / 00:14:43 / stefan" |
218 "Modified: 24.5.1996 / 17:48:13 / cg" |
215 ! |
219 ! |
216 |
220 |
217 widthOfContents |
221 widthOfContents |
218 "return the width of the scrolledView" |
222 "return my contents' width; this is the scrolledViews width" |
219 |
223 |
220 ^ scrolledView width |
224 ^ scrolledView width |
221 |
225 |
222 "Modified: 24.5.1996 / 00:15:01 / stefan" |
226 "Modified: 24.5.1996 / 17:34:56 / cg" |
223 ! ! |
227 ! ! |
224 |
228 |
225 !ViewScroller methodsFor:'scrolling'! |
229 !ViewScroller methodsFor:'scrolling'! |
226 |
230 |
227 scrollDown:nPixels |
231 scrollDown:nPixels |