comparison dwt/events/TypedEvent.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 649b8e223d5a
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 module dwt.events.TypedEvent;
12
13 import dwt.dwthelper.utils;
14
15
16 import dwt.internal.DWTEventObject;
17 import dwt.widgets.Display;
18 import dwt.widgets.Event;
19 import dwt.widgets.Widget;
20
21 /**
22 * This is the super class for all typed event classes provided
23 * by DWT. Typed events contain particular information which is
24 * applicable to the event occurrence.
25 *
26 * @see dwt.widgets.Event
27 */
28 public class TypedEvent extends DWTEventObject {
29
30 /**
31 * the display where the event occurred
32 *
33 * @since 2.0
34 */
35 public Display display;
36
37 /**
38 * the widget that issued the event
39 */
40 public Widget widget;
41
42 /**
43 * the time that the event occurred.
44 *
45 * NOTE: This field is an unsigned integer and should
46 * be AND'ed with 0xFFFFFFFFL so that it can be treated
47 * as a signed long.
48 */
49 public int time;
50
51 /**
52 * a field for application use
53 */
54 public Object data;
55
56 static final long serialVersionUID = 3257285846578377524L;
57
58 /**
59 * Constructs a new instance of this class.
60 *
61 * @param object the object that fired the event
62 */
63 public TypedEvent(Object object) {
64 super(object);
65 }
66
67 /**
68 * Constructs a new instance of this class based on the
69 * information in the argument.
70 *
71 * @param e the low level event to initialize the receiver with
72 */
73 public TypedEvent(Event e) {
74 super(e.widget);
75 this.display = e.display;
76 this.widget = e.widget;
77 this.time = e.time;
78 this.data = e.data;
79 }
80
81 /**
82 * Returns the name of the event. This is the name of
83 * the class without the package name.
84 *
85 * @return the name of the event
86 */
87 String getName () {
88 String string = getClass ().getName ();
89 int index = string.lastIndexOf ('.');
90 if (index is -1) return string;
91 return string.substring (index + 1, string.length ());
92 }
93
94 /**
95 * Returns a string containing a concise, human-readable
96 * description of the receiver.
97 *
98 * @return a string representation of the event
99 */
100 public String toString() {
101 return getName ()
102 + "{" + widget
103 + " time=" + time
104 + " data=" + data
105 + "}";
106 }
107 }