comparison dwt/graphics/Device.d @ 46:cfa563df4fdd

Updated Widget and Display to 3.514
author Jacob Carlborg <doob@me.com>
date Fri, 05 Dec 2008 16:00:41 +0100
parents d8635bb48c7c
children 62202ce0039f
comparison
equal deleted inserted replaced
45:d8635bb48c7c 46:cfa563df4fdd
28 import dwt.internal.cocoa.NSSize; 28 import dwt.internal.cocoa.NSSize;
29 import dwt.internal.cocoa.NSString; 29 import dwt.internal.cocoa.NSString;
30 import dwt.internal.cocoa.NSThread; 30 import dwt.internal.cocoa.NSThread;
31 import dwt.internal.cocoa.NSValue; 31 import dwt.internal.cocoa.NSValue;
32 import dwt.internal.cocoa.OS; 32 import dwt.internal.cocoa.OS;
33 import dwt.internal.cocoa.id; 33 import cocoa = dwt.internal.cocoa.id;
34 34
35 import dwt.dwthelper.Runnable; 35 import dwt.dwthelper.Runnable;
36 import dwt.dwthelper.System;
36 import dwt.dwthelper.utils; 37 import dwt.dwthelper.utils;
37 import dwt.graphics.Drawable; 38 import dwt.graphics.Drawable;
38 import dwt.graphics.Color; 39 import dwt.graphics.Color;
39 import dwt.graphics.DeviceData; 40 import dwt.graphics.DeviceData;
40 import dwt.graphics.Font; 41 import dwt.graphics.Font;
41 import dwt.graphics.FontData; 42 import dwt.graphics.FontData;
42 import dwt.graphics.GCData; 43 import dwt.graphics.GCData;
43 import dwt.graphics.Point; 44 import dwt.graphics.Point;
44 import dwt.graphics.Rectangle; 45 import dwt.graphics.Rectangle;
45 import dwt.internal.cocoa.NSInteger; 46 import dwt.internal.objc.cocoa.Cocoa;
46 import objc = dwt.internal.objc.runtime; 47 import objc = dwt.internal.objc.runtime;
47 48
48 49
49 /** 50 /**
50 * This class is the abstract superclass of all device objects, 51 * This class is the abstract superclass of all device objects,
143 if (tracking) { 144 if (tracking) {
144 errors = new Error [128]; 145 errors = new Error [128];
145 objects = new Object [128]; 146 objects = new Object [128];
146 trackingLock = new Object (); 147 trackingLock = new Object ();
147 } 148 }
148 NSAutoreleasePool pool = (NSAutoreleasePool) new NSAutoreleasePool().alloc().init(); 149 NSAutoreleasePool pool = cast(NSAutoreleasePool) (new NSAutoreleasePool()).alloc().init();
149 NSThread nsthread = NSThread.currentThread(); 150 NSThread nsthread = NSThread.currentThread();
150 NSMutableDictionary dictionary = nsthread.threadDictionary(); 151 NSMutableDictionary dictionary = nsthread.threadDictionary();
151 NSString key = NSString.stringWith("DWT_NSAutoreleasePool"); 152 NSString key = NSString.stringWith("DWT_NSAutoreleasePool");
152 id obj = dictionary.objectForKey(key); 153 cocoa.id obj = dictionary.objectForKey(key);
153 if (obj is null) { 154 if (obj is null) {
154 NSNumber nsnumber = NSNumber.numberWithInteger(pool.id); 155 NSNumber nsnumber = NSNumber.numberWithInteger(cast(NSInteger) pool.id);
155 dictionary.setObject(nsnumber, key); 156 dictionary.setObject(nsnumber, key);
156 } else { 157 } else {
157 pool.release(); 158 pool.release();
158 } 159 }
159 //check and create pool 160 //check and create pool
345 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> 346 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
346 * </ul> 347 * </ul>
347 */ 348 */
348 public int getDepth () { 349 public int getDepth () {
349 checkDevice (); 350 checkDevice ();
350 return (int)/*64*/OS.NSBitsPerPixelFromDepth(getPrimaryScreen().depth()); 351 return cast(int)/*64*/OS.NSBitsPerPixelFromDepth(getPrimaryScreen().depth());
351 } 352 }
352 353
353 /** 354 /**
354 * Returns a point whose x coordinate is the horizontal 355 * Returns a point whose x coordinate is the horizontal
355 * dots per inch of the display, and whose y coordinate 356 * dots per inch of the display, and whose y coordinate
424 return result; 425 return result;
425 } 426 }
426 427
427 Point getScreenDPI () { 428 Point getScreenDPI () {
428 NSDictionary dictionary = getPrimaryScreen().deviceDescription(); 429 NSDictionary dictionary = getPrimaryScreen().deviceDescription();
429 NSValue value = new NSValue(dictionary.objectForKey(new id(OS.NSDeviceResolution())).id); 430 NSValue value = new NSValue(dictionary.objectForKey(new cocoa.id(OS.NSDeviceResolution)).id);
430 NSSize size = value.sizeValue(); 431 NSSize size = value.sizeValue();
431 return new Point((int)size.width, (int)size.height); 432 return new Point(cast(int)size.width, cast(int)size.height);
432 } 433 }
433 434
434 /** 435 /**
435 * Returns the matching standard color for the given 436 * Returns the matching standard color for the given
436 * constant, which should be one of the color constants 437 * constant, which should be one of the color constants