/*
 * Created on 25.02.2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package de.farafin.snEADy.control.GaphixStuff;

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.image.BufferedImage;

/**
 * @author larsonmars
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class GrWindow extends Frame implements I_GraphixConstants{
	
	private BufferedImage img_bg;
	protected GrWindow sroot;
	protected int w,h;
	
	protected GrWindow(){super();}
	public GrWindow(String titleText,BufferedImage bg){
		this(titleText,bg.getWidth(),bg.getHeight());
		img_bg=bg;
	}
	public GrWindow(String titleText,int width,int height){
		super(titleText);
		sroot=this;
		w=width;
		h=height;
		setResizable(false);
        setUndecorated(true);
        setFocusable(true);
        setLayout(null);
        Dimension screenD=Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenD.width-w)/2,(screenD.height-h)/2,w,h);
	    addMouseMotionListener(new MouseMotionListener(){
	        private int mdx,mdy;
            public void mouseDragged(MouseEvent e){
            	setLocation((getX()-mdx+e.getX()),getY()-mdy+e.getY());
            }
            public void mouseMoved(MouseEvent e){
            	mdx=e.getX();
            	mdy=e.getY();
            }           
	    });
	}

	public void paint(Graphics g){
		g.drawImage(img_bg,0,0,null);
		
	}

}
