I am trying to redraw my layout when the user resizes the window.
You can see it running here: https://dev.3dmathpuzzles.com/3dmp/D...therlink2.html
The div containing the layout has a green border. It resizes when the window resizes.
My WindowResizeHandler is getting called when I resize the window (I get a Window alert), but the onDraw method of the LayoutHandler is not getting called.
Here is a sample application:
Here is the WindowResizeHandler:
Here is the draw handler:
You can see it running here: https://dev.3dmathpuzzles.com/3dmp/D...therlink2.html
The div containing the layout has a green border. It resizes when the window resizes.
My WindowResizeHandler is getting called when I resize the window (I get a Window alert), but the onDraw method of the LayoutHandler is not getting called.
Here is a sample application:
Code:
package com._3dmathpuzzles.gwt.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.Window; import com.smartgwt.client.widgets.drawing.DrawPane; import com.smartgwt.client.widgets.layout.VLayout; public class DiagonalSlitherlink2 implements EntryPoint { private DrawPane drawPane; public void onModuleLoad() { drawPane = new DrawPane(); drawPane.setShowEdges(true); drawPane.setEdgeSize(1); drawPane.setCanDragScroll(true); drawPane.setZoomLevel(1.0); drawPane.addDrawHandler(new DiagonalSlitherlinkDrawHandler2()); Element gwtElement = Document.get().getElementById("gwt"); VLayout layout = new VLayout(); layout.addDrawHandler(new LayoutDrawHandler()); layout.addDrawHandler(new ButtonDrawHandler(drawPane)); layout.setHtmlElement(gwtElement); layout.addMember(drawPane); layout.setLayoutMargin(0); layout.setMembersMargin(0); layout.setRedrawOnResize(true); layout.draw(); Window.addResizeHandler(new WindowResizeHandler(layout,drawPane)); } }
Code:
package com._3dmathpuzzles.gwt.client; import com.google.gwt.event.logical.shared.ResizeEvent; import com.google.gwt.event.logical.shared.ResizeHandler; import com.google.gwt.user.client.Window; import com.smartgwt.client.widgets.drawing.DrawPane; import com.smartgwt.client.widgets.layout.Layout; public class WindowResizeHandler implements ResizeHandler { private Layout layout; private DrawPane drawPane; public WindowResizeHandler(Layout layout, DrawPane drawPane) { this.layout = layout; this.drawPane = drawPane; } public void onResize(ResizeEvent event) { Window.alert("In WindowResizeHandler.onResize()"); layout.markForRedraw(); layout.redraw(); layout.draw(); drawPane.markForRedraw(); drawPane.redraw(); drawPane.draw(); } }
Code:
package com._3dmathpuzzles.gwt.client; import com.smartgwt.client.widgets.drawing.DrawLine; import com.smartgwt.client.widgets.drawing.DrawPane; import com.smartgwt.client.widgets.drawing.Point; import com.smartgwt.client.widgets.events.DrawEvent; import com.smartgwt.client.widgets.events.DrawHandler; public class DiagonalSlitherlinkDrawHandler2 implements DrawHandler { public void onDraw(DrawEvent event) { DrawPane drawPane = (DrawPane) event.getSource(); DrawLine drawLine = new DrawLine(); drawLine.setStartPoint(new Point(0,0)); drawLine.setEndPoint(new Point(1000,1000)); drawLine.setDrawPane(drawPane); drawLine.draw(); } }
Comment