Mercurial > projects > dwt-win
annotate dwt/events/TypedEvent.d @ 341:f403c83322c3 default tip
fix: thx torhu
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 08 Nov 2009 20:58:32 +0100 |
parents | fd9c62a2998e |
children |
rev | line source |
---|---|
0 | 1 /******************************************************************************* |
246 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
0 | 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 | |
246 | 31 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
0 | 32 */ |
33 public class TypedEvent : DWTEventObject { | |
34 | |
35 /** | |
36 * the display where the event occurred | |
37 * | |
38 * @since 2.0 | |
39 */ | |
40 public Display display; | |
41 | |
42 /** | |
43 * the widget that issued the event | |
44 */ | |
45 public Widget widget; | |
46 | |
47 /** | |
48 * the time that the event occurred. | |
49 * | |
50 * NOTE: This field is an unsigned integer and should | |
51 * be AND'ed with 0xFFFFFFFFL so that it can be treated | |
52 * as a signed long. | |
53 */ | |
54 public int time; | |
55 | |
56 /** | |
57 * a field for application use | |
58 */ | |
59 public Object data; | |
60 | |
61 //static final long serialVersionUID = 3257285846578377524L; | |
62 | |
63 /** | |
64 * Constructs a new instance of this class. | |
65 * | |
66 * @param object the object that fired the event | |
67 */ | |
68 public this(Object object) { | |
69 super(object); | |
70 } | |
71 | |
72 /** | |
73 * Constructs a new instance of this class based on the | |
74 * information in the argument. | |
75 * | |
76 * @param e the low level event to initialize the receiver with | |
77 */ | |
78 public this(Event e) { | |
79 super(e.widget); | |
80 this.display = e.display; | |
81 this.widget = e.widget; | |
82 this.time = e.time; | |
83 this.data = e.data; | |
84 } | |
85 | |
86 /** | |
87 * Returns the name of the event. This is the name of | |
88 * the class without the module name. | |
89 * | |
90 * @return the name of the event | |
91 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
92 String getName () { |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
93 String str = this.classinfo.name; |
0 | 94 return split( str, "." )[$-1]; |
95 } | |
96 | |
97 /** | |
98 * Returns a string containing a concise, human-readable | |
99 * description of the receiver. | |
100 * | |
101 * @return a string representation of the event | |
102 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
103 public override String toString() { |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
86
diff
changeset
|
104 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
|
105 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
|
106 return Format( "{}{{time={} data={}}", str_widget, time, str_data ); |
0 | 107 } |
108 } |