1 11 package org.eclipse.swt.internal.theme; 12 13 import org.eclipse.swt.*; 14 import org.eclipse.swt.graphics.*; 15 import org.eclipse.swt.internal.win32.*; 16 17 public class ScaleDrawData extends RangeDrawData { 18 public int increment; 19 public int pageIncrement; 20 21 static final int TICS_MARGIN = 10; 22 23 public ScaleDrawData() { 24 state = new int[4]; 25 } 26 27 void draw(Theme theme, GC gc, Rectangle bounds) { 28 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 29 int style = this.style; 31 int minimum = this.minimum; 32 int maximum = this.maximum; 33 int selection = this.selection; 34 int pageIncrement = this.pageIncrement; 35 int hTheme = OS.OpenThemeData(0, getClassId()); 36 RECT rect = new RECT (); 37 rect.left = bounds.x; 38 rect.right = rect.left + bounds.width; 39 rect.top = bounds.y; 40 rect.bottom = rect.top + bounds.height; 41 SIZE size = new SIZE(); 42 if ((style & SWT.VERTICAL) != 0) { 43 OS.GetThemePartSize(hTheme, gc.handle, OS.TKP_TRACKVERT, 0, null, OS.TS_TRUE, size); 44 int trackWidth = size.cx - 1; 45 OS.GetThemePartSize(hTheme, gc.handle, OS.TKP_THUMBVERT, 0, null, OS.TS_TRUE, size); 46 int thumbWidth = size.cx, thumbHeight = size.cy; 47 OS.GetThemePartSize(hTheme, gc.handle, OS.TKP_TICS, 0, rect, OS.TS_TRUE, size); 48 int ticWidth = size.cx; 49 int marginX = (thumbWidth - trackWidth) / 2; 50 int marginY = marginX; 51 marginX += TICS_MARGIN; 52 rect.left += marginX; 53 rect.top += marginY; 54 rect.right = rect.left + trackWidth; 55 rect.bottom -= marginY; 56 int trackHeight = rect.bottom - rect.top; 57 OS.DrawThemeBackground(hTheme, gc.handle, OS.TKP_TRACKVERT, 0, rect, null); 58 rect.top += ((trackHeight - thumbHeight) * (selection - minimum)) / Math.max(1, maximum - minimum); 59 rect.left -= (thumbWidth - trackWidth) / 2; 60 rect.right = rect.left + thumbWidth; 61 rect.bottom = rect.top + thumbHeight; 62 OS.DrawThemeBackground(hTheme, gc.handle, OS.TKP_THUMBVERT, 0, rect, null); 63 rect.top = bounds.y + marginY + thumbHeight / 2; 64 rect.bottom = rect.top + 1; 65 for (int sel = minimum; sel <= maximum; sel += pageIncrement) { 66 rect.left = bounds.x + TICS_MARGIN / 2; 67 rect.right = rect.left + ticWidth; 68 if (sel != minimum && sel != maximum) rect.left++; 69 rect.top = bounds.y + marginY + thumbHeight / 2; 70 rect.top += ((trackHeight - thumbHeight) * (sel - minimum)) / Math.max(1, maximum - minimum); 71 rect.bottom = rect.top + 1; 72 OS.DrawThemeBackground(hTheme, gc.handle, OS.TKP_TICSVERT, 1, rect, null); 74 gc.drawLine(rect.left, rect.top, rect.right, rect.top); 75 rect.left = bounds.x + TICS_MARGIN + thumbWidth + 1; 76 rect.right = rect.left + ticWidth; 77 if (sel != minimum && sel != maximum) rect.right--; 78 OS.DrawThemeBackground(hTheme, gc.handle, OS.TKP_TICSVERT, 1, rect, null); 80 gc.drawLine(rect.left, rect.top, rect.right, rect.top); 81 } 82 } else { 83 84 } 85 OS.CloseThemeData (hTheme); 86 } 87 } 88 89 char[] getClassId() { 90 return TRACKBAR; 91 } 92 93 int hit(Theme theme, Point position, Rectangle bounds) { 94 return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE; 95 } 96 97 } 98 | Popular Tags |