Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -1,124 +1,124 @@
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.core.client.*;
20 - import com.google.gwt.user.client.*;
21 -
22 - /**
23 - * Converts {@link MouseEvent}s to {@link DragEvent}s and delegates to the
24 - * specified {@link DragGesture}.
25 - */
26 - public class MouseDragHandler extends MouseHandlerAdaptor {
27 - private static MouseDragHandlerImpl s_Impl = (MouseDragHandlerImpl) GWT.create( MouseDragHandlerImpl.class );
28 -
29 - private DragGesture m_dragGesture;
30 - private MouseEvent m_mouseDown = null;
31 - private MouseEvent m_previousEvent = null;
32 -
33 - public MouseDragHandler( DragGesture dragGesture ) {
34 - super( Event.ONMOUSEDOWN | Event.ONMOUSEMOVE | Event.ONMOUSEUP );
35 - m_dragGesture = dragGesture;
36 - }
37 -
38 - protected MouseEvent getMouseDown() {
39 - return m_mouseDown;
40 - }
41 -
42 - protected MouseEvent getPreviousEvent() {
43 - return m_previousEvent;
44 - }
45 -
46 - /**
47 - * Get the delegate object which will handle drag operations.
48 - */
49 - public DragGesture getDragGesture() {
50 - return m_dragGesture;
51 - }
52 -
53 - /**
54 - * Set the delegate object which will handle drag operations.
55 - */
56 - public void setDragGesture( DragGesture dragGesture ) {
57 - m_dragGesture = dragGesture;
58 - }
59 -
60 - @Override
61 - public void onMouseDown( MouseEvent e ) {
62 - DOM.eventCancelBubble( e.getDomEvent(), true );
63 - s_Impl.onMouseDown( e.getDomEvent() );
64 -
65 - if ( m_dragGesture != null ) {
66 - m_mouseDown = e;
67 - m_dragGesture.start( e );
68 - m_previousEvent = e;
69 - }
70 - }
71 -
72 - @Override
73 - public void onMouseMove( MouseEvent e ) {
74 - if ( m_mouseDown != null ) {
75 - m_dragGesture.step( new DragEvent( e, m_mouseDown, m_previousEvent ) );
76 - m_previousEvent = e;
77 - }
78 - }
79 -
80 - @Override
81 - public void onMouseUp( MouseEvent e ) {
82 - // it is possible to get a mouse up without a mouse down
83 - if ( m_mouseDown != null ) {
84 - // clear MD first to prevent reentrancy
85 - m_mouseDown = null;
86 - m_dragGesture.finish();
87 - m_previousEvent = null;
88 - }
89 -
90 - if ( e != null ) {
91 - s_Impl.onMouseUp( e.getDomEvent() );
92 - }
93 - }
94 -
95 - protected static class MouseDragHandlerImpl {
96 - public void onMouseDown( Event event ) {
97 - // prevents text selection and image dragging in Mozilla, Safari & Opera
98 - DOM.eventPreventDefault( event );
99 - }
100 -
101 - public void onMouseUp( Event event ) {
102 - }
103 - }
104 -
105 - protected static class MouseDragHandlerImplIE6 extends MouseDragHandlerImpl {
106 - @Override
107 - public native void onMouseDown( Event event ) /*-{
108 - $doc.body.onselectstart = function ()
109 - {
110 - return false;
111 - };
112 - $doc.body.ondragstart = function ()
113 - {
114 - return false;
115 - };
116 - }-*/;
117 -
118 - @Override
119 - public native void onMouseUp( Event event ) /*-{
120 - $doc.body.onselectstart = null;
121 - $doc.body.ondragstart = null;
122 - }-*/;
123 - }
124 - }
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.core.client.*;
20 + import com.google.gwt.user.client.*;
21 +
22 + /**
23 + * Converts {@link MouseEvent}s to {@link DragEvent}s and delegates to the
24 + * specified {@link DragGesture}.
25 + */
26 + public class MouseDragHandler extends MouseHandlerAdaptor {
27 + private static MouseDragHandlerImpl s_Impl = (MouseDragHandlerImpl) GWT.create( MouseDragHandlerImpl.class );
28 +
29 + private DragGesture m_dragGesture;
30 + private MouseEvent m_mouseDown = null;
31 + private MouseEvent m_previousEvent = null;
32 +
33 + public MouseDragHandler( DragGesture dragGesture ) {
34 + super( Event.ONMOUSEDOWN | Event.ONMOUSEMOVE | Event.ONMOUSEUP );
35 + m_dragGesture = dragGesture;
36 + }
37 +
38 + protected MouseEvent getMouseDown() {
39 + return m_mouseDown;
40 + }
41 +
42 + protected MouseEvent getPreviousEvent() {
43 + return m_previousEvent;
44 + }
45 +
46 + /**
47 + * Get the delegate object which will handle drag operations.
48 + */
49 + public DragGesture getDragGesture() {
50 + return m_dragGesture;
51 + }
52 +
53 + /**
54 + * Set the delegate object which will handle drag operations.
55 + */
56 + public void setDragGesture( DragGesture dragGesture ) {
57 + m_dragGesture = dragGesture;
58 + }
59 +
60 + @Override
61 + public void onMouseDown( MouseEvent e ) {
62 + DOM.eventCancelBubble( e.getDomEvent(), true );
63 + s_Impl.onMouseDown( e.getDomEvent() );
64 +
65 + if ( m_dragGesture != null ) {
66 + m_mouseDown = e;
67 + m_dragGesture.start( e );
68 + m_previousEvent = e;
69 + }
70 + }
71 +
72 + @Override
73 + public void onMouseMove( MouseEvent e ) {
74 + if ( m_mouseDown != null ) {
75 + m_dragGesture.step( new DragEvent( e, m_mouseDown, m_previousEvent ) );
76 + m_previousEvent = e;
77 + }
78 + }
79 +
80 + @Override
81 + public void onMouseUp( MouseEvent e ) {
82 + // it is possible to get a mouse up without a mouse down
83 + if ( m_mouseDown != null ) {
84 + // clear MD first to prevent reentrancy
85 + m_mouseDown = null;
86 + m_dragGesture.finish();
87 + m_previousEvent = null;
88 + }
89 +
90 + if ( e != null ) {
91 + s_Impl.onMouseUp( e.getDomEvent() );
92 + }
93 + }
94 +
95 + protected static class MouseDragHandlerImpl {
96 + public void onMouseDown( Event event ) {
97 + // prevents text selection and image dragging in Mozilla, Safari & Opera
98 + DOM.eventPreventDefault( event );
99 + }
100 +
101 + public void onMouseUp( Event event ) {
102 + }
103 + }
104 +
105 + protected static class MouseDragHandlerImplIE6 extends MouseDragHandlerImpl {
106 + @Override
107 + public native void onMouseDown( Event event ) /*-{
108 + $doc.body.onselectstart = function ()
109 + {
110 + return false;
111 + };
112 + $doc.body.ondragstart = function ()
113 + {
114 + return false;
115 + };
116 + }-*/;
117 +
118 + @Override
119 + public native void onMouseUp( Event event ) /*-{
120 + $doc.body.onselectstart = null;
121 + $doc.body.ondragstart = null;
122 + }-*/;
123 + }
124 + }