Changeset 213:36f5cb12e1a2 for dwt/graphics/Color.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/graphics/Color.d (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/graphics/Color.d
r212 r213 40 40 41 41 public final class Color : Resource { 42 43 alias Resource.init_ init_; 42 44 43 45 /** … … 56 58 * Prevents uninitialized instances from being created outside the package. 57 59 */ 58 this() { 60 this(Device device) { 61 super(device); 59 62 } 60 63 … … 84 87 */ 85 88 public this (Device device, int red, int green, int blue) { 86 if (device is null) device = Device.getDevice(); 87 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 88 init_(device, red, green, blue); 89 if (device.tracking) device.new_Object(this); 89 super(device); 90 init_(red, green, blue); 91 init_(); 90 92 } 91 93 … … 113 115 */ 114 116 public this (Device device, RGB rgb) { 115 if (device is null) device = Device.getDevice(); 116 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 117 super(device); 117 118 if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 118 init_(device, rgb.red, rgb.green, rgb.blue); 119 if (device.tracking) device.new_Object(this); 120 } 121 122 /** 123 * Disposes of the operating system resources associated with 124 * the color. Applications must dispose of all colors which 125 * they allocate. 126 */ 127 override public void dispose() { 128 if (handle is -1) return; 129 if (device.isDisposed()) return; 130 119 init_(rgb.red, rgb.green, rgb.blue); 120 init_(); 121 } 122 123 void destroy() { 131 124 /* 132 125 * If this is a palette-based device, … … 144 137 } 145 138 handle = -1; 146 if (device.tracking) device.dispose_Object(this);147 device = null;148 139 } 149 140 … … 250 241 * @see #dispose 251 242 */ 252 void init_( Device device,int red, int green, int blue) {243 void init_(int red, int green, int blue) { 253 244 if (red > 255 || red < 0 || green > 255 || green < 0 || blue > 255 || blue < 0) { 254 245 DWT.error(DWT.ERROR_INVALID_ARGUMENT); 255 246 } 256 this.device = device;257 247 handle = (red & 0xFF) | ((green & 0xFF) << 8) | ((blue & 0xFF) << 16); 258 248 … … 339 329 */ 340 330 public static Color win32_new(Device device, int handle) { 341 if (device is null) device = Device.getDevice(); 342 Color color = new Color(); 331 Color color = new Color(device); 343 332 color.handle = handle; 344 color.device = device;345 333 return color; 346 334 }
