/*
 * Created on Mar 22, 2004
 *
 */
package LumiSoft.UI.Controls;

import java.util.*;

/**
 * Statusbar panel collection.
 */
public class WStatusBarPanelCollection implements Iterable<WStatusBarPanel>
{
	private WStatusBar                 m_pStatusBar = null;
	private ArrayList<WStatusBarPanel> m_pPanels    = null; 
	
	/**
	 * Default constructor.
	 * @param statusBar Statusbar what owns this collection.
	 */
	protected WStatusBarPanelCollection(WStatusBar statusBar)
	{
		m_pStatusBar = statusBar;
		m_pPanels    = new ArrayList<WStatusBarPanel>();
	}
	
	
	/**
	 * Adds new statusbar panel to panels collection.
	 * @param autoSize
	 * @return
	 */
	public WStatusBarPanel Add(boolean autoSize)
	{
		WStatusBarPanel panel = new WStatusBarPanel(m_pStatusBar);
		panel.setAutoSize(autoSize);
		m_pPanels.add(panel);
		
		return panel;
	}
	/**
	 * Adds new statusbar panel to panels collection.
	 * @param width
	 * @return
	 */
	public WStatusBarPanel Add(int width)
	{				
		return Add(width,"");
	}
	/**
	 * Adds new statusbar panel to panels collection.
	 * @param width
	 * @param text
	 * @return
	 */
	public WStatusBarPanel Add(int width,String text)
	{
		WStatusBarPanel panel = new WStatusBarPanel(m_pStatusBar);
		panel.setWidth(width);
		panel.setText(text);
		m_pPanels.add(panel);
		
		return panel;
	}
	
	/**
	 * Removes specified panel from panles collection.
	 * @param panel
	 */
	public void Remove(WStatusBarPanel panel)
	{
		m_pPanels.remove(panel);
	}
	
	/**
	 * Removes all items from the collection.
	 *
	 */
	public void Clear()
	{
		m_pPanels.clear();
	}
	
	
	/**
	 * Gets the number of items in the collection.
	 * @return
	 */
	public int getCount()
	{
		return m_pPanels.size();
	}
	
	/**
	 * Gets the StatusBarPanel at the specified index. 
	 * @param index
	 * @return
	 */
	public WStatusBarPanel get(int index)
	{
		return m_pPanels.get(index);
	}
	
	
	/**
	 * Gets iterator.
	 */
	public Iterator<WStatusBarPanel> iterator()
	{
		return m_pPanels.iterator();
	}
}
