package com.ssdi.test.client;

import com.google.gwt.core.client.GWT;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.VLayout;

public class ImageTest {
	
	static String hostURL = GWT.getHostPageBaseURL();
	  public static void createWindow() {
		  Window window = new Window();
		    window.setHeight(250);
		    window.setWidth(500);
		    window.setIsModal(true);
		    window.setTitle("SampleWindow");
		    window.setShowMinimizeButton(false);
		    window.setShowModalMask(true);
		    window.centerInPage();
		    window.setCanDragResize(true);
		    window.setKeepInParentRect(true);
		    window.setAutoCenter(true);

		    final VLayout layout = new VLayout(10);
		    layout.setHeight("100%");
		    layout.setWidth("100%");
		    layout.setMargin(20);

		   /* DynamicForm  form = new DynamicForm();
		    form.setBorder("1px solid gray");
		    form.setNumCols(2);
		    form.setMargin(10);
		    form.setAlign(Alignment.CENTER);*/
		    
		    final ImgButton discoverButton = new ImgButton();
			discoverButton.setWidth(24); 
															
			discoverButton.setHeight(24); 
		
			discoverButton.setHoverWrap(false);
			discoverButton.setSrc(hostURL+"images/Search_Start.png");
			discoverButton.setName("discoverButton");
			
						
			discoverButton.addClickHandler(new ClickHandler() {
				
				@Override
				public void onClick(ClickEvent event) {
					
					String str = discoverButton.getSrc();
					if(str.contains("Search_Start.png")){
						discoverButton.setSrc(hostURL+"images/Search_Pause.png");
						
					}else{
						discoverButton.setSrc(hostURL+"images/Search_Start.png");
					}
					
				}
			});
			
		    
		    layout.addMembers(discoverButton );
		    
		    window.addItem(layout);
		    window.show();
	  }
	

}
