/** * @file XTPRibbonPaintManager.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(__XTPRIBBONPAINTMANAGER_H__) # define __XTPRIBBONPAINTMANAGER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPRibbonGroup; class CXTPRibbonBar; class CXTPRibbonTab; class CXTPResourceImage; class CXTPResourceImages; class CXTPTabPaintManager; class CXTPRibbonTabContextHeaders; class CXTPPopupToolBar; class CXTPPaintManager; class CXTPRibbonControlSystemButton; _XTP_EXT_CLASS BOOL AFX_CDECL IsCompositeRect(CXTPCommandBar* pRibbonBar, const CRect& rc); /** * @brief * Standalone class used by CXTPRibbonBar as a paint manager. */ class _XTP_EXT_CLASS CXTPRibbonPaintManager : public CXTPCmdTarget { /** @cond */ DECLARE_DYNAMIC(CXTPRibbonPaintManager) /** @endcond */ public: /** * @brief * Constructs a CXTPRibbonPaintManager object. * @param pPaintManager Pointer to a CXTPPaintManager object. */ CXTPRibbonPaintManager(CXTPPaintManager* pPaintManager); /** * @brief * Destroys a CXTPRibbonPaintManager object, handles cleanup and deallocation. */ virtual ~CXTPRibbonPaintManager(); /** * @brief * This method is called to refresh the visual metrics of the manager. * @details * Refreshes all of the colors in the ribbon bar. Many of the colors * used are set with the GROUP_COLOR structure. * @see * GROUP_COLOR */ virtual void RefreshMetrics(); public: /** * @brief * Draws the specified CXTPRibbonGroup. * @param pDC Pointer to a valid device context. * @param pGroup Pointer to the CXTPRibbonGroup to be drawn. * @details * Draws the entire group including background, caption, and text. * This will not draw the option button or the group pop-up. * @see * GROUP_COLOR, FillRibbonBar, FillGroupRect, RefreshMetrics */ virtual void DrawGroup(CDC* pDC, CXTPRibbonGroup* pGroup) = 0; /** * @brief * Draws the specified control which is a part of the Quick Access panel. * @param pDC Pointer to a valid device context * @param pControl Control to draw. * @param pRibbon Pointer to the ribbon bar to draw the caption for. */ virtual void DrawQuickAccessControl(CDC* pDC, CXTPRibbonBar* pRibbon, CXTPControl* pControl); /** * @brief * This method is called to fill the background of a CXTPRibbonGroup. * @param pDC Pointer to a valid device context. * @param pActiveTab Pointer to the tab that is currently active. * @param rcGroups Bounding rectangle of the group. * @details * Performs a gradient fill using the GROUP_COLOR::clrBackground for * the main group background and GROUP_COLOR::clrCaption to fill the * group caption rectangle. * @see * CXTPRibbonGroup::GetRect, GROUP_COLOR */ virtual void FillGroupRect(CDC* pDC, CXTPRibbonTab* pActiveTab, CRect rcGroups) = 0; /** * @brief * Draws the group pop-up button. * @param pDC Pointer to a valid device context * @param pControlGroupPopup Pointer to a CXTPControlPopup object. * @param bDraw TRUE to draw the group pop-up button, * FALSE to retrieve the size of the control. * @details * A single group button will be displayed if there is not enough room * to display the items in the group. A group pop-up is displayed * when the button is clicked. The pop-up contains all the items in * the group. When a group button is clicked, a CXTPControlPopup * is displayed that contains the items of the group. * @return * If bDraw is FALSE, then the size of the group pop-up button control * will be returned. * @see * CXTPRibbonGroup::GetControlGroupPopup */ virtual CSize DrawControlGroupPopup(CDC* pDC, CXTPControlPopup* pControlGroupPopup, BOOL bDraw) = 0; /** * @brief * This method is called to fill the background of a ribbon bar control. * @param pDC Pointer to a valid device context * @param pRibbonBar Pointer to the parent ribbon bar. */ virtual void FillRibbonBar(CDC* pDC, CXTPRibbonBar* pRibbonBar) = 0; /** * @brief * Draws the group option button. * @param pDC Pointer to a valid device context. * @param pControlGroupOption Pointer to a CXTPControl object. * @param bDraw TRUE to draw option button, * FALSE to retrieve the size of the control. * @details * The option button is typically used to launch a dialog associated with the group. * It is drawn on the right side of the group caption. * @return * If bDraw is FALSE, then the size of the option button control * will be returned. * @see * CXTPRibbonGroup::ShowOptionButton, CXTPRibbonGroup::GetControlGroupOption */ virtual CSize DrawControlGroupOption(CDC* pDC, CXTPControl* pControlGroupOption, BOOL bDraw) = 0; /** * @brief * This method is called to draw ribbon context headers. * @param pDC Pointer to a valid device context. * @param pContextHeaders Collection of context headers. * @param pRibbonBar Pointer to the parent ribbon bar. */ virtual void DrawRibbonFrameContextHeaders(CDC* pDC, CXTPRibbonBar* pRibbonBar, CXTPRibbonTabContextHeaders* pContextHeaders) = 0; /** * @brief * This method is called to draw a single tab of the ribbon bar. * @param pDC Pointer to a valid device context. * @param pItem Ribbon tab to draw. */ virtual void DrawRibbonTab(CDC* pDC, CXTPRibbonTab* pItem) = 0; /** * @brief * This member fills in the tab header and tab client area. It * will then draw tab client frame. * @param pRibbonBar Pointer to the ribbon bar to draw the tab control for. * @param pDC Pointer to a valid device context. * @param rcControl Bounding rectangle of the tab control. */ virtual void FillRibbonTabControl(CDC* pDC, CXTPRibbonBar* pRibbonBar, CRect rcControl) = 0; /** * @brief * This method is called to draw the pop-up toolbar of a reduced group. * @param pDC Pointer to a valid device context. * @param pGroup Parent group of pop-up'ed toolbar. * @param pCommandBar Pop-up toolbar to draw. */ virtual void FillGroupPopupToolBar(CDC* pDC, CXTPRibbonGroup* pGroup, CXTPCommandBar* pCommandBar) = 0; /** * @brief * This method is called to draw the ribbon caption if EnableFrameTheme * was not called. * @param pDC Pointer to a valid device context. * @param pRibbonBar Pointer to the ribbon bar to draw the caption for. * @param bActive TRUE if the ribbon frame is active. */ virtual void DrawRibbonFrameCaptionBar(CDC* pDC, CXTPRibbonBar* pRibbonBar, BOOL bActive) = 0; /** * @brief * This method is called to draw the Ribbon caption. * @param pDC Pointer to a valid device context. * @param pRibbonBar Pointer to the ribbon bar to draw the caption for. * @param bActive TRUE if the ribbon frame is active. */ virtual void DrawRibbonFrameCaption(CDC* pDC, CXTPRibbonBar* pRibbonBar, BOOL bActive) = 0; /** * @brief * This method is called to draw the Quick Access customize button. * @param pDC Pointer to a valid device context. * @param pControl Pointer to the Quick Access customize button. * @see * DrawRibbonQuickAccessMoreButton */ virtual void DrawRibbonQuickAccessButton(CDC* pDC, CXTPControlPopup* pControl) = 0; /** * @brief * This method is called to draw the Quick Access more button. * @param pDC Pointer to a valid device context. * @param pControl Pointer to the Quick Access more button. * @see * DrawRibbonQuickAccessButton */ virtual void DrawRibbonQuickAccessMoreButton(CDC* pDC, CXTPControlPopup* pControl) = 0; /** * @brief * Draws the top-left system button. * @param pDC Pointer to a valid device context. * @param pControl System button control. * @param rc Bounding rectangle of the control. */ virtual void DrawRibbonFrameSystemButton(CDC* pDC, CXTPRibbonControlSystemButton* pControl, CRect rc) = 0; /** * @brief * This method is called to draw scroll group buttons. * @param pDC Pointer to a valid device context. * @param pControl Scroll button to draw. * @param bScrollLeft TRUE to draw the left button, FALSE to draw the right. */ virtual void DrawRibbonScrollButton(CDC* pDC, CXTPControl* pControl, BOOL bScrollLeft) = 0; /** * @brief * This method is called to draw the background of a minimized pop-up bar * @param pDC Pointer to a valid device context. * @param pPopupToolBar Pointer to a pop-up toolbar. */ virtual void FillTabPopupToolBar(CDC* pDC, CXTPPopupToolBar* pPopupToolBar); /** * @brief * This method is called to draw the ribbon frame if EnableFrameTheme * was not called. * @param pDC Pointer to a valid device context. * @param pRibbonBar Ribbon bar to draw. */ virtual void DrawRibbonFramePart(CDC* pDC, CXTPRibbonBar* pRibbonBar); /** * @brief * This method is called to draw the pop-up bar of the more button. * @param pDC Pointer to a valid device context. * @param pBar Toolbar to fill. */ virtual void FillMorePopupToolBarEntry(CDC* pDC, CXTPCommandBar* pBar) = 0; /** * @brief * This method is called to draw the pop-up bar of the system button. * @param pDC Pointer to a valid device context. * @param pBar Toolbar to fill. */ virtual void FillSystemPopupBarEntry(CDC* pDC, CXTPPopupBar* pBar) = 0; /** * @brief * This method is called to draw a pop-up bar button. * @param pDC Pointer to a valid device context. * @param pButton Pop-up bar button to draw. */ virtual void DrawSystemPopupBarButton(CDC* pDC, CXTPControl* pButton) = 0; /** * @brief * This method is called to draw the ribbon group when the group is * minimized and only a button is displayed. When the button is * pressed, the group is displayed as a pop-up. * @param pDC Pointer to a valid device context. * @param pButton Button to draw. * @return TRUE if successful, FALSE otherwise. */ virtual BOOL DrawRibbonGroupControlEntry(CDC* pDC, CXTPControl* pButton) = 0; /** * @brief * This method is called to draw the ribbon group pop-up toolbar. * @param pDC Pointer to a valid device context. * @param pRibbonGroup Group to draw. */ virtual void DrawRibbonGroupPopupToolBar(CDC* pDC, CXTPRibbonGroup* pRibbonGroup); public: /** * @brief * Gets the edit control height. * @return * The edit control height. */ int GetEditHeight() const; /** * @brief * Sets the font height used for Ribbon. * @param nFontHeight New font height. * @see * GetFontHeight */ void SetFontHeight(int nFontHeight); /** * @brief * Gets the font height used for Ribbon. * @return * The font height used for Ribbon. * @see * SetFontHeight */ int GetFontHeight() const; /** * @brief * Calculates the ribbon caption height. * @param pRibbonBar Pointer to the parent ribbon bar. * @return * The ribbon caption height. */ virtual int GetRibbonCaptionHeight(const CXTPRibbonBar* pRibbonBar) const = 0; /** * @brief * Calculates the ribbon group option size. * @return * The ribbon group option size. */ virtual CSize GetControlGroupOptionSize() const = 0; /** * @brief * Gets the height of the group caption bar. * @return * The height of the group caption bar. * @see * CXTPRibbonGroup::RepositionControls, CXTPRibbonGroup::SetRect */ int GetGroupCaptionHeight() const; /** * @brief * Loads a bitmap image from the specified path. * @param lpszFileName The name of the file that contains the bitmaps * to load. * @details * The images are the bitmaps that represent all the visual components * of the Ribbon Bar. For example tab buttons, group buttons, menu buttons, * toolbar buttons, option button, toolbar dropdown, etc. * The images are loaded using LoadImage and are stored in the m_pImages * image collection. * Images for the Office 2007 theme can be found in the \\Source\\Ribbon\\Res * folder. * @return * New CXTPResourceImage containing the loaded bitmap. * @see * SetImageHandle, m_pImages */ CXTPResourceImage* LoadImage(LPCTSTR lpszFileName); /** * @brief * This method is called to get a pointer to the CXTPResourceImages object. * @return * A pointer to the CXTPResourceImages object. */ CXTPResourceImages* GetImages() const; public: /** * @brief * Call this member to get a pointer to the tab paint manager. * @details * The tab paint manager is used to customize the appearance of * CXTPTabManagerItem objects and the tab manager (i.e. tab colors, * styles, etc.). This member must be overridden in derived classes. * @return * A pointer to the CXTPTabPaintManager that contains the * visual elements of the tabs. */ CXTPTabPaintManager* GetTabPaintManager() const; /** * @brief * Call this member to get a pointer to the frame paint manager. * @return * A pointer to the frame paint manager. */ CXTPFramePaintManager* GetFramePaintManager() const; protected: /** * @brief * Creates a CXTPTabPaintManager object used to store the color and * appearance information of the tabs in the ribbon bar. * @return * A pointer to the newly created CXTPTabPaintManager object. */ virtual CXTPTabPaintManager* CreateTabPaintManager(); /** * @brief * This method is called to draw a ribbon bar application icon. * @param pDC Pointer to a valid device context. * @param pRibbonBar Pointer to the ribbon bar to draw the application icon for. * @param rc Bounding rectangle of the icon. * @param hIcon Pointer to the application icon to use. */ void DrawRibbonApplicationIcon(CDC* pDC, CXTPRibbonBar* pRibbonBar, CRect rc, HICON hIcon); /** * @brief * This method is called to draw caption text for an aero-transparent caption. * @param pDC Pointer to a valid device context. * @param rcCaptionText Caption text rectangle. * @param strText Caption text. * @param pSite Frame to draw. * @param bActive TRUE if the frame is active. */ void DrawDwmCaptionText(CDC* pDC, CRect rcCaptionText, CString strText, CWnd* pSite, BOOL bActive); # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ LPFONTDISP OleGetCaptionFont(); void OleSetCaptionFont(LPFONTDISP pFontDisp); LPFONTDISP OleGetTitleFont(); void OleSetTitleFont(LPFONTDISP pFontDisp); DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPRibbonTheme); DECLARE_INTERFACE_MAP() /** @endcond */ # endif public: BOOL m_bHotTrackingGroups; /**< TRUE to highlight the group under the cursor. */ BOOL m_bFlatFrame; /**< TRUE to draw a flat frame. */ CXTPPaintManagerFont m_fontGroupCaption; /**< Font used to draw text in the group caption. */ COLORREF m_clrRecentFileListEdgeShadow; /**< Color of the File List edge shadow. */ COLORREF m_clrRecentFileListEdgeHighLight; /**< Color of the File List edge highlight. */ int m_nTabsHeight; /**< Tabs heights. */ int m_nGroupSpacing; /**< Group spacing. */ int m_nGroupCaptionHeight; /**< Group caption bar height. */ protected: COLORREF m_clrRibbonFace; /**< Ribbon face color. */ COLORREF m_clrRibbonBorder; /**< Ribbon border color. */ COLORREF m_clrRibbonGroupCaptionText; /**< Ribbon group captions color. */ COLORREF m_clrRibbonInactiveFace; /**< Color of the ribbon when it is inactive. */ COLORREF m_clrFileButtonText; /**< Text caption to display when the system button is displayed as a tab button (Windows 7 style). Button style must be button caption. */ COLORREF m_clrMinimizedFrameEdgeHighLight; /**< Minimized bottom edge. */ COLORREF m_clrMinimizedFrameEdgeShadow; /**< Minimized bottom edge shadow. */ CXTPPaintManager* m_pPaintManager; /**< Paint manager used for the ribbon. */ CXTPTabPaintManager* m_pTabPaintManager; /**< Tab paint manager. */ CRect m_rcFileButtonMargin; /**< Margins of the system button when it is displayed as a tab button (Windows 7 style). */ public: private: HICON m_hApplicationIcon; BOOL m_bAlphaApplicationIcon; protected: friend class CXTPRibbonBar; }; AFX_INLINE int CXTPRibbonPaintManager::GetGroupCaptionHeight() const { return m_nGroupCaptionHeight; } AFX_INLINE CXTPTabPaintManager* CXTPRibbonPaintManager::GetTabPaintManager() const { return m_pTabPaintManager; } AFX_INLINE CXTPFramePaintManager* CXTPRibbonPaintManager::GetFramePaintManager() const { CXTPFramePaintManager* pFramePaintManager = NULL; if (NULL != m_pPaintManager) { pFramePaintManager = m_pPaintManager->GetFramePaintManager(); } return pFramePaintManager; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPRIBBONPAINTMANAGER_H__) /** @endcond */