Mercurial > projects > dwt-linux
annotate dwt/graphics/Resource.d @ 259:c0d810de7093
Update SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 29 Jun 2008 14:33:38 +0200 |
parents | ce446666f5a2 |
children |
rev | line source |
---|---|
72 | 1 /******************************************************************************* |
259 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
4 | 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 | |
72 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
4 | 12 *******************************************************************************/ |
10
63c023465156
moved from org.eclipse.swt to dwt
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
13 module dwt.graphics.Resource; |
4 | 14 |
71 | 15 import dwt.DWT; |
4 | 16 |
18 | 17 import dwt.graphics.Device; |
33
27324bbbac70
changed to regenerated BCD bindings
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
18 import dwt.internal.c.gdk; |
4 | 19 |
20 /** | |
21 * This class is the abstract superclass of all graphics resource objects. | |
22 * Resources created by the application must be disposed. | |
23 * <p> | |
24 * IMPORTANT: This class is intended to be subclassed <em>only</em> | |
71 | 25 * within the DWT implementation. However, it has not been marked |
26 * final to allow those outside of the DWT development team to implement | |
4 | 27 * patched versions of the class in order to get around specific |
28 * limitations in advance of when those limitations can be addressed | |
29 * by the team. Any class built using subclassing to access the internals | |
30 * of this class will likely fail to compile or run between releases and | |
31 * may be strongly platform specific. Subclassing should not be attempted | |
32 * without an intimate and detailed understanding of the workings of the | |
33 * hierarchy. No support is provided for user-written classes which are | |
34 * implemented as subclasses of this class. | |
35 * </p> | |
36 * | |
37 * @see #dispose | |
38 * @see #isDisposed | |
259 | 39 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
4 | 40 * |
41 * @since 3.1 | |
42 */ | |
43 public abstract class Resource { | |
44 | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
45 /** |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
46 * the device where this resource was created |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
47 */ |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
48 Device device; |
4 | 49 |
259 | 50 public this() { |
240 | 51 } |
52 | |
53 this(Device device) { | |
54 if (device is null) device = Device.getDevice(); | |
55 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
56 this.device = device; | |
57 } | |
58 | |
59 void destroy() { | |
60 } | |
61 | |
4 | 62 /** |
63 * Disposes of the operating system resources associated with | |
64 * this resource. Applications must dispose of all resources | |
65 * which they allocate. | |
66 */ | |
240 | 67 public void dispose() { |
68 if (device is null) return; | |
69 if (device.isDisposed()) return; | |
70 destroy(); | |
71 if (device.tracking) device.dispose_Object(this); | |
72 device = null; | |
73 } | |
4 | 74 |
75 /** | |
76 * Returns the <code>Device</code> where this resource was | |
77 * created. | |
78 * | |
79 * @return <code>Device</code> the device of the receiver | |
80 * | |
81 * @since 3.2 | |
82 */ | |
83 public Device getDevice() { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
84 Device device = this.device; |
71 | 85 if (device is null || isDisposed ()) DWT.error (DWT.ERROR_GRAPHIC_DISPOSED); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
33
diff
changeset
|
86 return device; |
4 | 87 } |
88 | |
240 | 89 void init_() { |
90 if (device.tracking) device.new_Object(this); | |
91 } | |
92 | |
4 | 93 /** |
94 * Returns <code>true</code> if the resource has been disposed, | |
95 * and <code>false</code> otherwise. | |
96 * <p> | |
97 * This method gets the dispose state for the resource. | |
98 * When a resource has been disposed, it is an error to | |
99 * invoke any other method using the resource. | |
100 * | |
101 * @return <code>true</code> when the resource is disposed and <code>false</code> otherwise | |
102 */ | |
103 public abstract bool isDisposed(); | |
104 | |
105 } |