Mercurial > projects > dwt-win
diff dwt/widgets/Scale.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | ab60f3309436 |
children | efe25e7c8a96 |
line wrap: on
line diff
--- a/dwt/widgets/Scale.d Mon May 05 00:12:38 2008 +0200 +++ b/dwt/widgets/Scale.d Sat May 17 17:34:28 2008 +0200 @@ -50,7 +50,7 @@ alias Control.setBackgroundImage setBackgroundImage; alias Control.windowProc windowProc; - bool ignoreResize; + bool ignoreResize, ignoreSelection; private static /+const+/ WNDPROC TrackBarProc; static const TCHAR[] TrackBarClass = OS.TRACKBAR_CLASS; @@ -68,7 +68,7 @@ TrackBarProc = lpWndClass.lpfnWndProc; /* * Feature in Windows. The track bar window class - * does not include CS_DBLCLKS. This mean that these + * does not include CS_DBLCLKS. This means that these * controls will not get double click messages such as * WM_LBUTTONDBLCLK. The fix is to register a new * window class with CS_DBLCLKS. @@ -248,7 +248,7 @@ */ public int getMinimum () { checkWidget (); - return OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0); + return cast(int)OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0); } /** @@ -334,6 +334,33 @@ ignoreResize = false; } +void setBounds (int x, int y, int width, int height, int flags, bool defer) { + /* + * Bug in Windows. If SetWindowPos() is called on a + * track bar with either SWP_DRAWFRAME, a new size, + * or both during mouse down, the track bar posts a + * WM_MOUSEMOVE message when the mouse has not moved. + * The window proc for the track bar uses WM_MOUSEMOVE + * to issue WM_HSCROLL or WM_SCROLL events to notify + * the application that the slider has changed. The + * end result is that when the user requests a page + * scroll and the application resizes the track bar + * during the change notification, continuous stream + * of WM_MOUSEMOVE messages are generated and the + * thumb moves to the mouse position rather than + * scrolling by a page. The fix is to clear the + * SWP_DRAWFRAME flag. + * + * NOTE: There is no fix for the WM_MOUSEMOVE that + * is generated by a new size. Clearing SWP_DRAWFRAME + * does not fix the problem. However, it is unlikely + * that the programmer will resize the control during + * mouse down. + */ + flags &= ~OS.SWP_DRAWFRAME; + super.setBounds (x, y, width, height, flags, true); +} + /** * Sets the amount that the receiver's value will be * modified by when the up/down (or right/left) arrows @@ -452,6 +479,34 @@ } override LRESULT WM_PAINT (int wParam, int lParam) { + LRESULT result = super.WM_MOUSEWHEEL (wParam, lParam); + if (result !is null) return result; + /* + * Bug in Windows. When a track bar slider is changed + * from WM_MOUSEWHEEL, it does not always send either + * a WM_VSCROLL or M_HSCROLL to notify the application + * of the change. The fix is to detect that the selection + * has changed and that notification has not been issued + * and send the selection event. + */ + int oldPosition = OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0); + ignoreSelection = true; + int /*long*/ code = callWindowProc (handle, OS.WM_MOUSEWHEEL, wParam, lParam); + ignoreSelection = false; + int newPosition = OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0); + if (oldPosition !is newPosition) { + /* + * Send the event because WM_HSCROLL and WM_VSCROLL + * are sent from a modal message loop in windows that + * is active when the user is scrolling. + */ + sendEvent (DWT.Selection); + // widget could be disposed at this point + } + return new LRESULT (code); +} + +override LRESULT WM_MOUSEWHEEL (int wParam, int lParam) { /* * Bug in Windows. For some reason, when WM_CTLCOLORSTATIC * is used to implement transparency and returns a NULL brush, @@ -491,7 +546,7 @@ override LRESULT wmScrollChild (int wParam, int lParam) { /* Do nothing when scrolling is ending */ - int code = wParam & 0xFFFF; + int code = OS.LOWORD (wParam); switch (code) { case OS.TB_ENDTRACK: case OS.TB_THUMBPOSITION: @@ -499,29 +554,31 @@ default: } - Event event = new Event (); - /* - * This code is intentionally commented. The event - * detail field is not currently supported on all - * platforms. - */ -// switch (code) { -// case OS.TB_TOP: event.detail = DWT.HOME; break; -// case OS.TB_BOTTOM: event.detail = DWT.END; break; -// case OS.TB_LINEDOWN: event.detail = DWT.ARROW_DOWN; break; -// case OS.TB_LINEUP: event.detail = DWT.ARROW_UP; break; -// case OS.TB_PAGEDOWN: event.detail = DWT.PAGE_DOWN; break; -// case OS.TB_PAGEUP: event.detail = DWT.PAGE_UP; break; + if (!ignoreSelection) { + Event event = new Event (); + /* + * This code is intentionally commented. The event + * detail field is not currently supported on all + * platforms. + */ +// switch (code) { +// case OS.TB_TOP: event.detail = DWT.HOME; break; +// case OS.TB_BOTTOM: event.detail = DWT.END; break; +// case OS.TB_LINEDOWN: event.detail = DWT.ARROW_DOWN; break; +// case OS.TB_LINEUP: event.detail = DWT.ARROW_UP; break; +// case OS.TB_PAGEDOWN: event.detail = DWT.PAGE_DOWN; break; +// case OS.TB_PAGEUP: event.detail = DWT.PAGE_UP; break; // default: -// } +// } - /* - * Send the event because WM_HSCROLL and WM_VSCROLL - * are sent from a modal message loop in windows that - * is active when the user is scrolling. - */ - sendEvent (DWT.Selection, event); - // widget could be disposed at this point + /* + * Send the event because WM_HSCROLL and WM_VSCROLL + * are sent from a modal message loop in windows that + * is active when the user is scrolling. + */ + sendEvent (DWT.Selection, event); + // widget could be disposed at this point + } return null; }