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 ProgressBarDrawData extends RangeDrawData { 18 19 public ProgressBarDrawData() { 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 RECT rect = new RECT (); 27 rect.left = bounds.x; 28 rect.right = rect.left + bounds.width; 29 rect.top = bounds.y; 30 rect.bottom = rect.top + bounds.height; 31 int[] buffer = new int[1]; 32 OS.GetThemeInt(hTheme, 0, 0, OS.PROGRESSCHUNKSIZE, buffer); 33 int chunkSize = buffer[0]; 34 OS.GetThemeInt(hTheme, 0, 0, OS.PROGRESSSPACESIZE, buffer); 35 int spaceSize = buffer[0]; 36 RECT content = new RECT(); 37 int[] part = getPartId(DrawData.WIDGET_WHOLE); 38 if ((style & SWT.VERTICAL) != 0) { 39 OS.GetThemeBackgroundContentRect(hTheme, gc.handle, part[0], part[1], rect, content); 40 OS.DrawThemeBackground(hTheme, gc.handle, part[0], part[1], rect, null); 41 int top = content.bottom - (((content.bottom - content.top) * (selection - minimum)) / (maximum - minimum)); 42 content.top = content.bottom - chunkSize; 43 while (content.top >= top) { 44 OS.DrawThemeBackground(hTheme, gc.handle, OS.PP_CHUNKVERT, 0, content, null); 45 content.bottom -= chunkSize + spaceSize; 46 content.top = content.bottom - chunkSize; 47 } 48 if (selection != 0) { 49 OS.DrawThemeBackground(hTheme, gc.handle, OS.PP_CHUNKVERT, 0, content, null); 50 } 51 } else { 52 OS.GetThemeBackgroundContentRect(hTheme, gc.handle, part[0], part[1], rect, content); 53 OS.DrawThemeBackground(hTheme, gc.handle, part[0], part[1], rect, null); 54 int right = content.left + (((content.right - content.left) * (selection - minimum)) / (maximum - minimum)); 55 content.right = content.left + chunkSize; 56 while (content.right <= right) { 57 OS.DrawThemeBackground(hTheme, gc.handle, OS.PP_CHUNK, 0, content, null); 58 content.left += chunkSize + spaceSize; 59 content.right = content.left + chunkSize; 60 } 61 if (selection != 0) { 62 OS.DrawThemeBackground(hTheme, gc.handle, OS.PP_CHUNK, 0, content, null); 63 } 64 } 65 OS.CloseThemeData (hTheme); 66 } 67 } 68 69 char[] getClassId() { 70 return PROGRESS; 71 } 72 73 int[] getPartId(int part) { 74 int iPartId = 0, iStateId = 0; 75 if ((style & SWT.VERTICAL) != 0) { 76 iPartId = OS.PP_BARVERT; 77 } else { 78 iPartId = OS.PP_BAR; 79 } 80 return new int[]{iPartId, iStateId}; 81 } 82 83 int hit(Theme theme, Point position, Rectangle bounds) { 84 return bounds.contains(position) ? DrawData.WIDGET_WHOLE : DrawData.WIDGET_NOWHERE; 85 } 86 87 } 88 | Popular Tags |