Mercurial > projects > dwt-mac
diff dwt/graphics/Rectangle.d @ 30:93b13b15f0b1
Ported a couple of modules in dwt.graphics
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Thu, 11 Sep 2008 23:16:53 +0200 |
parents | a9ab4c738ed8 |
children | 7d135fe0caf2 |
line wrap: on
line diff
--- a/dwt/graphics/Rectangle.d Wed Sep 10 23:18:26 2008 +0200 +++ b/dwt/graphics/Rectangle.d Thu Sep 11 23:16:53 2008 +0200 @@ -7,14 +7,19 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.Rectangle; -import dwt.dwthelper.utils; - import dwt.DWT; import dwt.internal.SerializableCompatibility; +import tango.text.convert.Format; + +import dwt.dwthelper.utils; + /** * Instances of this class represent rectangular areas in an * (x, y) coordinate system. The top left corner of the rectangle @@ -63,7 +68,7 @@ */ public int height; - static final long serialVersionUID = 3256439218279428914L; + static const long serialVersionUID = 3256439218279428914L; /** * Construct a new instance of this class given the @@ -150,13 +155,15 @@ * * @see #hashCode() */ -public bool equals (Object object) { +public bool opEquals (Object object) { if (object is this) return true; if (!( null !is cast(Rectangle)object )) return false; Rectangle r = cast(Rectangle)object; return (r.x is this.x) && (r.y is this.y) && (r.width is this.width) && (r.height is this.height); } +alias opEquals equals; + /** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to @@ -167,10 +174,12 @@ * * @see #equals(Object) */ -public int hashCode () { +public hash_t toHash () { return x ^ y ^ width ^ height; } +alias toHash hashCode; + /** * Destructively replaces the x, y, width and height values * in the receiver with ones which represent the intersection of the @@ -309,7 +318,7 @@ * @return a string representation of the rectangle */ public String toString () { - return "Rectangle {" + x + ", " + y + ", " + width + ", " + height + "}"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + return Format( "Rectangle {{{}, {}, {}, {}}", x, y, width, height ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ } /** @@ -330,7 +339,7 @@ * * @see #add(Rectangle) */ -public Rectangle union (Rectangle rect) { +public Rectangle unionn (Rectangle rect) { if (rect is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); int left = x < rect.x ? x : rect.x; int top = y < rect.y ? y : rect.y;