/** * @file XTPMarkupDelegate.h * * @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 * */ /** @cond */ #if !defined(__XTPMARKUPDELEGATE_H__) # define __XTPMARKUPDELEGATE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPMarkupRoutedEventArgs; class _XTP_EXT_CLASS CXTPMarkupDelegate : public CXTPMarkupObject { /** @cond */ DECLARE_DYNAMIC(CXTPMarkupDelegate); /** @endcond */ public: CXTPMarkupDelegate(); virtual void Execute(CXTPMarkupObject* /*pSender*/, CXTPMarkupRoutedEventArgs* /*pArgs*/); }; template class CXTPMarkupClassDelegate : public CXTPMarkupDelegate { public: typedef void (T::*ROUTEDEVENTHANDLER)(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs); public: CXTPMarkupClassDelegate(T* pObject, ROUTEDEVENTHANDLER pHandler) : m_pObject(pObject) , m_pHandler(pHandler) { _ASSERTE(NULL != pObject); _ASSERTE(NULL != pHandler); } virtual void Execute(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs) { (m_pObject->*m_pHandler)(pSender, pArgs); } protected: T* m_pObject; ROUTEDEVENTHANDLER m_pHandler; }; class _XTP_EXT_CLASS CXTPMarkupFunctionDelegate : public CXTPMarkupDelegate { DECLARE_DYNAMIC(CXTPMarkupFunctionDelegate); public: typedef void(AFX_CDECL* ROUTEDEVENTHANDLER)(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs); public: CXTPMarkupFunctionDelegate(ROUTEDEVENTHANDLER pHandler); virtual void Execute(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs); protected: ROUTEDEVENTHANDLER m_pHandler; }; class _XTP_EXT_CLASS CXTPMarkupDispatchDelegate : public CXTPMarkupDelegate { DECLARE_DYNAMIC(CXTPMarkupDispatchDelegate); public: CXTPMarkupDispatchDelegate(IDispatch* pDisp); ~CXTPMarkupDispatchDelegate(); IDispatch* GetDelegateDispatch(BOOL bAddRef = TRUE) const; virtual void Execute(CXTPMarkupObject* pSender, CXTPMarkupRoutedEventArgs* pArgs); protected: CXTPMarkupDispatchDelegate(const CXTPMarkupDispatchDelegate&); CXTPMarkupDispatchDelegate& operator=(const CXTPMarkupDispatchDelegate&); IDispatch* m_pDisp; }; template AFX_INLINE CXTPMarkupDelegate* CreateMarkupClassDelegate(T* pClass, EVENTHANDLER pfnDelegate) { return new CXTPMarkupClassDelegate( pClass, (typename CXTPMarkupClassDelegate::ROUTEDEVENTHANDLER)pfnDelegate); } template AFX_INLINE CXTPMarkupDelegate* CreateMarkupFunctionDelegate(EVENTHANDLER pfnDelegate) { return new CXTPMarkupFunctionDelegate( (CXTPMarkupFunctionDelegate::ROUTEDEVENTHANDLER)pfnDelegate); } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPMARKUPDELEGATE_H__) /** @endcond */