comparison dwt/events/TypedEvent.d @ 0:5406a8f6526d

Add initial files
author John Reimer <terminal.node@gmail.com
date Sun, 20 Jan 2008 21:50:55 -0800
parents
children 9a64a7781bab
comparison
equal deleted inserted replaced
-1:000000000000 0:5406a8f6526d
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 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module dwt.events.TypedEvent;
14
15
16 import dwt.widgets.Event;
17 import dwt.widgets.Display;
18 import dwt.widgets.Widget;
19 import dwt.internal.DWTEventObject;
20
21 import tango.text.convert.Format;
22 import tango.text.Util : split;
23
24 /**
25 * This is the super class for all typed event classes provided
26 * by DWT. Typed events contain particular information which is
27 * applicable to the event occurrence.
28 *
29 * @see dwt.widgets.Event
30 */
31 public class TypedEvent : DWTEventObject {
32
33 /**
34 * the display where the event occurred
35 *
36 * @since 2.0
37 */
38 public Display display;
39
40 /**
41 * the widget that issued the event
42 */
43 public Widget widget;
44
45 /**
46 * the time that the event occurred.
47 *
48 * NOTE: This field is an unsigned integer and should
49 * be AND'ed with 0xFFFFFFFFL so that it can be treated
50 * as a signed long.
51 */
52 public int time;
53
54 /**
55 * a field for application use
56 */
57 public Object data;
58
59 //static final long serialVersionUID = 3257285846578377524L;
60
61 /**
62 * Constructs a new instance of this class.
63 *
64 * @param object the object that fired the event
65 */
66 public this(Object object) {
67 super(object);
68 }
69
70 /**
71 * Constructs a new instance of this class based on the
72 * information in the argument.
73 *
74 * @param e the low level event to initialize the receiver with
75 */
76 public this(Event e) {
77 super(e.widget);
78 this.display = e.display;
79 this.widget = e.widget;
80 this.time = e.time;
81 this.data = e.data;
82 }
83
84 /**
85 * Returns the name of the event. This is the name of
86 * the class without the module name.
87 *
88 * @return the name of the event
89 */
90 char[] getName () {
91 char[] str = this.classinfo.name;
92 return split( str, "." )[$-1];
93 }
94
95 /**
96 * Returns a string containing a concise, human-readable
97 * description of the receiver.
98 *
99 * @return a string representation of the event
100 */
101 public char[] toString() {
102 return Format( "{}{{{} time={} data={}}", widget.toString(), time, data.toString() );
103 }
104 }