/** * @file XTPControlPopupColor.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(__XTPCONTROLPOPUPCOLOR_H__) # define __XTPCONTROLPOPUPCOLOR_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPImageManagerIcon; class CXTPImageManagerIconHandle; /** * @brief * CXTPControlPopupColor is a CXTPControlPopup derived class. * It represents a color picker control. */ class _XTP_EXT_CLASS CXTPControlPopupColor : public CXTPControlPopup { /** @cond */ DECLARE_XTP_CONTROL(CXTPControlPopupColor) /** @endcond */ public: /** * @brief * Constructs a CXTPControlPopupColor object. */ CXTPControlPopupColor(); /** * @brief * Destroys a CXTPControlPopupColor object, handles cleanup and * deallocation. */ ~CXTPControlPopupColor(); /** * @brief * Call this member to set the picker color. * @param clr Color to set. */ void SetColor(COLORREF clr); /** * @brief * Call this member to retrieve the control color. * @return * Color of the color picker. */ COLORREF GetColor() const; protected: /** * @brief * This method is called to copy the control. * @param pControl Pointer to a source CXTPControl object. * @param bRecursive TRUE to copy recursively. */ void Copy(CXTPControl* pControl, BOOL bRecursive = FALSE); private: void RedrawIcon(CXTPImageManagerIcon* pImage, CXTPImageManagerIconHandle& hIcon); void RedrawVectorIcon(CXTPImageManagerVectorImageHandle pIcon, UINT nWidth, XTPImageState state); private: COLORREF m_clr; # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPControlPopupColor); /** @endcond */ # endif }; /** * @brief * CXTPControlButtonColor is a CXTPControlButton derived class. * It represents a text button in the color picker pop-up. */ class _XTP_EXT_CLASS CXTPControlButtonColor : public CXTPControlButton { /** @cond */ DECLARE_XTP_CONTROL(CXTPControlButtonColor) /** @endcond */ public: /** * @brief * Constructs a CXTPControlButtonColor object. */ CXTPControlButtonColor(); /** * @brief * Call this member to retrieve the color of the control. * @return * Color of the selector. */ COLORREF GetColor() const; /** * @brief * Call this method to set the color of the control. * @param clr Color to set. */ void SetColor(COLORREF clr); protected: /** * @brief * This method is called to copy the control. * @param pControl Pointer to a source CXTPControl object. * @param bRecursive TRUE to copy recursively. */ void Copy(CXTPControl* pControl, BOOL bRecursive = FALSE); /** * @brief * Either reads this object from or writes this object to an archive. * @param pPX A CXTPPropExchange object to serialize to or from. */ void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * This method is called to determine the size of the control. * @param pDC Pointer to a valid device context. * @return * A CSize object containing the size of the control. */ CSize GetSize(CDC* pDC); /** * @brief * This method is called to draw the control. * @param pDC Pointer to a valid device context. */ void Draw(CDC* pDC); protected: COLORREF m_clr; /**< Color of the color bar displayed in the color button under the "pin" icon. */ }; /** * @brief * CXTPControlColorSelector is a CXTPControl derived class. * It represents a color selector control. */ class _XTP_EXT_CLASS CXTPControlColorSelector : public CXTPControl { /** @cond */ DECLARE_XTP_CONTROL(CXTPControlColorSelector) /** @endcond */ /** * @brief * Internal helper class. */ struct CColorInfo; public: /** * @brief * Constructs a CXTPControlColorSelector object. */ CXTPControlColorSelector(); /** * @brief * Call this member to retrieve the color of the selector control. * @return * Color of the selector. */ COLORREF GetColor() const; /** * @brief * Call this method to set the color of the control. * @param clr Color to set. */ void SetColor(COLORREF clr); protected: /** * @brief * This method is called to determine the size of the control. * @param pDC Pointer to a valid device context. * @return * A CSize object containing the size of the control. */ CSize GetSize(CDC* pDC); /** * @brief * This method is called to draw the control. * @param pDC Pointer to a valid device context. */ void Draw(CDC* pDC); /** * @brief * This member is called when the mouse cursor moves. * @param point Specifies the x- and y- coordinates of the cursor. */ void OnMouseMove(CPoint point); /** * @brief * This method is called when the control becomes selected. * @param bSelected TRUE if the control becomes selected. * @return * TRUE if successful, otherwise FALSE. */ BOOL OnSetSelected(int bSelected); /** * @brief * This method is called when the user clicks the control. * @param bKeyboard TRUE if the control is selected using the keyboard. * @param pt Mouse cursor position. */ void OnClick(BOOL bKeyboard = FALSE, CPoint pt = CPoint(0, 0)); /** * @brief * This method is called when the control is executed. */ void OnExecute(); /** * @brief * This member is called when the user releases the left mouse button. * @param point Specifies the x- and y- coordinates of the cursor. */ void OnLButtonUp(CPoint point); protected: /** * @brief * The framework calls this member function to determine * whether a point is in the bounding rectangle of the * specified tool. * @param point Specifies the x- and y- coordinates of the cursor. * These coordinates are always relative to the * upper-left corner of the window. * @param pTI A pointer to a TOOLINFO structure. * @return * If the tooltip control was found, then the window control ID is returned. * If the tooltip control was not found, then a value of -1 is returned. */ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; private: CRect GetRect(int nIndex) const; int HitTest(CPoint point) const; BOOL IsFocused() const; BOOL OnHookKeyDown(UINT nChar, LPARAM /*lParam*/); void SetSelectedItem(int nItem); int GetItemCount() const; private: int m_nSelected; int m_nPressed; COLORREF m_clr; # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPControlPopupColor); /** @endcond */ # endif }; // Obsolete define # define XTP_IDS_AUTOMATIC XTP_IDS_CLR_AUTOMATIC # define XTP_IDS_MORE_COLORS XTP_IDS_CLR_MORE /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTPCONTROLPOPUPCOLOR_H__) /** @endcond */