diff dwt/widgets/Display.d @ 38:198549365851

Fixed all the runtime errors, hello world app "works"
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sun, 12 Oct 2008 15:26:21 +0200
parents 642f460a0908
children d8635bb48c7c
line wrap: on
line diff
--- a/dwt/widgets/Display.d	Fri Oct 10 12:29:48 2008 +0200
+++ b/dwt/widgets/Display.d	Sun Oct 12 15:26:21 2008 +0200
@@ -82,7 +82,7 @@
 import dwt.widgets.Tray;
 import dwt.widgets.Widget;
 
-import mambo.io;
+//import mambo.io;
 
 /**
  * Instances of this class are responsible for managing the
@@ -1668,9 +1668,9 @@
     objc.Class cls = OS.objc_allocateClassPair(cast(objc.Class) OS.class_NSObject, className, 0);
     
     static if ((void*).sizeof > int.sizeof) // 64bit target
-        OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "q");
+        OS.class_addIvar(cls, "dObject", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "q");
     else
-        OS.class_addIvar(cls, "tag", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
+        OS.class_addIvar(cls, "dObject", OS.PTR_SIZEOF, cast(byte)(Math.log(OS.PTR_SIZEOF) / Math.log(2)), "i");
     
     OS.class_addMethod(cls, OS.sel_windowDidResize_1, proc3, "@:@");
     OS.class_addMethod(cls, OS.sel_windowShouldClose_1, proc3, "@:@");
@@ -3154,17 +3154,17 @@
     return null;
 }
 	
-objc.id windowDelegateProc2(objc.id delegate_, objc.SEL selector) {
+objc.id windowDelegateProc2(objc.id delegate_, objc.SEL selector) { 
     String sel = fromStringz(selector);
     
-    if (sel == OS.sel_tag) {
+    /*if (sel == OS.sel_tag) {
         NSInteger* tag;
         OS.object_getInstanceVariable(delegate_, "tag", cast(void**) &tag);    
         return cast(objc.id) tag[0];
     }
-    NSInteger jniRef = *cast(NSInteger*) OS.objc_msgSend(delegate_, OS.sel_tag);
-    if (jniRef is 0 || jniRef is -1) return null;
-    Widget widget = cast(Widget)OS.JNIGetObject(jniRef);
+    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(delegate_, OS.sel_tag);
+    if (jniRef is 0 || jniRef is -1) return null;*/
+    Widget widget = getWidget(delegate_);//cast(Widget)OS.JNIGetObject(jniRef);
     if (widget is null) return null;
     if (sel == OS.sel_isFlipped) {
         return widget.isFlipped() ? cast(objc.id) 1 : null;
@@ -3345,4 +3345,12 @@
     }
     return null;
 }
+    
+Widget getWidget (objc.id ID)
+{
+    NSInteger* dObject;
+    OS.object_getInstanceVariable(ID, "dObject", cast(void**)dObject);
+    if (dObject is null) return null;
+    return cast(Widget)(*dObject);
 }
+}