summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine <veronika>2002-12-09 22:32:02 +0000
committerVeronika Irvine <veronika>2002-12-09 22:32:02 +0000
commit8679abb53a4e9116bc631da1b133f656409bc71d (patch)
tree25b497bc073a88a7ede2bfe8e18492cc01aa86c5
parentb98fb531680b1395ad559e743a6390137c985495 (diff)
downloadeclipse.platform.swt-8679abb53a4e9116bc631da1b133f656409bc71d.tar.gz
eclipse.platform.swt-8679abb53a4e9116bc631da1b133f656409bc71d.tar.xz
eclipse.platform.swt-8679abb53a4e9116bc631da1b133f656409bc71d.zip
*** empty log message ***
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/ByteArrayTransfer.java49
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/Clipboard.java123
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/DragSource.java258
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/DropTarget.java245
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/FileTransfer.java116
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/RTFTransfer.java86
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TableDragUnderEffect.java54
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TextTransfer.java89
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/Transfer.java127
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TransferData.java47
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TreeDragUnderEffect.java94
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DND.java229
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DNDEvent.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DNDListener.java80
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceAdapter.java37
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceEvent.java66
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceListener.java76
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragUnderEffect.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetAdapter.java63
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetEvent.java108
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetListener.java246
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/NoDragUnderEffect.java16
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/package.html15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c32
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java42
27 files changed, 2322 insertions, 21 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/ByteArrayTransfer.java
new file mode 100644
index 0000000000..a87f6ce595
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -0,0 +1,49 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public abstract class ByteArrayTransfer extends Transfer {
+
+public TransferData[] getSupportedTypes() {
+ int[] types= getTypeIds();
+ TransferData[] data= new TransferData[types.length];
+ for (int i= 0; i < types.length; i++) {
+ data[i]= new TransferData();
+ data[i].type= types[i];
+ }
+ return data;
+}
+
+public boolean isSupportedType(TransferData transferData){
+ if (transferData == null) return false;
+ int[] types= getTypeIds();
+ for (int i= 0; i < types.length; i++) {
+ if (transferData.type == types[i])
+ return true;
+ }
+ return false;
+}
+
+protected void javaToNative (Object object, TransferData transferData) {
+ if ((object == null) || !(object instanceof byte[]) || !(isSupportedType(transferData))) {
+ transferData.result = -1;
+ return;
+ }
+ byte[] orig = (byte[])object;
+ byte[] buffer= new byte[orig.length];
+ System.arraycopy(orig, 0, buffer, 0, orig.length);
+ transferData.data = buffer;
+ transferData.result = 0;
+}
+
+protected Object nativeToJava(TransferData transferData) {
+ if (!isSupportedType(transferData)) return null;
+ return transferData.data;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/Clipboard.java
new file mode 100644
index 0000000000..8b554d54ae
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/Clipboard.java
@@ -0,0 +1,123 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.carbon.OS;
+import org.eclipse.swt.internal.carbon.CFRange;
+
+public class Clipboard {
+
+ private Display display;
+
+public Clipboard(Display display) {
+ checkSubclass ();
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ }
+ if (display.getThread() != Thread.currentThread()) {
+ SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.display = display;
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+public void dispose () {
+ display = null;
+}
+
+public Object getContents(Transfer transfer) {
+ if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED);
+ if (transfer == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
+
+ int[] scrapHandle = new int[1];
+ OS.GetCurrentScrap(scrapHandle);
+ int scrap= scrapHandle[0];
+
+ // Does Clipboard have data in required format?
+ int[] typeIds = transfer.getTypeIds();
+ for (int i= 0; i < typeIds.length; i++) {
+ int type = typeIds[i];
+ int[] size = new int[1];
+ if (OS.GetScrapFlavorSize(scrap, type, size) == OS.noErr) {
+ if (size[0] > 0) {
+ TransferData tdata = new TransferData();
+ tdata.type = type;
+ tdata.data = new byte[size[0]];
+ OS.GetScrapFlavorData(scrap, type, size, tdata.data);
+ return transfer.nativeToJava(tdata);
+ }
+ }
+ }
+ return null; // No data available for this transfer
+}
+
+public void setContents(Object[] data, Transfer[] dataTypes) {
+ if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED);
+ if (data == null || dataTypes == null || data.length != dataTypes.length) {
+ DND.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ OS.ClearCurrentScrap();
+ int[] scrapHandle = new int[1];
+ OS.GetCurrentScrap(scrapHandle);
+ int scrap = scrapHandle[0];
+ // copy data directly over to System clipboard (not deferred)
+ for (int i= 0; i < dataTypes.length; i++) {
+ int[] ids = dataTypes[i].getTypeIds();
+ for (int j= 0; j < ids.length; j++) {
+ TransferData transferData = new TransferData();
+ transferData.type = ids[j];
+ dataTypes[i].javaToNative(data[i], transferData);
+ if (transferData.result != OS.noErr)
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ if (OS.PutScrapFlavor(scrap, transferData.type, 0, transferData.data.length, transferData.data) != OS.noErr){
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ }
+ }
+ }
+}
+
+public String[] getAvailableTypeNames() {
+ if (display == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ if (display.isDisposed()) DND.error(SWT.ERROR_DEVICE_DISPOSED);
+
+ int[] scrapHandle = new int[1];
+ OS.GetCurrentScrap(scrapHandle);
+ int scrap = scrapHandle[0];
+ int[] count = new int[1];
+ OS.GetScrapFlavorCount(scrap, count);
+ if (count [0] == 0) return new String [0];
+ int[] info = new int[count[0] * 2];
+ OS.GetScrapFlavorInfoList(scrap, count, info);
+ String[] result = new String[count[0]];
+ for (int i= 0; i < count [0]; i++) {
+ int type = info[i*2];
+ StringBuffer sb = new StringBuffer();
+ sb.append((char)((type & 0xff000000) >> 24));
+ sb.append((char)((type & 0x00ff0000) >> 16));
+ sb.append((char)((type & 0x0000ff00) >> 8));
+ sb.append((char)((type & 0x000000ff) >> 0));
+ result[i] = sb.toString();
+ }
+ return result;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/DragSource.java
new file mode 100644
index 0000000000..d84579c58e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/DragSource.java
@@ -0,0 +1,258 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+
+/**
+ *
+ * <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * <p>IMPORTANT: This class is <em>not</em> intended to be subclassed.</p>
+ *
+ * <p>A drag source is the object which originates a drag and drop operation. For the specified widget,
+ * it defines the type of data that is available for dragging and the set of operations that can
+ * be performed on that data. The operations can be any bit-wise combination of DND.MOVE, DND.COPY or
+ * DND.LINK. The type of data that can be transferred is specified by subclasses of Transfer such as
+ * TextTransfer or FileTransfer. The type of data transferred can be a predefined system type or it
+ * can be a type defined by the application. For instructions on how to define your own transfer type,
+ * refer to <code>ByteArrayTransfer</code>.</p>
+ *
+ * <p>You may have several DragSources in an application but you can only have one DragSource
+ * per Control. Data dragged from this DragSource can be dropped on a site within this application
+ * or it can be dropped on another application such as an external Text editor.</p>
+ *
+ * <p>The application supplies the content of the data being transferred by implementing the
+ * <code>DragSourceListener</code> and associating it with the DragSource via DragSource#addDragListener.</p>
+ *
+ * <p>When a successful move operation occurs, the application is required to take the appropriate
+ * action to remove the data from its display and remove any associated operating system resources or
+ * internal references. Typically in a move operation, the drop target makes a copy of the data
+ * and the drag source deletes the original. However, sometimes copying the data can take a long
+ * time (such as copying a large file). Therefore, on some platforms, the drop target may actually
+ * move the data in the operating system rather than make a copy. This is usually only done in
+ * file transfers. In this case, the drag source is informed in the DragEnd event that a
+ * DROP_TARGET_MOVE was performed. It is the responsibility of the drag source at this point to clean
+ * up its displayed information. No action needs to be taken on the operating system resources.</p>
+ *
+ * <p> The following example shows a Label widget that allows text to be dragged from it.</p>
+ *
+ * <code><pre>
+ * // Enable a label as a Drag Source
+ * Label label = new Label(shell, SWT.NONE);
+ * // This example will allow text to be dragged
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * // This example will allow the text to be copied or moved to the drop target
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY;
+ *
+ * DragSource source = new DragSource (label, operations);
+ * source.setTransfer(types);
+ * source.addDragListener (new DragSourceListener() {
+ * public void dragStart(DragSourceEvent e) {
+ * // Only start the drag if there is actually text in the
+ * // label - this text will be what is dropped on the target.
+ * if (label.getText().length() == 0) {
+ * event.doit = false;
+ * }
+ * };
+ * public void dragSetData (DragSourceEvent event) {
+ * // A drop has been performed, so provide the data of the
+ * // requested type.
+ * // (Checking the type of the requested data is only
+ * // necessary if the drag source supports more than
+ * // one data type but is shown here as an example).
+ * if (TextTransfer.getInstance().isSupportedType(event.dataType)){
+ * event.data = label.getText();
+ * }
+ * }
+ * public void dragFinished(DragSourceEvent event) {
+ * // A Move operation has been performed so remove the data
+ * // from the source
+ * if (event.detail == DND.DROP_MOVE)
+ * label.setText("");
+ * }
+ * });
+ * </pre></code>
+ *
+ *
+ * <dl>
+ * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ * <dt><b>Events</b></dt> <dd>DND.DragStart, DND.DragSetData, DND.DragEnd</dd>
+ * </dl>
+ */
+public final class DragSource extends Widget {
+
+ // info for registering as a drag source
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ private static final String DRAGSOURCEID = "DragSource";
+
+/**
+ * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
+ * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
+ * It is therefore mandatory that the DragSource instance be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> that the user clicks on to initiate the drag
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see DragSource#dispose
+ * @see DragSource#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ */
+public DragSource(Control control, int style) {
+ super (control, style);
+ this.control = control;
+ if (control.getData(DRAGSOURCEID) != null)
+ DND.error(DND.ERROR_CANNOT_INIT_DRAG);
+
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ if (event.type == SWT.Dispose){
+ DragSource.this.dispose();
+ }
+ }
+ };
+ control.addListener (SWT.Dispose, controlListener);
+
+ this.addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event e) {
+ onDispose();
+ }
+ });
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DragSourceListener</code>
+ * interface.
+ *
+ * <p><ul>
+ * <li><code>dragStart</code> is called when the user has begun the actions required to drag the widget.
+ * This event gives the application the chance to decide if a drag should be started.
+ * <li><code>dragSetData</code> is called when the data is required from the drag source.
+ * <li><code>dragFinished</code> is called when the drop has successfully completed (mouse up
+ * over a valid target) or has been terminated (such as hitting the ESC key). Perform cleanup
+ * such as removing data from the source side on a successful move operation.
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #removeDragListener
+ * @see DragSourceEvent
+ */
+public void addDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragStart, typedListener);
+ addListener (DND.DragEnd, typedListener);
+ addListener (DND.DragSetData, typedListener);
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DragSource.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+/**
+ * Returns the Control which is registered for this DragSource. This is the control that the
+ * user clicks in to initiate dragging.
+ *
+ * @return the Control which is registered for this DragSource
+ */
+public Control getControl () {
+ return control;
+}
+
+public Display getDisplay () {
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+/**
+ * Returns the list of data types that can be transferred by this DragSource.
+ *
+ * @return the list of data types that can be transferred by this DragSource
+ */
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+
+private void onDispose () {
+ if (control != null && controlListener != null){
+ control.removeListener(SWT.Dispose, controlListener);
+ control.removeListener(SWT.DragDetect, controlListener);
+ }
+ controlListener = null;
+ control.setData(DRAGSOURCEID, null);
+ control = null;
+
+ transferAgents = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DragSourceListener
+ * @see #addDragListener
+ */
+public void removeDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragStart, listener);
+ removeListener (DND.DragEnd, listener);
+ removeListener (DND.DragSetData, listener);
+}
+
+/**
+ * Specifies the list of data types that can be transferred by this DragSource.
+ * The application must be able to provide data to match each of these types when
+ * a successful drop has occurred.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dragged from this source
+ */
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/DropTarget.java
new file mode 100644
index 0000000000..d4d1f066e8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/DropTarget.java
@@ -0,0 +1,245 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+
+/**
+ *
+ * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class identifies the <code>Control</code> over which the user must position the cursor
+ * in order to drop the data being transferred. It also specifies what data types can be dropped on
+ * this control and what operations can be performed. You may have several DropTragets in an
+ * application but there can only be a one to one mapping between a <code>Control</code> and a <code>DropTarget</code>.
+ * The DropTarget can receive data from within the same application or from other applications
+ * (such as text dragged from a text editor like Word).</p>
+ *
+ * <code><pre>
+ * int operations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ * Transfer[] types = new Transfer[] {TextTransfer.getInstance()};
+ * DropTarget target = new DropTarget(label, operations);
+ * target.setTransfer(types);
+ * </code></pre>
+ *
+ * <p>The application is notified of data being dragged over this control and of when a drop occurs by
+ * implementing the interface <code>DropTargetListener</code> which uses the class
+ * <code>DropTargetEvent</code>. The application can modify the type of drag being performed
+ * on this Control at any stage of the drag by modifying the <code>event.detail</code> field or the
+ * <code>event.currentDataType</code> field. When the data is dropped, it is the responsibility of
+ * the application to copy this data for its own purposes.
+ *
+ * <code><pre>
+ * target.addDropListener (new DropTargetListener() {
+ * public void dragEnter(DropTargetEvent event) {};
+ * public void dragOver(DropTargetEvent event) {};
+ * public void dragLeave(DropTargetEvent event) {};
+ * public void dragOperationChanged(DropTargetEvent event) {};
+ * public void dropAccept(DropTargetEvent event) {}
+ * public void drop(DropTargetEvent event) {
+ * // A drop has occurred, copy over the data
+ * if (event.data == null) { // no data to copy, indicate failure in event.detail
+ * event.detail = DND.DROP_NONE;
+ * return;
+ * }
+ * label.setText ((String) event.data); // data copied to label text
+ * }
+ * });
+ * </pre></code>
+ *
+ * <dl>
+ * <dt><b>Styles</b></dt> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK</dd>
+ * <dt><b>Events</b></dt> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
+ * DND.DropAccept, DND.Drop </dd>
+ * </dl>
+ */
+public final class DropTarget extends Widget {
+
+ // info for registering as a droptarget
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ private static final String DROPTARGETID = "DropTarget";
+
+/**
+ * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
+ * <code>Control</code>.
+ * Creating an instance of a DropTarget may cause system resources to be allocated
+ * depending on the platform. It is therefore mandatory that the DropTarget instance
+ * be disposed when no longer required.
+ *
+ * @param control the <code>Control</code> over which the user positions the cursor to drop the data
+ * @param style the bitwise OR'ing of allowed operations; this may be a combination of any of
+ * DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ *
+ * @see DropTarget#dispose
+ * @see DropTarget#checkSubclass
+ * @see DND#DROP_NONE
+ * @see DND#DROP_COPY
+ * @see DND#DROP_MOVE
+ * @see DND#DROP_LINK
+ */
+public DropTarget(Control control, int style) {
+ super(control, style);
+ this.control = control;
+ if (control.getData(DROPTARGETID) != null)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP);
+ control.setData(DROPTARGETID, this);
+
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ DropTarget.this.dispose();
+ }
+ };
+
+ control.addListener (SWT.Dispose, controlListener);
+
+ this.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+ onDispose();
+ }
+ });
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when a drag and drop operation is in progress, by sending
+ * it one of the messages defined in the <code>DropTargetListener</code>
+ * interface.
+ *
+ * <p><ul>
+ * <li><code>dragEnter</code> is called when the cursor has entered the drop target boundaries
+ * <li><code>dragLeave</code> is called when the cursor has left the drop target boundaries and just before
+ * the drop occurs or is cancelled.
+ * <li><code>dragOperationChanged</code> is called when the operation being performed has changed
+ * (usually due to the user changing the selected modifier key(s) while dragging)
+ * <li><code>dragOver</code> is called when the cursor is moving over the drop target
+ * <li><code>dropAccept</code> is called just before the drop is performed. The drop target is given
+ * the chance to change the nature of the drop or veto the drop by setting the <code>event.detail</code> field
+ * <li><code>drop</code> is called when the data is being dropped
+ * </ul></p>
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #removeDropListener
+ * @see DropTargetEvent
+ */
+public void addDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragEnter, typedListener);
+ addListener (DND.DragLeave, typedListener);
+ addListener (DND.DragOver, typedListener);
+ addListener (DND.DragOperationChanged, typedListener);
+ addListener (DND.Drop, typedListener);
+ addListener (DND.DropAccept, typedListener);
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+/**
+ * Returns the Control which is registered for this DropTarget. This is the control over which the
+ * user positions the cursor to drop the data.
+ *
+ * @return the Control which is registered for this DropTarget
+ */
+public Control getControl () {
+ return control;
+}
+
+public Display getDisplay () {
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+
+/**
+ * Returns a list of the data types that can be transferred to this DropTarget.
+ *
+ * @return a list of the data types that can be transferred to this DropTarget
+ */
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+
+private void onDispose () {
+ if (control == null) return;
+
+ if (controlListener != null)
+ control.removeListener(SWT.Dispose, controlListener);
+ controlListener = null;
+ control.setData(DROPTARGETID, null);
+ transferAgents = null;
+ control = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when a drag and drop operation is in progress.
+ *
+ * @param listener the listener which should be notified
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see DropTargetListener
+ * @see #addDropListener
+ */
+public void removeDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragEnter, listener);
+ removeListener (DND.DragLeave, listener);
+ removeListener (DND.DragOver, listener);
+ removeListener (DND.DragOperationChanged, listener);
+ removeListener (DND.Drop, listener);
+ removeListener (DND.DropAccept, listener);
+}
+
+/**
+ * Specifies the data types that can be transferred to this DropTarget. If data is
+ * being dragged that does not match one of these types, the drop target will be notified of
+ * the drag and drop operation but the currentDataType will be null and the operation
+ * will be DND.NONE.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dropped on this target
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if transferAgents is null</li>
+ * </ul>
+ */
+public void setTransfer(Transfer[] transferAgents){
+ if (transferAgents == null) DND.error(SWT.ERROR_NULL_ARGUMENT);
+ this.transferAgents = transferAgents;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/FileTransfer.java
new file mode 100644
index 0000000000..4754874a98
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/FileTransfer.java
@@ -0,0 +1,116 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.Converter;
+
+/**
+ * The class <code>FileTransfer</code> provides a platform specific mechanism
+ * for converting a list of files represented as a java <code>String[]</code> to a
+ * platform specific representation of the data and vice versa.
+ * Each <code>String</code> in the array contains the absolute path for a single
+ * file or directory.
+ * See <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String[]</code> containing a list of files is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * File file1 = new File("C:\temp\file1");
+ * File file2 = new File("C:\temp\file2");
+ * String[] fileData = new String[2];
+ * fileData[0] = file1.getAbsolutePath();
+ * fileData[1] = file2.getAbsolutePath();
+ * </code></pre>
+ */
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "text/uri-list";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+/**
+ * Returns the singleton instance of the FileTransfer class.
+ *
+ * @return the singleton instance of the FileTransfer class
+ */
+public static FileTransfer getInstance () {
+ return _instance;
+}
+/**
+ * This implementation of <code>javaToNative</code> converts a list of file names
+ * represented by a java <code>String[]</code> to a platform specific representation.
+ * Each <code>String</code> in the array contains the absolute path for a single
+ * file or directory. For additional information see
+ * <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String[]</code> containing the file names to be
+ * converted
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
+ */
+public void javaToNative(Object object, TransferData transferData) {
+ if (object == null || !(object instanceof String[])) return;
+ // build a byte array from data
+ String[] files = (String[])object;
+
+ // create a string separated by "new lines" to represent list of files
+ String nativeFormat = "";
+ for (int i = 0, length = files.length; i < length; i++){
+ nativeFormat += "file:"+files[i]+"\r";
+ }
+ byte[] buffer = Converter.wcsToMbcs(null, nativeFormat, true);
+ // pass byte array on to super to convert to native
+ super.javaToNative(buffer, transferData);
+}
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of a list of file names to a java <code>String[]</code>.
+ * Each String in the array contains the absolute path for a single file or directory.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String[]</code> containing a list of file names if the
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ char[] unicode = Converter.mbcsToWcs(null, data);
+ String string = new String(unicode);
+ // parse data and convert string to array of files
+ int start = string.indexOf("file:");
+ if (start == -1) return null;
+ start += 5;
+ String[] fileNames = new String[0];
+ while (start < string.length()) {
+ int end = string.indexOf("\r", start);
+ if (end == -1) end = string.length() - 1;
+ String fileName = string.substring(start, end);
+
+ String[] newFileNames = new String[fileNames.length + 1];
+ System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
+ newFileNames[fileNames.length] = fileName;
+ fileNames = newFileNames;
+
+ start = string.indexOf("file:", end);
+ if (start == -1) break;
+ start += 5;
+ }
+ return fileNames;
+}
+protected String[] getTypeNames(){
+ return new String[] { TYPENAME };
+}
+protected int[] getTypeIds(){
+ return new int[] { TYPEID };
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/RTFTransfer.java
new file mode 100644
index 0000000000..54f84a437f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/RTFTransfer.java
@@ -0,0 +1,86 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+ import org.eclipse.swt.internal.Converter;
+
+/**
+ * The class <code>RTFTransfer</code> provides a platform specific mechanism
+ * for converting text in RTF format represented as a java <code>String</code>
+ * to a platform specific representation of the data and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String</code> containing RTF text is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * String rtfData = "{\\rtf1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i Hello World}";
+ * </code></pre>
+ */
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME1 = "RTF";
+ private static final int TYPEID1 = ('R'<<24) + ('T'<<16) + ('F'<<8) + ' ';
+
+private RTFTransfer() {
+}
+
+/**
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
+ */
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts RTF-formatted text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String</code> containing RTF text
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
+ */
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+ byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
+ super.javaToNative(buffer, transferData);
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of RTF text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String</code> containing RTF text if the
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ String string = new String (unicode);
+ int end = string.indexOf('\0');
+ return (end == -1) ? string : string.substring(0, end);
+}
+
+protected String[] getTypeNames() {
+ return new String[]{ TYPENAME1 };
+}
+
+protected int[] getTypeIds() {
+ return new int[] { TYPEID1 };
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TableDragUnderEffect.java
new file mode 100644
index 0000000000..e6e21b9ed7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TableDragUnderEffect.java
@@ -0,0 +1,54 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem currentItem;
+ private TableItem[] selection = new TableItem[0];
+ private int currentEffect = DND.FEEDBACK_NONE;
+
+TableDragUnderEffect(Table table) {
+ this.table = table;
+}
+void show(int effect, int x, int y) {
+ TableItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = table.getSelection();
+ table.setSelection(new TableItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ table.setSelection(selection);
+ selection = new TableItem[0];
+ }
+}
+private TableItem findItem(int x, int y){
+ if (table == null) return null;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ return table.getItem(coordinates);
+}
+private void setDragUnderEffect(int effect, TableItem item) {
+ if (currentItem != item) {
+ if (item == null) {
+ table.setSelection(new TableItem[0]);
+ } else {
+ table.setSelection(new TableItem[] {item});
+ }
+ currentItem = item;
+ }
+ currentEffect = effect;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TextTransfer.java
new file mode 100644
index 0000000000..2249eb2df9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TextTransfer.java
@@ -0,0 +1,89 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.carbon.OS;
+
+/**
+ * The class <code>TextTransfer</code> provides a platform specific mechanism
+ * for converting plain text represented as a java <code>String</code>
+ * to a platform specific representation of the data and vice versa. See
+ * <code>Transfer</code> for additional information.
+ *
+ * <p>An example of a java <code>String</code> containing plain text is shown
+ * below:</p>
+ *
+ * <code><pre>
+ * String textData = "Hello World";
+ * </code></pre>
+ */
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME1 = "TEXT";
+ private static final int TYPEID1 = OS.kScrapFlavorTypeText;
+
+private TextTransfer() {
+}
+/**
+ * Returns the singleton instance of the TextTransfer class.
+ *
+ * @return the singleton instance of the TextTransfer class
+ */
+public static TextTransfer getInstance () {
+ return _instance;
+}
+
+/**
+ * This implementation of <code>javaToNative</code> converts plain text
+ * represented by a java <code>String</code> to a platform specific representation.
+ * For additional information see <code>Transfer#javaToNative</code>.
+ *
+ * @param object a java <code>String</code> containing text
+ * @param transferData an empty <code>TransferData</code> object; this
+ * object will be filled in on return with the platform specific format of the data
+ */
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) {
+ transferData.result = -1;
+ return;
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, (String)object, true);
+ super.javaToNative(buffer, transferData);
+}
+
+/**
+ * This implementation of <code>nativeToJava</code> converts a platform specific
+ * representation of plain text to a java <code>String</code>.
+ * For additional information see <code>Transfer#nativeToJava</code>.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * been converted
+ * @return a java <code>String</code> containing text if the
+ * conversion was successful; otherwise null
+ */
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ String string = new String (unicode);
+ int end = string.indexOf('\0');
+ return (end == -1) ? string : string.substring(0, end);
+}
+
+protected String[] getTypeNames() {
+ return new String[] { TYPENAME1 };
+}
+
+protected int[] getTypeIds() {
+ return new int[] { TYPEID1 };
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/Transfer.java
new file mode 100644
index 0000000000..77d0460804
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/Transfer.java
@@ -0,0 +1,127 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * <code>Transfer</code> provides a mechanism for converting between a java
+ * representation of data and a platform specific representation of data and
+ * vice versa. It is used in data transfer operations such as drag and drop and
+ * clipboard copy/paste.
+ *
+ * <p>You should only need to become familiar with this class if you are
+ * implementing a Transfer subclass and you are unable to subclass the
+ * ByteArrayTransfer class.</p>
+ *
+ * @see ByteArrayTransfer
+ */
+public abstract class Transfer {
+
+/**
+ * Returns a list of the platform specific data types that can be converted using
+ * this transfer agent.
+ *
+ * <p>Only the data type fields of the <code>TransferData</code> objects are filled
+ * in.</p>
+ *
+ * @return a list of the data types that can be converted using this transfer agent
+ */
+abstract public TransferData[] getSupportedTypes();
+/**
+ * Returns true if the <code>TransferData</code> data type can be converted
+ * using this transfer agent.
+ *
+ * @param transferData a platform specific description of a data type; only the data
+ * type fields of the <code>TransferData</code> object need to be filled in
+ *
+ * @return true if the transferData data type can be converted using this transfer
+ * agent
+ */
+abstract public boolean isSupportedType(TransferData transferData);
+
+/**
+ * Returns the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ *
+ * @return the platform specfic names of the data types that can be converted
+ * using this transfer agent.
+ */
+abstract protected String[] getTypeNames();
+
+/**
+ * Returns the platform specfic ids of the data types that can be converted using
+ * this transfer agent.
+ *
+ * @return the platform specfic ids of the data types that can be converted using
+ * this transfer agent
+ */
+abstract protected int[] getTypeIds();
+
+/**
+ * Converts a java representation of data to a platform specific representation of
+ * the data.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set as follows:
+ * <ul>
+ * <li>Windows: COM.S_OK
+ * <li>Motif: 1
+ * <li>GTK: 1
+ * <li>Photon: 1
+ * </ul></p>
+ *
+ * <p>If this transfer agent is unable to perform the conversion, the transferData.result
+ * field will be set to a failure value as follows:
+ * <ul>
+ * <li>Windows: COM.DV_E_TYMED or COM.E_FAIL
+ * <li>Motif: 0
+ * <li>GTK: 0
+ * <li>Photon: 0
+ * </ul></p>
+ *
+ * @param object a java representation of the data to be converted; the type of
+ * Object that is passed in is dependant on the <code>Transfer</code> subclass.
+ *
+ * @param transferData an empty TransferData object; this object will be
+ * filled in on return with the platform specific representation of the data
+ */
+abstract protected void javaToNative (Object object, TransferData transferData);
+
+/**
+ * Converts a platform specific representation of data to a java representation.
+ *
+ * @param transferData the platform specific representation of the data to be
+ * converted
+ *
+ * @return a java representation of the converted data if the conversion was
+ * successful; otherwise null. The type of Object that is returned is dependant
+ * on the <code>Transfer</code> subclass
+ */
+abstract protected Object nativeToJava(TransferData transferData);
+
+/**
+ * Registers a name for a data type and returns the associated unique identifier.
+ *
+ * <p>You may register the same type more than once, the same unique identifier
+ * will be returned if the type has been previously registered.</p>
+ *
+ * <p>Note: On windows, do <b>not</b> call this method with pre-defined
+ * Clipboard Format types such as CF_TEXT or CF_BITMAP because the
+ * pre-defined identifier will not be returned</p>
+ *
+ * @param formatName the name of a data type
+ *
+ * @return the unique identifier associated with htis data type
+ */
+public static int registerType(String formatName) {
+ // System.out.println("Transfer.registerType: " + formatName);
+ // AW: FIXME: hashCode may not be not unique!
+ return formatName.hashCode();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TransferData.java
new file mode 100644
index 0000000000..d3ed77977d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TransferData.java
@@ -0,0 +1,47 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * The <code>TransferData</code> class is a platform specific data structure for
+ * describing the type and the contents of data being converted by a transfer agent.
+ *
+ * <p>As an application writer, you do not need to know the specifics of
+ * TransferData. TransferData instances are passed to a subclass of Transfer
+ * and the Transfer object manages the platform specific issues.
+ * You can ask a Transfer subclass if it can handle this data by calling
+ * Transfer.isSupportedType(transferData).</p>
+ *
+ * <p>You should only need to become familiar with the fields in this class if you
+ * are implementing a Transfer subclass and you are unable to subclass the
+ * ByteArrayTransfer class.</p>
+ */
+public class TransferData {
+ /**
+ * The type is a unique identifier of a system format or user defined format.
+ * (Warning: This field is platform dependent)
+ */
+ public int type;
+
+ /**
+ * The data being transferred.
+ * (Warning: This field is platform dependent)
+ */
+ public byte[] data;
+
+ /**
+ * The result field contains the result of converting a java data type
+ * into a platform specific value.
+ * (Warning: This field is platform dependent)
+ *
+ * <p>The value of result is if the conversion was successfully. The value of
+ * result is an error code if the conversion failed.</p>
+ */
+ public int result;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
new file mode 100644
index 0000000000..d31b5abc26
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/carbon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
@@ -0,0 +1,94 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private TreeItem currentItem = null;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ TreeItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.setSelection(new TreeItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ return tree.getItem(coordinates);
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ switch (effect) {
+ case DND.FEEDBACK_SELECT:
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ setInsertMark(null, false);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setDropSelection(item);
+ currentEffect = DND.FEEDBACK_SELECT;
+ currentItem = item;
+ }
+ break;
+ case DND.FEEDBACK_INSERT_AFTER:
+ case DND.FEEDBACK_INSERT_BEFORE:
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setInsertMark(item, effect == DND.FEEDBACK_INSERT_AFTER);
+ currentEffect = effect;
+ currentItem = item;
+ }
+ break;
+ default :
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ setInsertMark(null, false);
+ }
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ }
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ break;
+ }
+}
+private void setDropSelection (TreeItem item) {
+ if (item == null) {
+ tree.setSelection(new TreeItem[0]);
+ } else {
+ tree.setSelection(new TreeItem[]{item});
+ }
+}
+private void setInsertMark (TreeItem item, boolean after) {
+ // not currently implemented
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DND.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DND.java
new file mode 100644
index 0000000000..3c14096c0c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DND.java
@@ -0,0 +1,229 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.*;
+
+/**
+ *
+ * Class DND contains all the constants used in defining a
+ * DragSource or a DropTarget.
+ *
+ */
+public class DND {
+
+ /**
+ * Drag and Drop Operation: no drag/drop operation performed
+ * (value is 0).
+ */
+ public final static int DROP_NONE = 0;
+
+ /**
+ * Drag and Drop Operation: a copy of the data in the drag source is
+ * added to the drop target (value is 1 &lt;&lt; 0).
+ */
+ public final static int DROP_COPY = 1 << 0;
+
+ /**
+ * Drag and Drop Operation: a copy of the data is added to the drop target and
+ * the original data is removed from the drag source (value is 1 &lt;&lt; 1).
+ */
+ public final static int DROP_MOVE = 1 << 1;
+
+ /**
+ * Drag and Drop Operation: the drop target makes a link to the data in
+ * the drag source (value is 1 &lt;&lt; 2).
+ */
+ public final static int DROP_LINK = 1 << 2;
+
+ /**
+ * Drag and Drop Operation: the drop target moves the data and the drag source removes
+ * any references to the data and updates its display. This is not available on all platforms
+ * and is only used when a non-SWT application is the drop target. In this case, the SWT
+ * drag source is informed in the dragFinished event that the drop target has moved the data.
+ * (value is 1 &lt;&lt; 3).
+ *
+ * @see DragSourceListener#dragFinished
+ */
+ public final static int DROP_TARGET_MOVE = 1 << 3;
+
+ /**
+ * Drag and Drop Operation: During a dragEnter event or a dragOperationChanged, if no modifier keys
+ * are pressed, the operation is set to DROP_DEFAULT. The application can choose what the default
+ * operation should be by setting a new value in the operation field. If no value is choosen, the
+ * default operation for the platform will be selected (value is 1 &lt;&lt; 4).
+ *
+ * @see DropTargetListener#dragEnter
+ * @see DropTargetListener#dragOperationChanged
+ * @since 2.0
+ */
+ public final static int DROP_DEFAULT = 1 << 4;
+
+ /**
+ * DragSource Event: the drop has successfully completed or has been terminated (such as hitting
+ * the ESC key); perform cleanup such as removing data on a move operation (value is 2000).
+ */
+ public static final int DragEnd = 2000;
+
+ /**
+ * DragSource Event: the data to be dropped is required from the drag source (value is 2001).
+ */
+ public static final int DragSetData = 2001;
+
+ /**
+ * DropTarget Event: the cursor has entered the drop target boundaries (value is 2002).
+ */
+ public static final int DragEnter = 2002;
+
+ /**
+ * DropTarget Event: the cursor has left the drop target boundaries OR the drop
+ * operation has been cancelled (such as by hitting ECS) OR the drop is about to
+ * happen (user has released the mous ebutotn over this target) (value is 2003).
+ */
+ public static final int DragLeave = 2003;
+
+ /**
+ * DropTarget Event: the cursor is over the drop target (value is 2004).
+ */
+ public static final int DragOver = 2004;
+
+ /**
+ * DropTarget Event: the operation being performed has changed usually due to the user
+ * changing the selected modifier keys while dragging (value is 2005).
+ */
+ public static final int DragOperationChanged = 2005;
+
+ /**
+ * DropTarget Event: the data has been dropped (value is 2006).
+ */
+ public static final int Drop = 2006;
+
+ /**
+ * DropTarget Event: the drop target is given a last chance to modify the drop (value is 2007).
+ */
+ public static final int DropAccept = 2007;
+
+ /**
+ * DragSource Event: a drag is about to begin (value is 2008).
+ */
+ public static final int DragStart = 2008;
+
+ /**
+ * DropTarget drag under effect: No effect is shown (value is 0).
+ */
+ public static final int FEEDBACK_NONE = 0;
+
+ /**
+ * DropTarget drag under effect: The item under the cursor is selected; applies to tables
+ * and trees (value is 1).
+ */
+ public static final int FEEDBACK_SELECT = 1;
+
+ /**
+ * DropTarget drag under effect: An insertion mark is shown before the item under the cursor; applies to
+ * tables and trees (value is 2).
+ */
+ public static final int FEEDBACK_INSERT_BEFORE = 2;
+
+ /**
+ * DropTarget drag under effect:An insertion mark is shown after the item under the cursor; applies
+ * to tables and trees (value is 4).
+ */
+ public static final int FEEDBACK_INSERT_AFTER = 4;
+
+ /**
+ * DropTarget drag under effect: The widget is scrolled up or down to allow the user to drop on items that
+ * are not currently visible; applies to tables and trees (value is 8).
+ */
+ public static final int FEEDBACK_SCROLL = 8;
+
+ /**
+ * DropTarget drag under effect: The item currently under the cursor is expanded to allow the user to
+ * select a drop target from a sub item; applies to trees (value is 16).
+ */
+ public static final int FEEDBACK_EXPAND = 16;
+
+ /**
+ * Error code: drag source can not be initialized (value is 2000).
+ */
+ public static final int ERROR_CANNOT_INIT_DRAG = 2000;
+
+ /**
+ * Error code: drop target cannot be initialized (value is 2001).
+ */
+ public static final int ERROR_CANNOT_INIT_DROP = 2001;
+
+ /**
+ * Error code: Data can not be set on system clipboard (value is 2002).
+ */
+ public static final int ERROR_CANNOT_SET_CLIPBOARD = 2002;
+
+
+ static final String INIT_DRAG_MESSAGE = "Can not initialize Drag";
+ static final String INIT_DROP_MESSAGE = "Can not initialize Drop";
+ static final String CANNOT_SET_CLIPBOARD_MESSAGE = "Can not set data in clipboard";
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ *
+ * @param code the DND error code
+ */
+public static void error (int code) {
+ error (code, 0);
+}
+
+/**
+ * Throws an appropriate exception based on the passed in error code.
+ * The <code>hresult</code> argument should be either 0, or the
+ * platform specific error code.
+ * <p>
+ * In DND, errors are reported by throwing one of three exceptions:
+ * <dl>
+ * <dd>java.lang.IllegalArgumentException</dd>
+ * <dt>thrown whenever one of the API methods is invoked with an illegal argument</dt>
+ * <dd>org.eclipse.swt.SWTException (extends java.lang.RuntimeException)</dd>
+ * <dt>thrown whenever a recoverable error happens internally in SWT</dt>
+ * <dd>org.eclipse.swt.SWTError (extends java.lang.Error)</dd>
+ * <dt>thrown whenever a <b>non-recoverable</b> error happens internally in SWT</dt>
+ * </dl>
+ * This method provides the logic which maps between error codes
+ * and one of the above exceptions.
+ * </p>
+ *
+ * @param code the DND error code.
+ * @param hresult the platform specific error code.
+ *
+ * @see SWTError
+ * @see SWTException
+ * @see IllegalArgumentException
+ */
+public static void error (int code, int hresult) {
+ switch (code) {
+ /* OS Failure/Limit (fatal, may occur only on some platforms) */
+ case DND.ERROR_CANNOT_INIT_DRAG:{
+ String msg = DND.INIT_DRAG_MESSAGE;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTError (code, msg);
+ }
+ case DND.ERROR_CANNOT_INIT_DROP:{
+ String msg = DND.INIT_DROP_MESSAGE;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTError (code, msg);
+ }
+ case DND.ERROR_CANNOT_SET_CLIPBOARD:{
+ String msg = DND.CANNOT_SET_CLIPBOARD_MESSAGE;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTError (code, msg);
+ }
+ }
+
+ /* Unknown/Undefined Error */
+ SWT.error(code);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DNDEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DNDEvent.java
new file mode 100644
index 0000000000..c8b2956073
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DNDEvent.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.widgets.*;
+
+class DNDEvent extends Event {
+
+ public TransferData dataType;
+ public TransferData[] dataTypes;
+ public int operations;
+ public int feedback;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DNDListener.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DNDListener.java
new file mode 100644
index 0000000000..5e0ec3c123
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DNDListener.java
@@ -0,0 +1,80 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.internal.SWTEventListener;
+
+
+class DNDListener extends org.eclipse.swt.widgets.TypedListener {
+/**
+ * DNDListener constructor comment.
+ * @param listener org.eclipse.swt.internal.SWTEventListener
+ */
+DNDListener(SWTEventListener listener) {
+ super(listener);
+}
+public void handleEvent (Event e) {
+ switch (e.type) {
+ case DND.DragStart: {
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ ((DragSourceListener) eventListener).dragStart (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragEnd: {
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ ((DragSourceListener) eventListener).dragFinished (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragSetData: {
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ ((DragSourceListener) eventListener).dragSetData (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragEnter: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragEnter (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragLeave: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragLeave (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragOver: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragOver (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.Drop: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).drop (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DropAccept: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dropAccept (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragOperationChanged: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragOperationChanged (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceAdapter.java
new file mode 100644
index 0000000000..9752b94fc6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceAdapter.java
@@ -0,0 +1,37 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>DragSourceListener</code> interface.
+ *
+ * <p>Classes that wish to deal with <code>DragSourceEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.</p>
+ *
+ * @see DragSourceListener
+ * @see DragSourceEvent
+ */
+public class DragSourceAdapter implements DragSourceListener {
+ /**
+ * This implementation of <code>dragStart</code> permits the drag operation to start.
+ * For additional information see <code>DragSourceListener.dragStart</code>.
+ */
+ public void dragStart(DragSourceEvent event){};
+ /**
+ * This implementation of <code>dragFinished</code> does nothing.
+ * For additional information see <code>DragSourceListener.dragFinished</code>.
+ */
+ public void dragFinished(DragSourceEvent event){};
+ /**
+ * This implementation of <code>dragSetData</code> does nothing.
+ * For additional information see <code>DragSourceListener.dragSetData</code>.
+ */
+ public void dragSetData(DragSourceEvent event){};
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceEvent.java
new file mode 100644
index 0000000000..505ac1c6d7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceEvent.java
@@ -0,0 +1,66 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.events.TypedEvent;
+
+/**
+ * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
+ *
+ * @see DragSourceListener
+ */
+public class DragSourceEvent extends TypedEvent {
+ /**
+ * The operation that was performed.
+ * @see DND.DROP_NONE
+ * @see DND.DROP_MOVE
+ * @see DND.DROP_COPY
+ * @see DND.DROP_LINK
+ * @see DND.DROP_TARGET_MOVE.
+ */
+ public int detail;
+
+ /**
+ * In dragStart:
+ * <p>Flag to determine if the drag and drop operation should proceed.
+ * The application can set this value to false to prevent the drag from starting.
+ * Set to true by default.</p>
+ *
+ * <p>In dragFinished:</p>
+ * <p>Flag to indicate if the operation was performed successfully.
+ * True if the operation was performed successfully.</p>
+ */
+ public boolean doit;
+
+ /**
+ * The type of data requested.
+ * Data provided in the data field must be of the same type.
+ */
+ public TransferData dataType;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public DragSourceEvent(DNDEvent e) {
+ super(e);
+ this.data = e.data;
+ this.detail = e.detail;
+ this.doit = e.doit;
+ this.dataType = e.dataType;
+}
+void updateEvent(DNDEvent e) {
+ e.widget = this.widget;
+ e.time = this.time;
+ e.data = this.data;
+ e.detail = this.detail;
+ e.doit = this.doit;
+ e.dataType = this.dataType;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceListener.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceListener.java
new file mode 100644
index 0000000000..70022107f2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragSourceListener.java
@@ -0,0 +1,76 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * The <code>DragSourceListener</code> class provides event notification to the application for DragSource events.
+ *
+ * <p>When the user drops data on a <code>DropTarget</code>, the application which defines the <code>DragSource</code>
+ * must provide the dropped data by implementing <code>dragSetData</code>. In the dragSetData, the application
+ * must support all the data types that were specified in the DragSource#setTransfer method.</p>
+ *
+ * <p>After the drop has completed successfully or has been aborted, the application which defines the
+ * <code>DragSource</code> is required to take the appropriate cleanup action. In the case of a successful
+ * <b>move</b> operation, the application must remove the data that was transferred.</p>
+ *
+ */
+public interface DragSourceListener extends SWTEventListener {
+
+/**
+ * The user has begun the actions required to drag the widget. This event gives the application
+ * the chance to decide if a drag should be started.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in,out)doit
+ * </ul></p>
+ *
+ * @param event the information associated with the drag start event
+ *
+ * @see DragSourceEvent
+ */
+public void dragStart(DragSourceEvent event);
+
+/**
+ * The data is required from the drag source.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)dataType - the type of data requested.
+ * <li>(out)data - the application inserts the actual data here (must match the dataType)
+ * </ul></p>
+ *
+ * @param event the information associated with the drag set data event
+ *
+ * @see DragSourceEvent
+ */
+public void dragSetData(DragSourceEvent event);
+
+/**
+ * The drop has successfully completed(mouse up over a valid target) or has been terminated (such as hitting
+ * the ESC key). Perform cleanup such as removing data from the source side on a successful move operation.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)doit
+ * <li>(in)detail
+ * </ul></p>
+ *
+ * @param event the information associated with the drag finished event
+ *
+ * @see DragSourceEvent
+ */
+public void dragFinished(DragSourceEvent event);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragUnderEffect.java
new file mode 100644
index 0000000000..509f99eae9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DragUnderEffect.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+abstract class DragUnderEffect {
+
+abstract void show(int effect, int x, int y);
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetAdapter.java
new file mode 100644
index 0000000000..08e195d5a9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetAdapter.java
@@ -0,0 +1,63 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+/**
+ * This adapter class provides default implementations for the
+ * methods described by the <code>DropTargetListener</code> interface.
+ * <p>
+ * Classes that wish to deal with <code>DropTargetEvent</code>s can
+ * extend this class and override only the methods which they are
+ * interested in.
+ * </p>
+ *
+ * @see DropTargetListener
+ * @see DropTargetEvent
+ */
+public class DropTargetAdapter implements DropTargetListener {
+
+/**
+ * This implementation of <code>dragEnter</code> permits the default
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragEnter</code>.
+ */
+public void dragEnter(DropTargetEvent event){};
+/**
+ * This implementation of <code>dragLeave</code> does nothing.
+ * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
+ */
+public void dragLeave(DropTargetEvent event){};
+/**
+ * This implementation of <code>dragOperationChanged</code> permits the default
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragOperationChanged</code>.
+ */
+public void dragOperationChanged(DropTargetEvent event){};
+/**
+ * This implementation of <code>dragOver</code> permits the default
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dragOver</code>.
+ */
+public void dragOver(DropTargetEvent event){};
+/**
+ * This implementation of <code>drop</code> does nothing.
+ * For additional information see <code>DropTargetListener.drop</code>.
+ */
+public void drop(DropTargetEvent event){};
+/**
+ * This implementation of <code>dropAccept</code> permits the default
+ * operation defined in <code>event.detail</code>to be performed on the current data type
+ * defined in <code>event.currentDataType</code>.
+ * For additional information see <code>DropTargetListener.dropAccept</code>.
+ */
+public void dropAccept(DropTargetEvent event){};
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetEvent.java
new file mode 100644
index 0000000000..3fdd81bb8f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetEvent.java
@@ -0,0 +1,108 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * The DropTargetEvent contains the event information passed in the methods of the DropTargetListener.
+ */
+public class DropTargetEvent extends TypedEvent {
+ /**
+ * The x-cordinate of the cursor relative to the <code>Display</code>
+ */
+ public int x;
+
+ /**
+ * The y-cordinate of the cursor relative to the <code>Display</code>
+ */
+ public int y;
+
+ /**
+ * The operation being performed.
+ * @see DND.DROP_NONE
+ * @see DND.DROP_MOVE
+ * @see DND.DROP_COPY
+ * @see DND.DROP_LINK
+ */
+ public int detail;
+
+ /**
+ * A bitwise OR'ing of the operations that the DragSource can support
+ * (e.g. DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK).
+ * The detail value must be a member of this list or DND.DROP_NONE.
+ * @see DND.DROP_NONE
+ * @see DND.DROP_MOVE
+ * @see DND.DROP_COPY
+ * @see DND.DROP_LINK
+ */
+ public int operations;
+
+ /**
+ * A bitwise OR'ing of the drag under effect feedback to be displayed to the user
+ * (e.g. DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL | DND.FEEDBACK_EXPAND).
+ * <p>A value of DND.FEEDBACK_NONE indicates that no drag under effect will be displayed.</p>
+ * <p>Feedback effects will only be applied if they are applicable.</p>
+ * <p>The default value is DND.FEEDBACK_SELECT.</p>
+ * @see DND.FEEDBACK_SELECT
+ * @see DND.FEEDBACK_INSERT_BEFORE
+ * @see DND.FEEDBACK_INSERT_AFTER
+ * @see DND.FEEDBACK_SCROLL
+ * @see DND.FEEDBACK_EXPAND
+ */
+ public int feedback;
+
+ /**
+ * If the associated control is a table or tree, this field contains the item located
+ * at the cursor coordinates.
+ */
+ public Widget item;
+
+ /**
+ * The type of data that will be dropped.
+ */
+ public TransferData currentDataType;
+
+ /**
+ * A list of the types of data that the DragSource is capable of providing.
+ * The currentDataType must be a member of this list.
+ */
+ public TransferData[] dataTypes;
+
+/**
+ * Constructs a new instance of this class based on the
+ * information in the given untyped event.
+ *
+ * @param e the untyped event containing the information
+ */
+public DropTargetEvent(DNDEvent e) {
+ super(e);
+ this.data = e.data;
+ this.x = e.x;
+ this.y = e.y;
+ this.detail = e.detail;
+ this.currentDataType = e.dataType;
+ this.dataTypes = e.dataTypes;
+ this.operations = e.operations;
+ this.feedback = e.feedback;
+ this.item = e.item;
+}
+void updateEvent(DNDEvent e) {
+ e.widget = this.widget;
+ e.time = this.time;
+ e.data = this.data;
+ e.x = this.x;
+ e.y = this.y;
+ e.detail = this.detail;
+ e.dataType = this.currentDataType;
+ e.dataTypes = this.dataTypes;
+ e.operations = this.operations;
+ e.feedback = this.feedback;
+ e.item = this.item;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetListener.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetListener.java
new file mode 100644
index 0000000000..b17b8e9cbd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/DropTargetListener.java
@@ -0,0 +1,246 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+import org.eclipse.swt.internal.SWTEventListener;
+
+/**
+ * The <code>DropTargetListener</code> class provides event notification to the application
+ * for DropTarget events.
+ *
+ * <p>As the user moves the cursor into, over and out of a Control that has been designated
+ * as a DropTarget, events indicate what operation can be performed and what data can be
+ * transferred if a drop where to occur at that point.
+ * The application can respond to these events and change the type of data that will
+ * be dropped by modifying event.currentDataType, or change the operation that will be performed
+ * by modifying the event.detail field or stop any drop from happening on the current target
+ * by setting the event.detail field to DND_DROP_NONE.</p>
+ *
+ * <p>When the user causes a drop to happen by releasing the mouse over a valid drop target,
+ * the application has one last chance to change the data type of the drop through the
+ * DropAccept event. If the drop is still allowed, the DropAccept event is immediately
+ * followed by the Drop event. In the Drop event, the application can still change the
+ * operation that is performed but the data type is fixed.</p>
+ *
+ * @see DropTargetEvent
+ *
+ */
+public interface DropTargetListener extends SWTEventListener {
+
+/**
+ * The cursor has entered the drop target boundaries.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.
+ * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.
+ * If the application does not set the <code>event.detail</code> to something other
+ * than <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard
+ * default.</p>
+ *
+ * <p>The <code>currentDataType</code> is determined by the first transfer agent specified in
+ * setTransfer() that matches a data type provided by the drag source.</p>
+ *
+ * <p>It is possible to get a DragEnter event when the drag source does not provide any matching data.
+ * In this case, the default operation is DND.DROP_NONE and the currentDataType is null.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
+ * field or DND.DROP_NONE.</p>
+ *
+ * <p>The application can also change the type of data being requested by
+ * modifying the <code>currentDataTypes</code> field but the value must be one of the values
+ * in the <code>dataTypes</code> list.</p>
+ *
+ * @param event the information associated with the drag enter event
+ *
+ * @see DropTargetEvent
+ */
+public void dragEnter(DropTargetEvent event);
+
+/**
+ * The cursor has left the drop target boundaries OR the drop has been cancelled OR the data
+ * is about to be dropped.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in)currentDataType
+ * <li>(in)operations
+ * <li>(in)detail
+ * </ul></p>
+ *
+ * @param event the information associated with the drag leave event
+ *
+ * @see DropTargetEvent
+ */
+public void dragLeave(DropTargetEvent event);
+
+/**
+ * The operation being performed has changed (usually due to the user changing the selected modifier key(s)
+ * while dragging).
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the modifier keys pressed by the user.
+ * If no keys are pressed the <code>event.detail</code> field is set to DND.DROP_DEFAULT.
+ * If the application does not set the <code>event.detail</code> to something other than
+ * <code>DND.DROP_DEFAULT</code> the operation will be set to the platform defined standard default.</p>
+ *
+ * <p>The <code>currentDataType</code> value is determined by the value assigned to
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
+ * field.</p>
+ *
+ * <p>The application can also change the type of data being requested by modifying
+ * the <code>currentDataTypes</code> field but the value must be one of the values in the
+ * <code>dataTypes</code> list.</p>
+ *
+ * @param event the information associated with the drag operation changed event
+ *
+ * @see DropTargetEvent
+ */
+public void dragOperationChanged(DropTargetEvent event);
+
+/**
+ * The cursor is moving over the drop target.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * <li>(in,out)feedback
+ * </ul></p>
+ *
+ * <p>The <code>operation</code> value is determined by the value assigned to
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ *
+ * <p>The <code>currentDataType</code> value is determined by the value assigned to
+ * <code>currentDataType</code> in previous dragEnter and dragOver calls.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the
+ * <code>detail</code> field but the choice must be one of the values in the <code>operations</code>
+ * field.</p>
+ *
+ * <p>The application can also change the type of data being requested by modifying the
+ * <code>currentDataTypes</code> field but the value must be one of the values in the
+ * <code>dataTypes</code> list.</p>
+ *
+ * <p>NOTE: At this point the <code>data</code> field is null. On some platforms, it is possible
+ * to obtain the data being transferred before the transfer occurs but in most platforms this is
+ * not possible. On those platforms where the data is available, the application can access the
+ * data as follows:</p>
+ *
+ * <pre><code>
+ * public void dragOver(DropTargetEvent event) {
+ * TextTransfer textTransfer = TextTransfer.getInstance();
+ * String data = (String)textTransfer.nativeToJava(event.currentDataType);
+ * if (data != null) {
+ * System.out.println("Data to be dropped is (Text)"+data);
+ * }
+ * };
+ * </code></pre>
+ *
+ * @param event the information associated with the drag over event
+ *
+ * @see DropTargetEvent
+ */
+public void dragOver(DropTargetEvent event);
+
+/**
+ * The data is being dropped. The data field contains java format of the data being dropped.
+ * To determine the type of the data object, refer to the documentation for the Transfer subclass
+ * specified in event.currentDataType.
+ *
+ * <p>The following fields in DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in,out)detail
+ * <li>(in)currentDataType
+ * <li>(in)data
+ * </ul></p>
+ *
+ * <p>The application can refuse to perform the drop operation by setting the detail
+ * field to DND.DROP_NONE.</p>
+ *
+ * @param event the information associated with the drop event
+ *
+ * @see DropTargetEvent
+ */
+public void drop(DropTargetEvent event);
+
+/**
+ * The drop is about to be performed.
+ * The drop target is given a last chance to change the nature of the drop.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget
+ * <li>(in)time
+ * <li>(in)x
+ * <li>(in)y
+ * <li>(in)dataTypes
+ * <li>(in,out)currentDataType
+ * <li>(in)operations
+ * <li>(in,out)detail
+ * </ul></p>
+ *
+ * <p>The application can veto the drop by setting the <code>event.detail</code> field to
+ * <code>DND.DROP_NONE</code>.</p>
+ *
+ * <p>The application can change the operation that will be performed by modifying the
+ * <code>detail</code> field but the choice must be one of the values in the
+ * <code>operations</code> field.</p>
+ *
+ * <p>The application can also change the type of data being requested by modifying the
+ * <code>currentDataTypes</code> field but the value must be one of the values in the <
+ * code>dataTypes</code> list.</p>
+ *
+ * @param event the information associated with the drop accept event
+ *
+ * @see DropTargetEvent
+ */
+public void dropAccept(DropTargetEvent event);
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/NoDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/NoDragUnderEffect.java
new file mode 100644
index 0000000000..0d41868896
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/NoDragUnderEffect.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.widgets.*;
+
+class NoDragUnderEffect extends DragUnderEffect {
+
+NoDragUnderEffect(Control control) {}
+void show(int effect, int x, int y){}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/package.html b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/package.html
new file mode 100644
index 0000000000..e9f6028be5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/common/org/eclipse/swt/dnd/package.html
@@ -0,0 +1,15 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+SWT Drag and Drop support.
+<h2>
+Package Specification</h2>
+This package contains the classes which make up the public API of the SWT
+Drag and Drop support.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c
index 87f27ad336..e3ddfe6912 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/library/swt.c
@@ -3695,6 +3695,22 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetSuperControl
}
#endif /* NO_GetSuperControl */
+#ifndef NO_GetThemeBrushAsColor
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeBrushAsColor
+ (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jboolean arg2, jobject arg3)
+{
+ RGBColor _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetThemeBrushAsColor\n")
+
+ if (arg3) lparg3 = getRGBColorFields(env, arg3, &_arg3);
+ rc = (jint)GetThemeBrushAsColor(arg0, arg1, arg2, (RGBColor*)lparg3);
+ if (arg3) setRGBColorFields(env, arg3, lparg3);
+ return rc;
+}
+#endif
+
#ifndef NO_GetThemeDrawingState
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeDrawingState
(JNIEnv *env, jclass that, jintArray arg0)
@@ -3749,6 +3765,22 @@ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeMetric
}
#endif /* NO_GetThemeMetric */
+#ifndef NO_GetThemeTextColor
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeTextColor
+ (JNIEnv *env, jclass that, jshort arg0, jshort arg1, jboolean arg2, jobject arg3)
+{
+ RGBColor _arg3, *lparg3=NULL;
+ jint rc;
+
+ DEBUG_CALL("GetThemeTextColor\n")
+
+ if (arg3) lparg3 = getRGBColorFields(env, arg3, &_arg3);
+ rc = (jint)GetThemeTextColor(arg0, arg1, arg2, (RGBColor *)lparg3);
+ if (arg3) setRGBColorFields(env, arg3, lparg3);
+ return rc;
+}
+#endif
+
#ifndef NO_GetThemeTextDimensions
JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_carbon_OS_GetThemeTextDimensions
(JNIEnv *env, jclass that, jint arg0, jshort arg1, jint arg2, jboolean arg3, jobject arg4, jshortArray arg5)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java
index 249b45354b..b6afd6b9a5 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/carbon/org/eclipse/swt/internal/carbon/OS.java
@@ -389,6 +389,11 @@ public class OS {
public static final int kThemeArrowCursor = 0;
public static final int kThemeBrushDialogBackgroundActive = 1;
public static final int kThemeBrushDocumentWindowBackground = 15;
+ public static final int kThemeBrushPrimaryHighlightColor = -3;
+ public static final int kThemeBrushSecondaryHighlightColor = -4;
+ public static final int kThemeBrushButtonFaceActive = 29;
+ public static final int kThemeBrushFocusHighlight = 19;
+ public static final int kThemeBrushListViewBackground = 10;
public static final int kThemeButtonOff = 0;
public static final int kThemeButtonOn = 1;
public static final int kThemeCheckBox = 1;
@@ -426,6 +431,10 @@ public class OS {
public static final int kThemeStateInactive = 0;
public static final int kThemeStatePressed = 2;
public static final int kThemeSystemFont = 0;
+ public static final int kThemeTextColorDocumentWindowTitleActive = 23;
+ public static final int kThemeTextColorDocumentWindowTitleInactive = 24;
+ public static final int kThemeTextColorListView = 22;
+ public static final int kThemeTextColorPushButtonActive = 12;
public static final int kThemeToolbarFont = 108;
public static final int kThemeViewsFont = 3;
public static final int kThemeWatchCursor = 7;
@@ -759,9 +768,11 @@ public static final native int GetScrapFlavorData(int scrap, int flavorType, int
public static final native int GetScrapFlavorInfoList(int scrap, int[] infoCount, int[] info);
public static final native int GetScrapFlavorSize(int scrap, int flavorType, int[] byteCount);
public static final native int GetSuperControl(int cHandle, int[] parentHandle);
+public static final native int GetThemeBrushAsColor(short inBrush, short inDepth, boolean inColorDev, RGBColor outColor);
public static final native int GetThemeDrawingState(int[] state);
public static final native int GetThemeFont(short themeFontId, short scriptCode, byte[] fontName, short[] fontSize, byte[] style);
public static final native int GetThemeMetric(int inMetric, int [] outMetric);
+public static final native int GetThemeTextColor(short inColor, short inDepth, boolean inColorDev, RGBColor outColor);
public static final native int GetThemeTextDimensions(int sHandle, short fontID, int state, boolean wrapToWidth, Point ioBounds, short[] baseLine);
public static final native int GetUserFocusEventTarget();
public static final native int GetWRefCon(int wHandle);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
index 99d0a252ef..4325d39ab3 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
@@ -747,7 +747,6 @@ void releaseWidget () {
menu.dispose ();
}
menu = null;
- deregister ();
parent = null;
layoutData = null;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
index 34f2981da8..f1407571cd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
@@ -14,6 +14,7 @@ import org.eclipse.swt.internal.carbon.CGPoint;
import org.eclipse.swt.internal.carbon.CGRect;
import org.eclipse.swt.internal.carbon.Rect;
import org.eclipse.swt.internal.carbon.HICommand;
+import org.eclipse.swt.internal.carbon.RGBColor;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
@@ -615,29 +616,32 @@ public Thread getSyncThread () {
public Color getSystemColor (int id) {
checkDevice ();
//NOT DONE
+
+ RGBColor rgb = new RGBColor ();
switch (id) {
- case SWT.COLOR_INFO_FOREGROUND: return Color.carbon_new (this, new float [] {0x00 / 255f, 0x00 / 255f, 0x00 / 255f, 1});
- case SWT.COLOR_INFO_BACKGROUND: return Color.carbon_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1});
- case SWT.COLOR_TITLE_FOREGROUND: return super.getSystemColor (SWT.COLOR_WHITE);
- case SWT.COLOR_TITLE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_BLUE);
- case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_BLUE);
- case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_GRAY);
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_GRAY);
- case SWT.COLOR_WIDGET_DARK_SHADOW: return Color.carbon_new (this, new float [] {0x33 / 255f, 0x33 / 255f, 0x33 / 255f, 1});
- case SWT.COLOR_WIDGET_NORMAL_SHADOW: return Color.carbon_new (this, new float [] {0x66 / 255f, 0x66 / 255f, 0x66 / 255f, 1});
+ case SWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
+ case SWT.COLOR_INFO_BACKGROUND: return Color.carbon_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xE1 / 255f, 1});
+ case SWT.COLOR_TITLE_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorDocumentWindowTitleActive, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_TITLE_BACKGROUND: OS.GetThemeBrushAsColor((short)-5/*undocumented darker highlight color*/, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: OS.GetThemeBrushAsColor((short)OS.kThemeBrushPrimaryHighlightColor, (short)getDepth(), true, rgb) ; break;
+ case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorDocumentWindowTitleInactive, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushSecondaryHighlightColor, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: OS.GetThemeBrushAsColor((short)OS.kThemeBrushSecondaryHighlightColor, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_WIDGET_DARK_SHADOW: return Color.carbon_new (this, new float [] {0x33 / 255f, 0x33 / 255f, 0x33 / 255f, 1});
+ case SWT.COLOR_WIDGET_NORMAL_SHADOW: return Color.carbon_new (this, new float [] {0x66 / 255f, 0x66 / 255f, 0x66 / 255f, 1});
case SWT.COLOR_WIDGET_LIGHT_SHADOW: return Color.carbon_new (this, new float [] {0x99 / 255f, 0x99 / 255f, 0x99 / 255f, 1});
- case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: return Color.carbon_new (this, new float [] {0xCC / 255f, 0xCC / 255f, 0xCC / 255f, 1});
- case SWT.COLOR_WIDGET_BACKGROUND: return Color.carbon_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xFF / 255f, 1});
- case SWT.COLOR_WIDGET_FOREGROUND:
- case SWT.COLOR_WIDGET_BORDER: return Color.carbon_new (this, new float [] {0x00 / 255f, 0x00 / 255f, 0x00 / 255f, 1});
- case SWT.COLOR_LIST_FOREGROUND: return Color.carbon_new (this, new float [] {0x00 / 255f, 0x00 / 255f, 0x00 / 255f, 1});
- case SWT.COLOR_LIST_BACKGROUND: return Color.carbon_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xFF / 255f, 1});
- case SWT.COLOR_LIST_SELECTION_TEXT: return Color.carbon_new (this, new float [] {0xFF / 255f, 0xFF / 255f, 0xFF / 255f, 1});
- case SWT.COLOR_LIST_SELECTION: return Color.carbon_new (this, new float [] {0x66 / 255f, 0x66 / 255f, 0xCC / 255f, 1});
+ case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: return Color.carbon_new (this, new float [] {0xCC / 255f, 0xCC / 255f, 0xCC / 255f, 1});
+ case SWT.COLOR_WIDGET_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushButtonFaceActive, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_WIDGET_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorPushButtonActive, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_WIDGET_BORDER: return super.getSystemColor (SWT.COLOR_BLACK);
+ case SWT.COLOR_LIST_FOREGROUND: OS.GetThemeTextColor((short)OS.kThemeTextColorListView, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_LIST_BACKGROUND: OS.GetThemeBrushAsColor((short)OS.kThemeBrushListViewBackground, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_LIST_SELECTION_TEXT: OS.GetThemeTextColor((short)OS.kThemeTextColorListView, (short)getDepth(), true, rgb); break;
+ case SWT.COLOR_LIST_SELECTION: OS.GetThemeBrushAsColor((short)OS.kThemeBrushPrimaryHighlightColor, (short)getDepth(), true, rgb); break;
default:
return super.getSystemColor (id);
}
+ return new Color (this, (rgb.red >> 8) & 0xFF, (rgb.green >> 8) & 0xFF, (rgb.blue >> 8) & 0xFF);
}
public Thread getThread () {
@@ -1456,9 +1460,7 @@ void updateMenuBar (Shell shell) {
* current menu bar. The fix is to disable each individual menu
* item.
*/
- Menu menu = null;
if (menuBar != null) {
- int theMenu = menuBar.handle;
MenuItem [] items = menuBar.getItems ();
for (int i=0; i<items.length; i++) {
if (items [i].getEnabled ()) items [i]._setEnabled (true);