comparison dwt/graphics/Font.d @ 334:c49e17d48b76

Fix problems at GC run at main()'s end.
author Frank Benoit <benoit@tionex.de>
date Wed, 18 Feb 2009 16:14:31 +0100
parents fd9c62a2998e
children
comparison
equal deleted inserted replaced
333:684eed7589a0 334:c49e17d48b76
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 14
16 import dwt.DWT; 15 import dwt.DWT;
17 import dwt.DWTError; 16 import dwt.DWTError;
18 import dwt.DWTException; 17 import dwt.DWTException;
19 import dwt.internal.win32.OS; 18 import dwt.internal.win32.OS;
193 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> 192 * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
194 * </ul> 193 * </ul>
195 */ 194 */
196 public FontData[] getFontData() { 195 public FontData[] getFontData() {
197 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); 196 if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
198 LOGFONT* logFont = new LOGFONT(); 197 LOGFONT logFont;
199 OS.GetObject(handle, LOGFONT.sizeof, logFont); 198 OS.GetObject(handle, LOGFONT.sizeof, &logFont);
200 return [ cast(FontData) FontData.win32_new(logFont, device.computePoints(logFont, handle))]; 199 return [ cast(FontData) FontData.win32_new(&logFont, device.computePoints(&logFont, handle))];
201 } 200 }
202 201
203 /** 202 /**
204 * Returns an integer hash code for the receiver. Any two 203 * Returns an integer hash code for the receiver. Any two
205 * objects that return <code>true</code> when passed to 204 * objects that return <code>true</code> when passed to
245 * @return a string representation of the receiver 244 * @return a string representation of the receiver
246 */ 245 */
247 override public String toString () { 246 override public String toString () {
248 if (isDisposed()) return "Font {*DISPOSED*}"; 247 if (isDisposed()) return "Font {*DISPOSED*}";
249 return Format( "Font {{{}}", handle ); 248 return Format( "Font {{{}}", handle );
249 //
250 // LOGFONT logFont;
251 // OS.GetObject(handle, LOGFONT.sizeof, &logFont);
252 // char[] name = .TCHARzToStr( logFont.lfFaceName.ptr, -1 );
253 //
254 // return Format( "Font {{{}, {}}", handle, name );
250 } 255 }
251 256
252 /** 257 /**
253 * Invokes platform specific functionality to allocate a new font. 258 * Invokes platform specific functionality to allocate a new font.
254 * <p> 259 * <p>
263 * @param handle the handle for the font 268 * @param handle the handle for the font
264 * @return a new font object containing the specified device and handle 269 * @return a new font object containing the specified device and handle
265 */ 270 */
266 public static Font win32_new(Device device, HFONT handle) { 271 public static Font win32_new(Device device, HFONT handle) {
267 Font font = new Font(device); 272 Font font = new Font(device);
273 font.disposeChecking = false;
268 font.handle = handle; 274 font.handle = handle;
269 return font; 275 return font;
270 } 276 }
271 277
272 } 278 }