/** * @file XTPTabPaintManagerTheme.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(__XTPTABPAINTMANAGERTHEME_H__) # define __XTPTABPAINTMANAGERTHEME_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPTabPaintManagerColorSet; class CXTPTabManager; class CXTPTabManagerItem; class CXTPTabPaintManager; /** * @brief * CXTPTabPaintManagerTheme is a class that represents the appearance of all * components of the tab manager (e.g. tab button, tab caption font, * button size, tab margins, etc.). * @details * CXTPTabPaintManagerTheme is the base class for all appearances. * To create a custom appearance, a new class can be derived * either from this class or any of the appearances. * * The appearance should be updated in RefreshMetric's members * for each CXTPTabPaintManagerTheme object. * @see * XTPTabAppearanceStyle, SetAppearance, SetAppearanceSet, GetAppearance, * GetAppearanceSet, SetColor, GetColor, GetColorSet, SetColorSet, * CXTPTabPaintManagerColorSet */ class _XTP_EXT_CLASS CXTPTabPaintManagerTheme { public: /** * @brief * Constructs a CXTPTabPaintManagerTheme object. */ CXTPTabPaintManagerTheme(); /** * @brief * Destroys a CXTPTabPaintManagerTheme object, handles cleanup and deallocation. */ virtual ~CXTPTabPaintManagerTheme(); public: /** * @brief * Refreshes the appearance metrics. * Override this member to change the appearance metrics. * @details * This method is used to refresh the appearance metrics * such as font, button height, margin size, etc. */ virtual void RefreshMetrics(); /** * @brief * Gets the color set. * @return * A pointer to the color set. * @see * XTPTabColorStyle, CXTPTabPaintManager::GetColor, * CXTPTabPaintManager::SetColorSet, CXTPTabPaintManager::SetColor */ CXTPTabPaintManagerColorSet* GetColorSet() const; /** * @brief * Gets the bounding rectangle of the tab header area. * @param rcControl Bounding rectangle of the tab header. * See CXTPTabManager::GetControlRect. * @param pTabManager Pointer to a CXTPTabManager object. * @return * The bounding rectangle of the tab header area. * @see * GetClientRect, GetHeaderMargin, GetClientMargin, CXTPTabManager::GetControlRect */ virtual CRect GetHeaderRect(CRect rcControl, CXTPTabManager* pTabManager); /** * @brief * Gets the clip box of the tab header area. * @param pDC Pointer to a CDC object. * @param pTabManager Pointer to a CXTPTabManager object. * @return * The clip box of the tab header area. */ virtual CRect GetHeaderClipBox(CDC* pDC, CXTPTabManager* pTabManager); /** * @brief * Gets the height of the tab header area. * @param pTabManager Pointer to a CXTPTabManager object. * @return * The height of the tab header area. * @see * GetHeaderRect, GetClientRect, GetHeaderMargin, GetClientMargin, * CXTPTabManager::GetControlRect */ int GetHeaderHeight(CXTPTabManager* pTabManager); /** * @brief * Gets the bounding rectangle of the tab client area. * @param rcControl Bounding rectangle of the tab manager control. * See CXTPTabManager::GetControlRect. * @param pTabManager Pointer to a CXTPTabManager object. * @return * The bounding rectangle of the tab client area. * @see * GetHeaderRect, GetHeaderMargin, GetClientMargin, CXTPTabManager::GetControlRect */ virtual CRect GetClientRect(CRect rcControl, CXTPTabManager* pTabManager); /** * @brief * Gets the top, left, right, and bottom margins of the tab header. * @return * The top, left, right, and bottom margins of the tab header. * @details * The margins of the tab header are the space placed around * the tab buttons inside the tab header. * * The margins of the tab header are not placed around each * tab button. Instead, they are placed around all tab buttons. * * Example: *
	 * // Set the top, left, right, and bottom tab header margins to 5 pixels.  This will
	 * // place a margin of 5 pixels around the tab buttons in the tab header.
	 * m_wndTabControl.GetPaintManager()->GetAppearanceSet()->m_rcHeaderMargin.SetRect(5, 5, 5, 5);
	 *
	 * // Set the top, left, right, and bottom tab control margins to 4 pixels.  This will
	 * // place a margin of 4 pixels around the entire tab control (Includes tab header and tab
	 * // client area).
	 * m_wndTabControl.GetPaintManager()->m_rcControlMargin.SetRect(4, 4, 4, 4);
	 *
	 * // Set the top, left, right, and bottom tab button margins to 2 pixels.  This will
	 * // place a margin of 2 pixels around the text and icon in the tab buttons.
	 * m_wndTabControl.GetPaintManager()->m_rcButtonMargin.SetRect(2, 2, 2, 2);
	 *
	 * // Set the top, left, right, and bottom tab client margins to 10 pixels.  This will
	 * // place a margin of 10 pixels around the tab client area.
	 * m_wndTabControl.GetPaintManager()->m_rcClientMargin.SetRect(10, 10, 10, 10);
	 * 
* @see * m_rcHeaderMargin, GetHeaderRect */ virtual CRect GetHeaderMargin(); /** * @brief * Gets the top, left, right, and bottom margins of the tab client area. * @return * The top, left, right, and bottom margins of the tab client area. * @details * The margins of the tab client area are the space placed around * the tab client area inside the tab control. * * Example: *
	 * // Set the top, left, right, and bottom tab header margins to 5 pixels.  This will
	 * // place a margin of 5 pixels around the tab buttons in the tab header.
	 * m_wndTabControl.GetPaintManager()->GetAppearanceSet()->m_rcHeaderMargin.SetRect(5, 5, 5, 5);
	 *
	 * // Set the top, left, right, and bottom tab control margins to 4 pixels.  This will
	 * // place a margin of 4 pixels around the entire tab control (Includes tab header and tab
	 * // client area).
	 * m_wndTabControl.GetPaintManager()->m_rcControlMargin.SetRect(4, 4, 4, 4);
	 *
	 * // Set the top, left, right, and bottom tab button margins to 2 pixels.  This will
	 * // place a margin of 2 pixels around the text and icon in the tab buttons.
	 * m_wndTabControl.GetPaintManager()->m_rcButtonMargin.SetRect(2, 2, 2, 2);
	 *
	 * // Set the top, left, right, and bottom tab client margins to 10 pixels.  This will
	 * // place a margin of 10 pixels around the tab client area.
	 * m_wndTabControl.GetPaintManager()->m_rcClientMargin.SetRect(10, 10, 10, 10);
	 * 
* @see * CXTPTabPaintManager::m_rcClientMargin, GetClientRect */ virtual CRect GetClientMargin(); /** * @brief * Retrieves the total length of a specified tab button * including the left and right button margins. * @param pDC Pointer to a valid device context. * @param pItem Pointer to the tab button with the length to be retrieved. * @return * The total length of the specified tab button including * the left and right button margins. * @details * This method calls CXTPTabPaintManager::DrawSingleButtonIconAndText * with bDraw = FALSE to get the total length of the specified tab button * including the left and right button margins. * @see * CXTPTabPaintManager::m_rcButtonMargin, GetClientMargin, GetHeaderMargin, * CXTPTabPaintManager::DrawSingleButtonIconAndText, * CXTPTabManager::GetItemMetrics, GetButtonHeight */ virtual int GetButtonLength(CDC* pDC, CXTPTabManagerItem* pItem); /** * @brief * Retrieves the total height of the tab buttons within a specified tab manager * including the top and bottom margins and the icon. * @param pTabManager Pointer to the tab manager to retrieve * the total height of the tab buttons within. * @return * The height of the tab buttons within the specified tab manager. * @details * This method adds the size of the top and bottom margins and * the size of the icon to the size of * CXTPTabPaintManager.CXTPTabPaintManagerTheme.m_nButtonHeight * which is the height of * the tab buttons without the top or bottom margins or the icon. * @see * CXTPTabPaintManager.CXTPTabPaintManagerTheme.m_nButtonHeight, * CXTPTabPaintManager::m_rcButtonMargin, GetClientMargin, * GetHeaderMargin, CXTPTabPaintManager::DrawSingleButtonIconAndText, * CXTPTabManager::GetItemMetrics, GetButtonLength */ virtual int GetButtonHeight(const CXTPTabManager* pTabManager); /** * @brief * Retrieves the bounding rectangle of a specified drawing item. * @param pItem Pointer to the drawing item with * the bounding rectangle to retrieve. * @return * The bounding rectangle of the specified drawing item. * @see * CXTPTabManagerItem::GetRect */ virtual CRect GetButtonDrawRect(const CXTPTabManagerItem* pItem); public: /** * @brief * Draws the tab control. * @param pTabManager Pointer to the tab manager to draw. * @param pDC Pointer to a valid device context. * @param rcControl Bounding rectangle of the client area. * @details * This method is called during various Draw and Paint functions. * * Unless overridden, this method will just call * CXTPTabPaintManager::DrawTabControlEx. * @see * CXTPTabPaintManager::DrawTabControlEx. */ virtual void DrawTabControl(CXTPTabManager* pTabManager, CDC* pDC, CRect rcControl); /** * @brief * Fills both the tab header and the tab client area and then * draws the tab client frame. * @param pTabManager Pointer to the tab manager to fill. * @param pDC Pointer to a valid device context. * @param rcControl Bounding rectangle of the tab manager control. * See CXTPTabManager::GetControlRect. * @return * The bounding rectangle of the tab header. * @details * If CXTPTabPaintManager::m_bFillBackground is TRUE, then the tab client space * is filled using CXTPTabPaintManagerColorSet::m_clrControlFace. * CXTPTabPaintManager::m_bFillBackground is only FALSE when drawing * docking pane panel auto-hide tabs because there is no client area to draw. * @see * GetHeaderRect, CXTPTabPaintManager::m_bFillBackground, XTPTabClientFrame, * CXTPTabPaintManager::m_clientFrame */ virtual CRect FillTabControl(CXTPTabManager* pTabManager, CDC* pDC, CRect rcControl); /** * @brief * Moves the tab buttons of the tab control to their correct positions. * @param pTabManager Pointer to the tab manager that the tab buttons are on. * @param pDC Pointer to a valid device context. * @param rcClient Bounding rectangle of the tab client area. * @details * Both CXTPTabPaintManager::AdjustClientRect and * CXTPTabPaintManager::RepositionTabControl are called when the * window is resized. When CXTPTabPaintManager::DrawTabControl * is called, the changes will be used when drawing the tab control. * * This method is called during CXTPTabPaintManager::RepositionTabControl. * * Unless it is overridden, this method will only call * CXTPTabPaintManager::RepositionTabControlEx. */ virtual void RepositionTabControl(CXTPTabManager* pTabManager, CDC* pDC, CRect rcClient); /** * @brief * Adjusts the tab client rectangle. * @param pTabManager Pointer to the tab manager to adjust the tab client rectangle. * @param rcClient [out] Reference to a CRect object to receive * the new tab client rectangle with margins included. * @details * Both CXTPTabPaintManager::AdjustClientRect and * CXTPTabPaintManager::RepositionTabControl are called when the * window is resized. When CXTPTabPaintManager::DrawTabControl * is called, the changes will be used when drawing the tab control. * * This method will adjust the tab client rectangle based on * the currently set XTPTabClientFrame. * * CXTPTabPaintManager::AdjustClientRect calls this method if * there is one or more tabs in the tab manager. * @see * CXTPTabPaintManager::AdjustClientRect */ virtual void AdjustClientRect(CXTPTabManager* pTabManager, CRect& rcClient); /** * @brief * Draws a single tab button in the tab client header area. * @param pDC Pointer to a valid device context. * @param pItem Pointer to the tab button to draw. * @details * This method is only used to draw the tab button. This method does not * draw the button's icon or text. * * DrawSingleButton calls CXTPTabPaintManager::DrawSingleButtonIconAndText * after the button is drawn to draw the button's icon and text. * @see * CXTPTabPaintManager::DrawTabControlEx, * CXTPTabPaintManager::DrawSingleButtonIconAndText */ virtual void DrawSingleButton(CDC* pDC, CXTPTabManagerItem* pItem); /** * @brief * Draws a specified TabMDIClient TabWorkspace part. * @param pDC Pointer to a valid device context. * @param lpRect Size of the splitter. * @param workspacePart TabWorkspace part to be drawn; one of the values * defined by the XTPTabWorkspacePart enumeration. * @details * This method is used when drawing the TabWorkspace of * MDI tabs when tab grouping is enabled. * * If workspacePart is XTPTabWorkspacePartHSplitter, then lpRect refers to * the size of the splitter placed between horizontal tab groups. * * If workspacePart is XTPTabWorkspacePartVSplitter, then lpRect refers to * the size of the splitter placed between vertical tab groups. * * If workspacePart is XTPTabWorkspacePartWidth, then this is * the size of the splitter. * @see * XTPTabWorkspacePart */ virtual void DrawWorkspacePart(CDC* pDC, LPRECT lpRect, XTPTabWorkspacePart workspacePart); /** * @brief * Gets the supported color sets for this theme. * @return * The supported color sets for this theme. * @see * GetDefaultColorSet */ virtual int GetSupportedColorSets() { return xtpTabColorAll; } /** * @brief * Gets the default value of the color set for this theme. * @return * The default value of the color set for this theme. * @see * GetSupportedColorSets */ virtual XTPTabColorStyle GetDefaultColorSet() { return xtpTabColorDefault; } public: /** * @brief * Draws a tab button within a specified polygon. * @param pDC Pointer to the device context to draw. * @param pItem Pointer to the tab item to draw. * @param pts Pointer to an array of points that determine the target polygon. * @param nCount Number of points in the array of points of the target polygon. * @param tabPosition Tab position; must be one of the values * defined by the XTPTabPosition enumeration. * @param bAbsolute Flag that specifies if points are in absolute coordinates. * @return * The color of the tab that was filled */ COLORREF FillButton(CDC* pDC, CXTPTabManagerItem* pItem, LPPOINT pts, int nCount, XTPTabPosition tabPosition, BOOL bAbsolute = FALSE); /** * @brief * Draws the text of a specified item. * @param pDC Pointer to a valid device context. * @param pManager Pointer to a valid CXTPTabManager object. * @param str Reference to the text to render. * @param lpRect Size of the text to render. * @param nFormat Drawing format flags. */ virtual void DrawText(CDC* pDC, CXTPTabManager* pManager, const CString& str, LPRECT lpRect, UINT nFormat); /** @cond */ static void AFX_CDECL DrawPolyLine(CDC* pDC, COLORREF clr, LPPOINT pts, int nCount); static void AFX_CDECL DrawSingleLineBorder(CDC* pDC, CRect rc, XTPTabPosition position, COLORREF clrTopLeft, COLORREF clrBottomRight); static void AFX_CDECL InflateRectEx(CRect& rc, CRect rcInflate, XTPTabPosition position); static void AFX_CDECL DeflateRectEx(CRect& rc, CRect rcDeflate, XTPTabPosition position); /** @endcond */ public: CRect m_rcHeaderMargin; /**< CRect struct containing the left, top, right, and bottom */ /** * margins of the tab header. This is the space placed around * the tab buttons inside the tab header. */ int m_nRowMargin; // Margin between rows. protected: int m_nButtonHeight; /**< Current tab button height (without margins). */ CXTPTabPaintManager* m_pPaintManager; /**< Self paint manager pointer. */ BOOL m_bButtonsReverseZOrder; /**< Draw buttons in right to left order. */ friend class CXTPTabPaintManager; }; # define CXTPTabPaintManagerAppearanceSet CXTPTabPaintManagerTheme // Old class name. # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPTABPAINTMANAGERTHEME_H__) /** @endcond */