diff dwt/widgets/ToolItem.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/ToolItem.d	Wed Aug 27 14:10:03 2008 +0200
+++ b/dwt/widgets/ToolItem.d	Wed Aug 27 14:30:35 2008 +0200
@@ -204,10 +204,10 @@
             height = Math.max (height, control.getMininumHeight ());
         }
     } else {
-        ((NSButton)button).sizeToFit ();
+        (cast(NSButton)button).sizeToFit ();
         NSRect frame = button.frame();
-        width = (int)frame.width + INSET;
-        height = (int)frame.height;
+        width = cast(int)frame.width + INSET;
+        height = cast(int)frame.height;
         if (arrow !is null) {
             width += ARROW_INSET + ARROW_WIDTH;
         }
@@ -219,17 +219,17 @@
 void createWidget() {
     createJNIRef ();
     if ((style & DWT.SEPARATOR) !is 0) {
-        SWTBox widget = (SWTBox)new SWTBox().alloc();
+        SWTBox widget = cast(SWTBox)new SWTBox().alloc();
         widget.initWithFrame(new NSRect());
         widget.setBoxType(OS.NSBoxSeparator);
         widget.setTag(jniRef);
         view = widget;
     } else {
-        SWTView widget = (SWTView)new SWTView().alloc();
+        SWTView widget = cast(SWTView)new SWTView().alloc();
         widget.initWithFrame(new NSRect());
         widget.setTag(parent.jniRef);
         parent.contentView().addSubview_(widget);
-        button = (NSButton)new SWTButton().alloc();
+        button = cast(NSButton)new SWTButton().alloc();
         button.initWithFrame(new NSRect());
         button.setBordered(false);
         button.setAction(OS.sel_sendSelection);
@@ -240,7 +240,7 @@
         button.setEnabled(parent.getEnabled());
         widget.addSubview_(button);
         if ((style & DWT.DROP_DOWN) !is 0) {
-            arrow = (NSButton)new SWTButton().alloc();
+            arrow = cast(NSButton)new SWTButton().alloc();
             arrow.initWithFrame(new NSRect());
             arrow.setBordered(false);
             arrow.setAction(OS.sel_sendArrowSelection);
@@ -278,13 +278,13 @@
         NSGraphicsContext context = NSGraphicsContext.currentContext();
         context.saveGraphicsState();
         NSPoint p1 = new NSPoint();
-        p1.y = (float)Math.ceil(frame.height / 2 - frame.width / 2);
+        p1.y = cast(float)Math.ceil(frame.height / 2 - frame.width / 2);
         NSPoint p2 = new NSPoint();
         p2.x = frame.width;
         p2.y = p1.y;
         NSPoint p3 = new NSPoint();
         p3.x = frame.width / 2;
-        p3.y = (float)(p2.y + Math.sqrt(Math.pow(frame.width, 2) - Math.pow(frame.width / 2, 2)));
+        p3.y = cast(float)(p2.y + Math.sqrt(Math.pow(frame.width, 2) - Math.pow(frame.width / 2, 2)));
         NSBezierPath path = NSBezierPath.bezierPath();
         path.moveToPoint(p1);
         path.lineToPoint(p2);
@@ -299,9 +299,9 @@
 
 void enableWidget(bool enabled) {
     if ((style & DWT.SEPARATOR) is 0) {
-        ((NSButton)button).setEnabled(enabled);
+        (cast(NSButton)button).setEnabled(enabled);
         if (arrow !is null) {
-            ((NSButton)arrow).setEnabled(enabled);
+            (cast(NSButton)arrow).setEnabled(enabled);
         }
     }
 }
@@ -320,7 +320,7 @@
 public Rectangle getBounds () {
     checkWidget();
     NSRect rect = view.frame();
-    return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
+    return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height);
 }
 
 /**
@@ -555,8 +555,8 @@
     NSRect frame = view.frame();
     Event event = new Event ();
     event.detail = DWT.ARROW;
-    event.x = (int)frame.x;
-    event.y = (int)(frame.y + arrow.frame().height);
+    event.x = cast(int)frame.x;
+    event.y = cast(int)(frame.y + arrow.frame().height);
     postEvent (DWT.Selection, event);
 }
 
@@ -765,16 +765,16 @@
     if ((style & DWT.SEPARATOR) !is 0) return;
     super.setText (string);
     NSString str = NSString.stringWith(string);
-    ((NSButton)button).setTitle(str);
+    (cast(NSButton)button).setTitle(str);
     parent.relayout ();
     if (text.length() !is 0 && image !is null) {
         if ((parent.style & DWT.RIGHT) !is 0) {
-            ((NSButton)button).setImagePosition(OS.NSImageLeft);
+            (cast(NSButton)button).setImagePosition(OS.NSImageLeft);
         } else {
-            ((NSButton)button).setImagePosition(OS.NSImageAbove);       
+            (cast(NSButton)button).setImagePosition(OS.NSImageAbove);       
         }
     } else {
-        ((NSButton)button).setImagePosition(OS.NSImageOverlaps);            
+        (cast(NSButton)button).setImagePosition(OS.NSImageOverlaps);            
     }
 }
 
@@ -836,15 +836,15 @@
             image = disabledImage;
         }
     }
-    ((NSButton)button).setImage(image !is null ? image.handle : null);
+    (cast(NSButton)button).setImage(image !is null ? image.handle : null);
     if (text.length() !is 0 && image !is null) {
         if ((parent.style & DWT.RIGHT) !is 0) {
-            ((NSButton)button).setImagePosition(OS.NSImageLeft);
+            (cast(NSButton)button).setImagePosition(OS.NSImageLeft);
         } else {
-            ((NSButton)button).setImagePosition(OS.NSImageAbove);       
+            (cast(NSButton)button).setImagePosition(OS.NSImageAbove);       
         }
     } else {
-        ((NSButton)button).setImagePosition(OS.NSImageOverlaps);            
+        (cast(NSButton)button).setImagePosition(OS.NSImageOverlaps);            
     }
     parent.relayout();
 }