/****************************************************************************************

		IMFListPart.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Emil
		Date:	8/10/98

		COM interface to internal ListPart objects.

		Revision History

		when		who			what & why
		==========	==========	======================================================
		9/30/98		Eml			Added GetCellRect GetNextSelectedCell GetSelectedCellRange GetNumOfCells
								to COM API

*****************************************************************************************/

#ifndef __IMFLISTPART__
#define __IMFLISTPART__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "MCCompObj.h"
#include "MFTypes.h"

class TMCRect;
struct IMFPart;
template <class T> class TMCClassArray;


//*********************** Globally Unique Ids ********************************

MCDEFINE_GUID(IID_IMFListPart, 0xc4fbfaa8, 0x3c7c, 0x11d2, 0x84, 0x8c, 0x0, 0x60, 0x97, 0xb, 0xc5, 0x21);

//****************************************************************************

const int32 kLIST_DELETE_ALL			= -1;			//	DeleteCells(): delete all the cells.
const MessageID kCmnd_ListCmnd	= 'list';



/******************************************************************************\
*                                                                              *
*           IMFListPart                                                        *
*                                                                              *
\******************************************************************************/
/// \addtogroup MCF
/// \{

///<P>List Parts implement a 1 column by N row list of cells.  Cells are selectable.</P>
struct IMFListPart : public IMCUnknown
{
	//	
	// ****************************************************************************
	//								GetCellRect
	// 
	/// Return the rectangle that encloses the passed-in cell. The cell
	///	may not be visible, hence the rect may not be visible either.
	/// \param inCell   Index of cell to check
	/// \param outRect  Returns bounds of the cell
	/// 
	virtual void	MCCOMAPI GetCellRect			(const int32 inCell, TMCRect& outRect) const = 0;

	// ****************************************************************************
	//								GetNextSelectedCell
	// 
	/// Returns the index of the next selected cell.  Pass in the index of the first
	/// cell to check for selectedness.
	/// NOTE: 0 starts at top, may return 0 as first one too. If no cells are selected
	/// then FALSE is returned and "ioCell" should be ignored.
	/// 
	/// \param ioCell  Pass in a cell index, get back the index of the next selected cell
	/// \return False if there is no next selected cell.  If this is the case, the contents 
	/// of ioCell should not be used.
	/// 
	virtual boolean MCCOMAPI GetNextSelectedCell	(int32& ioCell ) const = 0;

	// ****************************************************************************
	//								GetSelectedCellRange
	// 
	/// Returns the first and last cells that are selected. If no cells are selected
	/// then -1 is returned for both. Note that there may be "holes" in the middle, 
	/// that is, the returned parameters are simply bounds, not an inclusive list.
	/// 
	/// \param outFirstCell  Returns the first cell that is selected or -1 if nothing selected
	/// \param outLastCell   Returns the last cell that is selected or -1 if nothing selected
	/// 
	virtual void	MCCOMAPI GetSelectedCellRange	(int32& outFirstCell, int32& outLastCell) const = 0;

	// ****************************************************************************
	//								GetNumOfCells
	// 
	/// Returns the number of cells in the list.
	/// 
	virtual int32	MCCOMAPI GetNumOfCells			(void) const = 0;

	// ****************************************************************************
	//								AddCells
	// 
	/// Add "inHowMany" cells to the list, starting at "inStartingWhere".
	/// "inStartingWhere" MUST BE WITHIN 0 AND THE TOTAL CELLS.
	///
	/// \param inStartingWhere  Index at which to insert the new cells
	/// \param inHowMany        How many cells to insert
	/// \param inInvalidate     If True, invalidate the List
	/// 
	virtual MCCOMErr MCCOMAPI AddCells				(int32 inStartingWhere, int32 inHowMany, boolean inInvalidate) = 0;

	// ****************************************************************************
	//								DeleteCells
	// 
	/// Delete cells from the list between inStartingWhere and inStartingWhere+inHowMany
	/// If *ALL* cells should be deleted, pass "kLIST_DELETE_ALL" for "inHowMany".
	/// 
	/// \param inStartingWhere  First index of cell to be deleted
	/// \param inHowMany        How many cells to delete
	/// \param inInvalidate     If True, invalidate the List
	/// 
	virtual MCCOMErr MCCOMAPI DeleteCells			(int32 inStartingWhere, int32 inHowMany, boolean inInvalidate) = 0;

	// ****************************************************************************
	//								SelectCell
	// 
	/// Set the selection state of a cell - redraws the cell too. If only single
	/// selection is allowed, other cells are deselected if "beSelected" is TRUE.
	/// 
	/// \param inCell        Which cell to select
	/// \param beSelected    If true, sets this cell to selected.  If false, to not selected.
	/// \param inInvalidate  If true, invalidates the cell
	///
	virtual void	 MCCOMAPI SelectCell			(const int32 inCell, const boolean beSelected, boolean inInvalidate) = 0;

	// ****************************************************************************
	//								CreateNamedCells
	// 
	/// Only implemented by TMFNameListPart (TMFListPart doens't do anything)
	/// Deletes previous cells, and creates a named cell for each element in inNames
	///
	/// \param inNames  Array of names of cells to create
	/// 
	virtual void	 MCCOMAPI CreateNamedCells		(const TMCClassArray<TMCDynamicString>& inNames) = 0;

	/// Retruns the IMFPart interface (always supported)
	virtual IMFPart* MCCOMAPI GetThisPart			() = 0;

    /// Get the cell height
    virtual int32 MCCOMAPI GetCellHeight() const = 0;
    
    /// Set the cell height
	virtual void MCCOMAPI SetCellHeight(const int32	inNewHeight ) = 0;
};
/// \}
#endif
