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

import java.awt.*;

import LumiSoft.Data.*;

/**
 * @author Ivar
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class RowInfo 
{
	private WGridTableView m_pOwnerView  = null;
	private int            m_RowHeight   = 0;
	private Rectangle      m_pBounds     = new Rectangle(-1,-1,0,0);
	private DataRowView    m_pRow        = null;
	private WGridTableView m_pDetailView = null;
		
	/**
	 * Default constructor.
	 * @param ownerView
	 * @param row
	 */
	protected RowInfo(WGridTableView ownerView,DataRowView row)
	{
		m_pOwnerView = ownerView;
		m_pRow = row;
	}
	
	
	/**
	 * Gets specified cell value for this row. 
	 * @param column Column which value to get.
	 * @return Returns specified cell value.
	 */
	public Object GetValue(WGridColumn column)
	{
		if(column.getMappingName().length() > 0){
			if(m_pOwnerView.getDataSource().getTable().getColumns().Contains(column.getMappingName())){
				Object value = m_pRow.get(column.getMappingName());
				if(value != null){
					return m_pRow.get(column.getMappingName());
				}
			}
		//	else{
		//		System.out.println("Column '" + column.getMappingName() + "' doesn't exist !");
		//	}			
		}
		
		return "";
	}
	
	
	/**
	 * Gets row.
	 * @return
	 */
	public DataRowView getRowSource()
	{
		return m_pRow;
	}
	
	/**
	 * Gets row height.
	 * @return
	 */
	public int getRowHeight()
	{
		return m_RowHeight;
	}
	/**
	 * Sets row height.
	 * @param value Row height.
	 */
	public void setRowHeight(int value)
	{
		m_RowHeight = value;
	}
	
	/**
	 * Gets row bounding rectangle.
	 * @return
	 */
	public Rectangle getBounds()
	{
		return m_pBounds;
	}
	/**
	 * Sets row bounding rectangle.
	 * @param value
	 */
	public void setBounds(Rectangle value)
	{
		m_pBounds = value;
	}
	
	/**
	 * Gets row Y position.
	 */
	public int getY()
	{
		return m_pBounds.y;
	}
	
	/**
	 * Gets row child view.
	 * @return
	 */
	public WGridTableView getDetailView()
	{
		return m_pDetailView;
	}
	/**
	 * Sets row child view.
	 * @param value
	 */
	public void setDetailView(WGridTableView value)
	{
		m_pDetailView = value;
	}

}
