1
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 *******************************************************************************/
|
|
11 module org.eclipse.swt.widgets.Event;
|
|
12
|
|
13 import tango.text.convert.Format;
|
|
14
|
|
15 /// PORTING_TYPE
|
|
16 class Display{}
|
|
17 class Widget{}
|
|
18 class GC{}
|
|
19 class Rectangle{
|
|
20 this(int,int,int,int){}
|
|
21 int x, y, width, height;
|
|
22 }
|
|
23
|
|
24
|
|
25 /**
|
|
26 * Instances of this class provide a description of a particular
|
|
27 * event which occurred within SWT. The SWT <em>untyped listener</em>
|
|
28 * API uses these instances for all event dispatching.
|
|
29 * <p>
|
|
30 * Note: For a given event, only the fields which are appropriate
|
|
31 * will be filled in. The contents of the fields which are not used
|
|
32 * by the event are unspecified.
|
|
33 * </p>
|
|
34 *
|
|
35 * @see Listener
|
|
36 * @see org.eclipse.swt.events.TypedEvent
|
|
37 */
|
|
38
|
|
39 public class Event {
|
|
40
|
|
41 /**
|
|
42 * the display where the event occurred
|
|
43 *
|
|
44 * @since 2.0
|
|
45 */
|
|
46 public Display display;
|
|
47
|
|
48 /**
|
|
49 * the widget that issued the event
|
|
50 */
|
|
51 public Widget widget;
|
|
52
|
|
53 /**
|
|
54 * the type of event, as defined by the event type constants
|
|
55 * in class <code>SWT</code>
|
|
56 *
|
|
57 * @see org.eclipse.swt.SWT
|
|
58 */
|
|
59 public int type;
|
|
60
|
|
61 /**
|
|
62 * the event specific detail field, as defined by the detail constants
|
|
63 * in class <code>SWT</code>
|
|
64 *
|
|
65 * @see org.eclipse.swt.SWT
|
|
66 */
|
|
67 public int detail;
|
|
68
|
|
69 /**
|
|
70 * the item that the event occurred in (can be null)
|
|
71 */
|
|
72 public Widget item;
|
|
73
|
|
74 /**
|
|
75 * the index of the item where the event occurred
|
|
76 *
|
|
77 * @since 3.2
|
|
78 */
|
|
79 public int index;
|
|
80
|
|
81 /**
|
|
82 * the graphics context to use when painting
|
|
83 * that is configured to use the colors, font and
|
|
84 * damaged region of the control. It is valid
|
|
85 * only during the paint and must not be disposed
|
|
86 */
|
|
87 public GC gc;
|
|
88
|
|
89 /**
|
|
90 * depending on the event type, the x offset of the bounding
|
|
91 * rectangle of the region that requires painting or the
|
|
92 * widget-relative, x coordinate of the pointer at the
|
|
93 * time the mouse button was pressed or released
|
|
94 */
|
|
95 public int x;
|
|
96
|
|
97 /**
|
|
98 * depending on the event type, the y offset of the bounding
|
|
99 * rectangle of the region that requires painting or the
|
|
100 * widget-relative, y coordinate of the pointer at the
|
|
101 * time the mouse button was pressed or released
|
|
102 */
|
|
103 public int y;
|
|
104
|
|
105 /**
|
|
106 * the width of the bounding rectangle of the
|
|
107 * region that requires painting
|
|
108 */
|
|
109 public int width;
|
|
110
|
|
111 /**
|
|
112 * the height of the bounding rectangle of the
|
|
113 * region that requires painting
|
|
114 */
|
|
115 public int height;
|
|
116
|
|
117 /**
|
|
118 * depending on the event type, the number of following
|
|
119 * paint events which are pending which may always be zero
|
|
120 * on some platforms or the number of lines or pages to
|
|
121 * scroll using the mouse wheel
|
|
122 */
|
|
123 public int count;
|
|
124
|
|
125 /**
|
|
126 * the time that the event occurred.
|
|
127 *
|
|
128 * NOTE: This field is an unsigned integer and should
|
|
129 * be AND'ed with 0xFFFFFFFFL so that it can be treated
|
|
130 * as a signed long.
|
|
131 */
|
|
132 public int time;
|
|
133
|
|
134 /**
|
|
135 * the button that was pressed or released; 1 for the
|
|
136 * first button, 2 for the second button, and 3 for the
|
|
137 * third button, etc.
|
|
138 */
|
|
139 public int button;
|
|
140
|
|
141 /**
|
|
142 * depending on the event, the character represented by the key
|
|
143 * that was typed. This is the final character that results
|
|
144 * after all modifiers have been applied. For example, when the
|
|
145 * user types Ctrl+A, the character value is 0x01 (ASCII SOH).
|
|
146 * It is important that applications do not attempt to modify the
|
|
147 * character value based on a stateMask (such as SWT.CTRL) or the
|
|
148 * resulting character will not be correct.
|
|
149 */
|
|
150 public char character;
|
|
151
|
|
152 /**
|
|
153 * depending on the event, the key code of the key that was typed,
|
|
154 * as defined by the key code constants in class <code>SWT</code>.
|
|
155 * When the character field of the event is ambiguous, this field
|
|
156 * contains the unaffected value of the original character. For
|
|
157 * example, typing Ctrl+M or Enter both result in the character '\r'
|
|
158 * but the keyCode field will also contain '\r' when Enter was typed
|
|
159 * and 'm' when Ctrl+M was typed.
|
|
160 *
|
|
161 * @see org.eclipse.swt.SWT
|
|
162 */
|
|
163 public int keyCode;
|
|
164
|
|
165 /**
|
|
166 * depending on the event, the state of the keyboard modifier
|
|
167 * keys and mouse masks at the time the event was generated.
|
|
168 *
|
|
169 * @see org.eclipse.swt.SWT
|
|
170 */
|
|
171 public int stateMask;
|
|
172
|
|
173 /**
|
|
174 * depending on the event, the range of text being modified.
|
|
175 * Setting these fields has no effect.
|
|
176 */
|
|
177 public int start, end;
|
|
178
|
|
179 /**
|
|
180 * depending on the event, the new text that will be inserted.
|
|
181 * Setting this field will change the text that is about to
|
|
182 * be inserted or deleted.
|
|
183 */
|
|
184 public char[] text;
|
|
185
|
|
186 /**
|
|
187 * depending on the event, a flag indicating whether the operation
|
|
188 * should be allowed. Setting this field to false will cancel the
|
|
189 * operation.
|
|
190 */
|
|
191 public bool doit = true;
|
|
192
|
|
193 /**
|
|
194 * a field for application use
|
|
195 */
|
|
196 public Object data;
|
|
197
|
|
198 /**
|
|
199 * Gets the bounds.
|
|
200 *
|
|
201 * @return a rectangle that is the bounds.
|
|
202 */
|
|
203 public Rectangle getBounds () {
|
|
204 return new Rectangle (x, y, width, height);
|
|
205 }
|
|
206
|
|
207 /**
|
|
208 * Sets the bounds.
|
|
209 *
|
|
210 * @param rect the new rectangle
|
|
211 */
|
|
212 public void setBounds (Rectangle rect) {
|
|
213 this.x = rect.x;
|
|
214 this.y = rect.y;
|
|
215 this.width = rect.width;
|
|
216 this.height = rect.height;
|
|
217 }
|
|
218
|
|
219 /**
|
|
220 * Returns a string containing a concise, human-readable
|
|
221 * description of the receiver.
|
|
222 *
|
|
223 * @return a string representation of the event
|
|
224 */
|
|
225 public char[] toString () {
|
|
226 return Format( "Event {type={} {} time={} data={} x={} y={} width={} height={} detail={}}",
|
|
227 type, widget, time, data, x, y, width, height, detail ); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
|
|
228 }
|
|
229 }
|