Mercurial > projects > dwt-mac
comparison dwt/events/MouseEvent.d @ 34:5123b17c98ef
Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sun, 14 Sep 2008 01:45:57 +0200 |
parents | 1a8b3cb347e0 |
children | 43be986a1372 |
comparison
equal
deleted
inserted
replaced
33:965ac0a77267 | 34:5123b17c98ef |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
10 *******************************************************************************/ | 12 *******************************************************************************/ |
11 module dwt.events.MouseEvent; | 13 module dwt.events.MouseEvent; |
12 | 14 |
13 import dwt.dwthelper.utils; | 15 import dwt.dwthelper.utils; |
14 | 16 |
15 | 17 |
16 import dwt.widgets.Event; | 18 import dwt.widgets.Event; |
19 import dwt.events.TypedEvent; | |
20 | |
21 import tango.text.convert.Format; | |
17 | 22 |
18 /** | 23 /** |
19 * Instances of this class are sent whenever mouse | 24 * Instances of this class are sent whenever mouse |
20 * related actions occur. This includes mouse buttons | 25 * related actions occur. This includes mouse buttons |
21 * being pressed and released, the mouse pointer being | 26 * being pressed and released, the mouse pointer being |
22 * moved and the mouse pointer crossing widget boundaries. | 27 * moved and the mouse pointer crossing widget boundaries. |
23 * <p> | 28 * <p> |
24 * Note: The <code>button</code> field is an integer that | 29 * Note: The <code>button</code> field is an integer that |
25 * represents the mouse button number. This is not the same | 30 * represents the mouse button number. This is not the same |
26 * as the <code>DWT</code> mask constants <code>BUTTONx</code>. | 31 * as the <code>DWT</code> mask constants <code>BUTTONx</code>. |
27 * </p> | 32 * </p> |
28 * | 33 * |
29 * @see MouseListener | 34 * @see MouseListener |
30 * @see MouseMoveListener | 35 * @see MouseMoveListener |
31 * @see MouseTrackListener | 36 * @see MouseTrackListener |
37 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
32 */ | 38 */ |
33 | 39 |
34 public class MouseEvent : TypedEvent { | 40 public class MouseEvent : TypedEvent { |
35 | 41 |
36 /** | 42 /** |
37 * the button that was pressed or released; 1 for the | 43 * the button that was pressed or released; 1 for the |
38 * first button, 2 for the second button, and 3 for the | 44 * first button, 2 for the second button, and 3 for the |
39 * third button, etc. | 45 * third button, etc. |
40 */ | 46 */ |
41 public int button; | 47 public int button; |
42 | 48 |
43 /** | 49 /** |
44 * the state of the keyboard modifier keys at the time | 50 * the state of the keyboard modifier keys at the time |
45 * the event was generated | 51 * the event was generated |
46 */ | 52 */ |
47 public int stateMask; | 53 public int stateMask; |
48 | 54 |
49 /** | 55 /** |
50 * the widget-relative, x coordinate of the pointer | 56 * the widget-relative, x coordinate of the pointer |
51 * at the time the mouse button was pressed or released | 57 * at the time the mouse button was pressed or released |
52 */ | 58 */ |
53 public int x; | 59 public int x; |
54 | 60 |
55 /** | 61 /** |
56 * the widget-relative, y coordinate of the pointer | 62 * the widget-relative, y coordinate of the pointer |
57 * at the time the mouse button was pressed or released | 63 * at the time the mouse button was pressed or released |
58 */ | 64 */ |
59 public int y; | 65 public int y; |
60 | 66 |
61 /** | 67 /** |
62 * the number times the mouse has been clicked, as defined | 68 * the number times the mouse has been clicked, as defined |
63 * by the operating system; 1 for the first click, 2 for the | 69 * by the operating system; 1 for the first click, 2 for the |
64 * second click and so on. | 70 * second click and so on. |
65 * | 71 * |
66 * @since 3.3 | 72 * @since 3.3 |
67 */ | 73 */ |
68 public int count; | 74 public int count; |
69 | 75 |
70 static final long serialVersionUID = 3257288037011566898L; | 76 //static final long serialVersionUID = 3257288037011566898L; |
71 | 77 |
72 /** | 78 /** |
73 * Constructs a new instance of this class based on the | 79 * Constructs a new instance of this class based on the |
74 * information in the given untyped event. | 80 * information in the given untyped event. |
75 * | 81 * |
76 * @param e the untyped event containing the information | 82 * @param e the untyped event containing the information |
88 * Returns a string containing a concise, human-readable | 94 * Returns a string containing a concise, human-readable |
89 * description of the receiver. | 95 * description of the receiver. |
90 * | 96 * |
91 * @return a string representation of the event | 97 * @return a string representation of the event |
92 */ | 98 */ |
93 public String toString() { | 99 public override String toString() { |
94 String string = super.toString (); | 100 return Format( "{} button={} stateMask={} x={} y={} count={}}", |
95 return string.substring (0, string.length() - 1) // remove trailing '}' | 101 super.toString[ 0 .. $-1 ], |
96 + " button=" + button | 102 button, stateMask, x, y, count ); |
97 + " stateMask=" + stateMask | |
98 + " x=" + x | |
99 + " y=" + y | |
100 + " count=" + count | |
101 + "}"; | |
102 } | 103 } |
103 } | 104 } |