# HG changeset patch # User Frank Benoit # Date 1199499875 -3600 # Node ID 94c5d794407ff939b5062972af288c85ee4054c0 # Parent 5dfd6e42e2efa22f5c79f6f607ad655046165401 more simple classes diff -r 5dfd6e42e2ef -r 94c5d794407f .hgignore --- a/.hgignore Sat Jan 05 02:29:20 2008 +0100 +++ b/.hgignore Sat Jan 05 03:24:35 2008 +0100 @@ -1,6 +1,7 @@ syntax: glob *.a +*.swp syntax: regexp diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/graphics/FontMetrics.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/eclipse/swt/graphics/FontMetrics.d Sat Jan 05 03:24:35 2008 +0100 @@ -0,0 +1,133 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module org.eclipse.swt.graphics.FontMetrics; + + +/** + * Instances of this class provide measurement information + * about fonts including ascent, descent, height, leading + * space between rows, and average character width. + * FontMetrics are obtained from GCs + * using the getFontMetrics() method. + * + * @see GC#getFontMetrics + */ +public final class FontMetrics { + int ascent, descent, averageCharWidth, leading, height; + +package this() { +} + +/** + * Compares the argument to the receiver, and returns true + * if they represent the same object using a class + * specific comparison. + * + * @param object the object to compare with this object + * @return true if the object is the same as this object and false otherwise + * + * @see #hashCode + */ +public int opEquals (Object object) { + if (object is this) return true; + if( auto metrics = cast(FontMetrics)object ){ + return ascent == metrics.ascent && descent == metrics.descent && + averageCharWidth == metrics.averageCharWidth && leading == metrics.leading && + height == metrics.height; + } + return false; +} + +/** + * Returns the ascent of the font described by the receiver. A + * font's ascent is the distance from the baseline to the + * top of actual characters, not including any of the leading area, + * measured in pixels. + * + * @return the ascent of the font + */ +public int getAscent() { + return ascent; +} + +/** + * Returns the average character width, measured in pixels, + * of the font described by the receiver. + * + * @return the average character width of the font + */ +public int getAverageCharWidth() { + return averageCharWidth; +} + +/** + * Returns the descent of the font described by the receiver. A + * font's descent is the distance from the baseline to the + * bottom of actual characters, not including any of the leading area, + * measured in pixels. + * + * @return the descent of the font + */ +public int getDescent() { + return descent; +} + +/** + * Returns the height of the font described by the receiver, + * measured in pixels. A font's height is the sum of + * its ascent, descent and leading area. + * + * @return the height of the font + * + * @see #getAscent + * @see #getDescent + * @see #getLeading + */ +public int getHeight() { + return height; +} + +/** + * Returns the leading area of the font described by the + * receiver. A font's leading area is the space + * above its ascent which may include accents or other marks. + * + * @return the leading space of the font + */ +public int getLeading() { + return leading; +} + +public static FontMetrics gtk_new(int ascent, int descent, int averageCharWidth, int leading, int height) { + FontMetrics fontMetrics = new FontMetrics(); + fontMetrics.ascent = ascent; + fontMetrics.descent = descent; + fontMetrics.averageCharWidth = averageCharWidth; + fontMetrics.leading = leading; + fontMetrics.height = height; + return fontMetrics; +} + +/** + * Returns an integer hash code for the receiver. Any two + * objects that return true when passed to + * equals must return the same value for this + * method. + * + * @return the receiver's hash + * + * @see #equals + */ +public hash_t toHash() { + return ascent ^ descent ^ averageCharWidth ^ leading ^ height; +} + +} diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/graphics/PathData.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/eclipse/swt/graphics/PathData.d Sat Jan 05 03:24:35 2008 +0100 @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module org.eclipse.swt.graphics.PathData; + + +/** + * Instances of this class describe device-independent paths. + * + * @see Path + * + * @since 3.1 + */ +public final class PathData { + + /** + * The type of each point. + */ + public byte[] types; + + /** + * The points of a path. + */ + public float[] points; +} diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/graphics/Point.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/eclipse/swt/graphics/Point.d Sat Jan 05 03:24:35 2008 +0100 @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module org.eclipse.swt.graphics.Point; + + +public import org.eclipse.swt.internal.SerializableCompatibility; + +import tango.text.convert.Format; + +/** + * Instances of this class represent places on the (x, y) + * coordinate plane. + *

+ * The coordinate space for rectangles and points is considered + * to have increasing values downward and to the right from its + * origin making this the normal, computer graphics oriented notion + * of (x, y) coordinates rather than the strict mathematical one. + *

+ *

+ * The hashCode() method in this class uses the values of the public + * fields to compute the hash value. When storing instances of the + * class in hashed collections, do not modify these fields after the + * object has been inserted. + *

+ *

+ * Application code does not need to explicitly release the + * resources managed by each instance when those instances are no longer + * required, and thus no dispose() method is provided. + *

+ * + * @see Rectangle + */ + +public final class Point : SerializableCompatibility { + + /** + * the x coordinate of the point + */ + public int x; + + /** + * the y coordinate of the point + */ + public int y; + + //static final long serialVersionUID = 3257002163938146354L; + +/** + * Constructs a new point with the given x and y coordinates. + * + * @param x the x coordinate of the new point + * @param y the y coordinate of the new point + */ +public this (int x, int y) { + this.x = x; + this.y = y; +} + +/** + * Compares the argument to the receiver, and returns true + * if they represent the same object using a class + * specific comparison. + * + * @param object the object to compare with this object + * @return true if the object is the same as this object and false otherwise + * + * @see #hashCode() + */ +public override int opEquals (Object object) { + if (object is this) return true; + if ( auto p = cast(Point)object ){ + return (p.x == this.x) && (p.y == this.y); + } + return false; +} + +/** + * Returns an integer hash code for the receiver. Any two + * objects that return true when passed to + * equals must return the same value for this + * method. + * + * @return the receiver's hash + * + * @see #equals(Object) + */ +public hash_t toHash () { + return x ^ y; +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the point + */ +public char[] toString () { + return Format( "Point {}, {}}", x, y );; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ +} + +} + diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/graphics/RGB.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/eclipse/swt/graphics/RGB.d Sat Jan 05 03:24:35 2008 +0100 @@ -0,0 +1,228 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module org.eclipse.swt.graphics.RGB; + +public import org.eclipse.swt.internal.SerializableCompatibility; + +import org.eclipse.swt.SWT; +import Math = tango.math.Math : min, max; +import tango.text.convert.Format; + +/** + * Instances of this class are descriptions of colors in + * terms of the primary additive color model (red, green and + * blue). A color may be described in terms of the relative + * intensities of these three primary colors. The brightness + * of each color is specified by a value in the range 0 to 255, + * where 0 indicates no color (blackness) and 255 indicates + * maximum intensity. + *

+ * The hashCode() method in this class uses the values of the public + * fields to compute the hash value. When storing instances of the + * class in hashed collections, do not modify these fields after the + * object has been inserted. + *

+ *

+ * Application code does not need to explicitly release the + * resources managed by each instance when those instances are no longer + * required, and thus no dispose() method is provided. + *

+ * + * @see Color + */ + +public final class RGB : SerializableCompatibility { + + /** + * the red component of the RGB + */ + public int red; + + /** + * the green component of the RGB + */ + public int green; + + /** + * the blue component of the RGB + */ + public int blue; + + //static final long serialVersionUID = 3258415023461249074L; + +/** + * Constructs an instance of this class with the given + * red, green and blue values. + * + * @param red the red component of the new instance + * @param green the green component of the new instance + * @param blue the blue component of the new instance + * + * @exception IllegalArgumentException + */ +public this (int red, int green, int blue) { + if ((red > 255) || (red < 0) || + (green > 255) || (green < 0) || + (blue > 255) || (blue < 0)) + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + this.red = red; + this.green = green; + this.blue = blue; +} + +/** +* Constructs an instance of this class with the given +* hue, saturation, and brightness. +* +* @param hue the hue value for the HSB color (from 0 to 360) +* @param saturation the saturation value for the HSB color (from 0 to 1) +* @param brightness the brightness value for the HSB color (from 0 to 1) +* +* @exception IllegalArgumentException +* +* @since 3.2 +*/ +public this (float hue, float saturation, float brightness) { + if (hue < 0 || hue > 360 || saturation < 0 || saturation > 1 || + brightness < 0 || brightness > 1) { + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + float r, g, b; + if (saturation == 0) { + r = g = b = brightness; + } else { + if (hue == 360) hue = 0; + hue /= 60; + int i = cast(int)hue; + float f = hue - i; + float p = brightness * (1 - saturation); + float q = brightness * (1 - saturation * f); + float t = brightness * (1 - saturation * (1 - f)); + switch(i) { + case 0: + r = brightness; + g = t; + b = p; + break; + case 1: + r = q; + g = brightness; + b = p; + break; + case 2: + r = p; + g = brightness; + b = t; + break; + case 3: + r = p; + g = q; + b = brightness; + break; + case 4: + r = t; + g = p; + b = brightness; + break; + case 5: + default: + r = brightness; + g = p; + b = q; + break; + } + } + red = cast(int)(r * 255 + 0.5); + green = cast(int)(g * 255 + 0.5); + blue = cast(int)(b * 255 + 0.5); +} + +/** + * Returns the hue, saturation, and brightness of the color. + * + * @return color space values in float format (hue, saturation, brightness) + * + * @since 3.2 + */ +public float[] getHSB() { + float r = red / 255f; + float g = green / 255f; + float b = blue / 255f; + float max = Math.max(Math.max(r, g), b); + float min = Math.min(Math.min(r, g), b); + float delta = max - min; + float hue = 0; + float brightness = max; + float saturation = max == 0 ? 0 : (max - min) / max; + if (delta != 0) { + if (r == max) { + hue = (g - b) / delta; + } else { + if (g == max) { + hue = 2 + (b - r) / delta; + } else { + hue = 4 + (r - g) / delta; + } + } + hue *= 60; + if (hue < 0) hue += 360; + } + return [ hue, saturation, brightness ]; +} + +/** + * Compares the argument to the receiver, and returns true + * if they represent the same object using a class + * specific comparison. + * + * @param object the object to compare with this object + * @return true if the object is the same as this object and false otherwise + * + * @see #hashCode() + */ +public override int opEquals(Object object) { + if (object is this) return true; + if( auto rgb = cast(RGB) object ){ + return (rgb.red == this.red) && (rgb.green == this.green) && (rgb.blue == this.blue); + } + return false; +} + +/** + * Returns an integer hash code for the receiver. Any two + * objects that return true when passed to + * equals must return the same value for this + * method. + * + * @return the receiver's hash + * + * @see #equals(Object) + */ +public hash_t toHash() { + return (blue << 16) | (green << 8) | red; +} + +/** + * Returns a String containing a concise, human-readable + * description of the receiver. + * + * @return a String representation of the RGB + */ +public override char[] toString() { + return Format( "RGB {}, {}, {}}", red, green, blue ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ +} + +} diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/graphics/Rectangle.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/eclipse/swt/graphics/Rectangle.d Sat Jan 05 03:24:35 2008 +0100 @@ -0,0 +1,349 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module org.eclipse.swt.graphics.Rectangle; + +public import org.eclipse.swt.graphics.Point; +public import org.eclipse.swt.internal.SerializableCompatibility; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTError; +import tango.text.convert.Format; + +/** + * Instances of this class represent rectangular areas in an + * (x, y) coordinate system. The top left corner of the rectangle + * is specified by its x and y values, and the extent of the + * rectangle is specified by its width and height. + *

+ * The coordinate space for rectangles and points is considered + * to have increasing values downward and to the right from its + * origin making this the normal, computer graphics oriented notion + * of (x, y) coordinates rather than the strict mathematical one. + *

+ *

+ * The hashCode() method in this class uses the values of the public + * fields to compute the hash value. When storing instances of the + * class in hashed collections, do not modify these fields after the + * object has been inserted. + *

+ *

+ * Application code does not need to explicitly release the + * resources managed by each instance when those instances are no longer + * required, and thus no dispose() method is provided. + *

+ * + * @see Point + */ + +public final class Rectangle : SerializableCompatibility { + + /** + * the x coordinate of the rectangle + */ + public int x; + + /** + * the y coordinate of the rectangle + */ + public int y; + + /** + * the width of the rectangle + */ + public int width; + + /** + * the height of the rectangle + */ + public int height; + + //static final long serialVersionUID = 3256439218279428914L; + +/** + * Construct a new instance of this class given the + * x, y, width and height values. + * + * @param x the x coordinate of the origin of the rectangle + * @param y the y coordinate of the origin of the rectangle + * @param width the width of the rectangle + * @param height the height of the rectangle + */ +public this (int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; +} + +/** + * Destructively replaces the x, y, width and height values + * in the receiver with ones which represent the union of the + * rectangles specified by the receiver and the given rectangle. + *

+ * The union of two rectangles is the smallest single rectangle + * that completely covers both of the areas covered by the two + * given rectangles. + *

+ * + * @param rect the rectangle to merge with the receiver + * + * @exception IllegalArgumentException + */ +public void add (Rectangle rect) { + if (rect is null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + int left = x < rect.x ? x : rect.x; + int top = y < rect.y ? y : rect.y; + int lhs = x + width; + int rhs = rect.x + rect.width; + int right = lhs > rhs ? lhs : rhs; + lhs = y + height; + rhs = rect.y + rect.height; + int bottom = lhs > rhs ? lhs : rhs; + x = left; y = top; width = right - left; height = bottom - top; +} + +/** + * Returns true if the point specified by the + * arguments is inside the area specified by the receiver, + * and false otherwise. + * + * @param x the x coordinate of the point to test for containment + * @param y the y coordinate of the point to test for containment + * @return true if the rectangle contains the point and false otherwise + */ +public bool contains (int x, int y) { + return (x >= this.x) && (y >= this.y) && ((x - this.x) < width) && ((y - this.y) < height); +} + +/** + * Returns true if the given point is inside the + * area specified by the receiver, and false + * otherwise. + * + * @param pt the point to test for containment + * @return true if the rectangle contains the point and false otherwise + * + * @exception IllegalArgumentException + */ +public bool contains (Point pt) { + if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + return contains(pt.x, pt.y); +} + +/** + * Compares the argument to the receiver, and returns true + * if they represent the same object using a class + * specific comparison. + * + * @param object the object to compare with this object + * @return true if the object is the same as this object and false otherwise + * + * @see #hashCode() + */ +public override int opEquals (Object object) { + if (object is this) return true; + if( auto r = cast(Rectangle) object ){ + return (r.x == this.x) && (r.y == this.y) && (r.width == this.width) && (r.height == this.height); + } + return false; +} + +/** + * Returns an integer hash code for the receiver. Any two + * objects that return true when passed to + * equals must return the same value for this + * method. + * + * @return the receiver's hash + * + * @see #equals(Object) + */ +public override hash_t toHash () { + return x ^ y ^ width ^ height; +} + +/** + * Destructively replaces the x, y, width and height values + * in the receiver with ones which represent the intersection of the + * rectangles specified by the receiver and the given rectangle. + * + * @param rect the rectangle to intersect with the receiver + * + * @exception IllegalArgumentException + * + * since 3.0 + */ +public void intersect (Rectangle rect) { + if (rect is null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (this is rect) return; + int left = x > rect.x ? x : rect.x; + int top = y > rect.y ? y : rect.y; + int lhs = x + width; + int rhs = rect.x + rect.width; + int right = lhs < rhs ? lhs : rhs; + lhs = y + height; + rhs = rect.y + rect.height; + int bottom = lhs < rhs ? lhs : rhs; + x = right < left ? 0 : left; + y = bottom < top ? 0 : top; + width = right < left ? 0 : right - left; + height = bottom < top ? 0 : bottom - top; +} + +/** + * Returns a new rectangle which represents the intersection + * of the receiver and the given rectangle. + *

+ * The intersection of two rectangles is the rectangle that + * covers the area which is contained within both rectangles. + *

+ * + * @param rect the rectangle to intersect with the receiver + * @return the intersection of the receiver and the argument + * + * @exception IllegalArgumentException + */ +public Rectangle intersection (Rectangle rect) { + if (rect is null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (this is rect) return new Rectangle (x, y, width, height); + int left = x > rect.x ? x : rect.x; + int top = y > rect.y ? y : rect.y; + int lhs = x + width; + int rhs = rect.x + rect.width; + int right = lhs < rhs ? lhs : rhs; + lhs = y + height; + rhs = rect.y + rect.height; + int bottom = lhs < rhs ? lhs : rhs; + return new Rectangle ( + right < left ? 0 : left, + bottom < top ? 0 : top, + right < left ? 0 : right - left, + bottom < top ? 0 : bottom - top); +} + +/** + * Returns true if the rectangle described by the + * arguments intersects with the receiver and false + * otherwise. + *

+ * Two rectangles intersect if the area of the rectangle + * representing their intersection is not empty. + *

+ * + * @param x the x coordinate of the origin of the rectangle + * @param y the y coordinate of the origin of the rectangle + * @param width the width of the rectangle + * @param height the height of the rectangle + * @return true if the rectangle intersects with the receiver, and false otherwise + * + * @exception IllegalArgumentException + * + * @see #intersection(Rectangle) + * @see #isEmpty() + * + * @since 3.0 + */ +public bool intersects (int x, int y, int width, int height) { + return (x < this.x + this.width) && (y < this.y + this.height) && + (x + width > this.x) && (y + height > this.y); +} + +/** + * Returns true if the given rectangle intersects + * with the receiver and false otherwise. + *

+ * Two rectangles intersect if the area of the rectangle + * representing their intersection is not empty. + *

+ * + * @param rect the rectangle to test for intersection + * @return true if the rectangle intersects with the receiver, and false otherwise + * + * @exception IllegalArgumentException + * + * @see #intersection(Rectangle) + * @see #isEmpty() + */ +public bool intersects (Rectangle rect) { + if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + return rect == this || intersects (rect.x, rect.y, rect.width, rect.height); +} + +/** + * Returns true if the receiver does not cover any + * area in the (x, y) coordinate plane, and false if + * the receiver does cover some area in the plane. + *

+ * A rectangle is considered to cover area in the + * (x, y) coordinate plane if both its width and height are + * non-zero. + *

+ * + * @return true if the receiver is empty, and false otherwise + */ +public bool isEmpty () { + return (width <= 0) || (height <= 0); +} + +/** + * Returns a string containing a concise, human-readable + * description of the receiver. + * + * @return a string representation of the rectangle + */ +public override char[] toString () { + return Format( "Rectangle {}, {}, {}, {}}", x, y, width, height ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ +} + +/** + * Returns a new rectangle which represents the union of + * the receiver and the given rectangle. + *

+ * The union of two rectangles is the smallest single rectangle + * that completely covers both of the areas covered by the two + * given rectangles. + *

+ * + * @param rect the rectangle to perform union with + * @return the union of the receiver and the argument + * + * @exception IllegalArgumentException + * + * @see #add(Rectangle) + */ +public Rectangle makeUnion (Rectangle rect) { + if (rect is null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + int left = x < rect.x ? x : rect.x; + int top = y < rect.y ? y : rect.y; + int lhs = x + width; + int rhs = rect.x + rect.width; + int right = lhs > rhs ? lhs : rhs; + lhs = y + height; + rhs = rect.y + rect.height; + int bottom = lhs > rhs ? lhs : rhs; + return new Rectangle (left, top, right - left, bottom - top); +} + +} diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/graphics/Resource.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/eclipse/swt/graphics/Resource.d Sat Jan 05 03:24:35 2008 +0100 @@ -0,0 +1,80 @@ +/******************************************************************************* + * Copyright (c) 2000, 2005 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module org.eclipse.swt.graphics.Resource; + +import org.eclipse.swt.SWT; + +//PORTING_TYPE +class Device{} + +/** + * This class is the abstract superclass of all graphics resource objects. + * Resources created by the application must be disposed. + *

+ * IMPORTANT: This class is intended to be subclassed only + * within the SWT implementation. However, it has not been marked + * final to allow those outside of the SWT development team to implement + * patched versions of the class in order to get around specific + * limitations in advance of when those limitations can be addressed + * by the team. Any class built using subclassing to access the internals + * of this class will likely fail to compile or run between releases and + * may be strongly platform specific. Subclassing should not be attempted + * without an intimate and detailed understanding of the workings of the + * hierarchy. No support is provided for user-written classes which are + * implemented as subclasses of this class. + *

+ * + * @see #dispose + * @see #isDisposed + * + * @since 3.1 + */ +public abstract class Resource { + + /** + * the device where this resource was created + */ + Device device; + +/** + * Disposes of the operating system resources associated with + * this resource. Applications must dispose of all resources + * which they allocate. + */ +public abstract void dispose(); + +/** + * Returns the Device where this resource was + * created. + * + * @return Device the device of the receiver + * + * @since 3.2 + */ +public Device getDevice() { + Device device = this.device; + if (device is null || isDisposed ()) SWT.error (SWT.ERROR_GRAPHIC_DISPOSED); + return device; +} + +/** + * Returns true if the resource has been disposed, + * and false otherwise. + *

+ * This method gets the dispose state for the resource. + * When a resource has been disposed, it is an error to + * invoke any other method using the resource. + * + * @return true when the resource is disposed and false otherwise + */ +public abstract bool isDisposed(); + +} diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/internal/CloneableCompatibility.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/eclipse/swt/internal/CloneableCompatibility.d Sat Jan 05 03:24:35 2008 +0100 @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module org.eclipse.swt.internal.CloneableCompatibility; + +//PORTING_TYPE +interface Cloneable{} + +/** + * This interface is the cross-platform version of the + * java.lang.Cloneable interface. + *

+ * It is part of our effort to provide support for both J2SE + * and J2ME platforms. Under this scheme, classes need to + * implement CloneableCompatibility instead of java.lang.Cloneable. + *

+ *

+ * Note: java.lang.Cloneable is not part of CLDC. + *

+ */ +public interface CloneableCompatibility : Cloneable { +} diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/internal/Compatibility.d --- a/org/eclipse/swt/internal/Compatibility.d Sat Jan 05 02:29:20 2008 +0100 +++ b/org/eclipse/swt/internal/Compatibility.d Sat Jan 05 03:24:35 2008 +0100 @@ -23,6 +23,8 @@ import Math = tango.math.Math; import Unicode = tango.text.Unicode; import tango.sys.Process; +import tango.io.stream.FileStream; +import tango.io.compress.ZlibStream; /** * This class is a placeholder for utility methods commonly @@ -150,7 +152,7 @@ } return 1; } -/++ + /** * Open a file if such things are supported. * @@ -158,8 +160,8 @@ * @return a stream on the file if it could be opened. * @exception IOException */ -public static InputStream newFileInputStream(String filename) throws IOException { - return new FileInputStream(filename); +public static InputStream newFileInputStream(char[] filename) { + return new FileInput(filename); } /** @@ -169,8 +171,8 @@ * @return a stream on the file if it could be opened. * @exception IOException */ -public static OutputStream newFileOutputStream(String filename) throws IOException { - return new FileOutputStream(filename); +public static OutputStream newFileOutputStream(char[] filename) { + return new FileOutput(filename); } /** @@ -182,10 +184,10 @@ * * @since 3.3 */ -public static InputStream newInflaterInputStream(InputStream stream) throws IOException { - return new InflaterInputStream(stream); +public static InputStream newInflaterInputStream(InputStream stream) { + return new ZlibInput(stream); } -++/ + /** * Answers whether the character is a letter. * diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/internal/Converter.d --- a/org/eclipse/swt/internal/Converter.d Sat Jan 05 02:29:20 2008 +0100 +++ b/org/eclipse/swt/internal/Converter.d Sat Jan 05 03:24:35 2008 +0100 @@ -63,7 +63,7 @@ return chars; } -/+ +/+ // only difference with String vs. char[] arg, so no diff in dwt public static char [] wcsToMbcs (char[] codePage, String str, bool terminate) { int length = str.length (); wchar [] buffer = new wchar [length]; diff -r 5dfd6e42e2ef -r 94c5d794407f org/eclipse/swt/internal/SerializableCompatibility.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org/eclipse/swt/internal/SerializableCompatibility.d Sat Jan 05 03:24:35 2008 +0100 @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +module org.eclipse.swt.internal.SerializableCompatibility; + + +//import java.io.Serializable; +///PORTING_TYPE +interface Serializable{} + +/** + * This interface is the cross-platform version of the + * java.io.Serializable interface. + *

+ * It is part of our effort to provide support for both J2SE + * and J2ME platforms. Under this scheme, classes need to + * implement SerializableCompatibility instead of + * java.io.Serializable. + *

+ *

+ * Note: java.io.Serializable is not part of CLDC. + *

+ */ +public interface SerializableCompatibility : Serializable { +} diff -r 5dfd6e42e2ef -r 94c5d794407f todo.txt --- a/todo.txt Sat Jan 05 02:29:20 2008 +0100 +++ b/todo.txt Sat Jan 05 03:24:35 2008 +0100 @@ -1,37 +1,37 @@ -SWT -SWTException -SWTError +SWT // left: getMessage -> Compatibility:ResourceBundle +SWTError // OK +SWTException // OK +graphics/Color +graphics/Cursor graphics/Device -graphics/LineAttributes +graphics/DeviceData +graphics/Drawable graphics/Font graphics/FontData -graphics/TextStyle -graphics/Region -graphics/DeviceData +graphics/FontMetrics // OK +graphics/GC +graphics/GCData +graphics/GlyphMetrics +graphics/Image +graphics/ImageData +graphics/ImageDataLoader graphics/ImageLoader +graphics/ImageLoaderEvent graphics/ImageLoaderListener -graphics/Point -graphics/ImageData -graphics/GCData -graphics/Cursor -graphics/GlyphMetrics -graphics/FontMetrics +graphics/LineAttributes +graphics/PaletteData +graphics/Path +graphics/PathData // OK +graphics/Pattern +graphics/Point // OK +graphics/Rectangle // OK (meth union->makeUnion) +graphics/Region +graphics/Resource // OK (stub: Display) +graphics/RGB // OK graphics/TextLayout -graphics/Drawable -graphics/Color -graphics/Image -graphics/ImageDataLoader -graphics/Resource -graphics/GC -graphics/ImageLoaderEvent -graphics/Rectangle -graphics/Path -graphics/RGB -graphics/PaletteData -graphics/Pattern +graphics/TextStyle graphics/Transform -graphics/PathData widgets/TableColumn widgets/DirectoryDialog @@ -48,7 +48,7 @@ widgets/Canvas widgets/TabFolder widgets/Control -widgets/Event +widgets/Event // refs to GC,Display,Rectangle,.. included dummy types widgets/Link widgets/Combo widgets/ToolTip @@ -105,19 +105,19 @@ -internal/Lock -internal/Library -internal/LONG -internal/SWTEventListener +internal/Lock // OK +internal/Library // OK (loading of lib not needed) +internal/LONG // OK internal/BidiUtil -internal/Compatibility -internal/Platform +internal/Compatibility // left: ResourceBundle, interrupt() +internal/Platform // OK internal/C internal/Callback -internal/Converter -internal/SWTEventObject -internal/CloneableCompatibility -internal/SerializableCompatibility +internal/Converter // left: gtk function prototypes +internal/SWTEventObject // OK (java.util.EventObject) +internal/SWTEventListener // OK (java.util.EventListener) +internal/CloneableCompatibility // OK (java.lang.Cloneable) +internal/SerializableCompatibility // OK (java.io.Serializable) internal/gnome/GnomeVFSMimeApplication internal/gnome/GNOME @@ -240,56 +240,56 @@ internal/gtk/GtkSelectionData internal/gtk/GtkFileSelection -events/ShellAdapter -events/SelectionListener -events/TreeListener -events/MenuDetectListener -events/SelectionAdapter -events/KeyAdapter -events/TreeEvent -events/ControlListener -events/ArmEvent -events/DragDetectEvent -events/PaintListener -events/MenuEvent -events/DisposeEvent -events/MouseEvent -events/ShellListener -events/SelectionEvent -events/ControlAdapter -events/ExpandListener -events/MouseTrackListener -events/FocusListener -events/TreeAdapter -events/MenuListener -events/FocusEvent -events/FocusAdapter -events/MenuAdapter -events/MouseWheelListener -events/HelpListener -events/ExpandAdapter -events/TraverseEvent -events/MouseListener -events/ShellEvent -events/KeyEvent -events/ExpandEvent -events/MenuDetectEvent -events/VerifyEvent -events/TraverseListener -events/ArmListener -events/ModifyListener -events/MouseMoveListener -events/ModifyEvent -events/KeyListener -events/VerifyListener -events/PaintEvent -events/HelpEvent -events/DragDetectListener -events/TypedEvent -events/ControlEvent -events/MouseTrackAdapter -events/DisposeListener -events/MouseAdapter +events/ShellAdapter // OK +events/SelectionListener // OK +events/TreeListener // OK +events/MenuDetectListener // OK +events/SelectionAdapter // OK +events/KeyAdapter // OK +events/TreeEvent // OK +events/ControlListener // OK +events/ArmEvent // OK +events/DragDetectEvent // OK +events/PaintListener // OK +events/MenuEvent // OK +events/DisposeEvent // OK +events/MouseEvent // OK +events/ShellListener // OK +events/SelectionEvent // OK +events/ControlAdapter // OK +events/ExpandListener // OK +events/MouseTrackListener // OK +events/FocusListener // OK +events/TreeAdapter // OK +events/MenuListener // OK +events/FocusEvent // OK +events/FocusAdapter // OK +events/MenuAdapter // OK +events/MouseWheelListener // OK +events/HelpListener // OK +events/ExpandAdapter // OK +events/TraverseEvent // OK +events/MouseListener // OK +events/ShellEvent // OK +events/KeyEvent // OK +events/ExpandEvent // OK +events/MenuDetectEvent // OK +events/VerifyEvent // OK +events/TraverseListener // OK +events/ArmListener // OK +events/ModifyListener // OK +events/MouseMoveListener // OK +events/ModifyEvent // OK +events/KeyListener // OK +events/VerifyListener // OK +events/PaintEvent // OK +events/HelpEvent // OK +events/DragDetectListener // OK +events/TypedEvent // OK +events/ControlEvent // OK +events/MouseTrackAdapter // OK +events/DisposeListener // OK +events/MouseAdapter // OK // not sure what this is