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


#ifndef __ZWLIST2_HPP
#define __ZWLIST2_HPP

#pragma once

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

// Physical Object dll "include"
class EditorPO;

// Family dll "include"
class CPA_Family;
// ANNECY AV CLEAN_MEC {
//class CPA_TestPointsList;
//class CPA_TestPointNode;
// END ANNECY AV }

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


//-----------------------
typedef enum eSharedMode_ { eNoSharedMode , eCommon , eShared , eVirge } tdeSharedMode;

//-------------------------------
typedef struct stListElementData_
{
    tdeTreeElementType    eType;
    ZDx_Object          * pZDxObject;
    CPA_SuperObject     * pZDxSuperObject;
    CString               csNameInNameList;
    tdeSharedMode         eSharedMode;
    // Used for the test points
// ANNECY AV CLEAN_MEC {
//    DNM_tdeKindOfPoint    eKindOfPoint;
//    CPA_TestPointNode   * pTestPoint;
// END ANNECY AV }
} tdstListElementData;


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

// Dialog Data
	//{{AFX_DATA(CList2Window)
	enum { IDD = IDD_ZDD_List2_Window };
	CComboBox	m_Combo_Box_List;
	CListBox m_List_Ctrl_2;
	BOOL	m_bShowZDD;
	BOOL	m_bShowZDE;
	BOOL	m_bShowZDM;
	BOOL	m_bShowZDR;
	CString	m_Combo_Box_String_List;
	//}}AFX_DATA

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CList2Window)
	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(CList2Window)
	afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
	afx_msg void On_Button_All_ZDx();
    afx_msg void On_Button_No_ZDx();
    afx_msg void On_Button_New_List();
	afx_msg void On_Check_Boxes_ZDx();
	afx_msg void On_Selection_Has_Changed_List_Ctrl_2(/*NMHDR* pNMHDR, LRESULT* pResult*/);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void On_Selection_Has_Changed_Combo_Box_List();
	//}}AFX_MSG
    afx_msg BOOL SetToolTipText(UINT uiControlId , NMHDR *pNMHDR, LRESULT *pResult);
	DECLARE_MESSAGE_MAP()

// Personal data
private:
    ZDx_Interface        *  m_pZDxInterface;
    CImageList              m_stImageList;
    CToolTipCtrl            m_ToolTipCtrl;
    HCURSOR                 m_hCursorDragAndDrop;
    HCURSOR                 m_hCursorNoDragAndDrop;
    HCURSOR                 m_hPreviousCursor;
    HICON                   m_hIconCommon;
    HICON                   m_hIconShared;
    HICON                   m_hIconVirge;
    HICON                   m_hIconMotorDisplayOn;
    HICON                   m_hIconMotorDisplayOff;
    CPA_BaseObject       *  m_pActor;
    CPA_SuperObject      *  m_pActorSuperObject;
    EditorPO             *  m_pModule;
    CPA_SuperObject      *  m_pModuleSuperObject;

    EdtList              *  m_pListOfZdd;
    EdtList              *  m_pListOfZde;
    EdtList              *  m_pListOfZdm;
    EdtList              *  m_pListOfZdr;

    ZDx_Object           *  m_pZdd;
    ZDx_Object           *  m_pZde;
    ZDx_Object           *  m_pZdm;
    ZDx_Object           *  m_pZdr;

    BOOL                    m_bIsCreatingList;    // Is TRUE when creating a list. Becomes FALSE when the list is created
    BOOL                    m_bIsSelectingZDx;    // Is TRUE when selecting a ZDx. Becomes FALSE when the ZDx is selected
    BOOL                    m_bIsInsideOnHasChanged;// Is TRUE when we are inside the On_Selection_Has_Changed_List_Ctrl_2 (to prevent recursiv call)
    BOOL                    m_bMustUpdateDisplay; // When TRUE, the On_Selection_Has_Changed_List_Ctrl_2 must update the display
    BOOL                    m_bIsSelectingPoAsZdr;// Is TRUE when the user has to select a PO to set as Zdr
    BOOL                    m_bRightDragAndDrop;  // Is TRUE during a right drap and drop.
    int                     m_DragedItem;         // The draged element
    int                     m_SwitchedItem;       // which is switch with another element

    char *     GetToolTipTextForList  ();
    void       OnMouseMoveRightDragAndDrop (CPoint Point);
    void       MoveWindow             (CWnd * , int _TranslationX , int _TranslationY);    // Used to move a control into the CList2Window
    void       DrawLineInList         (LPDRAWITEMSTRUCT);

    void       OnLButtonDown          (UINT, CPoint);
    void       OnRButtonDown          (UINT, CPoint);
	void       OnRButtonUp            (UINT, CPoint);

    int        InsertZDxObjectInList  (ZDx_Object * , tdeTreeElementType , CString NameInNameList , tdeSharedMode);
    void       FillComboBoxList       (tdeZDxType , EdtList *);    // Fill the combo box list with the list of EdtList of the given type
// ANNECY AV CLEAN_MEC {
//    void       FillComboBoxList       (CPA_Family * , CPA_TestPointsList * _pListOfTestPointToSelect);
                                                                   // Fill the combo box list with the list of test points of the given family
// END ANNECY AV }
    void       FillComboBoxListWithSelection ();
    void       CreateOneListOfZDx     (EdtList * _pListOfZDx , CPA_tdoNameList * _pNameList , tdeTreeElementType);
    void       SwitchItems            (int _Item1 , int _Item2);
    EdtList *  GetBigGlobalZone       (tdeTreeElementType);
    EdtList *  GetBigGlobalZone       (tdeZDxType);
    long       GetIndexInList         (int _Item , tdeTreeElementType eElementType);
    tdeZDxType         ConvertElementTypeToZDxType (tdeTreeElementType);
    tdeTreeElementType ConvertZDxTypeToElementType (tdeZDxType);
    void       DeleteZDx              ();

public:
    CPA_BaseObject       * GetActor             ()             { return m_pActor;                   }
    EditorPO             * GetModule            ()             { return m_pModule;                  }
    CPA_SuperObject      * GetActorSuperObject  ()             { return m_pActorSuperObject;        }
    CPA_SuperObject      * GetModuleSuperObject ()             { return m_pModuleSuperObject;       }
    CPA_SuperObject      * GetSelectedZDxSuperObject ();
	ZDx_Object           * GetSelectedZDx ();                  // Get the selected ZDX
    ZDx_Object           * GetSelectedZDx (tdeZDxType * ,
                                           long * plPosition); // Get the selected ZDx and its type and position
    ZDx_Object           * GetFirstZDxOfType (tdeZDxType);     // Get the first ZDx of the given type in the list
    tdeZDxType             GetZDxTypeOfSelection      ();      // Get the type of the selected ZDx
// ANNECY AV CLEAN_MEC {
//    DNM_tdeKindOfPoint     GetTypeOfSelectedTestPoint ();      // When editing the test points, return the type of the selected test point
//    CPA_TestPointsList   * GetListOfTestPoint         ();      // When editing the test points, return the selected list of test points
// END ANNECY AV }
    long                   GetNumberOfUnusedPosition  ();      // Get the number of unused position into the list

    void SetZDxInterface   (ZDx_Interface * _pZDxInterface)    { m_pZDxInterface = _pZDxInterface;     }
    void CreateListOfZDx         (CPA_SuperObject      * _pActorSuperObject ,
                                  EdtList              * _pListOfZdd ,
                                  EdtList              * _pListOfZde ,
                                  EdtList              * _pListOfZdm ,
                                  EdtList              * _pListOfZdr ,
                                  BOOL                   _bUpdateDisplayAndEditWindow = TRUE ,
                                  BOOL                   _bUpdateCheckBox = TRUE);
    void CreateListOfZDxOfModule (CPA_SuperObject     * _pModuleSuperObject ,
                                  BOOL                  _bUpdateDisplayAndEditWindow = TRUE);

    void CreateBoundingVolume    (CPA_SuperObject * _pActorSuperObject , ZDx_Object * _pBoundingVolume ,
                                  BOOL _bUdateEditWindow = TRUE, BOOL _bShowBdV = TRUE);

// ANNECY AV CLEAN_MEC {
/*
    void CreateListOfTestPoint   (CPA_SuperObject * _pActorSuperObject , CPA_TestPointsList * _pTestPointList = NULL ,
                                  BOOL _bUpdateEditWindow = TRUE);
    void LeaveEditionOfTestPoint ();
*/
// END ANNECY AV }

    void ReCreateListOfZDx (BOOL _bUpdateDisplayAndEditWindow = TRUE ,
                            BOOL _bUpdateCheckBox             = TRUE);
    void CreateASpecificListOfZDx  (CPA_SuperObject * _pActorSuperObject ,
                                    EdtList         * _pListOfZDx ,
                                    tdeZDxType        _eZDxType);
    BOOL          SelectZDx        (ZDx_Object      * _pZDxObjectToSelect ,
                                    BOOL              _bSelectEvenIfNull = FALSE ,
                                    BOOL              _bUpdateEditWindow = TRUE); // Select a ZDx in the list
    BOOL          SelectZDx        (tdeZDxType _eZDxType , long _lPosition); // Select the ZDx which have the given
                                                                             // type and the given position in the list
    unsigned char GetZDxTypeToShow ();                                       // Return the type of ZDx to show
    void          SetZDxCheckBoxes (tdeZDxType);
    void          SetZDxCheckBoxes (BOOL _bShowZDD , BOOL _bShowZDE , BOOL _bShowZDM , BOOL _bShowZDR);
};


#endif  // __ZWLIST2_HPP
