diff dwt/widgets/Scale.d @ 62:7757dae4f29f

Sash
author Frank Benoit <benoit@tionex.de>
date Mon, 04 Feb 2008 14:32:57 +0100
parents 0f25be5cbe6f
children adfa8c39be39
line wrap: on
line diff
--- a/dwt/widgets/Scale.d	Mon Feb 04 14:20:47 2008 +0100
+++ b/dwt/widgets/Scale.d	Mon Feb 04 14:32:57 2008 +0100
@@ -10,13 +10,6 @@
  *******************************************************************************/
 module dwt.widgets.Scale;
 
-import dwt.widgets.Control;
-import dwt.widgets.Composite;
-
-class Scale : Control {
-    this (Composite parent, int style) ;
-}
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.SelectionListener;
@@ -27,6 +20,11 @@
 import dwt.internal.win32.TCHAR;
 import dwt.internal.win32.WNDCLASS;
 
+import dwt.widgets.Control;
+import dwt.widgets.Composite;
+
+import dwt.dwthelper.utils;
+
 /**
  * Instances of the receiver represent a selectable user
  * interface object that present a range of continuous
@@ -46,18 +44,18 @@
  * </p>
  */
 
-public class Scale extends Control {
+public class Scale : Control {
 
     alias Control.computeSize computeSize;
     alias Control.setBackgroundImage setBackgroundImage;
     alias Control.windowProc windowProc;
 
     bool ignoreResize;
-    static final int TrackBarProc;
-    static final TCHAR TrackBarClass = new TCHAR (0, OS.TRACKBAR_CLASS, true);
-    static {
-        WNDCLASS lpWndClass = new WNDCLASS ();
-        OS.GetClassInfo (0, TrackBarClass, lpWndClass);
+    static const WNDPROC TrackBarProc;
+    static const TCHAR[] TrackBarClass = OS.TRACKBAR_CLASS;
+    static this() {
+        WNDCLASS lpWndClass;
+        OS.GetClassInfo (null, TrackBarClass.ptr, &lpWndClass);
         TrackBarProc = lpWndClass.lpfnWndProc;
         /*
         * Feature in Windows.  The track bar window class
@@ -76,13 +74,13 @@
         * code, other than DWT, could create a control with
         * this class name, and fail unexpectedly.
         */
-        int hInstance = OS.GetModuleHandle (null);
-        int hHeap = OS.GetProcessHeap ();
+        auto hInstance = OS.GetModuleHandle (null);
+        auto hHeap = OS.GetProcessHeap ();
         lpWndClass.hInstance = hInstance;
         lpWndClass.style &= ~OS.CS_GLOBALCLASS;
         lpWndClass.style |= OS.CS_DBLCLKS;
         int byteCount = TrackBarClass.length () * TCHAR.sizeof;
-        int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+        auto lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
         OS.MoveMemory (lpszClassName, TrackBarClass, byteCount);
         lpWndClass.lpszClassName = lpszClassName;
         OS.RegisterClass (lpWndClass);
@@ -118,7 +116,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Scale (Composite parent, int style) {
+public this (Composite parent, int style) {
     super (parent, checkStyle (style));
 }
 
@@ -153,9 +151,9 @@
     addListener (DWT.DefaultSelection,typedListener);
 }
 
-override int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
-    if (handle is 0) return 0;
-    return OS.CallWindowProc (TrackBarProc, hwnd, msg, wParam, lParam);
+override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
+    if (handle is null) return LRESULT.ZERO;
+    return cast(LRESULT)OS.CallWindowProc (TrackBarProc, hwnd, msg, wParam, lParam);
 }
 
 static int checkStyle (int style) {
@@ -166,8 +164,8 @@
     checkWidget ();
     int border = getBorderWidth ();
     int width = border * 2, height = border * 2;
-    RECT rect = new RECT ();
-    OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, rect);
+    RECT rect;
+    OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, &rect);
     if ((style & DWT.HORIZONTAL) !is 0) {
         width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10;
         int scrollY = OS.GetSystemMetrics (OS.SM_CYHSCROLL);
@@ -485,7 +483,7 @@
     switch (code) {
         case OS.TB_ENDTRACK:
         case OS.TB_THUMBPOSITION:
-            return null;
+            return LRESULT.NULL;
     }
 
     Event event = new Event ();
@@ -510,8 +508,8 @@
     */
     sendEvent (DWT.Selection, event);
     // widget could be disposed at this point
-    return null;
+    return LRESULT.NULL;
 }
 
 }
-++/
+