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