|
@@ -1,121 +1,121 @@ |
1 |
|
- |
// This Source Code is Copyright & Licenced as indicated below |
2 |
|
- |
package org.litesoft.GWT.client.widgets.nonpublic.external; |
3 |
|
- |
/* |
4 |
|
- |
* Copyright 2007 Mat Gessel <mat.gessel@gmail.com> |
5 |
|
- |
* |
6 |
|
- |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
7 |
|
- |
* use this file except in compliance with the License. You may obtain a copy of |
8 |
|
- |
* the License at |
9 |
|
- |
* |
10 |
|
- |
* http://www.apache.org/licenses/LICENSE-2.0 |
11 |
|
- |
* |
12 |
|
- |
* Unless required by applicable law or agreed to in writing, software |
13 |
|
- |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
14 |
|
- |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
15 |
|
- |
* License for the specific language governing permissions and limitations under |
16 |
|
- |
* the License. |
17 |
|
- |
*/ |
18 |
|
- |
|
19 |
|
- |
import com.google.gwt.user.client.*; |
20 |
|
- |
import com.google.gwt.user.client.ui.*; |
21 |
|
- |
|
22 |
|
- |
import java.util.*; |
23 |
|
- |
|
24 |
|
- |
/** |
25 |
|
- |
* Contains information used by drag operations to position elements in the UI. |
26 |
|
- |
* Different drag operations require different coordinates, so we pass all |
27 |
|
- |
* coordinates to operations using this object. Also encapsulates coordinate |
28 |
|
- |
* calulations. |
29 |
|
- |
*/ |
30 |
|
- |
public class MouseEvent extends EventObject { |
31 |
|
- |
private static final long serialVersionUID = 2294143695886173892L; |
32 |
|
- |
|
33 |
|
- |
private final Event m_domEvent; |
34 |
|
- |
private final Element m_target; |
35 |
|
- |
private final int m_clientX, m_clientY; |
36 |
|
- |
private final int m_absoluteX, m_absoluteY; |
37 |
|
- |
private final int m_widgetLeft, m_widgetTop; |
38 |
|
- |
private final int m_widgetX, m_widgetY; |
39 |
|
- |
|
40 |
|
- |
protected MouseEvent( MouseEvent e ) { |
41 |
|
- |
super( e.getSource() ); |
42 |
|
- |
m_domEvent = e.m_domEvent; |
43 |
|
- |
m_target = e.m_target; |
44 |
|
- |
m_clientX = e.m_clientX; |
45 |
|
- |
m_clientY = e.m_clientY; |
46 |
|
- |
m_absoluteX = e.m_absoluteX; |
47 |
|
- |
m_absoluteY = e.m_absoluteY; |
48 |
|
- |
m_widgetLeft = e.m_widgetLeft; |
49 |
|
- |
m_widgetTop = e.m_widgetTop; |
50 |
|
- |
m_widgetX = e.m_widgetX; |
51 |
|
- |
m_widgetY = e.m_widgetY; |
52 |
|
- |
} |
53 |
|
- |
|
54 |
|
- |
/** |
55 |
|
- |
* @param receiver the widget which is receiving the mouse event |
56 |
|
- |
* @param mouseEvent a <code>mousedown</code>, <code>mousemove</code> or <code>mouseup</code> event |
57 |
|
- |
* @param previousEvent |
58 |
|
- |
*/ |
59 |
|
- |
public MouseEvent( Widget receiver, Event mouseEvent ) { |
60 |
|
- |
super( receiver ); |
61 |
|
- |
m_domEvent = mouseEvent; |
62 |
|
- |
m_target = DOM.eventGetTarget( mouseEvent ); |
63 |
|
- |
m_clientX = DOM.eventGetClientX( mouseEvent ); |
64 |
|
- |
m_clientY = DOM.eventGetClientY( mouseEvent ); |
65 |
|
- |
m_absoluteX = m_clientX; |
66 |
|
- |
m_absoluteY = m_clientY; |
67 |
|
- |
m_widgetLeft = DOM.getAbsoluteLeft( receiver.getElement() ); |
68 |
|
- |
m_widgetTop = DOM.getAbsoluteTop( receiver.getElement() ); |
69 |
|
- |
|
70 |
|
- |
/* |
71 |
|
- |
* Translate the coordinates into the source widget's coordinate space |
72 |
|
- |
* see MouseListenerCollection.fireMouseEvent() |
73 |
|
- |
*/ |
74 |
|
- |
m_widgetX = m_absoluteX - m_widgetLeft; |
75 |
|
- |
m_widgetY = m_absoluteY - m_widgetTop; |
76 |
|
- |
} |
77 |
|
- |
|
78 |
|
- |
protected int getWidgetLeft() { |
79 |
|
- |
return m_widgetLeft; |
80 |
|
- |
} |
81 |
|
- |
|
82 |
|
- |
protected int getWidgetTop() { |
83 |
|
- |
return m_widgetTop; |
84 |
|
- |
} |
85 |
|
- |
|
86 |
|
- |
public int getClientX() { |
87 |
|
- |
return m_clientX; |
88 |
|
- |
} |
89 |
|
- |
|
90 |
|
- |
public int getClientY() { |
91 |
|
- |
return m_clientY; |
92 |
|
- |
} |
93 |
|
- |
|
94 |
|
- |
public int getWidgetX() { |
95 |
|
- |
return m_widgetX; |
96 |
|
- |
} |
97 |
|
- |
|
98 |
|
- |
public int getWidgetY() { |
99 |
|
- |
return m_widgetY; |
100 |
|
- |
} |
101 |
|
- |
|
102 |
|
- |
public Widget getReceiver() { |
103 |
|
- |
return (Widget) getSource(); |
104 |
|
- |
} |
105 |
|
- |
|
106 |
|
- |
public Element getTarget() { |
107 |
|
- |
return m_target; |
108 |
|
- |
} |
109 |
|
- |
|
110 |
|
- |
public int getAbsoluteX() { |
111 |
|
- |
return m_absoluteX; |
112 |
|
- |
} |
113 |
|
- |
|
114 |
|
- |
public int getAbsoluteY() { |
115 |
|
- |
return m_absoluteY; |
116 |
|
- |
} |
117 |
|
- |
|
118 |
|
- |
public Event getDomEvent() { |
119 |
|
- |
return m_domEvent; |
120 |
|
- |
} |
121 |
|
- |
} |
|
1 |
+ |
// This Source Code is Copyright & Licenced as indicated below |
|
2 |
+ |
package org.litesoft.GWT.client.widgets.nonpublic.external; |
|
3 |
+ |
/* |
|
4 |
+ |
* Copyright 2007 Mat Gessel <mat.gessel@gmail.com> |
|
5 |
+ |
* |
|
6 |
+ |
* Licensed under the Apache License, Version 2.0 (the "License"); you may not |
|
7 |
+ |
* use this file except in compliance with the License. You may obtain a copy of |
|
8 |
+ |
* the License at |
|
9 |
+ |
* |
|
10 |
+ |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
11 |
+ |
* |
|
12 |
+ |
* Unless required by applicable law or agreed to in writing, software |
|
13 |
+ |
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
|
14 |
+ |
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
|
15 |
+ |
* License for the specific language governing permissions and limitations under |
|
16 |
+ |
* the License. |
|
17 |
+ |
*/ |
|
18 |
+ |
|
|
19 |
+ |
import com.google.gwt.user.client.*; |
|
20 |
+ |
import com.google.gwt.user.client.ui.*; |
|
21 |
+ |
|
|
22 |
+ |
import java.util.*; |
|
23 |
+ |
|
|
24 |
+ |
/** |
|
25 |
+ |
* Contains information used by drag operations to position elements in the UI. |
|
26 |
+ |
* Different drag operations require different coordinates, so we pass all |
|
27 |
+ |
* coordinates to operations using this object. Also encapsulates coordinate |
|
28 |
+ |
* calulations. |
|
29 |
+ |
*/ |
|
30 |
+ |
public class MouseEvent extends EventObject { |
|
31 |
+ |
private static final long serialVersionUID = 2294143695886173892L; |
|
32 |
+ |
|
|
33 |
+ |
private final Event m_domEvent; |
|
34 |
+ |
private final Element m_target; |
|
35 |
+ |
private final int m_clientX, m_clientY; |
|
36 |
+ |
private final int m_absoluteX, m_absoluteY; |
|
37 |
+ |
private final int m_widgetLeft, m_widgetTop; |
|
38 |
+ |
private final int m_widgetX, m_widgetY; |
|
39 |
+ |
|
|
40 |
+ |
protected MouseEvent( MouseEvent e ) { |
|
41 |
+ |
super( e.getSource() ); |
|
42 |
+ |
m_domEvent = e.m_domEvent; |
|
43 |
+ |
m_target = e.m_target; |
|
44 |
+ |
m_clientX = e.m_clientX; |
|
45 |
+ |
m_clientY = e.m_clientY; |
|
46 |
+ |
m_absoluteX = e.m_absoluteX; |
|
47 |
+ |
m_absoluteY = e.m_absoluteY; |
|
48 |
+ |
m_widgetLeft = e.m_widgetLeft; |
|
49 |
+ |
m_widgetTop = e.m_widgetTop; |
|
50 |
+ |
m_widgetX = e.m_widgetX; |
|
51 |
+ |
m_widgetY = e.m_widgetY; |
|
52 |
+ |
} |
|
53 |
+ |
|
|
54 |
+ |
/** |
|
55 |
+ |
* @param receiver the widget which is receiving the mouse event |
|
56 |
+ |
* @param mouseEvent a <code>mousedown</code>, <code>mousemove</code> or <code>mouseup</code> event |
|
57 |
+ |
* @param previousEvent |
|
58 |
+ |
*/ |
|
59 |
+ |
public MouseEvent( Widget receiver, Event mouseEvent ) { |
|
60 |
+ |
super( receiver ); |
|
61 |
+ |
m_domEvent = mouseEvent; |
|
62 |
+ |
m_target = DOM.eventGetTarget( mouseEvent ); |
|
63 |
+ |
m_clientX = DOM.eventGetClientX( mouseEvent ); |
|
64 |
+ |
m_clientY = DOM.eventGetClientY( mouseEvent ); |
|
65 |
+ |
m_absoluteX = m_clientX; |
|
66 |
+ |
m_absoluteY = m_clientY; |
|
67 |
+ |
m_widgetLeft = DOM.getAbsoluteLeft( receiver.getElement() ); |
|
68 |
+ |
m_widgetTop = DOM.getAbsoluteTop( receiver.getElement() ); |
|
69 |
+ |
|
|
70 |
+ |
/* |
|
71 |
+ |
* Translate the coordinates into the source widget's coordinate space |
|
72 |
+ |
* see MouseListenerCollection.fireMouseEvent() |
|
73 |
+ |
*/ |
|
74 |
+ |
m_widgetX = m_absoluteX - m_widgetLeft; |
|
75 |
+ |
m_widgetY = m_absoluteY - m_widgetTop; |
|
76 |
+ |
} |
|
77 |
+ |
|
|
78 |
+ |
protected int getWidgetLeft() { |
|
79 |
+ |
return m_widgetLeft; |
|
80 |
+ |
} |
|
81 |
+ |
|
|
82 |
+ |
protected int getWidgetTop() { |
|
83 |
+ |
return m_widgetTop; |
|
84 |
+ |
} |
|
85 |
+ |
|
|
86 |
+ |
public int getClientX() { |
|
87 |
+ |
return m_clientX; |
|
88 |
+ |
} |
|
89 |
+ |
|
|
90 |
+ |
public int getClientY() { |
|
91 |
+ |
return m_clientY; |
|
92 |
+ |
} |
|
93 |
+ |
|
|
94 |
+ |
public int getWidgetX() { |
|
95 |
+ |
return m_widgetX; |
|
96 |
+ |
} |
|
97 |
+ |
|
|
98 |
+ |
public int getWidgetY() { |
|
99 |
+ |
return m_widgetY; |
|
100 |
+ |
} |
|
101 |
+ |
|
|
102 |
+ |
public Widget getReceiver() { |
|
103 |
+ |
return (Widget) getSource(); |
|
104 |
+ |
} |
|
105 |
+ |
|
|
106 |
+ |
public Element getTarget() { |
|
107 |
+ |
return m_target; |
|
108 |
+ |
} |
|
109 |
+ |
|
|
110 |
+ |
public int getAbsoluteX() { |
|
111 |
+ |
return m_absoluteX; |
|
112 |
+ |
} |
|
113 |
+ |
|
|
114 |
+ |
public int getAbsoluteY() { |
|
115 |
+ |
return m_absoluteY; |
|
116 |
+ |
} |
|
117 |
+ |
|
|
118 |
+ |
public Event getDomEvent() { |
|
119 |
+ |
return m_domEvent; |
|
120 |
+ |
} |
|
121 |
+ |
} |