changeset 28:71b49a659702

Ported dwt.graphics.Device
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Mon, 08 Sep 2008 22:42:00 +0200
parents dfcc6c4c4317
children d408fc12b991
files dwt/graphics/Device.d
diffstat 1 files changed, 24 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/graphics/Device.d	Mon Sep 08 18:15:39 2008 +0200
+++ b/dwt/graphics/Device.d	Mon Sep 08 22:42:00 2008 +0200
@@ -7,6 +7,9 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.graphics.Device;
 
@@ -29,6 +32,15 @@
 
 import dwt.graphics.Drawable;
 
+import dwt.graphics.Color;
+import dwt.graphics.DeviceData;
+import dwt.graphics.Font;
+import dwt.graphics.FontData;
+import dwt.graphics.GCData;
+import dwt.graphics.Rectangle;
+import dwt.internal.cocoa.NSInteger;
+
+
 /**
  * This class is the abstract superclass of all device objects,
  * such as the Display device and the Printer device. Devices
@@ -39,7 +51,7 @@
     
     /* Debugging */
     public static bool DEBUG;
-    bool debug = DEBUG;
+    bool debugg = DEBUG;
     bool tracking = DEBUG;
     Error [] errors;
     Object [] objects;
@@ -69,9 +81,9 @@
     */
     protected static Device CurrentDevice;
     protected static Runnable DeviceFinder;
-    static {
+    static this (){
         try {
-            Class.forName ("dwt.widgets.Display");
+            ClassInfo.find ("dwt.widgets.Display");
         } catch (Throwable e) {}
     }   
 
@@ -113,9 +125,9 @@
  * @see DeviceData
  */
 public this(DeviceData data) {
-    synchronized (Device.class) {
+    synchronized (Device.classinfo) {
         if (data !is null) {
-            debug = data.debug;
+            debugg = data.debugg;
             tracking = data.tracking;
         }
         if (tracking) {
@@ -180,7 +192,7 @@
  * @see #checkDevice
  */
 public void dispose () {
-    synchronized (Device.class) {
+    synchronized (Device.classinfo) {
         if (isDisposed()) return;
         checkDevice ();
         release ();
@@ -257,7 +269,7 @@
 public DeviceData getDeviceData () {
     checkDevice();
     DeviceData data = new DeviceData ();
-    data.debug = debug;
+    data.debugg = debugg;
     data.tracking = tracking;
     if (tracking) {
         synchronized (trackingLock) {
@@ -333,7 +345,7 @@
 public Point getDPI () {
     checkDevice ();
     NSDictionary dictionary = NSScreen.mainScreen().deviceDescription();
-    NSValue value = new NSValue(dictionary.objectForKey(new id(OS.NSDeviceResolution())).id);
+    NSValue value = new NSValue(dictionary.objectForKey(new id(OS.NSDeviceResolution())).id_);
     NSSize size = value.sizeValue();
     return new Point(cast(int)size.width, cast(int)size.height);
 }
@@ -357,11 +369,11 @@
     NSArray fonts = NSFontManager.sharedFontManager().availableFonts();
     int count = 0;
     FontData[] fds = new FontData[fonts.count()];
-    for (int i = 0; i < fds.length; i++) {
+    for (NSUInteger i = 0; i < fds.length; i++) {
         NSString str = new NSString(fonts.objectAtIndex(i));
         char[] buffer = new char[str.length()];
-        str.getCharacters_(buffer);
-        String nsName = new String(buffer);
+        str.getCharacters_(buffer.toString16().ptr);
+        String nsName = buffer.dup;
         String name = nsName;
         int index = nsName.indexOf('-');
         if (index !is -1) name = name.substring(0, index);
@@ -539,7 +551,7 @@
  * @return <code>true</code> when the device is disposed and <code>false</code> otherwise
  */
 public bool isDisposed () {
-    synchronized (Device.class) {
+    synchronized (Device.classinfo) {
         return disposed;
     }
 }