'From Smalltalk/X, Version:2.10.3 on 12-aug-1994 at 10:44:03 pm'!
Object subclass:#MultiColListEntry
instanceVariableNames:'strings tabSpec'
classVariableNames:''
poolDictionaries:''
category:'Views-Support'
!
!MultiColListEntry methodsFor:'accessing'!
colAt:index put:aString
strings isNil ifTrue:[
strings := OrderedCollection new:index
].
strings grow:index.
strings at:index put:aString
!
tabulatorSpecification:aTabSpec
tabSpec := aTabSpec
! !
!MultiColListEntry methodsFor:'converting'!
asString
|s tab|
s := ''.
tab := Character tab asString.
1 to:strings size do:[:subStringIndex |
s := s , (strings at:subStringIndex).
subStringIndex == strings size ifFalse:[
s := s , tab
]
].
^ s
! !
!MultiColListEntry methodsFor:'drawing'!
displayOn:aGC x:x y:y
|xPos subString tabPos w prevString|
xPos := x.
prevString := ''.
1 to:strings size do:[:index |
subString := strings at:index.
"
find next tab
"
tabPos := tabSpec positionOfTab:index forString:subString on:aGC.
tabPos isNil ifTrue:[
"
no tab - just continue where we are ...
"
xPos := xPos + (aGC font widthOf:prevString).
] ifFalse:[
xPos := tabPos + x.
].
aGC displayString:subString x:xPos y:y.
prevString := subString.
].
"
|v e myList tabs|
myList := OrderedCollection new.
tabs := TabulatorSpecification new.
tabs unit:#inch.
tabs positions:#(0 3 6).
tabs align:#(left #left #left).
e := MultiColListEntry new.
e colAt:1 put:'hello'.
e colAt:2 put:'hallo'.
e colAt:3 put:'salut'.
e tabulatorSpecification:tabs.
myList add:e.
e := MultiColListEntry new.
e colAt:1 put:'good morning'.
e colAt:2 put:'guten Morgen'.
e colAt:3 put:'bon jour'.
e tabulatorSpecification:tabs.
myList add:e.
e := MultiColListEntry new.
e colAt:1 put:'good bye'.
e colAt:2 put:'auf Wiedersehen'.
e colAt:3 put:'au revoir '.
e tabulatorSpecification:tabs.
myList add:e.
v := ListView new.
v setList:myList expandTabs:false.
v open
"
"
|v e myList tabs|
myList := OrderedCollection new.
tabs := TabulatorSpecification new.
tabs unit:#cm.
tabs positions:#(1 3 5).
tabs align:#(#right #center #left).
1 to:100 do:[:i|
e := MultiColListEntry new.
e colAt:1 put:i printString.
e colAt:2 put:i squared printString.
e colAt:3 put:i sqrt printString.
e tabulatorSpecification:tabs.
myList add:e.
].
v := ScrollableView for:ListView.
v setList:myList expandTabs:false.
v open
"
"
|v e myList tabs|
myList := OrderedCollection new.
tabs := TabulatorSpecification new.
tabs unit:#cm.
tabs positions:#(1 3 6 9 12).
tabs align:#(#right #decimal #decimal #decimal #decimal).
1 to:100 do:[:i|
e := MultiColListEntry new.
e colAt:1 put:i printString.
e colAt:2 put:i log printString.
e colAt:3 put:i sqrt printString.
e colAt:4 put:i sin printString.
e colAt:5 put:i cos printString.
e tabulatorSpecification:tabs.
myList add:e.
].
v := ScrollableView for:ListView.
v setList:myList expandTabs:false.
v open
"
"
|v e myList tabs|
myList := OrderedCollection new.
e := MultiColListEntry new.
e colAt:1 put:'2'.
e colAt:2 put:'3.5'.
e colAt:3 put:'4'.
e colAt:4 put:'6'.
e colAt:5 put:'8'.
e colAt:6 put:'10'.
e colAt:7 put:'12'.
e tabPositions:#(0 2 3.5 4 6 8 10 12); tabUnit:#inch.
myList add:e.
v := ScrollableView for:ListView.
v setList:myList expandTabs:false.
v open
"
! !