diff dwt/widgets/Control.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 a9ab4c738ed8
line wrap: on
line diff
--- a/dwt/widgets/Control.d	Wed Aug 27 14:10:03 2008 +0200
+++ b/dwt/widgets/Control.d	Wed Aug 27 14:30:35 2008 +0200
@@ -602,10 +602,10 @@
 //  return new Point (width, height);
     if (topView() instanceof NSControl) {
         NSRect oldRect = topView().frame();
-        ((NSControl)topView()).sizeToFit();
+        (cast(NSControl)topView()).sizeToFit();
         NSRect newRect = topView().frame();
         topView().setFrame (oldRect);
-        return new Point ((int)newRect.width, (int)newRect.height);
+        return new Point (cast(int)newRect.width, cast(int)newRect.height);
     }
     return new Point (width, height);
 }
@@ -656,7 +656,7 @@
 Font defaultFont () {
     //TODO - Controls only, does this leak?
     if (view instanceof NSControl) {
-        NSFont nsFont = ((NSControl)view).font ();
+        NSFont nsFont = (cast(NSControl)view).font ();
         if (nsFont !is null) {
             return Font.cocoa_new (display, nsFont);
         }
@@ -769,14 +769,14 @@
 //  int window = OS.GetControlOwner (handle);
 //  CGPoint pt = new CGPoint ();
 //  OS.HIViewConvertPoint (pt, handle, 0);
-//  x += (int) pt.x;
-//  y += (int) pt.y;
-//  OS.GetWindowBounds (window, (short) OS.kWindowStructureRgn, rect);
+//  x += cast(int) pt.x;
+//  y += cast(int) pt.y;
+//  OS.GetWindowBounds (window, cast(short) OS.kWindowStructureRgn, rect);
 //  x += rect.left;
 //  y += rect.top;
 //  dwt.internal.carbon.Point pt1 = new dwt.internal.carbon.Point ();
-//  pt1.h = (short) x;
-//  pt1.v = (short) y;
+//  pt1.h = cast(short) x;
+//  pt1.v = cast(short) y;
 //  return OS.WaitMouseMoved (pt1);
     return false;
 }
@@ -795,10 +795,10 @@
     GC gc = GC.cocoa_new (this, data);
     Event event = new Event ();
     event.gc = gc;
-    event.x = (int)rect.x;
-    event.y = (int)rect.y;
-    event.width = (int)rect.width;
-    event.height = (int)rect.height;
+    event.x = cast(int)rect.x;
+    event.y = cast(int)rect.y;
+    event.width = cast(int)rect.width;
+    event.height = cast(int)rect.height;
     sendEvent (DWT.Paint, event);
     event.gc = null;
     gc.dispose ();
@@ -807,7 +807,7 @@
 void enableWidget (bool enabled) {
     //TODO - other views
     if (view instanceof NSControl) {
-        ((NSControl)view).setEnabled(enabled);
+        (cast(NSControl)view).setEnabled(enabled);
     }
 }
 
@@ -965,7 +965,7 @@
 public Rectangle getBounds () {
     checkWidget();
     NSRect rect = topView().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);
 }
 
 /**
@@ -1090,7 +1090,7 @@
 public Point getLocation () {
     checkWidget();
     NSRect rect = topView().frame();
-    return new Point((int)rect.x, (int)rect.y);
+    return new Point(cast(int)rect.x, cast(int)rect.y);
 }
 
 /**
@@ -1231,7 +1231,7 @@
 public Point getSize () {
     checkWidget();
     NSRect rect = topView().frame();
-    return new Point((int)rect.width, (int)rect.height);
+    return new Point(cast(int)rect.width, cast(int)rect.height);
 }
 
 /**
@@ -1464,9 +1464,9 @@
 int menuForEvent (int nsEvent) {
     NSPoint pt = NSEvent.mouseLocation();   
     NSWindow window = view.window();
-    pt.y = (int) (window.screen().frame().height - pt.y);
-    int x = (int) pt.x;
-    int y = (int) pt.y;
+    pt.y = cast(int) (window.screen().frame().height - pt.y);
+    int x = cast(int) pt.x;
+    int y = cast(int) pt.y;
     Event event = new Event ();
     event.x = x;
     event.y = y;
@@ -1547,8 +1547,8 @@
     event.count = nsEvent.clickCount();
     NSPoint location = nsEvent.locationInWindow();
     NSPoint point = view.convertPoint_fromView_(location, null);
-    event.x = (int) point.x;
-    event.y = (int) point.y;
+    event.x = cast(int) point.x;
+    event.y = cast(int) point.y;
     setInputState (event, nsEvent, type);
     sendEvent (type, event);
 }
@@ -1587,7 +1587,7 @@
         if (keyCode !is 0) {
             event.keyCode = keyCode;
         } else {
-            event.character = (char) keys.characterAtIndex (i);
+            event.character = cast(wchar) keys.characterAtIndex (i);
             //TODO - get unshifted values for Shift+1
             event.keyCode = keyCodes.characterAtIndex (i);
         }
@@ -2201,15 +2201,15 @@
 //  CGPoint pt = new CGPoint ();
 //  OS.GetEventParameter (theEvent, OS.kEventParamWindowMouseLocation, OS.typeHIPoint, null, CGPoint.sizeof, null, pt);
 //  OS.HIViewConvertPoint (pt, 0, handle);
-//  int x = (int) pt.x;
-//  int y = (int) pt.y;
+//  int x = cast(int) pt.x;
+//  int y = cast(int) pt.y;
 //  display.lastX = x;
 //  display.lastY = y;
 //  int [] chord = new int [1];
 //  OS.GetEventParameter (theEvent, OS.kEventParamMouseChord, OS.typeUInt32, null, 4, null, chord);
 //  int [] modifiers = new int [1];
 //  OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, 4, null, modifiers);
-//  return sendMouseEvent (type, button, count, detail, send, chord [0], (short) x, (short) y, modifiers [0]);
+//  return sendMouseEvent (type, button, count, detail, send, chord [0], cast(short) x, cast(short) y, modifiers [0]);
     return false;
 }
 
@@ -2313,11 +2313,11 @@
 
 void setBackground (int control, float [] color) {
 //  ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
-//  OS.GetControlData (control, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
+//  OS.GetControlData (control, cast(short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
 //  if (color !is null) {
-//      fontStyle.backColor_red = (short) (color [0] * 0xffff);
-//      fontStyle.backColor_green = (short) (color [1] * 0xffff);
-//      fontStyle.backColor_blue = (short) (color [2] * 0xffff);
+//      fontStyle.backColor_red = cast(short) (color [0] * 0xffff);
+//      fontStyle.backColor_green = cast(short) (color [1] * 0xffff);
+//      fontStyle.backColor_blue = cast(short) (color [2] * 0xffff);
 //      fontStyle.flags |= OS.kControlUseBackColorMask;
 //  } else {
 //      fontStyle.flags &= ~OS.kControlUseBackColorMask;
@@ -2567,7 +2567,7 @@
 void setFont (NSFont font) {
     //TODO - bad cast
     if (view instanceof NSControl) {
-        ((NSControl)view).setFont(font);
+        (cast(NSControl)view).setFont(font);
     }
 }
 
@@ -2604,11 +2604,11 @@
 
 void setForeground (int control, float [] color) {
 //  ControlFontStyleRec fontStyle = new ControlFontStyleRec ();
-//  OS.GetControlData (control, (short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
+//  OS.GetControlData (control, cast(short) OS.kControlEntireControl, OS.kControlFontStyleTag, ControlFontStyleRec.sizeof, fontStyle, null);
 //  if (color !is null) {
-//      fontStyle.foreColor_red = (short) (color [0] * 0xffff);
-//      fontStyle.foreColor_green = (short) (color [1] * 0xffff);
-//      fontStyle.foreColor_blue = (short) (color [2] * 0xffff);
+//      fontStyle.foreColor_red = cast(short) (color [0] * 0xffff);
+//      fontStyle.foreColor_green = cast(short) (color [1] * 0xffff);
+//      fontStyle.foreColor_blue = cast(short) (color [2] * 0xffff);
 //      fontStyle.flags |= OS.kControlUseForeColorMask;
 //  } else {
 //      fontStyle.flags &= ~OS.kControlUseForeColorMask;