/** * @file XTPShortcutBarPane.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(__XTPSHORTCUTBARPANE_H__) # define __XTPSHORTCUTBARPANE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPShortcutBar; class CXTPShortcutBarPane; /** * @brief * CXTPShortcutBarPaneItem is a base class that represents * an item for a shortcut bar pane. */ class _XTP_EXT_CLASS CXTPShortcutBarPaneItem { protected: /** * @brief * Constructs a CXTPShortcutBarPaneItem object. * @param lpszCaption Caption of the item. * @param pWnd Pointer to the associated child window of the item. * @param nHeight Height of the item. */ CXTPShortcutBarPaneItem(LPCTSTR lpszCaption, CWnd* pWnd, int nHeight); public: /** * @brief * Gets the rectangle of the caption. * @return * The rectangle of the caption. */ CRect GetCaptionRect() const; /** * @brief * Gets the caption of the item. * * @return The caption of the item. */ CString GetCaption() const; /** * @brief * Sets the caption for the item. * @param lpszCaption Caption to be set. */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Sets the height for the item. * @param nHeight Height to be set. */ void SetHeight(int nHeight); /** * @brief * Gets the height of the item. * @return * The height of the item. */ int GetHeight() const; /** * @brief * Shows/hides the caption. * @param bShowCaption TRUE to show the caption, FALSE to hide the caption. */ void ShowCaption(BOOL bShowCaption); /** * @brief * Gets the highlighted state of the item. * @return * TRUE if the item is highlighted, otherwise FALSE. */ BOOL IsHighlighted() const; /** * @brief * Determines if the item is expandable. * @return * TRUE if the item is expandable, otherwise FALSE. */ BOOL IsExpandable() const; /** * @brief * Gets the expanded state of the item. * @return * TRUE if the item is expanded, otherwise FALSE. */ BOOL IsExpanded() const; /** * @brief * Specifies if the item should be expandable. * @param bExpandable TRUE to set the item to be expandable, FALSE otherwise. */ void SetExpandable(BOOL bExpandable); /** * @brief * Sets the expanded state of the item. * @param bExpanded TRUE to expand the item, FALSE to collapse the item. */ void SetExpanded(BOOL bExpanded); protected: CString m_strCaption; /**< Caption of the item. */ CRect m_rcCaption; /**< Rectangle of the caption. */ CRect m_rcClient; /**< Bounding rectangle of the client area. */ CWnd* m_pWndClient; /**< Associated child window. */ int m_nHeight; /**< Height of the item. */ BOOL m_bShowCaption; /**< TRUE to show the caption. */ CXTPShortcutBarPane* m_pPane; /**< Parent pane object. */ BOOL m_bExpandable; /**< TRUE if the pane is expandable. */ BOOL m_bExpanded; /**< TRUE if the pane is expanded. */ friend class CXTPShortcutBarPane; }; /** * @brief * CXTPShortcutBarPane is a CWnd derived class used * as a client area for a shortcut bar control. */ class _XTP_EXT_CLASS CXTPShortcutBarPane : public CWnd { /** @cond */ DECLARE_DYNAMIC(CXTPShortcutBarPane) /** @endcond */ public: /** * @brief * Constructs a CXTPShortcutBarPane object. */ CXTPShortcutBarPane(); /** * @brief * Destroys a CXTPShortcutBarPane object, handles cleanup and deallocation. */ virtual ~CXTPShortcutBarPane(); public: /** * @brief * Creates the CXTPShortcutBarPane control. * @param lpszCaption Caption of the pane. * @param pParent Pointer to the parent CXTPShortcutBar object. * @return TRUE if successful, FALSE otherwise. */ BOOL Create(LPCTSTR lpszCaption, CXTPShortcutBar* pParent); /** * @brief * Gets the caption of the pane. * @return * The caption of the pane. */ CString GetCaption() const; /** * @brief * Sets the caption for the pane. * @param lpszCaption Caption to be set. */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Adds a specified item to the pane. * @param lpszCaption Caption of the item. * @param pWnd Pointer to the associated child window of the item. * @param nHeight Height of the item. * @return * A pointer to the newly added CXTPShortcutBarPaneItem object. */ CXTPShortcutBarPaneItem* AddItem(LPCTSTR lpszCaption, CWnd* pWnd, int nHeight); /** * @brief * Gets the item at the specified index. * @param nIndex Zero-based index of the item to retrieve. * @return * A pointer to the item at the specified index. */ CXTPShortcutBarPaneItem* GetItem(int nIndex) const; /** * @brief * Sets the indent placed around the client area of the shortcut bar. * @param left Amount of space to be placed between the left client border * and the left border of the shortcut bar client area. * @param top Amount of space to be placed between the top client border * and the top border of the shortcut bar client area. * @param right Amount of space to be placed between the right client border * and the right border of the shortcut bar client area. * @param bottom Amount of space to be placed between the bottom client border * and the bottom border of the shortcut bar client area. * @details * The indent will be placed around the corresponding * CXTPShortcutBarPaneItem when displayed. */ void SetIndent(int left, int top, int right, int bottom); /** * @brief * Shows/hides the caption. * @param bShowCaption TRUE to show the caption, FALSE to hide the caption. */ void ShowCaption(BOOL bShowCaption); /** * @brief * Sets the minimum height for the client area. * @param nMinHeight Minimum height, in pixels, to be set. */ void SetMinimumClientHeight(int nMinHeight); /** * @brief * Gets the minimum height of the client area. * @return * The minimum height, in pixels, of the client area. */ virtual int GetMinimumClientHeight() const; /** * @brief * Determines which item, if any, is located at a specified point. * @param point Point to be tested. * @return * A pointer to the CXTPShortcutBarPaneItem object at * the specified point, if any, otherwise NULL. */ CXTPShortcutBarPaneItem* HitTest(CPoint point) const; /** * @brief * Recalculates the layout of the pane. */ void RecalcLayout(); CXTPShortcutBar* GetShortcutBar() const; CRect GetMinimizeButtonRect() const; BOOL IsMinimizeButtonHighlighted() const; BOOL IsMinimizeButtonPressed() const; virtual COLORREF GetBackgroundColor() const; virtual COLORREF GetTextColor() const; void SetFlatStyle(BOOL bFlatStyle); BOOL IsFlatStyle() const; protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_MSG(CXTPShortcutBarPane) afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM /*lParam*/); afx_msg void OnDraw(CDC* pDC); void OnMouseMove(UINT nFlags, CPoint point); void OnMouseLeave(); void OnLButtonDown(UINT nFlags, CPoint point); BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); //}}AFX_MSG /** @endcond */ private: BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); protected: CXTPShortcutBar* m_pShortcutBar; /**< Parent CXTPShortcutBar class. */ CString m_strCaption; /**< Caption of the pane. */ CArray m_arrItems; /**< Array of items. */ CRect m_rcIndent; /**< Indentation/padding around the client pane. */ BOOL m_bShowCaption; /**< TRUE to show caption. */ int m_nMinClientHeight; /**< The minimum height of the client area. */ CXTPShortcutBarPaneItem* m_pHighlighted; /**< Highlighted shortcut item. */ HCURSOR m_hHandCursor; /**< Hand cursor. */ CRect m_rcMinimizeButton; BOOL m_bMinimizeButtonHighlighted; BOOL m_bMinimizeButtonPressed; BOOL m_bFlatStyle; friend class CXTPShortcutBarPaneItem; }; ///////////////////////////////////////////////////////////////////////////// AFX_INLINE CString CXTPShortcutBarPane::GetCaption() const { return m_strCaption; } AFX_INLINE void CXTPShortcutBarPane::SetIndent(int left, int top, int right, int bottom) { m_rcIndent.SetRect(left, top, right, bottom); } AFX_INLINE void CXTPShortcutBarPane::ShowCaption(BOOL bShowCaption) { m_bShowCaption = bShowCaption; } AFX_INLINE BOOL CXTPShortcutBarPane::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) { return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext); } AFX_INLINE CRect CXTPShortcutBarPaneItem::GetCaptionRect() const { return m_rcCaption; } AFX_INLINE int CXTPShortcutBarPaneItem::GetHeight() const { return m_nHeight; } AFX_INLINE BOOL CXTPShortcutBarPaneItem::IsHighlighted() const { return m_pPane->m_pHighlighted == this; } AFX_INLINE CString CXTPShortcutBarPaneItem::GetCaption() const { return m_strCaption; } AFX_INLINE void CXTPShortcutBarPaneItem::ShowCaption(BOOL bShowCaption) { m_bShowCaption = bShowCaption; } AFX_INLINE void CXTPShortcutBarPane::SetMinimumClientHeight(int nMinHeight) { m_nMinClientHeight = nMinHeight; } AFX_INLINE int CXTPShortcutBarPane::GetMinimumClientHeight() const { return m_nMinClientHeight; } AFX_INLINE BOOL CXTPShortcutBarPaneItem::IsExpandable() const { return m_bExpandable && m_bShowCaption; } AFX_INLINE BOOL CXTPShortcutBarPaneItem::IsExpanded() const { return m_bExpanded; } AFX_INLINE void CXTPShortcutBarPaneItem::SetExpandable(BOOL bExpandable) { m_bExpandable = bExpandable; } AFX_INLINE void CXTPShortcutBarPaneItem::SetExpanded(BOOL bExpanded) { if (m_bExpanded != bExpanded) { m_bExpanded = bExpanded; m_pPane->RecalcLayout(); } } AFX_INLINE CXTPShortcutBar* CXTPShortcutBarPane::GetShortcutBar() const { return m_pShortcutBar; } AFX_INLINE CRect CXTPShortcutBarPane::GetMinimizeButtonRect() const { return m_rcMinimizeButton; } AFX_INLINE BOOL CXTPShortcutBarPane::IsMinimizeButtonHighlighted() const { return m_bMinimizeButtonHighlighted; } AFX_INLINE BOOL CXTPShortcutBarPane::IsMinimizeButtonPressed() const { return m_bMinimizeButtonPressed; } AFX_INLINE void CXTPShortcutBarPane::SetFlatStyle(BOOL bFlatStyle) { m_bFlatStyle = bFlatStyle; if (m_hWnd) Invalidate(FALSE); } AFX_INLINE BOOL CXTPShortcutBarPane::IsFlatStyle() const { return m_bFlatStyle; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSHORTCUTBARPANE_H__) /** @endcond */