package j3deditor.bin.editor.util;

import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;


/**
 * The <code>MainLayout</code> class is a layout manager
 * for <code>EditorPanel</code>.
 *
 * @author Risto Seene
 * 
 * @see j3deditor.bin.editor.EditorPanel
 */
public class MainLayout implements LayoutManager{

	/**
	 * Creates an instance of <code>MainLayout</code>.
	 */
	public MainLayout(){
	}


	/**
	 * Required by LayoutManager.
	 * 
	 * @param name
	 * 	doesn't do anything
	 * @param comp
	 * 	doesn't do anything
	 */
	public void addLayoutComponent(String name, Component comp){
	}

	/**
	 * Required by LayoutManager.
	 * 
	 * @param comp
	 * 	doesn't do anything
	 */
	public void removeLayoutComponent(Component comp){
	}

	/**
	 * Required by LayoutManager.
	 * 
	 * @param parent
	 * 	doesn't do anything
	 * @return (0, 0)
	 */
	public Dimension preferredLayoutSize(Container parent){
		return new Dimension(0, 0);
	}

	/**
	 * Required by LayoutManager.
	 * 
	 * @param parent
	 * 	doesn't do anything
	 * @return (0, 0)
	 */
	public Dimension minimumLayoutSize(Container parent){
		return new Dimension(0, 0);
	}

	/**
	 * Required by LayoutManager.
	 * Lays out the component into the given container.
	 *
	 * @param parent
	 *	container which components will be layd out
	 */
	public void layoutContainer(Container parent){
		int maxWidth = parent.getWidth();
		int maxHeight = parent.getHeight();

		try{
			int width;
			width = (int)(0.25 * maxWidth);

			parent.getComponent(0).setBounds(0, 0, width, maxHeight);
			parent.getComponent(1).setBounds(width, 0, maxWidth - width, maxHeight);
		} catch(Throwable t){
		}

	}
}

