/** * @file XTPMarkupDeviceDependentImage.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(__XTPMARKUPDEVICEDEPENDENTIMAGE_H__) # define __XTPMARKUPDEVICEDEPENDENTIMAGE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPMarkupContext; /** * @brief * Describes an image site interface. */ struct IXTPMarkupDeviceDependentImageSite { /** * @brief * Handles object destruction */ virtual ~IXTPMarkupDeviceDependentImageSite() { } /** * @brief * Implementation must return a valid pointer to a markup * context in which an image is to be rendered. * @return * A valid markup context pointer. */ virtual CXTPMarkupContext* GetMarkupContext() = 0; /** * @brief * (Optional) Implementation can re-draw the context when this method * is called; usually when a new animation frame is to be rendered. */ virtual void OnImageUpdateRequired() = 0; }; /** * @brief * Implements an abstract device dependent image. Whether it is a GDI or GDI+ * device context, each has its own implementation, optimization, * set of supported formats, and capabilities. */ class _XTP_EXT_CLASS CXTPMarkupDeviceDependentImage : public CObject { /** @cond */ DECLARE_DYNAMIC(CXTPMarkupDeviceDependentImage); /** @endcond */ protected: /** * @brief * Constructs a device dependent image object. * @param pSite Valid pointer to an image site interface. */ explicit CXTPMarkupDeviceDependentImage(IXTPMarkupDeviceDependentImageSite* pSite); public: /** * @brief * Handles device dependent image object deallocation. */ virtual ~CXTPMarkupDeviceDependentImage(); /** * @brief * Loads an image from a specified resource. * @param lpszSource Pointer to a string that indicates the image source. Can * be a relative or full file path, file:// path, res:// * path, or an integer in decimal representation that indicates * the icon index. * @param nWidth Width of the image to be loaded. Used only for icons. Can * be 0 if not relevant. * @param nHeight Width of the image to be loaded. Used only for XAML and SVG icons. * @return * TRUE if the image is loaded successfully. */ virtual BOOL Load(LPCWSTR lpszSource, int nWidth, int nHeight = 0) = 0; /** * @brief * Obtains the image size, in pixels. * @return * The image size, in pixels. */ const CSize& GetSize() const; /** * @brief * Checks if an image is loaded. * @return * TRUE if an image is loaded. */ BOOL IsLoaded() const; /** * @brief * Checks if the loaded image is an icon. * @return * TRUE if the loaded image is an icon. */ BOOL IsIcon() const; /** * @brief * Obtains the site object pointer. * @return * The site object pointer. */ IXTPMarkupDeviceDependentImageSite* GetSite() const; /** @cond */ ULONG AddRef(); ULONG Release(); /** @endcond */ protected: IXTPMarkupDeviceDependentImageSite* m_pSite; CSize m_imageSize; BOOL m_bIsIcon; private: ULONG m_nRefs; }; AFX_INLINE const CSize& CXTPMarkupDeviceDependentImage::GetSize() const { return m_imageSize; } AFX_INLINE BOOL CXTPMarkupDeviceDependentImage::IsLoaded() const { return (0 != m_imageSize.cx && 0 != m_imageSize.cy); } AFX_INLINE BOOL CXTPMarkupDeviceDependentImage::IsIcon() const { return m_bIsIcon; } AFX_INLINE IXTPMarkupDeviceDependentImageSite* CXTPMarkupDeviceDependentImage::GetSite() const { return m_pSite; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif /*__XTPMARKUPDEVICEDEPENDENTIMAGE_H__*/ /** @endcond */