diff dwt/widgets/Combo.d @ 7:e831403a80a9

Add 'cast' to casts
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 14:30:35 +0200
parents 1a8b3cb347e0
children d8635bb48c7c
line wrap: on
line diff
--- a/dwt/widgets/Combo.d	Wed Aug 27 14:10:03 2008 +0200
+++ b/dwt/widgets/Combo.d	Wed Aug 27 14:30:35 2008 +0200
@@ -143,13 +143,13 @@
     if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     NSString str = NSString.stringWith(string);
     if ((style & DWT.READ_ONLY) !is 0) {
-        NSMenu nsMenu = ((NSPopUpButton)view).menu();
-        NSMenuItem nsItem = (NSMenuItem)new NSMenuItem().alloc();
+        NSMenu nsMenu = (cast(NSPopUpButton)view).menu();
+        NSMenuItem nsItem = cast(NSMenuItem)new NSMenuItem().alloc();
         nsItem.initWithTitle(str, 0, NSString.stringWith(""));
         nsMenu.addItem(nsItem);
         nsItem.release();
     } else {
-        ((NSComboBox)view).addItemWithObjectValue(str);
+        (cast(NSComboBox)view).addItemWithObjectValue(str);
     }
 }
 
@@ -183,13 +183,13 @@
     if (0 > index || index > count) error (DWT.ERROR_INVALID_RANGE);
     NSString str = NSString.stringWith(string);
     if ((style & DWT.READ_ONLY) !is 0) {
-        NSMenu nsMenu = ((NSPopUpButton)view).menu();
-        NSMenuItem nsItem = (NSMenuItem)new NSMenuItem().alloc();
+        NSMenu nsMenu = (cast(NSPopUpButton)view).menu();
+        NSMenuItem nsItem = cast(NSMenuItem)new NSMenuItem().alloc();
         nsItem.initWithTitle(str, 0, NSString.stringWith(""));
         nsMenu.insertItem(nsItem, index);
         nsItem.release();
     } else {
-        ((NSComboBox)view).insertItemWithObjectValue(str, index);
+        (cast(NSComboBox)view).insertItemWithObjectValue(str, index);
     }
 }
 
@@ -344,13 +344,13 @@
 public Point computeSize (int wHint, int hHint, bool changed) {
     checkWidget ();
     int width = 0, height = 0;
-    NSControl widget = (NSControl)view;
+    NSControl widget = cast(NSControl)view;
     NSRect oldRect = widget.frame();
     widget.sizeToFit();
     NSRect newRect = widget.frame();
     widget.setFrame (oldRect);
-    width = (int)newRect.width;
-    height = (int)newRect.height;
+    width = cast(int)newRect.width;
+    height = cast(int)newRect.height;
     if (wHint !is DWT.DEFAULT) width = wHint;
     if (hHint !is DWT.DEFAULT) height = hHint;
     return new Point (width, height);
@@ -378,7 +378,7 @@
 
 void createHandle () {
     if ((style & DWT.READ_ONLY) !is 0) {
-        NSPopUpButton widget = (NSPopUpButton)new SWTPopUpButton().alloc();
+        NSPopUpButton widget = cast(NSPopUpButton)new SWTPopUpButton().alloc();
         widget.initWithFrame(new NSRect(), false);
         widget.menu().setAutoenablesItems(false);
         widget.setTarget(widget);
@@ -387,7 +387,7 @@
         view = widget;
         parent.view.addSubview_(widget);
     } else {
-        NSComboBox widget = (NSComboBox)new SWTComboBox().alloc();
+        NSComboBox widget = cast(NSComboBox)new SWTComboBox().alloc();
         widget.initWithFrame(new NSRect());
         widget.setTag(jniRef);
         widget.setDelegate(widget);
@@ -459,10 +459,10 @@
     if (index is -1) return;
     if (index is getSelectionIndex ()) {
         if ((style & DWT.READ_ONLY) !is 0) {
-            ((NSPopUpButton)view).selectItem(null);
+            (cast(NSPopUpButton)view).selectItem(null);
             sendEvent (DWT.Modify);
         } else {
-            ((NSComboBox)view).deselectItemAtIndex(index);
+            (cast(NSComboBox)view).deselectItemAtIndex(index);
         }
     }
 }
@@ -484,7 +484,7 @@
 public void deselectAll () {
     checkWidget ();
     if ((style & DWT.READ_ONLY) !is 0) {
-        ((NSPopUpButton)view).selectItem(null);
+        (cast(NSPopUpButton)view).selectItem(null);
         sendEvent (DWT.Modify);
     } else {
         setText ("");
@@ -494,9 +494,9 @@
 int getCharCount() {
     NSString str;
     if ((style & DWT.READ_ONLY) !is 0) {
-        str = ((NSPopUpButton)view).titleOfSelectedItem();
+        str = (cast(NSPopUpButton)view).titleOfSelectedItem();
     } else {
-        str = new NSCell(((NSComboBox)view).cell()).title();
+        str = new NSCell((cast(NSComboBox)view).cell()).title();
     }
     return str.length();
 }
@@ -523,9 +523,9 @@
     if (0 > index || index >= count) error (DWT.ERROR_INVALID_RANGE);
     NSString str;
     if ((style & DWT.READ_ONLY) !is 0) {
-        str = ((NSPopUpButton)view).itemTitleAtIndex(index);
+        str = (cast(NSPopUpButton)view).itemTitleAtIndex(index);
     } else {
-        str = new NSString(((NSComboBox)view).itemObjectValueAtIndex(index));
+        str = new NSString((cast(NSComboBox)view).itemObjectValueAtIndex(index));
     }
     if (str is null) error(DWT.ERROR_CANNOT_GET_ITEM);
     char[] buffer = new char[str.length()];
@@ -546,9 +546,9 @@
 public int getItemCount () {
     checkWidget ();
     if ((style & DWT.READ_ONLY) !is 0) {
-        return ((NSPopUpButton)view).numberOfItems();
+        return (cast(NSPopUpButton)view).numberOfItems();
     } else {
-        return ((NSComboBox)view).numberOfItems();
+        return (cast(NSComboBox)view).numberOfItems();
     }
 }
 
@@ -643,7 +643,7 @@
 //          selection = this.selection;
 //      } else {
 //          selection = new ControlEditTextSelectionRec ();
-//          OS.GetControlData (handle, (short) OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, selection, null);
+//          OS.GetControlData (handle, cast(short) OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, selection, null);
 //      }
 //      return new Point (selection.selStart, selection.selEnd);
         return null;
@@ -664,9 +664,9 @@
 public int getSelectionIndex () {
     checkWidget ();
     if ((style & DWT.READ_ONLY) !is 0) {
-        return ((NSPopUpButton)view).indexOfSelectedItem();
+        return (cast(NSPopUpButton)view).indexOfSelectedItem();
     } else {
-        return ((NSComboBox)view).indexOfSelectedItem();
+        return (cast(NSComboBox)view).indexOfSelectedItem();
     }
 }
 
@@ -690,9 +690,9 @@
 String getText (int start, int end) {
     NSString str;
     if ((style & DWT.READ_ONLY) !is 0) {
-        str = ((NSPopUpButton)view).titleOfSelectedItem();
+        str = (cast(NSPopUpButton)view).titleOfSelectedItem();
     } else {
-        str = new NSCell(((NSComboBox)view).cell()).title();
+        str = new NSCell((cast(NSComboBox)view).cell()).title();
     }
     if (str is null) return "";
     int length = str.length();
@@ -763,7 +763,7 @@
     if ((style & DWT.READ_ONLY) !is 0) {
         return getItemCount ();
     } else {
-        return ((NSComboBox)view).numberOfVisibleItems();
+        return (cast(NSComboBox)view).numberOfVisibleItems();
     }
 }
     
@@ -879,9 +879,9 @@
     int count = getItemCount ();
     if (0 > index || index >= count) error (DWT.ERROR_INVALID_RANGE);
     if ((style & DWT.READ_ONLY) !is 0) {
-        ((NSPopUpButton)view).removeItemAtIndex(index);
+        (cast(NSPopUpButton)view).removeItemAtIndex(index);
     } else {
-        ((NSComboBox)view).removeItemAtIndex(index);
+        (cast(NSComboBox)view).removeItemAtIndex(index);
     }
 }
 
@@ -950,10 +950,10 @@
 public void removeAll () {
     checkWidget ();
     if ((style & DWT.READ_ONLY) !is 0) {
-        ((NSPopUpButton)view).removeAllItems();
+        (cast(NSPopUpButton)view).removeAllItems();
     } else {
         setText ("", true);
-        ((NSComboBox)view).removeAllItems();
+        (cast(NSComboBox)view).removeAllItems();
     }
 }
 
@@ -1049,10 +1049,10 @@
     int count = getItemCount ();
     if (0 <= index && index < count) {
         if ((style & DWT.READ_ONLY) !is 0) {
-            ((NSPopUpButton)view).selectItemAtIndex(index);
+            (cast(NSPopUpButton)view).selectItemAtIndex(index);
             sendEvent (DWT.Modify);
         } else {
-            ((NSComboBox)view).selectItemAtIndex(index);
+            (cast(NSComboBox)view).selectItemAtIndex(index);
         }
     }   
 }
@@ -1124,7 +1124,7 @@
     } else {
         nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
     }
-    ((NSTextField)view).setBackgroundColor(nsColor);
+    (cast(NSTextField)view).setBackgroundColor(nsColor);
 }
 
 void setForeground (float [] color) {
@@ -1134,7 +1134,7 @@
     } else {
         nsColor = NSColor.colorWithDeviceRed(color[0], color[1], color[2], 1);
     }
-    ((NSTextField)view).setTextColor(nsColor);
+    (cast(NSTextField)view).setTextColor(nsColor);
 }
 
 /**
@@ -1160,10 +1160,10 @@
     if (0 > index || index >= count) error (DWT.ERROR_INVALID_RANGE);
     NSString str = NSString.stringWith(string);
     if ((style & DWT.READ_ONLY) !is 0) {
-        NSMenuItem nsItem = ((NSPopUpButton)view).itemAtIndex(index);
+        NSMenuItem nsItem = (cast(NSPopUpButton)view).itemAtIndex(index);
         nsItem.setTitle(str);
     } else {
-        NSComboBox widget = (NSComboBox)view;
+        NSComboBox widget = cast(NSComboBox)view;
         widget.insertItemWithObjectValue(str, index);
         widget.removeItemAtIndex(index + 1);
     }
@@ -1194,13 +1194,13 @@
     for (int i= 0; i < items.length; i++) {
         NSString str = NSString.stringWith(items[i]);
         if ((style & DWT.READ_ONLY) !is 0) {
-            NSMenu nsMenu = ((NSPopUpButton)view).menu();
-            NSMenuItem nsItem = (NSMenuItem)new NSMenuItem().alloc();
+            NSMenu nsMenu = (cast(NSPopUpButton)view).menu();
+            NSMenuItem nsItem = cast(NSMenuItem)new NSMenuItem().alloc();
             nsItem.initWithTitle(str, 0, NSString.stringWith(""));
             nsMenu.addItem(nsItem);
             nsItem.release();
         } else {
-            ((NSComboBox)view).addItemWithObjectValue(str);
+            (cast(NSComboBox)view).addItemWithObjectValue(str);
         }
     }
 }
@@ -1208,7 +1208,7 @@
 /*public*/ void setListVisible (bool visible) {
     checkWidget ();
     if ((style & DWT.READ_ONLY) !is 0) {
-        ((NSPopUpButton)view).setPullsDown(visible);
+        (cast(NSPopUpButton)view).setPullsDown(visible);
     } else {
     }
 }
@@ -1254,8 +1254,8 @@
 //      int length = getCharCount ();
 //      int start = selection.x, end = selection.y;
 //      ControlEditTextSelectionRec sel = new ControlEditTextSelectionRec ();
-//      sel.selStart = (short) Math.min (Math.max (Math.min (start, end), 0), length);
-//      sel.selEnd = (short) Math.min (Math.max (Math.max (start, end), 0), length);
+//      sel.selStart = cast(short) Math.min (Math.max (Math.min (start, end), 0), length);
+//      sel.selEnd = cast(short) Math.min (Math.max (Math.max (start, end), 0), length);
 //      if (hasFocus ()) {
 //          OS.SetControlData (handle, OS.kHIComboBoxEditTextPart, OS.kControlEditTextSelectionTag, 4, sel);
 //      } else {
@@ -1305,7 +1305,7 @@
             if (notify) sendEvent (DWT.Modify);
         }
     } else {
-        new NSCell(((NSComboBox)view).cell()).setTitle(NSString.stringWith(string));
+        new NSCell((cast(NSComboBox)view).cell()).setTitle(NSString.stringWith(string));
         if (notify) sendEvent (DWT.Modify);
     }
 }
@@ -1359,7 +1359,7 @@
     if ((style & DWT.READ_ONLY) !is 0) {
         //TODO 
     } else {
-        ((NSComboBox)view).setNumberOfVisibleItems(count);
+        (cast(NSComboBox)view).setNumberOfVisibleItems(count);
     }
 }