Mercurial > projects > dwt-mac
changeset 33:965ac0a77267
Ported a couple of modules in dwt.graphics
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 12 Sep 2008 13:53:21 +0200 |
parents | b9226997409c |
children | 5123b17c98ef |
files | dwt/graphics/LineAttributes.d dwt/graphics/PaletteData.d dwt/graphics/PathData.d dwt/graphics/Point.d dwt/graphics/TextStyle.d |
diffstat | 5 files changed, 43 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/graphics/LineAttributes.d Fri Sep 12 13:44:30 2008 +0200 +++ b/dwt/graphics/LineAttributes.d Fri Sep 12 13:53:21 2008 +0200 @@ -7,12 +7,15 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.LineAttributes; -import dwt.dwthelper.utils; +import dwt.DWT; -import dwt.DWT; +import dwt.dwthelper.utils; /** * <code>LineAttributes</code> defines a set of line attributes that
--- a/dwt/graphics/PaletteData.d Fri Sep 12 13:44:30 2008 +0200 +++ b/dwt/graphics/PaletteData.d Fri Sep 12 13:53:21 2008 +0200 @@ -7,14 +7,18 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.PaletteData; -import dwt.dwthelper.utils; - import dwt.DWT; +import dwt.dwthelper.utils; +import dwt.graphics.RGB; + /** * Instances of this class describe the color data used by an image. * <p>
--- a/dwt/graphics/PathData.d Fri Sep 12 13:44:30 2008 +0200 +++ b/dwt/graphics/PathData.d Fri Sep 12 13:53:21 2008 +0200 @@ -7,11 +7,12 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.PathData; -import dwt.dwthelper.utils; - /** * Instances of this class describe device-independent paths.
--- a/dwt/graphics/Point.d Fri Sep 12 13:44:30 2008 +0200 +++ b/dwt/graphics/Point.d Fri Sep 12 13:53:21 2008 +0200 @@ -7,12 +7,17 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.Point; -import dwt.dwthelper.utils; +import dwt.internal.SerializableCompatibility; -import dwt.internal.SerializableCompatibility; +import tango.text.convert.Format; + +import dwt.dwthelper.utils; /** * Instances of this class represent places on the (x, y) @@ -50,7 +55,7 @@ */ public int y; - static final long serialVersionUID = 3257002163938146354L; + static const long serialVersionUID = 3257002163938146354L; /** * Constructs a new point with the given x and y coordinates. @@ -73,13 +78,15 @@ * * @see #hashCode() */ -public bool equals (Object object) { +public bool opEquals (Object object) { if (object is this) return true; if (!( null !is cast(Point)object )) return false; Point p = cast(Point)object; return (p.x is this.x) && (p.y is this.y); } +alias opEquals equals; + /** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to @@ -90,10 +97,12 @@ * * @see #equals(Object) */ -public int hashCode () { +public hash_t toHash () { return x ^ y; } +alias toHash hashCode; + /** * Returns a string containing a concise, human-readable * description of the receiver. @@ -101,7 +110,7 @@ * @return a string representation of the point */ public String toString () { - return "Point {" + x + ", " + y + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return Format("Point {{}{}{}{}" , x , ", " , y , "}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }
--- a/dwt/graphics/TextStyle.d Fri Sep 12 13:44:30 2008 +0200 +++ b/dwt/graphics/TextStyle.d Fri Sep 12 13:53:21 2008 +0200 @@ -7,12 +7,17 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.TextStyle; -import dwt.dwthelper.utils; +import dwt.DWT; -import dwt.DWT; +import dwt.dwthelper.utils; +import dwt.graphics.Color; +import dwt.graphics.Font; /** * <code>TextStyle</code> defines a set of styles that can be applied @@ -197,7 +202,7 @@ * * @see #hashCode() */ -public bool equals(Object object) { +public bool opEquals(Object object) { if (object is this) return true; if (object is null) return false; if (!( null !is cast(TextStyle)object )) return false; @@ -230,6 +235,8 @@ return true; } +alias opEquals equals; + /** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to @@ -240,8 +247,8 @@ * * @see #equals(Object) */ -public int hashCode() { - int hash = 0; +public hash_t toHash() { + hash_t hash = 0; if (foreground !is null) hash ^= foreground.hashCode(); if (background !is null) hash ^= background.hashCode(); if (font !is null) hash ^= font.hashCode(); @@ -256,6 +263,8 @@ return hash; } +alias toHash hashCode; + bool isAdherentBorder(TextStyle style) { if (this is style) return true; if (style is null) return false;