Mercurial > projects > dwt-win
annotate dwt/events/TypedEvent.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | bef1ed4ebc50 |
children | fd9c62a2998e |
rev | line source |
---|---|
0 | 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; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
23 import dwt.dwthelper.utils; |
0 | 24 |
25 /** | |
26 * This is the super class for all typed event classes provided | |
27 * by DWT. Typed events contain particular information which is | |
28 * applicable to the event occurrence. | |
29 * | |
30 * @see dwt.widgets.Event | |
31 */ | |
32 public class TypedEvent : DWTEventObject { | |
33 | |
34 /** | |
35 * the display where the event occurred | |
36 * | |
37 * @since 2.0 | |
38 */ | |
39 public Display display; | |
40 | |
41 /** | |
42 * the widget that issued the event | |
43 */ | |
44 public Widget widget; | |
45 | |
46 /** | |
47 * the time that the event occurred. | |
48 * | |
49 * NOTE: This field is an unsigned integer and should | |
50 * be AND'ed with 0xFFFFFFFFL so that it can be treated | |
51 * as a signed long. | |
52 */ | |
53 public int time; | |
54 | |
55 /** | |
56 * a field for application use | |
57 */ | |
58 public Object data; | |
59 | |
60 //static final long serialVersionUID = 3257285846578377524L; | |
61 | |
62 /** | |
63 * Constructs a new instance of this class. | |
64 * | |
65 * @param object the object that fired the event | |
66 */ | |
67 public this(Object object) { | |
68 super(object); | |
69 } | |
70 | |
71 /** | |
72 * Constructs a new instance of this class based on the | |
73 * information in the argument. | |
74 * | |
75 * @param e the low level event to initialize the receiver with | |
76 */ | |
77 public this(Event e) { | |
78 super(e.widget); | |
79 this.display = e.display; | |
80 this.widget = e.widget; | |
81 this.time = e.time; | |
82 this.data = e.data; | |
83 } | |
84 | |
85 /** | |
86 * Returns the name of the event. This is the name of | |
87 * the class without the module name. | |
88 * | |
89 * @return the name of the event | |
90 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
91 String getName () { |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
92 String str = this.classinfo.name; |
0 | 93 return split( str, "." )[$-1]; |
94 } | |
95 | |
96 /** | |
97 * Returns a string containing a concise, human-readable | |
98 * description of the receiver. | |
99 * | |
100 * @return a string representation of the event | |
101 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
102 public override String toString() { |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
103 String str_widget = widget is null ? "null" : widget.toString; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
104 String str_data = data is null ? "null" : data.toString; |
86
bef1ed4ebc50
again copied events from dwt-linux
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
105 return Format( "{}{{time={} data={}}", str_widget, time, str_data ); |
0 | 106 } |
107 } |