ColoredListEntry.st
changeset 88 d591b16c8f46
parent 86 4d7dbb5f1719
child 93 f3158d8e67d0
--- a/ColoredListEntry.st	Tue Nov 14 14:19:37 1995 +0100
+++ b/ColoredListEntry.st	Thu Nov 16 17:26:36 1995 +0100
@@ -13,7 +13,7 @@
 'From Smalltalk/X, Version:2.10.5 on 15-may-1995 at 8:03:34 am'!
 
 ListEntry subclass:#ColoredListEntry
-	 instanceVariableNames:'color string'
+	 instanceVariableNames:'color string bgColor'
 	 classVariableNames:''
 	 poolDictionaries:''
 	 category:'Views-Support'
@@ -36,13 +36,16 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/ColoredListEntry.st,v 1.4 1995-11-11 16:28:53 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/ColoredListEntry.st,v 1.5 1995-11-16 16:26:36 cg Exp $'
 !
 
 documentation
 "
     Instances of ColoredListEntry can be used in place of strings
     as entries of the list in a ListView or SelectionInListView.
+
+    Notice: this is a temporary kludge class which will be made obsolete,
+	    once full-attributed strings are available.
 "
 !
 
@@ -92,6 +95,10 @@
 
 string:aString color:aColor
     ^ self new string:aString color:aColor
+!
+
+string:aString foregroundColor:fgColor backgroundColor:bgColor
+    ^ self new string:aString foregroundColor:fgColor backgroundColor:bgColor
 ! !
 
 !ColoredListEntry methodsFor:'drawing'!
@@ -99,12 +106,21 @@
 displayOn:aGC x:x y:y
     "display the receiver on a GC"
 
-    |savedPaint|
+    |savedPaint savedBgPaint|
 
     savedPaint := aGC paint.
-    aGC paint:color.
-    aGC displayString:string x:x y:y.
-    aGC paint:savedPaint
+    bgColor notNil ifTrue:[
+	savedBgPaint := aGC backgroundPaint.
+	aGC paint:color on:bgColor.
+	aGC displayOpaqueString:string x:x y:y.
+	aGC paint:savedPaint on:savedBgPaint
+    ] ifFalse:[
+	aGC paint:color.
+	aGC displayString:string x:x y:y.
+	aGC paint:savedPaint
+    ]
+
+    "Created: 16.11.1995 / 16:54:40 / cg"
 ! !
 
 !ColoredListEntry methodsFor:'accessing'!
@@ -112,6 +128,14 @@
 string:aString color:aColor
     string := aString.
     color := aColor
+!
+
+string:aString foregroundColor:fg backgroundColor:bg
+    string := aString.
+    color := fg.
+    bgColor := bg.
+
+    "Created: 16.11.1995 / 16:53:17 / cg"
 ! !
 
 !ColoredListEntry methodsFor:'converting'!