Mercurial > projects > dwt-addons
comparison dwtx/draw2d/NativeGraphicsSource.d @ 98:95307ad235d9
Added Draw2d code, still work in progress
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 00:52:14 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
96:b492ba44e44d | 98:95307ad235d9 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2005 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 | |
14 module dwtx.draw2d.NativeGraphicsSource; | |
15 | |
16 import dwt.dwthelper.utils; | |
17 | |
18 | |
19 | |
20 import dwt.widgets.Control; | |
21 import dwtx.draw2d.geometry.Rectangle; | |
22 import dwtx.draw2d.GraphicsSource; | |
23 import dwtx.draw2d.Graphics; | |
24 | |
25 /** | |
26 * A graphics source that posts a paint request to the control rather than constructing GC | |
27 * on it directly. This allows the OS's native painting mechanism to be used directly, | |
28 * including any double-buffering that the OS may provide for free. | |
29 * @since 3.2 | |
30 */ | |
31 public final class NativeGraphicsSource : GraphicsSource { | |
32 | |
33 private final Control canvas; | |
34 | |
35 /** | |
36 * Constructs a new graphics source on the given control. | |
37 * @param canvas the control | |
38 * @since 3.2 | |
39 */ | |
40 public this(Control canvas) { | |
41 this.canvas = canvas; | |
42 } | |
43 | |
44 /** | |
45 * Always returns <code>null</code>, because | |
46 * @see GraphicsSource#getGraphics(Rectangle) | |
47 */ | |
48 public Graphics getGraphics(Rectangle r) { | |
49 canvas.redraw(r.x, r.y, r.width, r.height, false); | |
50 canvas.update(); | |
51 return null; | |
52 } | |
53 | |
54 /** | |
55 * Does nothing. | |
56 * @see GraphicsSource#flushGraphics(Rectangle) | |
57 */ | |
58 public void flushGraphics(Rectangle region) { } | |
59 | |
60 } |