- Timestamp:
- Nov 10, 2010, 3:50:16 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/plugins/org.eclipse.swt/Eclipse SWT/pm/org/eclipse/swt/widgets/ProgressBar.java
r260 r265 30 30 */ 31 31 public class ProgressBar extends Control { 32 int maxRange ;33 int minRange ;32 int maxRange = 100; 33 int minRange = 0; 34 34 int position; 35 // static final int ProgressBarProc; 36 // static final TCHAR ProgressBarClass = new TCHAR (0, OS.PROGRESS_CLASS, true); 37 // static { 38 // WNDCLASS lpWndClass = new WNDCLASS (); 39 // OS.GetClassInfo (0, ProgressBarClass, lpWndClass); 40 // ProgressBarProc = lpWndClass.lpfnWndProc; 41 // } 42 // 43 ///** 44 // * Constructs a new instance of this class given its parent 45 // * and a style value describing its behavior and appearance. 46 // * <p> 47 // * The style value is either one of the style constants defined in 48 // * class <code>SWT</code> which is applicable to instances of this 49 // * class, or must be built by <em>bitwise OR</em>'ing together 50 // * (that is, using the <code>int</code> "|" operator) two or more 51 // * of those <code>SWT</code> style constants. The class description 52 // * lists the style constants that are applicable to the class. 53 // * Style bits are also inherited from superclasses. 54 // * </p> 55 // * 56 // * @param parent a composite control which will be the parent of the new instance (cannot be null) 57 // * @param style the style of control to construct 58 // * 59 // * @exception IllegalArgumentException <ul> 60 // * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> 61 // * </ul> 62 // * @exception SWTException <ul> 63 // * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> 64 // * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> 65 // * </ul> 66 // * 67 // * @see SWT#SMOOTH 68 // * @see SWT#HORIZONTAL 69 // * @see SWT#VERTICAL 70 // * @see Widget#checkSubclass 71 // * @see Widget#getStyle 72 // */ 35 static final int ProgressBarProc; 36 static final PSZ ProgressBarClass = PSZ.getAtom (OS.WC_SLIDER); 37 static { 38 CLASSINFO lpWndClass = new CLASSINFO (); 39 OS.WinQueryClassInfo (OS.NULLHANDLE, ProgressBarClass, lpWndClass); 40 ProgressBarProc = lpWndClass.pfnWindowProc; 41 } 42 /** 43 * Constructs a new instance of this class given its parent 44 * and a style value describing its behavior and appearance. 45 * <p> 46 * The style value is either one of the style constants defined in 47 * class <code>SWT</code> which is applicable to instances of this 48 * class, or must be built by <em>bitwise OR</em>'ing together 49 * (that is, using the <code>int</code> "|" operator) two or more 50 * of those <code>SWT</code> style constants. The class description 51 * lists the style constants that are applicable to the class. 52 * Style bits are also inherited from superclasses. 53 * </p> 54 * 55 * @param parent a composite control which will be the parent of the new instance (cannot be null) 56 * @param style the style of control to construct 57 * 58 * @exception IllegalArgumentException <ul> 59 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> 60 * </ul> 61 * @exception SWTException <ul> 62 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> 63 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> 64 * </ul> 65 * 66 * @see SWT#SMOOTH 67 * @see SWT#HORIZONTAL 68 * @see SWT#VERTICAL 69 * @see Widget#checkSubclass 70 * @see Widget#getStyle 71 */ 73 72 public ProgressBar (Composite parent, int style) { 74 // super (parent, checkStyle (style)); 75 PSZ pszTitle = new PSZ("u"); 76 PSZ pszButton1 = new PSZ("Text 2"); 77 PSZ pszCaption1 = new PSZ("Text 3"); 78 PSZ pszCaption2 = new PSZ("Text 4"); 79 PSZ pszCaption3 = new PSZ("Text 5"); 80 PSZ pszFontNameSize = new PSZ("9.WarpSans Bold"); 81 if ((handle=OS.PrgShowDlg(OS.HWND_DESKTOP, parent.handle, (short)(OS.PRS_SHOW | OS.PRS_BAR | OS.PRS_SEGMENTED), -1,0, 0, (short)1234, null, null, null, null, null)) != OS.NULLHANDLE){ 82 int[] pulForegroundColor = new int[1]; 83 int[] pulBackgroundColor = new int[1]; 84 pulForegroundColor[0] = OS.LEAVE_AS_IS; 85 pulBackgroundColor[0] = OS.LEAVE_AS_IS; 86 // if(!OS.PrgSetupAttributes(handle, OS.CAPTION_SET_1, pulForegroundColor, pulBackgroundColor, pszFontNameSize, true)) 87 // System.out.println("Couldn't create progress dialog! "); 88 } 89 else{ 90 System.out.println("Couldn't create progress dialog! "); 91 } 73 super (parent, checkStyle (style)); 74 OS.WinSendMsg(handle, OS.SLM_SETSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SHAFTDIMENSIONS, (short)0), 15); 92 75 } 93 76 94 77 int callWindowProc (int msg, int mp1, int mp2) { 95 /* if (handle == 0) */return 0;96 // return OS.CallWindowProc (ProgressBarProc, handle, msg, wParam, lParam);78 if (handle == 0) return 0; 79 return OS.WinCallWindowProc(ProgressBarProc, handle, msg, mp1, mp2); 97 80 } 98 81 … … 101 84 } 102 85 103 //public Point computeSize (int wHint, int hHint, boolean changed) { 104 // checkWidget (); 105 // int border = getBorderWidth (); 106 // int width = border * 2, height = border * 2; 107 // if ((style & SWT.HORIZONTAL) != 0) { 108 // width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10; 109 // height += OS.GetSystemMetrics (OS.SM_CYHSCROLL); 110 // } else { 111 // width += OS.GetSystemMetrics (OS.SM_CXVSCROLL); 112 // height += OS.GetSystemMetrics (OS.SM_CYVSCROLL) * 10; 113 // } 114 // if (wHint != SWT.DEFAULT) width = wHint + (border * 2); 115 // if (hHint != SWT.DEFAULT) height = hHint + (border * 2); 116 // return new Point (width, height); 117 //} 86 public Point computeSize (int wHint, int hHint, boolean changed) { 87 checkWidget (); 88 int border = getBorderWidth (); 89 int width = border * 2, height = border * 2; 90 int shaftLength = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SHAFTDIMENSIONS, (short)OS.SMA_RANGEVALUE), 0); 91 int arm = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMDIMENSIONS, (short)OS.SMA_RANGEVALUE), 0); 92 int tick = OS.WinSendMsg(handle, OS.SLM_QUERYTICKSIZE, 1, 0); 93 if ((style & SWT.HORIZONTAL) != 0) { 94 width += OS.WinQuerySysValue (OS.HWND_DESKTOP, OS.SV_CXHSCROLLARROW ) * 10; 95 height += OS.WinQuerySysValue (OS.HWND_DESKTOP, OS.SV_CYHSCROLL) + tick + OS.SHORT2FROMMP(arm); 96 } else { 97 width += OS.WinQuerySysValue (OS.HWND_DESKTOP, OS.SV_CXVSCROLL) + tick + OS.SHORT2FROMMP(arm); 98 height += OS.WinQuerySysValue (OS.HWND_DESKTOP, OS.SV_CYVSCROLLARROW ) * 10; 99 } 100 if (wHint != SWT.DEFAULT) width = wHint + (border * 2); 101 if (hHint != SWT.DEFAULT) height = hHint + (border * 2); 102 return new Point (width, height); 103 } 118 104 119 105 void createHandle () { 120 106 super.createHandle (); 121 // OS.SendMessage (handle, OS.TBM_SETRANGEMAX, 0, 100); 122 // OS.SendMessage (handle, OS.TBM_SETPAGESIZE, 0, 10); 123 // OS.SendMessage (handle, OS.TBM_SETTICFREQ, 10, 0); 124 } 125 126 //int defaultForeground () { 127 // return OS.GetSysColor (OS.COLOR_HIGHLIGHT); 128 //} 129 // 130 ///** 131 // * Returns the maximum value which the receiver will allow. 132 // * 133 // * @return the maximum 134 // * 135 // * @exception SWTException <ul> 136 // * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 137 // * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 138 // * </ul> 139 // */ 107 } 108 109 int defaultForeground () { 110 return OS.WinQuerySysColor(handle, OS.SYSCLR_WINDOWTEXT, 0); 111 } 112 113 /** 114 * Returns the maximum value which the receiver will allow. 115 * 116 * @return the maximum 117 * 118 * @exception SWTException <ul> 119 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 120 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 121 * </ul> 122 */ 140 123 public int getMaximum () { 141 124 checkWidget (); … … 143 126 } 144 127 145 / //**146 //* Returns the minimum value which the receiver will allow.147 //*148 //* @return the minimum149 //*150 //* @exception SWTException <ul>151 //* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>152 //* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>153 //* </ul>154 //*/128 /** 129 * Returns the minimum value which the receiver will allow. 130 * 131 * @return the minimum 132 * 133 * @exception SWTException <ul> 134 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 135 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 136 * </ul> 137 */ 155 138 public int getMinimum () { 156 139 checkWidget (); … … 158 141 } 159 142 160 / //**161 //* Returns the single <em>selection</em> that is the receiver's position.162 //*163 //* @return the selection164 //*165 //* @exception SWTException <ul>166 //* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>167 //* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>168 //* </ul>169 //*/143 /** 144 * Returns the single <em>selection</em> that is the receiver's position. 145 * 146 * @return the selection 147 * 148 * @exception SWTException <ul> 149 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 150 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 151 * </ul> 152 */ 170 153 public int getSelection () { 171 154 checkWidget (); … … 192 175 } 193 176 177 public void setBounds (int x, int y, int width, int height) { 178 OS.WinSendMsg(handle, OS.SLM_SETSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SHAFTDIMENSIONS, (short)0), height); 179 super.setBounds(x, y, width, height); 180 } 194 181 //void setForegroundPixel (int pixel) { 195 182 // if (foreground == pixel) return; … … 225 212 } 226 213 227 / //**228 //* Sets the minimum value which the receiver will allow229 //* to be the argument which must be greater than or230 //* equal to zero.231 //*232 //* @param value the new minimum (must be zero or greater)233 //*234 //* @exception SWTException <ul>235 //* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>236 //* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>237 //* </ul>238 //*/214 /** 215 * Sets the minimum value which the receiver will allow 216 * to be the argument which must be greater than or 217 * equal to zero. 218 * 219 * @param value the new minimum (must be zero or greater) 220 * 221 * @exception SWTException <ul> 222 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 223 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 224 * </ul> 225 */ 239 226 public void setMinimum (int value) { 240 227 checkWidget (); … … 244 231 } 245 232 246 / //**247 //* Sets the single <em>selection</em> that is the receiver's248 //* position to the argument which must be greater than or equal249 //* to zero.250 //*251 //* @param value the new selection (must be zero or greater)252 //*253 //* @exception SWTException <ul>254 //* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>255 //* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>256 //* </ul>257 //*/233 /** 234 * Sets the single <em>selection</em> that is the receiver's 235 * position to the argument which must be greater than or equal 236 * to zero. 237 * 238 * @param value the new selection (must be zero or greater) 239 * 240 * @exception SWTException <ul> 241 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 242 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 243 * </ul> 244 */ 258 245 public void setSelection (int value) { 259 246 checkWidget (); 260 247 if (value < 0) return; 261 position = value; 262 int percent = (value*(maxRange-minRange))/100; 263 OS.PrgSetPercentage(handle, (short)percent); 248 int pixels = OS.WinSendMsg(handle, OS.SLM_QUERYSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SHAFTDIMENSIONS, (short)OS.SMA_RANGEVALUE ), 0); 249 int totalPixels = OS.SHORT1FROMMP(pixels); 250 int pixelPos = ((value*totalPixels)/maxRange); 251 OS.WinSendMsg(handle, OS.SLM_SETSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SLIDERARMPOSITION, (short)OS.SMA_RANGEVALUE), pixelPos); 252 } 253 254 public void setSize (int width, int height) { 255 OS.WinSendMsg(handle, OS.SLM_SETSLIDERINFO, OS.MPFROM2SHORT((short)OS.SMA_SHAFTDIMENSIONS, (short)0), height); 256 super.setSize(width, height); 264 257 } 265 258 266 259 int widgetStyle () { 267 int bits = super.widgetStyle (); 268 // if ((style & SWT.SMOOTH) != 0) bits |= OS.PBS_SMOOTH; 269 // if ((style & SWT.VERTICAL) != 0) bits |= OS.PBS_VERTICAL; 270 return bits; 260 int bits = super.widgetStyle () | OS.SLS_CENTER | OS.WS_TABSTOP | OS.SLS_RIBBONSTRIP | OS.SLS_READONLY | OS.SLS_PRIMARYSCALE1 | OS.SLS_OWNERDRAW; 261 if ((style & SWT.HORIZONTAL) != 0) return bits | OS.SLS_HORIZONTAL | OS.SLS_HOMELEFT; 262 return bits | OS.SLS_VERTICAL | OS.SLS_HOMETOP; 271 263 } 272 264 273 265 PSZ windowClass () { 274 return null;266 return ProgressBarClass; 275 267 } 276 268 277 269 int windowProc () { 278 return 0; 279 } 280 // 281 //LRESULT WM_GETDLGCODE (int wParam, int lParam) { 282 // LRESULT result = super.WM_GETDLGCODE (wParam, lParam); 283 // if (result != null) return result; 284 // /* 285 // * Feature in Windows. The progress bar does 286 // * not implement WM_GETDLGCODE. As a result, 287 // * a progress bar takes focus and takes part 288 // * in tab traversal. This behavior, while 289 // * unspecified, is unwanted. The fix is to 290 // * implement WM_GETDLGCODE to behave like a 291 // * STATIC control. 292 // */ 293 // return new LRESULT (OS.DLGC_STATIC); 294 //} 295 296 } 270 return ProgressBarProc; 271 } 272 273 MRESULT wmDrawChild (int mp1, int mp2) { 274 OWNERITEM struct = new OWNERITEM(); 275 OS.objcpy(struct, mp2); 276 System.out.println("ProgressBar:WM_DRAWITEM"); 277 return null; 278 /* 279 switch(SHORT1FROMMP(mp1)){ 280 case SLD_VOLUME: 281 powner = (POWNERITEM) mp2; 282 switch(powner->idItem) 283 { 284 case SDA_RIBBONSTRIP: 285 sldmax = SHORT2FROMMR(WinSendDlgItemMsg (hwnd, SLD_VOLUME, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_RANGEVALUE), MPVOID)); 286 sldwidth = SHORT1FROMMR(WinSendDlgItemMsg (hwnd, SLD_VOLUME, SLM_QUERYSLIDERINFO, MPFROMSHORT(SMA_SLIDERARMDIMENSIONS), MPVOID)); 287 rectmax = powner->rclItem; 288 rectmax.xRight = rectmax.xLeft + sldmax; 289 rectg = recty = rectr = rectmax; 290 rectg.xRight = recty.xLeft = rectmax.xLeft + (sldmax * 4) / 5 + (sldwidth / 2); 291 rectr.xLeft = recty.xRight = rectmax.xLeft + (sldmax * 8) / 9 + (sldwidth / 2); 292 WinFillRect (powner->hps, &rectg, CLR_GREEN); 293 WinFillRect (powner->hps, &recty, CLR_YELLOW); 294 WinFillRect (powner->hps, &rectr, CLR_RED); 295 return ((MRESULT) TRUE); 296 } 297 } 298 299 break; */ 300 } 301 }
Note:
See TracChangeset
for help on using the changeset viewer.