Mercurial > projects > dwt-win
diff dwt/graphics/Color.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | ab60f3309436 |
children | fd9c62a2998e |
line wrap: on
line diff
--- a/dwt/graphics/Color.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/graphics/Color.d Sat May 17 17:34:28 2008 +0200 @@ -40,6 +40,8 @@ public final class Color : Resource { + alias Resource.init_ init_; + /** * the handle to the OS color resource * (Warning: This field is platform dependent) @@ -55,7 +57,8 @@ /** * Prevents uninitialized instances from being created outside the package. */ -this() { +this(Device device) { + super(device); } /** @@ -83,10 +86,9 @@ * @see #dispose */ public this (Device device, int red, int green, int blue) { - if (device is null) device = Device.getDevice(); - if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - init_(device, red, green, blue); - if (device.tracking) device.new_Object(this); + super(device); + init_(red, green, blue); + init_(); } /** @@ -112,22 +114,13 @@ * @see #dispose */ public this (Device device, RGB rgb) { - if (device is null) device = Device.getDevice(); - if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); + super(device); if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - init_(device, rgb.red, rgb.green, rgb.blue); - if (device.tracking) device.new_Object(this); + init_(rgb.red, rgb.green, rgb.blue); + init_(); } -/** - * Disposes of the operating system resources associated with - * the color. Applications must dispose of all colors which - * they allocate. - */ -override public void dispose() { - if (handle is -1) return; - if (device.isDisposed()) return; - +void destroy() { /* * If this is a palette-based device, * Decrease the reference count for this color. @@ -143,8 +136,6 @@ } } handle = -1; - if (device.tracking) device.dispose_Object(this); - device = null; } /** @@ -249,11 +240,10 @@ * * @see #dispose */ -void init_(Device device, int red, int green, int blue) { +void init_(int red, int green, int blue) { if (red > 255 || red < 0 || green > 255 || green < 0 || blue > 255 || blue < 0) { DWT.error(DWT.ERROR_INVALID_ARGUMENT); } - this.device = device; handle = (red & 0xFF) | ((green & 0xFF) << 8) | ((blue & 0xFF) << 16); /* If this is not a palette-based device, return */ @@ -338,10 +328,8 @@ * @return a new color object containing the specified device and handle */ public static Color win32_new(Device device, int handle) { - if (device is null) device = Device.getDevice(); - Color color = new Color(); + Color color = new Color(device); color.handle = handle; - color.device = device; return color; }