Mercurial > projects > dwt-addons
comparison dwtx/ui/internal/forms/widgets/BusyIndicator.d @ 167:862b05e0334a
Add a wrapper for Thread
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 09 Sep 2008 15:59:16 +0200 |
parents | 7ffeace6c47f |
children |
comparison
equal
deleted
inserted
replaced
163:e5dd0081ccba | 167:862b05e0334a |
---|---|
33 | 33 |
34 import dwt.dwthelper.utils; | 34 import dwt.dwthelper.utils; |
35 import dwt.dwthelper.Runnable; | 35 import dwt.dwthelper.Runnable; |
36 | 36 |
37 import tango.util.Convert; | 37 import tango.util.Convert; |
38 import tango.core.Thread; | 38 import dwtx.dwtxhelper.JThread; |
39 | 39 |
40 public final class BusyIndicator : Canvas { | 40 public final class BusyIndicator : Canvas { |
41 | 41 |
42 alias Canvas.computeSize computeSize; | 42 alias Canvas.computeSize computeSize; |
43 | 43 |
44 class BusyThread : Thread { | 44 class BusyThread : JThread { |
45 Rectangle bounds; | 45 Rectangle bounds; |
46 Display display; | 46 Display display; |
47 GC offScreenImageGC; | 47 GC offScreenImageGC; |
48 Image offScreenImage; | 48 Image offScreenImage; |
49 Image timage; | 49 Image timage; |
54 this.display = display; | 54 this.display = display; |
55 this.offScreenImageGC = offScreenImageGC; | 55 this.offScreenImageGC = offScreenImageGC; |
56 this.offScreenImage = offScreenImage; | 56 this.offScreenImage = offScreenImage; |
57 } | 57 } |
58 | 58 |
59 public void run() { | 59 public override void run() { |
60 try { | 60 try { |
61 /* | 61 /* |
62 * Create an off-screen image to draw on, and fill it with | 62 * Create an off-screen image to draw on, and fill it with |
63 * the shell background. | 63 * the shell background. |
64 */ | 64 */ |
123 })); | 123 })); |
124 /* | 124 /* |
125 * Sleep for the specified delay time | 125 * Sleep for the specified delay time |
126 */ | 126 */ |
127 try { | 127 try { |
128 Thread.sleep(MILLISECONDS_OF_DELAY/1000.0); | 128 JThread.sleep(MILLISECONDS_OF_DELAY); |
129 } catch (InterruptedException e) { | 129 } catch (InterruptedException e) { |
130 ExceptionPrintStackTrace(e); | 130 ExceptionPrintStackTrace(e); |
131 } | 131 } |
132 | 132 |
133 | 133 |
219 Rectangle bounds = getImage(0).getBounds(); | 219 Rectangle bounds = getImage(0).getBounds(); |
220 Display display = getDisplay(); | 220 Display display = getDisplay(); |
221 Image offScreenImage = new Image(display, bounds.width, bounds.height); | 221 Image offScreenImage = new Image(display, bounds.width, bounds.height); |
222 GC offScreenImageGC = new GC(offScreenImage); | 222 GC offScreenImageGC = new GC(offScreenImage); |
223 busyThread = new BusyThread(bounds, display, offScreenImageGC, offScreenImage); | 223 busyThread = new BusyThread(bounds, display, offScreenImageGC, offScreenImage); |
224 busyThread.priority((Thread.PRIORITY_MIN + Thread.PRIORITY_MAX )/2 + 2); | 224 busyThread.setPriority(JThread.NORM_PRIORITY + 2); |
225 busyThread.isDaemon(true); | 225 busyThread.setDaemon(true); |
226 busyThread.start(); | 226 busyThread.start(); |
227 } | 227 } |
228 | 228 |
229 public void dispose() { | 229 public void dispose() { |
230 if (busyThread !is null) { | 230 if (busyThread !is null) { |