/*
 * Created on Jan 14, 2004
 *
 */
package LumiSoft.UI.Controls;

import java.awt.*;

/**
 * Toolbar item.
 */
public class WToolBarItem 
{
	private WToolBar     m_pToolBar      = null;
	private String       m_Name          = "";
//	private String       m_Text          = "";
	private String       m_ToolTipText   = "";
	private String       m_ToolTipTextID = "";
	private boolean      m_Enabled       = true;
	private boolean      m_Visible       = true;
	private boolean      m_Sepearator    = false;
	private int          m_ImageIndex    = -1;
	private WContextMenu m_pMenu         = null;
	private Object       m_Tag           = null;
	private Rectangle    m_Bounds;
	
	/**
	 * Default constructor.
	 * @param toolbar
	 */
	protected WToolBarItem(WToolBar toolbar,String name)
	{
		m_pToolBar = toolbar;
		m_Name     = name;
		
		m_Bounds = new Rectangle(-1,-1,0,0);
	}
	
	
//	/**
//	 * Gets item text.
//	 * @return
//	 */
//	public String getText()
//	{
//		return m_Text;
//	}
//	/**
//	 * Sets item text.
//	 * @param value
//	 */
//	public void setText(String value)
//	{
//		if(m_Text != value){
//			m_Text = value;
//		}
//	}
	
	/**
	 * Gets tooltip text.
	 */
	public String getToolTipText()
	{
		if(m_pToolBar.getWText() != null && getToolTipTextID().length() > 0){			
			return m_pToolBar.getWText().get(getToolTipTextID());
		}
		else{
			return m_ToolTipText;
		}
	}
	/**
	 * Sets tooltip text.
	 * @param value
	 */
	public void setToolTipText(String value)
	{
		m_ToolTipText = value;
	}
	
	/**
	 * Gets tooltip text ID.
	 */
	public String getToolTipTextID()
	{
		return m_ToolTipTextID;
	}
	/**
	 * Sets tooltip text ID.
	 * @param value
	 */
	public void setToolTipTextID(String value)
	{
		m_ToolTipTextID = value;
	}
	
	/**
	 * Gets toolbar item name.
	 */
	public String getName()
	{
		return m_Name;
	}
	
	/**
	 * Gets if toolbar button is enabled.
	 */
	public boolean getEnabled()
	{
		return m_Enabled;
	}
	/**
	 * Sets if toolbar button is enabled.
	 * @param value
	 */
	public void setEnabled(boolean value)
	{
		if(m_Enabled != value){
			m_Enabled = value;
			
			m_pToolBar.repaint();
		}
	}
	
	/**
	 * Gets if toolbar item is visible.
	 * @return
	 */
	public boolean getVisible()
	{
		return m_Visible;
	}
	/**
	 * Sets if toolbar item is visible.
	 * @param value
	 */
	public void setVisible(boolean value)
	{
		if(m_Visible != value){
			m_Visible = value;
			
			m_pToolBar.repaint();
		}
	}
	
	/**
	 * Gets if toolbar item is separator.
	 * @return
	 */
	public boolean getSeparator()
	{
		return m_Sepearator;
	}
	/**
	 * Sets if toolbar item is separator.
	 * @param value
	 */
	public void setSeparator(boolean value)
	{
		if(m_Sepearator != value){
			m_Sepearator = value;
			
			m_pToolBar.repaint();
		}
	}
	
	/**
	 * Gets item image index.
	 * @return
	 */
	public int getImageIndex()
	{
		return m_ImageIndex;
	}
	/**
	 * Sets item image index.
	 * @param value
	 */
	public void setImageIndex(int value)
	{
		if(m_ImageIndex != value){
			m_ImageIndex = value;
			
			m_pToolBar.repaint();
		}
	}
	
	/**
	 * Gets item menu.
	 * @return
	 */
	public WContextMenu getMenu()
	{
		return m_pMenu;
	}
	/**
	 * Sets item menu.
	 * @param value
	 */
	public void setMenu(WContextMenu value)
	{
		if(m_pMenu != value){
			m_pMenu = value;
			
			m_pToolBar.repaint();
		}
	}
	
	/**
	 * Gets item tag.
	 * @return
	 */
	public Object getTag()
	{
		return m_Tag;
	}
	/**
	 * Sets item tag.
	 * @param value
	 */
	public void setTag(Object value)
	{
		if(m_Tag != value){
			m_Tag = value;
		}
	}
	
	/**
	 * Gets item bounding rectangle.
	 * @return
	 */
	public Rectangle getBounds()
	{
		return m_Bounds;
	}
	/**
	 * Sets item bounding rectangle.
	 * @param value
	 */
	protected void setBounds(Rectangle value)
	{
		if(m_Bounds != value){
			m_Bounds = value;
		}
	}	

}
