@Override void draw(Theme theme, GC gc, Rectangle bounds) { if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { int /*long*/ hTheme = OS.OpenThemeData(0, getClassId()); RECT rect = new RECT (); if ((style & SWT.VERTICAL) != 0) { rect.top = bounds.y; rect.bottom = rect.top + width; int[] part = getPartId(DrawData.SCROLLBAR_UP_ARROW); OS.DrawThemeBackground (hTheme, gc.handle, part[0], part[1], rect, null); rect.bottom = bounds.y + bounds.height; rect.top = rect.bottom - width; part = getPartId(DrawData.SCROLLBAR_DOWN_ARROW); OS.DrawThemeBackground (hTheme, gc.handle, part[0], part[1], rect, null); int totalWidth = bounds.height - 2 * width; rect.top = bounds.y + width; rect.bottom = thumbPos; part = getPartId(DrawData.SCROLLBAR_UP_TRACK); OS.DrawThemeBackground (hTheme, gc.handle, part[0], part[1], rect, null); rect.top = rect.bottom; rect.bottom = rect.top + thumbWidth; part = getPartId(DrawData.SCROLLBAR_THUMB); OS.DrawThemeBackground (hTheme, gc.handle, part[0], part[1], rect, null); OS.DrawThemeBackground (hTheme, gc.handle, OS.SBP_GRIPPERVERT, part[1], rect, null); rect.top = rect.bottom; rect.bottom = bounds.y + bounds.height - width; part = getPartId(DrawData.SCROLLBAR_DOWN_TRACK); OS.DrawThemeBackground (hTheme, gc.handle, part[0], part[1], rect, null);
@Override int getSelection(Point position, Rectangle bounds) { if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { int /*long*/ hTheme = OS.OpenThemeData(0, getClassId()); if ((style & SWT.VERTICAL) != 0) { int width = OS.GetThemeSysSize(hTheme, OS.SM_CXVSCROLL); int totalWidth = bounds.height - 2 * width; int thumbPos = bounds.y + width + Math.max(0, (totalWidth * selection) / Math.max(1, (maximum - minimum))); thumbPos += position.y; int selection = ((thumbPos - bounds.y - width) * (maximum - minimum)) / totalWidth; return Math.max(0, Math.min(selection, maximum - thumb)); } else { } OS.CloseThemeData (hTheme); } return 0; }
@Override Rectangle getBounds(int part, Rectangle bounds) { if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { int /*long*/ hTheme = OS.OpenThemeData(0, getClassId()); if ((style & SWT.VERTICAL) != 0) { int width = OS.GetThemeSysSize(hTheme, OS.SM_CXVSCROLL); int totalWidth = bounds.height - 2 * width; int thumbWidth = Math.max(width / 2, (totalWidth * thumb) / Math.max(1, (maximum - minimum)));//BAD int thumbPos = bounds.y + width + Math.max(0, (totalWidth * selection) / Math.max(1, (maximum - minimum))); switch (part) { case DrawData.SCROLLBAR_DOWN_ARROW: return new Rectangle(bounds.x, bounds.y + bounds.height - width, bounds.width, width); case DrawData.SCROLLBAR_UP_ARROW: return new Rectangle(bounds.x, bounds.y, bounds.width, width); case DrawData.SCROLLBAR_UP_TRACK: return new Rectangle(bounds.x, bounds.y + width, bounds.width, thumbPos - bounds.y - width); case DrawData.SCROLLBAR_THUMB: return new Rectangle(bounds.x, thumbPos, bounds.width, thumbWidth); case DrawData.SCROLLBAR_DOWN_TRACK: return new Rectangle(bounds.x, thumbPos + thumbWidth, bounds.width, bounds.y + bounds.height - width - thumbPos - thumbWidth); } } else { } OS.CloseThemeData (hTheme); } return super.getBounds(part, bounds); }
@Override int hit(Theme theme, Point position, Rectangle bounds) { if (!(OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ())) return -1; int /*long*/ hTheme = OS.OpenThemeData(0, getClassId()); rect.top = bounds.y; rect.bottom = rect.top + width; int[] part = getPartId(DrawData.SCROLLBAR_UP_ARROW); OS.HitTestThemeBackground(hTheme, hDC, part[0], part[1], 0, rect, 0, pt, code); if (code[0] != OS.HTNOWHERE) return DrawData.SCROLLBAR_UP_ARROW; rect.bottom = bounds.y + bounds.height; rect.top = rect.bottom - width; part = getPartId(DrawData.SCROLLBAR_DOWN_ARROW); OS.HitTestThemeBackground(hTheme, hDC, part[0], part[1], 0, rect, 0, pt, code); if (code[0] != OS.HTNOWHERE) return DrawData.SCROLLBAR_DOWN_ARROW; rect.top = bounds.y + width; rect.bottom = thumbPos; part = getPartId(DrawData.SCROLLBAR_THUMB); OS.HitTestThemeBackground(hTheme, hDC, part[0], part[1], 0, rect, 0, pt, code); if (code[0] != OS.HTNOWHERE) return DrawData.SCROLLBAR_UP_TRACK; rect.top = rect.bottom; rect.bottom = rect.top + thumbWidth; part = getPartId(DrawData.SCROLLBAR_UP_TRACK); OS.HitTestThemeBackground(hTheme, hDC, part[0], part[1], 0, rect, 0, pt, code); if (code[0] != OS.HTNOWHERE) return DrawData.SCROLLBAR_THUMB; rect.top = rect.bottom; rect.bottom = bounds.y + bounds.height - width; part = getPartId(DrawData.SCROLLBAR_DOWN_TRACK); OS.HitTestThemeBackground(hTheme, hDC, part[0], part[1], 0, rect, 0, pt, code);