Mercurial > projects > dwt-win
diff dwt/graphics/Cursor.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/Cursor.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/graphics/Cursor.d Sat May 17 17:34:28 2008 +0200 @@ -54,6 +54,8 @@ public final class Cursor : Resource { + alias Resource.init_ init_; + /** * the handle to the OS cursor resource * (Warning: This field is platform dependent) @@ -149,7 +151,8 @@ /** * Prevents uninitialized instances from being created outside the package. */ -this() { +this(Device device) { + super(device); } /** @@ -194,10 +197,8 @@ * @see DWT#CURSOR_HAND */ public this(Device device, int style) { - if (device is null) device = Device.getDevice(); - if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - this.device = device; - int lpCursorName = 0; + super(device); + int /*long*/ lpCursorName = 0; switch (style) { case DWT.CURSOR_HAND: lpCursorName = OS.IDC_HAND; break; case DWT.CURSOR_ARROW: lpCursorName = OS.IDC_ARROW; break; @@ -240,7 +241,7 @@ } } if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); - if (device.tracking) device.new_Object(this); + init_(); } /** @@ -275,9 +276,7 @@ * </ul> */ public this(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) { - if (device is null) device = Device.getDevice(); - if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - this.device = device; + super(device); if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (mask is null) { if (source.getTransparencyType() !is DWT.TRANSPARENCY_MASK) { @@ -307,7 +306,7 @@ static if (OS.IsWinCE) DWT.error (DWT.ERROR_NOT_IMPLEMENTED); handle = OS.CreateCursor(hInst, hotspotX, hotspotY, source.width, source.height, sourceData.ptr, maskData.ptr); if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); - if (device.tracking) device.new_Object(this); + init_(); } /** @@ -338,9 +337,7 @@ * @since 3.0 */ public this(Device device, ImageData source, int hotspotX, int hotspotY) { - if (device is null) device = Device.getDevice(); - if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); - this.device = device; + super(device); if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); /* Check the hotspots */ if (hotspotX >= source.width || hotspotX < 0 || @@ -348,7 +345,7 @@ DWT.error(DWT.ERROR_INVALID_ARGUMENT); } ImageData mask = source.getTransparencyMask(); - int[] result = Image.init_(device, null, source, mask); + int[] result = Image.init_(this.device, null, source, mask); auto hBitmap = cast(HBITMAP)result[0]; auto hMask = cast(HBITMAP)result[1]; /* Create the icon */ @@ -363,18 +360,10 @@ OS.DeleteObject(hBitmap); OS.DeleteObject(hMask); isIcon = true; - if (device.tracking) device.new_Object(this); + init_(); } -/** - * Disposes of the operating system resources associated with - * the cursor. Applications must dispose of all cursors which - * they allocate. - */ -override public void dispose () { - if (handle is null) return; - if (device.isDisposed()) return; - +void destroy () { /* * It is an error in Windows to destroy the current * cursor. Check that the cursor that is about to @@ -402,8 +391,6 @@ static if (!OS.IsWinCE) OS.DestroyCursor(handle); } handle = null; - if (device.tracking) device.dispose_Object(this); - device = null; } /** @@ -477,10 +464,8 @@ * @return a new cursor object containing the specified device and handle */ public static Cursor win32_new(Device device, HCURSOR handle) { - if (device is null) device = Device.getDevice(); - Cursor cursor = new Cursor(); + Cursor cursor = new Cursor(device); cursor.handle = handle; - cursor.device = device; return cursor; }