package gwt.client;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.util.SC;
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.drawing.events.ClickEvent;
import com.smartgwt.client.widgets.drawing.events.ClickHandler;
import com.smartgwt.client.widgets.events.DrawEvent;
import com.smartgwt.client.widgets.events.DrawHandler;

public class ZIndexTest implements EntryPoint {
  class MyClickHandler implements ClickHandler {
    public void onClick(ClickEvent event) {
      DrawLine drawLine = (DrawLine)event.getSource();
      SC.logWarn("Calling erase on "+drawLine);
      drawLine.erase();
    }
  }
  
  public void onModuleLoad() {
    DrawPane drawPane = new DrawPane();
    drawPane.addDrawHandler(new DrawHandler() {
      public void onDraw(DrawEvent event) {
        DrawLine drawLine = new DrawLine();
        drawLine.addClickHandler(new MyClickHandler());
        drawLine.setDrawPane(drawPane);
        drawLine.setStartPoint(new Point(250,0));
        drawLine.setEndPoint(new Point(250,500));
        drawLine.setLineColor("#ff0000");
        drawLine.setLineWidth(20);
        drawLine.draw();

        drawLine = new DrawLine();
        drawLine.addClickHandler(new MyClickHandler());
        drawLine.setDrawPane(drawPane);
        drawLine.setStartPoint(new Point(0,250));
        drawLine.setEndPoint(new Point(500,250));
        drawLine.setLineColor("#00ff00");
        drawLine.setLineWidth(20);
        drawLine.draw();
      }
    });
    drawPane.setCanDragScroll(true);
    drawPane.setEdgeSize(5);
    drawPane.setEdgeOpacity(25);
    drawPane.setShowEdges(true);
    drawPane.setZoomLevel(1.0);
    drawPane.setWidth(1200);
    drawPane.setHeight(750);
    drawPane.draw();    
  }
}
