changeset 61:cb74965f7ca3

ProgressBar
author Frank Benoit <benoit@tionex.de>
date Mon, 04 Feb 2008 14:20:47 +0100
parents 6423053f6d3e
children 7757dae4f29f
files dwt/internal/win32/OS.d dwt/widgets/ProgressBar.d
diffstat 2 files changed, 36 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d	Mon Feb 04 14:12:19 2008 +0100
+++ b/dwt/internal/win32/OS.d	Mon Feb 04 14:20:47 2008 +0100
@@ -1328,7 +1328,7 @@
     public static const int PM_QS_PAINT = QS_PAINT << 16;
     public static const int PM_QS_SENDMESSAGE = QS_SENDMESSAGE << 16;
     public static const int PM_REMOVE = 0x1;
-    public static const char[] PROGRESS_CLASS = "msctls_progress32"; //$NON-NLS-1$
+    public static const TCHAR[] PROGRESS_CLASS = "msctls_progress32"; //$NON-NLS-1$
     public static const int PP_BAR = 1;
     public static const int PP_BARVERT = 2;
     public static const int PP_CHUNK = 3;
--- a/dwt/widgets/ProgressBar.d	Mon Feb 04 14:12:19 2008 +0100
+++ b/dwt/widgets/ProgressBar.d	Mon Feb 04 14:20:47 2008 +0100
@@ -11,17 +11,15 @@
 module dwt.widgets.ProgressBar;
 
 import dwt.widgets.Control;
-class ProgressBar : Control {
-}
-/++
+
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.graphics.Point;
-import dwt.internal.win32.LRESULT;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.WNDCLASS;
+
+import dwt.widgets.Composite;
+
+import dwt.dwthelper.utils;
 
 /**
  * Instances of the receiver represent an unselectable
@@ -40,19 +38,19 @@
  * within the DWT implementation.
  * </p>
  */
-public class ProgressBar extends Control {
+public class ProgressBar : Control {
 
     alias Control.computeSize computeSize;
     alias Control.windowProc windowProc;
 
-    static final int DELAY = 100;
-    static final int TIMER_ID = 100;
-    static final int MINIMUM_WIDTH = 100;
-    static final int ProgressBarProc;
-    static final TCHAR ProgressBarClass = new TCHAR (0, OS.PROGRESS_CLASS, true);
-    static {
-        WNDCLASS lpWndClass = new WNDCLASS ();
-        OS.GetClassInfo (0, ProgressBarClass, lpWndClass);
+    static const int DELAY = 100;
+    static const int TIMER_ID = 100;
+    static const int MINIMUM_WIDTH = 100;
+    static const WNDPROC ProgressBarProc;
+    static const TCHAR[] ProgressBarClass = OS.PROGRESS_CLASS;
+    static this() {
+        WNDCLASS lpWndClass;
+        OS.GetClassInfo (null, ProgressBarClass.ptr, &lpWndClass);
         ProgressBarProc = lpWndClass.lpfnWndProc;
         /*
         * Feature in Windows.  The progress bar window class
@@ -71,16 +69,16 @@
         * 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 = ProgressBarClass.length () * TCHAR.sizeof;
-        int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-        OS.MoveMemory (lpszClassName, ProgressBarClass, byteCount);
+        int byteCount = (ProgressBarClass.length+1) * TCHAR.sizeof;
+        TCHAR* lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+        OS.MoveMemory (lpszClassName, ProgressBarClass.ptr, byteCount);
         lpWndClass.lpszClassName = lpszClassName;
-        OS.RegisterClass (lpWndClass);
+        OS.RegisterClass (&lpWndClass);
         OS.HeapFree (hHeap, 0, lpszClassName);
     }
 
@@ -114,13 +112,13 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public ProgressBar (Composite parent, int style) {
+public this (Composite parent, int style) {
     super (parent, checkStyle (style));
 }
 
-override int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
-    if (handle is 0) return 0;
-    return OS.CallWindowProc (ProgressBarProc, 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 (ProgressBarProc, hwnd, msg, wParam, lParam);
 }
 
 static int checkStyle (int style) {
@@ -207,7 +205,7 @@
     if ((style & DWT.INDETERMINATE) !is 0) {
         int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
         if (OS.COMCTL32_MAJOR < 6 || (bits & OS.PBS_MARQUEE) is 0) {
-            OS.SetTimer (handle, TIMER_ID, DELAY, 0);
+            OS.SetTimer (handle, TIMER_ID, DELAY, null);
         } else {
             OS.SendMessage (handle, OS.PBM_SETMARQUEE, 1, DELAY);
         }
@@ -302,17 +300,17 @@
     return bits;
 }
 
-override TCHAR windowClass () {
-    return ProgressBarClass;
+override char[] windowClass () {
+    return TCHARsToStr( ProgressBarClass );
 }
 
 override int windowProc () {
-    return ProgressBarProc;
+    return cast(int) ProgressBarProc;
 }
 
 override LRESULT WM_GETDLGCODE (int wParam, int lParam) {
     LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Feature in Windows.  The progress bar does
     * not implement WM_GETDLGCODE.  As a result,
@@ -322,12 +320,12 @@
     * implement WM_GETDLGCODE to behave like a
     * STATIC control.
     */
-    return new LRESULT (OS.DLGC_STATIC);
+    return cast(LRESULT) (OS.DLGC_STATIC);
 }
 
 override LRESULT WM_SIZE (int wParam, int lParam) {
     LRESULT result = super.WM_SIZE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Feature in Windows.  When a progress bar with the style
     * PBS_MARQUEE becomes too small, the animation (currently
@@ -342,8 +340,8 @@
     if ((style & DWT.INDETERMINATE) !is 0) {
         if (OS.COMCTL32_MAJOR >= 6) {
             forceResize ();
-            RECT rect = new RECT ();
-            OS.GetClientRect (handle, rect);
+            RECT rect;
+            OS.GetClientRect (handle, &rect);
             int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE);
             int newBits = oldBits;
             if (rect.right - rect.left < MINIMUM_WIDTH) {
@@ -363,7 +361,7 @@
 
 override LRESULT WM_TIMER (int wParam, int lParam) {
     LRESULT result = super.WM_TIMER (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if ((style & DWT.INDETERMINATE) !is 0) {
         int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
         if (OS.COMCTL32_MAJOR < 6 || (bits & OS.PBS_MARQUEE) is 0) {
@@ -376,4 +374,4 @@
 }
 
 }
-++/
+