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 ExpanderDrawData extends DrawData { 18 19 public ExpanderDrawData() { 20 state = new int[1]; 21 } 22 23 void draw(Theme theme, GC gc, Rectangle bounds) { 24 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 25 int hTheme = OS.OpenThemeData(0, getClassId()); 26 int iStateId = OS.GLPS_CLOSED; 27 if ((this.style & SWT.DOWN) != 0) iStateId = OS.GLPS_OPENED; 28 SIZE size = new SIZE(); 29 OS.GetThemePartSize(hTheme, gc.handle, OS.TVP_GLYPH, iStateId, null, OS.TS_TRUE, size); 30 RECT rect = new RECT (); 31 rect.left = bounds.x; 32 rect.right = rect.left + size.cx; 33 rect.top = bounds.y; 34 rect.bottom = rect.top + size.cy; 35 OS.DrawThemeBackground (hTheme, gc.handle, OS.TVP_GLYPH, iStateId, rect, null); 36 OS.CloseThemeData (hTheme); 37 } 38 } 39 40 char[] getClassId() { 41 return TREEVIEW; 42 } 43 44 int[] getPartId(int part) { 45 int iPartId = OS.TVP_GLYPH; 46 int iStateId = OS.GLPS_CLOSED; 47 if ((this.style & SWT.DOWN) != 0) iStateId = OS.GLPS_OPENED; 48 return new int[]{iPartId, iStateId}; 49 } 50 51 int hit(Theme theme, Point position, Rectangle bounds) { 52 if (!(OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ())) return DrawData.WIDGET_NOWHERE; 53 if (!bounds.contains(position)) return DrawData.WIDGET_NOWHERE; 54 int hTheme = OS.OpenThemeData(0, getClassId()); 55 SIZE size = new SIZE(); 56 int[] part = getPartId(DrawData.WIDGET_WHOLE); 57 OS.GetThemePartSize(hTheme, 0, part[0], part[1], null, OS.TS_TRUE, size); 58 OS.CloseThemeData (hTheme); 59 if (new Rectangle(bounds.x, bounds.y, size.cx, size.cy).contains(position)) { 60 return DrawData.WIDGET_WHOLE; 61 } 62 return DrawData.WIDGET_NOWHERE; 63 } 64 65 } 66 | Popular Tags |