diff dwt/widgets/MenuItem.d @ 35:7d135fe0caf2

Ported dwt.graphics.Cursor and dwt.widgets.MenuItem
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sun, 14 Sep 2008 23:32:29 +0200
parents e831403a80a9
children 642f460a0908
line wrap: on
line diff
--- a/dwt/widgets/MenuItem.d	Sun Sep 14 01:45:57 2008 +0200
+++ b/dwt/widgets/MenuItem.d	Sun Sep 14 23:32:29 2008 +0200
@@ -7,11 +7,12 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     
+ * Port to the D programming language:
+ *     Jacob Carlborg <jacob.carlborg@gmail.com>
  *******************************************************************************/
 module dwt.widgets.MenuItem;
 
-import dwt.dwthelper.utils;
-
 
 import dwt.DWT;
 import dwt.DWTException;
@@ -26,6 +27,15 @@
 import dwt.internal.cocoa.OS;
 import dwt.internal.cocoa.SWTMenu;
 
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.NSInteger;
+import dwt.widgets.Decorations;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+import dwt.widgets.Item;
+import dwt.widgets.Menu;
+import dwt.widgets.TypedListener;
+
 /**
  * Instances of this class represent a selectable user interface object
  * that issues notification when pressed and released. 
@@ -224,7 +234,7 @@
 
 NSMenu createEmptyMenu () {
     if ((parent.style & DWT.BAR) !is 0) {
-        return cast(NSMenu) new SWTMenu ().alloc ().init ();
+        return cast(NSMenu) (new SWTMenu ()).alloc ().init ();
     }
     return null;
 }
@@ -555,11 +565,11 @@
     this.accelerator = accelerator;
     int key = accelerator & DWT.KEY_MASK;
     int virtualKey = Display.untranslateKey (key);
-    NSString string =  null;
+    NSString str =  null;
     if (virtualKey !is 0) {
-        string = NSString.stringWith (cast(wchar)virtualKey + "");
+        str = NSString.stringWith (Integer.toString(virtualKey));
     } else {
-        string = NSString.stringWith (cast(wchar)key + "").lowercaseString();
+        str = NSString.stringWith (Integer.toString(key)).lowercaseString();
     }
     nsItem.setKeyEquivalent (string);
     int mask = 0;
@@ -568,7 +578,7 @@
 //  if ((accelerator & DWT.COMMAND) !is 0) mask &= ~OS.kMenuNoCommandModifier;
     if ((accelerator & DWT.COMMAND) !is 0) mask |= OS.NSCommandKeyMask;
     if ((accelerator & DWT.ALT) !is 0) mask |= OS.NSAlternateKeyMask;
-    nsItem.setKeyEquivalentModifierMask (mask);
+    nsItem.setKeyEquivalentModifierMask (cast(NSUInteger) mask);
     if ((this.accelerator is 0 && accelerator !is 0) || (this.accelerator !is 0 && accelerator is 0)) {
         updateText ();
     }
@@ -760,7 +770,7 @@
             j--;
         }
     }
-    String text = new String (buffer, 0, j);
+    String text = new_String (buffer, 0, j);
     NSMenu submenu = nsItem.submenu ();
     NSString label = NSString.stringWith (text);
     if(submenu !is null && (parent.getStyle () & DWT.BAR) !is 0) {