Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/GWT/Client/src/org/litesoft/GWT/client/widgets/nonpublic/external/DragEvent.java

Diff revisions: vs.
  @@ -1,84 +1,84 @@
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 - /**
20 - * Contains information used by drag operations to position elements in the UI.
21 - * Different drag operations require different coordinates, so we pass all
22 - * coordinates to operations using this object. Also encapsulates coordinate
23 - * calulations.
24 - */
25 - /*
26 - * Extends MouseEvent so that both types may be used polymorphically. For
27 - * example, a slider will process both mouse down and mouse drag (but not mouse
28 - * move).
29 - */
30 - public class DragEvent extends MouseEvent {
31 - private static final long serialVersionUID = -60876731058183754L;
32 -
33 - private final int m_deltaX, m_deltaY;
34 - private final int m_cumulativeX, m_cumulativeY;
35 -
36 - /**
37 - * @param receiver the widget which is receiving the mouse event
38 - * @param mouseEvent a <code>mousedown</code>, <code>mousemove</code> or <code>mouseup</code> event
39 - * @param previousEvent
40 - */
41 - public DragEvent( MouseEvent mouseMove, MouseEvent mouseDown, MouseEvent previousEvent ) {
42 - super( mouseMove );
43 -
44 - if ( previousEvent != null ) {
45 - /*
46 - * Calculate the delta relative to the last event, adjusting for a
47 - * possibly moving coordinate space
48 - */
49 - m_deltaX = mouseMove.getWidgetLeft() - previousEvent.getWidgetLeft() + mouseMove.getWidgetX() - previousEvent.getWidgetX();
50 - m_deltaY = mouseMove.getWidgetTop() - previousEvent.getWidgetTop() + mouseMove.getWidgetY() - previousEvent.getWidgetY();
51 - m_cumulativeX = mouseMove.getWidgetX() - mouseDown.getWidgetX();
52 - m_cumulativeY = mouseMove.getWidgetY() - mouseDown.getWidgetY();
53 - } else {
54 - m_deltaX = m_deltaY = 0;
55 - m_cumulativeX = m_cumulativeY = 0;
56 - }
57 - }
58 -
59 - /**
60 - * Get the distance moved horizontally, relative to the last event. Returns
61 - * a useful value even if the document is scrolled or the widget has moved
62 - * since the last event.
63 - */
64 - public int getDeltaX() {
65 - return m_deltaX;
66 - }
67 -
68 - /**
69 - * Get the distance moved vertically, relative to the last event. Returns
70 - * a useful value even if the document is scrolled or the widget has moved
71 - * since the last event.
72 - */
73 - public int getDeltaY() {
74 - return m_deltaY;
75 - }
76 -
77 - public int getCumulativeX() {
78 - return m_cumulativeX;
79 - }
80 -
81 - public int getCumulativeY() {
82 - return m_cumulativeY;
83 - }
84 - }
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 + /**
20 + * Contains information used by drag operations to position elements in the UI.
21 + * Different drag operations require different coordinates, so we pass all
22 + * coordinates to operations using this object. Also encapsulates coordinate
23 + * calulations.
24 + */
25 + /*
26 + * Extends MouseEvent so that both types may be used polymorphically. For
27 + * example, a slider will process both mouse down and mouse drag (but not mouse
28 + * move).
29 + */
30 + public class DragEvent extends MouseEvent {
31 + private static final long serialVersionUID = -60876731058183754L;
32 +
33 + private final int m_deltaX, m_deltaY;
34 + private final int m_cumulativeX, m_cumulativeY;
35 +
36 + /**
37 + * @param receiver the widget which is receiving the mouse event
38 + * @param mouseEvent a <code>mousedown</code>, <code>mousemove</code> or <code>mouseup</code> event
39 + * @param previousEvent
40 + */
41 + public DragEvent( MouseEvent mouseMove, MouseEvent mouseDown, MouseEvent previousEvent ) {
42 + super( mouseMove );
43 +
44 + if ( previousEvent != null ) {
45 + /*
46 + * Calculate the delta relative to the last event, adjusting for a
47 + * possibly moving coordinate space
48 + */
49 + m_deltaX = mouseMove.getWidgetLeft() - previousEvent.getWidgetLeft() + mouseMove.getWidgetX() - previousEvent.getWidgetX();
50 + m_deltaY = mouseMove.getWidgetTop() - previousEvent.getWidgetTop() + mouseMove.getWidgetY() - previousEvent.getWidgetY();
51 + m_cumulativeX = mouseMove.getWidgetX() - mouseDown.getWidgetX();
52 + m_cumulativeY = mouseMove.getWidgetY() - mouseDown.getWidgetY();
53 + } else {
54 + m_deltaX = m_deltaY = 0;
55 + m_cumulativeX = m_cumulativeY = 0;
56 + }
57 + }
58 +
59 + /**
60 + * Get the distance moved horizontally, relative to the last event. Returns
61 + * a useful value even if the document is scrolled or the widget has moved
62 + * since the last event.
63 + */
64 + public int getDeltaX() {
65 + return m_deltaX;
66 + }
67 +
68 + /**
69 + * Get the distance moved vertically, relative to the last event. Returns
70 + * a useful value even if the document is scrolled or the widget has moved
71 + * since the last event.
72 + */
73 + public int getDeltaY() {
74 + return m_deltaY;
75 + }
76 +
77 + public int getCumulativeX() {
78 + return m_cumulativeX;
79 + }
80 +
81 + public int getCumulativeY() {
82 + return m_cumulativeY;
83 + }
84 + }