comparison dwt/graphics/Color.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 5123b17c98ef
children d8635bb48c7c
comparison
equal deleted inserted replaced
35:7d135fe0caf2 36:db5a898b2119
15 15
16 16
17 import dwt.DWT; 17 import dwt.DWT;
18 import dwt.DWTException; 18 import dwt.DWTException;
19 19
20 import tango.text.convert.Format;
21
20 import dwt.dwthelper.utils; 22 import dwt.dwthelper.utils;
21 import dwt.graphics.Device; 23 import dwt.graphics.Device;
22 import dwt.graphics.Resource; 24 import dwt.graphics.Resource;
23 import dwt.graphics.RGB; 25 import dwt.graphics.RGB;
24 import dwt.internal.cocoa.CGFloat; 26 import dwt.internal.cocoa.CGFloat;
36 * 38 *
37 * @see RGB 39 * @see RGB
38 * @see Device#getSystemColor 40 * @see Device#getSystemColor
39 */ 41 */
40 public final class Color : Resource { 42 public final class Color : Resource {
43
44 alias Resource.init_ init_;
45
41 /** 46 /**
42 * the handle to the OS color resource 47 * the handle to the OS color resource
43 * (Warning: This field is platform dependent) 48 * (Warning: This field is platform dependent)
44 * <p> 49 * <p>
45 * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT 50 * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
78 * 83 *
79 * @see #dispose 84 * @see #dispose
80 */ 85 */
81 public this(Device device, int red, int green, int blue) { 86 public this(Device device, int red, int green, int blue) {
82 super(device); 87 super(device);
83 init(red, green, blue); 88 init_(red, green, blue);
84 init(); 89 init_();
85 } 90 }
86 91
87 /** 92 /**
88 * Constructs a new instance of this class given a device and an 93 * Constructs a new instance of this class given a device and an
89 * <code>RGB</code> describing the desired red, green and blue values. 94 * <code>RGB</code> describing the desired red, green and blue values.
107 * @see #dispose 112 * @see #dispose
108 */ 113 */
109 public this(Device device, RGB rgb) { 114 public this(Device device, RGB rgb) {
110 super(device); 115 super(device);
111 if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 116 if (rgb is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
112 init(rgb.red, rgb.green, rgb.blue); 117 init_(rgb.red, rgb.green, rgb.blue);
113 init(); 118 init_();
114 } 119 }
115 120
116 void destroy() { 121 void destroy() {
117 handle = null; 122 handle = null;
118 } 123 }
233 Color color = new Color(device); 238 Color color = new Color(device);
234 color.handle = rgbColor; 239 color.handle = rgbColor;
235 return color; 240 return color;
236 } 241 }
237 242
238 void init(int red, int green, int blue) { 243 void init_(int red, int green, int blue) {
239 if ((red > 255) || (red < 0) || 244 if ((red > 255) || (red < 0) ||
240 (green > 255) || (green < 0) || 245 (green > 255) || (green < 0) ||
241 (blue > 255) || (blue < 0)) { 246 (blue > 255) || (blue < 0)) {
242 DWT.error(DWT.ERROR_INVALID_ARGUMENT); 247 DWT.error(DWT.ERROR_INVALID_ARGUMENT);
243 } 248 }
269 * 274 *
270 * @return a string representation of the receiver 275 * @return a string representation of the receiver
271 */ 276 */
272 public String toString () { 277 public String toString () {
273 if (isDisposed()) return "Color {*DISPOSED*}"; 278 if (isDisposed()) return "Color {*DISPOSED*}";
274 return "Color {" ~ getRed() ~ ", " ~ getGreen() ~ ", " ~ getBlue() + "}"; 279 return Format("Color {{}{}{}{}{}{}" , getRed() , ", " , getGreen() , ", " , getBlue() , "}");
275 } 280 }
276 281
277 } 282 }