// Implementation file for the definition of an object list ///////////////////////////////////////////////////////////////////// #include "StdAfx.h" #include "ACP_Base.h" #include "ITF.h" #include "TAC.h" #include "EDACCnst.hpp" #include "CPA_CtlO.hpp" #include "_AInterf.hpp" #include "CPA_DatO.hpp" #include "CPA_NLL.hpp" #include "EDACDgNL.hpp" #include "EDACStrg.hpp" #include "EDACModl.hpp" //External Modules #include "ErO.h" //End of External Modules #undef CPA_WANTS_IMPORT #undef CPA_EXPORT #define CPA_WANTS_EXPORT #include "_Actors.hpp" #undef CPA_WANTS_EXPORT #define CPA_WANTS_IMPORT #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif //Constructor / Destructor //************************************************************************************** CPA_Editor_ObjectListControl::CPA_Editor_ObjectListControl(BOOL bReadOnly, BOOL bUserCanChangeAspect, BOOL bNoNames, BOOL bNoAlternateList, CTL_Editor_ControlList *_pclParentList, CString _csControlName, BOOL _bAcceptsToTakeNameOfData, //ANNECY BBB //Stefan Dumitrean 20-07-98 ( OAC buttons ) unsigned char ucInitialCurrentPair //End Stefan Dumitrean 20-07-98 ( OAC buttons ) ) : CTL_Editor_Control(CTL_DATA_TYPE__USE_USER_DEFINED_TYPE, bReadOnly, CTL_SPACING_TYPE__MULTI_LINE, bUserCanChangeAspect, _pclParentList, _csControlName, _bAcceptsToTakeNameOfData, //Stefan Dumitrean 20-07-98 ( OAC buttons ) ucInitialCurrentPair //End Stefan Dumitrean 20-07-98 ( OAC buttons ) ) { m_p_oPushButtonToEdit = NULL; m_p_oPushButtonToRename = NULL; m_p_oNamesCombo = NULL; m_p_oAlternateNamesCombo = NULL; m_bNoNames = bNoNames; m_bNoAlternateList = bNoAlternateList; } //************************************************************************************** CPA_Editor_ObjectListControl::~CPA_Editor_ObjectListControl() { } //Member functions //************************************************************************************** //Function called to create associated control BOOL CPA_Editor_ObjectListControl::m_fn_bCreateControl(CWnd *pclParentWnd) { BOOL bReturnValue = TRUE; m_pclParentWnd = pclParentWnd; m_pro_fn_bCreateBaseControls( C_OLIST_NAME_PERCENT_WIDTH, 27, C_EDIT_HEIGHT); CTL_Editor_BaseControl *pclBC; if ( !m_fn_bIsAlwaysReadOnly() ) { //Creates the combo box containing the names of the current name list m_p_oNamesCombo = new CTL_Editor_ComboBox(CTL_COMBO_BOX_TYPE_USE_USER_DEFINED_TYPE, WS_TABSTOP, this, m_pclParentWnd, OAC_COMBO_BOX_TYPE__OBJECTS_LIST_COMBO_BOX, OAC_COMBO_BOX_RETURN_CODE_VALUE__OBJECTS_LIST_NAMES); m_p_oNamesCombo->m_pub_fn_vSetSelChanged_CallBack(s_m_fn_vComboBoxSelChanged); m_p_oNamesCombo->m_pub_fn_vRegisterWindowsControl(m_pub_fn_csGetControlName() + " - ObjectList Name"); pclBC = m_pclListOfBaseControls->m_pub_fn_pclAddControlAtTail( m_p_oNamesCombo, m_p_oNamesCombo, this, CTL_BASE_CONTROL_DISPLAY_TYPE__NORMAL, C_OLIST_BOX_PERCENT_WIDTH, C_OLIST_BOX_MIN_WIDTH, C_OLIST_COMBO_BOX_HEIGHT, FALSE, FALSE); pclBC->m_pub_fn_vSetMustBeEnabledCallBack(s_m_fn_bComboMustBeEnabled); } m_p_oPushButtonToEdit = new CTL_Editor_Button("Edit", CTL_BUTTON_TYPE__USE_USER_DEFINED_TYPE, 0, this, m_pclParentWnd, OAC_BUTTON_TYPE__OBJECTS_LIST_BUTTON, OAC_BUTTON_RETURN_CODE_VALUE__OBJECTS_LIST_EDIT ); m_p_oPushButtonToEdit->m_pub_fn_vSetButtonHasBeenClicked_CallBack(s_m_fn_vAButtonHasBeenClicked); m_p_oPushButtonToEdit->m_pub_fn_vRegisterWindowsControl(m_pub_fn_csGetControlName() + " - ObjectList Edit"); pclBC = m_pclListOfBaseControls->m_pub_fn_pclAddControlAtTail(m_p_oPushButtonToEdit, m_p_oPushButtonToEdit, this, CTL_BASE_CONTROL_DISPLAY_TYPE__NORMAL, C_OLIST_BUTTON_PERCENT_WIDTH, C_OLIST_BUTTON_MIN_WIDTH, C_OLIST_BUTTON_HEIGHT); pclBC->m_pub_fn_vSetMustBeEnabledCallBack(s_m_fn_bButtonMustBeEnabled); if ( !m_bNoAlternateList && !m_fn_bIsAlwaysReadOnly() ) { //Creates the combo box containing the names of the current name list m_p_oAlternateNamesCombo = new CTL_Editor_ComboBox(CTL_COMBO_BOX_TYPE_USE_USER_DEFINED_TYPE, WS_TABSTOP, this, m_pclParentWnd, OAC_COMBO_BOX_TYPE__OBJECTS_LIST_COMBO_BOX, OAC_COMBO_BOX_RETURN_CODE_VALUE__OBJECTS_LIST_ALTERNATE_NAMES); m_p_oAlternateNamesCombo->m_pub_fn_vSetSelChanged_CallBack(s_m_fn_vComboBoxSelChanged); m_p_oAlternateNamesCombo->m_pub_fn_vRegisterWindowsControl(m_pub_fn_csGetControlName() + " - ObjectList AlternateNames"); pclBC = m_pclListOfBaseControls->m_pub_fn_pclAddControlAtTail( m_p_oAlternateNamesCombo, m_p_oAlternateNamesCombo, this, CTL_BASE_CONTROL_DISPLAY_TYPE__NORMAL, C_OLIST_BOX_PERCENT_WIDTH + C_OLIST_NAME_PERCENT_WIDTH, C_OLIST_BOX_MIN_WIDTH, C_OLIST_COMBO_BOX_HEIGHT, FALSE, TRUE); //force this item to go to next line pclBC->m_pub_fn_vSetCanBeDisplayedCallBack(s_m_fn_bAlternateComboMustBeDisplayed); m_p_oPushButtonToRename = new CTL_Editor_Button("Rename", CTL_BUTTON_TYPE__USE_USER_DEFINED_TYPE, 0, this, m_pclParentWnd, OAC_BUTTON_TYPE__OBJECTS_LIST_BUTTON, OAC_BUTTON_RETURN_CODE_VALUE__OBJECTS_LIST_RENAME); m_p_oPushButtonToRename->m_pub_fn_vSetButtonHasBeenClicked_CallBack(s_m_fn_vAButtonHasBeenClicked); m_p_oPushButtonToRename->m_pub_fn_vRegisterWindowsControl(m_pub_fn_csGetControlName() + " - ObjectList Rename"); pclBC = m_pclListOfBaseControls->m_pub_fn_pclAddControlAtTail(m_p_oPushButtonToRename, m_p_oPushButtonToRename, this, CTL_BASE_CONTROL_DISPLAY_TYPE__NORMAL, C_OLIST_BUTTON_PERCENT_WIDTH, C_OLIST_BUTTON_MIN_WIDTH, C_OLIST_BUTTON_HEIGHT); pclBC->m_pub_fn_vSetCanBeDisplayedCallBack(s_m_fn_bRenameButtonCanBeDisplayed); pclBC->m_pub_fn_vSetMustBeEnabledCallBack(s_m_fn_bButtonMustBeEnabled); } m_bControlCreated = bReturnValue; return bReturnValue; } //************************************************************************************ //Function called to display the associated control(s) of the char. void CPA_Editor_ObjectListControl::m_fn_vDisplay() { m_pro_fn_vDisplayBaseControls(); } //************************************************************************ //Function called to update editor data of the CPA_XXData when a ComboBox receives OnSelChange() //the action is the identifier of the combo box void CPA_Editor_ObjectListControl::m_fn_vUpdateCurrentValue(short wAction /* = 0 */) { OAC_tdeUpdateReason eReason = OAC_E_ur_ComboSelChanged; short wSelectedIndex = CB_ERR; // if ( m_pclComboBox != NULL ) // { // short wIndex = m_pclComboBox->GetCurSel(); // if ( wIndex != CB_ERR ) // ((CPA_Editor_ObjectListData *)m_pclData)->m_pclCurrentValue = (CTL_Editor_EnumElement *)(m_pclComboBox->GetItemDataPtr(wIndex)); // } CPA_Editor_ObjectListData *pclData = (CPA_Editor_ObjectListData *)m_pclData; switch ( wAction ) { case OAC_COMBO_BOX_RETURN_CODE_VALUE__OBJECTS_LIST_NAMES: //the primary list wSelectedIndex = m_p_oNamesCombo->GetCurSel(); if ( OAC_fn_bIsEditingAnInstance(this) ) { //tell the actor not to use its current list. this will clear m_p_oObjectList as well if ( pclData->m_p_oObjectList ) pclData->m_p_oObjectList->fn_bMakeActorNotUseThisList(OAC_fn_pclGetParentActorOfData(pclData)); //if a new list was selected if ( wSelectedIndex != CB_ERR ) { //set the pointer to the list EdtList *p_oNewObjectList = (EdtList *) m_p_oNamesCombo->GetItemDataPtr(wSelectedIndex); pclData->m_p_oObjectList = p_oNewObjectList; eReason = OAC_E_ur_InstanceChangedObjectList; //and tell the handler that the actor uses this list if ( p_oNewObjectList ) p_oNewObjectList->fn_bMakeActorUseThisList(OAC_fn_pclGetParentActorOfData(pclData)); } } else /* is editing a model -> change current name list for the model */ { CPA_tdoNameList *p_oNewNameList = (CPA_tdoNameList *) m_p_oNamesCombo->GetItemDataPtr(wSelectedIndex); eReason = OAC_E_ur_ModelChangedNameList; if ( p_oNewNameList != ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList ) { //tell the coherence manager to remember the model no longer uses its old name list. g_oCoherenceManager.m_fn_vRemoveALink( (CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(pclData)->m_pclActor, pclData->m_p_oNameList ); //tell the coherence manager to remember the model now uses the new name list. if ( p_oNewNameList ) g_oCoherenceManager.m_fn_vAddALink( (CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(pclData)->m_pclActor, p_oNewNameList ); // store the pointer in the editor data pclData->m_p_oNameList = p_oNewNameList; } //if the model has instances and the selected list is valid, no more change is allowed if ( p_oNewNameList && ((EdActors_EditorActorModel *) OAC_fn_pclGetParentActorOfData(pclData))->m_fn_wGetRelatedInstancesCount() > 0 ) m_p_oNamesCombo->EnableWindow(FALSE); } break; case OAC_COMBO_BOX_RETURN_CODE_VALUE__OBJECTS_LIST_ALTERNATE_NAMES: //the alternate list eReason = OAC_E_ur_InstanceChangedAlternateList; ERROR_ASSERT(!m_bNoAlternateList && m_p_oAlternateNamesCombo ); wSelectedIndex = m_p_oAlternateNamesCombo->GetCurSel(); if ( wSelectedIndex != CB_ERR ) { CPA_ZonesActivatingList *p_oNewZAList = (CPA_ZonesActivatingList *) m_p_oAlternateNamesCombo->GetItemDataPtr(wSelectedIndex); ((CPA_Editor_ObjectListData *) m_pclData)->m_vSetZAList(p_oNewZAList); //m_pclData->m_pclParentActor->m_pclActor->fn_vNotifySave(); //done in m_vSetZAList //get the model of the instance EdActors_EditorActor *p_oEditorModel = OAC_fn_pclGetParentActorOfData(pclData)->m_pclActor->m_fn_pclGetModel()->m_fn_pclGetEditorActor(); ERROR_ASSERT(p_oEditorModel); //find the associated data for the model CPA_Editor_ObjectListData *p_oModelData = (CPA_Editor_ObjectListData *) p_oEditorModel->m_fn_p_oFindDataByName(m_pclData->m_pub_fn_csGetDataName()); //if the model has no default activation list if ( !p_oModelData->m_p_oZAList && p_oNewZAList ) { //give it this one p_oModelData->m_vSetZAList(p_oNewZAList); //and save the model to remember that //p_oEditorModel->m_pclActor->fn_vNotifySave(); //done in m_vSetZAList //TODO: capture cohmnge messages to the interface to handle invalidation of links... } } else pclData->m_vSetZAList(NULL); break; } // normally this call is unnecessary because the control is already up-to-date, but we never know... //update the contents of the combo according to the new name list m_fn_vUpdate(); m_fn_vUpdateParent(CTL_UPDATE_REASON__USE_USER_DEFINED_REASON, eReason); } //************************************************************************ //Function called to update editor data of the CPA_XXData when a CheckBox receives Onclicked() void CPA_Editor_ObjectListControl::m_fn_vSetValue(short wAction) { tdstEdtListMess stMessage; OAC_tdeUpdateReason eReason = OAC_E_ur_ButtonClicked; CPA_Editor_ObjectListData *pclData = (CPA_Editor_ObjectListData *)m_pclData; switch ( wAction ) { case OAC_BUTTON_RETURN_CODE_VALUE__OBJECTS_LIST_EDIT: //the "edit" button was pressed if ( OAC_fn_bIsEditingAnInstance(this) ) { if ( ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList ) { stMessage.csListType = ((CPA_Editor_ObjectListData *) m_pclData)->m_pub_fn_csGetDataName(); stMessage.pActor = (CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(pclData)->m_pclActor->m_pub_fn_pclGetSuperObject(); stMessage.ulIndexInList = -1; stMessage.pObject = NULL; stMessage.pList = ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oObjectList; CPA_DLLBase *p_oDll = g_pclInterface->GetMainWorld()->GetDLLWithTypeName(M_MAKECHAR(stMessage.csListType)); if ( p_oDll ) p_oDll->OnQueryAction(g_pclInterface, C_uiQueryEditAnObjectList, (long) &stMessage); } else { //tell the user that there is no name list in the model... MessageBox( m_p_oPushButtonToEdit->m_hWnd, //parent window of the dialog "There is no name list defined\nfor this instance's model", "Actor's Editor Warning", MB_OK ); } } else /* we are editing a model */ { CString csRototo; short wInstancesCount = ((EdActors_EditorActorModel *) OAC_fn_pclGetParentActorOfData(pclData))->m_fn_wGetRelatedInstancesCount(); EdActors_EditNameListsDialog *p_oDialog; tdstCarEditNameListsDialogArgs stArgs; // ALX csRototo = g_c_csGenericNameListType + ((CPA_Editor_ObjectListData *) m_pclData)->m_pub_fn_csGetDataName(); // End ALX stArgs.stIn.p_c_szNameListType = LPCTSTR(csRototo); stArgs.stIn.p_oEditorActor = OAC_fn_pclGetParentActorOfData(pclData); stArgs.stIn.p_oCurrentNameList = ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList; stArgs.stIn.p_c_szScriptName = LPCTSTR(((CPA_Editor_ObjectListData *) m_pclData)->m_pub_fn_csGetDataName()); //the model can select a different name list only if he has no instance or he specified no name list //before starting to create instances //in which condition the model can change its name list to select another ? stArgs.stIn.bModelCanSelectANameList = (wInstancesCount <= 0) //it has no instance || !stArgs.stIn.p_oCurrentNameList //if it has instances, it must not a a name list yet || (stArgs.stIn.p_oCurrentNameList->m_pEdtListHandler->fn_oGetListOfEdtLists()->GetCount() <= 0); //if it has a name list, no object list must be defined for it stArgs.stIn.bNoNames = m_bNoNames; HINSTANCE hOldInstance = AfxGetResourceHandle(); AfxSetResourceHandle(g_stActorEditorIdentity.hModule); p_oDialog = new EdActors_EditNameListsDialog(&stArgs); p_oDialog->DoModal(); delete p_oDialog; AfxSetResourceHandle(hOldInstance); // the model can change its current name list only if no instance exist... if ( stArgs.stIn.bModelCanSelectANameList && stArgs.stIn.p_oCurrentNameList != stArgs.stOut.p_oNameListSelectedForModel ) { //tell the instances that the model selected a name list eReason = OAC_E_ur_ModelChangedNameList; //tell the coherence manager to remember the model no longer uses its old name list. #if defined ( D_UseCoherenceManager ) g_oCoherenceManager.m_fn_vRemoveALink( (CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(pclData)->m_pclActor, ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList ); //tell the coherence manager to remember the model now uses the new name list. if ( stArgs.stOut.p_oNameListSelectedForModel ) g_oCoherenceManager.m_fn_vAddALink( (CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(pclData)->m_pclActor, stArgs.stOut.p_oNameListSelectedForModel ); #endif /* D_UseCoherenceManager */ //since the model changed a name list, its current object and activation lists must be forgotten ((CPA_Editor_ObjectListData *) m_pclData)->m_vSetObjectList(NULL); ((CPA_Editor_ObjectListData *) m_pclData)->m_vSetZAList(NULL); // store the pointer on the new name list in the editor data ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList = stArgs.stOut.p_oNameListSelectedForModel; if ( stArgs.stOut.p_oNameListSelectedForModel && ((EdActors_EditorActorModel *) OAC_fn_pclGetParentActorOfData(pclData))->m_fn_wGetRelatedInstancesCount() > 0 ) m_p_oNamesCombo->EnableWindow(FALSE); } else eReason = OAC_E_ur_ModelEditedNameList; } break; case OAC_BUTTON_RETURN_CODE_VALUE__OBJECTS_LIST_RENAME: //the rename button was pressed (in instance mode) { eReason = OAC_E_ur_InstanceRenamedObjectList; //get the current edited object list short wSelIndex = m_p_oNamesCombo->GetCurSel(); if ( wSelIndex != CB_ERR ) { EdtList *p_oEdtList = (EdtList *) m_p_oNamesCombo->GetItemDataPtr(wSelIndex); CDialog *p_oDialog = new CDialog(); p_oDialog->Create(IDD_CAR_DIALOG_OBJECTLIST_RENAME, m_p_oPushButtonToRename); //get strings to init the controls in the dialog CString csCurrentName = p_oEdtList->GetName(); CString csStaticCaption; p_oDialog->GetDlgItem(IDC_STATIC_OLR_RENAMELIST)->GetWindowText(csStaticCaption); short wNameInsertPos = csStaticCaption.Find('§'); csStaticCaption = csStaticCaption.Left(wNameInsertPos) + csCurrentName + csStaticCaption.Mid(wNameInsertPos + 1); p_oDialog->GetDlgItem(IDC_EDIT_OLR_NAME)->SetWindowText(csCurrentName); p_oDialog->GetDlgItem(IDC_STATIC_OLR_RENAMELIST)->SetWindowText(csStaticCaption); //create the dialog to get the new name p_oDialog->ShowWindow(TRUE); BOOL bChangeAccepted = (p_oDialog->RunModalLoop() == IDOK); if ( bChangeAccepted ) //if name is accepted, get it p_oDialog->GetDlgItem(IDC_EDIT_OLR_NAME)->GetWindowText(csCurrentName); delete p_oDialog; if ( bChangeAccepted ) { p_oEdtList->fn_bUnValidate(); ((CPA_SaveObject *) p_oEdtList->GetOwner())->fn_vUpdateReference(p_oEdtList); p_oEdtList->fn_bValidate(); //the rename will cause a rename notification that will notify all dependent actors as well p_oEdtList->fn_eRename(csCurrentName); ((CPA_SaveObject *) p_oEdtList->GetOwner())->fn_vUpdateReference(p_oEdtList); //now update the string in the combo too m_p_oNamesCombo->DeleteString(wSelIndex); VERIFY(m_p_oNamesCombo->InsertString(wSelIndex, p_oEdtList->GetName()) == wSelIndex); m_p_oNamesCombo->SetItemDataPtr(wSelIndex, p_oEdtList); m_p_oNamesCombo->SetCurSel(wSelIndex); } } } break; default: // debug... ERROR_ASSERT(FALSE); break; } //update the contents of the combo according to the new name list m_fn_vUpdate(CTL_UPDATE_REASON__USE_USER_DEFINED_REASON, eReason); //Updates parent's controls if necessary (Watch Window, ...) m_fn_vUpdateParent(CTL_UPDATE_REASON__USE_USER_DEFINED_REASON, eReason); } //************************************************************************ //fills the controls with editor data void CPA_Editor_ObjectListControl::m_fn_vUpdate(CTL_tdeUpdateReason _eReason /*= CTL_UPDATE_REASON__NO_REASON_GIVEN*/, long _lUserDefinedReason /*= 0*/) { /* if ( (m_pclCheckBoxForLink != NULL) && (m_pclData != NULL) ) { m_pclCheckBoxForLink->SetCheck(m_pclData->m_pub_fn_bIsLinked()); m_pclCheckBoxForLink->EnableWindow( (m_pclData->m_fn_eGetLink() != E_dlm_AlwaysLinked) && (m_pclData->m_fn_eGetLink() != E_dlm_NeverLinked) ); }*/ CPA_Editor_ObjectListData *pclData = (CPA_Editor_ObjectListData *)m_pclData; if ( m_pclData->m_pub_fn_bGetDataHasChanged() ) { CPA_tdoNameList *p_oNameList; CString csReachableType = g_c_csGenericNameListType + ((CPA_Editor_ObjectListData *) m_pclData)->m_pub_fn_csGetDataName(); //make the buttons display their text if ( m_p_oPushButtonToEdit ) m_p_oPushButtonToEdit->SetCheck(FALSE); m_p_oNamesCombo->ResetContent(); m_p_oNamesCombo->SetItemDataPtr(m_p_oNamesCombo->AddString("No List"), NULL); if ( !m_bNoAlternateList && m_p_oAlternateNamesCombo ) { m_p_oAlternateNamesCombo->ResetContent(); m_p_oAlternateNamesCombo->SetItemDataPtr(m_p_oAlternateNamesCombo->AddString("No ZA List"), NULL); } if ( OAC_fn_bIsEditingAnInstance(this) ) { //fill the m_p_oNamesCombo with the names of the data's m_p_oNameList p_oNameList = ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList; if ( !p_oNameList ) { ((CPA_Editor_ObjectListData *) m_pclData)->m_vSetObjectList(NULL); ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList = NULL; ((CPA_Editor_ObjectListData *) m_pclData)->m_vSetZAList(NULL); } else { short wInstanceIndex = CB_ERR; short wNbObjectLists = 0; CPA_List *p_oListOfObjectLists = p_oNameList->m_pEdtListHandler->fn_oGetListOfEdtLists();; wNbObjectLists = p_oListOfObjectLists->GetCount(); if ( p_oListOfObjectLists && wNbObjectLists ) for ( short wIndex = 0; wIndex < wNbObjectLists; wIndex ++ ) { //get the list of objects EdtList *p_oObjectList = (EdtList *) p_oListOfObjectLists->FindElementFromIndex(wIndex); /*if ( p_oObjectList->fn_bIsOfType(C_szEdtListTypeName) ) //TODO-B 21/02/97: a virer + tard... {*/ //add its name in the combo short wPos = m_p_oNamesCombo->AddString(p_oObjectList->GetName()); //set the pointer m_p_oNamesCombo->SetItemDataPtr(wPos, p_oObjectList); if ( p_oObjectList == ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oObjectList ) wInstanceIndex = wPos; //} } if ( wInstanceIndex != CB_ERR ) m_p_oNamesCombo->SetCurSel(wInstanceIndex); //fill the other combo with the list of zone activating lists for the name list wInstanceIndex = CB_ERR; if ( !m_bNoAlternateList && m_p_oAlternateNamesCombo ) { CPA_List oActivationListList; g_pclInterface->GetMainWorld()->fn_lFindObjects( &oActivationListList, "" /* obj name */, C_szZAListTypeName, /* type */ p_oNameList /* owner */ ); short wNbActivationLists = oActivationListList.GetCount(); POSITION Pos = oActivationListList.GetHeadPosition (); while (Pos) { //get the activation list CPA_ZonesActivatingList *p_oActivationList = (CPA_ZonesActivatingList *) oActivationListList.GetNext(Pos); short wPos = m_p_oAlternateNamesCombo->AddString(p_oActivationList->GetName()); m_p_oAlternateNamesCombo->SetItemDataPtr(wPos, p_oActivationList); if ( p_oActivationList == ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oZAList ) wInstanceIndex = wPos; } } if ( wInstanceIndex != CB_ERR ) m_p_oAlternateNamesCombo->SetCurSel(wInstanceIndex); } } else // we display the data for a model { //fill the m_p_oNamesCombo with the names of available name lists //Gets the current Family's List of name lists CPA_List oNameListList; g_pclInterface->GetMainWorld()->fn_lFindObjects( &oNameListList, "", csReachableType, (CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(pclData)->m_pclActor->m_pub_fn_pclGetFamily() /* owner */ ); short wNbNameLists = (short) oNameListList.GetCount(); short wOk = 0, wModelIndex = -1; if ( wNbNameLists == 0 ) // no name list remain { #if defined ( D_UseCoherenceManager ) //remove the coherence link if ( ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList ) g_oCoherenceManager.m_fn_vRemoveALink( (CPA_SaveObject *) OAC_fn_pclGetParentActorOfData(pclData)->m_pclActor, ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList ); #endif /* D_UseCoherenceManager */ //make the model reference no list ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList = NULL; } else { //for each list of names we got POSITION Pos= oNameListList.GetHeadPosition(); short wIndex = 1; while (Pos) { //get the list of names p_oNameList = (CPA_tdoNameList *) oNameListList.GetNext(Pos); /*if ( p_oNameList->fn_bIsOfType(M_MAKECHAR(csReachableType)) ) //TODO-B 01/03/97: a virer + tard... {*/ wOk = 1; //add its name in the combo short wPos = m_p_oNamesCombo->AddString(p_oNameList->GetName()); //set the pointer m_p_oNamesCombo->SetItemDataPtr(wPos, p_oNameList); if ( ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList && p_oNameList == ((CPA_Editor_ObjectListData *) m_pclData)->m_p_oNameList ) wModelIndex = wIndex; /*}*/ wIndex++; } } // make the combo select the name of the current name list if ( wOk ) m_p_oNamesCombo->SetCurSel(wModelIndex); } } } //************************************************************************ //Function called to update parent window in case of values changes. void CPA_Editor_ObjectListControl::m_fn_vUpdateParent(CTL_tdeUpdateReason eReason, long _lUserDefinedReason /*= 0*/) { //Updates parent if necessary(Watch a.s.o.) CTL_Editor_Control::m_fn_vUpdateParent(eReason, _lUserDefinedReason); //Updates motor's data m_pclData->m_fn_vUpdateMotorData(eReason, _lUserDefinedReason); } //************************************************************************ //Function called to make control Read Only void CPA_Editor_ObjectListControl::m_fn_vMakeReadOnly() { if ( !m_fn_bIsReadOnly() ) { m_bIsReadOnly = TRUE; } } //************************************************************************ //Function called to make control Read-Write void CPA_Editor_ObjectListControl::m_fn_vMakeReadWrite() { if ( (m_fn_bIsReadOnly()) && (!m_fn_bIsAlwaysReadOnly()) ) { m_bIsReadOnly = FALSE; } } //************************************************************************ // CALLBACKS //************************************************************************ void CPA_Editor_ObjectListControl::s_m_fn_vAButtonHasBeenClicked(class CTL_Editor_Button *_pclSenderButton, class CTL_Editor_Control *_pclParentControl, enum CTL_eButtonType _tdeType, long _lUserDefinedType, long _lUserDefinedCode) { ERROR_ASSERT( _tdeType == CTL_BUTTON_TYPE__USE_USER_DEFINED_TYPE ); ERROR_ASSERT( _lUserDefinedType == OAC_BUTTON_TYPE__OBJECTS_LIST_BUTTON ); ERROR_ASSERT( _pclParentControl != NULL ); ((CPA_Editor_ObjectListControl *)_pclParentControl)->m_fn_vSetValue((short)_lUserDefinedCode); } //************************************************************************ void CPA_Editor_ObjectListControl::s_m_fn_vComboBoxSelChanged(class CTL_Editor_ComboBox *_pclSenderComboBox, class CTL_Editor_Control *_pclParentControl, enum CTL_eComboBoxType _tdeType, long _lUserDefinedType, long _lUserDefinedCode) { ERROR_ASSERT( _tdeType == CTL_COMBO_BOX_TYPE_USE_USER_DEFINED_TYPE ); ERROR_ASSERT( _lUserDefinedType == OAC_COMBO_BOX_TYPE__OBJECTS_LIST_COMBO_BOX ); ERROR_ASSERT( _pclParentControl != NULL ); ((CPA_Editor_ObjectListControl *)_pclParentControl)->m_fn_vUpdateCurrentValue((short)_lUserDefinedCode); } //************************************************************************ BOOL CPA_Editor_ObjectListControl::s_m_fn_bRenameButtonCanBeDisplayed(class CTL_Editor_BaseControl *_pclSenderBaseControl) { CPA_Editor_ObjectListControl *pclControl = (CPA_Editor_ObjectListControl *)_pclSenderBaseControl->m_pub_fn_pclGetParentControl(); return OAC_fn_bIsEditingAnInstance(pclControl); } //************************************************************************ BOOL CPA_Editor_ObjectListControl::s_m_fn_bButtonMustBeEnabled(class CTL_Editor_BaseControl *_pclSenderBaseControl) { return !_pclSenderBaseControl->m_pub_fn_pclGetParentControl()->m_fn_bIsAlwaysReadOnly(); } //************************************************************************ BOOL CPA_Editor_ObjectListControl::s_m_fn_bComboMustBeEnabled(class CTL_Editor_BaseControl *_pclSenderBaseControl) { CPA_Editor_ObjectListControl *pclControl = (CPA_Editor_ObjectListControl *)_pclSenderBaseControl->m_pub_fn_pclGetParentControl(); CPA_Editor_ObjectListData *pclData = (CPA_Editor_ObjectListData *)pclControl->m_pclData; BOOL bMustBeEnabled = FALSE; //The edited Actor is an Instance if ( OAC_fn_bIsEditingAnInstance(pclControl) ) { //if the list contains a specific item, the instance cannot select another list if ( pclData->m_p_oNameList->m_bHasAVirgeField() ) bMustBeEnabled = FALSE; else bMustBeEnabled = TRUE; } //The edited Actor is a Model else { if ( //it has at least one associated instance ( ((EdActors_EditorActorModel *) OAC_fn_pclGetParentActorOfData(pclData))->m_fn_wGetRelatedInstancesCount() > 0 ) //and it already has a selected name list && ( pclData->m_p_oNameList != NULL ) ) //the combo just gives the name of the current name list bMustBeEnabled = FALSE; else bMustBeEnabled = TRUE; } return bMustBeEnabled; } //************************************************************************ BOOL CPA_Editor_ObjectListControl::s_m_fn_bAlternateComboMustBeDisplayed(class CTL_Editor_BaseControl *_pclSenderBaseControl) { CPA_Editor_ObjectListControl *pclControl = (CPA_Editor_ObjectListControl *)_pclSenderBaseControl->m_pub_fn_pclGetParentControl(); BOOL bMustBeDisplayed = FALSE; if ( !pclControl->m_bNoAlternateList ) { if ( OAC_fn_bIsEditingAnInstance(pclControl) ) bMustBeDisplayed = TRUE; else bMustBeDisplayed = FALSE; } return bMustBeDisplayed; }