author | Claus Gittinger <cg@exept.de> |
Wed, 18 Aug 1999 16:41:24 +0200 | |
changeset 1478 | 38f08dec8e34 |
parent 1159 | eda06596899f |
child 1969 | e325d38ce469 |
permissions | -rw-r--r-- |
36 | 1 |
" |
2 |
COPYRIGHT (c) 1994 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 |
" |
|
19 | 12 |
|
58 | 13 |
ListEntry subclass:#MultiColListEntry |
158 | 14 |
instanceVariableNames:'strings tabSpec' |
15 |
classVariableNames:'DefaultTabSpec' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Support' |
|
19 | 18 |
! |
19 |
||
329 | 20 |
!MultiColListEntry class methodsFor:'documentation'! |
25 | 21 |
|
36 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1994 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
34 |
! |
|
35 |
||
25 | 36 |
documentation |
37 |
" |
|
38 |
Instances of MultiColListEntry can be used in place of strings |
|
36 | 39 |
as entries of the list in a ListView or SelectionInListView. |
34 | 40 |
They allow data to be presented in table (or any other) form. |
36 | 41 |
See example here and in TabulatorSpecs documentation. |
42 |
Notice, that each entry can have its own tabulator specification; |
|
43 |
although, usually all share a single spec. |
|
44 |
Also, notice that each column may align different; making these |
|
45 |
perfect elements to present table data. |
|
25 | 46 |
|
36 | 47 |
MultiColListEntry and TabulatorSpec were originally created to |
329 | 48 |
support nice tabular display of file-lists in the FileBrowser |
49 |
(see its long list); you may find many other uses ... |
|
158 | 50 |
|
51 |
[author:] |
|
52 |
Claus Gittinger |
|
36 | 53 |
" |
19 | 54 |
! |
55 |
||
36 | 56 |
examples |
57 |
" |
|
58 | 58 |
putting multiColListEntries into a ListView |
59 |
(instead of strings)' |
|
161 | 60 |
[exBegin] |
61 |
|v e myList tabs| |
|
19 | 62 |
|
161 | 63 |
myList := OrderedCollection new. |
19 | 64 |
|
161 | 65 |
tabs := TabulatorSpecification new. |
66 |
tabs unit:#inch. |
|
67 |
tabs positions:#(0 3 4). |
|
68 |
tabs align:#(left #center #left). |
|
19 | 69 |
|
161 | 70 |
e := MultiColListEntry |
71 |
fromString:'left centered left'. |
|
72 |
e tabulatorSpecification:tabs. |
|
73 |
myList add:e. |
|
58 | 74 |
|
161 | 75 |
e := MultiColListEntry |
76 |
fromString:'| | |'. |
|
77 |
e tabulatorSpecification:tabs. |
|
78 |
myList add:e. |
|
79 |
myList add:''. |
|
19 | 80 |
|
161 | 81 |
e := MultiColListEntry |
82 |
fromString:'hello hallo salut'. |
|
83 |
e tabulatorSpecification:tabs. |
|
84 |
myList add:e. |
|
58 | 85 |
|
161 | 86 |
e := MultiColListEntry |
87 |
fromString:'good morning,guten Morgen,bon jour' |
|
88 |
separatedBy:$,. |
|
89 |
e tabulatorSpecification:tabs. |
|
90 |
myList add:e. |
|
19 | 91 |
|
161 | 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. |
|
19 | 98 |
|
161 | 99 |
v := ListView new. |
100 |
v setList:myList expandTabs:false. |
|
101 |
v extent:500@100. |
|
102 |
v open |
|
103 |
[exEnd] |
|
36 | 104 |
|
105 |
||
106 |
||
58 | 107 |
many multiColListEntries in a scrollable ListView |
161 | 108 |
[exBegin] |
109 |
|v l e myList tabs| |
|
36 | 110 |
|
161 | 111 |
myList := OrderedCollection new. |
19 | 112 |
|
161 | 113 |
tabs := TabulatorSpecification new. |
114 |
tabs unit:#cm. |
|
115 |
tabs positions:#(1 3 5). |
|
116 |
tabs align:#(#right #center #left). |
|
19 | 117 |
|
161 | 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] |
|
36 | 132 |
|
133 |
||
134 |
||
58 | 135 |
like above, but uses nicer decimal alignments |
161 | 136 |
[exBegin] |
137 |
|v l e myList tabs| |
|
36 | 138 |
|
161 | 139 |
myList := OrderedCollection new. |
58 | 140 |
|
161 | 141 |
tabs := TabulatorSpecification new. |
142 |
tabs unit:#cm. |
|
143 |
tabs positions:#(1 3 6 9 12). |
|
144 |
tabs align:#(#right #decimal #decimal #decimal #decimal). |
|
19 | 145 |
|
161 | 146 |
1 to:100 do:[:i| |
147 |
e := MultiColListEntry new. |
|
148 |
e colAt:1 put:i printString. |
|
149 |
e colAt:2 put:i log printString. |
|
150 |
e colAt:3 put:i sqrt printString. |
|
151 |
e colAt:4 put:i sin printString. |
|
152 |
e colAt:5 put:i cos printString. |
|
153 |
e tabulatorSpecification:tabs. |
|
154 |
myList add:e. |
|
155 |
]. |
|
156 |
l := ListView new. |
|
157 |
l setList:myList expandTabs:false. |
|
158 |
v := ScrollableView forView:l. |
|
159 |
v extent:600@200. |
|
160 |
v open |
|
161 |
[exEnd] |
|
36 | 162 |
|
163 |
||
164 |
||
58 | 165 |
specifying tabs in inches |
161 | 166 |
[exBegin] |
167 |
|v l e myList tabs| |
|
19 | 168 |
|
161 | 169 |
myList := OrderedCollection new. |
19 | 170 |
|
161 | 171 |
tabs := TabulatorSpecification new. |
172 |
tabs unit:#inch. |
|
173 |
tabs positions:#(0 2 3.5 4 6 8 10 12). |
|
36 | 174 |
|
161 | 175 |
e := MultiColListEntry new. |
176 |
e colAt:1 put:'2'. |
|
177 |
e colAt:2 put:'3.5'. |
|
178 |
e colAt:3 put:'4'. |
|
179 |
e colAt:4 put:'6'. |
|
180 |
e colAt:5 put:'8'. |
|
181 |
e colAt:6 put:'10'. |
|
182 |
e colAt:7 put:'12'. |
|
183 |
e tabulatorSpecification:tabs. |
|
184 |
myList add:e. |
|
36 | 185 |
|
161 | 186 |
myList add:((MultiColListEntry fromString:'| | | | | | |') |
187 |
tabulatorSpecification:tabs). |
|
188 |
myList add:((MultiColListEntry fromString:'xxx xxx xxx xxx xxx xxx xxx') |
|
189 |
tabulatorSpecification:tabs). |
|
58 | 190 |
|
161 | 191 |
l := ListView new. |
192 |
l setList:myList expandTabs:false. |
|
193 |
v := HVScrollableView forView:l. |
|
194 |
v extent:600@200. |
|
195 |
v open |
|
196 |
[exEnd] |
|
36 | 197 |
|
198 |
||
58 | 199 |
if you have the columns available as a collection, |
200 |
setup can be done easier |
|
161 | 201 |
[exBegin] |
202 |
|v l e myList tabs| |
|
58 | 203 |
|
161 | 204 |
myList := OrderedCollection new. |
58 | 205 |
|
161 | 206 |
tabs := TabulatorSpecification new. |
207 |
tabs unit:#inch. |
|
208 |
tabs positions:#(0 2 3.5 4 6 8 10 12). |
|
58 | 209 |
|
161 | 210 |
e := MultiColListEntry new. |
211 |
e strings:#('2' '3.5' '4' '6' '8' '10' '12'). |
|
212 |
e tabulatorSpecification:tabs. |
|
213 |
myList add:e. |
|
36 | 214 |
|
161 | 215 |
l := ListView new. |
216 |
l setList:myList expandTabs:false. |
|
217 |
v := HVScrollableView forView:l. |
|
218 |
v extent:600@200. |
|
219 |
v open |
|
220 |
[exEnd] |
|
58 | 221 |
|
36 | 222 |
|
357 | 223 |
using icons instead of strings: |
224 |
[exBegin] |
|
225 |
|v l e myList tabs i1 i2 i3| |
|
226 |
||
227 |
myList := OrderedCollection new. |
|
228 |
||
229 |
tabs := TabulatorSpecification new. |
|
230 |
tabs unit:#cm. |
|
231 |
tabs positions:#(1 3 5). |
|
232 |
tabs align:#(#left #left #left). |
|
233 |
||
234 |
i1 := Image fromFile:'bitmaps/xpmBitmaps/document_images/small_dir.xpm'. |
|
235 |
i2 := Image fromFile:'bitmaps/xpmBitmaps/document_images/small_file.xpm'. |
|
236 |
i3 := Image fromFile:'bitmaps/xpmBitmaps/document_images/small_file_binary.xpm'. |
|
237 |
||
238 |
1 to:100 do:[:i| |
|
239 |
e := MultiColListEntry new. |
|
240 |
i odd ifTrue:[ |
|
241 |
e colAt:1 put:i1. |
|
242 |
] ifFalse:[ |
|
243 |
e colAt:1 put:i2 |
|
244 |
]. |
|
245 |
e colAt:2 put:i printString. |
|
246 |
e colAt:3 put:i3. |
|
247 |
e tabulatorSpecification:tabs. |
|
248 |
myList add:e. |
|
249 |
]. |
|
250 |
l := SelectionInListView new. |
|
251 |
l setList:myList expandTabs:false. |
|
252 |
v := ScrollableView forView:l. |
|
253 |
v extent:300@200. |
|
254 |
v open |
|
255 |
[exEnd] |
|
256 |
||
257 |
||
258 |
||
58 | 259 |
concrete example, show /etc/passwd in a table: |
161 | 260 |
[exBegin] |
261 |
||
262 |
|v l s myList line e htabs tabs fingerEntry| |
|
58 | 263 |
|
161 | 264 |
tabs := TabulatorSpecification new. |
265 |
tabs unit:#inch. |
|
266 |
tabs positions:#(0 2 3.5 4.5 5 8 11). |
|
267 |
tabs align: #(left left right right left left left). |
|
36 | 268 |
|
161 | 269 |
htabs := TabulatorSpecification new. |
270 |
htabs unit:#inch. |
|
271 |
htabs positions:#(0 2 3.5 4.5 5 8 11). |
|
272 |
htabs align: #(left center center center left left left). |
|
58 | 273 |
|
161 | 274 |
myList := OrderedCollection new. |
58 | 275 |
|
161 | 276 |
e := MultiColListEntry |
277 |
fromString:'login-name:password:uid:gid:finger-entry:home-dir:shell' |
|
278 |
separatedBy:$:. |
|
279 |
e tabulatorSpecification:htabs. |
|
280 |
myList add:e. |
|
281 |
myList add:''. |
|
36 | 282 |
|
161 | 283 |
s := '/etc/passwd' asFilename readStream. |
284 |
[s atEnd] whileFalse:[ |
|
285 |
line := s nextLine. |
|
286 |
e := MultiColListEntry |
|
287 |
fromString:line |
|
288 |
separatedBy:$:. |
|
289 |
fingerEntry := e colAt:5. |
|
290 |
e colAt:5 put:(fingerEntry asCollectionOfSubstringsSeparatedBy:$,) first. |
|
291 |
e tabulatorSpecification:tabs. |
|
292 |
myList add:e. |
|
293 |
]. |
|
294 |
s close. |
|
58 | 295 |
|
161 | 296 |
l := ListView new. |
297 |
l setList:myList expandTabs:false. |
|
298 |
v := HVScrollableView forView:l. |
|
299 |
v extent:600@200. |
|
300 |
v open |
|
301 |
[exEnd] |
|
36 | 302 |
" |
303 |
! ! |
|
304 |
||
329 | 305 |
!MultiColListEntry class methodsFor:'instance creation'! |
36 | 306 |
|
97 | 307 |
fromString:aString |
1159 | 308 |
"create and return a new listEntry with columns taken |
309 |
from the words of aString. Assumes that columns are |
|
310 |
separated by spaces in the string" |
|
311 |
||
97 | 312 |
^ self fromString:aString separatedBy:Character space |
313 |
! |
|
314 |
||
315 |
fromString:aString separatedBy:separatorCharacter |
|
1159 | 316 |
"create and return a new listEntry with columns taken |
317 |
from the words of aString. Assumes that columns are |
|
318 |
separated by separatorCharacter in the string" |
|
319 |
||
320 |
|subStrings e| |
|
97 | 321 |
|
322 |
e := self new. |
|
323 |
subStrings := aString asCollectionOfSubstringsSeparatedBy:separatorCharacter. |
|
324 |
subStrings keysAndValuesDo:[:i :sub | |
|
1159 | 325 |
e colAt:i put:sub. |
97 | 326 |
]. |
327 |
^ e |
|
328 |
! |
|
329 |
||
70 | 330 |
new:numberOfColumns |
1159 | 331 |
"create and return a new listEntry with numberOfColumns empty columns" |
332 |
||
70 | 333 |
|e| |
334 |
||
335 |
e := self new. |
|
336 |
1 to:numberOfColumns do:[:i | |
|
1159 | 337 |
e colAt:i put:''. |
70 | 338 |
]. |
339 |
^ e |
|
340 |
||
341 |
"Modified: 30.8.1995 / 16:33:53 / claus" |
|
342 |
! |
|
343 |
||
344 |
new:numberOfColumns tabulatorSpecification:aTabSpec |
|
1159 | 345 |
"create and return a new listEntry with numberOfColumns empty columns |
346 |
and the given tab-specification" |
|
347 |
||
70 | 348 |
^ (self new:numberOfColumns) tabulatorSpecification:aTabSpec |
349 |
||
350 |
"Modified: 30.8.1995 / 16:34:23 / claus" |
|
97 | 351 |
! ! |
352 |
||
353 |
!MultiColListEntry methodsFor:'accessing'! |
|
354 |
||
355 |
colAt:index |
|
356 |
"return the substring at column index" |
|
357 |
||
358 |
index > strings size ifTrue:[^ nil]. |
|
359 |
^ strings at:index |
|
70 | 360 |
! |
361 |
||
97 | 362 |
colAt:index put:aString |
363 |
"replace the substring at column index" |
|
364 |
||
365 |
strings isNil ifTrue:[ |
|
366 |
strings := OrderedCollection new:index |
|
367 |
]. |
|
368 |
index > strings size ifTrue:[strings grow:index]. |
|
369 |
strings at:index put:aString |
|
370 |
! |
|
371 |
||
372 |
strings:aCollectionOfStrings |
|
373 |
"replace all substrings" |
|
374 |
||
375 |
strings := OrderedCollection withAll:aCollectionOfStrings. |
|
36 | 376 |
! |
377 |
||
97 | 378 |
tabulatorSpecification:aTabSpec |
379 |
"set the tabulator spec" |
|
380 |
||
381 |
tabSpec := aTabSpec |
|
382 |
! ! |
|
383 |
||
384 |
!MultiColListEntry methodsFor:'converting'! |
|
385 |
||
386 |
asString |
|
387 |
"return the receiver as a string with embedded tabs" |
|
388 |
||
389 |
|s sub tab |
|
390 |
nSub "{ Class: SmallInteger }"| |
|
36 | 391 |
|
97 | 392 |
s := ''. |
393 |
tab := Character tab asString. |
|
394 |
nSub := strings size. |
|
395 |
1 to:nSub do:[:subStringIndex | |
|
363
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
396 |
sub := strings at:subStringIndex. |
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
397 |
sub notNil ifTrue:[ |
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
398 |
sub isString ifTrue:[ |
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
399 |
s := s , sub. |
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
400 |
] |
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
401 |
]. |
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
402 |
subStringIndex == nSub ifFalse:[ |
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
403 |
s := s , tab |
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
404 |
] |
36 | 405 |
]. |
97 | 406 |
|
407 |
^ s |
|
103 | 408 |
|
409 |
"Created: 24.11.1995 / 18:54:27 / cg" |
|
363
c025abf2d73c
care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents:
357
diff
changeset
|
410 |
"Modified: 17.4.1997 / 03:21:13 / cg" |
36 | 411 |
! ! |
412 |
||
89 | 413 |
!MultiColListEntry methodsFor:'defaults'! |
414 |
||
415 |
defaultTabSpec |
|
416 |
"the default tabulators are 1 inch apart" |
|
417 |
||
418 |
|spec| |
|
419 |
||
420 |
spec := DefaultTabSpec. |
|
421 |
spec isNil ifTrue:[ |
|
422 |
spec := TabulatorSpecification new. |
|
423 |
spec unit:#inch. |
|
424 |
spec positions:(0 to:20). |
|
425 |
spec align: #left. |
|
426 |
DefaultTabSpec := spec. |
|
427 |
]. |
|
428 |
^ spec. |
|
429 |
||
430 |
"Created: 17.11.1995 / 12:23:29 / cg" |
|
431 |
"Modified: 17.11.1995 / 12:24:20 / cg" |
|
432 |
! ! |
|
433 |
||
36 | 434 |
!MultiColListEntry methodsFor:'drawing'! |
435 |
||
108 | 436 |
displayOn:aGC x:x y:y opaque:opaque |
36 | 437 |
"display the receiver on a GC" |
438 |
||
357 | 439 |
|xPos spec tabPos prevString y0| |
36 | 440 |
|
89 | 441 |
spec := tabSpec. |
442 |
spec isNil ifTrue:[ |
|
211
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
443 |
spec := self defaultTabSpec |
89 | 444 |
]. |
36 | 445 |
xPos := x. |
446 |
prevString := ''. |
|
364 | 447 |
|
1478 | 448 |
aGC font:(aGC font onDevice:aGC device). |
366
34e1870524f1
fetch device font before querying
Claus Gittinger <cg@exept.de>
parents:
364
diff
changeset
|
449 |
|
34e1870524f1
fetch device font before querying
Claus Gittinger <cg@exept.de>
parents:
364
diff
changeset
|
450 |
y0 := y - aGC font ascent. |
357 | 451 |
|
36 | 452 |
strings keysAndValuesDo:[:index :subString | |
357 | 453 |
|item| |
454 |
||
211
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
455 |
subString notNil ifTrue:[ |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
456 |
" |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
457 |
find next tab |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
458 |
" |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
459 |
tabPos := spec positionOfTab:index forString:subString on:aGC. |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
460 |
tabPos isNil ifTrue:[ |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
461 |
" |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
462 |
no tab - just continue where we are ... |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
463 |
" |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
464 |
xPos := xPos + (prevString widthOn:aGC). "/ (aGC font widthOf:prevString). |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
465 |
] ifFalse:[ |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
466 |
xPos := tabPos + x. |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
467 |
]. |
357 | 468 |
subString isString ifFalse:[ |
469 |
item := subString. |
|
470 |
item isImage ifTrue:[ |
|
471 |
strings at:index put:(item := item on:aGC device) |
|
472 |
]. |
|
473 |
item displayOn:aGC x:xPos y:y0 |
|
474 |
] ifTrue:[ |
|
475 |
opaque ifTrue:[ |
|
476 |
aGC displayOpaqueString:subString x:xPos y:y. |
|
477 |
] ifFalse:[ |
|
478 |
aGC displayString:subString x:xPos y:y. |
|
479 |
]. |
|
480 |
]. |
|
211
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
481 |
prevString := subString. |
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
482 |
] |
36 | 483 |
]. |
89 | 484 |
|
366
34e1870524f1
fetch device font before querying
Claus Gittinger <cg@exept.de>
parents:
364
diff
changeset
|
485 |
"Modified: 19.4.1997 / 09:54:56 / cg" |
58 | 486 |
! ! |
36 | 487 |
|
58 | 488 |
!MultiColListEntry methodsFor:'queries'! |
489 |
||
357 | 490 |
heightOn:aGC |
491 |
"return the height of the receiver when displayed in aGC" |
|
492 |
||
493 |
|hMax| |
|
494 |
||
495 |
hMax := 0. |
|
496 |
strings keysAndValuesDo:[:index :subString | |
|
497 |
|h| |
|
498 |
||
499 |
subString notNil ifTrue:[ |
|
500 |
h := subString heightOn:aGC. |
|
501 |
hMax := hMax max:h. |
|
502 |
] |
|
503 |
]. |
|
504 |
^ hMax |
|
505 |
||
506 |
"Created: 15.4.1997 / 09:39:07 / cg" |
|
507 |
! |
|
508 |
||
173 | 509 |
widthOn:aGC |
58 | 510 |
"return the width of the receiver when displayed in aGC" |
511 |
||
62 | 512 |
|xPos xMax tabPos prevLen| |
58 | 513 |
|
514 |
"just to make certain: |
|
515 |
do not assume, that the last col is the rightmost one ... |
|
516 |
" |
|
517 |
xPos := 0. |
|
518 |
xMax := 0. |
|
519 |
prevLen := 0. |
|
520 |
strings keysAndValuesDo:[:index :subString | |
|
173 | 521 |
|w| |
62 | 522 |
|
173 | 523 |
subString notNil ifTrue:[ |
524 |
" |
|
525 |
find next tab |
|
526 |
" |
|
527 |
tabPos := tabSpec positionOfTab:index forString:subString on:aGC. |
|
528 |
tabPos isNil ifTrue:[ |
|
529 |
" |
|
530 |
no tab - just continue where we are ... |
|
531 |
" |
|
532 |
xPos := xPos + prevLen. |
|
533 |
] ifFalse:[ |
|
534 |
xPos := tabPos. |
|
535 |
]. |
|
211
f6e9378de69f
allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents:
173
diff
changeset
|
536 |
w := prevLen := subString widthOn:aGC. "/ aGC font widthOf:subString. |
173 | 537 |
xMax := xMax max:(xPos + w). |
538 |
] |
|
58 | 539 |
]. |
364 | 540 |
xMax isInteger ifFalse:[ |
541 |
^ xMax truncated + 1 |
|
542 |
]. |
|
58 | 543 |
^ xMax |
173 | 544 |
|
545 |
"Created: 12.5.1996 / 20:38:38 / cg" |
|
364 | 546 |
"Modified: 17.4.1997 / 12:52:00 / cg" |
58 | 547 |
! ! |
548 |
||
329 | 549 |
!MultiColListEntry class methodsFor:'documentation'! |
98 | 550 |
|
551 |
version |
|
1478 | 552 |
^ '$Header: /cvs/stx/stx/libwidg2/MultiColListEntry.st,v 1.25 1999-08-18 14:40:25 cg Exp $' |
98 | 553 |
! ! |