/* (c) Ubi Studios 1996*/
/* See Vincent Greco for any comment or question*/
 
#ifndef __LSTEDPAR_HPP__
#define __LSTEDPAR_HPP__
 
#include "LstEdLst.Hpp"
 
 
#define ChildClass	\
CPA_EdChild<EditorClass, tdxHandleToStruct, tdxPointerToAnchorStruct>
 
#define ParentClass	\
CPA_EdParent<EditorClass,tdxHandleToStruct,tdxPointerToAnchorStruct>
 
TemplateParam class CPA_EdParent;
 
TemplateParam
class CPA_EdChild : public ElementClass
{
private:
/*	ParentClass * pParent;*/
public:
	CPA_EdChild(void)
    {
/*		pParent=NULL;*/
	}
	virtual ~CPA_EdChild(void){}
 
public:
	ParentClass * GetParent() {return (ParentClass *)GetList();}
/*	void SetParent(ParentClass * _pParent, BOOL ModifyEngine=TRUE);*/
/*	void Isolate(BOOL ModifyEngine=TRUE);*/
 
};
 
TemplateParam
class CPA_EdParent : virtual public CPA_EdMot<tdxPointerToAnchorStruct>, public ListClass
{
private:
/*	CPA_EdList<EditorClass, tdxHandleToStruct, tdxPointerToAnchorStruct> m_List;*/
public:
	void SetStruct(tdxPointerToAnchorStruct pNewStruct)
	{
		CPA_EdMot<tdxPointerToAnchorStruct>::SetStruct(pNewStruct);
		SetEngineAnchor(pNewStruct);
	}
 
public:
    CPA_EdParent(void) {SetEngineAnchor(GetStruct());}/*m_List.SetOwner(this);/*LST_M_InitParent(GetStruct());  }*/
    virtual ~CPA_EdParent(void){}
 
/*	CPA_EdList<EditorClass, tdxHandleToStruct, tdxPointerToAnchorStruct> *GetList(){return &m_List;}*/
 
/*
	POSITION InsertAfter( POSITION position, ChildClass* newElement, BOOL ModifyEngine=TRUE);
    POSITION InsertBefore( POSITION position, ChildClass* newElement, BOOL ModifyEngine=TRUE);
	POSITION AddHead(ChildClass* newElement, BOOL ModifyEngine=TRUE);
	POSITION AddTail(ChildClass* newElement, BOOL ModifyEngine=TRUE);
	void RemoveAt(POSITION position, BOOL ModifyEngine=TRUE);
	EditorClass* RemoveHead(BOOL ModifyEngine=TRUE);
	EditorClass* RemoveTail(BOOL ModifyEngine=TRUE);
	void RemoveAll(BOOL ModifyEngine=TRUE);
*/
};
 
 
/*both Parent and Child (homogenous tree)*/
 
TemplateParam
class CPA_EdNode : public ElementClass, public ListClass
{
private:
/*	CPA_EdList<EditorClass, tdxHandleToStruct, tdxPointerToAnchorStruct> m_List;*/
public:
	void SetStruct(tdxPointerToAnchorStruct pNewStruct)
	{
		CPA_EdMot<tdxPointerToAnchorStruct>::SetStruct(pNewStruct);
		SetEngineAnchor(pNewStruct);
	}
	EditorClass * GetParent() {return (EditorClass *)GetList();}
 
public:
    CPA_EdNode(void) {SetEngineAnchor(GetStruct());}
    virtual ~CPA_EdNode(void){}
 
};
 
 
/*------------------------------------------------------------------*/
 
 
 
/*
//redondance avec SetList de ElementClass ?
TemplateParam void ChildClass::SetParent(ParentClass * _pParent, BOOL ModifyEngine)
{
	pParent=_pParent;
}
*/
 
 
/*
TemplateParam void ChildClass::Isolate(BOOL ModifyEngine)//can be called as many times as you want.
{
	if(pParent)
	{
		POSITION P=pParent->GetList()->Find(this);
		pParent->GetList()->RemoveAt(P, ModifyEngine);
//		pParent=NULL;//???
	}
}
 
 
TemplateParam void ChildClass::InsertBetween(tdxHandleToStruct pPrev, tdxHandleToStruct pNext)
{
	if(pParent)
	{
		POSITION P=pParent->GetList()->Find(this);
		pParent->GetList()->RemoveAt(P);
//		pParent=NULL; InsertBetween is always followed by a SetParent
	}
	LST_M_StaticInsertBetween(GetStruct(),pPrev,pNext);
}
 
 
//-----------------------------------------
 
 
TemplateParam POSITION ParentClass::InsertAfter(POSITION position, ChildClass* newElement, BOOL ModifyEngine)
{
//	newElement->SetParent(this, ModifyEngine);
	return ListClass::InsertAfter(position, newElement);
}
 
 
TemplateParam POSITION ParentClass::InsertBefore(POSITION position, ChildClass* newElement, BOOL ModifyEngine)
{
//	newElement->SetParent(this, ModifyEngine);
	return ListClass::InsertBefore(position, newElement);
}
 
TemplateParam POSITION ParentClass:: AddHead(ChildClass* newElement, BOOL ModifyEngine )
{
//	newElement->SetParent(this, ModifyEngine);
	return ListClass::AddHead(newElement);
}
 
 
TemplateParam POSITION ParentClass::AddTail(ChildClass* newElement, BOOL ModifyEngine )
{
//	newElement->SetParent(this, ModifyEngine);
	return ListClass::AddTail(newElement);
}
 
 
TemplateParam void ParentClass::RemoveAt(POSITION position, BOOL ModifyEngine)
{
//	GetAt(position)->SetParent(NULL, ModifyEngine);
	ListClass::RemoveAt(position);
}
 
TemplateParam EditorClass* ParentClass::RemoveHead(BOOL ModifyEngine)
{
	ChildClass *pOldObj = ListClass::RemoveHead();
//	pOldObj->SetParent(NULL, ModifyEngine);
	return (EditorClass*)pOldObj;
}
 
 
TemplateParam EditorClass* ParentClass::RemoveTail(BOOL ModifyEngine)
{
	ChildClass *pOldObj = ListClass::RemoveTail();
//	pOldObj->SetParent(NULL, ModifyEngine);
	return (EditorClass*)pOldObj;
}
 
TemplateParam void ParentClass::RemoveAll(BOOL ModifyEngine)//not tested !!!
{
	ListClass::RemoveAll();
}
 
*/
 
#endif /*__LSTEDPAR_HPP__*/
