changeset 4570:8ca06d3040d0

flys-client: Map.updateSize() is now called on every windows movement which fixes the cursor offset problem (flys/#422).
author Christian Lins <christian.lins@intevation.de>
date Tue, 20 Nov 2012 14:30:33 +0100
parents 276d9bd3c77d
children 95e23bcf6a50
files flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java
diffstat 2 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Tue Nov 20 12:53:14 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapOutputTab.java	Tue Nov 20 14:30:33 2012 +0100
@@ -3,9 +3,10 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.AbsolutePanel;
-
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.events.ParentMovedEvent;
+import com.smartgwt.client.widgets.events.ParentMovedHandler;
 import com.smartgwt.client.widgets.events.ResizedEvent;
 import com.smartgwt.client.widgets.events.ResizedHandler;
 import com.smartgwt.client.widgets.layout.HLayout;
@@ -164,6 +165,13 @@
             }
         });
 
+        rootLayout.addParentMovedHandler(new ParentMovedHandler() {
+            @Override
+            public void onParentMoved(ParentMovedEvent event) {
+                mapPanel.getMap().updateSize();
+            }
+        });
+
         setPane(rootLayout);
     }
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Tue Nov 20 12:53:14 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPanel.java	Tue Nov 20 14:30:33 2012 +0100
@@ -1,7 +1,10 @@
 package de.intevation.flys.client.client.ui.map;
 
 import com.google.gwt.core.client.GWT;
-
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.WidgetCanvas;
+import com.smartgwt.client.widgets.events.ParentMovedEvent;
+import com.smartgwt.client.widgets.events.ParentMovedHandler;
 import com.smartgwt.client.widgets.events.ResizedEvent;
 import com.smartgwt.client.widgets.events.ResizedHandler;
 import com.smartgwt.client.widgets.layout.VLayout;
@@ -52,14 +55,34 @@
         addMember(floodMapWidget);
 
         addResizedHandler(new ResizedHandler() {
-
             @Override
             public void onResized(ResizedEvent event) {
                 doLayout();
             }
         });
+
+        addParentMovedHandler(new ParentMovedHandler() {
+            @Override
+            public void onParentMoved(ParentMovedEvent event) {
+                floodMapWidget.getMap().updateSize();
+            }
+        });
     }
 
+    /**
+     * Due to the fact that SmartGWT Layout misses a removeMember(Widget)
+     * method we use this method to remove all WidgetCanvas members.
+     * WidgetCanvas is the wrapper class used by Layout to handle Widget
+     * objects.
+     */
+    protected void removeWidgetCanvasMember() {
+        Canvas[] allCanvas = getMembers();
+        for (Canvas canvas : allCanvas) {
+            if (canvas instanceof WidgetCanvas) {
+                removeMember(canvas);
+            }
+        }
+    }
 
     protected void doLayout() {
         int width = getWidth();
@@ -69,6 +92,12 @@
         width -= 2; // minus black borders
         height -= toolbar.getHeight() + 4;
 
+        // Recreate Map widget
+        /*removeWidgetCanvasMember();
+        floodMap.recreateWidget(width, height);
+        floodMapWidget = floodMap.getMapWidget();
+        addMember(floodMapWidget);
+*/
         floodMapWidget.setSize(Integer.toString(width), Integer.toString(height));
         floodMapWidget.getMap().updateSize();
     }

http://dive4elements.wald.intevation.org