Mercurial > projects > dwt-win
comparison dwt/widgets/ProgressBar.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | ab60f3309436 |
children | a8fed3e56433 |
comparison
equal
deleted
inserted
replaced
212:ab60f3309436 | 213:36f5cb12e1a2 |
---|---|
63 WNDCLASS lpWndClass; | 63 WNDCLASS lpWndClass; |
64 OS.GetClassInfo (null, ProgressBarClass.ptr, &lpWndClass); | 64 OS.GetClassInfo (null, ProgressBarClass.ptr, &lpWndClass); |
65 ProgressBarProc = lpWndClass.lpfnWndProc; | 65 ProgressBarProc = lpWndClass.lpfnWndProc; |
66 /* | 66 /* |
67 * Feature in Windows. The progress bar window class | 67 * Feature in Windows. The progress bar window class |
68 * does not include CS_DBLCLKS. This mean that these | 68 * does not include CS_DBLCLKS. This means that these |
69 * controls will not get double click messages such as | 69 * controls will not get double click messages such as |
70 * WM_LBUTTONDBLCLK. The fix is to register a new | 70 * WM_LBUTTONDBLCLK. The fix is to register a new |
71 * window class with CS_DBLCLKS. | 71 * window class with CS_DBLCLKS. |
72 * | 72 * |
73 * NOTE: Screen readers look for the exact class name | 73 * NOTE: Screen readers look for the exact class name |
208 public int getSelection () { | 208 public int getSelection () { |
209 checkWidget (); | 209 checkWidget (); |
210 return OS.SendMessage (handle, OS.PBM_GETPOS, 0, 0); | 210 return OS.SendMessage (handle, OS.PBM_GETPOS, 0, 0); |
211 } | 211 } |
212 | 212 |
213 /** | |
214 * Returns the state of the receiver. The value will be one of | |
215 * <code>NORMAL</code>, <code>ERROR</code> or <code>PAUSED</code>. | |
216 * | |
217 * @return the state | |
218 * | |
219 * @exception DWTException <ul> | |
220 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
221 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
222 * </ul> | |
223 * | |
224 * @since 3.4 | |
225 */ | |
226 public int getState () { | |
227 checkWidget (); | |
228 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { | |
229 int state = OS.SendMessage (handle, OS.PBM_GETSTATE, 0, 0); | |
230 switch (state) { | |
231 case OS.PBST_NORMAL: return DWT.NORMAL; | |
232 case OS.PBST_ERROR: return DWT.ERROR; | |
233 case OS.PBST_PAUSED: return DWT.PAUSED; | |
234 } | |
235 } | |
236 return DWT.NORMAL; | |
237 } | |
238 | |
213 override void releaseWidget () { | 239 override void releaseWidget () { |
214 super.releaseWidget (); | 240 super.releaseWidget (); |
215 stopTimer (); | 241 stopTimer (); |
216 } | 242 } |
217 | 243 |
301 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 327 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
302 * </ul> | 328 * </ul> |
303 */ | 329 */ |
304 public void setSelection (int value) { | 330 public void setSelection (int value) { |
305 checkWidget (); | 331 checkWidget (); |
332 /* | |
333 * Feature in Vista. When the progress bar is not in | |
334 * a normal state, PBM_SETPOS does not set the position. | |
335 * This is undocumented. The fix is to temporarily | |
336 * set the state to PBST_NORMAL, set the position, then | |
337 * reset the state. | |
338 */ | |
339 int /*long*/ state = 0; | |
340 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { | |
341 state = OS.SendMessage (handle, OS.PBM_GETSTATE, 0, 0); | |
342 OS.SendMessage (handle, OS.PBM_SETSTATE, OS.PBST_NORMAL, 0); | |
343 } | |
306 OS.SendMessage (handle, OS.PBM_SETPOS, value, 0); | 344 OS.SendMessage (handle, OS.PBM_SETPOS, value, 0); |
345 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { | |
346 OS.SendMessage (handle, OS.PBM_SETSTATE, state, 0); | |
347 } | |
348 } | |
349 | |
350 /** | |
351 * Sets the state of the receiver. The state is be one of | |
352 * <code>NORMAL</code>, <code>ERROR</code> or <code>PAUSED</code>. | |
353 * | |
354 * @param state the new state | |
355 * | |
356 * @exception DWTException <ul> | |
357 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
358 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
359 * </ul> | |
360 * | |
361 * @since 3.4 | |
362 */ | |
363 public void setState (int state) { | |
364 checkWidget (); | |
365 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { | |
366 switch (state) { | |
367 case DWT.NORMAL: | |
368 OS.SendMessage (handle, OS.PBM_SETSTATE, OS.PBST_NORMAL, 0); | |
369 break; | |
370 case DWT.ERROR: | |
371 OS.SendMessage (handle, OS.PBM_SETSTATE, OS.PBST_ERROR, 0); | |
372 break; | |
373 case DWT.PAUSED: | |
374 OS.SendMessage (handle, OS.PBM_SETSTATE, OS.PBST_PAUSED, 0); | |
375 break; | |
376 } | |
377 } | |
307 } | 378 } |
308 | 379 |
309 override int widgetStyle () { | 380 override int widgetStyle () { |
310 int bits = super.widgetStyle (); | 381 int bits = super.widgetStyle (); |
311 if ((style & DWT.SMOOTH) !is 0) bits |= OS.PBS_SMOOTH; | 382 if ((style & DWT.SMOOTH) !is 0) bits |= OS.PBS_SMOOTH; |