/* * Smart GWT (GWT for SmartClient) * Copyright 2008 and beyond, Isomorphic Software, Inc. * * Smart GWT is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. Smart GWT is also * available under typical commercial license terms - see * http://smartclient.com/license * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import com.smartgwt.client.types.Alignment; import com.smartgwt.client.types.DragAppearance; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Img; import com.smartgwt.client.widgets.layout.HStack; import com.smartgwt.client.widgets.layout.VStack; import com.google.gwt.core.client.EntryPoint; public class DragMoveImageSample implements EntryPoint { public void onModuleLoad() { HStack hStack = new HStack(10); hStack.setLayoutMargin(10); hStack.setLeft(120); hStack.setShowEdges(true); hStack.setEdgeImage("edges/blue/6.png"); hStack.setCanAcceptDrop(true); hStack.setAnimateMembers(true); hStack.setShowDragPlaceHolder(true); hStack.setBorder("1px solid #4040ff"); hStack.addMember(new DragPiece("cube_blue.png")); hStack.addMember(new DragPiece("cube_green.png")); hStack.addMember(new DragPiece("cube_yellow.png")); VStack vStack = new VStack(10); vStack.setLayoutMargin(10); vStack.setShowEdges(true); vStack.setEdgeImage("edges/green/6.png"); vStack.setCanAcceptDrop(true); vStack.setAnimateMembers(true); vStack.setDropLineThickness(4); Canvas dropLineProp = new Canvas(); dropLineProp.setBackgroundColor("#40c040"); vStack.setDropLineProperties(dropLineProp); vStack.addMember(new DragPiece("cube_blue.png")); vStack.addMember(new DragPiece("cube_green.png")); vStack.addMember(new DragPiece("cube_yellow.png")); Canvas main = new Canvas(); main.addChild(hStack); main.addChild(vStack); main.draw(); } private class DragPiece extends Img { public DragPiece() { setWidth(48); setHeight(48); setLayoutAlign(Alignment.CENTER); setCanDragReposition(true); setCanDrop(true); setDragAppearance(DragAppearance.TARGET); setAppImgDir("pieces/48/"); } public DragPiece(String src) { this(); setSrc(src); } } }