Mercurial > projects > dwt-mac
diff dwt/graphics/Color.d @ 29:d408fc12b991
Ported dwt.graphics.Color and RGB
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Wed, 10 Sep 2008 23:18:26 +0200 |
parents | a9ab4c738ed8 |
children | 5123b17c98ef |
line wrap: on
line diff
--- a/dwt/graphics/Color.d Mon Sep 08 22:42:00 2008 +0200 +++ b/dwt/graphics/Color.d Wed Sep 10 23:18:26 2008 +0200 @@ -7,15 +7,21 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.Color; -import dwt.dwthelper.utils; - import dwt.DWT; import dwt.DWTException; +import dwt.dwthelper.utils; +import dwt.graphics.Device; +import dwt.graphics.Resource; +import dwt.graphics.RGB; + /** * Instances of this class manage the operating system resources that * implement DWT's RGB color model. To create a color you can either @@ -132,6 +138,8 @@ cast(int)(handle[2] * 255) is cast(int)(rgbColor[2] * 255); } +alias equals opEquals; + /** * Returns the amount of blue in the color, from 0 to 255. * @@ -184,11 +192,13 @@ * * @see #equals */ -public int hashCode() { +public hash_t toHash() { if (isDisposed()) return 0; return cast(int)(handle[0] * 255) ^ cast(int)(handle[1] * 255) ^ cast(int)(handle[2] * 255); } +alias toHash hashCode; + /** * Returns an <code>RGB</code> representing the receiver. * @@ -260,7 +270,7 @@ */ public String toString () { if (isDisposed()) return "Color {*DISPOSED*}"; - return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}"; + return "Color {" ~ getRed() ~ ", " ~ getGreen() ~ ", " ~ getBlue() + "}"; } }