From d67b8caceb3f10df6a8e238427498db262144133 Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Mon, 18 Mar 2002 17:48:47 +0000 Subject: *** empty log message *** --- .../gtk/org/eclipse/swt/internal/gtk/OS.java | 4 + .../gtk/org/eclipse/swt/graphics/GC.java | 2576 ++++++++++---------- .../gtk/org/eclipse/swt/graphics/Image.java | 608 +++-- 3 files changed, 1779 insertions(+), 1409 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java index 78a789f47e..6602016841 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java @@ -57,6 +57,10 @@ public class OS { public static final int GDK_GC_LINE_STYLE = 1 << 15; public static final int GDK_GC_CAP_STYLE = 1 << 16; public static final int GDK_GC_JOIN_STYLE = 1 << 17; + + /* GdkImage byte order */ + public static final int GDK_LSB_FIRST = 0; + public static final int GDK_MSB_FIRST = 1; /* For Display.KeyTable: */ /* Keyboard and mouse masks */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java index bf80991565..a9c145cda3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java @@ -5,7 +5,6 @@ package org.eclipse.swt.graphics; * All Rights Reserved */ -import org.eclipse.swt.widgets.*; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.*; @@ -31,14 +30,10 @@ public final class GC { * (Warning: This field is platform dependent) */ public int handle; + Drawable drawable; GCData data; - -/* - * === Constructors === - */ - GC() { } @@ -61,688 +56,969 @@ GC() { */ public GC(Drawable drawable) { if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - - data = new GCData(); - handle = drawable.internal_new_GC(data); - this.drawable = drawable; - - // The colors we get from the widget are not always right. - // Get the default GTK_STATE_NORMAL colors -/* setBackground( DefaultGtkStyle.instance().backgroundColorNORMAL() ); - setForeground( DefaultGtkStyle.instance().foregroundColorNORMAL() ); -*/ - - // Feature in GDK. - // Sometimes, gdk_gc_new() doesn't get the font from the control, - // and also, some controls don't contain a font; so when the GC - // was created in internal_new_gc(), the font might or might not - // be set; if the font isn't there, just fall back to default. - GdkGCValues values = new GdkGCValues(); - OS.gdk_gc_get_values(handle, values); - if (values.font == 0) { -/* OS.gdk_gc_set_font(handle, DefaultGtkStyle.instance().loadDefaultFont() );*/ - } - - if (data.image != null) { - data.image.memGC = this; - /* - * The transparent pixel mask might change when drawing on - * the image. Destroy it so that it is regenerated when - * necessary. - */ - //if (image.transparentPixel != -1) image.destroyMask(); - } - + GCData data = new GCData(); + int gdkGC = drawable.internal_new_GC(data); + init(drawable, data, gdkGC); } - - -/** - * Returns the background color. +/** + * Copies a rectangular area of the receiver at the source + * position onto the receiver at the destination position. * - * @return the receiver's background color + * @param srcX the x coordinate in the receiver of the area to be copied + * @param srcY the y coordinate in the receiver of the area to be copied + * @param width the width of the area to copy + * @param height the height of the area to copy + * @param destX the x coordinate in the receiver of the area to copy to + * @param destY the y coordinate in the receiver of the area to copy to * * @exception SWTException */ -/* - * === Access - Get/Set === - */ -public Color getBackground() { - if (handle == 0) error(SWT.ERROR_WIDGET_DISPOSED); - GdkColor gdkColor = _getBackgroundGdkColor(); - return Color.gtk_new(gdkColor); -} /** - * Sets the background color. The background color is used - * for fill operations and as the background color when text - * is drawn. + * Copies a rectangular area of the receiver at the specified + * position into the image, which must be of type SWT.BITMAP. * - * @param color the new background color for the receiver + * @param x the x coordinate in the receiver of the area to be copied + * @param y the y coordinate in the receiver of the area to be copied * * @exception IllegalArgumentException * @exception SWTException */ -public void setBackground(Color color) { - if (color == null) error(SWT.ERROR_NULL_ARGUMENT); - if (color.handle == null) error(SWT.ERROR_NULL_ARGUMENT); - if (handle == 0) error(SWT.ERROR_WIDGET_DISPOSED); - OS.gdk_gc_set_background(handle, color.handle); +public void copyArea(Image image, int x, int y) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + Rectangle rect = image.getBounds(); + int gdkGC = OS.gdk_gc_new(image.pixmap); + if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); + OS.gdk_gc_set_subwindow(gdkGC, OS.GDK_INCLUDE_INFERIORS); + OS.gdk_draw_drawable(image.pixmap, gdkGC, data.drawable, x, y, 0, 0, rect.width, rect.height); + OS.g_object_unref(gdkGC); } -/** - * Returns the receiver's foreground color. +/** + * Copies a rectangular area of the receiver at the source + * position onto the receiver at the destination position. * - * @return the color used for drawing foreground things + * @param srcX the x coordinate in the receiver of the area to be copied + * @param srcY the y coordinate in the receiver of the area to be copied + * @param width the width of the area to copy + * @param height the height of the area to copy + * @param destX the x coordinate in the receiver of the area to copy to + * @param destY the y coordinate in the receiver of the area to copy to * * @exception SWTException */ -public Color getForeground() { - if (handle == 0) error(SWT.ERROR_WIDGET_DISPOSED); - GdkColor gdkColor = _getForegroundGdkColor(); - return Color.gtk_new(gdkColor); +public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (width <= 0 || height <= 0) return; + int deltaX = destX - srcX, deltaY = destY - srcY; + if (deltaX == 0 && deltaY == 0) return; + int drawable = data.drawable; + OS.gdk_gc_set_exposures(handle, true); + OS.gdk_draw_drawable(drawable, handle, drawable, srcX, srcY, destX, destY, width, height); + OS.gdk_gc_set_exposures(handle, false); + if (data.image != null) return; + boolean disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY); + if (disjoint) { + OS.gdk_window_clear_area_e(drawable, srcX, srcY, width, height); + } else { + if (deltaX != 0) { + int newX = destX - deltaX; + if (deltaX < 0) newX = destX + width; + OS.gdk_window_clear_area_e(drawable, newX, srcY, Math.abs(deltaX), height); + } + if (deltaY != 0) { + int newY = destY - deltaY; + if (deltaY < 0) newY = destY + height; + OS.gdk_window_clear_area_e(drawable, srcX, newY, width, Math.abs(deltaY)); + } + } } /** - * Sets the foreground color. The foreground color is used - * for drawing operations including when text is drawn. - * - * @param color the new foreground color for the receiver - * - * @exception IllegalArgumentException - * @exception SWTException + * Disposes of the operating system resources associated with + * the graphics context. Applications must dispose of all GCs + * which they allocate. */ -public void setForeground(Color color) { - if (handle == 0) error(SWT.ERROR_WIDGET_DISPOSED); - if (color == null) error(SWT.ERROR_NULL_ARGUMENT); - if (color.handle == null) error(SWT.ERROR_NULL_ARGUMENT); - OS.gdk_gc_set_foreground(handle, color.handle); -} - - - - +public void dispose() { + if (handle == 0) return; + if (data.device.isDisposed()) return; + + /* Free resources */ + int clipRgn = data.clipRgn; + if (clipRgn != 0) OS.gdk_region_destroy(clipRgn); + Image image = data.image; + if (image != null) image.memGC = null; + /* Dispose the GC */ + drawable.internal_dispose_GC(handle, data); + data.drawable = data.clipRgn = 0; + drawable = null; + data.image = null; + data = null; + handle = 0; + +} /** - * Returns the advance width of the specified character in - * the font which is currently selected into the receiver. + * Draws the outline of a circular or elliptical arc + * within the specified rectangular area. *

- * The advance width is defined as the horizontal distance the cursor - * should move after printing the character in the selected font. + * The resulting arc begins at startAngle and extends + * for arcAngle degrees, using the current color. + * Angles are interpreted such that 0 degrees is at the 3 o'clock + * position. A positive value indicates a counter-clockwise rotation + * while a negative value indicates a clockwise rotation. + *

+ * The center of the arc is the center of the rectangle whose origin + * is (x, y) and whose size is specified by the + * width and height arguments. + *

+ * The resulting arc covers an area width + 1 pixels wide + * by height + 1 pixels tall. *

* - * @param ch the character to measure - * @return the distance in the x direction to move past the character before painting the next + * @param x the x coordinate of the upper-left corner of the arc to be drawn + * @param y the y coordinate of the upper-left corner of the arc to be drawn + * @param width the width of the arc to be drawn + * @param height the height of the arc to be drawn + * @param startAngle the beginning angle + * @param arcAngle the angular extent of the arc, relative to the start angle * - * @exception SWTException * @exception SWTException */ -public Point stringExtent(String string) { - if (string == null) error(SWT.ERROR_NULL_ARGUMENT); - byte[] buffer = Converter.wcsToMbcs(null, string, true); - int width = OS.gdk_string_width(_getGCFont(), buffer); - int height = OS.gdk_string_height(_getGCFont(), buffer); - return new Point(width, height); +public void drawText (String string, int x, int y, int flags) { + // NOT IMPLEMENTED + drawText(string, x, y, (flags & SWT.DRAW_TRANSPARENT) != 0); } + /** - * Returns the extent of the given string. Tab expansion and - * carriage return processing are performed. + * 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 boolean equals(Object object) { + if (object == this) return true; + if (!(object instanceof GC)) return false; + return handle == ((GC)object).handle; +} + +/** + * Fills the interior of a circular or elliptical arc within + * the specified rectangular area, with the receiver's background + * color. *

- * The extent of a string is the width and height of - * the rectangular area it would cover if drawn in a particular - * font (in this case, the current font in the receiver). + * The resulting arc begins at startAngle and extends + * for arcAngle degrees, using the current color. + * Angles are interpreted such that 0 degrees is at the 3 o'clock + * position. A positive value indicates a counter-clockwise rotation + * while a negative value indicates a clockwise rotation. + *

+ * The center of the arc is the center of the rectangle whose origin + * is (x, y) and whose size is specified by the + * width and height arguments. + *

+ * The resulting arc covers an area width + 1 pixels wide + * by height + 1 pixels tall. *

* - * @param string the string to measure - * @return a point containing the extent of the string + * @param x the x coordinate of the upper-left corner of the arc to be filled + * @param y the y coordinate of the upper-left corner of the arc to be filled + * @param width the width of the arc to be filled + * @param height the height of the arc to be filled + * @param startAngle the beginning angle + * @param arcAngle the angular extent of the arc, relative to the start angle * * @exception IllegalArgumentException * @exception SWTException + * + * @see #drawArc */ -public Point textExtent(String string) { - if (string == null) error(SWT.ERROR_NULL_ARGUMENT); - byte[] buffer = Converter.wcsToMbcs(null, string, true); - int width = OS.gdk_string_width(_getGCFont(), buffer); - int height = OS.gdk_string_height(_getGCFont(), buffer); - return new Point(width, height); -} - - - -/* - * === Access - Internal utils === - */ - -private GdkGCValues _getGCValues() { +public void fillArc(int x, int y, int width, int height, int startAngle, int endAngle) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (width < 0) { + x = x + width; + width = -width; + } + if (height < 0) { + y = y + height; + height = -height; + } + if (width == 0 || height == 0 || endAngle == 0) { + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } GdkGCValues values = new GdkGCValues(); OS.gdk_gc_get_values(handle, values); - return values; -} -private GdkColor _getForegroundGdkColor() { - GdkGCValues values = _getGCValues(); - GdkColor color = new GdkColor(); - color.pixel = values.foreground_pixel; - color.red = values.foreground_red; - color.green = values.foreground_green; - color.blue = values.foreground_blue; - return color; -} -private GdkColor _getBackgroundGdkColor() { - GdkGCValues values = _getGCValues(); GdkColor color = new GdkColor(); color.pixel = values.background_pixel; - color.red = values.background_red; + color.red = values.background_red; color.green = values.background_green; - color.blue = values.background_blue; - return color; -} -private int _getGCFont() { - GdkGCValues values = _getGCValues(); - if (values.font==0) { - values.font = OS.gdk_font_load(Converter.wcsToMbcs(null, "fixed", true)); - if (values.font == 0) SWT.error(SWT.ERROR_NO_HANDLES); - } - return values.font; + color.blue = values.background_blue; + OS.gdk_gc_set_foreground(handle, color); + OS.gdk_draw_arc(data.drawable, handle, 1, x, y, width, height, startAngle * 64, endAngle * 64); + color.pixel = values.foreground_pixel; + color.red = values.foreground_red; + color.green = values.foreground_green; + color.blue = values.foreground_blue; + OS.gdk_gc_set_foreground(handle, color); } - - /** - * Copies a rectangular area of the receiver at the source - * position onto the receiver at the destination position. + * Fills the interior of the specified rectangle with a gradient + * sweeping from left to right or top to bottom progressing + * from the receiver's foreground color to its background color. * - * @param srcX the x coordinate in the receiver of the area to be copied - * @param srcY the y coordinate in the receiver of the area to be copied - * @param width the width of the area to copy - * @param height the height of the area to copy - * @param destX the x coordinate in the receiver of the area to copy to - * @param destY the y coordinate in the receiver of the area to copy to + * @param x the x coordinate of the rectangle to be filled + * @param y the y coordinate of the rectangle to be filled + * @param width the width of the rectangle to be filled, may be negative + * (inverts direction of gradient if horizontal) + * @param height the height of the rectangle to be filled, may be negative + * (inverts direction of gradient if vertical) + * @param vertical if true sweeps from top to bottom, else + * sweeps from left to right * * @exception SWTException - */ -/* - * === Drawing operations proper === - */ - -/** - * Copies a rectangular area of the receiver at the specified - * position into the image, which must be of type SWT.BITMAP. - * - * @param x the x coordinate in the receiver of the area to be copied - * @param y the y coordinate in the receiver of the area to be copied * - * @exception IllegalArgumentException - * @exception SWTException + * @see #drawRectangle */ -public void copyArea(Image image, int x, int y) { +public void fillGradientRectangle(int x, int y, int width, int height, boolean vertical) { if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (image.type != SWT.BITMAP || image.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - Rectangle rect = image.getBounds(); - int xGC = OS.gdk_gc_new(image.pixmap); - if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); - // is it possible/necessary to set the subwindow mode?? - OS.gdk_window_copy_area (image.pixmap, // dest window - xGC, - 0, 0, // dest coords - image.pixmap, // src window - x, y, // src coords - rect.width, rect.height); - OS.gdk_gc_destroy(xGC); -} + if ((width == 0) || (height == 0)) return; + + /* Rewrite this to use GdkPixbuf */ -/** - * Copies a rectangular area of the receiver at the source - * position onto the receiver at the destination position. - * - * @param srcX the x coordinate in the receiver of the area to be copied - * @param srcY the y coordinate in the receiver of the area to be copied - * @param width the width of the area to copy - * @param height the height of the area to copy - * @param destX the x coordinate in the receiver of the area to copy to - * @param destY the y coordinate in the receiver of the area to copy to - * - * @exception SWTException - */ -public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) { - OS.gdk_window_copy_area (data.drawable, handle, - destX, destY, - data.drawable, - srcX, srcY, width, height); + GdkGCValues values = new GdkGCValues(); + OS.gdk_gc_get_values(handle, values); + + RGB backgroundRGB, foregroundRGB; + backgroundRGB = getBackground().getRGB(); + foregroundRGB = getForeground().getRGB(); + + RGB fromRGB, toRGB; + fromRGB = foregroundRGB; + toRGB = backgroundRGB; + boolean swapColors = false; + if (width < 0) { + x += width; width = -width; + if (! vertical) swapColors = true; + } + if (height < 0) { + y += height; height = -height; + if (vertical) swapColors = true; + } + if (swapColors) { + fromRGB = backgroundRGB; + toRGB = foregroundRGB; + } + if (fromRGB == toRGB) { + fillRectangle(x, y, width, height); + return; + } + ImageData.fillGradientRectangle(this, data.device, + x, y, width, height, vertical, fromRGB, toRGB, + 8, 8, 8); } -/** - * Draws the outline of a circular or elliptical arc - * within the specified rectangular area. - *

- * The resulting arc begins at startAngle and extends - * for arcAngle degrees, using the current color. - * Angles are interpreted such that 0 degrees is at the 3 o'clock - * position. A positive value indicates a counter-clockwise rotation - * while a negative value indicates a clockwise rotation. - *

- * The center of the arc is the center of the rectangle whose origin - * is (x, y) and whose size is specified by the - * width and height arguments. - *

- * The resulting arc covers an area width + 1 pixels wide - * by height + 1 pixels tall. - *

+/** + * Fills the interior of an oval, within the specified + * rectangular area, with the receiver's background + * color. * - * @param x the x coordinate of the upper-left corner of the arc to be drawn - * @param y the y coordinate of the upper-left corner of the arc to be drawn - * @param width the width of the arc to be drawn - * @param height the height of the arc to be drawn - * @param startAngle the beginning angle - * @param arcAngle the angular extent of the arc, relative to the start angle + * @param x the x coordinate of the upper left corner of the oval to be filled + * @param y the y coordinate of the upper left corner of the oval to be filled + * @param width the width of the oval to be filled + * @param height the height of the oval to be filled * - * @exception IllegalArgumentException * @exception SWTException + * + * @see #drawOval */ -public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) { +public void fillOval(int x, int y, int width, int height) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (width < 0) { x = x + width; width = -width; @@ -751,968 +1027,803 @@ public void drawArc(int x, int y, int width, int height, int startAngle, int end y = y + height; height = -height; } - if (width == 0 || height == 0 || endAngle == 0) { - error(SWT.ERROR_INVALID_ARGUMENT); - } - OS.gdk_draw_arc(data.drawable, handle, 0, x, y, width, height, startAngle * 64, endAngle * 64); + GdkGCValues values = new GdkGCValues(); + OS.gdk_gc_get_values(handle, values); + GdkColor color = new GdkColor(); + color.pixel = values.background_pixel; + color.red = values.background_red; + color.green = values.background_green; + color.blue = values.background_blue; + OS.gdk_gc_set_foreground(handle, color); + OS.gdk_draw_arc(data.drawable, handle, 1, x, y, width, height, 0, 23040); + color.pixel = values.foreground_pixel; + color.red = values.foreground_red; + color.green = values.foreground_green; + color.blue = values.foreground_blue; + OS.gdk_gc_set_foreground(handle, color); } + /** - * Draws a rectangle, based on the specified arguments, which has - * the appearance of the platform's focus rectangle if the - * platform supports such a notion, and otherwise draws a simple - * rectangle in the receiver's forground color. + * Fills the interior of the closed polygon which is defined by the + * specified array of integer coordinates, using the receiver's + * background color. The array contains alternating x and y values + * which are considered to represent points which are the vertices of + * the polygon. Lines are drawn between each consecutive pair, and + * between the first pair and last pair in the array. * - * @param x the x coordinate of the rectangle - * @param y the y coordinate of the rectangle - * @param width the width of the rectangle - * @param height the height of the rectangle + * @param pointArray an array of alternating x and y values which are the vertices of the polygon * + * @exception IllegalArgumentException * @exception SWTException * - * @see #drawRectangle + * @see #drawPolygon */ -public void drawFocus(int x, int y, int width, int height) { - GtkStyle style = new GtkStyle(OS.gtk_widget_get_default_style()); - GdkColor color = new GdkColor(); - color.pixel = style.fg0_pixel; - color.red = style.fg0_red; - color.green = style.fg0_green; - color.blue = style.fg0_blue; +public void fillPolygon(int[] pointArray) { + if (handle == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); GdkGCValues values = new GdkGCValues(); OS.gdk_gc_get_values(handle, values); + GdkColor color = new GdkColor(); + color.pixel = values.background_pixel; + color.red = values.background_red; + color.green = values.background_green; + color.blue = values.background_blue; OS.gdk_gc_set_foreground(handle, color); - OS.gdk_draw_rectangle(data.drawable, handle, 0, x, y, width, height); + OS.gdk_draw_polygon(data.drawable, handle, 1, pointArray, pointArray.length / 2); color.pixel = values.foreground_pixel; color.red = values.foreground_red; color.green = values.foreground_green; color.blue = values.foreground_blue; OS.gdk_gc_set_foreground(handle, color); } -/** - * Draws the given image in the receiver at the specified - * coordinates. + +/** + * Fills the interior of the rectangle specified by the arguments, + * using the receiver's background color. * - * @param image the image to draw - * @param x the x coordinate of where to draw - * @param y the y coordinate of where to draw + * @param x the x coordinate of the rectangle to be filled + * @param y the y coordinate of the rectangle to be filled + * @param width the width of the rectangle to be filled + * @param height the height of the rectangle to be filled * - * @exception IllegalArgumentException */ public Image(Device display, int width, int height) { - init(display, width, height); - - if (pixmap==0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + init(device, width, height); } /** @@ -178,72 +177,122 @@ public Image(Device display, int width, int height) { * */ public Image(Device device, Image srcImage, int flag) { - /* basic sanity */ if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - this.device = device; if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (srcImage.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + switch (flag) { + case SWT.IMAGE_COPY: + case SWT.IMAGE_DISABLE: + case SWT.IMAGE_GRAY: + break; + default: + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + this.device = device; this.type = srcImage.type; - this.mask = 0; - /* this is somewhat ugly, because this dilutes the encapsulation - * of knowledge about what the cloning operations do (e.g., the - * following lines assume graying and disabling don't change alpha) - */ - this.alphaData = srcImage.alphaData; - this.alpha = srcImage.alpha; - this.transparentPixel = srcImage.transparentPixel; - // FIXME - are we sure about memGC? - - /* Special case: - * If all we want is just a clone of the existing pixmap, it can - * be done entirely in the X server, without copying across the net. - */ - if (flag == SWT.IMAGE_COPY) { - int[] width = new int[1]; int[] height = new int[1]; - OS.gdk_drawable_get_size(srcImage.pixmap, width, height); - int depth = OS.gdk_drawable_get_depth(srcImage.pixmap); - pixmap = OS.gdk_pixmap_new (0, width[0], height[0], depth); - - int gc = OS.gdk_gc_new (pixmap); - OS.gdk_draw_pixmap(pixmap, gc, srcImage.pixmap, - 0,0,0,0, width[0], height[0]); - OS.gdk_gc_destroy(gc); + /* Get source image size */ + int[] w = new int[1], h = new int[1]; + OS.gdk_drawable_get_size(srcImage.pixmap, w, h); + int width = w[0]; + int height = h[0]; + + /* Copy the mask */ + if (srcImage.mask != 0 || srcImage.transparentPixel != -1) { + /* Generate the mask if necessary. */ + if (srcImage.transparentPixel != -1) srcImage.createMask(); + int mask = OS.gdk_pixmap_new(0, width, height, 1); + if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int gdkGC = OS.gdk_gc_new(mask); + if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); + OS.gdk_draw_drawable(mask, gdkGC, srcImage.mask, 0, 0, 0, 0, width, height); + OS.g_object_unref(gdkGC); + this.mask = mask; + /* Destroy the image mask if the there is a GC created on the image */ + if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask(); + } + + /* Copy transparent pixel and alpha data when necessary */ + if (flag != SWT.IMAGE_DISABLE) { transparentPixel = srcImage.transparentPixel; alpha = srcImage.alpha; if (srcImage.alphaData != null) { alphaData = new byte[srcImage.alphaData.length]; System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length); } - - /* we are not quite done yet. Need to copy the maskData */ - if (srcImage.mask != 0) { - /* Generate the mask if necessary. */ -// if (srcImage.transparentPixel != -1) srcImage.createMask(); - mask = OS.gdk_pixmap_new(0, width[0], height[0], 1); - gc = OS.gdk_gc_new(mask); - OS.gdk_draw_pixmap(mask, gc, srcImage.mask, - 0,0,0,0, width[0], height[0]); - OS.gdk_gc_destroy(gc); - /* Destroy the image mask if the there is a GC created on the image */ - if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask(); - } + } + /* Create the new pixmap */ + int pixmap = OS.gdk_pixmap_new (OS.GDK_ROOT_PARENT(), width, height, -1); + if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int gdkGC = OS.gdk_gc_new(pixmap); + if (gdkGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); + this.pixmap = pixmap; - if (pixmap==0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); - + if (flag == SWT.IMAGE_COPY) { + OS.gdk_draw_drawable(pixmap, gdkGC, srcImage.pixmap, 0, 0, 0, 0, width, height); + OS.g_object_unref(gdkGC); return; } - - - - - Pixbuffer pb = new Pixbuffer(srcImage); - Pixbuffer pb2 = new Pixbuffer(pb, flag); - pb2.toImage(this); + /* Retrieve the source pixmap data */ + int pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB(), false, 8, width, height); + if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int colormap = OS.gdk_colormap_get_system(); + OS.gdk_pixbuf_get_from_drawable(pixbuf, srcImage.pixmap, colormap, 0, 0, 0, 0, width, height); + int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); + int pixels = OS.gdk_pixbuf_get_pixels(pixbuf); + + /* Apply transformation */ + switch (flag) { + case SWT.IMAGE_DISABLE: { + byte[] line = new byte[stride]; + for (int y=0; y> 3); + line[offset] = line[offset+1] = line[offset+2] = intensity; + } + OS.memmove(pixels + (y * stride), line, stride); + } + transparentPixel = srcImage.transparentPixel; + alpha = srcImage.alpha; + if (srcImage.alphaData != null) { + alphaData = new byte[srcImage.alphaData.length]; + System.arraycopy(srcImage.alphaData, 0, alphaData, 0, alphaData.length); + } + break; + } + } + /* Copy data back to destination pixmap */ + OS.gdk_pixbuf_render_to_drawable(pixbuf, pixmap, gdkGC, 0, 0, 0, 0, width, height, OS.GDK_RGB_DITHER_NORMAL, 0, 0); + + /* Free resources */ + OS.g_object_unref(pixbuf); + OS.g_object_unref(gdkGC); } /** @@ -257,6 +306,12 @@ public Image(Device device, Image srcImage, int flag) { * gc.drawRectangle(0, 0, 50, 50); * gc.dispose(); * + *

+ * Note: Some platforms may have a limitation on the size + * of image that can be created (size depends on width, height, + * and depth). For example, Windows 95, 98, and ME do not allow + * images larger than 16M. + *

* * @param device the device on which to create the image * @param bounds a rectangle specifying the image's width and height (must not be null) @@ -267,10 +322,10 @@ public Image(Device device, Image srcImage, int flag) { * */ public Image(Device display, Rectangle bounds) { + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - init(display, bounds.width, bounds.height); - - if (pixmap==0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); + init(device, bounds.width, bounds.height); } /** @@ -284,12 +339,10 @@ public Image(Device display, Rectangle bounds) { *
  • ERROR_NULL_ARGUMENT - if the image data is null
  • * */ -public Image(Device display, ImageData image) { - if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (display == null) display = Display.getDefault(); - init(display, image); - - if (pixmap==0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); +public Image(Device device, ImageData data) { + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + init(device, data); } /** @@ -320,27 +373,14 @@ public Image(Device display, ImageData image) { public Image(Device display, ImageData source, ImageData mask) { if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); if (mask == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (display == null) display = Display.getDefault(); - if (source.width != mask.width || source.height != mask.height) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + if (source.width != mask.width || source.height != mask.height) { + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT); - ImageData image; - if (source.depth != 1) - image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data); - else { - image = source.getTransparencyMask(); //create an imagedata with scanlinepad == 1 and invalid data - int[] row = new int[source.width]; - for (int y = 0; y < source.height; y++) { - source.getPixels(0, y, source.width, row, 0); - image.setPixels(0, y, source.width, row, 0); - }//change source data format from scanlinePad == 4 to scanlinePad == 1; - - } - image.type = SWT.ICON; + ImageData image = new ImageData(source.width, source.height, source.depth, source.palette, source.scanlinePad, source.data); image.maskPad = mask.scanlinePad; image.maskData = mask.data; - init(display, image); - - if (pixmap==0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); + init(device, image); } /** @@ -368,12 +408,10 @@ public Image(Device display, ImageData source, ImageData mask) { *
  • ERROR_IO - if an IO error occurs while reading data
  • * */ -public Image(Device display, InputStream stream) { - if (stream == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (display == null) display = Display.getDefault(); - init(display, new ImageData(stream)); - - if (pixmap==0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); +public Image(Device device, InputStream stream) { + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + init(device, new ImageData(stream)); } /** @@ -395,11 +433,27 @@ public Image(Device display, InputStream stream) { * */ public Image(Device display, String filename) { - if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (display == null) display = Display.getDefault(); - init(display, new ImageData(filename)); - - if (pixmap==0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); + if (device == null) device = Device.getDevice(); + if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + init(device, new ImageData(filename)); +} + +/** + * Create the receiver's mask if necessary. + */ +void createMask() { + if (mask != 0) return; + ImageData maskImage = getImageData().getTransparencyMask(); + byte[] maskData = maskImage.data; + for (int i = 0; i < maskData.length; i++) { + byte s = maskData[i]; + maskData[i] = (byte)(((s & 0x80) >> 7) | ((s & 0x40) >> 5) | + ((s & 0x20) >> 3) | ((s & 0x10) >> 1) | ((s & 0x08) << 1) | + ((s & 0x04) << 3) | ((s & 0x02) << 5) | ((s & 0x01) << 7)); + } + int mask = OS.gdk_bitmap_create_from_data(0, maskData, maskImage.bytesPerLine * 8, maskImage.height); + if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES); + this.mask = mask; } /** @@ -407,7 +461,7 @@ public Image(Device display, String filename) { */ void destroyMask() { if (mask == 0) return; - OS.gdk_bitmap_unref(mask); + OS.g_object_unref(mask); mask = 0; } @@ -417,11 +471,15 @@ void destroyMask() { * they allocate. */ public void dispose () { - if (pixmap != 0) OS.gdk_pixmap_unref(pixmap); - if (mask != 0) OS.gdk_pixmap_unref(mask); + if (pixmap == 0) return; + if (device.isDisposed()) return; + if (pixmap != 0) OS.g_object_unref(pixmap); + if (mask != 0) OS.g_object_unref(mask); + device = null; pixmap = mask = 0; memGC = null; } + /** * Compares the argument to the receiver, and returns true * if they represent the same object using a class @@ -433,9 +491,12 @@ public void dispose () { * @see #hashCode */ public boolean equals (Object object) { - return (object == this) || ((object instanceof Image) && - (pixmap == ((Image)object).pixmap) && - (mask == ((Image)object).mask)); + if (object == this) return true; + if (!(object instanceof Image)) return false; + Image image = (Image)object; + return device == image.device && pixmap == image.pixmap && + transparentPixel == image.transparentPixel && + mask == image.mask; } /** @@ -457,48 +518,12 @@ public boolean equals (Object object) { * */ public Color getBackground() { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (transparentPixel == -1) return null; + //NOT DONE return null; } -/** - * Sets the color to which to map the transparent pixel. - *

    - * There are certain uses of Images that do not support - * transparency (for example, setting an image into a button or label). - * In these cases, it may be desired to simulate transparency by using - * the background color of the widget to paint the transparent pixels - * of the image. This method specifies the color that will be used in - * these cases. For example: - *

    - *    Button b = new Button();
    - *    image.setBackground(b.getBackground());>
    - *    b.setImage(image);
    - * 
    - *

    - * The image may be modified by this operation (in effect, the - * transparent regions may be filled with the supplied color). Hence - * this operation is not reversible and it is not legal to call - * this function twice or with a null argument. - *

    - * This method has no effect if the receiver does not have a transparent - * pixel value. - *

    - * - * @param color the color to use when a transparent pixel is specified - * - * @exception IllegalArgumentException - * @exception SWTException - */ -public void setBackground(Color color) { - if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); -} - /** * Returns the bounds of the receiver. The rectangle will always * have x and y values of 0, and the width and height of the @@ -512,11 +537,12 @@ public void setBackground(Color color) { * */ public Rectangle getBounds() { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); int[] width = new int[1]; int[] height = new int[1]; OS.gdk_drawable_get_size(pixmap, width, height); return new Rectangle(0, 0, width[0], height[0]); - } + /** * Returns an ImageData based on the receiver * Modifications made to this ImageData will not @@ -532,17 +558,83 @@ public Rectangle getBounds() { * @see ImageData */ public ImageData getImageData() { - return new Pixbuffer(this).getImageData(); + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + + int[] w = new int[1], h = new int[1]; + OS.gdk_drawable_get_size(pixmap, w, h); + int width = w[0], height = h[0]; + int pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB(), false, 8, width, height); + if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int colormap = OS.gdk_colormap_get_system(); + OS.gdk_pixbuf_get_from_drawable(pixbuf, pixmap, colormap, 0, 0, 0, 0, width, height); + int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); + int pixels = OS.gdk_pixbuf_get_pixels(pixbuf); + byte[] srcData = new byte[stride * height]; + OS.memmove(srcData, pixels, srcData.length); + OS.g_object_unref(pixbuf); + + PaletteData palette = new PaletteData(0xFF0000, 0xFF00, 0xFF); + ImageData data = new ImageData(width, height, 24, palette); + data.data = srcData; + data.bytesPerLine = stride; + + if (transparentPixel == -1 && type == SWT.ICON && mask != 0) { + /* Get the icon mask data */ + int gdkImagePtr = OS.gdk_drawable_get_image(mask, 0, 0, width, height); + if (gdkImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES); + GdkImage gdkImage = new GdkImage(gdkImagePtr); + byte[] maskData = new byte[gdkImage.bpl * height]; + OS.memmove(maskData, gdkImage.mem, maskData.length); + OS.g_object_unref(gdkImagePtr); + + data.maskPad = 4; + data.maskData = maskData; + /* Bit swap the mask data if necessary */ + if (gdkImage.byte_order == OS.GDK_LSB_FIRST) { + for (int i = 0; i < maskData.length; i++) { + byte b = maskData[i]; + maskData[i] = (byte)(((b & 0x01) << 7) | ((b & 0x02) << 5) | + ((b & 0x04) << 3) | ((b & 0x08) << 1) | ((b & 0x10) >> 1) | + ((b & 0x20) >> 3) | ((b & 0x40) >> 5) | ((b & 0x80) >> 7)); + } + } + } + data.transparentPixel = transparentPixel; + data.alpha = alpha; + if (alpha == -1 && alphaData != null) { + data.alphaData = new byte[alphaData.length]; + System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length); + } + return data; } -public static Image gtk_new(int type, int pixmap, int mask) { +/** + * Invokes platform specific functionality to allocate a new image. + *

    + * IMPORTANT: This method is not part of the public + * API for Image. It is marked public only so that it + * can be shared within the packages provided by SWT. It is not + * available on all platforms, and should never be called from + * application code. + *

    + * + * @param device the device on which to allocate the color + * @param type the type of the image (SWT.BITMAP or SWT.ICON) + * @param pixmap the OS handle for the image + * @param mask the OS handle for the image mask + * + * @private + */ +public static Image gtk_new(Device device, int type, int pixmap, int mask) { + if (device == null) device = Device.getDevice(); Image image = new Image(); - if (pixmap==0) SWT.error(SWT.ERROR_CANNOT_BE_ZERO); // FIXME remove this, this is for debugging only image.type = type; image.pixmap = pixmap; image.mask = mask; + image.device = device; return image; } + /** * Returns an integer hash code for the receiver. Any two * objects which return true when passed to @@ -556,6 +648,138 @@ public static Image gtk_new(int type, int pixmap, int mask) { public int hashCode () { return pixmap; } + +void init(Device device, int width, int height) { + if (width <= 0 || height <= 0) { + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + } + this.device = device; + this.type = SWT.BITMAP; + + /* Create the pixmap */ + this.pixmap = OS.gdk_pixmap_new(OS.GDK_ROOT_PARENT(), width, height, -1); + if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES); + /* Fill the bitmap with white */ + GdkColor white = new GdkColor(); + white.red = (short)0xFFFF; + white.green = (short)0xFFFF; + white.blue = (short)0xFFFF; + int colormap = OS.gdk_colormap_get_system(); + OS.gdk_colormap_alloc_color(colormap, white, true, true); + int gdkGC = OS.gdk_gc_new(pixmap); + OS.gdk_gc_set_foreground(gdkGC, white); + OS.gdk_draw_rectangle(pixmap, gdkGC, 1, 0, 0, width, height); + OS.g_object_unref(gdkGC); + OS.gdk_colormap_free_colors(colormap, white, 1); +} + +void init(Device device, ImageData image) { + if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + this.device = device; + int width = image.width; + int height = image.height; + PaletteData palette = image.palette; + int pixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB(), false, 8, width, height); + if (pixbuf == 0) SWT.error(SWT.ERROR_NO_HANDLES); + int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); + int data = OS.gdk_pixbuf_get_pixels(pixbuf); + if (palette.isDirect) { + int redMask = palette.redMask; + int greenMask = palette.greenMask; + int blueMask = palette.blueMask; + int redShift = palette.redShift; + int greenShift = palette.greenShift; + int blueShift = palette.blueShift; + int[] pixels = new int[width]; + byte[] rgbPixels = new byte[stride]; + for (int y=0; y>> -redShift : r << redShift; + int g = pixel & greenMask; + g = (greenShift < 0) ? g >>> -greenShift : g << greenShift; + int b = pixel & blueMask; + b = (blueShift < 0) ? b >>> -blueShift : b << blueShift; + rgbPixels[offset] = (byte)r; + rgbPixels[offset + 1] = (byte)g; + rgbPixels[offset + 2] = (byte)b; + } + OS.memmove(data + (stride * y), rgbPixels, rgbPixels.length); + } + } else { + RGB[] rgbs = palette.colors; + byte[] pixels = new byte[width]; + byte[] rgbPixels = new byte[stride]; + for (int y=0; y> 7) | ((s & 0x40) >> 5) | + ((s & 0x20) >> 3) | ((s & 0x10) >> 1) | ((s & 0x08) << 1) | + ((s & 0x04) << 3) | ((s & 0x02) << 5) | ((s & 0x01) << 7)); + } + int mask = OS.gdk_bitmap_create_from_data(0, maskData, maskImage.bytesPerLine * 8 , height); + if (mask == 0) SWT.error(SWT.ERROR_NO_HANDLES); + this.mask = mask; + if (image.getTransparencyType() == SWT.TRANSPARENCY_MASK) { + this.type = SWT.ICON; + } else { + this.type = SWT.BITMAP; + } + } else { + this.type = SWT.BITMAP; + this.mask = 0; + this.alpha = image.alpha; + if (image.alpha == -1 && image.alphaData != null) { + this.alphaData = new byte[image.alphaData.length]; + System.arraycopy(image.alphaData, 0, this.alphaData, 0, alphaData.length); + } + } + this.pixmap = pixmap; +} + /** * Invokes platform specific functionality to allocate a new GC handle. *

    @@ -573,16 +797,18 @@ public int hashCode () { */ public int internal_new_GC (GCData data) { if (pixmap == 0) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); - if (data == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); if (type != SWT.BITMAP || memGC != null) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - - data.image = this; - int gc = OS.gdk_gc_new(pixmap); - data.drawable = pixmap; - return gc; + int gdkGC = OS.gdk_gc_new(pixmap); + if (data != null) { + data.device = device; + data.drawable = pixmap; + data.image = this; + } + return gdkGC; } + /** * Invokes platform specific functionality to dispose a GC handle. *

    @@ -598,42 +824,8 @@ public int internal_new_GC (GCData data) { * * @private */ -public void internal_dispose_GC (int gc, GCData data) { - OS.gdk_gc_unref(gc); -} - -void init(Device display, int width, int height) { - device = display; - GdkVisual visual = new GdkVisual (OS.gdk_visual_get_system()); - this.pixmap = OS.gdk_pixmap_new(0, width, height, visual.depth); - if (pixmap == 0) SWT.error(SWT.ERROR_NO_HANDLES); - /* Fill the bitmap with white */ - GdkColor white = new GdkColor(); - int colormap = OS.gdk_colormap_get_system(); - OS.gdk_color_white(colormap, white); - int gc = OS.gdk_gc_new(pixmap); - OS.gdk_gc_set_foreground(gc, white); - OS.gdk_draw_rectangle(pixmap, gc, 1, 0, 0, width, height); - OS.gdk_gc_destroy(gc); - OS.gdk_colors_free(colormap, new int[] { white.pixel }, 1, 0); - this.type = SWT.BITMAP; -} - -void init(Device display, ImageData image) { - if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (display == null) display = Display.getCurrent(); - device = display; - - /* - * We don't really care about the real depth of the ImageData we are - * given. We stretch everything to 24bpp which is the native GdkPixbuffer - * depth. HOWEVER, there is one situation where this is not acceptable, - * namely bitmaps (1bpp), because they may be used in contexts that are - * sensitive to pixmap depth. - */ - Pixbuffer buff = new Pixbuffer(image); - buff.toImage(this); - return; +public void internal_dispose_GC (int gdkGC, GCData data) { + OS.g_object_unref(gdkGC); } /** @@ -650,6 +842,48 @@ public boolean isDisposed() { return pixmap == 0; } +/** + * Sets the color to which to map the transparent pixel. + *

    + * There are certain uses of Images that do not support + * transparency (for example, setting an image into a button or label). + * In these cases, it may be desired to simulate transparency by using + * the background color of the widget to paint the transparent pixels + * of the image. This method specifies the color that will be used in + * these cases. For example: + *

    + *    Button b = new Button();
    + *    image.setBackground(b.getBackground());>
    + *    b.setImage(image);
    + * 
    + *

    + * The image may be modified by this operation (in effect, the + * transparent regions may be filled with the supplied color). Hence + * this operation is not reversible and it is not legal to call + * this function twice or with a null argument. + *

    + * This method has no effect if the receiver does not have a transparent + * pixel value. + *

    + * + * @param color the color to use when a transparent pixel is specified + * + * @exception IllegalArgumentException
      + *
    • ERROR_NULL_ARGUMENT - if the color is null
    • + *
    • ERROR_INVALID_ARGUMENT - if the color has been disposed
    • + *
    + * @exception SWTException
      + *
    • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
    • + *
    + */ +public void setBackground(Color color) { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + if (transparentPixel == -1) return; + //NOT DONE +} + /** * Returns a string containing a concise, human-readable * description of the receiver. -- cgit v1.2.3