/** * @file XTPImageManagerResource.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(__XTPIMAGEMANAGERRESOURCE_H__) # define __XTPIMAGEMANAGERRESOURCE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * @param Standalone class used to manage Image resources. */ class _XTP_EXT_CLASS CXTPImageManagerResource { protected: public: /** * @brief * Constructs a CXTPImageManagerResource object used to create common bitmap for all icons * of image manager * @param pImageManager : Pointer to Parent ImageManager class * @param szIcon : Size of images that will be managed by this resource */ CXTPImageManagerResource(CXTPImageManager* pImageManager, CSize szIcon); /** * @brief * Destroys a CXTPImageManagerResource object, handles cleanup and de- * allocation. */ ~CXTPImageManagerResource(); /** * @brief * This method is called to add new icon to common bitmap fo resource manger * @param hHandle : Handle of image to add * @return * Returns pointer to XTP_IMAGERESOURCE_INFO contained position and style of new icon. */ XTP_IMAGERESOURCE_INFO* Add(const CXTPImageManagerIconHandle& hHandle); /** * @brief * Clears image in specified position * @param pRInfo : Posiotion of image to clear */ void Clear(XTP_IMAGERESOURCE_INFO* pRInfo); /** * @brief * This method is called to draw image. * @param pDC Pointer to a valid device context. * @param pRInfo Pointer to XTP_IMAGERESOURCE_INFO * @param pt Point to start drawing. * @param szIcon Size of the icon. * @param bDrawComposited BOOL flag of composite or not way of draw */ void Draw(CDC* pDC, XTP_IMAGERESOURCE_INFO* pRInfo, CPoint pt, CSize szIcon, BOOL bDrawComposited); /** * @brief * Creates new icon from bitmap specified by pRInfo parameter * @param hHandle Handle of icon to be created * @param pRInfo Posiotion of icon inside m_hbmpImage to create */ void CreateIcon(CXTPImageManagerIconHandle& hHandle, XTP_IMAGERESOURCE_INFO* pRInfo); /** * @brief * Returns size of iconsmanaged by this Resource * @return * Size of images contained inside m_hbmpImage */ CSize GetExtent() const; private: XTP_IMAGERESOURCE_INFO* AllocBitmap(); void RemoveAll(); void DrawIconComposited(CDC* pDC, XTP_IMAGERESOURCE_INFO* pRInfo, CPoint pt, CSize szIcon); protected: HBITMAP m_hbmpImage; /**< Handle of bitmap contained all images of the resources */ HBITMAP m_hbmpMask; /**< Handle of bitmap contained mask for images of the resources */ CXTPBitmapDC m_dc; /**< Helper device context class for quick image select */ BYTE* m_pBits; /**< Bits of m_hbmpImage */ CXTPImageManager* m_pImageManager; /**< Parent CXTPImageManager object */ CSize m_szIcon; /**< Size of images of the resources */ int m_nAllocWidth; /**< Total allocated with of the resources */ CArray m_arrIcons; /**< List of used icons */ CArray m_arrAlloc; /**< List of free icons */ CRITICAL_SECTION m_cs; /**< Critical section for multithreading support. */ private: friend class CXTPImageManager; friend class CXTPImageManagerIconHandle; friend class CXTPImageManagerIcon; }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPIMAGEMANAGERRESOURCE_H__) /** @endcond */