Mercurial > projects > dwt-linux
annotate dwt/dnd/Transfer.d @ 255:5a30aa9820f3
removed tango.stdc.stringz imports and allow null for arrays and string arguments.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 15 Jun 2008 22:32:20 +0200 |
parents | 380bad9f6852 |
children | c0d810de7093 |
rev | line source |
---|---|
255
5a30aa9820f3
removed tango.stdc.stringz imports and allow null for arrays and string arguments.
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
1 /******************************************************************************* |
92 | 2 * Copyright (c) 2000, 2007 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 | |
108 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
92 | 12 *******************************************************************************/ |
13 module dwt.dnd.Transfer; | |
14 | |
238 | 15 import dwt.dwthelper.utils; |
16 | |
92 | 17 |
18 import dwt.internal.Converter; | |
19 import dwt.internal.gtk.OS; | |
20 import dwt.dnd.TransferData; | |
21 | |
22 | |
23 /** | |
24 * <code>Transfer</code> provides a mechanism for converting between a java | |
25 * representation of data and a platform specific representation of data and | |
26 * vice versa. It is used in data transfer operations such as drag and drop and | |
27 * clipboard copy/paste. | |
28 * | |
29 * <p>You should only need to become familiar with this class if you are | |
30 * implementing a Transfer subclass and you are unable to subclass the | |
31 * ByteArrayTransfer class.</p> | |
32 * | |
33 * @see ByteArrayTransfer | |
34 */ | |
35 public abstract class Transfer { | |
36 | |
37 /** | |
38 * Returns a list of the platform specific data types that can be converted using | |
39 * this transfer agent. | |
40 * | |
41 * <p>Only the data type fields of the <code>TransferData</code> objects are filled | |
42 * in.</p> | |
43 * | |
44 * @return a list of the data types that can be converted using this transfer agent | |
45 */ | |
46 abstract public TransferData[] getSupportedTypes(); | |
47 | |
48 /** | |
49 * Returns true if the <code>TransferData</code> data type can be converted | |
50 * using this transfer agent, or false otherwise (including if transferData is | |
51 * <code>null</code>). | |
52 * | |
53 * @param transferData a platform specific description of a data type; only the data | |
54 * type fields of the <code>TransferData</code> object need to be filled in | |
55 * | |
56 * @return true if the transferData data type can be converted using this transfer | |
57 * agent | |
58 */ | |
59 abstract public bool isSupportedType(TransferData transferData); | |
60 | |
61 /** | |
62 * Returns the platform specific names of the data types that can be converted | |
63 * using this transfer agent. | |
64 * | |
65 * @return the platform specific names of the data types that can be converted | |
66 * using this transfer agent. | |
67 */ | |
238 | 68 abstract public String[] getTypeNames(); |
92 | 69 |
70 /** | |
71 * Returns the platform specific ids of the data types that can be converted using | |
72 * this transfer agent. | |
73 * | |
74 * @return the platform specific ids of the data types that can be converted using | |
75 * this transfer agent | |
76 */ | |
77 abstract public int[] getTypeIds(); | |
78 | |
79 /** | |
80 * Converts a java representation of data to a platform specific representation of | |
81 * the data. | |
82 * | |
83 * <p>On a successful conversion, the transferData.result field will be set as follows: | |
84 * <ul> | |
85 * <li>Windows: COM.S_OK | |
86 * <li>Motif: 1 | |
87 * <li>GTK: 1 | |
88 * <li>Photon: 1 | |
89 * </ul></p> | |
90 * | |
91 * <p>If this transfer agent is unable to perform the conversion, the transferData.result | |
92 * field will be set to a failure value as follows: | |
93 * <ul> | |
94 * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL | |
95 * <li>Motif: 0 | |
96 * <li>GTK: 0 | |
97 * <li>Photon: 0 | |
98 * </ul></p> | |
99 * | |
100 * @param object a java representation of the data to be converted; the type of | |
101 * Object that is passed in is dependent on the <code>Transfer</code> subclass. | |
102 * | |
103 * @param transferData an empty TransferData object; this object will be | |
104 * filled in on return with the platform specific representation of the data | |
105 * | |
106 * @exception dwt.DWTException <ul> | |
107 * <li>ERROR_INVALID_DATA - if object does not contain data in a valid format or is <code>null</code></li> | |
108 * </ul> | |
109 */ | |
110 abstract public void javaToNative (Object object, TransferData transferData); | |
111 | |
112 /** | |
113 * Converts a platform specific representation of data to a java representation. | |
114 * | |
115 * @param transferData the platform specific representation of the data to be | |
116 * converted | |
117 * | |
118 * @return a java representation of the converted data if the conversion was | |
119 * successful; otherwise null. If transferData is <code>null</code> then | |
120 * <code>null</code> is returned. The type of Object that is returned is | |
121 * dependent on the <code>Transfer</code> subclass. | |
122 */ | |
123 abstract public Object nativeToJava(TransferData transferData); | |
124 | |
125 /** | |
126 * Registers a name for a data type and returns the associated unique identifier. | |
127 * | |
128 * <p>You may register the same type more than once, the same unique identifier | |
129 * will be returned if the type has been previously registered.</p> | |
130 * | |
131 * <p>Note: On windows, do <b>not</b> call this method with pre-defined | |
132 * Clipboard Format types such as CF_TEXT or CF_BITMAP because the | |
133 * pre-defined identifier will not be returned</p> | |
134 * | |
135 * @param formatName the name of a data type | |
136 * | |
137 * @return the unique identifier associated with this data type | |
138 */ | |
238 | 139 public static int registerType(String formatName){ |
92 | 140 if (formatName is null) return OS.GDK_NONE; |
255
5a30aa9820f3
removed tango.stdc.stringz imports and allow null for arrays and string arguments.
Frank Benoit <benoit@tionex.de>
parents:
238
diff
changeset
|
141 char* buffer = toStringz( formatName ); |
92 | 142 return cast(int)/*64*/OS.gdk_atom_intern(buffer, false); |
143 } | |
144 | |
145 /** | |
146 * Test that the object is of the correct format for this Transfer class. | |
147 * | |
148 * @param object a java representation of the data to be converted | |
149 * | |
150 * @return true if object is of the correct form for this transfer type | |
151 * | |
152 * @since 3.1 | |
153 */ | |
154 public bool validate(Object object) { | |
155 return true; | |
156 } | |
157 } |