/*========================================================================= * * EDTlType.cpp : Editor Lists - Implementation file * * * Version 1.0 * Creation date * Revision date * * Shaitan *=======================================================================*/ #include "stdafx.h" #ifdef ACTIVE_EDITOR #include "acp_base.h" #include "itf/CPALists.hpp" #include "itf/CPAInter.hpp" #include "itf/cpaproj.hpp" //################################################################################# // CLASS EDT_ListByType //################################################################################# /*=========================================================================== * Description: constructor * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ EDT_ListByType::EDT_ListByType (CPA_ObjectDLLBase *p_oDLL, CString csTypeName) { // DLL m_pObjectDLL = p_oDLL; // TypeName m_csTypeName = csTypeName; } //=========================================================================== //=========================================================================== EDT_ListByType::EDT_ListByType (void) { // DLL m_pObjectDLL = NULL; } //=========================================================================== //=========================================================================== EDT_ListByType::~EDT_ListByType (void) { CPA_BaseObject *pElem; // lists m_stListObjects.RemoveAll(); if (M_GetMainApp()->m_bLeavingApplication == FALSE) { while (m_stSortedList.GetCount()) { pElem = m_stSortedList.GetHead(); m_stSortedList.fn_bRemoveObject(pElem); delete pElem; } } } /*=========================================================================== * Description: set name * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void EDT_ListByType::SetTypeName (CString csTypeName) { // TypeName m_csTypeName = csTypeName; } /*=========================================================================== * Description: Reinit the list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void EDT_ListByType::fn_vReinit (void) { // lists m_stListObjects.RemoveAll(); } /*=========================================================================== * Description: Test unicity of the name * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ CPA_SuperObject * EDT_ListByType::GetObjectWithName (CString csName) { CPA_SuperObject *pElem; POSITION pos; // search the list for (pElem = m_stListObjects.GetHeadElement(pos); pElem; pElem = m_stListObjects.GetNextElement(pos)) { // search for the name if (pElem->GetName().CompareNoCase(csName) == 0) return pElem; } // name was not found return NULL; } //################################################################################# // CLASS EDT_ListByDLL //################################################################################# /*=========================================================================== * Description: constructor * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ EDT_ListByDLL::EDT_ListByDLL (CPA_ObjectDLLBase *p_oDLL) { // parameters m_pDLLObject = p_oDLL; // reinit list m_stListConcerned.RemoveAll(); m_stListSelected.RemoveAll(); m_stListProtectConcerned.RemoveAll(); m_stListProtectSelected.RemoveAll(); } EDT_ListByDLL::~EDT_ListByDLL (void) { // remove selection m_stListConcerned.RemoveAll(); m_stListSelected.RemoveAll(); // remove protect m_stListProtectConcerned.RemoveAll(); m_stListProtectSelected.RemoveAll(); // delete list by type while (m_stListOfListByType.GetCount()) delete (m_stListOfListByType.RemoveTail()); } /*=========================================================================== * Description: Reinit the list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void EDT_ListByDLL::fn_vReinit (void) { EDT_ListByType *pListType; POSITION pos; // reinit list all types m_stListAllTypes.fn_vReinit(); // reinit list by type for (pListType = m_stListOfListByType.GetHeadElement(pos); pListType; pListType = m_stListOfListByType.GetNextElement(pos)) pListType->fn_vReinit(); // reinit selection m_stListConcerned.RemoveAll(); m_stListSelected.RemoveAll(); // reinit protect m_stListProtectSelected.RemoveAll(); m_stListProtectConcerned.RemoveAll(); } /*=========================================================================== * Description: Reinit sorted list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void EDT_ListByDLL::fn_vUpdateSortedList (void) { /* EDT_ListByType *pListType; POSITION pos; // update list all types m_stListAllTypes.m_stSortedList.fn_vReinitSortedList((CPA_List *) &m_stListAllTypes.m_stListObjects); // update list by type for (pListType = m_stListOfListByType.GetHeadElement(pos); pListType; pListType = m_stListOfListByType.GetNextElement(pos)) pListType->m_stSortedList.fn_vReinitSortedList((CPA_List *) &pListType->m_stListObjects); */ } /*=========================================================================== * Description: Update the list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void EDT_ListByDLL::fn_vUpdateListObject (CPA_SuperObject *pEdObj, tdeListUpdateMode eType) { EDT_ListByType *pListType; POSITION pos; pListType = GetListByType(pEdObj->GetRealTypeName()); // insert ? if ((eType == E_lum_Insert) || (eType == E_lum_ReInsert)) { // update the lists by type m_stListAllTypes.m_stListObjects.AddTail(pEdObj); m_stListAllTypes.m_stSortedList.fn_bAddObject(pEdObj); // update corresponding list if (pListType) { pListType->m_stListObjects.AddTail(pEdObj); pListType->m_stSortedList.fn_bAddObject(pEdObj); } } // delete ? else if (eType == E_lum_Delete) { // update the lists by type pos = m_stListAllTypes.m_stListObjects.Find(pEdObj, NULL); if (pos) m_stListAllTypes.m_stListObjects.RemoveAt(pos); m_stListAllTypes.m_stSortedList.fn_bRemoveObject(pEdObj); // update corresponding list if (pListType) { pos = pListType->m_stListObjects.Find(pEdObj, NULL); if (pos) pListType->m_stListObjects.RemoveAt(pos); pListType->m_stSortedList.fn_bRemoveObject(pEdObj); } } } /*=========================================================================== * Description: Update the list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void EDT_ListByDLL::fn_vUpdateListSelect (CPA_SuperObject *pEdObj, tdeListUpdateMode eType, BOOL bIsSelected) { POSITION pos; // update list concerned pos = m_stListConcerned.Find(pEdObj, NULL); // insert ? if ((eType == E_lum_Insert)&&(!pos)) m_stListConcerned.AddTail(pEdObj); // delete ? if ((eType == E_lum_Delete)&&(pos)) m_stListConcerned.RemoveAt(pos); // update list selected if (bIsSelected) { pos = m_stListSelected.Find(pEdObj, NULL); // insert ? if ((eType == E_lum_Insert)&&(!pos)) m_stListSelected.AddTail(pEdObj); // delete ? if ((eType == E_lum_Delete)&&(pos)) m_stListSelected.RemoveAt(pos); } } /*=========================================================================== * Description: Update the list * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ void EDT_ListByDLL::fn_vUpdateListProtect (CPA_SuperObject *pEdObj, tdeListUpdateMode eType, BOOL bIsSelected) { POSITION pos; // update list concerned pos = m_stListProtectConcerned.Find(pEdObj, NULL); // insert ? if ((eType == E_lum_Insert)&&(!pos)) m_stListProtectConcerned.AddTail(pEdObj); // delete ? if ((eType == E_lum_Delete)&&(pos)) m_stListProtectConcerned.RemoveAt(pos); // update list selected if (bIsSelected) { pos = m_stListProtectSelected.Find(pEdObj, NULL); // insert ? if ((eType == E_lum_Insert)&&(!pos)) m_stListProtectSelected.AddTail(pEdObj); // delete ? if ((eType == E_lum_Delete)&&(pos)) m_stListProtectSelected.RemoveAt(pos); } } /*=========================================================================== * Description: Test unicity of the name * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ CPA_SuperObject * EDT_ListByDLL::GetObject (char *szTypeName, char *szName) { EDT_ListByType *pListType; if (szTypeName) pListType = GetListByType (szTypeName); else pListType = &m_stListAllTypes; if (pListType) return pListType->GetObjectWithName(szName); // name was not found return NULL; } /*=========================================================================== * Description: Test unicity of the name * Creation date: * Author: Shaitan *--------------------------------------------------------------------------- * *--------------------------------------------------------------------------- * Revision date: Author: *=========================================================================*/ EDT_ListByType * EDT_ListByDLL::GetListByType (CString csTypeName) { EDT_ListByType *pListType; POSITION pos; // all types if (csTypeName == "All Types") return &m_stListAllTypes; // list by type for (pListType = m_stListOfListByType.GetHeadElement(pos); pListType; pListType = m_stListOfListByType.GetNextElement(pos)) { if (csTypeName == pListType->GetTypeName()) return pListType; } // not found return NULL; } #endif // ACTIVE_EDITOR