#ifndef __FRMBASE_HPP__
#define __FRMBASE_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
/****************************************/
 
#ifdef ACTIVE_EDITOR
 
/* To associate another view to a frame*/
#define M_FRMAssociateView(pFrame, CClassView)\
{\
	CCreateContext		creat;\
    CClassView          *pView;\
	creat.m_pNewViewClass = RUNTIME_CLASS(CClassView);\
	creat.m_pCurrentDoc = M_GetMainWnd()->GetActiveView()->GetDocument();\
	pView = (CClassView *) ((pFrame)->CreateView(&creat));\
	pView->ShowWindow(TRUE);\
	(pFrame)->SetActiveView(pView, TRUE);\
}
 
class CPA_MainWorld;
 
/* Types of sizing*/
#define FRM_C_MoveLeft      0x01
#define FRM_C_MoveRight     0x02
#define FRM_C_MoveTop       0x04
#define FRM_C_MoveBottom    0x08
 
/* A link to another window*/
class FRMBase;
typedef struct tdstFRMLink_
{
    char            cLinkSame;
} tdstFRMLink;
 
/* Base class of a window*/
class CPA_EXPORT FRMBase : public CFrameWnd
{
 
public:
    CPA_MainWorld  *m_p_oMainWorld;
    BOOL            m_bAlreadySize;     /* For recursive sizing*/
    unsigned int    m_uiHitTest;
    char            m_cLock;            /* Can be size in a given direction*/
    CRect           m_oLastPos;         /* Last position for refresh*/
    CRect           m_oCurPos;
    CRect           m_oMainPos;
 
public:
    tdstFRMLink     m_stWinTop;         /* Links with other windows*/
    tdstFRMLink     m_stWinBottom;
    tdstFRMLink     m_stWinLeft;
    tdstFRMLink     m_stWinRight;
    int             m_iCol, m_iRow;     /* Type of window*/
    BOOL            m_bKeepPos;         /* We want to keep last position*/
    int             m_iInitWidth;       /* First width and height*/
    int             m_iInitHeight;
    DWORD           m_dwCaptionStyle;   /* Style of caption of window*/
 
public:
    FRMBase(void);
	DECLARE_DYNCREATE(FRMBase)
 
    virtual BOOL    CreateBase(LPCTSTR, int, int, CPA_MainWorld*, CCreateContext *pContext = NULL);
    void            mfn_vEnableCaption(BOOL);
    CPA_MainWorld*  GetMainWorld()  { return m_p_oMainWorld; }
    virtual void    fn_vOnActivate(void)   {};
    void            mfn_vComputeWidthWindow(int);
    void            mfn_vWidthWindow(int);
    void            mfn_vComputeHeightWindow(int);
    void            mfn_vHeightWindow(int);
 
protected:
    afx_msg void OnNcLButtonDown(UINT, CPoint);
	afx_msg UINT OnNcHitTest(CPoint);
    afx_msg void OnSize(UINT, int, int);
    afx_msg void OnInitMenu(CMenu *);
    afx_msg void OnGetMinMaxInfo(MINMAXINFO FAR *);
    DECLARE_MESSAGE_MAP()
};
 
#endif /* ACTIVE_EDITOR*/
 
#endif /* __FRMBASE_HPP__*/
