/** * @file XTPTabManagerItem.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(__XTPTABMANAGERITEM_H__) # define __XTPTABMANAGERITEM_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPMarkupUIElement; class CXTPImageManagerIcon; class CXTPTabManagerNavigateButtons; class CXTPTabManager; /** * @brief * CXTPTabManagerItem is the base class for the tabs that appear in * the command bars tab workspace, docking panes, and tab control. */ class _XTP_EXT_CLASS CXTPTabManagerItem : public CXTPCmdTarget { /** @cond */ DECLARE_DYNAMIC(CXTPTabManagerItem) /** @endcond */ protected: /** * @brief * Constructs a CXTPTabManagerItem object. */ CXTPTabManagerItem(); /** * @brief * Destroys a CXTPTabManagerItem object, handles cleanup and deallocation. */ virtual ~CXTPTabManagerItem(); public: /** * @brief * Sets the text caption for this tab. * @param lpszCaption Text caption to be set. * @details * The text caption is the text displayed in the tab button. * @see * GetCaption */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Gets the text caption of this tab. * @details * The text caption is the text displayed in the tab button. * @return * The text caption of this tab. * @see * SetCaption */ virtual CString GetCaption() const; /** * @brief * Sets the tooltip for this tab. * @param lpszTooltip Tooltip to be set. * @details * The tooltip is the text displayed when * the mouse is positioned over the tab button. * @see * GetTooltip, CXTPTabManager::GetItemTooltip */ void SetTooltip(LPCTSTR lpszTooltip); /** * @brief * Gets the tooltip of this tab. * @details * The tooltip is the text displayed when * the mouse is positioned over the tab button. * @return * The tooltip of this tab. * @see * SetTooltip, CXTPTabManager::GetItemTooltip */ CString GetTooltip() const; /** * @brief * Gets the color of the tab button. * @return * The color of the tab button. * @see * SetColor, CXTPTabManager::GetItemColor */ COLORREF GetColor(); /** * @brief * Sets the color for the tab button. * @param clr Color to be set. * @details * This method calls CXTPTabManager::RedrawControl after the color is set. * @see * GetColor, CXTPTabManager::GetItemColor */ void SetColor(COLORREF clr); /** * @brief * Gets the bounding rectangle of the tab button. * @return * The bounding rectangle of the tab button. * @see * SetRect */ CRect GetRect() const; /** * @brief * Gets the width of the tab button. * @return * The width of the tab button. * @details * The width of the tab button may change depending on * the layout and position of the tabs. * @see * XTPTabLayoutStyle, XTPTabPosition */ int GetButtonLength() const; /** * @brief * Gets the width of the content of the tab button. * @return * The width of the content of the tab button. * @details * The width of the content of the tab button may change depending on * the layout and position of the tabs. * @see * XTPTabLayoutStyle, XTPTabPosition */ int GetContentLength() const; /** * @brief * Gets the index of this tab within the collection of tabs. * @return * The index of this tab within the collection of tabs. * @see * CXTPTabManager::GetItem, CXTPTabManager */ int GetIndex() const; /** * @brief * Gets the index of the image displayed in the tab button. * @return * The index of the image displayed in the tab button. * @details * This is the index of the image within either * a CXTPImageManager or CImageList object. * * CXTPTabManager::ShowIcons is used to show/hide icons. * @see * SetImageIndex, CXTPTabControl::InsertItem, CXTPTabControl::GetImageManager, * CXTPTabControl::SetImageList, CXTPTabManager::ShowIcons */ int GetImageIndex() const; /** * @brief * Sets the index for the image displayed in the tab button. * @param nImage Index to be set. * @details * This is the index of the image within either * a CXTPImageManager or CImageList object. * * CXTPTabManager::ShowIcons is used to show/hide icons. * @see * GetImageIndex, CXTPTabControl::InsertItem, CXTPTabControl::GetImageManager, * CXTPTabControl::SetImageList, CXTPTabManager::ShowIcons */ void SetImageIndex(int nImage); /** * @brief * Gets the application-supplied, 32-bit value associated with * the tab item. * @details * This method returns the "extra" information, such as pointers * and/or integers, that was associated with the tab item using * the SetData function. * Note: * Do not use GetData when working with docking pane tabs. * With docking panes, GetData returns a pointer to a CXTPDockingPane. * Use CXTPDockingPane::GetPaneData when working with docking panes. * @return * The 32-bit value associated with the tab item. * @see * SetData, CXTPDockingPane::SetPaneData, CXTPDockingPane::GetPaneData */ DWORD_PTR GetData() const; /** * @brief * Sets the 32-bit value associated with the tab item. * @param dwData Value to be set. * @details * This method allows for "extra" information, such as pointers * and/or integers to be associated with the tab item. * Note: * Do not use SetData when working with docking pane tabs. * With docking panes, dwData stores a pointer to a CXTPDockingPane. * Use CXTPDockingPane::SetPaneData when working with docking panes. * @see * SetData, CXTPDockingPane::SetPaneData */ void SetData(DWORD_PTR dwData); /** * @brief * Sets the handle for the object displayed in the tab client area * when this tab is selected. * @param hWnd Handle of the object to be set. * @see * GetHandle */ void SetHandle(HWND hWnd); /** * @brief * Gets the handle of the object displayed in the tab client area * when this tab is selected. * @return * The handle of the object displayed in the tab client area * when this tab is selected. * @see * SetHandle */ HWND GetHandle() const; /** * @brief * Sets the bounding rectangle for this tab. * @param rcItem Bounding rectangle to be set. * @see * GetRect */ void SetRect(CRect rcItem); /** * @brief * Determines if this tab is shown/hidden. * @return * TRUE if this tab is shown, FALSE if this tab is hidden. * @details * A tab may not be visible due to the tab layout. * @see * SetVisible */ BOOL IsVisible() const; /** * @brief * Shows/hides this tab. * @param bVisible TRUE to show this tab, FALSE to hide this tab. * @see * IsVisible */ virtual void SetVisible(BOOL bVisible); /** * @brief * Determines if this tab is enabled/disabled. * @return * TRUE if this tab is enabled, FALSE if this tab is disabled. * @see * SetEnabled */ BOOL IsEnabled() const; /** * @brief * Enables/disables this tab. * @param bEnabled TRUE to enable this tab, FALSE to disable this tab. * @details * If a tab is disabled, then it will appear "grayed out" * and will be inaccessible to the user. * @see * IsEnabled */ void SetEnabled(BOOL bEnabled); /** * @brief * Gets the row of this item. * @return * The row of this item. */ int GetItemRow() const; /** * @brief * Determines if this item has shrinked. * @return * TRUE if this item has shrinked, otherwise FALSE. */ BOOL IsItemShrinked() const; /** * @brief * Gets the collection of navigate buttons. * @return * A pointer to the collection of navigate buttons. * @see * CXTPTabManagerNavigateButtons, CXTPTabManagerNavigateButton */ CXTPTabManagerNavigateButtons* GetNavigateButtons(); public: /** * @brief * Determines the selected state of this tab * (i.e. if this tab is clicked). * @return * TRUE if this tab is selected, otherwise FALSE. */ BOOL IsSelected() const; /** * @brief * Determines the focused state of this tab. * @return * TRUE if this tab has focus, otherwise FALSE. */ BOOL IsFocused() const; /** * @brief * Determines the highlighted state of this tab. * @details * A tab is highlighted when CXTPTabPaintManager::m_bHotTracking * is TRUE and either the mouse pointer is positioned over * the tab button or the tab is being dragged (i.e. when reordering tabs). * @return * TRUE if this tab is highlighted, otherwise FALSE. * @see * IsPressed, IsFocused */ BOOL IsHighlighted() const; /** * @brief * Determines the pressed state of this tab. * @return * TRUE if this tab is pressed, otherwise FALSE. * @see * IsHighlighted */ BOOL IsPressed() const; /** * @brief * Deletes this tab. */ void Remove(); /** * @brief * Selects this tab. * @details * This method calls OnItemClick. * * A tab can also be selected by clicking on it. */ void Select(); /** * @brief * Sets the position for this item. * @param nIndex Position to be set. */ void Move(int nIndex); /** * @brief * Determines if this tab is closable. * @return * TRUE if this tab can be closed, otherwise FALSE. */ BOOL IsClosable() const; /** * @brief * Specifies if this tab should be closable. * @param bClosable TRUE to allow this tab to be closed, * FALSE to disallow this tab from being closed. */ void SetClosable(BOOL bClosable); /** * @brief * Gets the Markup element used to render the caption of this tab. * @return * A pointer to the Markup element used to render the caption of this tab. */ CXTPMarkupUIElement* GetMarkupUIElement() const; /** * @brief * Determines if this tab is new window. * @return * TRUE if this tab is new window, otherwise FALSE. */ BOOL IsNewWindowTab(); /** * @brief * Specifies if this tab is new window. */ void SetNewWindowTab(); public: /** * @brief * Gets the tab manager. * @details * The tab manager is used to manage all CXTPTabManagerItem objects. * @return * A pointer to the tab manager. */ CXTPTabManager* GetTabManager() const; /** * @brief * Draws the icon of a tab. * @param pDC Pointer to device context to draw. * @param rcIcon Bounding rectangle of the icon. * @param pImage Pointer to the image associated with the tab. * @see * CXTPImageManagerIcon */ void DrawImage(CDC* pDC, CRect rcIcon, CXTPImageManagerIcon* pImage); protected: /** * @brief * Updates the position of the tab manager. */ void Reposition(); /** * @brief * This method is called when an item is removed from * the tab manager collection. */ virtual void OnRemoved(); private: BOOL DrawRotatedImage(CDC* pDC, CRect rcItem, CXTPImageManagerIcon* pImage); protected: int m_nButtonLength; /**< Width of the tab button. */ int m_nContentLength; /**< Width of the content of the tab button. */ int m_nImage; /**< Image index; this is the index of the image within a CXTPImageManger or CImageList object. */ int m_nIndex; /**< Index of this tab within the collection of tabs. */ BOOL m_bEnabled; /**< TRUE if this tab is enabled. */ BOOL m_bVisible; /**< TRUE if this tab is visible. */ HWND m_hWnd; /**< CWnd pointer to the window associated with this tab. */ HICON m_hIcon; /**< Icon associated with this tab. */ DWORD_PTR m_dwData; /**< Developer specific data. */ CRect m_rcItem; /**< Rectangle of this tab. */ CString m_strCaption; /**< User specified label for this tab. */ CString m_strToolTip; /**< Tooltip text for this tab. */ COLORREF m_clrItem; /**< Color of the tab button. */ CXTPTabManager* m_pTabManager; /**< Pointer to the parent item. */ int m_nItemRow; /**< Row of this item. */ BOOL m_bClosable; /**< TRUE if this item can be closed. */ BOOL m_bNewWindowTab; /**< TRUE if this item is new window tab. */ CXTPTabManagerNavigateButtons m_arrNavigateButtons; /**< Array of navigate buttons. */ CXTPMarkupUIElement* m_pMarkupUIElement; /**< Markup element pointer. */ private: BOOL m_bFound; friend class CXTPTabManager; friend class CXTPTabPaintManager; friend class CXTPTabWorkspace; friend class CXTPTabClientWnd; friend class CXTPGroupClientWnd; # ifdef _XTP_ACTIVEX /** @cond */ afx_msg BSTR OleGetCaption(); afx_msg void OleSetCaption(LPCTSTR lpszNewValue); afx_msg long OleGetIndex(); afx_msg long OleGetTag(); afx_msg void OleSetTag(long nNewValue); afx_msg BOOL OleGetSelected(); afx_msg void OleSetSelected(BOOL bNewValue); afx_msg long OleGetImage(); afx_msg void OleSetImage(long nNewValue); afx_msg void OleSetHandle(long hWnd); afx_msg void OleSetVisible(BOOL bVisible); afx_msg void OleGetRect(long* Left, long* Top, long* Right, long* Botton); afx_msg void OleEnsureVisible(); DECLARE_DISPATCH_MAP(); DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPTabManagerItem) COleVariant m_oleTag; /** @endcond */ # endif }; ////////////////////////////////////////////////////////////////////////// // CXTPTabManagerItem AFX_INLINE CXTPTabManager* CXTPTabManagerItem::GetTabManager() const { return m_pTabManager; } AFX_INLINE CRect CXTPTabManagerItem::GetRect() const { return m_rcItem; } AFX_INLINE int CXTPTabManagerItem::GetIndex() const { return m_nIndex; } AFX_INLINE DWORD_PTR CXTPTabManagerItem::GetData() const { return m_dwData; } AFX_INLINE void CXTPTabManagerItem::SetData(DWORD_PTR dwData) { m_dwData = dwData; } AFX_INLINE int CXTPTabManagerItem::GetImageIndex() const { return m_nImage; } AFX_INLINE BOOL CXTPTabManagerItem::IsClosable() const { return m_bClosable; } AFX_INLINE int CXTPTabManagerItem::GetButtonLength() const { return m_nButtonLength; } AFX_INLINE int CXTPTabManagerItem::GetContentLength() const { return m_nContentLength; } AFX_INLINE void CXTPTabManagerItem::SetTooltip(LPCTSTR lpszTooltip) { m_strToolTip = lpszTooltip; } AFX_INLINE int CXTPTabManagerItem::GetItemRow() const { return m_nItemRow; } AFX_INLINE BOOL CXTPTabManagerItem::IsItemShrinked() const { return m_nButtonLength < m_nContentLength; } AFX_INLINE CXTPTabManagerNavigateButtons* CXTPTabManagerItem::GetNavigateButtons() { return &m_arrNavigateButtons; } AFX_INLINE void CXTPTabManagerItem::SetNewWindowTab() { m_bNewWindowTab = TRUE; } AFX_INLINE BOOL CXTPTabManagerItem::IsNewWindowTab() { return m_bNewWindowTab; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPTABMANAGERITEM_H__) /** @endcond */