/* 
 * This file is part of the Echo Point Project.  This project is a collection
 * of Components that have extended the Echo Web Application Framework.
 *
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 */
package echopointng;

import nextapp.echo2.app.Color;
import nextapp.echo2.app.Component;
import nextapp.echo2.app.Extent;
import nextapp.echo2.app.PaneContainer;
import nextapp.echo2.app.Style;
import echopointng.able.Positionable;
import echopointng.able.ScrollBarProperties;
import echopointng.able.Scrollable;

/** 
 * <code>ContainerEx</code> is a component that can be positioned anywhere on the screen 
 * with an specified size attributes.  It does this by implementing the <code>Positionable</code>
 * interface.
 * <p>
 * By default, the children of <code>ContainerEx</code> are layed out one after the other, left to right and
 * without any other specified processing.  Therefore to get more precise layout within the
 * <code>ContainerEx</code>, you may want to consider using a Column/Row/Grid as the child 
 * of this component or you can associated a <code>DisplayLayoutData</code> object with each child component
 * and use that to position the children where you want.  
 * 
 * @see echopointng.layout.DisplayLayoutData
 */

public class ContainerEx extends AbleComponent implements PaneContainer, Positionable, Scrollable {
	
	/** Default serial Id */
	private static final long serialVersionUID = 1L;
	
	
	public static final Style DEFAULT_STYLE;
	static {
		MutableStyleEx style = new MutableStyleEx();
		
		style.setProperty(PROPERTY_POSITION, RELATIVE);
		DEFAULT_STYLE  = style;
	}	
	/**
	 * Constructs a <code>ContainerEx</code>
	 */
	public ContainerEx() {
		super();
	}

	/**
	 * Constructs a <code>ContainerEx</code> with the
	 * specified component as its first child.
	 */
	public ContainerEx(Component child) {
		this();
		add(child);
	}

	/**
	 * @see echopointng.able.Positionable#clear()
	 */
	public void clear() {
		setZIndex(Integer.MIN_VALUE);
		setPosition(RELATIVE);
		setLeft(null);
		setRight(null);
		setTop(null);
		setBottom(null);
	
	}

	/**
	 * @see echopointng.able.Positionable#getBottom()
	 */
	public Extent getBottom() {
		return (Extent) getProperty(PROPERTY_BOTTOM);
	}

	/**
	 * @see echopointng.able.Positionable#getLeft()
	 */
	public Extent getLeft() {
		return (Extent) getProperty(PROPERTY_LEFT);
	}

	/**
	 * @see echopointng.able.Positionable#getPosition()
	 */
	public int getPosition() {
		return getProperty(PROPERTY_POSITION,RELATIVE);
	}

	/**
	 * @see echopointng.able.Positionable#getRight()
	 */
	public Extent getRight() {
		return (Extent) getProperty(PROPERTY_RIGHT);
	}

	/**
	 * @see echopointng.able.Positionable#getTop()
	 */
	public Extent getTop() {
		return (Extent) getProperty(PROPERTY_TOP);
	}

	/**
	 * @see echopointng.able.Positionable#getZindex()
	 */
	public int getZindex() {
		return getProperty(PROPERTY_ZINDEX,Integer.MIN_VALUE);
	}

	/**
	 * @see echopointng.able.Positionable#isPositioned()
	 */
	public boolean isPositioned() {
		return getPosition() != STATIC;
	}

	/**
	 * @see echopointng.able.Positionable#setBottom(nextapp.echo2.app.Extent)
	 */
	public void setBottom(Extent newValue) {
		setProperty(PROPERTY_BOTTOM,newValue);
	}

	/**
	 * @see echopointng.able.Positionable#setLeft(nextapp.echo2.app.Extent)
	 */
	public void setLeft(Extent newValue) {
		setProperty(PROPERTY_LEFT,newValue);
	}

	/**
	 * @see echopointng.able.Positionable#setPosition(int)
	 */
	public void setPosition(int newPositioning) {
		setProperty(PROPERTY_POSITION,newPositioning);
	}

	/**
	 * @see echopointng.able.Positionable#setRight(nextapp.echo2.app.Extent)
	 */
	public void setRight(Extent newValue) {
		setProperty(PROPERTY_RIGHT,newValue);
	}

	/**
	 * @see echopointng.able.Positionable#setTop(nextapp.echo2.app.Extent)
	 */
	public void setTop(Extent newValue) {
		setProperty(PROPERTY_TOP,newValue);
	}

	/**
	 * @see echopointng.able.Positionable#setZIndex(int)
	 */
	public void setZIndex(int newValue) {
		setProperty(PROPERTY_ZINDEX,newValue);
	}

	/**
	 * @see echopointng.able.Scrollable#getScrollBarPolicy()
	 */
	public int getScrollBarPolicy() {
		return getProperty(Scrollable.PROPERTY_SCROLL_BAR_POLICY,Scrollable.AUTO);
	}

	/**
	 * @see echopointng.able.Scrollable#getScrollBarBaseColor()
	 */
	public Color getScrollBarBaseColor() {
		return (Color) getProperty(Scrollable.PROPERTY_SCROLL_BAR_BASE_COLOR);
	}

	/**
	 * @see echopointng.able.Scrollable#getScrollBarProperties()
	 */
	public ScrollBarProperties getScrollBarProperties() {
		return (ScrollBarProperties) getProperty(Scrollable.PROPERTY_SCROLL_BAR_PROPERTIES);
	}

	/**
	 * @see echopointng.able.Scrollable#setScrollBarPolicy(int)
	 */
	public void setScrollBarPolicy(int newScrollBarPolicy) {
		setProperty(Scrollable.PROPERTY_SCROLL_BAR_POLICY,newScrollBarPolicy);
	}

	/**
	 * @see echopointng.able.Scrollable#setScrollBarBaseColor(nextapp.echo2.app.Color)
	 */
	public void setScrollBarBaseColor(Color newValue) {
		setProperty(Scrollable.PROPERTY_SCROLL_BAR_BASE_COLOR,newValue);
	}

	/**
	 * @see echopointng.able.Scrollable#setScrollBarProperties(echopointng.able.ScrollBarProperties)
	 */
	public void setScrollBarProperties(ScrollBarProperties newValue) {
		setProperty(Scrollable.PROPERTY_SCROLL_BAR_PROPERTIES,newValue);
	}
}
