/** * @file XTPFramePaintManager.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(__XTPFRAMEPAINTMANAGER_H__) # define __XTPFRAMEPAINTMANAGER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCommandBarsFrameHook; class CXTPFrameShadow; class CXTPRibbonBar; /** * @brief Paint manager for the Office 2007 style window frame. */ class _XTP_EXT_CLASS CXTPFramePaintManager : public CObject { DECLARE_DYNAMIC(CXTPFramePaintManager); public: /** * @brief * Constructs a CXTPFramePaintManager object. * * @param pPaintManager Reference to a CXTPPaintManager object. */ CXTPFramePaintManager(CXTPPaintManager* pPaintManager); /** * @brief * Destroys a CXTPFramePaintManager object, handles cleanup and * deallocation */ virtual ~CXTPFramePaintManager(); public: /** * @brief * Sets the frame icon. * @param szIcon Size of the icon. * @param hIcon Icon handle to set. */ void SetIcon(HICON hIcon, CSize szIcon); public: /** * @brief * Calculates the frame caption rect. * @param pFrameHook CXTPCommandBarsFrameHook hook object. * @return Returns Calculated frame caption rect */ virtual CRect CalcFrameCaption(const CXTPCommandBarsFrameHook* pFrameHook) const; /** * @brief * Calculates the frame border sizes. * @param pFrameHook CXTPCommandBarsFrameHook hook object. * @return Returns Calculated frame border sizes */ virtual CRect CalcFrameBorder(const CXTPCommandBarsFrameHook* pFrameHook) const; public: virtual void RecalcLayout(CXTPCommandBarsFrameHook* pFrameHook); /** * @brief * This method is called to create the window region. * * @param pFrameHook CXTPCommandBarsFrameHook hook object. * @param sz Window size. * * @return * Region of the window to be set. */ virtual HRGN CalcFrameRegion(CXTPCommandBarsFrameHook* pFrameHook, CSize sz) const = 0; /** * @brief * This method is called to draw the frame if Ribbon was found. * * @param pDC Pointer to device context. * @param pFrameHook CXTPCommandBarsFrameHook hook object. */ virtual void DrawFrame(CDC* pDC, CXTPCommandBarsFrameHook* pFrameHook) = 0; virtual void DrawFrameIcon(CDC* pDC, CXTPCommandBarsFrameHook* pFrameHook, CRect& rcCaption); virtual void DrawFrameCaptionButtons(CDC* pDC, CXTPCommandBarsFrameHook* pFrameHook, CRect& rcCaptionText); /** * @brief * This method is called to draw the caption button. * * @param pDC Pointer to device context. * @param rc Bounding rectangle of the button. * @param nId Identifier of the button. * @param bSelected TRUE if the button is highlighted. * @param bPressed TRUE if the button is pressed. * @param bActive TRUE if the frame is active. */ virtual void DrawFrameCaptionButton(CDC* pDC, CRect rc, int nId, BOOL bSelected, BOOL bPressed, BOOL bActive) = 0; /** * @brief * This method is called to draw the caption button. * * @param pDC Pointer to device context. * @param rc Bounding rectangle of the button. * @param nId Identifier of the button. * @param bSelected TRUE if the button is highlighted. * @param bPressed TRUE if the button is pressed. * @param bActive TRUE if the frame is active. * @param pRibbonBar Ribbon bar pointer. */ virtual void DrawFrameCaptionButton(CDC* pDC, CRect rc, int nId, BOOL bSelected, BOOL bPressed, BOOL bActive, CXTPRibbonBar* pRibbonBar) = 0; virtual CSize GetCaptionButtonSize(UINT nId) const; virtual CSize GetCaptionButtonSize(UINT nId, HWND hwnd) const; virtual CRect GetCaptionButtonMargin() const; /** * @brief Obtains frame caption accent color. * @param bActive If TRUE then an active caption frame accent color to be obtained, FALSE otherwise. * @return Caption frame accent color value or COLORREF_NULL if no color is specified. */ virtual COLORREF GetFrameCaptionAccentTextColor(BOOL bActive) const; /** * @brief Determines whether xtpApplicationUseSystemAccentColor application ambient property is * set. * @return TRUE if use of system accent color is required, FALSE otherwise. */ BOOL IsUseSystemAccentColorEnabled() const; /** * @brief * Retrieves the frame caption's height. * * @return * The frame Caption's height. */ virtual int GetFrameCaptionHeight() const; /** * @brief * This method is called to refresh the visual metrics of the manager. */ virtual void RefreshMetrics(); /** * @brief * This method is called to get a pointer to the CXTPResourceImages object. * * @return * A pointer to the CXTPResourceImages object. */ CXTPResourceImages* GetImages() const; /** * @brief * This method is called to draw the frame caption text. * * @param pDC Pointer to device context. * @param rcCaptionText Bounding rectangle of window text. * @param pSite Frame to draw. * @param bActive TRUE if the frame is active. */ virtual void DrawCaptionText(CDC* pDC, CRect rcCaptionText, CWnd* pSite, BOOL bActive); /** * @brief * This method is called to draw the frame caption text. * * @param pDC Pointer to device context. * @param rcCaptionText Bounding rectangle of window text. * @param pSite Frame to draw. * @param bActive TRUE if the frame is active. * @param pRibbonBar Ribbon bar pointer. */ virtual void DrawCaptionText(CDC* pDC, CRect rcCaptionText, CWnd* pSite, BOOL bActive, CXTPRibbonBar* pRibbonBar); /** * @brief * This method is called to draw the frame caption bar. * * @param pDC Pointer to device context. * @param rcCaptionBar Caption bar rectangle. * @param pSite Frame to draw. * @param bActive TRUE if the frame is active. */ virtual void DrawCaptionBar(CDC* pDC, CRect rcCaptionBar, CWnd* pSite, BOOL bActive); /** * @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 * Retrieves frame small icon. * * @param pFrame Window to retrieve icon. * * @return * Frame small icon. * * @see * GetFrameLargeIcon */ HICON GetFrameSmallIcon(CWnd* pFrame); /** * @brief * Retrieves frame large icon. * * @param pFrame Window to retrieve icon. * * @return * Frame large icon. * * @see * GetFrameLargeIcon */ HICON GetFrameLargeIcon(CWnd* pFrame); /** * @brief * Creates frame shadow if supported by theme. Default implementation returns NULL. * * @param pFrame Window object pointer * * @return * Returns either a valid frame shadow pointer created by * XTPFrameShadowManager()->EnableShadow or NULL if frame has no shadow. * * @see * XTPFrameShadowManager */ virtual CXTPFrameShadow* CreateShadow(CWnd* pFrame); /** * @brief * An implementation can override this method in order to change frame appearance * when a window gets activated or deactivated. * * @param bActive TRUE is a window is activated, otherwise FALSE. * @param pFrame Window object pointer. * @param pShadow Shadow object pointer. * * @see * CreateShadow, XTPFrameShadowManager */ virtual void OnShadowedFrameActiveStateChanged(BOOL bActive, CWnd* pFrame, CXTPFrameShadow* pShadow); /** * @brief * Obtains theme specific active frame caption color value. * @return Theme specific active frame caption color value. */ const CXTPPaintManagerColor& GetFrameCaptionActiveColor() const; public: BOOL m_bFrameStatusBar; /**< TRUE if status bar used to draw.*/ BOOL m_bRoundedCornersAlways; CXTPPaintManagerFont m_fntFrameCaption; /**< Font used to draw text in the frame caption*/ public: int m_nFrameCaptionHeight; /**< Frame caption*/ CXTPPaintManager* m_pPaintManager; /**< Parent Paint Manager.*/ BOOL m_bFlatFrame; /**< TRUE to use a flat frame, FALSE otherwise.*/ BOOL m_bCaptionCenterAligned; /**< If TRUE, caption title will be center aligned.*/ protected: HICON m_hIcon; /**< Icon handle*/ CSize m_szIcon; /**< Icon size*/ CRect m_rcIconMargin; /**< Icon margin*/ CRect m_rcCaptionButtonMargin; CSize m_szCaptionButtonSize; CSize m_szMDIClildWindowCaptionButtonSize; CXTPPaintManagerColor m_clrFrameCaptionActive; /**< Caption color (active)*/ CXTPPaintManagerColor m_clrFrameCaptionInactive; /**< Caption color (inactive)*/ CXTPPaintManagerColor m_clrFrameCaptionTextActive; /**< Caption text color*/ CXTPPaintManagerColor m_clrFrameCaptionTextInactive; /**< Caption text color*/ CXTPPaintManagerColor m_clrFrameCaptionTextActiveTitle; /**< Caption text color*/ CXTPPaintManagerColor m_clrFrameCaptionTextActiveBSMode; /**< Caption text color*/ CXTPPaintManagerColor m_clrFrameCaptionTextInactiveBSMode; /**< Caption text color*/ CXTPPaintManagerColor m_clrFrameCaptionTextActiveTitleBSMode; /**< Caption text color*/ friend class CXTPMenuTitleBarCaption; }; AFX_INLINE int CXTPFramePaintManager::GetFrameCaptionHeight() const { return m_nFrameCaptionHeight; } AFX_INLINE CRect CXTPFramePaintManager::GetCaptionButtonMargin() const { return m_rcCaptionButtonMargin; } AFX_INLINE CSize CXTPFramePaintManager::GetCaptionButtonSize(UINT /*nId*/) const { return m_szCaptionButtonSize; } AFX_INLINE const CXTPPaintManagerColor& CXTPFramePaintManager::GetFrameCaptionActiveColor() const { return m_clrFrameCaptionActive; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(__XTPFRAMEPAINTMANAGER_H__) /** @endcond */