# HG changeset patch # User Jacob Carlborg # Date 1220041253 -7200 # Node ID b55912b6771e9c5c7523f9cbaf7dad08df042162 # Parent 5b53d338c709067ecb62644bead7a88d353fcb5f Ported dwt.widgets.Menu diff -r 5b53d338c709 -r b55912b6771e dwt/widgets/Menu.d --- 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 *******************************************************************************/ 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; }