Changeset 213:36f5cb12e1a2 for dwt/graphics/Font.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/graphics/Font.d (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/graphics/Font.d
r212 r213 43 43 public final class Font : Resource { 44 44 45 alias Resource.init_ init_; 45 46 /** 46 47 * the handle to the OS font resource … … 58 59 * Prevents uninitialized instances from being created outside the package. 59 60 */ 60 this() { 61 this(Device device) { 62 super(device); 61 63 } 62 64 … … 80 82 */ 81 83 public this(Device device, FontData fd) { 82 if (device is null) device = Device.getDevice(); 83 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 84 init_(device, fd); 85 if (device.tracking) device.new_Object(this); 84 super(device); 85 init_(fd); 86 init_(); 86 87 } 87 88 … … 110 111 */ 111 112 public this(Device device, FontData[] fds) { 112 if (device is null) device = Device.getDevice(); 113 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 113 super(device); 114 114 if (fds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 115 115 if (fds.length is 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT); … … 117 117 if (fds[i] is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 118 118 } 119 init_( device,fds[0]);120 i f (device.tracking) device.new_Object(this);119 init_(fds[0]); 120 init_(); 121 121 } 122 122 … … 144 144 */ 145 145 public this(Device device, String name, int height, int style) { 146 if (device is null) device = Device.getDevice(); 147 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 146 super(device); 148 147 if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 149 init_( device,new FontData (name, height, style));150 i f (device.tracking) device.new_Object(this);148 init_(new FontData (name, height, style)); 149 init_(); 151 150 } 152 151 153 152 /*public*/ this(Device device, String name, float height, int style) { 154 if (device is null) device = Device.getDevice(); 155 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 153 super(device); 156 154 if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 157 init_(device, new FontData (name, height, style)); 158 if (device.tracking) device.new_Object(this); 159 } 160 161 /** 162 * Disposes of the operating system resources associated with 163 * the font. Applications must dispose of all fonts which 164 * they allocate. 165 */ 166 override public void dispose() { 167 if (handle is null) return; 168 if (device.isDisposed()) return; 155 init_(new FontData (name, height, style)); 156 init_(); 157 } 158 void destroy() { 169 159 OS.DeleteObject(handle); 170 160 handle = null; 171 if (device.tracking) device.dispose_Object(this);172 device = null;173 161 } 174 162 … … 224 212 } 225 213 226 void init_ ( Device device,FontData fd) {214 void init_ (FontData fd) { 227 215 if (fd is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 228 this.device = device;229 216 LOGFONT* logFont = &fd.data; 230 217 int lfHeight = logFont.lfHeight; … … 275 262 */ 276 263 public static Font win32_new(Device device, HFONT handle) { 277 if (device is null) device = Device.getDevice(); 278 Font font = new Font(); 264 Font font = new Font(device); 279 265 font.handle = handle; 280 font.device = device;281 266 return font; 282 267 }
