/** * @file XTPHeaderCtrlTheme.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(__XTHEADERCTRLTHEME_H__) # define __XTHEADERCTRLTHEME_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPHeaderCtrl; class CXTPWinThemeWrapper; /** * @brief * CXTPHeaderCtrlTheme is a theme class used to draw a Windows classic style * theme for the header control.
* @details * The CXTPHeaderCtrlTheme class provides theme capability to the CXTPHeaderCtrl * class. You can derive a class from CXTPHeaderCtrlTheme to create custom user * defined themes. * * To use this class, first subclass your header control using the * Windows API SubclassWindow and a CXTPHeaderCtrl base class. Once * you have done this, you can call SetTheme and pass in a pointer to * the theme you wish to use for the header control. */ class _XTP_EXT_CLASS CXTPHeaderCtrlTheme : public CXTPControlTheme { public: /** * @brief * Constructs a CXTPHeaderCtrlTheme object using the specified * header control. */ CXTPHeaderCtrlTheme(); /** * @brief * Destroys a CXTPHeaderCtrlTheme object, handles cleanup and * deallocation. */ virtual ~CXTPHeaderCtrlTheme(); public: /** * @brief * Call this member function to return a pointer to the Windows * theme API wrapper for this control. * @return * A CXTPWinThemeWrapper pointer. */ CXTPWinThemeWrapper* GetThemeWrapper(); /** * @brief * Call this member function from the header control's WM_PAINT * message to perform themed drawing. * @param pDC Pointer to a valid device context. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. * @details * Called by the CXTPHeaderCtrlTheme class to render the header for * the CXTPHeaderCtrl object. */ virtual void DrawHeader(CDC* pDC, CXTPHeaderCtrl* pHeaderCtrl); /** * @brief * Call this member whenever the system colors need to be updated. * @param pHeader Pointer to the CXTPHeaderCtrl object. */ virtual void RefreshMetrics(CXTPHeaderCtrl* pHeader); /** * @brief * This member function can be called to determine if Windows XP * themes can be displayed for the header control. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. * @return * TRUE if Windows themes can be displayed, otherwise FALSE. */ virtual BOOL UseWinXPThemes(CXTPHeaderCtrl* pHeaderCtrl); /** * @brief * Call this member function to set the desired HDRARROW_XTP_drawing styles * for the header theme. * @param dwDrawStyle The desired styles for the header control theme. Can be * one or more of the values listed in the remarks section. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. * @details * Does not affect the WS_ (window style) settings. Styles to be * added or removed can be combined by using the bitwise OR (|) * operator. It can be one or more of the following: * * HDR_XTP_WINDEF: Allows the header control to display Windows XP * themes when they are available. * HDR_XTP_HOTTRACKING: Allows the header control to display mouse over * effects for the header control. * HDR_XTP_SORTARROW: Allows the header control to display a sort arrow * to indicate sort order. * @see * GetDrawStyle */ virtual void SetDrawStyle(DWORD dwDrawStyle, CXTPHeaderCtrl* pHeaderCtrl); /** * @brief * Call this member function to return the current drawing style * used by the header theme. * @return * The current HDRARROW_XTP_(xt theme) settings for the header control. * See SetDrawStyle for the complete list of available styles. * @see * SetDrawStyle */ virtual DWORD GetDrawStyle() const; /** * @brief * Retrieves the size and position of a header control within a * given rectangle. This function is used to determine the * appropriate dimensions for a new header control that is to * occupy the given rectangle. * @param lpHDL Pointer to an HDLAYOUT structure, which contains * information used to set the size and position of a * header control. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. * @return * Nonzero if successful, otherwise 0. */ virtual BOOL Layout(LPHDLAYOUT lpHDL, CXTPHeaderCtrl* pHeaderCtrl); /** * @brief * Cleans up allocated GDI resources used by the theme. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. * @details * The CXTPHeaderCtrlTheme class calls this member function to free GDI * resources that have been allocated during draw routines. */ virtual void CleanUp(CXTPHeaderCtrl* pHeaderCtrl); /** * @brief * Call this member function to set the bitmap image for the * specified header item. * @param iCol Zero-based index of the column to set the sort * image for. * @param uBitmapID Resource ID of the bitmap to use. * @param bRemove TRUE to remove a bitmap, FALSE if adding a bitmap. * @param crMask Color used to generate the mask. Each pixel of * this color in the given bitmap is changed to black * and the corresponding bit in the mask is set to one. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL SetBitmap(int iCol, UINT uBitmapID, BOOL bRemove, COLORREF crMask, CXTPHeaderCtrl* pHeaderCtrl); /** * @brief * Call this member function to determine if the header control displays * a sort arrow. * @return * TRUE if the header control displays a sort arrow, otherwise FALSE. */ BOOL HasSortArrow(); protected: /** * @brief * This member function is called by the theme to draw the header * control's background. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The structure * contains information about the item to be drawn and the type * of drawing required. */ virtual void OnDrawBackground(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by the theme to draw the header * control's background using Windows themes. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL OnDrawBackgroundWinThemed(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by the theme to draw the background * for the header item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. */ virtual void OnDrawItemBackground(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by the theme to draw the background * using Windows themes for the header item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL OnDrawItemBackgroundWinThemed(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by the theme to draw the sort used to * display the sort order for a header item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. * @param bAscending TRUE if the arrow is to be draw ascending. */ virtual void OnDrawItemSortArrow(LPDRAWITEMSTRUCT lpDIS, BOOL bAscending); /** * @brief * This member function is called to draw the text for the header * item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. */ virtual void OnDrawItemText(LPDRAWITEMSTRUCT lpDIS, CXTPHeaderCtrl* pHeaderCtrl); /** * @brief * This member function is called to draw a bitmap for the header * item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. * @param rcText Size of the area where the header item text is displayed. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. */ virtual void OnDrawItemBitmap(LPDRAWITEMSTRUCT lpDIS, CRect& rcText, CXTPHeaderCtrl* pHeaderCtrl); /** * @brief * This member function is called by CXTPHeaderCtrlTheme::OnDrawItemSortArrow * to draw the sort arrow. * @param pDC Pointer to a valid device context. * @param ptsArrow POINT array used to define the 3 points of the arrow drawn. * @param bAscending TRUE if the arrow is to be drawn ascending. */ virtual void DrawSortArrow(CDC* pDC, LPPOINT ptsArrow, BOOL bAscending); protected: int m_iArrowPadding; /**< Spacing between text and sort arrow. */ DWORD m_dwDrawStyle; /**< Style flags used by theme, see CXTPHeaderCtrlTheme::SetDrawStyle(). */ BOOL m_bUseWinThemes; /**< TRUE to use Windows XP themes when available. */ CSize m_sizePadding; /**< Leading and trailing padding for text display. */ CSize m_sizeArrow; /**< Width and height of sort arrow. */ COLORREF m_crText; /**< RGB value for text color. */ COLORREF m_cr3DFace; /**< RGB value for header background color. */ COLORREF m_cr3DShadow; /**< RGB value for border shadow color. */ COLORREF m_cr3DDkShadow; /**< RGB value for border dark shadow color. */ COLORREF m_cr3DHighLight; /**< RGB value for border highlight color. */ CXTPWinThemeWrapper* m_themeHeader; /**< Wraps the Windows XP theme API that is used to display Windows XP themes. */ }; /** @cond */ # define CXTPHeaderTheme CXTPHeaderCtrlTheme // deprecated /** @endcond */ /** @cond */ AFX_INLINE CXTPWinThemeWrapper* CXTPHeaderCtrlTheme::GetThemeWrapper() { return m_themeHeader; } /** @endcond */ /** * @brief * CXTPHeaderCtrlThemeOfficeXP is a CXTPHeaderCtrlTheme derived theme class * used to draw an Office XP style theme for the header control. * @details * The CXTPHeaderCtrlThemeOfficeXP class provides theme capability to the * CXTPHeaderCtrl class. You can derive a class from CXTPHeaderCtrlThemeOfficeXP * to create custom user-defined themes. * * To use this class, first subclass your header control using the * Windows API SubclassWindow and a CXTPHeaderCtrl base class. Once * you have done this, you can call SetTheme and pass in a pointer to * the theme you wish to use for the header control. */ class _XTP_EXT_CLASS CXTPHeaderCtrlThemeOfficeXP : public CXTPHeaderCtrlTheme { public: /** * @brief * Constructs a CXTPHeaderCtrlThemeOfficeXP object using the specified * header control. */ CXTPHeaderCtrlThemeOfficeXP(); /** * @brief * Destroys a CXTPHeaderCtrlThemeOfficeXP object, handles cleanup and * deallocation. */ virtual ~CXTPHeaderCtrlThemeOfficeXP(); protected: /** * @brief * This member function is called by the theme to draw the header * control's background. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. */ virtual void OnDrawBackground(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by the theme to draw the background * for the header item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. */ virtual void OnDrawItemBackground(LPDRAWITEMSTRUCT lpDIS); }; /** @cond */ # define CXTPHeaderThemeOfficeXP CXTPHeaderCtrlThemeOfficeXP // deprecated /** @endcond */ /** * @brief * CXTPHeaderCtrlThemeOffice2003 is a CXTPHeaderCtrlTheme derived theme class * used to draw an Office 2003 style theme for the header control. * @details * The CXTPHeaderCtrlThemeOffice2003 class provides theme capability to * the CXTPHeaderCtrl class. You can derive a class from * CXTPHeaderCtrlThemeOffice2003 to create custom user-defined themes. * * To use this class, first subclass your header control using the * Windows API SubclassWindow and a CXTPHeaderCtrl base class. Once * you have done this, you can call SetTheme and pass in a pointer to * the theme you wish to use for the header control. */ class _XTP_EXT_CLASS CXTPHeaderCtrlThemeOffice2003 : public CXTPHeaderCtrlTheme { public: /** * @brief * Constructs a CXTPHeaderCtrlThemeOffice2003 object using the specified * header control. */ CXTPHeaderCtrlThemeOffice2003(); /** * @brief * Destroys a CXTPHeaderCtrlThemeOffice2003 object, handles cleanup and * deallocation. */ virtual ~CXTPHeaderCtrlThemeOffice2003(); /** * @brief * Retrieves the size and position of a header control within a * given rectangle. This function is used to determine the * appropriate dimensions for a new header control that is to * occupy the given rectangle. * @param lpHDL Pointer to an HDLAYOUT structure, which contains * information used to set the size and position of a * header control. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. * @return * Nonzero if successful, otherwise 0. */ virtual BOOL Layout(LPHDLAYOUT lpHDL, CXTPHeaderCtrl* pHeaderCtrl); protected: /** * @brief * This member function is called by the theme to draw the header * control's background. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. */ virtual void OnDrawBackground(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by the theme to draw the background * for the header item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. */ virtual void OnDrawItemBackground(LPDRAWITEMSTRUCT lpDIS); private: COLORREF MixColor(COLORREF clrLight, COLORREF clrDark, double dFactor); }; /** * @brief * CXTPHeaderCtrlThemeExplorer is a CXTPHeaderCtrlThemeOffice2003 derived theme * class used to draw an Office XP style theme for the header * control. * @details * The CXTPHeaderCtrlThemeExplorer class provides theme capability to the * CXTPHeaderCtrl class. You can derive a class from CXTPHeaderCtrlThemeExplorer * to create custom user-defined themes. * * To use this class, first subclass your header control using the * Windows API SubclassWindow and a CXTPHeaderCtrl base class. Once * you have done this, you can call SetTheme and pass in a pointer to * the theme you wish to use for the header control. */ class _XTP_EXT_CLASS CXTPHeaderCtrlThemeExplorer : public CXTPHeaderCtrlThemeOffice2003 { public: /** * @brief * Constructs a CXTPHeaderCtrlThemeExplorer object using the specified * header control. */ CXTPHeaderCtrlThemeExplorer(); /** * @brief * Destroys a CXTPHeaderCtrlThemeExplorer object, handles cleanup and * deallocation. */ virtual ~CXTPHeaderCtrlThemeExplorer(); /** * @brief * Retrieves the size and position of a header control within a * given rectangle. This function is used to determine the * appropriate dimensions for a new header control that is to * occupy the given rectangle. * @param lpHDL Pointer to an HDLAYOUT structure, which contains * information used to set the size and position of a * header control. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. * @return * Nonzero if successful, otherwise 0. */ virtual BOOL Layout(LPHDLAYOUT lpHDL, CXTPHeaderCtrl* pHeaderCtrl); protected: /** * @brief * This member function is called by the theme to draw the background * using Windows themes for the header item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL OnDrawItemBackgroundWinThemed(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by CXTPHeaderCtrlTheme::OnDrawItemSortArrow * to draw the sort arrow. * @param pDC Pointer to a valid device context. * @param ptsArrow POINT array used to define the 3 points of the arrow drawn. * @param bAscending TRUE if the arrow is to be draw ascending. */ virtual void DrawSortArrow(CDC* pDC, LPPOINT ptsArrow, BOOL bAscending); /** * @brief * This member function is called by the theme to draw the header * control's background. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. */ virtual void OnDrawBackground(LPDRAWITEMSTRUCT lpDIS); }; /** * @brief * CXTPHeaderCtrlThemeResource is a CXTPHeaderCtrlThemeOfficeXP derived theme * class used to draw a resource .dll style theme for the header * control. * @details * The CXTPHeaderCtrlThemeResource class provides theme capability to the * CXTPHeaderCtrl class. You can derive a class from CXTPHeaderCtrlThemeResource * to create custom user-defined themes. * * To use this class, first subclass your header control using the * Windows API SubclassWindow and a CXTPHeaderCtrl base class. Once * you have done this, you can call SetTheme and pass in a pointer to * the theme you wish to use for the header control. */ class _XTP_EXT_CLASS CXTPHeaderCtrlThemeResource : public CXTPHeaderCtrlThemeOfficeXP { public: /** * @brief * Constructs a CXTPHeaderCtrlThemeResource object using the specified * header control. */ CXTPHeaderCtrlThemeResource(); /** * @brief * Call this member whenever the system colors need to be updated. * @param pHeader Pointer to the CXTPHeaderCtrl object. */ virtual void RefreshMetrics(CXTPHeaderCtrl* pHeader); protected: /** * @brief * This member function is called by the theme to draw the header * control's background. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The structure * contains information about the item to be drawn and the type * of drawing required. */ virtual void OnDrawBackground(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by the theme to draw the background * for the header item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. */ virtual void OnDrawItemBackground(LPDRAWITEMSTRUCT lpDIS); /** * @brief * This member function is called by CXTPHeaderCtrlTheme::OnDrawItemSortArrow * to draw the sort arrow. * @param pDC Pointer to a valid device context. * @param ptsArrow POINT array used to define the 3 points of the arrow drawn. * @param bAscending TRUE if the arrow is to be draw ascending. */ virtual void DrawSortArrow(CDC* pDC, LPPOINT ptsArrow, BOOL bAscending); /** * @brief * This member function is called by the theme to draw the sort used to * display the sort order for a header item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. * @param bAscending TRUE if the arrow is to be drawn ascending. */ virtual void OnDrawItemSortArrow(LPDRAWITEMSTRUCT lpDIS, BOOL bAscending); /** * @brief * This member function is called to draw the text for the header * item specified by lpDIS->itemID. * @param lpDIS A long pointer to a DRAWITEMSTRUCT structure. The * structure contains information about the item to be * drawn and the type of drawing required. * @param pHeaderCtrl Pointer to a CXTPHeaderCtrl object. */ virtual void OnDrawItemText(LPDRAWITEMSTRUCT lpDIS, CXTPHeaderCtrl* pHeaderCtrl); CXTPPaintManagerColorGradient m_crgBack; /**< Gradient item background color. */ CXTPPaintManagerColorGradient m_crgBackPressed; /**< Gradient pressed item background color. */ }; /** @cond */ # define CXTPHeaderThemeExplorer CXTPHeaderCtrlThemeExplorer // deprecated /** @endcond */ /** @cond */ # ifndef ODS_HOTLIGHT # define ODS_HOTLIGHT 0x0040 # endif // ODS_HOTLIGHT /** @endcond */ const DWORD HDR_XTP_WINDEF = 0x0001; /**< @see CXTPHeaderCtrlTheme::SetDrawStyle */ const DWORD HDR_XTP_HOTTRACKING = 0x0002; /**< @see CXTPHeaderCtrlTheme::SetDrawStyle */ const DWORD HDR_XTP_SORTARROW = 0x0004; /**< @see CXTPHeaderCtrlTheme::SetDrawStyle */ /** @cond */ AFX_INLINE BOOL CXTPHeaderCtrlTheme::HasSortArrow() { return ((m_dwDrawStyle & HDR_XTP_SORTARROW) == HDR_XTP_SORTARROW); } AFX_INLINE COLORREF CXTPHeaderCtrlThemeOffice2003::MixColor(COLORREF clrLight, COLORREF clrDark, double dFactor) { return RGB(GetRValue(clrLight) - dFactor * (GetRValue(clrLight) - GetRValue(clrDark)), GetGValue(clrLight) - dFactor * (GetGValue(clrLight) - GetGValue(clrDark)), GetBValue(clrLight) - dFactor * (GetBValue(clrLight) - GetBValue(clrDark))); } /** @endcond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTHEADERCTRLTHEME_H__) /** @endcond */