/*=========================================================================
* 
* CPAdTree.hpp :  class CPA_HierarchyTree
* 
*
* Version			1.0
* Creation date		
* Revision date
*
* Shaitan
*=======================================================================*/
#ifdef ACTIVE_EDITOR
 
#ifndef __CPA_HIERARCHYTREE_H__
#define __CPA_HIERARCHYTREE_H__
 
/****************************************/
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
/****************************************/
 
class CPA_EditorBase;
class CPA_BaseObject;
class CPA_DialogList;
 
/*#################################################################################*/
/* Tree Control */
/*#################################################################################*/
/*===========================================================================
*		Description:	Class for the Tree Item
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
class CPA_EXPORT CPA_TreeItem
{
protected:
	CPA_BaseObject	*m_pObject;
	void			*m_pInfo;
	int				m_iIcon;
	int				m_iState;
 
public:
	CPA_TreeItem  (CPA_BaseObject *pObject);
	~CPA_TreeItem (void);
 
	CPA_BaseObject * GetObject (void) { return m_pObject; }
	
	void * GetInfo	(void)			{ return m_pInfo; }
	void   SetInfo	(void *pInfo)	{ m_pInfo = pInfo; }
 
	int	 GetIcon	(void)			{ return m_iIcon; }
	void SetIcon	(int iIcon)		{ m_iIcon = iIcon; }
	
	int	 GetState	(void)			{ return m_iState; }
	void SetState	(int iState)	{ m_iState = iState; }
};
 
/*===========================================================================
*		Description:	Class for Hierarchy Tree
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
class CPA_EXPORT CPA_HierarchyTree : public CTreeCtrl
{
protected:
	CPA_EditorBase  *m_pOwnerEditor;
	CPA_DialogList	*m_pParentDialog;
	CPA_BaseObject	*m_pRoot;
	CImageList		*m_pIconList;
	CImageList		*m_pStateList;
	CImageList		m_stDefaultImageList;
	HTREEITEM		m_hDraggedItem;
	HTREEITEM		m_hTarget;
 
 
public:
 
	CPA_HierarchyTree ();
	~CPA_HierarchyTree ();
 
	HTREEITEM GetDraggedItem (void) { return m_hDraggedItem; }
	HTREEITEM GetDropTarget  (void) { return m_hTarget; }
 
	void SetParentDialog	(CPA_DialogList *pParentDialog) { m_pParentDialog = pParentDialog; }
	void SetOwnerEditor		(CPA_EditorBase *pEditor)		{ m_pOwnerEditor = pEditor; }
	void SetDraggedItem		(HTREEITEM hItem)				{ m_hDraggedItem = hItem; }
	void SetIconList		(CImageList *pIconList, BOOL bUpdate = TRUE);
	void SetStateList		(CImageList *pIconList, BOOL bUpdate = TRUE);
 
	void SetTreeRoot (CPA_BaseObject *pRoot);
 
	void fn_vDeleteHierarchyTree	(HTREEITEM hTreeNode = NULL);
	void fn_vFillHierarchyTree		(CPA_BaseObject *pEdParent, HTREEITEM hTreeNode);
 
	HTREEITEM		 GetCorrespondingItem	(CPA_BaseObject *pObject, CPA_BaseObject *pParent, HTREEITEM hElem);
	CPA_BaseObject * GetCorrespondingChild	(CPA_BaseObject *pObject, CPA_BaseObject *pParent);
	void *			 GetCorrespondingInfo	(CPA_BaseObject *pObject, CPA_BaseObject *pParent);
	int				 GetCorrespondingIcon	(CPA_BaseObject *pObject);
	int				 GetCorrespondingState	(CPA_BaseObject *pObject);
 
	void *	GetItemInfo		(CPA_BaseObject *pObject, CPA_BaseObject *pParent);
	void	SetItemInfo		(CPA_BaseObject *pObject, CPA_BaseObject *pParent, void *pInfo);
 
	int 	GetItemIcon		(CPA_BaseObject *pObject, CPA_BaseObject *pParent);
	void	SetItemIcon		(CPA_BaseObject *pObject, CPA_BaseObject *pParent, int iIcon);
 
	int		GetItemStateI	(CPA_BaseObject *pObject, CPA_BaseObject *pParent);
	void	SetItemStateI	(CPA_BaseObject *pObject, CPA_BaseObject *pParent, int iState);
 
	afx_msg void OnRButtonDown		(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp		(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDblClk	(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove		(UINT nFlags, CPoint point);
	afx_msg void OnKeyDown			(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyUp			(UINT nChar, UINT nRepCnt, UINT nFlags);
 
	BOOL OnCommand( WPARAM wParam, LPARAM lParam );
 
	DECLARE_MESSAGE_MAP()
};
 
 
 
 
#endif /*__CPA_HIERARCHYTREE_H__*/
#endif /* ACTIVE_EDITOR*/
