//*****************************************************************************
//*  _zWList1.hpp                                                             *
//*****************************************************************************
//*                                                                           *
//* This file contains the definitions of the first list window               *
//*                                                                           *
//*****************************************************************************
//* Author : Alexis Vaisse                                                    *
//*****************************************************************************


#ifndef __ZWLIST1_HPP
#define __ZWLIST1_HPP

#pragma once

// Actors dll "include"
class EdtList;
class CPA_tdoNameList;

// Physical Object dll "include"
class EditorPO;

// personal "include"
#include "_zRes.h"       // File created by Microsoft Developer Studio
#include "_zObject.hpp"
class ZDx_Interface;


//-----------------------------------------------------------------------------
// Definition for the first list
//-----------------------------------------------------------------------------

typedef enum eList1Type_ {eListOfFamily , eListOfModel , eListOfModelOfFamily , eListOfInstance , eListOfModule} tdeList1Type;

#define C_szListOfFamily               "List of all families"
#define C_szListOfModel                "List of all models"
#define C_szListOfModelOfFamily        "List of models of same family"
#define C_szListOfInstance             "List of instances"
#define C_szListOfModule               "List of modules"

#define C_szListOfModelOfGivenFamily   "List of models of family: "
#define C_szListOfInstanceOfGivenModel "List of instances of model: "
#define C_szListOfModuleOfGivenTable   "List of modules of table: "

#define C_ucIconFamily                 0
#define C_ucIconModel                  1
#define C_ucIconInstance               2
#define C_ucIconModule                 3
#define C_ucIconUsedModule             4
#define C_ucIconZDx                    5
#define C_ucIconBigGlobalZone          6


//-----------------------------------------------------------------------------
// class TreeControl
//-----------------------------------------------------------------------------

//----------------------------
// ANNECY AV CLEAN_MEC {
typedef enum eTreeElementType_ { eFamilyElement      , eModelElement  , eInstanceElement      ,
                                 eModuleElement      , eBigGlobalZoneElement ,
                                 eZddElement         , eZdeElement    , eZdmElement           , eZdrElement ,
                                 eBoundingVolumeElement /* , eTestPointElement */
                               } tdeTreeElementType;
// END ANNECY AV }

//-------------------------------
typedef struct stTreeElementData_
{
    tdeTreeElementType      eType;
    CPA_BaseObject        * pObject;
    CPA_SuperObject       * pSuperObject;
} tdstTreeElementData;

//----------------------------------
class TreeControl : public CTreeCtrl
{
private:
    void DeleteItemRecursive (HTREEITEM hHandle);

public:
    HTREEITEM InsertItem (LPCTSTR Name , tdeTreeElementType _eType , CPA_BaseObject * _pObject , CPA_SuperObject * _pSuperObject ,
                          HTREEITEM hParent = TVI_ROOT , HTREEITEM hInsertAfter = TVI_LAST);
    BOOL DeleteAllItems  ();
    BOOL DestroyWindow   ();
};


//-----------------------------------------------------------------------------
// class CList1Window
//
// Window that shows different lists
//-----------------------------------------------------------------------------
class CList1Window : public CFormView
{
// Construction
public:
	CList1Window(CWnd* pParent = NULL);   // standard constructor
    DECLARE_DYNCREATE (CList1Window)

// Dialog Data
	//{{AFX_DATA(CList1Window)
	enum { IDD = IDD_ZDD_List1_Window };
	CButton	m_Check_Button_Show_Actor;
    CButton m_Check_Button_Show_Module;
    CButton m_Check_Button_Show_Module_ZDx;
    CButton m_Check_Button_Bounding_Volume;
    CButton m_Check_Button_Test_Point;
	CButton	m_Button_Return;
	CComboBox	m_Combo_Box_List_1;
	TreeControl	m_Tree_Ctrl_1;
	CString	m_Combo_Box_String_List_1;
	//}}AFX_DATA

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CList1Window)
	public:
	virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
	virtual BOOL PreTranslateMessage(MSG* pMsg);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
	//}}AFX_VIRTUAL

// Implementation
protected:
	// Generated message map functions
	//{{AFX_MSG(CList1Window)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void On_Selection_Has_Changed_Combo_Box_List_1();
	afx_msg void On_Return_Button();
	afx_msg void On_Double_Click_Tree_Ctrl_1(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void On_Selection_Has_Changed_Tree_Ctrl_1(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
	afx_msg void On_Right_Click_Tree_Ctrl_1(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void On_Check_Button_Show_Actor();
	afx_msg void On_Check_Button_Show_Module();
	afx_msg void On_Check_Button_Show_Module_ZDx();
    afx_msg void On_Check_Button_Bounding_Volume();
    afx_msg void On_Check_Button_Test_Point();
	afx_msg void On_Key_Down_Tree_Ctrl_1(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void On_Begin_Change_Name_Tree_Ctrl_1(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void On_End_Change_Name_Tree_Ctrl_1(NMHDR* pNMHDR, LRESULT* pResult);
	//}}AFX_MSG
    afx_msg BOOL SetToolTipText(UINT uiControlId , NMHDR *pNMHDR, LRESULT *pResult);
	DECLARE_MESSAGE_MAP()

// Private data
private:
    ZDx_Interface        * m_pZDxInterface;
    CBitmap                m_ButtonReturnBitmap;
    CBitmap                m_ButtonShowActorBitmap;
    CBitmap                m_ButtonShowModuleBitmap;
    CBitmap                m_ButtonShowModuleZDxBitmap;
    CBitmap                m_ButtonBoundingVolumeBitmap;
    CBitmap                m_ButtonTestPointBitmap;
    CImageList             m_stImageList;
    CToolTipCtrl           m_ToolTipCtrl;
    tdeList1Type           m_eList1Type;
    CPA_BaseObject       * m_pSelectedFamily;
    CPA_BaseObject       * m_pSelectedModel;
    CPA_BaseObject       * m_pSelectedActor;
    CPA_SuperObject      * m_pSelectedActorSuperObject;
    EdtList              * m_pSelectedBigGlobalZone;

    BOOL             m_bIsCreatingList;    // Is TRUE when creating a list. Becomes FALSE when the list is created

    BOOL             m_bCanSelectListOfFamily;
    BOOL             m_bCanSelectListOfModel;
    BOOL             m_bCanSelectListOfModelOfFamily;
    BOOL             m_bCanSelectListOfInstance;
    BOOL             m_bCanSelectListOfModule;

    BOOL             ComboBoxLineEnabled         (char * _szName);
    void             ComboBoxChoseCorrectName    (char * _szNewName , char * _szOldName);
    void             ComboBoxDrawLine            (LPDRAWITEMSTRUCT lpDrawItemStruct);
    void             CreateANewListOfZDx         (tdeZDxType _eType);
    void             DeleteSelectedElement       ();
    HTREEITEM        FindAnElementInTree         (HTREEITEM _hItem , void * _pData , void * _pParentData = NULL);
    void             ChangeIconOfModuleAndChild  (CPA_SuperObject * pSuperObject);

    void             SetCameraOnActor            (CPA_SuperObject * _pActorSuperObject);

    void             ShowActorAlone              ();
    void             ShowModuleAlone             ();

public:
    void SetZDxInterface           (ZDx_Interface       * _pZDxInterface)    { m_pZDxInterface = _pZDxInterface; }

    void CreateListOfFamily        (CPA_BaseObject * _pFamilyToSelect   = NULL ,
                                    CPA_BaseObject * _pModelToSelect    = NULL);
    void CreateListOfModel         (CPA_BaseObject * _pModelToSelect    = NULL ,
                                    CPA_BaseObject * _pInstanceToSelect = NULL);
    void CreateListOfModelOfFamily (CPA_BaseObject * _pFamily ,
                                    CPA_BaseObject * _pModelToSelect    = NULL ,
                                    CPA_BaseObject * _pInstanceToSelect = NULL);
    void CreateListOfInstance      (CPA_BaseObject * _pModel ,
                                    CPA_BaseObject * _pInstanceToSelect = NULL ,
                                    EdtList        * _pBigGlobalZoneToSelect = NULL);
    void CreateListOfModule        (CPA_SuperObject * _pActorSuperObject ,
                                    CPA_BaseObject * _pModuleToSelect   = NULL ,
                                    BOOL             _bOpenGrid         = TRUE);
    void LeaveListOfModule         ();

    void ReCreateCurrentList       ();
    void SelectInstance            (CPA_BaseObject * _pInstanceToSelect , BOOL bRefreshNeeded);
    void SelectBigGlobalZone       (CPA_BaseObject * _pInstance ,
                                    EdtList        * _pBigGlobalZone    , BOOL bRefreshNeeded);
    void SelectModule              (CPA_BaseObject * _pModule           , BOOL bRefreshNeeded);
    void SelectZDxOfActor          (CPA_BaseObject * _pInstance         ,
                                    ZDx_Object     * _pZDxObject        , BOOL bRefreshNeeded);
    void SelectZDxOfModule         (CPA_BaseObject * _pModule           ,
                                    ZDx_Object     * _pZDxObject        , BOOL bRefreshNeeded);

    CPA_BaseObject  * GetSelectedModule ();
    CPA_SuperObject * GetSelectedModuleSuperObject ();

    void                  SetShowActorButtonState     (BOOL _bButtonChecked);
    BOOL                  GetShowActorButtonState     ()       { return m_Check_Button_Show_Actor . GetCheck ();      }
    CPA_BaseObject  *     GetSelectedActor            ()       { return m_pSelectedActor;                             }
    CPA_SuperObject *     GetSelectedActorSuperObject ()       { return m_pSelectedActorSuperObject;                  }
    BOOL                  IsEditingZDxOfModule        ()       { return m_eList1Type == eListOfModule;                }

    BOOL                  IsEditingBoundingVolume      ()      { return m_Check_Button_Bounding_Volume . GetCheck (); }
    void                  EnterEditionOfBoundingVolume ();
    void                  LeaveEditionOfBoundingVolume ();

// ANNECY AV CLEAN_MEC {
/*
    BOOL                  IsEditingTestPoint           ()      { return m_Check_Button_Test_Point . GetCheck ();      }
    void                  EnterEditionOfTestPoint      ();
    void                  LeaveEditionOfTestPoint      ();
*/
// END ANNECY AV }
};


#endif  // __ZWLIST1_HPP
