Changeset 213:36f5cb12e1a2 for dwt/graphics/Cursor.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/graphics/Cursor.d (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/graphics/Cursor.d
r212 r213 54 54 55 55 public final class Cursor : Resource { 56 57 alias Resource.init_ init_; 56 58 57 59 /** … … 150 152 * Prevents uninitialized instances from being created outside the package. 151 153 */ 152 this() { 154 this(Device device) { 155 super(device); 153 156 } 154 157 … … 195 198 */ 196 199 public this(Device device, int style) { 197 if (device is null) device = Device.getDevice(); 198 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 199 this.device = device; 200 int lpCursorName = 0; 200 super(device); 201 int /*long*/ lpCursorName = 0; 201 202 switch (style) { 202 203 case DWT.CURSOR_HAND: lpCursorName = OS.IDC_HAND; break; … … 241 242 } 242 243 if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); 243 i f (device.tracking) device.new_Object(this);244 init_(); 244 245 } 245 246 … … 276 277 */ 277 278 public this(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) { 278 if (device is null) device = Device.getDevice(); 279 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 280 this.device = device; 279 super(device); 281 280 if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 282 281 if (mask is null) { … … 308 307 handle = OS.CreateCursor(hInst, hotspotX, hotspotY, source.width, source.height, sourceData.ptr, maskData.ptr); 309 308 if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); 310 i f (device.tracking) device.new_Object(this);309 init_(); 311 310 } 312 311 … … 339 338 */ 340 339 public this(Device device, ImageData source, int hotspotX, int hotspotY) { 341 if (device is null) device = Device.getDevice(); 342 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 343 this.device = device; 340 super(device); 344 341 if (source is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 345 342 /* Check the hotspots */ … … 349 346 } 350 347 ImageData mask = source.getTransparencyMask(); 351 int[] result = Image.init_( device, null, source, mask);348 int[] result = Image.init_(this.device, null, source, mask); 352 349 auto hBitmap = cast(HBITMAP)result[0]; 353 350 auto hMask = cast(HBITMAP)result[1]; … … 364 361 OS.DeleteObject(hMask); 365 362 isIcon = true; 366 if (device.tracking) device.new_Object(this); 367 } 368 369 /** 370 * Disposes of the operating system resources associated with 371 * the cursor. Applications must dispose of all cursors which 372 * they allocate. 373 */ 374 override public void dispose () { 375 if (handle is null) return; 376 if (device.isDisposed()) return; 377 363 init_(); 364 } 365 366 void destroy () { 378 367 /* 379 368 * It is an error in Windows to destroy the current … … 403 392 } 404 393 handle = null; 405 if (device.tracking) device.dispose_Object(this);406 device = null;407 394 } 408 395 … … 478 465 */ 479 466 public static Cursor win32_new(Device device, HCURSOR handle) { 480 if (device is null) device = Device.getDevice(); 481 Cursor cursor = new Cursor(); 467 Cursor cursor = new Cursor(device); 482 468 cursor.handle = handle; 483 cursor.device = device;484 469 return cursor; 485 470 }
