Mercurial > projects > dwt-addons
annotate dwtx/jface/resource/DeviceResourceManager.d @ 43:ea8ff534f622
Fix override and super aliases
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 11 Apr 2008 01:24:25 +0200 |
parents | 6c14e54dfc11 |
children |
rev | line source |
---|---|
9 | 1 /******************************************************************************* |
2 * Copyright (c) 2004, 2006 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 module dwtx.jface.resource.DeviceResourceManager; | |
14 | |
15 import dwtx.jface.resource.AbstractResourceManager; | |
16 import dwtx.jface.resource.DeviceResourceDescriptor; | |
17 import dwtx.jface.resource.ImageDescriptor; | |
18 | |
19 import dwt.graphics.Device; | |
20 import dwt.graphics.Image; | |
21 | |
22 import dwt.dwthelper.utils; | |
23 | |
24 /** | |
25 * Manages DWT resources for a particular device. | |
26 * | |
27 * <p> | |
28 * IMPORTANT: in most cases clients should use a <code>LocalResourceManager</code> instead of a | |
29 * <code>DeviceResourceManager</code>. To create a resource manager on a particular display, | |
30 * use <code>new LocalResourceManager(JFaceResources.getResources(myDisplay))</code>. | |
31 * <code>DeviceResourceManager</code> should only be used directly when managing | |
32 * resources for a device other than a Display (such as a printer). | |
33 * </p> | |
34 * | |
35 * @see LocalResourceManager | |
36 * | |
37 * @since 3.1 | |
38 */ | |
39 public final class DeviceResourceManager : AbstractResourceManager { | |
40 | |
41 private Device device; | |
42 private Image missingImage; | |
43 | |
44 /* (non-Javadoc) | |
45 * @see dwtx.jface.resource.ResourceManager#getDevice() | |
46 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
47 public override Device getDevice() { |
9 | 48 return device; |
49 } | |
50 | |
51 /** | |
52 * Creates a new registry for the given device. | |
53 * | |
54 * @param device device to manage | |
55 */ | |
56 public this(Device device) { | |
57 this.device = device; | |
58 } | |
59 | |
60 /* (non-Javadoc) | |
61 * @see dwtx.jface.resource.AbstractResourceManager#allocate(dwtx.jface.resource.DeviceResourceDescriptor) | |
62 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
63 protected override Object allocate(DeviceResourceDescriptor descriptor){ |
9 | 64 return descriptor.createResource(device); |
65 } | |
66 | |
67 /* (non-Javadoc) | |
68 * @see dwtx.jface.resource.AbstractResourceManager#deallocate(java.lang.Object, dwtx.jface.resource.DeviceResourceDescriptor) | |
69 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
70 protected override void deallocate(Object resource, DeviceResourceDescriptor descriptor) { |
9 | 71 descriptor.destroyResource(resource); |
72 } | |
73 | |
74 /* (non-Javadoc) | |
75 * @see dwtx.jface.resource.ResourceManager#getDefaultImage() | |
76 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
77 protected override Image getDefaultImage() { |
9 | 78 if (missingImage is null) { |
79 missingImage = ImageDescriptor.getMissingImageDescriptor().createImage(); | |
80 } | |
81 return missingImage; | |
82 } | |
83 | |
84 /* (non-Javadoc) | |
85 * @see dwtx.jface.resource.AbstractResourceManager#dispose() | |
86 */ | |
43
ea8ff534f622
Fix override and super aliases
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
87 public override void dispose() { |
9 | 88 super.dispose(); |
89 if (missingImage !is null) { | |
90 missingImage.dispose(); | |
91 missingImage = null; | |
92 } | |
93 } | |
94 } |