handle Text
authorClaus Gittinger <cg@exept.de>
Sun, 12 May 1996 16:20:15 +0200
changeset 627 257058092fbf
parent 626 35bc7d217ff5
child 628 c790cf65fdcb
handle Text
ListView.st
--- a/ListView.st	Sun May 12 16:16:01 1996 +0200
+++ b/ListView.st	Sun May 12 16:20:15 1996 +0200
@@ -214,7 +214,29 @@
 
 
 
-      non-string entries:
+      non-string (text) entries:
+                                                                        [exBegin]
+        |top list l|
+
+        top := StandardSystemView new.
+        top extent:100@200.
+
+        l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
+        list := #('all' 'of' 'your' 'preferred' 'colors') 
+                with:#(red green blue 'orange' cyan)
+                collect:[:s :clr | 
+                            Text string:s 
+                                 emphasis:(Array with:#bold
+                                                 with:(#color->(Color name:clr))) ].
+        l list:list.
+
+        top open
+                                                                        [exEnd]
+
+
+
+      generic non-string entries:
+      (notice: ColoredListEntry is obsoleted by Text)
                                                                         [exBegin]
         |top list l|
 
@@ -1051,24 +1073,25 @@
 
     self paint:bg.
 
-    (lineString notNil and:[lineString isString not]) ifTrue:[
-	self drawVisibleLine:visLineNr with:fg and:bg
+    (lineString notNil and:[lineString isString not])
+    ifTrue:[
+        self drawVisibleLine:visLineNr with:fg and:bg
     ] ifFalse:[
-	yf := y - (lineSpacing//2).
-	col > lineString size ifTrue:[
-	    self fillRectangleX:x y:yf width:(font width) height:fontHeight.
-	    self paint:fg
-	] ifFalse:[
-	    characterString := (lineString at:col) asString.
-	    self fillRectangleX:x y:yf 
-			  width:(font widthOf:characterString)
-			 height:fontHeight.
-	    self paint:fg.
-	    self displayString:characterString x:x y:(y + fontAscent)
-	]
+        yf := y - (lineSpacing//2).
+        col > lineString size ifTrue:[
+            self fillRectangleX:x y:yf width:(font width) height:fontHeight.
+            self paint:fg
+        ] ifFalse:[
+            characterString := lineString copyFrom:col to:col.
+            self fillRectangleX:x y:yf 
+                          width:(font widthOf:characterString)
+                         height:fontHeight.
+            self paint:fg.
+            self displayString:characterString x:x y:(y + fontAscent)
+        ]
     ]
 
-    "Modified: 22.11.1995 / 23:42:27 / cg"
+    "Modified: 12.5.1996 / 12:47:07 / cg"
 !
 
 drawVisibleLine:visLineNr from:startCol to:endCol with:fg and:bg
@@ -1079,7 +1102,8 @@
     (endCol >= startCol) ifTrue:[
         lineString := self visibleAt:visLineNr.
 
-        (lineString notNil and:[lineString isString not]) ifTrue:[
+        (lineString notNil and:[lineString isString not])
+        ifTrue:[
             self drawVisibleLine:visLineNr with:fg and:bg.
         ] ifFalse:[
             x := (self xOfCol:startCol inVisibleLine:visLineNr) - leftOffset.
@@ -1094,7 +1118,7 @@
                              height:fontHeight
             ] ifFalse:[
                 (endCol > len) ifTrue:[
-                    characterString := lineString class new:endCol.
+                    characterString := lineString species new:endCol.
                     characterString replaceFrom:1 to:len with:lineString startingAt:1.
                     lineString := characterString
                 ].
@@ -1107,7 +1131,7 @@
         ]
     ]
 
-    "Modified: 23.2.1996 / 03:00:18 / cg"
+    "Modified: 12.5.1996 / 12:47:34 / cg"
 !
 
 drawVisibleLine:visLineNr from:startCol with:fg and:bg
@@ -1116,32 +1140,32 @@
     |y x lineString index1 index2|
 
     (startCol < 1) ifTrue:[
-	index1 := 1
+        index1 := 1
     ] ifFalse:[
-	index1 := startCol
+        index1 := startCol
     ].
     y := self yOfVisibleLine:visLineNr.
     x := (self xOfCol:index1 inVisibleLine:visLineNr) - leftOffset.
     self paint:bg.
     self fillRectangleX:x y:y - (lineSpacing // 2)
-		  width:(width + leftOffset - x)
-		 height:fontHeight.
+                  width:(width + leftOffset - x)
+                 height:fontHeight.
 
     lineString := self visibleAt:visLineNr.
     lineString notNil ifTrue:[
-	lineString isString ifFalse:[
-	    self drawVisibleLine:visLineNr with:fg and:bg.
-	] ifTrue:[
-	    index2 := lineString size.
-	    (index2 < index1) ifTrue:[^ self].
-	    (index1 <= index2) ifTrue:[
-		self paint:fg on:bg.
-		self displayOpaqueString:lineString from:index1 to:index2 x:x y:(y + fontAscent)
-	    ]
-	]
+        lineString isString ifFalse:[
+            self drawVisibleLine:visLineNr with:fg and:bg.
+        ] ifTrue:[
+            index2 := lineString size.
+            (index2 < index1) ifTrue:[^ self].
+            (index1 <= index2) ifTrue:[
+                self paint:fg on:bg.
+                self displayOpaqueString:lineString from:index1 to:index2 x:x y:(y + fontAscent)
+            ]
+        ]
     ]
 
-    "Modified: 11.12.1995 / 17:15:55 / cg"
+    "Modified: 12.5.1996 / 12:47:49 / cg"
 !
 
 drawVisibleLine:visLineNr with:fg and:bg
@@ -2908,23 +2932,24 @@
 
     includesNonStrings := false.
     list notNil ifTrue:[
-	nLines := self size.
-	1 to:nLines do:[:index |
-	    line := self at:index.
-	    line notNil ifTrue:[
-		line isString ifTrue:[
-		    newLine := line withTabsExpanded.
-		    newLine ~~ line ifTrue:[
-			self withoutRedrawAt:index put:newLine
-		    ].
-		] ifFalse:[
-		    includesNonStrings := true.
-		]
-	    ]
-	]
+        nLines := self size.
+        1 to:nLines do:[:index |
+            line := self at:index.
+            line notNil ifTrue:[
+                line isString ifTrue:[
+                    newLine := line withTabsExpanded.
+                    newLine ~~ line ifTrue:[
+                        self withoutRedrawAt:index put:newLine
+                    ].
+                ] ifFalse:[
+                    includesNonStrings := true.
+                ]
+            ]
+        ]
     ]
 
     "Modified: 30.8.1995 / 19:06:37 / claus"
+    "Modified: 12.5.1996 / 12:48:03 / cg"
 !
 
 nextTabAfter:colNr
@@ -3090,5 +3115,5 @@
 !ListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.81 1996-04-30 15:36:22 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ListView.st,v 1.82 1996-05-12 14:20:15 cg Exp $'
 ! !