Mercurial > projects > dwt-addons
diff dwtx/ui/internal/forms/widgets/FormImages.d @ 90:7ffeace6c47f
Update 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 06 Jul 2008 23:30:07 +0200 |
parents | 26c6c9dfd13c |
children | 04b47443bb01 |
line wrap: on
line diff
--- a/dwtx/ui/internal/forms/widgets/FormImages.d Sun Jun 22 22:57:31 2008 +0200 +++ b/dwtx/ui/internal/forms/widgets/FormImages.d Sun Jul 06 23:30:07 2008 +0200 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,6 +17,7 @@ import dwt.graphics.Color; import dwt.graphics.GC; import dwt.graphics.Image; +import dwt.graphics.RGB; import dwt.widgets.Display; import dwt.dwthelper.utils; @@ -39,22 +40,26 @@ private abstract class ImageIdentifier { Display fDisplay; - Color[] fColors; + RGB[] fRGBs; int fLength; this(Display display, Color[] colors, int length) { fDisplay = display; - fColors = colors; + fRGBs = new RGB[colors.length]; + for (int i = 0; i < colors.length; i++) { + Color color = colors[i]; + fRGBs[i] = color is null ? null : color.getRGB(); + } fLength = length; } public bool equals(Object obj) { if (null !is cast(ImageIdentifier)obj ) { ImageIdentifier id = cast(ImageIdentifier)obj; - if (id.fColors.length is fColors.length) { + if (id.fRGBs.length is fRGBs.length) { bool result = id.fDisplay.opEquals(fDisplay) && id.fLength is fLength; - for (int i = 0; i < fColors.length && result; i++) { - result = result && id.fColors[i].opEquals(fColors[i]); + for (int i = 0; i < fRGBs.length && result; i++) { + result = result && id.fRGBs[i].opEquals(fRGBs[i]); } return result; } @@ -64,8 +69,8 @@ public override hash_t toHash() { int hash = fDisplay.toHash(); - for (int i = 0; i < fColors.length; i++) - hash = hash * 7 + fColors[i].toHash(); + for (int i = 0; i < fRGBs.length; i++) + hash = hash * 7 + fRGBs[i].toHash(); hash = hash * 7 + fLength; return hash; } @@ -101,14 +106,14 @@ } private class ComplexImageIdentifier : ImageIdentifier { - Color fBg; + RGB fBgRGB; bool fVertical; int[] fPercents; public this(Display display, Color[] colors, int length, int[] percents, bool vertical, Color bg) { super(display, colors, length); - fBg = bg; + fBgRGB = bg is null ? null : bg.getRGB(); fVertical = vertical; fPercents = percents; } @@ -118,8 +123,8 @@ ComplexImageIdentifier id = cast(ComplexImageIdentifier) obj; if (super.equals(obj) && id.fVertical is fVertical && ArrayEquals(id.fPercents, fPercents)) { - if ((id.fBg is null && fBg is null) || - (id.fBg !is null && id.fBg.opEquals(fBg))) + if ((id.fBgRGB is null && fBgRGB is null) || + (id.fBgRGB !is null && id.fBgRGB.opEquals(fBgRGB))) return true; // if the only thing that isn't the same is the background color // still return true if it does not matter (percents add up to 100)