/** * @file XTPTabBaseTheme.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(__XTPTABCTRLTHEME_H__) # define __XTPTABCTRLTHEME_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPTabCtrl; class CXTPTabBase; class CXTPTabCtrlButton; class CXTPTabCtrlButtons; class CXTPTcbItem; class CXTPWinThemeWrapper; /** * @brief * CXTPTabBaseTheme is used to draw the CXTPTabBase object. All themes * used for CXTPTabBase should inherit from this base class. */ class _XTP_EXT_CLASS CXTPTabBaseTheme : public CXTPControlTheme { public: /** * @brief * Constructs a CXTPTabBaseTheme object. */ CXTPTabBaseTheme(); /** * @brief * Destroys a CXTPTabBaseTheme object, handles cleanup and deallocation. */ virtual ~CXTPTabBaseTheme(); public: /** * @brief * Call this function to refresh the colors of the Tab control. * @param pTab Pointer to a CTabCtrl object. */ virtual void RefreshMetrics(CTabCtrl* pTab); /** * @brief * This member function is called to render the tab control using * the specified theme. * @param pDC A CDC pointer that represents the current device * context. * @param pTabCtrl A pointer to a CXTPTabBase object. */ virtual void DrawTabCtrl(CDC* pDC, CXTPTabBase* pTabCtrl); /** * @brief * Call this member function to get the current background color * for the theme. * @return * A CXTPPaintManagerColor object that contains the value for the * current background color. * @see * CXTPTabBaseThemeOffice2003::GetBackColor */ virtual CXTPPaintManagerColor GetBackColor() const; /** * @brief * Call this member function to redraw the borders for a particular tab. * @param pTabCtrl A pointer to a CXTPTabBase object. * @param pMember A pointer to a CXTPTcbItem struct that contains information * about the tab. * @see * CXTPTabBaseThemeOfficeXP::AdjustBorders */ virtual void AdjustBorders(CXTPTabBase* pTabCtrl, CXTPTcbItem* pMember); /** * @brief * This member function is called to draw a single button of a tab control. * @param pDC A CDC pointer that represents the current device * context. * @param pButton A pointer to a CXTPTabCtrlButton object. * @param clrButton The color of the button. * Note: * This function ASSERTS if called. Must be overridden. */ virtual void DrawButton(CDC* pDC, CXTPTabCtrlButton* pButton, COLORREF clrButton); /** * @brief * This method is called to draw navigate buttons. * @param pDC A CDC pointer that represents the current device * context. * @param pButtons A pointer to a collection of buttons to draw. * @return * An RGB value that represents the background of the buttons. */ virtual COLORREF FillButtons(CDC* pDC, CXTPTabCtrlButtons* pButtons); protected: /** * @brief * This member function is called to draw the borders around the tab control. * @param pDC A pointer to a valid device context. * @param rcClient A CRect object that contains the location and dimensions * of the tab control. * @see * CXTPTabBaseThemeOfficeXP::DrawBorders */ virtual void DrawBorders(CDC* pDC, const CRect& rcClient); /** * @brief * This member function is called to draw the header for the tab control. * @param pDC A pointer to a valid device context. * @param pTabCtrlBase A pointer to a CXTPTabBase object. * @param rcHeader A CRect object that contains the location and dimensions * of the header. * @see * CXTPTabBaseThemeOfficeXP::FillHeader, FillTabFaceNativeWinXP */ virtual void FillHeader(CDC* pDC, CXTPTabBase* pTabCtrlBase, CRect rcHeader); /** * @brief * This member function is called to draw the tab face so that the * tab appears with the Native Windows XP theme. * @param pDC A pointer to a valid device context. * @param pTabCtrl A pointer to a CTabCtrl object. This is the associated * TabControl object. * @param rcItem A CRect object that contains the location and dimensions * of the tab. * @param bSelected TRUE if the tab is selected, FALSE otherwise. * @see * CXTPTabBaseThemeOfficeXP::FillTabFace, CXTPTabBaseThemeOffice2003::FillTabFace, * FillTabFace, DrawTab, DrawTabIcon, DrawTabText */ virtual void FillTabFaceNativeWinXP(CDC* pDC, CTabCtrl* pTabCtrl, CRect rcItem, BOOL bSelected); /** * @brief * This member function is called to draw the tab face. * @param pDC A pointer to a valid device context. * @param pTabCtrl A pointer to a CTabCtrl object. * @param rcItem A CRect object that contains the location and dimensions * of the tab. * @param bSelected TRUE if the tab is selected, FALSE otherwise. * @see * CXTPTabBaseThemeOfficeXP::FillTabFace, CXTPTabBaseThemeOffice2003::FillTabFace, * DrawTab, DrawTabIcon, DrawTabText, FillTabFaceNativeWinXP */ virtual void FillTabFace(CDC* pDC, CTabCtrl* pTabCtrl, CRect rcItem, BOOL bSelected); /** * @brief * This member function is called to draw a tab on the tab control. * @param pDC A pointer to a valid device context. * @param pTabCtrlBase A pointer to a CXTPTabBase object. Contains information * about the tab control. * @param iItem An int that specifies the tab item to draw. * @see * CXTPTabBaseThemeOfficeXP::FillTabFace, CXTPTabBaseThemeOffice2003::FillTabFace, * DrawTabIcon, DrawTabText, FillTabFaceNativeWinXP, CXTPExcelTabCtrlTheme::DrawTab, * FillTabFace */ virtual void DrawTab(CDC* pDC, CXTPTabBase* pTabCtrlBase, int iItem); /** * @brief * This member function is called to draw the icon on the tab. * @param pDC A pointer to a valid device context. * @param pTabCtrl A pointer to a CTabCtrl object. * @param rcItem A CRect object that contains the location and dimensions * of the tab. * @param iItem An int that represents the tab item to draw the icon on. * @see * CXTPTabBaseThemeOfficeXP::FillTabFace, CXTPTabBaseThemeOffice2003::FillTabFace, * DrawTab, DrawTabText, FillTabFace, FillTabFaceNativeWinXP, * CXTPExcelTabCtrlTheme::DrawTab */ virtual void DrawTabIcon(CDC* pDC, CTabCtrl* pTabCtrl, CRect& rcItem, int iItem); /** * @brief * This member function is called to draw text on the tab. * @param pDC A pointer to a valid device context. * @param pTabCtrl A pointer to a CTabCtrl object. * @param rcItem A CRect object that contains the location and dimensions * of the tab. * @param iItem Index of the item to draw. * @param bSelected TRUE if the tab is selected, FALSE otherwise. * @param bBoldFont TRUE if the text is to be bold, FALSE otherwise. * @see * CXTPTabBaseThemeOfficeXP::FillTabFace, CXTPTabBaseThemeOffice2003::FillTabFace, * DrawTabIcon, FillTabFace, FillTabFaceNativeWinXP, * CXTPExcelTabCtrlTheme::DrawTab */ virtual void DrawTabText(CDC* pDC, CTabCtrl* pTabCtrl, CRect& rcItem, int iItem, BOOL bSelected, BOOL bBoldFont); /** * @brief * Call this member function to get the bounding rectangle of the tab * header area. * @param pTabCtrlBase A pointer to a CXTPTabBase object. * @return * A CRect object that contains the bounding rectangle of the header area. * @see * FillHeader */ virtual CRect GetHeaderRect(CXTPTabBase* pTabCtrlBase); /** * @brief * Call this function to paint the Navigation buttons on the tab control. * @param pTabCtrlBase A pointer to a CXTPTabBase object. Contains * information about the tab control. * @see * DrawButton */ virtual void ShowButtons(CXTPTabBase* pTabCtrlBase); /** * @brief * This member function is called to draw a border around a tab child window. * @param pDC A pointer to a valid device context. * @param r A CRect object that contains the location and dimensions * of the child window. * @see * CXTPTabBaseThemeOfficeXP::DrawBorder, CXTPTabBaseThemeOffice2003::DrawBorder */ virtual void DrawBorder(CDC* pDC, const CRect& r); /** * @brief * This member function is called to determine the tab style. * @param pTabCtrl A pointer to a CTabCtrl object. * @return * A DWORD representing the tab style. * @see * IsLeft, IsRight, IsTop, IsBottom, IsVert, IsHorz */ DWORD GetTabStyle(CTabCtrl* pTabCtrl) const { _ASSERTE(::IsWindow(pTabCtrl->GetSafeHwnd())); return (pTabCtrl->GetStyle() & (TCS_VERTICAL | TCS_RIGHT | TCS_BOTTOM)); } /** * @brief * This member function is called to determine if the tabs are drawn * on the left side of the tab control. * @param dwStyle A DWORD value that represents the current tab style. * @return * A BOOL. TRUE if the tabs are drawn on the left side of the tab * control, otherwise FALSE. * @see * GetTabStyle, IsRight, IsTop, IsBottom, IsVert, IsHorz */ BOOL IsLeft(DWORD dwStyle) const { return ((dwStyle & (TCS_VERTICAL | TCS_RIGHT | TCS_BOTTOM)) == TCS_VERTICAL); } /** * @brief * This member function is called to determine if the tabs are drawn * on the right side of the tab control. * @param dwStyle A DWORD value that represents the current tab style. * @return * A BOOL. TRUE if the tabs are drawn on the right side of the tab * control, otherwise FALSE. * @see * GetTabStyle, IsLeft, IsTop, IsBottom, IsVert, IsHorz */ BOOL IsRight(DWORD dwStyle) const { return ((dwStyle & (TCS_VERTICAL | TCS_RIGHT | TCS_BOTTOM)) == (TCS_VERTICAL | TCS_RIGHT)); } /** * @brief * This member function is called to determine if the tabs are drawn * on the top of the tab control. * @param dwStyle A DWORD value that represents the current tab style. * @return * A BOOL. TRUE if the tabs are drawn on the top of the tab control, * otherwise FALSE. * @see * GetTabStyle, IsLeft, IsRight, IsBottom, IsVert, IsHorz */ BOOL IsTop(DWORD dwStyle) const { return ((dwStyle & (TCS_VERTICAL | TCS_RIGHT | TCS_BOTTOM)) == 0); } /** * @brief * This member function is called to determine if the tabs are drawn * on the bottom of the tab control. * @param dwStyle A DWORD value that represents the current tab style. * @return * A BOOL. TRUE if the tabs are drawn on the bottom of the tab control, * otherwise FALSE. * @see * GetTabStyle, IsLeft, IsRight, IsTop, IsVert, IsHorz */ BOOL IsBottom(DWORD dwStyle) const { return ((dwStyle & (TCS_VERTICAL | TCS_RIGHT | TCS_BOTTOM)) == TCS_BOTTOM); } /** * @brief * This member function is called to determine if the tabs are drawn * vertically on the tab control. * @param dwStyle A DWORD value that represents the current tab style. * @return * A BOOL. TRUE if the tabs are drawn vertically on the tab control, * otherwise FALSE. * @see * GetTabStyle, IsLeft, IsRight, IsTop, IsBottom, IsHorz */ BOOL IsVert(DWORD dwStyle) const { return (IsRight(dwStyle) || IsLeft(dwStyle)); } /** * @brief * This member function is called to determine if the tabs are drawn * horizontally on the tab control. * @param dwStyle A DWORD value that represents the current tab style. * @return * A BOOL. TRUE if the tabs are drawn horizontally on the tab control, * otherwise FALSE. * @see * GetTabStyle, IsLeft, IsRight, IsTop, IsVert, IsBottom */ BOOL IsHorz(DWORD dwStyle) const { return (IsTop(dwStyle) || IsBottom(dwStyle)); } /** * @brief * This member function is called to swap the dark and the light colors. * @param clrLight An RGB value that represents the light color. * @param clrDark An RGB value that represents the dark color. * @see * VerticalLine, HorizontalLine, Pixel */ void SwapColors(COLORREF& clrLight, COLORREF& clrDark); /** * @brief * This member function is called to draw a vertical line. * @param pDC A pointer to a valid device context. * @param xPos An int that specifies the logical x-coordinate of the line. * @param yPos An int that specifies the logical y-coordinate of the line. * @param nLength Specifies the length of the line. * @param clr An RGB value that specifies the color of the line. * @see * HorizontalLine, Pixel, SwapColors */ void VerticalLine(CDC* pDC, int xPos, int yPos, int nLength, COLORREF clr); /** * @brief * This member function is called to draw a horizontal line. * @param pDC A pointer to a valid device context. * @param xPos An int that specifies the logical x-coordinate of the line. * @param yPos An int that specifies the logical y-coordinate of the line. * @param nLength Specifies the length of the line. * @param clr An RGB value that specifies the color of the line. * @see * VerticalLine, Pixel, SwapColors */ void HorizontalLine(CDC* pDC, int xPos, int yPos, int nLength, COLORREF clr); /** * @brief * This member function is called to draw a single pixel. * @param pDC A pointer to a valid device context. * @param xPos An int that specifies the logical x-coordinate of the pixel. * @param yPos An int that specifies the logical y-coordinate of the pixel. * @param clr An RGB value that specifies the color of the pixel. * @see * VerticalLine, HorizontalLine, SwapColors */ void Pixel(CDC* pDC, int xPos, int yPos, COLORREF clr); private: typedef void(AFX_CDECL* LPFNDRAWROTATEDBITS)(int cx, int cy, UINT* pSrcBits, UINT* pDestBits); void DrawRotatedButton(CDC* pDC, CRect rcItem, BOOL bSelected, BOOL bSwap, LPFNDRAWROTATEDBITS pfnRotatedProc); static void AFX_CDECL DrawRotatedBitsLeft(int cx, int cy, UINT* pSrcBits, UINT* pDestBits); static void AFX_CDECL DrawRotatedBitsRight(int cx, int cy, UINT* pSrcBits, UINT* pDestBits); static void AFX_CDECL DrawRotatedBitsBottom(int cx, int cy, UINT* pSrcBits, UINT* pDestBits); public: BOOL m_bSystemDrawing; /**< TRUE to perform system drawing. FALSE otherwise. */ BOOL m_bUseWinThemes; /**< TRUE to use Windows XP themes when available. FALSE otherwise. */ protected: int m_iEdge; /**< The Y dimension of a 3D border. */ CXTPWinThemeWrapper* m_themeTab; /**< Windows Theme wrapper. */ CXTPPaintManagerColor m_clrNormalText; /**< Color of text in a normal tab. Normal tabs are tabs that are not selected or disabled. */ CXTPPaintManagerColor m_clrSelectedText; // Color of text in a "selected" tab button. The // "selected" tab button is the tab with focus. I.e. // The tab becomes active when it is clicked. */ }; /** * @brief * Class CXTPTabBaseThemeOfficeXP is derived from CXTPTabBaseTheme. * This class is used to implement an Office XP theme for the tab controls. */ class _XTP_EXT_CLASS CXTPTabBaseThemeOfficeXP : public CXTPTabBaseTheme { public: /** * @brief * Constructs a CXTPTabBaseThemeOfficeXP object. */ CXTPTabBaseThemeOfficeXP(); public: /** * @brief * This function calls the base class RefreshMetrics and then * calls DeleteObject() for the CPen member variables m_penBlack, * m_penWhite, m_penFace, and m_penText. Then, the CPen member variables * are created with the system default colors for COLOR_BTNTEXT, * COLOR_3DHIGHLIGHT, COLOR_3DFACE, and COLOR_3DSHADOW. Finally, the * member variable m_iEdge is set to the SM_CYEDGE system value. * @param pTab Pointer to a CTabCtrl object. */ virtual void RefreshMetrics(CTabCtrl* pTab); /** * @brief * Call this member function to redraw the borders for a particular tab. * @param pTabCtrl A pointer to a CXTPTabBase object. * @param pMember A pointer to a CXTPTcbItem struct that contains information * about the tab. * @see * CXTPTabBaseTheme::AdjustBorders */ virtual void AdjustBorders(CXTPTabBase* pTabCtrl, CXTPTcbItem* pMember); /** * @brief * This member is called to draw a single button of a tab control. * @param pDC A CDC pointer that represents the current device * context. * @param pButton A pointer to a CXTPTabCtrlButton object. * @param clrButton The color of the button. * Note: * This function ASSERTS if called. Must be overridden. */ virtual void DrawButton(CDC* pDC, CXTPTabCtrlButton* pButton, COLORREF clrButton); /** * @brief * This method is called to draw navigate buttons. * @param pDC A CDC pointer that represents the current device * context. * @param pButtons A pointer to a collection of buttons to draw. * @return * An RGB value that represents the background of the buttons. */ virtual COLORREF FillButtons(CDC* pDC, CXTPTabCtrlButtons* pButtons); protected: /** * @brief * This member function is called to draw the icon on the tab. * @param pDC A pointer to a valid device context. * @param pTabCtrl A pointer to a CTabCtrl object. * @param rcItem A CRect object that contains the location and dimensions * of the tab. * @param iItem An int that represents the tab item to draw the icon on. * @see * CXTPTabBaseTheme::FillTabFace, CXTPTabBaseThemeOffice2003::FillTabFace, * CXTPTabBaseTheme::DrawTabIcon, FillTabFace, * CXTPTabBaseTheme::FillTabFaceNativeWinXP, CXTPExcelTabCtrlTheme::DrawTab */ virtual void DrawTabIcon(CDC* pDC, CTabCtrl* pTabCtrl, CRect& rcItem, int iItem); /** * @brief * This member function is called to draw the borders around the tab control. * @param pDC A pointer to a valid device context. * @param rcClient A CRect object that contains the location and dimensions * of the tab control. * @see * CXTPTabBaseTheme::DrawBorders */ virtual void DrawBorders(CDC* pDC, const CRect& rcClient); /** * @brief * This member function is called to draw the header for the tab control. * @param pDC A pointer to a valid device context. * @param pTabCtrlBase A pointer to a CXTPTabBase object. * @param rcHeader A CRect object that contains the location and dimensions * of the header. * @see * CXTPTabBaseTheme::FillHeader, CXTPTabBaseThemeOffice2003::FillHeader */ virtual void FillHeader(CDC* pDC, CXTPTabBase* pTabCtrlBase, CRect rcHeader); /** * @brief * This member function is called draw the tab face. * @param pDC A pointer to a valid device context. * @param pTabCtrl A pointer to a CTabCtrl object. * @param rcItem A CRect object that contains the location and dimensions * of the tab. * @param bSelected TRUE if the tab is selected, FALSE otherwise. * @see * CXTPTabBaseTheme::FillTabFace, CXTPTabBaseThemeOffice2003::FillTabFace, * CXTPTabBaseThemeOffice2003::FillTabFace, DrawTabIcon, * CXTPExcelTabCtrlTheme::DrawTab, CXTPTabBaseTheme::FillTabFaceNativeWinXP */ virtual void FillTabFace(CDC* pDC, CTabCtrl* pTabCtrl, CRect rcItem, BOOL bSelected); /** * @brief * This member function is called to draw a border around a tab child window. * @param pDC A pointer to a valid device context. * @param r A CRect object that contains the location and dimensions * of the child window. * @see * CXTPTabBaseTheme::DrawBorder, CXTPTabBaseThemeOffice2003::DrawBorder */ virtual void DrawBorder(CDC* pDC, const CRect& r); }; /** * @brief * Class CXTPTabBaseThemeOffice2003 is derived from CXTPTabBaseThemeOfficeXP. */ class _XTP_EXT_CLASS CXTPTabBaseThemeOffice2003 : public CXTPTabBaseThemeOfficeXP { public: /** * @brief * Constructs a CXTPTabBaseThemeOffice2003 object. */ CXTPTabBaseThemeOffice2003(); public: /** * @brief * This function calls the base class RefreshMetrics and then * calls DeleteObject() for the CPen member variables m_penBlack, * m_penWhite, m_penFace, and m_penText. Then, the CPen member variables * are created with the system default colors for COLOR_BTNTEXT, * COLOR_3DHIGHLIGHT, COLOR_3DFACE, and COLOR_3DSHADOW. Finally, the * member variable m_iEdge is set to the SM_CYEDGE system value. * @param pTab Pointer to a CTabCtrl object. */ virtual void RefreshMetrics(CTabCtrl* pTab); /** * @brief * This member function is called to get the background for the theme. * @return * A CXTPPaintManagerColor object that contains the value for the * background color. * @see * CXTPTabBaseTheme::GetBackColor */ virtual CXTPPaintManagerColor GetBackColor() const; protected: /** * @brief * This member function is called to draw the header for the tab Control. * @param pDC A pointer to a valid device context. * @param pTabCtrlBase A pointer to a CXTPTabBase object. * @param rcHeader A CRect object that contains the location and dimensions * of the header. * @see * CXTPTabBaseTheme::FillHeader, CXTPTabBaseThemeOfficeXP::FillHeader */ virtual void FillHeader(CDC* pDC, CXTPTabBase* pTabCtrlBase, CRect rcHeader); /** * @brief * This member function is called to draw the tab face with a gradient fill. * @param pDC A pointer to a valid device context. * @param pTabCtrl A pointer to a CTabCtrl object. * @param rcItem A CRect object that contains the location and dimensions * of the tab. * @param bSelected TRUE if the tab is selected, FALSE otherwise. * @return * An RBG color that represents the dark color of the gradient fill for the tab. * @see * CXTPTabBaseThemeOfficeXP::FillTabFace, CXTPTabBaseThemeOffice2003::FillTabFace, * FillTabFace, DrawTab, DrawTabIcon, DrawTabText */ virtual COLORREF GradientFillTabFace(CDC* pDC, CTabCtrl* pTabCtrl, CRect rcItem, BOOL bSelected); /** * @brief * This member function is called to draw the tab face. * @param pDC A pointer to a valid device context. * @param pTabCtrl A pointer to a CTabCtrl object. * @param rcItem A CRect object that contains the location and dimensions * of the tab. * @param bSelected TRUE if the tab is selected, FALSE otherwise. * @see * CXTPTabBaseTheme::FillTabFace, CXTPTabBaseThemeOfficeXP::FillTabFace, * GradientFillTabFace */ virtual void FillTabFace(CDC* pDC, CTabCtrl* pTabCtrl, CRect rcItem, BOOL bSelected); /** * @brief * This member function is called to draw a border around a tab child window. * @param pDC A pointer to a valid device context. * @param r A CRect object that contains the location and dimensions * of the child window. * @see * CXTPTabBaseTheme::DrawBorder, CXTPTabBaseThemeOfficeXP::DrawBorder */ virtual void DrawBorder(CDC* pDC, const CRect& r); /** * @brief * This method is called to draw navigate buttons. * @param pDC A CDC pointer that represents the current device * context. * @param pButtons A pointer to a collection of buttons to draw. * @return * An RGB value that represents the background of the buttons. */ virtual COLORREF FillButtons(CDC* pDC, CXTPTabCtrlButtons* pButtons); protected: CXTPPaintManagerColorGradient m_clrHeaderFace; /**< Represents the gradient color of the header face. */ CXTPPaintManagerColor m_clrShadow; /**< Represents the color used for shadows. */ CXTPPaintManagerColor m_clrHighlight; /**< Represents the highlight color. */ CXTPPaintManagerColor m_clrDarkShadow; /**< Represents the color used for dark shadows. */ CXTPPaintManagerColor m_clrButtonSelected; /**< Represents the color used for selected buttons. */ CXTPPaintManagerColor m_clrButtonNormal; /**< Represents the color used for normal buttons. */ }; ///////////////////////////////////////////////////////////////////////////// # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPTABCTRLTHEME_H__) /** @endcond */