Mercurial > projects > dwt-linux
comparison dwt/graphics/Font.d @ 238:380bad9f6852
reverted char[] to String
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:42:55 +0200 |
parents | 997624cece6a |
children | ce446666f5a2 |
comparison
equal
deleted
inserted
replaced
237:98b80b00af79 | 238:380bad9f6852 |
---|---|
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | 11 * Frank Benoit <benoit@tionex.de> |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 module dwt.graphics.Font; | 13 module dwt.graphics.Font; |
14 | |
15 import dwt.dwthelper.utils; | |
14 | 16 |
15 | 17 |
16 import dwt.DWT; | 18 import dwt.DWT; |
17 import dwt.graphics.Resource; | 19 import dwt.graphics.Resource; |
18 import dwt.graphics.FontData; | 20 import dwt.graphics.FontData; |
134 * </ul> | 136 * </ul> |
135 * @exception DWTError <ul> | 137 * @exception DWTError <ul> |
136 * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li> | 138 * <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li> |
137 * </ul> | 139 * </ul> |
138 */ | 140 */ |
139 public this(Device device, char[] name, int height, int style) { | 141 public this(Device device, String name, int height, int style) { |
140 if (device is null) device = Device.getDevice(); | 142 if (device is null) device = Device.getDevice(); |
141 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 143 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
142 init_(device, name, height, style, null); | 144 init_(device, name, height, style, null); |
143 if (device.tracking) device.new_Object(this); | 145 if (device.tracking) device.new_Object(this); |
144 } | 146 } |
145 | 147 |
146 /*public*/ this(Device device, char[] name, float height, int style) { | 148 /*public*/ this(Device device, String name, float height, int style) { |
147 if (device is null) device = Device.getDevice(); | 149 if (device is null) device = Device.getDevice(); |
148 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 150 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
149 init_(device, name, height, style, null); | 151 init_(device, name, height, style, null); |
150 if (device.tracking) device.new_Object(this); | 152 if (device.tracking) device.new_Object(this); |
151 } | 153 } |
197 */ | 199 */ |
198 public FontData[] getFontData() { | 200 public FontData[] getFontData() { |
199 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); | 201 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); |
200 | 202 |
201 auto family = OS.pango_font_description_get_family(handle); | 203 auto family = OS.pango_font_description_get_family(handle); |
202 char[] name = fromStringz( family ); | 204 String name = fromStringz( family ); |
203 float height = cast(float)OS.pango_font_description_get_size(handle) / OS.PANGO_SCALE; | 205 float height = cast(float)OS.pango_font_description_get_size(handle) / OS.PANGO_SCALE; |
204 int pangoStyle = OS.pango_font_description_get_style(handle); | 206 int pangoStyle = OS.pango_font_description_get_style(handle); |
205 int pangoWeight = OS.pango_font_description_get_weight(handle); | 207 int pangoWeight = OS.pango_font_description_get_weight(handle); |
206 int style = DWT.NORMAL; | 208 int style = DWT.NORMAL; |
207 if (pangoStyle is OS.PANGO_STYLE_ITALIC) style |= DWT.ITALIC; | 209 if (pangoStyle is OS.PANGO_STYLE_ITALIC) style |= DWT.ITALIC; |
250 */ | 252 */ |
251 public override hash_t toHash() { | 253 public override hash_t toHash() { |
252 return cast(hash_t)/*64*/handle; | 254 return cast(hash_t)/*64*/handle; |
253 } | 255 } |
254 | 256 |
255 void init_(Device device, char[] name, float height, int style, char[] fontString) { | 257 void init_(Device device, String name, float height, int style, String fontString) { |
256 if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 258 if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
257 if (height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | 259 if (height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
258 this.device = device; | 260 this.device = device; |
259 if (fontString !is null) { | 261 if (fontString !is null) { |
260 handle = OS.pango_font_description_from_string (toStringz(fontString)); | 262 handle = OS.pango_font_description_from_string (toStringz(fontString)); |
294 * Returns a string containing a concise, human-readable | 296 * Returns a string containing a concise, human-readable |
295 * description of the receiver. | 297 * description of the receiver. |
296 * | 298 * |
297 * @return a string representation of the receiver | 299 * @return a string representation of the receiver |
298 */ | 300 */ |
299 public char[] toString () { | 301 public String toString () { |
300 if (isDisposed()) return "Font {*DISPOSED*}"; | 302 if (isDisposed()) return "Font {*DISPOSED*}"; |
301 return Format( "Font {{{}}", handle ); | 303 return Format( "Font {{{}}", handle ); |
302 } | 304 } |
303 | 305 |
304 } | 306 } |