Changeset 213:36f5cb12e1a2 for dwt/graphics/Pattern.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/graphics/Pattern.d (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/graphics/Pattern.d
r212 r213 44 44 */ 45 45 public class Pattern : Resource { 46 46 alias Resource.init_ init_; 47 47 /** 48 48 * the OS resource for the Pattern … … 83 83 */ 84 84 public this(Device device, Image image) { 85 if (device is null) device = Device.getDevice(); 86 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 85 super(device); 87 86 if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 88 87 if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 89 this.device = device; 90 device.checkGDIP(); 91 int[] gdipImage = image.createGdipImage(); 92 auto img = cast(Gdip.Image)gdipImage[0]; 88 this.device.checkGDIP(); 89 int /*long*/[] gdipImage = image.createGdipImage(); 90 auto img = cast(Gdip.Image) gdipImage[0]; 93 91 int width = Gdip.Image_GetWidth(img); 94 92 int height = Gdip.Image_GetHeight(img); … … 100 98 } 101 99 if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES); 102 i f (device.tracking) device.new_Object(this);100 init_(); 103 101 } 104 102 … … 176 174 */ 177 175 public this(Device device, float x1, float y1, float x2, float y2, Color color1, int alpha1, Color color2, int alpha2) { 178 if (device is null) device = Device.getDevice(); 179 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 176 super(device); 180 177 if (color1 is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 181 178 if (color1.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 182 179 if (color2 is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 183 180 if (color2.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 184 this.device = device; 185 device.checkGDIP(); 181 this.device.checkGDIP(); 186 182 auto colorRef1 = color1.handle; 187 183 int rgb = ((colorRef1 >> 16) & 0xFF) | (colorRef1 & 0xFF00) | ((colorRef1 & 0xFF) << 16); … … 216 212 f[1] = 0.5f; 217 213 f[2] = 1; 218 Gdip.LinearGradientBrush_SetInterpolationColors( cast(Gdip.LinearGradientBrush)handle, c , f, 3);214 Gdip.LinearGradientBrush_SetInterpolationColors( cast(Gdip.LinearGradientBrush)handle, c.ptr, f.ptr, 3); 219 215 Gdip.Color_delete(midColor); 220 216 } … … 222 218 } 223 219 Gdip.Color_delete(foreColor); 224 if (device.tracking) device.new_Object(this); 225 } 226 227 /** 228 * Disposes of the operating system resources associated with 229 * the Pattern. Applications must dispose of all Patterns that 230 * they allocate. 231 */ 232 override public void dispose() { 233 if (handle is null) return; 234 if (device.isDisposed()) return; 220 init_(); 221 } 222 223 void destroy() { 235 224 int type = Gdip.Brush_GetType(handle); 236 225 switch (type) { … … 250 239 } 251 240 handle = null; 252 if (device.tracking) device.dispose_Object(this);253 device = null;254 241 } 255 242
