comparison dwt/graphics/Cursor.d @ 36:db5a898b2119

Fixed a lot of compile errors
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 07 Oct 2008 12:56:18 +0200
parents 7d135fe0caf2
children d8635bb48c7c
comparison
equal deleted inserted replaced
35:7d135fe0caf2 36:db5a898b2119
58 * Note: Only one of the above styles may be specified. 58 * Note: Only one of the above styles may be specified.
59 * </p> 59 * </p>
60 */ 60 */
61 61
62 public final class Cursor : Resource { 62 public final class Cursor : Resource {
63
64 alias Resource.init_ init_;
63 65
64 /** 66 /**
65 * the handle to the OS cursor resource 67 * the handle to the OS cursor resource
66 * (Warning: This field is platform dependent) 68 * (Warning: This field is platform dependent)
67 * <p> 69 * <p>
149 default: 151 default:
150 DWT.error(DWT.ERROR_INVALID_ARGUMENT); 152 DWT.error(DWT.ERROR_INVALID_ARGUMENT);
151 } 153 }
152 handle.retain(); 154 handle.retain();
153 handle.setOnMouseEntered(true); 155 handle.setOnMouseEntered(true);
154 init(); 156 init_();
155 } 157 }
156 158
157 /** 159 /**
158 * Constructs a new cursor given a device, image and mask 160 * Constructs a new cursor given a device, image and mask
159 * data describing the desired cursor appearance, and the x 161 * data describing the desired cursor appearance, and the x
227 } 229 }
228 offset += 4; 230 offset += 4;
229 } 231 }
230 } 232 }
231 createNSCursor(hotspotX, hotspotY, data, source.width, source.height); 233 createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
232 init(); 234 init_();
233 } 235 }
234 236
235 void createNSCursor(int hotspotX, int hotspotY, byte[] buffer, int width, int height) { 237 void createNSCursor(int hotspotX, int hotspotY, byte[] buffer, int width, int height) {
238 ubyte** dummy;
236 NSImage nsImage = cast(NSImage)(new NSImage()).alloc(); 239 NSImage nsImage = cast(NSImage)(new NSImage()).alloc();
237 NSBitmapImageRep nsImageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc(); 240 NSBitmapImageRep nsImageRep = cast(NSBitmapImageRep)(new NSBitmapImageRep()).alloc();
238 handle = cast(NSCursor)(new NSCursor()).alloc(); 241 handle = cast(NSCursor)(new NSCursor()).alloc();
239 NSSize size = NSSize(); 242 NSSize size = NSSize();
240 size.width = width; 243 size.width = width;
241 size.height = height; 244 size.height = height;
242 nsImage = nsImage.initWithSize(size); 245 nsImage = nsImage.initWithSize(size);
243 nsImageRep = nsImageRep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(0, cast(NSInteger) width, cast(NSInteger) height, 246 nsImageRep = nsImageRep.initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bitmapFormat_bytesPerRow_bitsPerPixel_(dummy, cast(NSInteger) width, cast(NSInteger) height,
244 8, 4, true, false, new NSString(OS.NSDeviceRGBColorSpace()), 247 8, 4, true, false, OS.NSDeviceRGBColorSpace,
245 OS.NSAlphaFirstBitmapFormat | OS.NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) (width * 4, 32)); 248 NSAlphaFirstBitmapFormat | NSAlphaNonpremultipliedBitmapFormat, cast(NSInteger) (width * 4), 32);
246 OS.memmove(nsImageRep.bitmapData(), buffer, buffer.length); 249 OS.memmove(cast(void*) nsImageRep.bitmapData(), buffer.ptr, buffer.length);
247 nsImage.addRepresentation(nsImageRep); 250 nsImage.addRepresentation(nsImageRep);
248 NSPoint point = NSPoint(); 251 NSPoint point = NSPoint();
249 point.x = hotspotX; 252 point.x = hotspotX;
250 point.y = hotspotY; 253 point.y = hotspotY;
251 handle = handle.initWithImage_hotSpot_(nsImage, point); 254 handle = handle.initWithImage_hotSpot_(nsImage, point);
336 for (int i=0; i<data.length; i+=4) { 339 for (int i=0; i<data.length; i+=4) {
337 data[i] = alphaData[i/4]; 340 data[i] = alphaData[i/4];
338 } 341 }
339 } 342 }
340 createNSCursor(hotspotX, hotspotY, data, source.width, source.height); 343 createNSCursor(hotspotX, hotspotY, data, source.width, source.height);
341 init(); 344 init_();
342 } 345 }
343 346
344 void destroy() { 347 void destroy() {
345 handle.release(); 348 handle.release();
346 handle = null; 349 handle = null;
361 if (!( null !is cast(Cursor)object )) return false; 364 if (!( null !is cast(Cursor)object )) return false;
362 Cursor cursor = cast(Cursor) object; 365 Cursor cursor = cast(Cursor) object;
363 return device is cursor.device && handle is cursor.handle; 366 return device is cursor.device && handle is cursor.handle;
364 } 367 }
365 368
366 alias opEequals equals; 369 alias opEquals equals;
367 370
368 /** 371 /**
369 * Returns an integer hash code for the receiver. Any two 372 * Returns an integer hash code for the receiver. Any two
370 * objects that return <code>true</code> when passed to 373 * objects that return <code>true</code> when passed to
371 * <code>equals</code> must return the same value for this 374 * <code>equals</code> must return the same value for this
373 * 376 *
374 * @return the receiver's hash 377 * @return the receiver's hash
375 * 378 *
376 * @see #equals 379 * @see #equals
377 */ 380 */
378 public hast_t toHash () { 381 public hash_t toHash () {
379 return handle !is null ? handle.id_ : 0; 382 return handle !is null ? cast(hash_t) handle.id_ : 0;
380 } 383 }
381 384
382 alias toHash hashCode; 385 alias toHash hashCode;
383 386
384 /** 387 /**