changeset 18:b55912b6771e

Ported dwt.widgets.Menu
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 29 Aug 2008 22:20:53 +0200
parents 5b53d338c709
children fba856099f87
files dwt/widgets/Menu.d
diffstat 1 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/widgets/Menu.d	Fri Aug 29 22:04:22 2008 +0200
+++ b/dwt/widgets/Menu.d	Fri Aug 29 22:20:53 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.widgets.Menu;
 
@@ -29,6 +32,18 @@
 import dwt.internal.cocoa.SWTMenu;
 import dwt.internal.cocoa.SWTMenuItem;
 
+import dwt.dwthelper.System;
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSInteger;
+import dwt.widgets.ImageList;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Event;
+import dwt.widgets.MenuItem;
+import dwt.widgets.Widget;
+import dwt.widgets.Control;
+import dwt.widgets.Decorations;
+import dwt.widgets.Shell;
+
 /**
  * Instances of this class are user interface objects that contain
  * menu items.
@@ -198,11 +213,11 @@
     if (visible) {
         Shell shell = getShell ();
         NSWindow window = shell.window;
-        NSPoint location = null;
+        NSPoint location;
         if (hasLocation) {
             NSView topView = window.contentView();
             Point shellCoord = display.map(null, shell, new Point(x,y));
-            location = new NSPoint ();
+            location = NSPoint ();
             location.x = shellCoord.x;
             location.y = topView.frame().height - shellCoord.y;
         } else {
@@ -270,7 +285,7 @@
 
 void createHandle () {
 //  display.addMenu (this);
-    SWTMenu widget = cast(SWTMenu)new SWTMenu().alloc();
+    SWTMenu widget = cast(SWTMenu)(new SWTMenu()).alloc();
     widget.initWithTitle(NSString.stringWith(""));
     widget.setAutoenablesItems(false);
     widget.setTag(jniRef);
@@ -286,11 +301,11 @@
         nsItem = NSMenuItem.separatorItem();
         nsItem.retain();
     } else {
-        nsItem = cast(NSMenuItem)new SWTMenuItem().alloc();
-        nsItem.initWithTitle(NSString.stringWith(""), 0, NSString.stringWith(""));
+        nsItem = cast(NSMenuItem)(new SWTMenuItem()).alloc();
+        nsItem.initWithTitle(NSString.stringWith(""), null, NSString.stringWith(""));
         nsItem.setTarget(nsItem);
         nsItem.setAction(OS.sel_sendSelection);
-        item.createJNIRef();
+        //item.createJNIRef();
         nsItem.setTag(item.jniRef);
     }
     item.nsItem = nsItem;
@@ -637,7 +652,7 @@
 }
 
 void menu_willHighlightItem(int menu, int itemID) {
-    int jniRef = OS.objc_msgSend(itemID, OS.sel_tag);
+    NSInteger jniRef = cast(NSInteger) OS.objc_msgSend(itemID, OS.sel_tag);
     if (jniRef !is -1 && jniRef !is 0) {
         Object object = OS.JNIGetObject(jniRef);
         if ( null !is cast(MenuItem)object ) {
@@ -679,7 +694,7 @@
 }
 
 int numberOfItemsInMenu(int menu) {
-    System.out.println("numver");
+    System.Out.println("numver");
     return 4;
 }