/*=========================================================================
* 
* CPAdList.h :  class CPA_DialogList
* 
*
* Version			1.0
* Creation date		
* Revision date
*
* Shaitan
*=======================================================================*/
#ifdef ACTIVE_EDITOR
 
#ifndef __CPA_DIALOGLIST_H__
#define __CPA_DIALOGLIST_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
/****************************************/
 
/* mode : tree or list*/
typedef enum tdeListDrawMode_
{
	E_ldm_Tree,
	E_ldm_List
}
tdeListDrawMode;
 
/* update action*/
typedef enum tdeListReinitMode_
{ 
	E_lrm_ReinitList,
	E_lrm_ChangeSelection, 
	E_lrm_GoToChild, 
	E_lrm_GoToParent
} 
tdeListReinitMode; 
 
/* control position*/
typedef enum tdeListControlPos_
{
	E_lcp_Center,
	E_lcp_AdjustWidth,
	E_lcp_AdjustAll
}
tdeListControlPos;
 
 
 
#include "CPARes.h"
#include "CPAListB.hpp"
#include "CPAdLbox.hpp"
#include "CPAdTree.hpp"
 
class CPA_EditorBase;
class CPA_SuperObject;
class CPA_DialogList;
 
/*#################################################################################*/
/* Lists for Dialog */
/*#################################################################################*/
 
/*===========================================================================
*		Description:	Class for the Lists of Dialog
*		Creation date:	
*		Author:			Shaitan
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
class CPA_EXPORT CPA_ListForDialog : public CObject
{
protected:
	CPA_BaseObject					*m_pTreeRoot;			/* Root for the Tree*/
	CPA_BaseObjectList				*m_pSortedList;			/* List for the ListBox */
	CImageList						*m_pIconList;			/* List of icons*/
	CImageList						*m_pStateList;			/* List of state icons*/
	CString							m_csName;				/* Name in the ComboBox*/
	tdeListDrawMode					m_eDrawMode;			/* C_List or C_Tree*/
	tdeListOrder					m_eListOrder;			/* Default order					*/
	long							m_lDrawStyle;			/* current style;*/
	BOOL							m_bCanChangeOrder;		/* Flag for popup*/
	BOOL							m_bCanChangeStyle;		/* Flag for popup*/
 
 
public:
 
	/* constructors*/
	CPA_ListForDialog  (CString csName, CPA_BaseObjectList *pListObjects, 
						CImageList *pIconList, CImageList *pStateList = NULL,
						tdeListOrder eDefaultOrder = E_lo_Alpha, BOOL bCanChangeOrder = TRUE, 
						long lDefaultStyle = C_lDrawName, BOOL bCanChangeStyle = TRUE);
 
	CPA_ListForDialog  (CString csName, CPA_BaseObject *pTreeRoot, 
						CImageList *pIconList, CImageList *pStateList = NULL);
 
	~CPA_ListForDialog (void);
 
	/* accessing members*/
	CPA_BaseObjectList		* GetSortedList		 (void) { return m_pSortedList; }
	CPA_BaseObject			* GetRoot			 (void) { return m_pTreeRoot; }
	CImageList				* GetIconList		 (void)	{ return m_pIconList; }
	CImageList				* GetStateList		 (void)	{ return m_pStateList; }
	tdeListDrawMode			  GetMode			 (void) { return m_eDrawMode; }
	tdeListOrder			  GetOrder			 (void) { return m_eListOrder; }
	CString					  GetName			 (void) { return m_csName; }
	long					  GetStyle			 (void) { return m_lDrawStyle; }
	BOOL					  fn_bCanChangeOrder (void) { return m_bCanChangeOrder; }
	BOOL					  fn_bCanChangeStyle (void) { return m_bCanChangeStyle; }
	/* setting members*/
	void SetTreeRoot		(CPA_BaseObject *pNewRoot)					{ m_pTreeRoot = pNewRoot; }
	void SetListObjects		(CPA_BaseObjectList *pNewList)				{ m_pSortedList = pNewList; }
	void SetIconList		(CImageList *pNewIcons)						{ m_pIconList = pNewIcons; }
	void SetStateList		(CImageList *pNewStates)					{ m_pStateList = pNewStates; }
	void SetOrder			(tdeListOrder eOrder);
	void SetStyle			(long lStyle);
};
 
 
 
 
 
/*#################################################################################*/
/* Dialog */
/*#################################################################################*/
 
/*===========================================================================
*		Description:	Class for the Dialog
*		Creation date:	
*		Author:			Shaitan
*
*---------------------------------------------------------------------------
*		
*---------------------------------------------------------------------------
*		Revision date:                                                                                          Author:         
*=========================================================================*/
 
class CPA_EXPORT CPA_DialogList : public CFormView
{
/* Construction*/
protected:
	CPA_EditorBase	*m_pOwnerEditor;
	
	CPA_List<CPA_ListForDialog>   m_stListOfListObjects;
	CPA_ListForDialog			* m_pCurrentList;
	CPA_BaseObject				* m_pSelectedObject;
	CPA_BaseObject				* m_pSelectedParent;
	CPA_BaseObject				* m_pClickedObject;
	CPA_BaseObject				* m_pClickedParent;
	BOOL						  m_bInitialised;
	BOOL						  m_bButtonState;
	BOOL						  m_bTestEnabled;
	CString						  m_csTypeName;
	CString						  m_csTestName;
 
public:
/* standard constructor*/
	CPA_DialogList (CWnd* pParent = NULL);   
 
/* get functions*/
	CPA_ListForDialog	* GetListFromName	 (CString csName);
	CPA_ListForDialog	* GetCurrentList      (void) { return m_pCurrentList; }
	CPA_BaseObject		* GetSelectedObject   (void) { return m_pSelectedObject; }
	CPA_BaseObject		* GetSelectedParent   (void) { return m_pSelectedParent; }
	CString				  GetCurrentType 	  (void) { return m_csTypeName; }
/* ALX*/
    HWND                  GetComboHandle      (void) { return m_cComboType   . m_hWnd; }
    HWND                  GetListHandle       (void) { return m_cListObjects . m_hWnd; }
    HWND                  GetTreeHandle       (void) { return m_cHierarchy   . m_hWnd; }
    HWND                  GetTestButtonHandle (void) { return m_cButtonTest  . m_hWnd; }
/* End ALX*/
 
/* set functions*/
	void SetDefaultButtonState	(BOOL bEnabled)		{ m_bButtonState = bEnabled; } 
	void SetDefaultTestName		(CString csName)	{ m_csTestName = csName; }	
	void SetDefaultTypeName		(CString csName)	{ m_csTypeName = csName; }
	void SetCurrentType			(CString csName);
 
	void SetPermanentOrder		(tdeListOrder ePermanentOrder);
	void SetPermanentDisplay	(BOOL bPermanentDisplay);
	void SetPermanentHeaders	(BOOL bColumnHeaders);
	void SetPermanentStyle		(long lPermanentStyle);
 
	void SetDefaultOrder		(tdeListOrder eDefaultOrder);
	void SetDefaultDisplay		(BOOL bDefaultDisplay);
	void SetDefaultHeaders		(BOOL bColumnHeaders);
	void SetDefaultStyle		(long lDefaultStyle);
 
	void	SetItemInfo			(CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pParent, void *pInfo);
	void *	GetItemInfo			(CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pParent);
 
	int 	GetItemIcon			(CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pParent);
	void	SetItemIcon			(CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pParent, int iIcon);
 
	int		GetItemState		(CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pParent);
	void	SetItemState		(CString csListName, CPA_BaseObject *pObject, CPA_BaseObject *pParent, int iState);
 
/* Dialog*/
	void fn_vInitDialog		 (CPA_EditorBase *pOwnerEditor, CWnd *pParent);
	void fn_vInitAllLists	 (void);
	void fn_vReinitDialog	 (void);
	void fn_vInitComboType	 (void);
	void fn_vInitButtonTest	 (CString CzName, BOOL bButtonState, BOOL bEnabled);
	void fn_vUpdateSelection (tdeListReinitMode eType);
	void fn_vAddANewList	 (CString csName, CPA_BaseObjectList *pListObjects, 
							  CImageList *pIconList = NULL, CImageList *pStateList = NULL,
							  tdeListOrder eOrder = E_lo_Alpha, BOOL bCanChangeOrder = TRUE,
							  long lListStyle = C_lDrawName, BOOL bCanChangeStyle = TRUE);
 
	void fn_vAddANewTree	 (CString csName, CPA_BaseObject *pTreeRoot, 
							  CImageList *pIconList = NULL, CImageList *pStateList = NULL);
 
	void fn_vDeleteAList	 (CString csName);
 
	void fn_vInitHierarchy		(void);
	void fn_vInitListObjects	(void);
	BOOL fn_bCanInsertElement	(CPA_BaseObject *pElem);
 
	void fn_vOnDragDropEndHierarchy		(void);
	BOOL fn_bAcceptAsDragDropTarget		(HTREEITEM hTarget);
	void fn_vOnDblClkHierarchyTree		(void);
 
	BOOL fn_bOnKeyDownInControl	(UINT nChar, UINT nRepCnt, UINT nFlags);
	BOOL fn_bOnKeyUpInControl	(UINT nChar, UINT nRepCnt, UINT nFlags);
 
	void fn_vRedrawElement	 (CPA_BaseObject *pObject, BOOL bEnsureVisible);
 
protected:
	void fn_vReinitPosition		(CWnd *pControl, CWnd *pRef, tdeListControlPos ePos);
 
/* Dialog Data*/
	/*{{AFX_DATA(CPA_DialogList)*/
	enum { IDD = CPA_IDD_DIALOGLIST };
	CComboBox			m_cComboType;
	CPA_SortedListBox	m_cListObjects;
	CPA_HierarchyTree	m_cHierarchy;
	CButton				m_cButtonTest;
	/*}}AFX_DATA*/
 
/* Overrides*/
	/* ClassWizard generated virtual function overrides*/
	/*{{AFX_VIRTUAL(CPA_DialogList)*/
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    /* DDX/DDV support*/
	/*}}AFX_VIRTUAL*/
 
 
/* Implementation*/
protected:
 
	/* Generated message map functions*/
	/*{{AFX_MSG(CPA_DialogList)*/
	afx_msg void OnSelchangeComboType();
	afx_msg void OnButtonTest();
	afx_msg void OnSelchangeListObjects(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDblClkListObjects(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnSelchangeHierarchy(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDblClkHierarchy(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnBeginDragHierarchy(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnSize(UINT, int, int);
	/*}}AFX_MSG*/
	DECLARE_MESSAGE_MAP()
};
 
#endif /*__DIALOGLIST_H__*/
#endif /* ACTIVE_EDITOR*/
