/*=========================================================================
*
* CPASubM.hpp
*
*
* Version			1.0
* Creation date
* Revision date
*
* FBF
*=======================================================================*/
#ifdef ACTIVE_EDITOR
 
#ifndef __EDTSUBM_HPP__
#define __EDTSUBM_HPP__
 
/****************************************/
#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
/****************************************/
 
#include "CustomID.h"
#include <afxtempl.h>
 
class CPA_EditorBase;
class EDT_SubMenu;
 
typedef enum {
    C_SubMenuEdit,
    C_SubMenuEditor,
    C_SubMenuTool,
/*ANNECY Shaitan NewInterface 24/03/98 {*/
    C_SubMenuLoad,
    C_SubMenu3DView,
	C_SubMenuSpecific,
/*ENDANNECY Shaitan NewInterface }*/
    C_SubMenuPreference,
    C_PopupMenu,
    C_SubSubMenu
} tde_SubMenu;
 
typedef enum {
    C_SMEEntry,
    C_SMESeparator,
    C_SMEMenu
} tde_SubMenuElementType;
 
 
/*#########################*/
/* Base class*/
/*#########################*/
class EDT_SubMenuElement
{
/* datas*/
protected:
    tde_SubMenuElementType  m_eType;
public:
    EDT_SubMenuElement(tde_SubMenuElementType _eType)   { m_eType = _eType; }
    virtual ~EDT_SubMenuElement()   {}
/* methods*/
public:
    tde_SubMenuElementType mfn_eGetElementType()    { return m_eType; }
};
 
/*#########################*/
/* Entry*/
/*#########################*/
class CPA_EXPORT EDT_SubMenuEntry : public EDT_SubMenuElement
{
protected:
 
    char           *m_p_cText;			/* text of entry in menu*/
    UINT            m_uiID;             /* Intern ID*/
    UINT            m_IDCmdMsg;         /* ID of message to send to owner*/
    CPA_EditorBase *m_pOwner;			/* concerned Editor*/
    BOOL            m_bChecked;         /* check entry menu*/
    BOOL            m_bEnabled;         /* enable entry menu*/
public:
    EDT_SubMenuEntry(CPA_EditorBase *pOwner, char *p_cName, UINT uiMsgID, UINT uiIntID, BOOL _bCheck = FALSE, BOOL _bEnable = TRUE);
    virtual ~EDT_SubMenuEntry();
 
    void        fn_vSetCheck    (BOOL _bCheck)              { m_bChecked = _bCheck; }
    void        fn_vSetEnable   (BOOL _bEnable)             { m_bEnabled = _bEnable; }
    BOOL        GetCheck        (void)                      { return m_bChecked; }
    BOOL        GetEnable       (void)                      { return m_bEnabled; }
    UINT        GetInternalID   (void)                      { return m_uiID; }
    char        *GetText        (void)                      { return m_p_cText;}
	UINT		GetCmdID		(void)						{ return m_IDCmdMsg; }
	CPA_EditorBase * GetOwner	(void)						{ return m_pOwner; } 
    virtual UINT SendCommand    (EDT_SubMenu *_p_oSubMenu);
};
 
/*#########################*/
/* Separator*/
/*#########################*/
class EDT_SubMenuSeparator : public EDT_SubMenuElement
{
/* methods*/
public:
    EDT_SubMenuSeparator() : EDT_SubMenuElement(C_SMESeparator) {};
};
 
/*#########################*/
/* SubMenu*/
/*#########################*/
class CPA_EXPORT EDT_SubMenu : public EDT_SubMenuElement, public CList<EDT_SubMenuElement*,EDT_SubMenuElement*>
{
/* datas*/
protected:
    tde_SubMenu     m_eSubMenu;
    UINT            m_uiInternalIDStart;
    UINT            m_uiInternalID;
    BOOL            m_bHasFather;
    EDT_SubMenu    *m_p_oFather;
    char           *m_szName;
/* methods*/
public:
            EDT_SubMenu(tde_SubMenu _eSubMenu,UINT _uiIDStart = C_CustomIDUserEnd);
    virtual ~EDT_SubMenu();
 
            tde_SubMenu GetSubMenuType      (void);
    virtual EDT_SubMenu *fn_p_oGetNewSubMenu(char *_szName, tde_SubMenu _eMenuType = C_SubSubMenu);
            void        fn_vSetIDStart      (UINT _uiIDStart)   { m_uiInternalIDStart = _uiIDStart; }
            void        AddASeparator       (void);
    virtual void        AddAnEntry          (CPA_EditorBase *p_oOwner = NULL, char *p_cText = NULL, UINT uiEntryID = 0, BOOL _bCheck = FALSE, BOOL _bEnable = TRUE);
    virtual void        AddASubMenu         (EDT_SubMenu *_p_oSubMenu);
    virtual void        Build               (CMenu *pPopupMenu = NULL);
            UINT        _OnCommand          (UINT uiInternalID);
            void        Clear               (void);
			BOOL		fn_bFindCmdID		(UINT uiInternalID, CPA_EditorBase **, UINT *CmdID);
            void        fn_vSetFather       (EDT_SubMenu *_p_oFather);
            void        fn_vSetName         (char *_szName);
            char        fn_cGrayedItem (CMenu *pPopupMenu, char *szItem) ;
protected:
            UINT        mfn_vGetNextInternalID  (void);
            void        DeleteEntirePopupMenu   (CMenu* pPopupMenu);		
            void        fn_vGrayedAllMenuItem ( CMenu *pPopupMenu );
};
 
#endif /* __EDTSUBM_HPP__*/
#endif /* ACTIVE_EDITOR*/
