Color.st
changeset 1365 37a9e7ac4dbc
parent 1348 acb4e4874e4d
child 1368 cb5fbbcf568f
--- a/Color.st	Fri Feb 21 20:17:42 1997 +0100
+++ b/Color.st	Mon Feb 24 18:32:40 1997 +0100
@@ -11,13 +11,13 @@
 "
 
 Object subclass:#Color
-        instanceVariableNames:'red green blue device colorId ditherForm replacementColor
-                writable'
-        classVariableNames:'MaxValue Lobby Cells Black White LightGrey Grey DarkGrey Pseudo0
-                Pseudo1 PseudoAll Red Green Blue RetryAllocation DitherBits
-                ColorAllocationFailSignal InvalidColorNameSignal'
-        poolDictionaries:''
-        category:'Graphics-Support'
+	instanceVariableNames:'red green blue device colorId ditherForm replacementColor
+		writable'
+	classVariableNames:'MaxValue Cells Black White LightGrey Grey DarkGrey Pseudo0
+		Pseudo1 PseudoAll Red Green Blue RetryAllocation DitherBits
+		ColorAllocationFailSignal InvalidColorNameSignal'
+	poolDictionaries:''
+	category:'Graphics-Support'
 !
 
 !Color class methodsFor:'documentation'!
@@ -146,23 +146,11 @@
 flushDeviceColors
     "unassign all colors from their device"
 
-    "if all colors are registered in Lobby, use:"
-"
-    Lobby do:[:aColor |
-        aColor restored.
-        Lobby unregister:aColor
-    ].
-"
-
-    "if only device colors are registered, use"
-
     self allInstances do:[:aColor |
         aColor restored
     ].
 
-    Lobby do:[:aColor |
-        Lobby unregister:aColor
-    ]
+    "Modified: 24.2.1997 / 18:27:06 / cg"
 !
 
 getColors6x6x4
@@ -412,22 +400,22 @@
         InvalidColorNameSignal notifierString:'invalid color name'.
     ].
 
-    Lobby isNil ifTrue:[
-        MaxValue := 16rFFFF.
-
-        Lobby := Registry new.
-
-        self getPrimaryColors.
-
-        "want to be informed when returning from snapshot"
-        ObjectMemory addDependent:self.
-
-        RetryAllocation := true.
-
-        DitherBits := self ditherBits
-    ].
-
-    "Modified: 24.1.1997 / 13:37:30 / cg"
+    MaxValue := 16rFFFF.
+
+    self getPrimaryColors.
+
+    "want to be informed when returning from snapshot"
+    ObjectMemory addDependent:self.
+
+    RetryAllocation := true.
+
+    DitherBits := self ditherBits.
+
+    "
+     Color initialize
+    "
+
+    "Modified: 24.2.1997 / 18:26:41 / cg"
 !
 
 update:something with:aParameter from:changedObject
@@ -503,18 +491,10 @@
     id == -1 ifTrue:[
         ^ self allColor
     ].
-    "look if already known"
-
-    Lobby do:[:aColor |
-        aColor scaledRed isNil ifTrue:[
-            (aColor colorId == id) ifTrue:[
-                ^ aColor
-            ]
-        ]
-    ].
+
     ^ self basicNew setColorId:id
 
-    "Modified: 17.1.1997 / 00:06:41 / cg"
+    "Modified: 24.2.1997 / 18:16:30 / cg"
 !
 
 cyan:c magenta:m yellow:y
@@ -689,17 +669,17 @@
 
     |newColor|
 
-    "look if already known"
-
-    Lobby do:[:aColor |
-        (r == aColor scaledRed) ifTrue:[
-            (g == aColor scaledGreen) ifTrue:[
-                (b == aColor scaledBlue) ifTrue:[
-                    ^ aColor
-                ]
-            ]
-        ]
-    ].
+"/    "look if already known"
+"/
+"/    aDevice deviceColors do:[:aColor |
+"/        (r == aColor scaledRed) ifTrue:[
+"/            (g == aColor scaledGreen) ifTrue:[
+"/                (b == aColor scaledBlue) ifTrue:[
+"/                    ^ aColor
+"/                ]
+"/            ]
+"/        ]
+"/    ].
     newColor := self basicNew setScaledRed:r scaledGreen:g scaledBlue:b device:nil.
     ^ newColor
 
@@ -709,8 +689,8 @@
      (Color red:50 green:0 blue:0) inspect
     "
 
-    "Modified: 23.4.1996 / 13:32:36 / cg"
     "Modified: 2.5.1996 / 13:40:51 / stefan"
+    "Modified: 24.2.1997 / 18:18:47 / cg"
 !
 
 variableColorOn:aDevice
@@ -792,9 +772,11 @@
     |colors|
 
     colors := OrderedCollection new.
-    Lobby do:[:clr |
-        (clr graphicsDevice == aDevice and:[clr colorId notNil]) ifTrue:[
+    aDevice deviceColors do:[:clr |
+        clr colorId notNil ifTrue:[
             colors add:clr
+        ] ifFalse:[
+            'color - oops' printCR.
         ]
     ].
     ^ colors asArray
@@ -803,7 +785,7 @@
      Color allocatedColorsOn:Display
     "
 
-    "Modified: 5.7.1996 / 17:58:23 / cg"
+    "Modified: 24.2.1997 / 18:16:14 / cg"
 ! !
 
 !Color class methodsFor:'cleanup'!
@@ -812,10 +794,11 @@
     "this is sent when a display connection is closed,
      to release all cached Colors from that device"
 
-    Lobby unregisterAllForWhich:[:aColor | aColor graphicsDevice == aDevice]
-
-    "Modified: 16.1.1997 / 16:41:12 / cg"
+    aDevice releaseDeviceColors
+    "/ Lobby unregisterAllForWhich:[:aColor | aColor graphicsDevice == aDevice]
+
     "Created: 16.1.1997 / 16:44:20 / cg"
+    "Modified: 24.2.1997 / 18:18:22 / cg"
 ! !
 
 !Color class methodsFor:'color space conversions'!
@@ -1281,24 +1264,21 @@
     rb := (b / 2) rounded * 2.      "round to 2%"
 
     minDelta := 100*100*100.
-    Lobby do:[:aColor |
-        (aColor graphicsDevice == aDevice) ifTrue:[
-"/            (aColor colorId notNil) ifTrue:[
-                dRed := rr - aColor red.
-                dRed < 10 ifTrue:[
-                    diff := dRed asInteger squared
-                            + (rg - aColor green) asInteger squared
-                            + (rb - aColor blue) asInteger squared.
-                    diff < minDelta ifTrue:[
-                        diff = 0 ifTrue:[
-                            "got it"
-                            ^ aColor
-                        ].
-                        bestColor := aColor.
-                        minDelta := diff
-                    ]
-                ]
-"/            ]
+    aDevice deviceColors do:[:aColor |
+        dRed := rr - aColor red.
+        dRed < 10 ifTrue:[
+            diff := dRed asInteger squared
+                    + (rg - aColor green) asInteger squared
+                    + (rb - aColor blue) asInteger squared.
+
+            diff < minDelta ifTrue:[
+                diff = 0 ifTrue:[
+                    "got it"
+                    ^ aColor
+                ].
+                bestColor := aColor.
+                minDelta := diff
+            ]
         ]
     ].
 
@@ -1306,7 +1286,7 @@
     minDelta < (100+100+100) ifTrue:[ ^ bestColor ].
     ^ nil
 
-    "Modified: 5.7.1996 / 17:58:19 / cg"
+    "Modified: 24.2.1997 / 18:17:24 / cg"
 !
 
 ditherBits
@@ -2025,20 +2005,18 @@
     "return a device color on aDevice with rgb values
      if there is one, nil otherwise."
 
-    Lobby do:[:aColor |
+    aDevice deviceColors do:[:aColor |
         (r == aColor scaledRed) ifTrue:[
             (g == aColor scaledGreen) ifTrue:[
                 (b == aColor scaledBlue) ifTrue:[
-                    (aColor graphicsDevice == aDevice) ifTrue:[
-                        ^ aColor
-                    ]
+                    ^ aColor
                 ]
             ]
         ]
     ].
     ^ nil
 
-    "Modified: 5.7.1996 / 17:58:15 / cg"
+    "Modified: 24.2.1997 / 18:17:35 / cg"
 ! !
 
 !Color class methodsFor:'queries'!
@@ -2152,10 +2130,10 @@
         scaledGreen:g 
         scaledBlue:b 
         on:aDevice 
-        in:Lobby
+        in:aDevice deviceColors
 
     "Created: 14.6.1996 / 20:11:18 / cg"
-    "Modified: 11.7.1996 / 18:20:50 / cg"
+    "Modified: 24.2.1997 / 18:17:51 / cg"
 !
 
 nearestColorScaledRed:r scaledGreen:g scaledBlue:b on:aDevice in:colors
@@ -2744,7 +2722,8 @@
         colorId := id.
 
         aDevice visualType ~~ #TrueColor ifTrue:[
-            Lobby register:self.
+            "/ Lobby register:self.
+            aDevice registerColor:self.
         ].
         ^ self
     ].
@@ -2753,11 +2732,12 @@
     newColor := (self class basicNew) setScaledRed:r scaledGreen:g scaledBlue:b device:aDevice.
     newColor setColorId:id.
     aDevice visualType ~~ #TrueColor ifTrue:[
-        Lobby register:newColor.
+        "/ Lobby register:newColor.
+        aDevice registerColor:newColor.
     ].
     ^ newColor
 
-    "Modified: 17.1.1997 / 00:15:35 / cg"
+    "Modified: 24.2.1997 / 18:23:20 / cg"
 !
 
 nearestOn:aDevice 
@@ -2799,7 +2779,8 @@
         colorId := id.
 
         aDevice visualType ~~ #TrueColor ifTrue:[
-            Lobby register:self.
+            "/ Lobby register:self.
+            aDevice registerColor:self.
         ].
         ^ self
     ].
@@ -2808,11 +2789,12 @@
     newColor := (self class basicNew) setScaledRed:red scaledGreen:green sclaedBlue:blue device:aDevice.
     newColor setColorId:id.
     aDevice visualType ~~ #TrueColor ifTrue:[
-        Lobby register:newColor.
+        "/ Lobby register:newColor.
+        aDevice registerColor:newColor.
     ].
     ^ newColor
 
-    "Modified: 17.1.1997 / 00:06:56 / cg"
+    "Modified: 24.2.1997 / 18:23:26 / cg"
 !
 
 on:aDevice
@@ -2848,7 +2830,8 @@
         (aDevice isNil and:[device notNil]) ifTrue:[
             "/ trueColor device-colors are not registered
             device visualType ~~ #TrueColor ifTrue:[
-                Lobby unregister:self.
+                "/ Lobby unregister:self.
+                device unregisterColor:newColor.
                 device freeColor:colorId
             ].
             device := nil.
@@ -2910,7 +2893,8 @@
                 id notNil ifTrue:[
                     colorId := id.
                     ditherForm := nil.
-                    Lobby register:self
+                    "/ Lobby register:self.
+                    device registerColor:self.
                 ]
             ]
         ].
@@ -3009,7 +2993,8 @@
 
         id notNil ifTrue:[
             deviceVisual ~~ #TrueColor ifTrue:[    
-                Lobby register:self
+                "/ Lobby register:self.
+                device registerColor:self.
             ]
         ].
         ^ self
@@ -3030,13 +3015,14 @@
 
         "/ trueColor device-colors are not registered
         deviceVisual ~~ #TrueColor ifTrue:[    
-            Lobby register:newColor.
+            "/ Lobby register:newColor.
+            device registerColor:newColor.
         ]
     ].
     ^ newColor
 
     "Created: 16.11.1995 / 20:16:42 / cg"
-    "Modified: 17.1.1997 / 00:15:19 / cg"
+    "Modified: 24.2.1997 / 18:23:39 / cg"
 ! !
 
 !Color methodsFor:'inspecting'!
@@ -3407,7 +3393,7 @@
         hiL := nil.
 
         "find the 2 bounding colors"
-        Lobby do:[:aColor |
+        aDevice deviceColors do:[:aColor |
             aColor colorId notNil ifTrue:[
                 
                 Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:h :l :s |
@@ -3475,7 +3461,7 @@
     lowH := nil.
     hiH := nil.
 
-    Lobby do:[:aColor |
+    aDevice deviceColors do:[:aColor |
         aColor colorId notNil ifTrue:[
             Color withHLSFromRed:aColor red green:aColor green blue:aColor blue do:[:h :l :s |
                 | cl ch cs|
@@ -3646,7 +3632,7 @@
 
     ^ aBlock value:nil value:nil
 
-    "Modified: 11.6.1996 / 17:26:57 / cg"
+    "Modified: 24.2.1997 / 18:22:45 / cg"
 !
 
 fixDitherRed:redVal green:greenVal blue:blueVal on:aDevice into:aBlock
@@ -4016,6 +4002,6 @@
 !Color class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.87 1997-02-13 23:49:54 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.88 1997-02-24 17:32:40 cg Exp $'
 ! !
 Color initialize!