/** * @file XTPColorPageCustom.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(__XTPCOLORCUSTOM_H__) # define __XTPCOLORCUSTOM_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPColorDialog; /** * @brief * CXTPColorBase is a CStatic derived base class. It is used to create * custom color selection windows. */ class _XTP_EXT_CLASS CXTPColorBase : public CStatic { public: /** * @brief * Enumeration used to determine window focus. * @details * FocusControl type defines the constants used by CXTPColorBase for * determining which area of the color window control has focus. * @see * CXTPColorBase * @see * focusNone, focusColorWheel, focusLumination> */ enum FocusedControl { focusNone, /**< Color window does not have input focus. */ focusColorWheel, /**< Color wheel window has focus. */ focusLumination /**< Lumination window has focus. */ }; public: /** * @brief * Constructs a CXTPColorBase object. */ CXTPColorBase(); /** * @brief * Destroys a CXTPColorBase object, handles cleanup and deallocation. */ virtual ~CXTPColorBase(); public: /** * @brief * Call this member function to update the cursor position. * @param point Current cursor location relative to the device context. */ virtual void UpdateCursorPos(CPoint point); /** * @brief * This member function is called to convert an RGB color value to * an HSL value. * @param color An RGB value that represents the value to convert to HSL. * @param h Represents the color hue. * @param s Represents the color saturation. * @param l Represents the color illumination. * @return */ static void AFX_CDECL RGBtoHSL(COLORREF color, double* h, double* s, double* l); /** * @brief * This member function is called to convert an HLS value to an RGB * color value. * @param h Represents the color hue. * @param l Represents the color illumination. * @param s Represents the color saturation. * @return * A COLORREF value. */ static COLORREF AFX_CDECL HLStoRGB(double h, double l, double s); protected: /** * @brief * This member function is called by the CXTPColorBase class to * perform initialization when the window is created or sub-classed. * @return * TRUE if the window was successfully initialized, otherwise FALSE. */ virtual bool Init(); /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPColorBase) virtual void PreSubclassWindow(); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPColorBase) afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); //}}AFX_MSG /** @endcond */ protected: static FocusedControl m_eHasFocus; /**< Determines which property page has input focus. */ bool m_bPreSubclassInit; /**< true when initializing from PreSubclassWindow. */ public: double m_nLum; /**< Current illumination value. */ double m_nSat; /**< Current saturation value. */ double m_nHue; /**< Current hue value. */ CPoint m_ptMousePos; /**< Current mouse position relative to the device context. */ }; /** * @brief * CXTPColorWnd is a CXTPColorBase derived class. It is used to create a * color selection window. */ class _XTP_EXT_CLASS CXTPColorWnd : public CXTPColorBase { public: /** * @brief * Constructs a CXTPColorWnd object. */ CXTPColorWnd(); /** * @brief * Destroys a CXTPColorWnd object, handles cleanup and deallocation. */ virtual ~CXTPColorWnd(); public: /** * @brief * Call this member function to set the color for the selection window. * @param nHue Current hue value that represents the color. * @param nSat Current saturation value that represents the color. */ virtual void SetColor(double nHue, double nSat); /** * @brief * Call this member function to update the cursor position. * @param point Current cursor location relative to the device context. */ virtual void UpdateCursorPos(CPoint point); /** * @brief * This member function is called to update the crosshair cursor. * @param pDC A CDC pointer that represents the current device context. */ void DrawCrossHair(CDC* pDC); /** * @brief * This member function is called to set the hue for the color * window. * @param h Represents the new hue value to set. */ void SetHue(double h); /** * @brief * This member function is called to set the saturation for the * color window. * @param s Represents the new saturation value to set. */ void SetSaturation(double s); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPColorWnd) virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPColorWnd) afx_msg void OnPaint(); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg BOOL OnEraseBkgnd(CDC* pDC); //}}AFX_MSG /** @endcond */ protected: CBitmap m_bmpPicker; /**< Background device context. */ }; /** * @brief * CXTPColorLum is a CXTPColorBase derived class. It is used to create a * color luminance selection bar. */ class _XTP_EXT_CLASS CXTPColorLum : public CXTPColorBase { public: /** * @brief * Constructs a CXTPColorLum object. */ CXTPColorLum(); /** * @brief * Destroys a CXTPColorLum object, handles cleanup and deallocation. */ virtual ~CXTPColorLum(); public: /** * @brief * Call this member function to set the color for the selection window. * @param nHue Current hue value that represents the color. * @param nSat Current saturation value that represents the color. */ virtual void SetColor(double nHue, double nSat); /** * @brief * Call this member function to update the cursor position. * @param point Current cursor location relative to the device context. */ virtual void UpdateCursorPos(CPoint point); /** * @brief * This member function is called to draw the indicator arrow. * @param pDC A CDC pointer that represents the current device context. */ void DrawSliderArrow(CDC* pDC); /** * @brief * This member function is called to draw the selection bar. * @param pDC A CDC pointer that represents the current device context. */ void DrawLuminanceBar(CDC* pDC); /** * @brief * This member function is called to set the luminance for the color * window. * @param l Represents the new luminance value to set. */ void SetLuminance(double l); /** * @brief * This member function is called to retrieve the display size of the * luminance bar. * @param rect Address to a CRect object. */ void GetLumBarRect(CRect& rect); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPColorLum) virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPColorLum) afx_msg void OnPaint(); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg BOOL OnEraseBkgnd(CDC* pDC); //}}AFX_MSG /** @endcond */ protected: }; /** * @brief * CXTPColorPageCustom is derived from CPropertyPage. It is used * to create a CXTPColorPageCustom dialog. */ class _XTP_EXT_CLASS CXTPColorPageCustom : public CPropertyPage { public: /** * @brief * Constructs a CXTPColorPageCustom object. * @param pParentSheet A pointer to the parent sheet. */ CXTPColorPageCustom(CXTPColorDialog* pParentSheet = NULL); /** * @brief * Destroys a CXTPColorPageCustom object, handles cleanup and deallocation. */ virtual ~CXTPColorPageCustom(); public: /** * @brief * This member function is called to retrieve the HSL values of the RGB * specified by color. * @param color An RGB value that represents the color. * @param xtFocusLumination Address of the integer to receive the * illumination value (0-255). * @param sat Address of the integer to receive the saturation value (0-255). * @param hue Address of the integer to receive the hue value (0-255). */ void RGBtoHSL(COLORREF color, int* xtFocusLumination, int* sat, int* hue); protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPColorPageCustom) virtual BOOL OnSetActive(); virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPColorPageCustom) void UpdateRGB(COLORREF clr); afx_msg void OnChangeEdit(); afx_msg void OnChangeEditLum(); afx_msg void OnChangeEditHue(); afx_msg void OnChangeEditSat(); afx_msg LRESULT OnUpdateColor(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnColorDblClick(WPARAM wParam, LPARAM lParam); //}}AFX_MSG /** @endcond */ protected: /** @cond */ //{{AFX_DATA(CXTPColorPageCustom) enum { IDD = XTP_IDD_COLORCUSTOM }; CXTPColorWnd m_colorWnd; CXTPColorLum m_colorLum; CStatic m_txtSat; CStatic m_txtRed; CStatic m_txtLum; CStatic m_txtHue; CStatic m_txtGreen; CStatic m_txtBlue; CSpinButtonCtrl m_spinSat; CSpinButtonCtrl m_spinRed; CSpinButtonCtrl m_spinLum; CSpinButtonCtrl m_spinHue; CSpinButtonCtrl m_spinGreen; CSpinButtonCtrl m_spinBlue; CEdit m_editHue; CEdit m_editGreen; CEdit m_editBlue; CEdit m_editLum; CEdit m_editRed; CEdit m_editSat; int m_nR; int m_nB; int m_nG; int m_nH; int m_nL; int m_nS; //}}AFX_DATA /** @endcond */ protected: CXTPColorDialog* m_pParentSheet; /**< Pointer to the parent property sheet. */ friend class CXTPColorLum; }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPCOLORCUSTOM_H__) /** @endcond */