55 |
55 |
56 examples |
56 examples |
57 " |
57 " |
58 putting multiColListEntries into a ListView |
58 putting multiColListEntries into a ListView |
59 (instead of strings)' |
59 (instead of strings)' |
|
60 [exBegin] |
|
61 |v e myList tabs| |
|
62 |
|
63 myList := OrderedCollection new. |
|
64 |
|
65 tabs := TabulatorSpecification new. |
|
66 tabs unit:#inch. |
|
67 tabs positions:#(0 3 4). |
|
68 tabs align:#(left #center #left). |
|
69 |
|
70 e := MultiColListEntry |
|
71 fromString:'left centered left'. |
|
72 e tabulatorSpecification:tabs. |
|
73 myList add:e. |
|
74 |
|
75 e := MultiColListEntry |
|
76 fromString:'| | |'. |
|
77 e tabulatorSpecification:tabs. |
|
78 myList add:e. |
|
79 myList add:''. |
|
80 |
|
81 e := MultiColListEntry |
|
82 fromString:'hello hallo salut'. |
|
83 e tabulatorSpecification:tabs. |
|
84 myList add:e. |
|
85 |
|
86 e := MultiColListEntry |
|
87 fromString:'good morning,guten Morgen,bon jour' |
|
88 separatedBy:$,. |
|
89 e tabulatorSpecification:tabs. |
|
90 myList add:e. |
|
91 |
|
92 e := MultiColListEntry new. |
|
93 e colAt:1 put:'good bye'. |
|
94 e colAt:2 put:'auf Wiedersehen'. |
|
95 e colAt:3 put:'au revoir '. |
|
96 e tabulatorSpecification:tabs. |
|
97 myList add:e. |
|
98 |
|
99 v := ListView new. |
|
100 v setList:myList expandTabs:false. |
|
101 v extent:500@100. |
|
102 v open |
|
103 [exEnd] |
|
104 |
|
105 |
|
106 |
|
107 many multiColListEntries in a scrollable ListView |
|
108 [exBegin] |
|
109 |v l e myList tabs| |
|
110 |
|
111 myList := OrderedCollection new. |
|
112 |
|
113 tabs := TabulatorSpecification new. |
|
114 tabs unit:#cm. |
|
115 tabs positions:#(1 3 5). |
|
116 tabs align:#(#right #center #left). |
|
117 |
|
118 1 to:100 do:[:i| |
|
119 e := MultiColListEntry new. |
|
120 e colAt:1 put:i printString. |
|
121 e colAt:2 put:i squared printString. |
|
122 e colAt:3 put:i sqrt printString. |
|
123 e tabulatorSpecification:tabs. |
|
124 myList add:e. |
|
125 ]. |
|
126 l := ListView new. |
|
127 l setList:myList expandTabs:false. |
|
128 v := ScrollableView forView:l. |
|
129 v extent:300@200. |
|
130 v open |
|
131 [exEnd] |
|
132 |
|
133 |
|
134 |
|
135 like above, but uses nicer decimal alignments |
|
136 [exBegin] |
|
137 |v l e myList tabs| |
|
138 |
|
139 myList := OrderedCollection new. |
60 |
140 |
61 |v e myList tabs| |
141 tabs := TabulatorSpecification new. |
62 |
142 tabs unit:#cm. |
63 myList := OrderedCollection new. |
143 tabs positions:#(1 3 6 9 12). |
64 |
144 tabs align:#(#right #decimal #decimal #decimal #decimal). |
65 tabs := TabulatorSpecification new. |
145 |
66 tabs unit:#inch. |
146 1 to:100 do:[:i| |
67 tabs positions:#(0 3 4). |
147 e := MultiColListEntry new. |
68 tabs align:#(left #center #left). |
148 e colAt:1 put:i printString. |
69 |
149 e colAt:2 put:i log printString. |
70 e := MultiColListEntry |
150 e colAt:3 put:i sqrt printString. |
71 fromString:'left centered left'. |
151 e colAt:4 put:i sin printString. |
72 e tabulatorSpecification:tabs. |
152 e colAt:5 put:i cos printString. |
73 myList add:e. |
153 e tabulatorSpecification:tabs. |
74 |
154 myList add:e. |
75 e := MultiColListEntry |
155 ]. |
76 fromString:'| | |'. |
156 l := ListView new. |
77 e tabulatorSpecification:tabs. |
157 l setList:myList expandTabs:false. |
78 myList add:e. |
158 v := ScrollableView forView:l. |
79 myList add:''. |
159 v extent:600@200. |
80 |
160 v open |
81 e := MultiColListEntry |
161 [exEnd] |
82 fromString:'hello hallo salut'. |
|
83 e tabulatorSpecification:tabs. |
|
84 myList add:e. |
|
85 |
|
86 e := MultiColListEntry |
|
87 fromString:'good morning,guten Morgen,bon jour' |
|
88 separatedBy:$,. |
|
89 e tabulatorSpecification:tabs. |
|
90 myList add:e. |
|
91 |
|
92 e := MultiColListEntry new. |
|
93 e colAt:1 put:'good bye'. |
|
94 e colAt:2 put:'auf Wiedersehen'. |
|
95 e colAt:3 put:'au revoir '. |
|
96 e tabulatorSpecification:tabs. |
|
97 myList add:e. |
|
98 |
|
99 v := ListView new. |
|
100 v setList:myList expandTabs:false. |
|
101 v extent:500@100. |
|
102 v open |
|
103 |
|
104 |
|
105 |
|
106 many multiColListEntries in a scrollable ListView |
|
107 |
|
108 |v l e myList tabs| |
|
109 |
|
110 myList := OrderedCollection new. |
|
111 |
|
112 tabs := TabulatorSpecification new. |
|
113 tabs unit:#cm. |
|
114 tabs positions:#(1 3 5). |
|
115 tabs align:#(#right #center #left). |
|
116 |
|
117 1 to:100 do:[:i| |
|
118 e := MultiColListEntry new. |
|
119 e colAt:1 put:i printString. |
|
120 e colAt:2 put:i squared printString. |
|
121 e colAt:3 put:i sqrt printString. |
|
122 e tabulatorSpecification:tabs. |
|
123 myList add:e. |
|
124 ]. |
|
125 l := ListView new. |
|
126 l setList:myList expandTabs:false. |
|
127 v := ScrollableView forView:l. |
|
128 v extent:300@200. |
|
129 v open |
|
130 |
|
131 |
|
132 |
|
133 like above, but uses nicer decimal alignments |
|
134 |
|
135 |v l e myList tabs| |
|
136 |
|
137 myList := OrderedCollection new. |
|
138 |
|
139 tabs := TabulatorSpecification new. |
|
140 tabs unit:#cm. |
|
141 tabs positions:#(1 3 6 9 12). |
|
142 tabs align:#(#right #decimal #decimal #decimal #decimal). |
|
143 |
|
144 1 to:100 do:[:i| |
|
145 e := MultiColListEntry new. |
|
146 e colAt:1 put:i printString. |
|
147 e colAt:2 put:i log printString. |
|
148 e colAt:3 put:i sqrt printString. |
|
149 e colAt:4 put:i sin printString. |
|
150 e colAt:5 put:i cos printString. |
|
151 e tabulatorSpecification:tabs. |
|
152 myList add:e. |
|
153 ]. |
|
154 l := ListView new. |
|
155 l setList:myList expandTabs:false. |
|
156 v := ScrollableView forView:l. |
|
157 v extent:600@200. |
|
158 v open |
|
159 |
162 |
160 |
163 |
161 |
164 |
162 specifying tabs in inches |
165 specifying tabs in inches |
163 |
166 [exBegin] |
164 |v l e myList tabs| |
167 |v l e myList tabs| |
165 |
168 |
166 myList := OrderedCollection new. |
169 myList := OrderedCollection new. |
167 |
170 |
168 tabs := TabulatorSpecification new. |
171 tabs := TabulatorSpecification new. |
169 tabs unit:#inch. |
172 tabs unit:#inch. |
170 tabs positions:#(0 2 3.5 4 6 8 10 12). |
173 tabs positions:#(0 2 3.5 4 6 8 10 12). |
171 |
174 |
172 e := MultiColListEntry new. |
175 e := MultiColListEntry new. |
173 e colAt:1 put:'2'. |
176 e colAt:1 put:'2'. |
174 e colAt:2 put:'3.5'. |
177 e colAt:2 put:'3.5'. |
175 e colAt:3 put:'4'. |
178 e colAt:3 put:'4'. |
176 e colAt:4 put:'6'. |
179 e colAt:4 put:'6'. |
177 e colAt:5 put:'8'. |
180 e colAt:5 put:'8'. |
178 e colAt:6 put:'10'. |
181 e colAt:6 put:'10'. |
179 e colAt:7 put:'12'. |
182 e colAt:7 put:'12'. |
180 e tabulatorSpecification:tabs. |
183 e tabulatorSpecification:tabs. |
181 myList add:e. |
184 myList add:e. |
182 |
185 |
183 myList add:((MultiColListEntry fromString:'| | | | | | |') |
186 myList add:((MultiColListEntry fromString:'| | | | | | |') |
184 tabulatorSpecification:tabs). |
187 tabulatorSpecification:tabs). |
185 myList add:((MultiColListEntry fromString:'xxx xxx xxx xxx xxx xxx xxx') |
188 myList add:((MultiColListEntry fromString:'xxx xxx xxx xxx xxx xxx xxx') |
186 tabulatorSpecification:tabs). |
189 tabulatorSpecification:tabs). |
187 |
190 |
188 l := ListView new. |
191 l := ListView new. |
189 l setList:myList expandTabs:false. |
192 l setList:myList expandTabs:false. |
190 v := HVScrollableView forView:l. |
193 v := HVScrollableView forView:l. |
191 v extent:600@200. |
194 v extent:600@200. |
192 v open |
195 v open |
|
196 [exEnd] |
193 |
197 |
194 |
198 |
195 if you have the columns available as a collection, |
199 if you have the columns available as a collection, |
196 setup can be done easier |
200 setup can be done easier |
197 |
201 [exBegin] |
198 |v l e myList tabs| |
202 |v l e myList tabs| |
199 |
203 |
200 myList := OrderedCollection new. |
204 myList := OrderedCollection new. |
201 |
205 |
202 tabs := TabulatorSpecification new. |
206 tabs := TabulatorSpecification new. |
203 tabs unit:#inch. |
207 tabs unit:#inch. |
204 tabs positions:#(0 2 3.5 4 6 8 10 12). |
208 tabs positions:#(0 2 3.5 4 6 8 10 12). |
205 |
209 |
206 e := MultiColListEntry new. |
210 e := MultiColListEntry new. |
207 e strings:#('2' '3.5' '4' '6' '8' '10' '12'). |
211 e strings:#('2' '3.5' '4' '6' '8' '10' '12'). |
208 e tabulatorSpecification:tabs. |
212 e tabulatorSpecification:tabs. |
209 myList add:e. |
213 myList add:e. |
210 |
214 |
211 l := ListView new. |
215 l := ListView new. |
212 l setList:myList expandTabs:false. |
216 l setList:myList expandTabs:false. |
213 v := HVScrollableView forView:l. |
217 v := HVScrollableView forView:l. |
214 v extent:600@200. |
218 v extent:600@200. |
215 v open |
219 v open |
|
220 [exEnd] |
216 |
221 |
217 |
222 |
218 concrete example, show /etc/passwd in a table: |
223 concrete example, show /etc/passwd in a table: |
|
224 [exBegin] |
|
225 |
|
226 |v l s myList line e htabs tabs fingerEntry| |
|
227 |
|
228 tabs := TabulatorSpecification new. |
|
229 tabs unit:#inch. |
|
230 tabs positions:#(0 2 3.5 4.5 5 8 11). |
|
231 tabs align: #(left left right right left left left). |
|
232 |
|
233 htabs := TabulatorSpecification new. |
|
234 htabs unit:#inch. |
|
235 htabs positions:#(0 2 3.5 4.5 5 8 11). |
|
236 htabs align: #(left center center center left left left). |
|
237 |
|
238 myList := OrderedCollection new. |
|
239 |
|
240 e := MultiColListEntry |
|
241 fromString:'login-name:password:uid:gid:finger-entry:home-dir:shell' |
|
242 separatedBy:$:. |
|
243 e tabulatorSpecification:htabs. |
|
244 myList add:e. |
|
245 myList add:''. |
|
246 |
|
247 s := '/etc/passwd' asFilename readStream. |
|
248 [s atEnd] whileFalse:[ |
|
249 line := s nextLine. |
|
250 e := MultiColListEntry |
|
251 fromString:line |
|
252 separatedBy:$:. |
|
253 fingerEntry := e colAt:5. |
|
254 e colAt:5 put:(fingerEntry asCollectionOfSubstringsSeparatedBy:$,) first. |
|
255 e tabulatorSpecification:tabs. |
|
256 myList add:e. |
|
257 ]. |
|
258 s close. |
219 |
259 |
220 |v l s myList line e htabs tabs fingerEntry| |
260 l := ListView new. |
221 |
261 l setList:myList expandTabs:false. |
222 tabs := TabulatorSpecification new. |
262 v := HVScrollableView forView:l. |
223 tabs unit:#inch. |
263 v extent:600@200. |
224 tabs positions:#(0 2 3.5 4.5 5 8 11). |
264 v open |
225 tabs align: #(left left right right left left left). |
265 [exEnd] |
226 |
|
227 htabs := TabulatorSpecification new. |
|
228 htabs unit:#inch. |
|
229 htabs positions:#(0 2 3.5 4.5 5 8 11). |
|
230 htabs align: #(left center center center left left left). |
|
231 |
|
232 myList := OrderedCollection new. |
|
233 |
|
234 e := MultiColListEntry |
|
235 fromString:'login-name:password:uid:gid:finger-entry:home-dir:shell' |
|
236 separatedBy:$:. |
|
237 e tabulatorSpecification:htabs. |
|
238 myList add:e. |
|
239 myList add:''. |
|
240 |
|
241 s := '/etc/passwd' asFilename readStream. |
|
242 [s atEnd] whileFalse:[ |
|
243 line := s nextLine. |
|
244 e := MultiColListEntry |
|
245 fromString:line |
|
246 separatedBy:$:. |
|
247 fingerEntry := e colAt:5. |
|
248 e colAt:5 put:(fingerEntry asCollectionOfSubstringsSeparatedBy:$,) first. |
|
249 e tabulatorSpecification:tabs. |
|
250 myList add:e. |
|
251 ]. |
|
252 s close. |
|
253 |
|
254 l := ListView new. |
|
255 l setList:myList expandTabs:false. |
|
256 v := HVScrollableView forView:l. |
|
257 v extent:600@200. |
|
258 v open |
|
259 " |
266 " |
260 ! ! |
267 ! ! |
261 |
268 |
262 !MultiColListEntry class methodsFor:'instance creation'! |
269 !MultiColListEntry class methodsFor:'instance creation'! |
263 |
270 |