Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSGradient.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children | 62202ce0039f |
comparison
equal
deleted
inserted
replaced
44:ca5e494f2bbf | 45:d8635bb48c7c |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * | 10 * |
11 * Port to the D programming language: | 11 * Port to the D programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <doob@me.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSGradient; | 14 module dwt.internal.cocoa.NSGradient; |
15 | 15 |
16 import dwt.internal.cocoa.CGFloat; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.NSArray; | 17 import dwt.internal.c.Carbon; |
18 import dwt.internal.cocoa.NSBezierPath; | 18 import cocoa = dwt.internal.cocoa.id; |
19 import dwt.internal.cocoa.NSColor; | 19 import dwt.internal.cocoa.NSColor; |
20 import dwt.internal.cocoa.NSColorSpace; | |
21 import dwt.internal.cocoa.NSInteger; | |
22 import dwt.internal.cocoa.NSObject; | 20 import dwt.internal.cocoa.NSObject; |
23 import dwt.internal.cocoa.NSPoint; | 21 import dwt.internal.cocoa.NSPoint; |
24 import dwt.internal.cocoa.NSRect; | 22 import dwt.internal.cocoa.NSRect; |
25 import dwt.internal.cocoa.OS; | 23 import dwt.internal.cocoa.OS; |
24 import dwt.internal.objc.cocoa.Cocoa; | |
26 import objc = dwt.internal.objc.runtime; | 25 import objc = dwt.internal.objc.runtime; |
27 | 26 |
28 alias NSUInteger NSGradientDrawingOptions; | 27 enum NSGradientDrawingOptions : NSUInteger |
28 { | |
29 NSGradientDrawsBeforeStartingLocation = (1 << 0), | |
30 NSGradientDrawsAfterEndingLocation = (1 << 1), | |
31 } | |
29 | 32 |
30 public class NSGradient : NSObject | 33 public class NSGradient : NSObject { |
31 { | |
32 | 34 |
33 public this () | 35 public this() { |
34 { | 36 super(); |
35 super(); | 37 } |
36 } | |
37 | 38 |
38 public this (objc.id id) | 39 public this(objc.id id) { |
39 { | 40 super(id); |
40 super(id); | 41 } |
41 } | |
42 | 42 |
43 public NSColorSpace colorSpace () | 43 public this(cocoa.id id) { |
44 { | 44 super(id); |
45 objc.id result = OS.objc_msgSend(this.id_, OS.sel_colorSpace); | 45 } |
46 return result !is null ? new NSColorSpace(result) : null; | |
47 } | |
48 | 46 |
49 public void drawFromCenter (NSPoint startCenter, CGFloat startRadius, NSPoint endCenter, CGFloat endRadius, NSGradientDrawingOptions options) | 47 public void drawFromPoint(NSPoint startingPoint, NSPoint endingPoint, NSGradientDrawingOptions options) { |
50 { | 48 OS.objc_msgSend(this.id, OS.sel_drawFromPoint_toPoint_options_, startingPoint, endingPoint, options); |
51 OS.objc_msgSend(this.id_, OS.sel_drawFromCenter_1radius_1toCenter_1radius_1options_1, startCenter, startRadius, endCenter, endRadius, options); | 49 } |
52 } | |
53 | 50 |
54 public void drawFromPoint (NSPoint startingPoint, NSPoint endingPoint, NSGradientDrawingOptions options) | 51 public void drawInRect(NSRect rect, CGFloat angle) { |
55 { | 52 OS.objc_msgSend(this.id, OS.sel_drawInRect_angle_, rect, angle); |
56 OS.objc_msgSend(this.id_, OS.sel_drawFromPoint_1toPoint_1options_1, startingPoint, endingPoint, options); | 53 } |
57 } | |
58 | 54 |
59 public void drawInBezierPath_angle_ (NSBezierPath path, CGFloat angle) | 55 public NSGradient initWithStartingColor(NSColor startingColor, NSColor endingColor) { |
60 { | 56 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithStartingColor_endingColor_, startingColor !is null ? startingColor.id : null, endingColor !is null ? endingColor.id : null); |
61 OS.objc_msgSend(this.id_, OS.sel_drawInBezierPath_1angle_1, path !is null ? path.id_ : null, angle); | 57 return result is this.id ? this : (result !is null ? new NSGradient(result) : null); |
62 } | 58 } |
63 | |
64 public void drawInBezierPath_relativeCenterPosition_ (NSBezierPath path, NSPoint relativeCenterPosition) | |
65 { | |
66 OS.objc_msgSend(this.id_, OS.sel_drawInBezierPath_1relativeCenterPosition_1, path !is null ? path.id_ : null, relativeCenterPosition); | |
67 } | |
68 | |
69 public void drawInRect_angle_ (NSRect rect, CGFloat angle) | |
70 { | |
71 OS.objc_msgSend(this.id_, OS.sel_drawInRect_1angle_1, rect, angle); | |
72 } | |
73 | |
74 public void drawInRect_relativeCenterPosition_ (NSRect rect, NSPoint relativeCenterPosition) | |
75 { | |
76 OS.objc_msgSend(this.id_, OS.sel_drawInRect_1relativeCenterPosition_1, rect, relativeCenterPosition); | |
77 } | |
78 | |
79 public void getColor (objc.id** color, CGFloat* location, NSInteger index) | |
80 { | |
81 OS.objc_msgSend(this.id_, OS.sel_getColor_1location_1atIndex_1, color, location, index); | |
82 } | |
83 | |
84 public NSGradient initWithColors_ (NSArray colorArray) | |
85 { | |
86 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithColors_1, colorArray !is null ? colorArray.id_ : null); | |
87 return result !is null ? this : null; | |
88 } | |
89 | |
90 public NSGradient initWithColors_atLocations_colorSpace_ (NSArray colorArray, /*const*/CGFloat* locations, NSColorSpace colorSpace) | |
91 { | |
92 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithColors_1atLocations_1colorSpace_1, colorArray !is null ? colorArray.id_ : null, | |
93 locations, colorSpace !is null ? colorSpace.id_ : null); | |
94 return result !is null ? this : null; | |
95 } | |
96 | |
97 public NSGradient initWithColorsAndLocations (NSColor initWithColorsAndLocations) | |
98 { | |
99 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithColorsAndLocations_1, | |
100 initWithColorsAndLocations !is null ? initWithColorsAndLocations.id_ : null); | |
101 return result !is null ? this : null; | |
102 } | |
103 | |
104 public NSGradient initWithStartingColor (NSColor startingColor, NSColor endingColor) | |
105 { | |
106 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithStartingColor_1endingColor_1, startingColor !is null ? startingColor.id_ : null, | |
107 endingColor !is null ? endingColor.id_ : null); | |
108 return result !is null ? this : null; | |
109 } | |
110 | |
111 public NSColor interpolatedColorAtLocation (CGFloat location) | |
112 { | |
113 objc.id result = OS.objc_msgSend(this.id_, OS.sel_interpolatedColorAtLocation_1, location); | |
114 return result !is null ? new NSColor(result) : null; | |
115 } | |
116 | |
117 public NSInteger numberOfColorStops () | |
118 { | |
119 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfColorStops); | |
120 } | |
121 | 59 |
122 } | 60 } |