// Implementation for the definition of the class representing a Mechanical Card ///////////////////////////////////////////////////////////////////////////////// #include "StdAfx.h" #include "EMECCrdT.hpp" #include "EMECVwMS.hpp" #include "EMECDoc.hpp" #include "EMECFmMn.hpp" #include "EMECCnst.hpp" #include "EMECDgQu.hpp" #include "EMECClBk.hpp" #include "EMECCStr.hpp" #include "_Minterf.hpp" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //*************************************************************************** CPA_Meca_CardType::CPA_Meca_CardType(CString csName, DNM_tdeMechanicsID tdeMotorID) { m_csName = csName; m_tdeMotorID = tdeMotorID; m_pclCurrentCard = NULL; m_p_fn_vUnallocate = NULL; m_p_fn_vFill = NULL; m_p_fn_vSave = NULL; m_crControlZone = CRect(0,0,0,0); m_bControlsAreHidden = TRUE; m_bAtLeastOneCardOfTheCardTypeHasBeenLoaded = FALSE; } //*************************************************************************** CPA_Meca_CardType::~CPA_Meca_CardType() { } //************************************************************************************** //********************************** Controls **************************************** //************************************************************************************** //************************************************************************************** void CPA_Meca_CardType::m_fn_vAddDecimalControl(long double ldMinValue, long double ldMaxValue, char cDataLength, BOOL bReadOnly, CString _csControlName) { m_pri_fn_vAddOwnerDataToControl( m_clControlList.m_fn_pclAddDecimalControl( ldMinValue, ldMaxValue, cDataLength, bReadOnly, CTL_SPACING_TYPE__SINGLE_LINE, FALSE, _csControlName, TRUE, 0 //ANNECY BBB ) ); } //************************************************************************************** void CPA_Meca_CardType::m_fn_vAddBooleanControl(BOOL bReadOnly, CString _csControlName) { m_pri_fn_vAddOwnerDataToControl( m_clControlList.m_fn_pclAddBooleanControl( bReadOnly, CTL_SPACING_TYPE__SINGLE_LINE, FALSE, _csControlName, TRUE, 0 //ANNECY BBB ) ); } //************************************************************************************** void CPA_Meca_CardType::m_pri_fn_vAddOwnerDataToControl(CTL_Editor_Control *_pclControl) { if ( _pclControl != NULL ) { //OwnerData _pclControl->m_pub_fn_pclAddOwnerData((void *)this, TME_g_c_cs_ControlOwnerData_ParentCardType); } } //************************************************************************************** //************************************************************************************** //************************************************************************************** //************************************************************************************** //Creates all controls long CPA_Meca_CardType::m_fn_lCreateMSControls( CWnd *pclWnd, CRect crRect) { m_pclParentView = (CPA_Meca_MiniStrucView *)pclWnd; //Adds an item in the tree m_crDisplayRect = crRect; //Creates controls of the data list //// CTL_fn_vSetModuleInfo("TMe", CString("Type ") + m_csName); ///for TUT //// //Creates controls of the data list POSITION pos = m_clControlList.GetHeadPosition(); while ( pos != NULL ) (m_clControlList.GetNext(pos))->m_fn_bCreateControl(pclWnd); //// CTL_fn_vResetModuleInfo(); //// return 0L; } //************************************************************************************** //Hides all controls void CPA_Meca_CardType::m_fn_vHideAllControls() { //Hides controls of the data list m_clControlList.m_pub_fn_vHideAllControls(); m_bControlsAreHidden = TRUE; } //************************************************************************************** long CPA_Meca_CardType::m_fn_lOpen(CRect crRect) { CPoint clTopLeft; CPoint clTopRight; clTopLeft.y = clTopRight.y = crRect.top; clTopLeft.x = crRect.left + C_TABULATION; clTopRight.x = crRect.right; m_clControlList.m_pub_fn_vDisplayControlsInZone(clTopLeft, clTopRight); m_bControlsAreHidden = FALSE; return (clTopLeft.y - crRect.top); } //************************************************************************************** void CPA_Meca_CardType::m_fn_vClose() { //Hides controls of the list m_clControlList.m_pub_fn_vHideAllControls(); m_crControlZone = CRect(0,0,0,0); m_bControlsAreHidden = TRUE; } //************************************************************************************** void CPA_Meca_CardType::m_fn_vOffsetZone(long lOffset) { m_crControlZone.OffsetRect(0, lOffset); } //************************************************************************************** void CPA_Meca_CardType::m_fn_vGetMotorDatas() { //Gets motor data for all controls of the data list //And retrieves it in the control m_clControlList.m_pub_fn_vUpdateControlsWithEditedData(TRUE); } //************************************************************************************** CPA_Meca_Card *CPA_Meca_CardType::m_fn_pclGetEditedCard() { return m_pclCurrentCard; } //************************************************************************************** void CPA_Meca_CardType::m_fn_vSetEditedCard(CPA_Meca_Card *pclNewCard) { // ERROR_ASSERT( (pclNewCard != NULL) && (pclNewCard->fn_bIsAvailable()) ); m_pclCurrentCard = pclNewCard; } //************************************************************************************** CPA_Meca_CardList *CPA_Meca_CardType::m_fn_pclGetCardsList() { return (&m_clCardsList); } //************************************************************************************** unsigned long CPA_Meca_CardType::m_fn_ulGetCardsNumber() { return m_clCardsList.GetCount(); } //************************************************************************************** BOOL CPA_Meca_CardType::m_fn_bControlsAreHidden() { return m_bControlsAreHidden; } //************************************************************************************** CString CPA_Meca_CardType::m_fn_csGetCardTypeName() { return m_csName; } //************************************************************************************** void CPA_Meca_CardType::m_fn_vSetCardTypeName(CString csNewName) { m_csName = csNewName; } //*************************************************************************** //Get : The ID of the type of Mechanics (image of Motor ID) DNM_tdeMechanicsID CPA_Meca_CardType::m_fn_tdeGetMotorID() { return m_tdeMotorID; } //*************************************************************************** //The name of the File where this type of Cards are stored CString CPA_Meca_CardType::m_fn_csGetFileName() { return m_csFileName; } //*************************************************************************** void CPA_Meca_CardType::m_fn_vSetFileName(CString csNewName) { m_csFileName = csNewName; } //*************************************************************************** //The name of the Action for this type of Cards CString CPA_Meca_CardType::m_fn_csGetActionName() { return m_csActionName; } //*************************************************************************** void CPA_Meca_CardType::m_fn_vSetActionName(CString csNewName) { m_csActionName = csNewName; } //************************************************************************************** //************************************************************************************** //************************************************************************************** CPA_Meca_CardTypeList::CPA_Meca_CardTypeList() { } //************************************************************************************** CPA_Meca_CardTypeList::~CPA_Meca_CardTypeList() { m_fn_vEmptyList(); } //************************************************************************************** CPA_Meca_CardType* CPA_Meca_CardTypeList::m_fn_pclAddElement(CString csName, DNM_tdeMechanicsID tdeMotorID) { CPA_Meca_CardType *pclNewElement = new CPA_Meca_CardType(csName, tdeMotorID); AddTail(pclNewElement); return pclNewElement; } //************************************************************************************** void CPA_Meca_CardTypeList::m_fn_vEmptyList() { POSITION pos = GetHeadPosition(); while( pos != NULL ) delete (GetNext(pos)); RemoveAll(); } //************************************************************************************** //Gets a Type Card from its Motor ID CPA_Meca_CardType* CPA_Meca_CardTypeList::m_fn_pclGetTypeCardFromID(DNM_tdeMechanicsID tdeMotorID) { CPA_Meca_CardType *pclTypeCard; POSITION pos = GetHeadPosition(); BOOL bFound = FALSE; while ( (pos != NULL) && (!bFound) ) { pclTypeCard = GetNext(pos); bFound = ( pclTypeCard->m_fn_tdeGetMotorID() == tdeMotorID ); } if ( bFound ) return pclTypeCard; else return NULL; }