diff options
author | Steve Northover <steve> | 2004-11-02 15:59:31 +0000 |
---|---|---|
committer | Steve Northover <steve> | 2004-11-02 15:59:31 +0000 |
commit | 4347318ee55544599f9aa1e141bed166353844a3 (patch) | |
tree | 4758044866dfe362340aac6cad2927cebb1388e4 /bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java | |
parent | 9b2e75bad029158cb5a5c36103892d9c96132a6c (diff) | |
download | eclipse.platform.swt-4347318ee55544599f9aa1e141bed166353844a3.tar.gz eclipse.platform.swt-4347318ee55544599f9aa1e141bed166353844a3.tar.xz eclipse.platform.swt-4347318ee55544599f9aa1e141bed166353844a3.zip |
76750
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java')
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java | 201 |
1 files changed, 53 insertions, 148 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java index 82776f8016..27eb5b98d7 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java @@ -540,8 +540,11 @@ public void setEnabled (boolean enabled) { int hwnd = hwndScrollBar (), type = scrollBarType (); int flags = enabled ? OS.ESB_ENABLE_BOTH : OS.ESB_DISABLE_BOTH; OS.EnableScrollBar (hwnd, type, flags); - state &= ~DISABLED; - if (!enabled) state |= DISABLED; + if (enabled) { + state &= ~DISABLED; + } else { + state |= DISABLED; + } } } @@ -587,46 +590,7 @@ public void setMaximum (int value) { OS.GetScrollInfo (hwnd, type, info); if (value - info.nMin - info.nPage < 1) return; info.nMax = value; - OS.SetScrollInfo (hwnd, type, info, (state & DISABLED) == 0); - - /* - * Bug in Windows. For some reason, when the widget - * is a standard scroll bar, and SetScrollInfo () is - * called with SIF_RANGE or SIF_PAGE, the widget is - * incorrectly made visible so that the next time the - * widget is resized (or another scroll bar operation - * is performed), the scroll bar draws. The fix is - * to hide the scroll bar (again) when already hidden. - */ - if ((state & HIDDEN) != 0) { - /* - * This line is intentionally commented. Currently - * always show scrollbar as being enabled and visible. - */ -// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED); - if (!OS.IsWinCE) { - OS.ShowScrollBar (hwnd, type, false); - } - } - - /* - * Feature in Windows. Using SIF_DISABLENOSCROLL, - * SetScrollInfo () can change enabled and disabled - * state of the scroll bar causing a scroll bar that - * was disabled by the application to become enabled. - * The fix is to disable the scroll bar (again) when - * the application has disabled the scroll bar. - */ - if ((state & DISABLED) != 0) { - /* - * This line is intentionally commented. Currently - * always show scrollbar as being enabled and visible. - */ -// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED); - if (!OS.IsWinCE) { - OS.EnableScrollBar (hwnd, type, OS.ESB_DISABLE_BOTH); - } - } + SetScrollInfo (hwnd, type, info, true); } /** @@ -652,14 +616,51 @@ public void setMinimum (int value) { OS.GetScrollInfo (hwnd, type, info); if (info.nMax - value - info.nPage < 1) return; info.nMin = value; - OS.SetScrollInfo (hwnd, type, info, true); + SetScrollInfo (hwnd, type, info, true); +} + +/** + * Sets the amount that the receiver's value will be + * modified by when the page increment/decrement areas + * are selected to the argument, which must be at least + * one. + * + * @param value the page increment (must be greater than zero) + * + * @exception SWTException <ul> + * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> + * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> + * </ul> + */ +public void setPageIncrement (int value) { + checkWidget(); + if (value < 1) return; + pageIncrement = value; +} + +boolean SetScrollInfo (int hwnd, int flags, SCROLLINFO info, boolean fRedraw) { + /* + * Bug in Windows. For some reason, when SetScrollInfo() + * is used with SIF_POS and the scroll bar is hidden, + * the opposite scroll bar is incorrectly made visible + * so that the next time the parent is resized (or another + * scroll bar operation is performed), the opposite scroll + * bar draws. The fix is turn off redraw for the parent. + */ + boolean fixRedraw = false; + if ((state & (DISABLED | HIDDEN)) != 0) { + fRedraw = false; + fixRedraw = OS.IsWindowVisible (hwnd) && parent.drawCount == 0; + } + if (fixRedraw) OS.DefWindowProc (hwnd, OS.WM_SETREDRAW, 0, 0); + boolean result = OS.SetScrollInfo (hwnd, flags, info, fRedraw); /* * Bug in Windows. For some reason, when the widget - * is a standard scroll bar, and SetScrollInfo () is + * is a standard scroll bar, and SetScrollInfo() is * called with SIF_RANGE or SIF_PAGE, the widget is * incorrectly made visible so that the next time the - * widget is resized (or another scroll bar operation + * parent is resized (or another scroll bar operation * is performed), the scroll bar draws. The fix is * to hide the scroll bar (again) when already hidden. */ @@ -670,7 +671,7 @@ public void setMinimum (int value) { */ // if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED); if (!OS.IsWinCE) { - OS.ShowScrollBar (hwnd, type, false); + OS.ShowScrollBar (hwnd, flags, false); } } @@ -689,28 +690,12 @@ public void setMinimum (int value) { */ // if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED); if (!OS.IsWinCE) { - OS.EnableScrollBar (hwnd, type, OS.ESB_DISABLE_BOTH); + OS.EnableScrollBar (hwnd, flags, OS.ESB_DISABLE_BOTH); } } -} -/** - * Sets the amount that the receiver's value will be - * modified by when the page increment/decrement areas - * are selected to the argument, which must be at least - * one. - * - * @param value the page increment (must be greater than zero) - * - * @exception SWTException <ul> - * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> - * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> - * </ul> - */ -public void setPageIncrement (int value) { - checkWidget(); - if (value < 1) return; - pageIncrement = value; + if (fixRedraw) OS.DefWindowProc (hwnd, OS.WM_SETREDRAW, 1, 0); + return result; } /** @@ -732,7 +717,7 @@ public void setSelection (int selection) { int hwnd = hwndScrollBar (), type = scrollBarType (); info.fMask = OS.SIF_POS; info.nPos = selection; - OS.SetScrollInfo (hwnd, type, info, true); + SetScrollInfo (hwnd, type, info, true); } /** @@ -751,8 +736,6 @@ public void setSelection (int selection) { */ public void setThumb (int value) { checkWidget(); - - /* Position the thumb */ if (value < 1) return; SCROLLINFO info = new SCROLLINFO (); info.cbSize = SCROLLINFO.sizeof; @@ -761,46 +744,7 @@ public void setThumb (int value) { OS.GetScrollInfo (hwnd, type, info); info.nPage = value; if (info.nPage != 0) info.nPage++; - OS.SetScrollInfo (hwnd, type, info, true); - - /* - * Bug in Windows. For some reason, when the widget - * is a standard scroll bar, and SetScrollInfo () is - * called with SIF_RANGE or SIF_PAGE, the widget is - * incorrectly made visible so that the next time the - * widget is resized (or another scroll bar operation - * is performed), the scroll bar draws. The fix is - * to hide the scroll bar (again) when already hidden. - */ - if ((state & HIDDEN) != 0) { - /* - * This line is intentionally commented. Currently - * always show scrollbar as being enabled and visible. - */ -// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED); - if (!OS.IsWinCE) { - OS.ShowScrollBar (hwnd, type, false); - } - } - - /* - * Feature in Windows. Using SIF_DISABLENOSCROLL, - * SetScrollInfo () can change enabled and disabled - * state of the scroll bar causing a scroll bar that - * was disabled by the application to become enabled. - * The fix is to disable the scroll bar (again) when - * the application has disabled the scroll bar. - */ - if ((state & DISABLED) != 0) { - /* - * This line is intentionally commented. Currently - * always show scrollbar as being enabled and visible. - */ -// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED); - if (!OS.IsWinCE) { - OS.EnableScrollBar (hwnd, type, OS.ESB_DISABLE_BOTH); - } - } + SetScrollInfo (hwnd, type, info, true); } /** @@ -842,46 +786,7 @@ public void setValues (int selection, int minimum, int maximum, int thumb, int i info.nPage = thumb; if (info.nPage != 0) info.nPage++; int hwnd = hwndScrollBar (), type = scrollBarType (); - OS.SetScrollInfo (hwnd, type, info, true); - - /* - * Bug in Windows. For some reason, when the widget - * is a standard scroll bar, and SetScrollInfo () is - * called with SIF_RANGE or SIF_PAGE, the widget is - * incorrectly made visible so that the next time the - * widget is resized (or another scroll bar operation - * is performed), the scroll bar draws. The fix is - * to hide the scroll bar (again) when already hidden. - */ - if ((state & HIDDEN) != 0) { - /* - * This line is intentionally commented. Currently - * always show scrollbar as being enabled and visible. - */ -// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED); - if (!OS.IsWinCE) { - OS.ShowScrollBar (hwnd, type, false); - } - } - - /* - * Feature in Windows. Using SIF_DISABLENOSCROLL, - * SetScrollInfo () can change enabled and disabled - * state of the scroll bar causing a scroll bar that - * was disabled by the application to become enabled. - * The fix is to disable the scroll bar (again) when - * the application has disabled the scroll bar. - */ - if ((state & DISABLED) != 0) { - /* - * This line is intentionally commented. Currently - * always show scrollbar as being enabled and visible. - */ -// if (OS.IsWinCE) error (SWT.ERROR_NOT_IMPLEMENTED); - if (!OS.IsWinCE) { - OS.EnableScrollBar (hwnd, type, OS.ESB_DISABLE_BOTH); - } - } + SetScrollInfo (hwnd, type, info, true); } /** |