/** * @file XTPTabManagerNavigateButton.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(__XTPTABMANAGERNAVIGATEBUTTON_H__) # define __XTPTABMANAGERNAVIGATEBUTTON_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPTabManager; class CXTPTabManagerItem; /** * @brief * CXTPTabManagerNavigateButton is a class used to represent * a tab navigation button. * @details * Navigation buttons are the buttons that appear in the tab header area. * The buttons include the left arrow, right arrow, and close buttons. * Any combination of these buttons can be shown. You can choose to never * display then, always display them, or automatically display them. * If you automatically display the buttons, they are only displayed when * needed (e.g. when there are too many tabs to be displayed in the * tab header, the arrow buttons will appear). * * By default, all these buttons are displayed in the command bars * tab workspace. You must add them to the tab control. * * If the xtpTabNavigateButtonAutomatic flag is used, then buttons will * only appear when needed (e.g. when there are too many tabs to be * displayed in the tab header, the arrow buttons will appear). * * Example: * This example code illustrates how to specify when the tab navigation * buttons are displayed: *
 * //Finds the left navigation button and specifies that it is always displayed
 * m_wndTabControl.FindNavigateButton(xtpTabNavigateButtonLeft)->SetFlags(xtpTabNavigateButtonAlways);
 * //Finds the right navigation button and specifies that it is never displayed
 * m_wndTabControl.FindNavigateButton(xtpTabNavigateButtonRight)->SetFlags(xtpTabNavigateButtonNone);
 * //Finds the close navigation button and specifies that it is always displayed
 * m_wndTabControl.FindNavigateButton(xtpTabNavigateButtonClose)->SetFlags(xtpTabNavigateButtonAlways);
 *
 * //Called to recalculate tab area and reposition components
 * Reposition();
 * 
* @see * XTPTabNavigateButtonFlags, CXTPTabManager::FindNavigateButton */ class _XTP_EXT_CLASS CXTPTabManagerNavigateButton { public: /** * @brief * Constructs a CXTPTabManagerNavigateButton object. * @param pManager CXTPTabManager object to draw the button on. * @param nID ID of the button; can be one of * the values listed in the Remarks section. * @param dwFlags Indicates when to display the button. * @details * Standard IDs of buttons are listed below: * xtpTabNavigateButtonLeft: Left tab navigation button. * xtpTabNavigateButtonRight: Right tab navigation button. * xtpTabNavigateButtonClose: Close tab navigation button. * @see * CXTPTabManager::FindNavigateButton, XTPTabNavigateButtonFlags, * XTPTabNavigateButton */ CXTPTabManagerNavigateButton(CXTPTabManager* pManager, UINT nID, XTPTabNavigateButtonFlags dwFlags); protected: /** * @brief * Destroys a CXTPTabManagerNavigateButton object, handles cleanup and deallocation. */ virtual ~CXTPTabManagerNavigateButton(); public: /** * @brief * Adjusts the width of the tab header area. * @param nWidth Reference to the width of the tab header area. * @details * If the tabs are horizontal, then the width of the tab header area * is adjusted by subtracting the width of the navigation button from nWidth. * * If the tabs are vertical, then the width of the tab header area * is adjusted by subtracting the height of the navigation button from nWidth. * * The width will only be adjusted if the xtpTabNavigateButtonAlways flag is set. */ virtual void AdjustWidth(int& nWidth); /** * @brief * Specifies when the navigation button is displayed. * @param dwFlags Flags that indicate when the navigation button is displayed; must be * one of the values defined by the XTPTabNavigateButtonFlags enumeration. * @see * XTPTabNavigateButtonFlags, CXTPTabManager::FindNavigateButton, GetFlags */ void SetFlags(XTPTabNavigateButtonFlags dwFlags); /** * @brief * Determines when the navigation button is displayed. * @return * Flags that indicate when the navigation button is displayed; * one of the values defined by the XTPTabNavigateButtonFlags enumeration. * @see * XTPTabNavigateButtonFlags, CXTPTabManager::FindNavigateButton, SetFlags */ XTPTabNavigateButtonFlags GetFlags() const; /** * @brief * Gets the size of the navigation button. * @return * The size of the navigation button. * @see * GetRect */ virtual CSize GetSize() const; /** * @brief * Gets the parent item of the navigation button. * @return * A pointer to the parent item of the navigation button. */ CXTPTabManagerItem* GetItem() const; /** * @brief * Draws the navigation button in the tab header area. * @param pDC Pointer to a valid device context. */ void Draw(CDC* pDC); /** * @brief * This method is called when the user presses the left mouse button. * @param hWnd Handle to the CWnd object beneath the mouse cursor. * @param pt Specifies the x- and y- coordinates of the mouse cursor. * These coordinates are always relative to the upper-left * corner of the window. * @details * This method performs the common operations of when a button * is clicked (e.g. drawing the "pressed" button and calling * the OnExecute member of the clicked tab navigation button). * * When the user clicks on a tab navigation button, this method * will call the OnExecute member of the clicked tab navigation button. * OnExecute will then call CXTPTabManager::OnNavigateButtonClick to * pass in the indentifier of the tab navigation button that was pressed. * @see * CXTPTabManager::OnNavigateButtonClick */ virtual void PerformClick(HWND hWnd, CPoint pt); /** * @brief * Determines if the navigation button is enabled/disabled. * @return * TRUE if the navigation button is enabled, * FALSE if the navigation button is disabled. */ BOOL IsEnabled() const; /** * @brief * Determines the pressed state of the navigation button. * @return * TRUE if the navigation button is pressed, otherwise FALSE. * @details * This method is used within both CXTPTabColorSetDefault::FillNavigateButton * and all objects derived from CXTPTabColorSetDefault to determine * how to colorize the navigation button. * @see * CXTPTabColorSetDefault::FillNavigateButton */ BOOL IsPressed() const; /** * @brief * Determines the highlighted state of the navigation button. * @details * The navigation button becomes highlighted when * the mouse cursor is positioned over it. * * This method is used within both CXTPTabColorSetDefault::FillNavigateButton * and all objects derived from CXTPTabColorSetDefault to determine * how to colorize the navigation button. * @return * TRUE if the navigation button is highlighted, otherwise FALSE. * @see * CXTPTabColorSetDefault::FillNavigateButton */ BOOL IsHighlighted() const; /** * @brief * Determines the selected state of the owner tab button. * @return * TRUE if the owner tab button is selected, otherwise FALSE. */ BOOL IsOwnerSelected() const; /** * @brief * Determines the highlighted state of the owner tab button. * @return * TRUE if the owner tab button is highlighted, otherwise FALSE. */ BOOL IsOwnerHighlighted() const; /** * @brief * Determines if the navigation button is either * a common navigation item or owned by a tab item. * @return * TRUE if the navigation button is a common navigation item, * FALSE if the navigation button is owned by a tab item. */ BOOL IsOwnerNull() const; /** * @brief * Determines if this tab group is active/inactive. * @return * TRUE if this tab group is active, FALSE if this tab group is inactive. * @details * This method only applies to tab groups in the MDITabClient * (i.e. the tabs groups that appear in the CommandBars TabWorkspace) * when grouping is enabled. */ BOOL IsOwnerActive() const; /** * @brief * Determines the visible state of the navigation button. * @return * TRUE if the navigation button is visible, otherwise FALSE. */ BOOL IsVisible() const; /** * @brief * Gets the bounding rectangle of the navigation button. * @return * The bounding rectangle of the navigation button. */ CRect GetRect() const; /** * @brief * Sets the bounding rectangle for the navigation button. * @param rcButton Bounding rectangle to be set. */ void SetRect(CRect rcButton); /** * @brief * Gets the identifier of the navigation button. * @return * The identifier of the navigation button. * @details * See XTPTabNavigateButton for the list of standard identifiers. * @see * XTPTabNavigateButton */ UINT GetID() const; /** * @brief * Updates the position of the navigation button. * @param rcNavigateButtons Reference to the bounding rectangle of * the navigation buttons. */ virtual void Reposition(CRect& rcNavigateButtons); /** * @brief * Sets the tooltip for the navigation button. * @param lpszTooltip Tooltip to be set. * @details * The tooltip is the text displayed when * the mouse is positioned over the navigation button. * @see * GetTooltip */ void SetTooltip(LPCTSTR lpszTooltip); /** * @brief * Gets the tooltip of the navigation button. * @details * The tooltip is the text displayed when * the mouse is positioned over the navigation button. * @return * The tooltip of the navigation button. * @see * SetTooltip */ CString GetTooltip() const; /** * @brief * Draws a symbol in the navigation button * (i.e. either "left", "right" or "x"). * @param pDC Pointer to a valid device context. * @param rc Bounding rectangle of the navigation button. * @param clr Button color. * @param bEnabled TRUE if the button is enabled. * @details * This method must be overridden in derived classes. */ virtual void DrawEntry(CDC* pDC, CRect rc, COLORREF clr, BOOL bEnabled) = 0; /** * @brief * This method is called when a navigation button is clicked. * @param bTick If TRUE, then CXTPTabManager::OnNavigateButtonClick * will be called to pass in the identifier of * the navigation button that was clicked. */ virtual void OnExecute(BOOL bTick); protected: UINT m_nID; /**< ID of the navigation button. */ XTPTabNavigateButtonFlags m_dwFlags; /**< Flag that indicates when the navigation button will be drawn. */ CXTPTabManager* m_pManager; /**< Pointer to the tab manager the navigation buttons are drawn on. */ CRect m_rcButton; /**< Bounding rectangle of the navigation button. */ BOOL m_bEnabled; /**< TRUE if the navigation button is enabled. */ BOOL m_bPressed; /**< TRUE if the navigation button is pressed/clicked. */ CString m_strToolTip; /**< Tooltip for the button. */ CXTPTabManagerItem* m_pItem; /**< Owner item. NULL if common. */ private: friend class CXTPTabManager; friend class CXTPTabManagerNavigateButtons; }; ////////////////////////////////////////////////////////////////////////// // CXTPTabManagerNavigateButton AFX_INLINE void CXTPTabManagerNavigateButton::SetFlags(XTPTabNavigateButtonFlags dwFlags) { m_dwFlags = dwFlags; } AFX_INLINE XTPTabNavigateButtonFlags CXTPTabManagerNavigateButton::GetFlags() const { return m_dwFlags; } AFX_INLINE BOOL CXTPTabManagerNavigateButton::IsEnabled() const { return m_bEnabled; } AFX_INLINE BOOL CXTPTabManagerNavigateButton::IsPressed() const { return m_bPressed; } AFX_INLINE CRect CXTPTabManagerNavigateButton::GetRect() const { return m_rcButton; } AFX_INLINE BOOL CXTPTabManagerNavigateButton::IsVisible() const { return !m_rcButton.IsRectEmpty(); } AFX_INLINE UINT CXTPTabManagerNavigateButton::GetID() const { return m_nID; } AFX_INLINE void CXTPTabManagerNavigateButton::SetTooltip(LPCTSTR lpszTooltip) { m_strToolTip = lpszTooltip; } AFX_INLINE CString CXTPTabManagerNavigateButton::GetTooltip() const { return m_strToolTip; } AFX_INLINE CXTPTabManagerItem* CXTPTabManagerNavigateButton::GetItem() const { return m_pItem; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPTABMANAGERNAVIGATEBUTTON_H__) /** @endcond */