diff -r 457286c379f9 -r 306cb0aa67be MultiColListEntry.st --- a/MultiColListEntry.st Thu Nov 23 03:25:38 1995 +0100 +++ b/MultiColListEntry.st Thu Nov 23 03:29:00 1995 +0100 @@ -10,8 +10,6 @@ hereby transferred. " -'From Smalltalk/X, Version:2.10.5 on 15-may-1995 at 9:15:44 am'! - ListEntry subclass:#MultiColListEntry instanceVariableNames:'strings tabSpec' classVariableNames:'DefaultTabSpec' @@ -35,10 +33,6 @@ " ! -version - ^ '$Header: /cvs/stx/stx/libwidg2/MultiColListEntry.st,v 1.9 1995-11-17 17:23:36 cg Exp $' -! - documentation " Instances of MultiColListEntry can be used in place of strings @@ -260,10 +254,29 @@ v extent:600@200. v open " +! + +version + ^ '$Header: /cvs/stx/stx/libwidg2/MultiColListEntry.st,v 1.10 1995-11-23 02:28:32 cg Exp $' ! ! !MultiColListEntry class methodsFor:'instance creation'! +fromString:aString + ^ self fromString:aString separatedBy:Character space +! + +fromString:aString separatedBy:separatorCharacter + |subStrings e| + + e := self new. + subStrings := aString asCollectionOfSubstringsSeparatedBy:separatorCharacter. + subStrings keysAndValuesDo:[:i :sub | + e colAt:i put:sub. + ]. + ^ e +! + new:numberOfColumns |e| @@ -280,21 +293,61 @@ ^ (self new:numberOfColumns) tabulatorSpecification:aTabSpec "Modified: 30.8.1995 / 16:34:23 / claus" +! ! + +!MultiColListEntry methodsFor:'accessing'! + +colAt:index + "return the substring at column index" + + index > strings size ifTrue:[^ nil]. + ^ strings at:index ! -fromString:aString - ^ self fromString:aString separatedBy:Character space +colAt:index put:aString + "replace the substring at column index" + + strings isNil ifTrue:[ + strings := OrderedCollection new:index + ]. + index > strings size ifTrue:[strings grow:index]. + strings at:index put:aString +! + +strings:aCollectionOfStrings + "replace all substrings" + + strings := OrderedCollection withAll:aCollectionOfStrings. ! -fromString:aString separatedBy:separatorCharacter - |subStrings e| +tabulatorSpecification:aTabSpec + "set the tabulator spec" + + tabSpec := aTabSpec +! ! + +!MultiColListEntry methodsFor:'converting'! + +asString + "return the receiver as a string with embedded tabs" + + |s sub tab + nSub "{ Class: SmallInteger }"| - e := self new. - subStrings := aString asCollectionOfSubstringsSeparatedBy:separatorCharacter. - subStrings keysAndValuesDo:[:i :sub | - e colAt:i put:sub. + s := ''. + tab := Character tab asString. + nSub := strings size. + 1 to:nSub do:[:subStringIndex | + sub := strings at:subStringIndex. + sub notNil ifTrue:[ + s := s , sub. + ]. + subStringIndex == strings size ifFalse:[ + s := s , tab + ] ]. - ^ e + + ^ s ! ! !MultiColListEntry methodsFor:'defaults'! @@ -353,37 +406,6 @@ "Modified: 17.11.1995 / 12:21:18 / cg" ! ! -!MultiColListEntry methodsFor:'accessing'! - -colAt:index put:aString - "replace the substring at column index" - - strings isNil ifTrue:[ - strings := OrderedCollection new:index - ]. - index > strings size ifTrue:[strings grow:index]. - strings at:index put:aString -! - -tabulatorSpecification:aTabSpec - "set the tabulator spec" - - tabSpec := aTabSpec -! - -strings:aCollectionOfStrings - "replace all substrings" - - strings := OrderedCollection withAll:aCollectionOfStrings. -! - -colAt:index - "return the substring at column index" - - index > strings size ifTrue:[^ nil]. - ^ strings at:index -! ! - !MultiColListEntry methodsFor:'queries'! widthIn:aGC @@ -420,27 +442,3 @@ ^ xMax ! ! -!MultiColListEntry methodsFor:'converting'! - -asString - "return the receiver as a string with embedded tabs" - - |s sub tab - nSub "{ Class: SmallInteger }"| - - s := ''. - tab := Character tab asString. - nSub := strings size. - 1 to:nSub do:[:subStringIndex | - sub := strings at:subStringIndex. - sub notNil ifTrue:[ - s := s , sub. - ]. - subStringIndex == strings size ifFalse:[ - s := s , tab - ] - ]. - - ^ s -! ! -