Mercurial > projects > dwt-win
annotate dwt/graphics/Resource.d @ 213:36f5cb12e1a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 17 May 2008 17:34:28 +0200 |
parents | f906dbcacee5 |
children | fd9c62a2998e |
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 /******************************************************************************* |
14 | 2 * Copyright (c) 2000, 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 | |
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 | |
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
|
37 * |
14 | 38 * @since 3.1 |
39 */ | |
40 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
|
41 |
14 | 42 /** |
43 * the device where this resource was created | |
44 */ | |
45 Device device; | |
46 | |
213 | 47 this() { |
48 } | |
49 | |
50 this(Device device) { | |
51 if (device is null) device = Device.getDevice(); | |
52 if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | |
53 this.device = device; | |
54 } | |
55 | |
56 void destroy() { | |
57 } | |
58 | |
14 | 59 /** |
60 * Disposes of the operating system resources associated with | |
61 * this resource. Applications must dispose of all resources | |
62 * which they allocate. | |
63 */ | |
213 | 64 public void dispose() { |
65 if (device is null) return; | |
66 if (device.isDisposed()) return; | |
67 destroy(); | |
68 if (device.tracking) device.dispose_Object(this); | |
69 device = null; | |
70 } | |
14 | 71 |
72 /** | |
73 * Returns the <code>Device</code> where this resource was | |
74 * created. | |
75 * | |
76 * @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
|
77 * |
14 | 78 * @since 3.2 |
79 */ | |
80 public Device getDevice() { | |
81 Device device = this.device; | |
82 if (device is null || isDisposed ()) DWT.error (DWT.ERROR_GRAPHIC_DISPOSED); | |
83 return device; | |
84 } | |
85 | |
213 | 86 void init_() { |
87 if (device.tracking) device.new_Object(this); | |
88 } | |
89 | |
14 | 90 /** |
91 * Returns <code>true</code> if the resource has been disposed, | |
92 * and <code>false</code> otherwise. | |
93 * <p> | |
94 * This method gets the dispose state for the resource. | |
95 * When a resource has been disposed, it is an error to | |
96 * invoke any other method using the resource. | |
97 * | |
98 * @return <code>true</code> when the resource is disposed and <code>false</code> otherwise | |
99 */ | |
100 public abstract bool isDisposed(); | |
101 | |
102 } |