Mercurial > projects > dwt-mac
diff dwt/graphics/Pattern.d @ 30:93b13b15f0b1
Ported a couple of modules in dwt.graphics
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Thu, 11 Sep 2008 23:16:53 +0200 |
parents | e831403a80a9 |
children | db5a898b2119 |
line wrap: on
line diff
--- a/dwt/graphics/Pattern.d Wed Sep 10 23:18:26 2008 +0200 +++ b/dwt/graphics/Pattern.d Thu Sep 11 23:16:53 2008 +0200 @@ -7,6 +7,9 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.Pattern; @@ -19,6 +22,15 @@ import dwt.internal.cocoa.NSGradient; import dwt.internal.cocoa.NSPoint; +import tango.text.convert.Format; + +import dwt.graphics.Color; +import dwt.graphics.Device; +import dwt.graphics.GC; +import dwt.graphics.Image; +import dwt.graphics.Resource; +import dwt.internal.cocoa.CGFloat; + /** * Instances of this class represent patterns to use while drawing. Patterns * can be specified either as bitmaps or gradients. @@ -154,8 +166,8 @@ if (color1.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); if (color2 is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (color2.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); - pt1 = new NSPoint(); - pt2 = new NSPoint(); + pt1 = NSPoint(); + pt2 = NSPoint(); pt1.x = x1; pt1.y = y1; pt2.x = x2; @@ -164,9 +176,9 @@ this.color2 = color2.handle; this.alpha1 = alpha1; this.alpha2 = alpha2; - NSColor start = NSColor.colorWithDeviceRed(color1.handle[0], color1.handle[1], color1.handle[2], alpha1 / 255f); - NSColor end = NSColor.colorWithDeviceRed(color2.handle[0], color2.handle[1], color2.handle[2], alpha2 / 255f); - gradient = (cast(NSGradient)new NSGradient().alloc()).initWithStartingColor(start, end); + NSColor start = NSColor.colorWithDeviceRed(cast(CGFloat) color1.handle[0], cast(CGFloat) color1.handle[1], cast(CGFloat) color1.handle[2], cast(CGFloat) (alpha1 / 255f)); + NSColor end = NSColor.colorWithDeviceRed(cast(CGFloat) color2.handle[0], cast(CGFloat) color2.handle[1], cast(CGFloat) color2.handle[2], cast(CGFloat) (alpha2 / 255f)); + gradient = (cast(NSGradient)(new NSGradient()).alloc()).initWithStartingColor(start, end); init(); } @@ -201,7 +213,7 @@ */ public String toString() { if (isDisposed()) return "Pattern {*DISPOSED*}"; - return "Pattern {" + (color !is null ? color.id : gradient.id) + "}"; + return Format("Pattern {{}{}" , (color !is null ? color.id_ : gradient.id_) , "}"); } }