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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
1 /*******************************************************************************
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
2 * Copyright (c) 2000, 2007 IBM Corporation and others.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
5 * which accompanies this distribution, and is available at
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
7 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
8 * Contributors:
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
10 * Port to the D programming language:
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
12 *******************************************************************************/
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
13 module dwt.events.TypedEvent;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
14
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
15
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
16 import dwt.widgets.Event;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
17 import dwt.widgets.Display;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
18 import dwt.widgets.Widget;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
19 import dwt.internal.DWTEventObject;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
20
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
21 import tango.text.convert.Format;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
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
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
24
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
25 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
26 * This is the super class for all typed event classes provided
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
27 * by DWT. Typed events contain particular information which is
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
28 * applicable to the event occurrence.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
29 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
30 * @see dwt.widgets.Event
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
31 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
32 public class TypedEvent : DWTEventObject {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
33
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
34 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
35 * the display where the event occurred
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
36 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
37 * @since 2.0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
38 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
39 public Display display;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
40
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
41 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
42 * the widget that issued the event
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
43 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
44 public Widget widget;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
45
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
46 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
47 * the time that the event occurred.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
48 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
49 * NOTE: This field is an unsigned integer and should
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
50 * be AND'ed with 0xFFFFFFFFL so that it can be treated
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
51 * as a signed long.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
52 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
53 public int time;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
54
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
55 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
56 * a field for application use
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
57 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
58 public Object data;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
59
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
60 //static final long serialVersionUID = 3257285846578377524L;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
61
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
62 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
63 * Constructs a new instance of this class.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
64 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
65 * @param object the object that fired the event
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
66 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
67 public this(Object object) {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
68 super(object);
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
69 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
70
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
71 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
72 * Constructs a new instance of this class based on the
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
73 * information in the argument.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
74 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
75 * @param e the low level event to initialize the receiver with
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
76 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
77 public this(Event e) {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
78 super(e.widget);
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
79 this.display = e.display;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
80 this.widget = e.widget;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
81 this.time = e.time;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
82 this.data = e.data;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
83 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
84
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
85 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
86 * Returns the name of the event. This is the name of
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
87 * the class without the module name.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
88 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
89 * @return the name of the event
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
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
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
93 return split( str, "." )[$-1];
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
94 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
95
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
96 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
97 * Returns a string containing a concise, human-readable
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
98 * description of the receiver.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
99 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
100 * @return a string representation of the event
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
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
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
106 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
107 }