deepCopy fix (do not copy device dependent stuff)
authorClaus Gittinger <cg@exept.de>
Wed, 15 Sep 1999 14:57:54 +0200
changeset 2910 97a836c7e15c
parent 2909 c8edb71fb275
child 2911 b0f0fc948830
deepCopy fix (do not copy device dependent stuff)
Color.st
--- a/Color.st	Wed Sep 15 13:21:14 1999 +0200
+++ b/Color.st	Wed Sep 15 14:57:54 1999 +0200
@@ -3282,6 +3282,46 @@
     "Modified: 11.7.1996 / 18:20:14 / cg"
 ! !
 
+!Color methodsFor:'AEG-Extensions'!
+
+device: aDevice
+
+    device := aDevice
+
+!
+
+getBlue
+
+    ^blue
+!
+
+getGreen
+
+    ^green
+!
+
+getRed
+
+    ^red
+!
+
+magnifiedTo: extent
+
+    "do nothing here, because of compatibility to Image"
+!
+
+rgb3DByteArray
+    "return the 3d rgb byteValues packed into a byte array of length 3"
+
+    ^Array with: (self red / 100) with: (self green / 100) with: (self blue / 100).
+!
+
+rgbByteArray
+    "return the rgb byteValues packed into a byte array of length 3"
+
+    ^ByteArray with: self redByte with: self greenByte with: self blueByte.
+! !
+
 !Color methodsFor:'ST-80 compatibility'!
 
 asDevicePaintOn:aDevice
@@ -3806,12 +3846,44 @@
 
 !Color methodsFor:'copying'!
 
+deepCopyNamedInstvarsFrom:anOriginal using:aDictionary
+    "a helper for deepCopy; deep-copy instance variables from anOriginal,
+     using aDictionary to keep track of already copied objects.
+     Can be redefined in subclasses for partial copies"
+
+    red := anOriginal scaledRed.
+    green := anOriginal scaledGreen.
+    blue := anOriginal scaledBlue.
+    colorId := anOriginal colorId.
+
+!
+
 postCopy
     "redefined to clear out any device handles in the copy"
 
     device := colorId := ditherForm := replacementColor := nil
 
     "Modified: 17.1.1997 / 00:03:42 / cg"
+!
+
+skipInstvarIndexInDeepCopy:index
+    index == 4 ifTrue:[
+        ^ true "/ skip device
+    ].
+    index == 5 ifTrue:[
+        ^ true "/ skip colorId
+    ].
+    index == 6 ifTrue:[
+        ^ true "/ skip ditherForm
+    ].
+    index == 7 ifTrue:[
+        ^ true "/ skip replacementColor
+    ].
+    ^ false
+
+    "
+     (Color black onDevice:Screen current) deepCopy
+    "
 ! !
 
 !Color methodsFor:'getting a device color'!
@@ -4640,6 +4712,6 @@
 !Color class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.132 1999-09-08 15:54:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Color.st,v 1.133 1999-09-15 12:57:54 cg Exp $'
 ! !
 Color initialize!