]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/dnd/DragSourceEvent.java
Work around SWT 4.13 - 4.18 Win32 DnD bug 567422
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / dnd / DragSourceEvent.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.dnd;
15
16 import org.eclipse.swt.events.*;
17 import org.eclipse.swt.graphics.*;
18
19 /**
20  * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
21  *
22  * @see DragSourceListener
23  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
24  */
25 public class DragSourceEvent extends TypedEvent {
26         /**
27          * The operation that was performed.
28          * @see DND#DROP_NONE
29          * @see DND#DROP_MOVE
30          * @see DND#DROP_COPY
31          * @see DND#DROP_LINK
32          * @see DND#DROP_TARGET_MOVE
33          */
34         public int detail;
35
36         /**
37          * In dragStart, the doit field determines if the drag and drop operation
38          * should proceed; in dragFinished, the doit field indicates whether
39          * the operation was performed successfully.
40          * <p>
41          * In dragStart:</p>
42          * <p>Flag to determine if the drag and drop operation should proceed.
43          * The application can set this value to false to prevent the drag from starting.
44          * Set to true by default.</p>
45          * <p>In dragSetData:</p>
46          * <p>This will be set to true when the call to dragSetData is made.  Set it to
47          * false to cancel the drag.</p>
48          * <p>In dragFinished:</p>
49          * <p>Flag to indicate if the operation was performed successfully.
50          * True if the operation was performed successfully.</p>
51          */
52         public boolean doit;
53
54         /**
55          * In dragStart, the x coordinate (relative to the control) of the
56          * position the mouse went down to start the drag.
57          *
58          * @since 3.2
59          */
60         public int x;
61         /**
62          * In dragStart, the y coordinate (relative to the control) of the
63          * position the mouse went down to start the drag.
64          *
65          * @since 3.2
66          */
67         public int y;
68
69         /**
70          * The type of data requested.
71          * Data provided in the data field must be of the same type.
72          */
73         public TransferData dataType;
74
75         /**
76          * The drag source image to be displayed during the drag.
77          * <p>A value of null indicates that no drag image will be displayed.</p>
78          * <p>The default value is null.</p>
79          *
80          * @since 3.3
81          */
82         public Image image;
83
84         /**
85          * In dragStart, the x offset (relative to the image) where the drag source image will be displayed.
86          *
87          * @since 3.5
88          */
89         public int offsetX;
90         /**
91          * In dragStart, the y offset (relative to the image) where the drag source image will be displayed.
92          *
93          * @since 3.5
94          */
95         public int offsetY;
96
97         static final long serialVersionUID = 3257002142513770808L;
98
99 /**
100  * Constructs a new instance of this class based on the
101  * information in the given untyped event.
102  *
103  * @param e the untyped event containing the information
104  */
105 public DragSourceEvent(DNDEvent e) {
106         super(e);
107         this.data = e.data;
108         this.detail = e.detail;
109         this.doit = e.doit;
110         this.dataType = e.dataType;
111         this.x = e.x;
112         this.y = e.y;
113         this.image = e.image;
114         this.offsetX = e.offsetX;
115         this.offsetY = e.offsetY;
116 }
117 void updateEvent(DNDEvent e) {
118         e.widget = this.widget;
119         e.time = this.time;
120         e.data = this.data;
121         e.detail = this.detail;
122         e.doit = this.doit;
123         e.dataType = this.dataType;
124         e.x = this.x;
125         e.y = this.y;
126         e.image = this.image;
127         e.offsetX = this.offsetX;
128         e.offsetY = this.offsetY;
129 }
130 /**
131  * Returns a string containing a concise, human-readable
132  * description of the receiver.
133  *
134  * @return a string representation of the event
135  */
136 @Override
137 public String toString() {
138         String string = super.toString ();
139         return string.substring (0, string.length() - 1) // remove trailing '}'
140                 + " operation=" + detail
141                 + " type=" + (dataType != null ? dataType.type : 0)
142                 + " doit=" + doit
143                 + "}";
144 }
145 }