### Eclipse Workspace Patch 1.0 #P org.eclipse.swt diff --git Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java index 8490144..c9bc421 100644 --- Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java +++ Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2012 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,9 +11,9 @@ package org.eclipse.swt.widgets; -import org.eclipse.swt.internal.win32.*; import org.eclipse.swt.*; import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.win32.*; /** * This class is the abstract superclass of all classes which @@ -291,6 +291,7 @@ } LRESULT WM_HSCROLL (long /*int*/ wParam, long /*int*/ lParam) { + System.out.println("Scrollable.WM_HSCROLL()"); LRESULT result = super.WM_HSCROLL (wParam, lParam); if (result != null) return result; @@ -308,7 +309,14 @@ } LRESULT WM_MOUSEWHEEL (long /*int*/ wParam, long /*int*/ lParam) { + System.out.println("Scrollable.WM_MOUSEWHEEL()"); return wmScrollWheel ((state & CANVAS) != 0, wParam, lParam); +} + +LRESULT WM_MOUSEHWHEEL (long /*int*/ wParam, long /*int*/ lParam) { + System.out.println("Scrollable.WM_MOUSEHWHEEL()"); +// return super.WM_MOUSEHWHEEL(wParam, lParam); + return wmScrollHWheel ((state & CANVAS) != 0, wParam, lParam); } LRESULT WM_SIZE (long /*int*/ wParam, long /*int*/ lParam) { @@ -320,6 +328,7 @@ } LRESULT WM_VSCROLL (long /*int*/ wParam, long /*int*/ lParam) { + System.out.println("Scrollable.WM_VSCROLL()"); LRESULT result = super.WM_VSCROLL (wParam, lParam); if (result != null) return result; /* @@ -476,6 +485,75 @@ return new LRESULT (code); } +LRESULT wmScrollHWheel (boolean update, long /*int*/ wParam, long /*int*/ lParam) { + int scrollRemainder = display.scrollHRemainder; + LRESULT result = super.WM_MOUSEHWHEEL (wParam, lParam); + if (result != null) return result; + /* + * Translate WM_MOUSEHWHEEL to WM_HSCROLL. + */ + if (update) { + if ((wParam & (OS.MK_SHIFT | OS.MK_CONTROL)) != 0) return result; + boolean horizontal = horizontalBar != null && horizontalBar.getEnabled (); + int msg = horizontal ? OS.WM_HSCROLL : 0; + if (msg == 0) return result; + int [] charsToScroll = new int [1]; + // TODO: http://msdn.microsoft.com/en-us/library/ms997498.aspx : SPI_GETWHEELSCROLLCHARS may not be defined! + int SPI_GETWHEELSCROLLCHARS = 0x006C; + OS.SystemParametersInfo (SPI_GETWHEELSCROLLCHARS, 0, charsToScroll, 0); + int delta = OS.GET_WHEEL_DELTA_WPARAM (wParam); + boolean pageScroll = charsToScroll [0] == OS.WHEEL_PAGESCROLL; + if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) { + ScrollBar bar = horizontalBar; + SCROLLINFO info = new SCROLLINFO (); + info.cbSize = SCROLLINFO.sizeof; + info.fMask = OS.SIF_POS; + OS.GetScrollInfo (handle, bar.scrollBarType (), info); + int increment = pageScroll ? bar.getPageIncrement () : bar.getIncrement (); + info.nPos += increment * delta / OS.WHEEL_DELTA; + OS.SetScrollInfo (handle, bar.scrollBarType (), info, true); + OS.SendMessage (handle, msg, OS.SB_THUMBPOSITION, 0); + } else { + int code = 0; + if (pageScroll) { + code = delta < 0 ? OS.SB_PAGEDOWN : OS.SB_PAGEUP; + } else { + code = delta < 0 ? OS.SB_LINEDOWN : OS.SB_LINEUP; + } + /* Check if the delta and the remainder have the same direction (sign) */ + if ((delta ^ scrollRemainder) >= 0) delta += scrollRemainder; + int count = Math.abs (delta) / OS.WHEEL_DELTA; + for (int i=0; i