/*=========================================================================*/
/* DEVMulti.hpp :	MultiDevice which manage the Device.*/
/* This is a part of the PCA project.*/
/**/
/* Version			1.0*/
/* Creation date	26/06/96*/
/* Revision date*/
/**/
/* (c) Ubi Studios 1996*/
/**/
/* DO NOT MODIFY THAT FILE. IF SOMETHING NEEDS TO BE CHANGE, PLEASE CONTACT*/
/* OLIVIER DIDELOT OR MARC VILLEMAIN.*/
/*=========================================================================*/
 
#ifndef __DEVMULTI_HPP__
#define __DEVMULTI_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 "CPAMdf.hpp"
#include "DEVDevic.hpp"
#include "CPAWorld.hpp"
 
class CPA_Contact;
class CPA_Interface;
class FRMBaseMenu;
class CPA_ProjectDoc;
class CPA_KeyActionConfiguration;
 
#define CPA_MSG_DRAWOBJECT          WM_USER + 0x6500
#define CPA_MSG_DRAWOBJECTEXCEPT0   WM_USER + 0x6501
 
#define MD_ONEDEVICE		(1)
#define MD_NOTRANSLATIONX	(1<<2)
#define MD_NOTRANSLATIONY	(1<<3)
#define MD_NOTRANSLATIONZ	(1<<4)
#define MD_NOTRANSLATION	(1<<5)
#define MD_NOROTATIONX		(1<<6)
#define MD_NOROTATIONY		(1<<7)
#define MD_NOROTATIONZ		(1<<8)
#define MD_NOROTATION		(1<<9)
#define MD_NOZOOMX			(1<<10)
#define MD_NOZOOMY			(1<<11)
#define MD_VIEW2D   (1<<12)
 
#define MAX_DEVICE (10+1)           /* Maximum number of Device.*/
 
 
typedef enum {MultiDevice3D = 1,MultiDevice2D,
			  SingleDevice3D, SingleDevice2D } tdeMultiDeviceType;
 
/*---------------------------------------------------------------------*/
class CPA_EXPORT DEV_MultiDevice : public CView
{
protected:
	DEV_MultiDevice();
	DECLARE_DYNCREATE(DEV_MultiDevice)
 
public:
	DEV_MultiDevice(int);
	virtual ~DEV_MultiDevice();
 
/*--------------------------------------------------------------------------------*/
/*								VARIABLE MEMBERS*/
/*--------------------------------------------------------------------------------*/
	BOOL				mbOnDestroy;	            /* Is MultiDevice is Destroy.*/
protected:
	short				mFlags;			            /* Flags defining behaviour of MultiDevice.*/
 
#ifdef ACTIVE_EDITOR
	DEV_Device		    *mpDevice[MAX_DEVICE];	    /* List of Devices.*/
	DEV_Device		    mDevice[MAX_DEVICE];
	BOOL			    mActivDevice[MAX_DEVICE];	/* List of active Devices.*/
	long			    m_lFocusDevice;				/* Number of the device who has the focus.*/
	long				m_lFocusPane;				/* Number of the pane who has the focus.		*/
 
public:
    CWnd                *m_p_oMultiToDraw;
    BOOL                mbForceDrawing;
    char                m_cIsAdditional;            /* Additional multi device ?*/
 
private:
	CPA_EditManager		*m_p_oEditManager;			/* For undo*/
	CPA_Contact         *m_p_oContact;	            /* Address of contact object.*/
	CPA_Interface		*m_p_oInterface;			/* Adress of Interface*/
	BOOL				m_bActive;
protected:
    CWnd                *m_p_oParent;               /* Parent of multidevice*/
 
#else
 
	DEV_Device		    mDeviceAlone;				/* When there is only one Device.*/
	BOOL			    mActivDeviceAlone;			/* Is the device is active.*/
#endif /* ACTIVE_EDITOR*/
 
/*--------------------------------------------------------------------------------*/
/*								GET-FUNCTIONS*/
/*--------------------------------------------------------------------------------*/
 
public:
	CPA_ProjectDoc      *GetDocument();
	int					GetFlags()				    { return mFlags;	}
	DEV_Device          *GetDevice(int);
	DEV_Device          *GetFocusDevice();
	DEV_Device          *GetFocusDevice2();
 
#ifdef ACTIVE_EDITOR	
	FRMBaseMenu			*GetParentFrame()			{ return (FRMBaseMenu *) GetParent()->GetParent(); }
#else
	CFrameWnd			*GetParentFrame()			{ return (CFrameWnd *) GetParent(); }
#endif
 
#ifdef ACTIVE_EDITOR
	void				Activate() { m_bActive = TRUE;};
	void				Disactivate() { m_bActive = FALSE;};
	BOOL				IsActive() { return m_bActive; };
 
	CPA_EditManager		*GetEditManager();
	CPA_Contact			*GetContact();
	CPA_Interface		*GetInterface();
    long                GetNumFocusDevice()         { return m_lFocusDevice; }
 
protected:
	DEV_MultiDevice3D	*GetPane_0_0();
private:
	UINT			    GetNextNumDevice();
#endif /* ACTIVE_EDITOR*/
 
 
/*--------------------------------------------------------------------------------*/
/*								SET-FUNCTIONS*/
/*--------------------------------------------------------------------------------*/
public:
	void                SetFlags(int flag)						    { mFlags = (short) flag; };
	void				SetBackgroundColor(COLORREF Color);
	void				SetBackgroundColor(char Red, char Green, char Blue);
	void				GetBackgroundColor(char *Red, char *Green, char *Blue);
 
#ifdef ACTIVE_EDITOR
	void				SetEditManager(CPA_EditManager *p_oMng);
	void                SetContact(CPA_Contact *p_oContact);
	void				SetInterface (CPA_Interface *p_oInterface);
	void				SetFocusPane(long lPane);
	void                SetActivDevice(int num, BOOL activ)	        { mActivDevice[num] = activ; };
	void                SetFocusDevice(int);
private:
	BOOL                SetDevice(DEV_Device *pDevice, UINT num);
#endif /* ACTIVE_EDITOR*/
 
 
/*--------------------------------------------------------------------------------*/
/*								TEST-FUNCTIONS*/
/*--------------------------------------------------------------------------------*/
public:
	BOOL                TestFlags(int flag)	    { return mFlags & flag; };
	BOOL                IsView2D()				{ return (mFlags & MD_VIEW2D); };
 
#ifdef ACTIVE_EDITOR
	BOOL                IsDevice(DEV_Device *);
	BOOL                IsActivDevice(int num)	{ return mActivDevice[num]; };
#endif /* ACTIVE_EDITOR*/
 
/*--------------------------------------------------------------------------------*/
/*								ACTION-FUNCTIONS*/
/*--------------------------------------------------------------------------------*/
public:
	void                FreezeAllButOne(UINT Number);
	void                FreezeAll();
	void                UnfreezeAll();
	void                Init();
    DEV_Device*         OpenNewDevice(int _iLeft = -1, int _iTop = -1, int _iWidth = -1, int _iHeight = -1);
    void                CloseAllDevices();
 
private:
	void                OnOpenDeviceBackground();
	void                DelFlags(int flag)	            { mFlags &= !flag; };
 
protected:
	void                AddFlags(int flag)	            { mFlags |= flag; };
 
#ifdef ACTIVE_EDITOR
public:
    void                UpdateColorTitle(void);
	virtual long        InitButtonsViewport(long)	        { return 0; };
 
	virtual void        DrawObject(void) {};
	virtual void        DrawEditorObject(void) {};
    virtual void        DrawObjectExcept0(void) {};
 
 
#endif /* ACTIVE_EDITOR*/
 
/* Overrides*/
	/* ClassWizard generated virtual function overrides*/
	/*{{AFX_VIRTUAL(DEV_MultiDevice)*/
	public:
	virtual void OnDraw(CDC* pDC);
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	/*}}AFX_VIRTUAL*/
 
/*--------------------------------------------------------------------------------*/
/*						        MESSAGE MAP FUNCTIONS*/
/*--------------------------------------------------------------------------------*/
protected:
	/*{{AFX_MSG(DEV_MultiDevice)*/
	afx_msg void    OnWindowPosChanged(WINDOWPOS FAR* lpwndpos);
	afx_msg int     OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void    OnDestroy();
	afx_msg BOOL    OnNotifyEx( UINT id, NMHDR * pNotifyStruct, LRESULT * result );
#ifdef ACTIVE_EDITOR
public:
	afx_msg void    OnDeviceTileHorz();
	afx_msg void    OnDeviceTileVert();
    afx_msg void    OnDeviceCascade();
	afx_msg void    OnOpenDevice();
    afx_msg void    OnCloseDevice();
    afx_msg void    OnCloseAllDevice();
    afx_msg void    OnMaximizeDevice(void);
    afx_msg void    OnRestoreDevice(void);
    afx_msg LONG    OnDrawObject(UINT, LONG);
    afx_msg LONG    OnDrawObjectExcept0(UINT, LONG);
#endif /* ACTIVE_EDITOR*/
	/*}}AFX_MSG*/
	DECLARE_MESSAGE_MAP()
};
 
inline CPA_ProjectDoc* DEV_MultiDevice::GetDocument()
{
    return (CPA_ProjectDoc*)m_pDocument;
}
 
#endif /* __DEVMULTI_HPP__*/
