/** * @file XTPFlowGraphNodeGroups.cpp * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #include "stdafx.h" #include "Common/XTPTypeId.h" #include "Common/XTPFramework.h" #include "Common/XTPSystemHelpers.h" #include "FlowGraph/XTPFlowGraphElement.h" #include "FlowGraph/XTPFlowGraphNodeGroup.h" #include "FlowGraph/XTPFlowGraphNodeGroups.h" #include "FlowGraph/XTPFlowGraphIIDs.h" #include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif CXTPFlowGraphNodeGroups::CXTPFlowGraphNodeGroups(CXTPFlowGraphPage* pPage) { m_pPage = pPage; #ifdef _XTP_ACTIVEX EnableAutomation(); EnableTypeLib(); #endif } CXTPFlowGraphNodeGroups::~CXTPFlowGraphNodeGroups() { RemoveAll(); } void CXTPFlowGraphNodeGroups::RemoveAll() { if (m_arrGroups.GetSize() == 0) return; for (int i = 0; i < m_arrGroups.GetSize(); i++) { m_arrGroups[i]->RemoveAll(); m_arrGroups[i]->InternalRelease(); } m_arrGroups.RemoveAll(); } void CXTPFlowGraphNodeGroups::Remove(CXTPFlowGraphNodeGroup* pGroup) { for (int i = 0; i < m_arrGroups.GetSize(); i++) { if (m_arrGroups[i] == pGroup) { pGroup->RemoveAll(); pGroup->InternalRelease(); m_arrGroups.RemoveAt(i); return; } } } CXTPFlowGraphNodeGroup* CXTPFlowGraphNodeGroups::AddGroup() { CXTPFlowGraphNodeGroup* pGroup = new CXTPFlowGraphNodeGroup(); pGroup->m_pGroups = this; m_arrGroups.Add(pGroup); return pGroup; } #ifdef _XTP_ACTIVEX BEGIN_DISPATCH_MAP(CXTPFlowGraphNodeGroups, CXTPCmdTarget) DISP_FUNCTION_ID(CXTPFlowGraphNodeGroups, "Count", 1, OleGetItemCount, VT_I4, VTS_NONE) DISP_FUNCTION_ID(CXTPFlowGraphNodeGroups, "Group", DISPID_VALUE, OleGetItem, VT_DISPATCH, VTS_I4) DISP_FUNCTION_ID(CXTPFlowGraphNodeGroups, "_NewEnum", DISPID_NEWENUM, OleNewEnum, VT_UNKNOWN, VTS_NONE) DISP_FUNCTION_ID(CXTPFlowGraphNodeGroups, "RemoveAll", 3, RemoveAll, VT_EMPTY, VTS_NONE) DISP_FUNCTION_ID(CXTPFlowGraphNodeGroups, "AddGroup", 2, OleAddGroup, VT_DISPATCH, VTS_NONE) DISP_FUNCTION_ID(CXTPFlowGraphNodeGroups, "RemoveGroup", 4, OleRemoveGroup, VT_EMPTY, VTS_DISPATCH) END_DISPATCH_MAP() BEGIN_INTERFACE_MAP(CXTPFlowGraphNodeGroups, CXTPCmdTarget) INTERFACE_PART(CXTPFlowGraphNodeGroups, XTPDIID_FlowGraphNodeGroups, Dispatch) END_INTERFACE_MAP() IMPLEMENT_OLETYPELIB_EX(CXTPFlowGraphNodeGroups, XTPDIID_FlowGraphNodeGroups) IMPLEMENT_ENUM_VARIANT(CXTPFlowGraphNodeGroups) LPDISPATCH CXTPFlowGraphNodeGroups::OleGetItem(int nIndex) { return XTPGetDispatch(GetAt(nIndex)); } int CXTPFlowGraphNodeGroups::OleGetItemCount() { return GetCount(); } LPDISPATCH CXTPFlowGraphNodeGroups::OleAddGroup() { return XTPGetDispatch(AddGroup()); } void CXTPFlowGraphNodeGroups::OleRemoveGroup(LPDISPATCH Group) { CXTPFlowGraphNodeGroup* pGroup = XTP_DYNAMIC_DOWNCAST_REMOTE_( CXTPFlowGraphNodeGroup, CXTPFlowGraphNodeGroup::FromIDispatchSafe(Group)); if (NULL == pGroup) { AfxThrowOleException(E_INVALIDARG); } Remove(pGroup); } #endif