comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/PanControl.java @ 553:c5fc3fa02edb

The MouseOut event will now finish a current pan operation. flys-client/trunk@2067 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 07 Jun 2011 13:58:38 +0000
parents 13c7f90917fc
children ea2191b1299d
comparison
equal deleted inserted replaced
552:6050d49eaba3 553:c5fc3fa02edb
6 import com.google.gwt.core.client.GWT; 6 import com.google.gwt.core.client.GWT;
7 7
8 import com.smartgwt.client.types.Overflow; 8 import com.smartgwt.client.types.Overflow;
9 import com.smartgwt.client.types.SelectionType; 9 import com.smartgwt.client.types.SelectionType;
10 import com.smartgwt.client.widgets.Canvas; 10 import com.smartgwt.client.widgets.Canvas;
11 import com.smartgwt.client.widgets.Img;
11 import com.smartgwt.client.widgets.ImgButton; 12 import com.smartgwt.client.widgets.ImgButton;
12 import com.smartgwt.client.widgets.events.MouseDownEvent; 13 import com.smartgwt.client.widgets.events.MouseDownEvent;
13 import com.smartgwt.client.widgets.events.MouseDownHandler; 14 import com.smartgwt.client.widgets.events.MouseDownHandler;
14 import com.smartgwt.client.widgets.events.MouseMoveEvent; 15 import com.smartgwt.client.widgets.events.MouseMoveEvent;
15 import com.smartgwt.client.widgets.events.MouseMoveHandler; 16 import com.smartgwt.client.widgets.events.MouseMoveHandler;
145 * This event is used to cancel the current dragging operation. 146 * This event is used to cancel the current dragging operation.
146 * 147 *
147 * @param event The mouse out event. 148 * @param event The mouse out event.
148 */ 149 */
149 public void onMouseOut(MouseOutEvent event) { 150 public void onMouseOut(MouseOutEvent event) {
150 // TODO Cancel dragging if mouse pointer leaves chart area 151 int x = event.getX();
152 int y = event.getY();
153
154 if (!isSelected() || !isMouseOut(x, y) || start[0] == -1) {
155 return;
156 }
157
158 Canvas parent = chartTab.getChartPanel().getParentElement();
159 parent.setOverflow(Overflow.AUTO);
160
161 fireOnPan();
162
163 start[0] = -1;
164 start[1] = -1;
165 }
166
167
168 /**
169 * This method is required to check manually if the mouse pointer really
170 * moves out the chart area. The MouseOutEvent is also fired if the mouse
171 * goes down which doesn't seem to be correct. So, we gonna check this
172 * manually.
173 *
174 * @param x The x coordinate.
175 * @param y The y coordinate.
176 *
177 * @return true, if the mouse is really out of the chart area, otherwise
178 * false.
179 */
180 protected boolean isMouseOut(int x, int y) {
181 Canvas chart = chartTab.getChartPanel();
182
183 if (chart instanceof Img) {
184 chart = chart.getParentElement();
185 }
186
187 int left = chart.getPageLeft();
188 int right = chart.getPageRight();
189 int top = chart.getPageTop();
190 int bottom = chart.getPageBottom();
191
192 if (x <= left || x >= right || y <= top || y >= bottom) {
193 return true;
194 }
195
196 return false;
151 } 197 }
152 198
153 199
154 /** 200 /**
155 * A pan event is fired to inform the registered listeners about a pan 201 * A pan event is fired to inform the registered listeners about a pan

http://dive4elements.wald.intevation.org