diff dwt/widgets/ScrollBar.d @ 26:74a3be48bba8

Ported dwt.widgets.ScrollBar
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Mon, 08 Sep 2008 17:55:37 +0200
parents e831403a80a9
children 642f460a0908
line wrap: on
line diff
--- a/dwt/widgets/ScrollBar.d	Mon Sep 08 17:44:31 2008 +0200
+++ b/dwt/widgets/ScrollBar.d	Mon Sep 08 17:55:37 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.ScrollBar;
 
-import dwt.dwthelper.utils;
-
  
 import dwt.DWT;
 import dwt.DWTException;
@@ -22,6 +23,13 @@
 import dwt.internal.cocoa.OS;
 import dwt.internal.cocoa.id;
 
+import dwt.dwthelper.utils;
+import dwt.internal.cocoa.CGFloat;
+import dwt.widgets.Event;
+import dwt.widgets.Scrollable;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Widget;
+
 /**
  * Instances of this class are selectable user interface
  * objects that represent a range of positive, numeric values. 
@@ -412,7 +420,7 @@
         value = getSelection ();
     }
     Event event = new Event();
-    int hitPart = (cast(NSScroller)view).hitPart();
+    NSScrollerPart hitPart = (cast(NSScroller)view).hitPart();
     switch (hitPart) {
         case OS.NSScrollerDecrementLine:
             value -= increment;
@@ -656,7 +664,7 @@
     selection = Math.max(minimum, Math.min(maximum - thumb, selection));
     int range = maximum - thumb - minimum;
     float fraction = range < 0 ? 1 : cast(float)(selection - minimum) / range;
-    float knob = minimum is maximum ? 1 : cast(float)(thumb - minimum) / maximum - minimum;
+    CGFloat knob = minimum is maximum ? 1 : cast(CGFloat)(thumb - minimum) / maximum - minimum;
     widget.setFloatValue(fraction, knob);
     widget.setEnabled(range > 0); 
 }