diff dwt/widgets/ScrollBar.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents 25f88bf5a6df
children a8fed3e56433
line wrap: on
line diff
--- a/dwt/widgets/ScrollBar.d	Mon May 05 00:12:38 2008 +0200
+++ b/dwt/widgets/ScrollBar.d	Sat May 17 17:34:28 2008 +0200
@@ -207,7 +207,10 @@
     } else {
         OS.ShowScrollBar (hwnd, type, false);
     }
+    parent.destroyScrollBar (style);
     releaseHandle ();
+    //This code is intentionally commented
+    //parent.sendEvent (DWT.Resize);
 }
 
 Rectangle getBounds () {
@@ -433,6 +436,13 @@
  */
 public bool getVisible () {
     checkWidget();
+    if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION(4, 10)) {
+        SCROLLBARINFO psbi;
+        psbi.cbSize = SCROLLBARINFO.sizeof;
+        int idObject = (style & DWT.VERTICAL) !is 0 ? OS.OBJID_VSCROLL : OS.OBJID_HSCROLL;
+        OS.GetScrollBarInfo (hwndScrollBar (), idObject, &psbi);
+        return (psbi.rgstate [0] & OS.STATE_SYSTEM_INVISIBLE) is 0;
+    }
     return (state & HIDDEN) is 0;
 }
 
@@ -653,7 +663,27 @@
     * scroll bar operation is performed), the opposite scroll
     * bar draws.  The fix is to hide both scroll bars.
     */
-    if ((state & (DISABLED | HIDDEN)) !is 0) fRedraw = false;
+    bool barVisible = false;
+    bool visible = getVisible ();
+
+    /*
+    * This line is intentionally commented.  Currently
+    * always show scrollbar as being enabled and visible.
+    */
+//  if (OS.IsWinCE) error (DWT.ERROR_NOT_IMPLEMENTED);
+    ScrollBar bar = null;
+    if (!OS.IsWinCE) {
+        switch (flags) {
+            case OS.SB_HORZ:
+                bar = parent.getVerticalBar ();
+                break;
+            case OS.SB_VERT:
+                bar = parent.getHorizontalBar ();
+                break;
+        }
+        barVisible = bar !is null && bar.getVisible ();
+    }
+    if (!visible || (state & DISABLED) !is 0) fRedraw = false;
     bool result = cast(bool) OS.SetScrollInfo (hwnd, flags, info, fRedraw);
 
     /*
@@ -665,25 +695,31 @@
     * is performed), the scroll bar draws.  The fix is
     * to hide the scroll bar (again) when already hidden.
     */
-    if ((state & HIDDEN) !is 0) {
+    if (!visible) {
         /*
         * This line is intentionally commented.  Currently
         * always show scrollbar as being enabled and visible.
         */
 //      if (OS.IsWinCE) error (DWT.ERROR_NOT_IMPLEMENTED);
         if (!OS.IsWinCE) {
-            ScrollBar bar = null;
-            switch (flags) {
-                case OS.SB_HORZ:
-                    bar = parent.getVerticalBar ();
-                    break;
-                case OS.SB_VERT:
-                    bar = parent.getHorizontalBar ();
-                    break;
-                default:
-            }
-            bool both = bar !is null && !bar.getVisible ();
-            OS.ShowScrollBar (hwnd, both ? OS.SB_BOTH : flags, false);
+            OS.ShowScrollBar (hwnd, !barVisible ? OS.SB_BOTH : flags, false);
+        }
+    }
+
+    /*
+    * Bug in Windows.  When only one scroll bar is visible,
+    * and the thumb changes using SIF_RANGE or SIF_PAGE
+    * from being visible to hidden, the opposite scroll
+    * bar is incorrectly made visible.  The next time the
+    * parent is resized (or another scroll bar operation
+    * is performed), the opposite scroll bar draws.  The
+    * fix is to hide the opposite scroll bar again.
+    *
+    * NOTE: This problem only happens on Vista
+    */
+    if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
+        if (visible && bar !is null && !barVisible) {
+            OS.ShowScrollBar (hwnd, flags is OS.SB_HORZ ? OS.SB_VERT : OS.SB_HORZ, false);
         }
     }
 
@@ -820,8 +856,7 @@
  */
 public void setVisible (bool visible) {
     checkWidget();
-    bool isVisible = (state & HIDDEN) is 0;
-    if (isVisible is visible) return;
+    if (visible is getVisible ()) return;
 
     /*
     * On Windows CE, use SIF_DISABLENOSCROLL to show and
@@ -898,11 +933,11 @@
     }
 }
 
-LRESULT wmScrollChild (int wParam, int lParam) {
+LRESULT wmScrollChild (int /*long*/ wParam, int /*long*/ lParam) {
 trc(__LINE__);
 
     /* Do nothing when scrolling is ending */
-    int code = wParam & 0xFFFF;
+    int code = OS.LOWORD (wParam);
     if (code is OS.SB_ENDSCROLL) return null;
 
     /*