/** * @file XTPTabManager.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(__XTPTABMANAGER_H__) # define __XTPTABMANAGER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPTabManagerNavigateButton; class CXTPTabManagerNavigateButtons; class CXTPTabManagerItem; class CXTPTabManagerAtom; class CXTPTabManager; class CXTPTabPaintManagerColorSet; class CXTPTabPaintManagerTheme; /** * @brief * The WM_XTP_GETTABCOLOR message is sent to an MDI child window to * retrieve the color that will be used for a tabbed interface with * enabled OneNote colors. * @details * You can override CXTPTabClientWnd::GetItemColor instead of * processing this message. * @return * The color that will be used for a tabbed interface with * enabled OneNote colors. * * Example: * Here is an example of how an application would process * the WM_XTP_GETTABCOLOR message: *
 * BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
 *     //{{AFX_MSG_MAP(CChildFrame)
 *     ON_MESSAGE(WM_XTP_GETTABCOLOR, OnGetTabColor)
 *     //}}AFX_MSG_MAP
 * END_MESSAGE_MAP()
 *
 * LRESULT CChildFrame::OnGetTabColor(WPARAM, LPARAM)
 * {
 *     return CXTPTabPaintManager::GetOneNoteColor(xtpTabColorOrange);
 * }
 * 
* @see * CXTPTabPaintManager::GetOneNoteColor, CXTPTabClientWnd, WM_XTP_GETWINDOWTEXT, * WM_XTP_GETTABICON, WM_XTP_GETWINDOWTOOLTIP */ const UINT WM_XTP_GETTABCOLOR = (WM_USER + 9400 + 1); class CXTPTabPaintManager; class CXTPImageManagerIcon; class CXTPMarkupContext; class CXTPMarkupUIElement; /** * @brief * CXTPTabManager is the base class for docking pane tabs, * tab control tabs, and MDI client tabs. * @see * CXTPTabClientWnd, CXTPDockingPaneTabbedContainer, CXTPTabControl */ class _XTP_EXT_CLASS CXTPTabManager : public CXTPTabManagerAtom { protected: class CNavigateButtonArrow; class CNavigateButtonArrowLeft; class CNavigateButtonArrowRight; class CNavigateButtonClose; class CNavigateButtonTabClose; public: /** * @brief * Helper structure that contains the first and last item indices * of rows of the tab manager. */ struct ROW_ITEMS { int nFirstItem; /**< First item index of row. */ int nLastItem; /**< Last item index of row. */ }; protected: /** * @brief * Helper class used to collect the indices of rows for a multi-row tab manager. */ class CRowIndexer { public: /** * @brief * Constructs a CRowIndexer object. * @param pManager Pointer to the owner tab manager. */ CRowIndexer(CXTPTabManager* pManager); /** * @brief * Destroys a CRowIndexer object, handles cleanup and deallocation. */ ~CRowIndexer(); public: /** * @brief * Creates the array of indices for the multi-row tab manager. * @param nRowCount Total number of rows in the tab manager. * @return * A pointer to the array of indices of the multi-row tab manager. */ ROW_ITEMS* CreateIndexer(int nRowCount); /** * @brief * Gets the array of indices of the multi-row tab manager. * @return * A pointer to the array of indices of the multi-row tab manager. */ ROW_ITEMS* GetRowItems() const; private: ROW_ITEMS* m_pRowItems; int m_nRowCount; CXTPTabManager* m_pManager; friend class CXTPTabManager; }; public: /** * @brief * Constructs a CXTPTabManager object. */ CXTPTabManager(); /** * @brief * Destroys a CXTPTabManager object, handles cleanup and deallocation. */ virtual ~CXTPTabManager(); public: /** * @brief * Retrieves a tab item by its index. * @param nIndex Zero-based index of the tab item to retrieve. * @return * A pointer to the tab item if successful, otherwise FALSE. */ CXTPTabManagerItem* GetItem(int nIndex) const; /** * @brief * Deletes a tab item by its index. * @param nItem Zero-based index of the tab item to delete. * @return * Nonzero if successful, otherwise 0. */ BOOL DeleteItem(int nItem); /** * @brief * Deletes all tab items from the tab manager. */ void DeleteAllItems(); /** * @brief * Gets the number of tab items in the tab manager. * @return * The number of tab items in the tab manager. */ int GetItemCount() const; public: /** * @brief * Retrieves the caption text of a specified tab item. * @param pItem Pointer to the tab item with the caption text to retrieve. * @return * The caption text of the specified tab item. */ virtual CString GetItemCaption(const CXTPTabManagerItem* pItem) const; /** * @brief * Retrieves the icon of a specified tab item. * @param pItem Pointer to the tab item with the icon to retrieve. * @return * The icon of the specified tab item. */ virtual HICON GetItemIcon(const CXTPTabManagerItem* pItem) const; /** * @brief * Retrieves the tab button color of a specified tab item. * @param pItem Pointer to the tab item with the tab button color to retrieve. * @return * The tab button color of the specified tab item. * @see * CXTPTabManagerItem::SetColor, CXTPTabManagerItem::GetColor */ virtual COLORREF GetItemColor(const CXTPTabManagerItem* pItem) const; /** * @brief * Retrieves the tooltip of a specified tab item. * @param pItem Pointer to the tab item with the tooltip to retrieve. * @details * The tooltip is the text displayed when * the mouse is positioned over the tab button. * @return * The tooltip of the specified tab item. * @see * CXTPTabManagerItem::SetTooltip, CXTPTabManagerItem::GetTooltip */ virtual CString GetItemTooltip(const CXTPTabManagerItem* pItem) const; /** * @brief * This method is called when tab items are changed * (i.e. after a tab item is added, deleted, or reordered). * @details * This method will recalculate the index for all tab items * and then call Reposition. * @see * CXTPTabManager::AddItem, CXTPTabManager::ReOrder, * CXTPTabManager::DeleteItem, CXTPTabManager::DeleteAllItems */ virtual void OnItemsChanged(); public: /** * @brief * Sets the index for the currently selected tab item within * the collection of tab items. * @param nIndex Index to be set. * @details * The currently selected tab item is the currently active tab item. * A tab item is selected when it has focus or is clicked. * * This method calls GetItem to retrieve a pointer to the tab item at * the specified index and then SetSelectedItem to select that tab item. * @see * CXTPTabManagerItem, GetCurSel, SetSelectedItem, GetSelectedItem */ void SetCurSel(int nIndex); /** * @brief * Gets the index of the currently selected tab item within * the collection of tab items. * @details * The currently selected tab item is the currently active tab item. * A tab item is selected when it has focus or is clicked. * * The currently selected tab item can be retrieved by using * GetSelectedItem. * @return * The index of the currently selected tab item. * @see * CXTPTabManagerItem, SetSelectedItem, SetCurSel, GetSelectedItem */ int GetCurSel() const; /** * @brief * Sets the currently selected tab item. * @param pItem Pointer to the tab item to be selected. * @details * The currently selected tab item is the currently active tab item. * A tab item is selected when it has focus or is clicked. * * The currently selected tab item can be set by its index within * the collection of tab items by using SetCurSel. * @see * CXTPTabManagerItem, GetCurSel, SetCurSel, GetSelectedItem */ virtual void SetSelectedItem(CXTPTabManagerItem* pItem); /** * @brief * Sets the focused tab item. * @param pItem Pointer to the tab item to be focused. * @see * SetSelectedItem */ virtual void SetFocusedItem(CXTPTabManagerItem* pItem); /** * @brief * Gets the currently selected tab item. * @details * The currently selected tab item is the currently active tab item. * A tab item is selected when it has focus or is clicked. * @return * A pointer to the currently selected tab item. * @see * CXTPTabManagerItem, SetSelectedItem, SetCurSel, GetCurSel */ CXTPTabManagerItem* GetSelectedItem() const; /** * @brief * Determines which tab is at a specified point, if any. * @param point Point to be tested. * @return * A pointer to the tab at the specified point, if any, * otherwise NULL. * @details * This method can be used to determine if the user clicked on a tab. * * In order for a pointer to the tab at the specified point to * be returned, the tab must be both visible and enabled. If the tab * is not both visible and enabled, then NULL will be returned. * @see * PerformClick, PerformMouseMove */ CXTPTabManagerItem* HitTest(CPoint point) const; /** * @brief * Determines which navigation button is at a specified point, if any. * @param point Point to be tested. * @param pnIndex Pointer to an integer to receive the index of * the navigation button at the specified point, if any. * @param bHeaderOnly TRUE to only test buttons located in the header, * FALSE to test all buttons. * @return * A pointer to the navigation button at the specified point, if any, * otherwise NULL. * @see * HitTest */ CXTPTabManagerNavigateButton* HitTestNavigateButton(CPoint point, BOOL bHeaderOnly, int* pnIndex = NULL) const; /** * @brief * Gets the minimum, maximum, and normal lengths of tab buttons. * @param szNormal Pointer to a CSize object to receive the fixed length used * for all tabs when the layout is xtpTabLayoutFixed. * @param szMin Pointer to a CSize object to receive the minimum length used * for tabs when the layout is not xtpTabLayoutFixed. * @param szMax Pointer to a CSize object to receive the maximum length used * for tabs when the layout is not xtpTabLayoutFixed. * @details * The minimum, maximum, and normal lengths of tab buttons are used * when calculating the lengths of tabs for each XTPTabLayoutStyle. * * szNormal only applies when the layout is xtpTabLayoutFixed. When * the layout is xtpTabLayoutFixed, every tab will have a fixed length of * szNormal. Otherwise, szMin and szMax represent the lower and upper * bounds for the length of individual tabs respectively. * @see * XTPTabLayoutStyle, SetItemMetrics, SetLayoutStyle */ virtual void GetItemMetrics(CSize* szNormal, CSize* szMin = NULL, CSize* szMax = NULL) const; /** * @brief * Sets the minimum, maximum, and normal lengths for tab buttons. * @param szNormal Fixed length to be used for all tabs when * the layout is xtpTabLayoutFixed. * @param szMin Minimum length to be used for tabs when * the layout is not xtpTabLayoutFixed. * @param szMax Maximum length to be used for tabs when * the layout is not xtpTabLayoutFixed. * @details * The minimum, maximum, and normal lengths of tab buttons are used * when calculating the lengths of tabs for each XTPTabLayoutStyle. * * szNormal only applies when the layout is xtpTabLayoutFixed. When * the layout is xtpTabLayoutFixed, every tab will have a fixed length of * szNormal. Otherwise, szMin and szMax represent the lower and upper * bounds for the length of individual tabs respectively. * @see * XTPTabLayoutStyle, GetItemMetrics, SetLayoutStyle */ void SetItemMetrics(CSize szNormal, CSize szMin = CSize(0, 0), CSize szMax = CSize(0, 0)); /** * @brief * Sets the position of a specified tab item. * @param pItem Pointer to the tab item whose position must be set. * @param nIndex Position to be set. */ void MoveItem(CXTPTabManagerItem* pItem, int nIndex); /** * @brief * Call this member to show close button for each tab * @param bCloseItemButton XTPTabNavigateButtonFlags that specify if close button for each tab * is visible */ void ShowCloseItemButton( XTPTabNavigateButtonFlags bCloseItemButton = xtpTabNavigateButtonAlways); public: /** * @brief * Gets the total width of all of the tab buttons. * @return * The total width of all of the tab buttons. * @details * The width may change depending on both * the tab layout and the position of the tabs. * @see * XTPTabLayoutStyle, XTPTabPosition */ virtual int GetItemsLength() const; /** * @brief * Gets the length of the bounding rectangle of * the tab client header area. * @param rc Bounding rectangle of tab client header area. * @return * If tabs are horizontal, then the width of * the tab client header area is returned. * If tabs are vertical, then the height of * the tab client header area is returned. * @details * The tab client header area is the area that * has all of the tab buttons. * @see * GetAppearanceSet, CXTPTabPaintManagerTheme::GetHeaderRect */ int GetRectLength(CRect rc) const; /** * @brief * Retrieves a specified tab navigation button (i.e. either the * left arrow, right arrow, or close button in the tab header area). * @param nID Identifier of the button to retrieve. * Can be one of the values listed in the Remarks section. * @details * Standard IDs of buttons are listed below: * xtpTabNavigateButtonLeft: Left tab navigation button. * xtpTabNavigateButtonRight: Right tab navigation button. * xtpTabNavigateButtonClose: Close tab navigation button. * @return * A pointer to the specified tab navigation button. * @see * XTPTabNavigateButton */ CXTPTabManagerNavigateButton* FindNavigateButton(UINT nID) const; /** * @brief * Determines if the tabs are positioned horizontally. * @return * TRUE if the tabs are positioned horizontally (i.e. top or bottom), * FALSE if the tabs are positioned vertically (i.e. left or right). * @see * GetPosition, XTPTabPosition */ BOOL IsHorizontalPosition() const; /** * @brief * Gets the scroll offset of the tabs in the tab header. * @return * The scroll offset of the tabs in the tab header. * @details * The scroll offset is how much the tabs have been scrolled by * pressing the left and right tab navigation buttons. * * The scroll offset starts at zero and remains at zero until * there are enough tabs to scroll. If the tabs are scrolled, then * the offset will be a negative number indicating how much * the tabs have been scrolled to the right. * * NOTE: GetHeaderOffset and SetHeaderOffset are used when the * left and right tab navigate buttons are pressed to scroll * the tabs by 20 pixels to the left or right. * * EnsureVisible uses GetHeaderOffset and SetHeaderOffset to * ensure that a tab button is visible. * * Example: * This sample illustrates how to programmatically set the scroll offset * of the tabs in the tab header of the CXTPTabClientWnd: *
	 * //Scroll the tabs in the tab header to the right by 100 pixels.
	 * m_MTIClientWnd.GetWorkspace(0)->SetHeaderOffset((m_MTIClientWnd.GetWorkspace(0)->GetHeaderOffset())
	 * - 100);
	 *
	 * //Scroll the tabs in the tab header to the left by 100 pixels.//
	 * m_MTIClientWnd.GetWorkspace(0)->SetHeaderOffset((m_MTIClientWnd.GetWorkspace(0)->GetHeaderOffset())
	 * + 100);
	 * 
* @see * SetHeaderOffset, CXTPTabManagerNavigateButton, EnsureVisible */ int GetHeaderOffset() const; /** * @brief * Sets the scroll offset for the tabs in the tab header. * @param nOffset Scroll offset to be set. The value of this parameter * must be \<= 0. GetHeaderOffset should be used to get * the current scroll offset and then add to or subtract * from the current scroll offset to move left or right. * If the value of this parameter is set to 0, then the * tabs will be reset to there starting position. * @details * The scroll offset is how much the tabs have been scrolled by * pressing the left and right tab navigation buttons. * * The scroll offset starts at zero and remains at zero until * there are enough tabs to scroll. If the tabs are scrolled, then * the offset will be a negative number indicating how much * the tabs have been scrolled to the right. * * NOTE: GetHeaderOffset and SetHeaderOffset are used when the * left and right tab navigate buttons are pressed to scroll * the tabs by 20 pixels to the left or right. * * EnsureVisible uses GetHeaderOffset and SetHeaderOffset to * ensure that a tab button is visible. * * Example: * This sample illustrates how to programmatically set the scroll offset * of the tabs in the tab header of the CXTPTabClientWnd: *
	 * //Scroll the tabs in the tab header to the right by 100 pixels.
	 * m_MTIClientWnd.GetWorkspace(0)->SetHeaderOffset((m_MTIClientWnd.GetWorkspace(0)->GetHeaderOffset())
	 * - 100);
	 *
	 * //Scroll the tabs in the tab header to the left by 100 pixels.//
	 * m_MTIClientWnd.GetWorkspace(0)->SetHeaderOffset((m_MTIClientWnd.GetWorkspace(0)->GetHeaderOffset())
	 * + 100);
	 * 
* @see * GetHeaderOffset, CXTPTabManagerNavigateButton, EnsureVisible */ void SetHeaderOffset(int nOffset); /** * @brief * Ensures that a specified tab is visible. * @param pItem Pointer to the tab to ensure the visibility of. * @see * SetHeaderOffset, GetHeaderOffset */ void EnsureVisible(CXTPTabManagerItem* pItem); public: /** * @brief * Gets the tab paint manager. * @details * The tab paint manager is used to customize the appearance of * both CXTPTabManagerItem objects and the tab manager * (i.e. tab colors, styles, etc.). * * This method must be overridden in derived classes. * @return * A pointer to the tab paint manager. */ virtual CXTPTabPaintManager* GetPaintManager() const = 0; /** * @brief * Sets the tab paint manager. * @param pPaintManager Pointer to the tab paint manager to be set. * @details * The tab paint manager is used to customize the appearance of * both CXTPTabManagerItem objects and the tab manager * (i.e. tab colors, styles, etc.). */ virtual void SetPaintManager(CXTPTabPaintManager* pPaintManager); /** * @brief * This method is called when the visual properties of the tabs * are changed (e.g. color, mouse-over, on-click). * @param lpRect Rectangular area of the window that is invalid. * @param bAnimate TRUE to animate changes in the bounding rectangle. * @details * This method must be overridden in derived classes. */ virtual void RedrawControl(LPCRECT lpRect, BOOL bAnimate) = 0; /** * @brief * Determines if tabs are allowed to be reordered. * @return * TRUE if tabs are allowed to be reordered, * FALSE if tabs are not allowed to be reordered. * @see * SetAllowReorder */ virtual BOOL IsAllowReorder() const; /** * @brief * Specifies if tabs should be allowed to be reordered. * @param bAllowReorder TRUE to allow tabs to be reordered, * FALSE to disallow tabs from being reordered. * @see * IsAllowReorder */ virtual void SetAllowReorder(BOOL bAllowReorder); /** * @brief * Determines if a static frame is used. * @return * TRUE if a static frame is used, otherwise FALSE. * @details * If a static frame is used, then it will be drawn around * the entire tab manager control * (i.e. around both the tab header and the tab client). * @see * CXTPTabPaintManager::m_bStaticFrame */ virtual BOOL IsDrawStaticFrame() const; /** * @brief * This method is called when the icon of a tab must * be redrawn (e.g. on mouse-over). * @param pDC Pointer to the destination device context. * @param pt Point that specifies the location of the image. * @param pItem Pointer to a CXTPTabManagerItem object to draw the icon on. * @param bDraw TRUE if the icon must be drawn/redrawn * (i.e. the icon size changed), FALSE otherwise. * @param szIcon Reference to the size of the tab icon. * @details * This method is overridden by its descendants. * * This method must be overridden in derived classes. * @return * TRUE if the icon was drawn successfully, otherwise FALSE. */ virtual BOOL DrawIcon(CDC* pDC, CPoint pt, CXTPTabManagerItem* pItem, BOOL bDraw, CSize& szIcon) const = 0; /** * @brief * Enables/disables Windows XP themed back color. * @param hWnd Window handle of the target object or dialog. * @param bEnable TRUE to enable Windows XP themed back color, * FALSE to disable Windows XP themed back color. * @details * This method should only be used when the tab color * is set to xtpTabColorWinNative. * * Example: * This sample code illustrates how to apply a * Windows XP themed back color to a tab control: *
	 * m_wndTabControl.GetPaintManager()->SetColor(xtpTabColorWinNative);
	 * XTPTabColorStyle color = m_wndTabControl.GetPaintManager()->GetColor();
	 * m_wndTabControl.EnableTabThemeTexture(m_wndTabControl.GetSafeHwnd(), color ==
	 * xtpTabColorWinNative ? TRUE : FALSE); RedrawWindow();
	 * 
* @see * XTPTabColorStyle, GetColor, SetColor */ void EnableTabThemeTexture(HWND hWnd, BOOL bEnable = TRUE); public: /** * @brief * Applies one of the "built-in" color sets for the tabs. * @param tabColor "Built-in" color set to be applied. * Can be one of the values listed in the Remarks section. * @details * Use SetColor to apply a "built-in" color set. * Use SetColorSet to apply a custom color set. * * Color sets are used to colorize the tabs. For example, applying * the xtpTabColorWinNative color set will give the tabs a Windows XP colorization. * * tabColor can be one of the following: * xtpTabColorDefault: Tabs will use the default color * style for the currently set Appearance. * xtpTabColorVisualStudio2003: Tabs will use the Visual Studio color * style for the currently set Appearance. * xtpTabColorOffice2003: Tabs will use the Office 2003 color * style for the currently set Appearance. * xtpTabColorWinNative: Tabs will use the Windows XP color * style for the currently set Appearance. * xtpTabColorVisualStudio2005: Tabs will use the Visual Studio 2005 color * style for the currently set Appearance. * @return * A pointer to the newly applied "built-in" color set. * @see * XTPTabColorStyle, SetColorSet, GetColor, GetColorSet, XTPTabAppearanceStyle, * SetAppearanceSet, SetAppearance, GetAppearance, GetAppearanceSet */ CXTPTabPaintManagerColorSet* SetColor(XTPTabColorStyle tabColor); /** * @brief * Applies a custom color set for the tabs. * @param pColorSet Pointer to the custom color set to be applied. * @return * A pointer to the newly applied custom color set. * @details * Use SetColor to apply a "built-in" color set. * Use SetColorSet to apply a custom color set. * * Color sets are used to colorize the tabs. For example, applying * the xtpTabColorWinNative color set will give the tabs a Windows XP colorization. * @see * XTPTabColorStyle, SetColor, GetColor, GetColorSet, XTPTabAppearanceStyle, * SetAppearanceSet, SetAppearance, GetAppearance, GetAppearanceSet */ CXTPTabPaintManagerColorSet* SetColorSet(CXTPTabPaintManagerColorSet* pColorSet); /** * @brief * Applies one of the "built-in" appearance sets for the tabs. * @param tabAppearance "Built-in" appearance set to be applied; must be one of * the values defined by the XTPTabAppearanceStyle enumeration. * @return * A pointer to the newly applied "built-in" appearance set. * @details * Use SetAppearance to apply a "built-in" appearance. * Use SetAppearanceSet to apply a custom appearance. * * An appearance set specifies how tabs will look. This is * the actual physical structure of the tab buttons. For example, * tab buttons with an Excel appearance set will have a half-hexagon shape. * @see * XTPTabAppearanceStyle, SetAppearanceSet, GetAppearance, GetAppearanceSet, * SetColor, GetColor, GetColorSet, SetColorSet */ CXTPTabPaintManagerTheme* SetAppearance(XTPTabAppearanceStyle tabAppearance); /** * @brief * Applies a custom appearance set for the tabs. * @param pAppearanceSet Pointer to the custom appearance set to be applied. * @details * Use SetAppearance to apply a "built-in" appearance. * Use SetAppearanceSet to apply a custom appearance. * * An appearance set specifies how tabs will look. This is * the actual physical structure of the tab buttons. For example, * tab buttons with an Excel appearance set will have a half-hexagon shape. * * SetColorSet is used to set custom colors. * * See the GUI_Eclipse sample for an example of how to create * a custom appearance set and apply it for the tabs. * @return * A pointer to the newly applied custom appearance set. * @see * XTPTabAppearanceStyle, SetAppearance, GetAppearance, GetAppearanceSet, * SetColor, GetColor, GetColorSet, SetColorSet */ CXTPTabPaintManagerTheme* SetAppearanceSet(CXTPTabPaintManagerTheme* pAppearanceSet); /** * @brief * Gets the currently applied custom appearance set. * @return * A pointer to the currently applied custom appearance set. * @details * An appearance set specifies how tabs will look. This is * the actual physical structure of the tab buttons. For example, * tab buttons with an Excel appearance set will have a half-hexagon shape. * * SetColorSet is used to set custom colors. * * See the GUI_Eclipse sample for an example of how to create * a custom appearance set and apply it for the tabs. * @see * GetAppearanceSet, SetAppearanceSet, SetAppearance */ CXTPTabPaintManagerTheme* GetAppearanceSet() const; /** * @brief * Gets the currently applied custom color set. * @return * A pointer to the currently applied custom color set. * @details * Color sets are used to colorize the tabs. For example, applying * the xtpTabColorWinNative color set will give the tabs a Windows XP colorization. * @see * XTPTabColorStyle, GetColor, SetColorSet, SetColor */ CXTPTabPaintManagerColorSet* GetColorSet() const; /** * @brief * Gets the currently applied "built-in appearance set. * @return * The currently applied "built-in" appearance set; one of * the values defined by the XTPTabAppearanceStyle enumeration. * @details * An appearance set specifies how tabs will look. This is * the actual physical structure of the tab buttons. For example, * tab buttons with an Excel appearance set will have a half-hexagon shape. * @see * XTPTabAppearanceStyle, GetAppearanceSet, SetAppearanceSet, SetAppearance */ XTPTabAppearanceStyle GetAppearance() const; /** * @brief * Gets the currently applied "built-in" color set. * @return * The currently applied "built-in" color set. * @details * Color sets are used to colorize the tabs. For example, applying * the xtpTabColorWinNative color set will give the tabs a Windows XP colorization. * @see * XTPTabColorStyle, SetColor, GetColorSet, SetColorSet */ XTPTabColorStyle GetColor() const; /** * @brief * Sets the tab position. * @param tabPosition Tab position to be set. * Can be one of the values listed in the Remarks section. * @details * The tab position refers to where the tab buttons are located. * The tab buttons can be positioned on either the top, bottom, * left, or right side of the tab client area. * * tabPosition can be one of the following: * xtpTabPositionTop: Tabs will be drawn on the top. * xtpTabPositionLeft: Tabs will be drawn on the left. * xtpTabPositionBottom: Tabs will be drawn on the bottom. * xtpTabPositionRight: Tabs will be drawn on the right. * @see * XTPTabPosition, GetPosition */ void SetPosition(XTPTabPosition tabPosition); /** * @brief * Sets the tab layout style. * @param tabLayout Tab layout style to be set. * Can be one of the values listed in the Remarks section. * @details * The tab layout style refers to how the tab buttons are sized * within the tab client header. The tab buttons can be in either * a compressed, fixed, auto-size, or size-to-fit layout. * * tabLayout can be one of the following: * xtpTabLayoutAutoSize: Tabs will be automatically sized based on * the caption and image size. With this flag set, * tabs will appear in their normal size. * xtpTabLayoutSizeToFit: Tabs are sized to fit within the tab panel. * All tabs will be compressed and forced to fit * into the tab panel. * xtpTabLayoutFixed: All tabs will be set to a fixed size within * the tab panel. * xtpTabLayoutCompressed: Tabs will be compressed within the tab panel. * This will compress the size of the tabs, but * all tabs will not be forced into the tab panel. * xtpTabLayoutMultiRow: Causes a tab control to display multiple * rows of tabs. * @see * XTPTabLayoutStyle, GetLayout */ void SetLayoutStyle(XTPTabLayoutStyle tabLayout); /** * @brief * Gets the tab position. * @return * The tab position; one of the values defined by * the XTPTabPosition enumeration. * @details * The tab position refers to where the tab buttons are located. * The tab buttons can be positioned on either the top, bottom, * left, or right side of the tab client area. * @see * XTPTabPosition, SetPosition */ virtual XTPTabPosition GetPosition() const; /** * @brief * Gets the tab layout style. * @return * The tab layout style; one of the values defined by * the XTPTabLayoutStyle enumeration. * @details * The tab layout style refers to how the tab buttons are sized * within the tab client header. The tab buttons can be in either * a compressed, fixed, auto-size, or size-to-fit layout. * @see * XTPTabLayoutStyle, SetLayoutStyle */ XTPTabLayoutStyle GetLayout() const; /** * @brief * Shows/hides tab icons. * @param bShowIcons TRUE to show tab icons, FALSE to hide tab icons. */ void ShowIcons(BOOL bShowIcons); /** * @brief * Specifies if this tab group should be active/inactive. * @param bActive TRUE to set this tab group to active, * FALSE to set this tab group to 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. * * When grouping is enabled, each tab group has its own CXTPTabManager. * * SetActive is used to activate/set focus to the tab group. * * Only one tab group can be active at a given time. * @see * IsActive, CXTPTabClientWnd::Attach */ void SetActive(BOOL bActive); /** * @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. * * When grouping is enabled, each tab group has its own CXTPTabManager. * * SetActive is used to activate/set focus to the tab group. * * Only one tab group can be active at a given time. * @see * SetActive, CXTPTabClientWnd::Attach */ BOOL IsActive() const; /** * @brief * Gets the bounding rectangle of the tab manager control area. * @return * The bounding rectangle of the tab manager control area. * @see * GetHeaderRect, GetClientRect */ CRect GetControlRect() const; /** * @brief * Gets the bounding rectangle of the tab client area. * @return * The bounding rectangle of the tab client area. * @see * GetHeaderRect, GetControlRect */ CRect GetClientRect() const; /** * @brief * Gets the bounding rectangle of the tab client header area. * @return * The bounding rectangle of the tab client header area. * @see * GetClientRect, GetControlRect */ CRect GetHeaderRect() const; /** * @brief * Gets the number of rows of tabs in the tab control. * @return * The number of rows of tabs in the tab control. * @details * Only tab controls which have the xtpTabLayoutMultiRow layout * can have multiple rows of tabs. * @see * SetLayoutStyle, CXTPTabManagerItem::GetItemRow */ int GetRowCount() const; /** * @brief * This method is called when the user presses either * the left or right navigation buttons. * @param bRight TRUE to scroll right, FALSE to scroll left. */ virtual void OnScrollHeader(BOOL bRight); /** * @brief * Gets the collection of navigation buttons. * @return * A pointer to the collection of navigation buttons. * @see * CXTPTabManagerNavigateButtons, CXTPTabManagerNavigateButton */ CXTPTabManagerNavigateButtons* GetNavigateButtons(); /** * @brief * Retrieves the next/previous focusable tab item from * a specified index. * @param nIndex Index to begin search. * @param nDirection Direction to search in (+1 for next, -1 for previous). * @return * A pointer to the next/previous focusable tab item from * the specified index. * @details * A tab item is focusable if it is both visible and enabled. * @see * CXTPTabManagerItem */ CXTPTabManagerItem* FindNextFocusable(int nIndex, int nDirection) const; public: /** * @brief * This method is called when the mouse cursor moves. * @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 * When the mouse cursor is moved across a tab while hot tracking is enabled, * PerformMouseMove will highlight and un-highlight the tabs and then call * CXTPTabManagerNavigateButton::PerformMouseMove for each tab navigation button. * * When the mouse cursor is moved across a tab navigation button, * CXTPTabManagerNavigateButton::PerformMouseMove will be called to perform * actions related to the mouse movement over the tab navigation buttons. * This will highlight and un-highlight the tab navigation buttons. * @see * CXTPTabManagerNavigateButton::PerformMouseMove */ void PerformMouseMove(HWND hWnd, CPoint pt); /** * @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. * @param bNoItemClick TRUE to only test tab navigation buttons * to determine if they were clicked, * FALSE to test both tabs and tab navigation buttons * to determine if they were clicked. * @details * When the user clicks on a tab navigation button, this method will * call the CXTPTabManagerNavigateButton::PerformClick member * of the tab navigation button that was clicked. * * When the user clicks on a tab, OnItemClick will be called to * select the tab. * * If IsAllowReorder is TRUE, then ReOrder will be called before * OnItemClick. ReOrder will check if the tab is being moved and, if * it is being moved, keep the tab selected so OnItemClick is not * called. If the tab is not being moved, then OnItemClick will be called. * @return * If bNoItemClick is TRUE, then this method will return either * TRUE if a tab navigation button was clicked or * FALSE if a tab navigation button was not clicked. * * If bNoItemClick is FALSE, then this method will return either * TRUE if a tab or tab navigation button was clicked or * FALSE if a tab or tab navigation button was not clicked. * @see * OnItemClick, ReOrder, CXTPTabManager::OnNavigateButtonClick */ BOOL PerformClick(HWND hWnd, CPoint pt, BOOL bNoItemClick = FALSE); /** * @brief * Determines which tab is beneath the mouse cursor, if any, and * stores the tooltip information of the tab within a TOOLINFO structure. * @param hWnd Handle to the window that contains the tab. * @param point Specifies the x- and y- coordinates of the mouse cursor. * @param pTI Pointer to a TOOLINFO structure to receive the tooltip information * of the tab beneath the mouse cursor, if any. * @return * The identifier of the tab beneath the mouse cursor, if any, * if a tooltip was found, otherwise a value of -1. * @details * This member is called in the CXTPTabControl::OnToolHitTest, * CXTPDockingPaneTabbedContainer::OnToolHitTest, and * CXTPTabClientWnd::OnToolHitTest members. */ virtual INT_PTR PerformToolHitTest(HWND hWnd, CPoint point, TOOLINFO* pTI) const; /** * @brief * This method is called to process a WM_KEYDOWN event for * the tab manager. * @param hWnd Handle to the window that contains the tab. * @param nChar Specifies the virtual-key code of the given key. * @return * TRUE if the key was processed successfully, otherwise FALSE. */ virtual BOOL PerformKeyDown(HWND hWnd, UINT nChar); /** * @brief * Draws the parent background under the tab control. * @param pDC Pointer to valid device context. * @param rc Bounding rectangle. * @return * TRUE if the rectangle was filled. */ virtual BOOL DrawParentBackground(CDC* pDC, CRect rc); public: /** * @brief * Gets the total number of tab navigation buttons within * the collection of tab navigation buttons. * @return * The total number of tab navigation buttons within * the collection of tab navigation buttons. * @see * GetNavigateButton, CXTPTabManagerNavigateButton, OnNavigateButtonClick */ int GetNavigateButtonCount() const; /** * @brief * Retrieves the tab navigation button at a specified index within * the collection of tab navigation buttons. * @param nIndex Zero-based index of the tab navigation button to retrieve. * @return * A pointer to the tab navigation button at the specified index within * the collection of tab navigation buttons. * @see * GetNavigateButtonCount, CXTPTabManagerNavigateButton, OnNavigateButtonClick */ CXTPTabManagerNavigateButton* GetNavigateButton(int nIndex) const; public: /** * @brief * Enables/disables markup for the tab captions. * @param bEnable TRUE to enable markup for the tab captions, * FALSE to disable markup for the tab captions. */ void EnableMarkup(BOOL bEnable = TRUE); /** * @brief * Gets the markup context. * @return * A pointer to the markup context. */ virtual CXTPMarkupContext* GetMarkupContext() const; protected: /** * @brief * Determines if a specified tab navigation button is automatically displayed. * @param pButton Pointer to the tab navigation button to check. * @return * TRUE if the specified tab navigation button is automatically displayed, * otherwise FALSE. * @see * XTPTabNavigateButtonFlags */ virtual BOOL IsNavigateButtonAutomaticVisible(CXTPTabManagerNavigateButton* pButton); /** * @brief * Determines if a specified tab navigation button is visible. * @param pButton Pointer to the tab navigation button to check. * @return * TRUE if the specified tab navigation button is visible, otherwise FALSE. */ virtual BOOL IsNavigateButtonVisible(CXTPTabManagerNavigateButton* pButton); /** * @brief * This method is called when a tab button is clicked * to select the tab item that was clicked. * @param pItem Pointer to the tab item that was clicked. * @see * PerformClick */ virtual void OnItemClick(CXTPTabManagerItem* pItem); /** * @brief * This method is called before a tab item is clicked. * @param pItem Pointer to the tab item that is about * to be clicked. * @return * TRUE to cancel the process. */ virtual BOOL OnBeforeItemClick(CXTPTabManagerItem* pItem); /** * @brief * This method is called when a tab item is clicked and dragged * within the tab header. * @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. * @param pItem Pointer to the tab item that is about * to be clicked and dragged. * @details * This method will reorder the selected tab item to * the location that it is dragged to. * @see * PerformClick */ virtual void ReOrder(HWND hWnd, CPoint pt, CXTPTabManagerItem* pItem); /** * @brief * This method is called by ReOrder when two tab items are switched. * @param pItem1 Pointer to the tab item dragged by the user. * @param pItem2 Pointer to the other tab item that was switched. */ virtual void OnSwitchItem(CXTPTabManagerItem* pItem1, CXTPTabManagerItem* pItem2); /** * @brief * This method is called by ReOrder when a tab item's position is changed. * @param pItem Pointer to the tab item dragged by the user. * @param nOldIndex Old item position. * @param nNewIndex New item position. */ virtual void OnItemOrderChanged(CXTPTabManagerItem* pItem, int nOldIndex, int nNewIndex); /** * @brief * This method is called when a tab navigation button is clicked. * @param pButton Pointer to the tab navigation button that was clicked. * Can be one of the values listed in the Remarks section. * @details * Standard identifiers of buttons are listed below: * xtpTabNavigateButtonLeft: Left tab navigation button. * xtpTabNavigateButtonRight: Right tab navigation button. * xtpTabNavigateButtonClose: Close tab navigation button. * * This method is overridden in CXTPTabClientWnd::CWorkspace and CXTPTabControl * to capture when the tab navigation close "x" button * is pressed and deletes the tab. * * This member is called after CXTPTabManagerNavigateButton::PerformClick. * @see * CXTPTabManagerNavigateButton::PerformClick, XTPTabNavigateButton */ virtual void OnNavigateButtonClick(CXTPTabManagerNavigateButton* pButton); /** * @brief * This method is called when a tab navigation button is clicked. * @param nID Button identifier. * Can be one of the values listed in the Remarks section. * @details * Standard identifiers of buttons are listed below: * xtpTabNavigateButtonLeft: Left tab navigation button. * xtpTabNavigateButtonRight: Right tab navigation button. * xtpTabNavigateButtonClose: Close tab navigation button. * * This method is overridden in CXTPTabClientWnd::CWorkspace and CXTPTabControl * to capture when the tab navigation close "x" button * is pressed and deletes the tab. * * This member is called after CXTPTabManagerNavigateButton::PerformClick. * @see * CXTPTabManagerNavigateButton::PerformClick, XTPTabNavigateButton */ virtual void OnNavigateButtonClick(UINT nID); /** * @brief * Determines if the MouseMove event has been disabled. * @return * Always returns FALSE in the base class implementation. * @details * This method is overridden in CXTPTabClientWnd::CWorkspace. * * The MouseMove event is disabled when a command bar pop-up * becomes active/visible. * @see * CXTPTabClientWnd::CWorkspace::IsMouseLocked */ virtual BOOL IsMouseLocked() const; /** * @brief * Adds a specified tab item to the collection of tab items. * @param nItem Position in the collection of tab items to add * the specified tab item. If the value of * this parameter is less than 0 or greater than * the number of tab items in the collection, * then the specified tab item will be added to * the end of the collection. * @param pItem Pointer to the tab item to add, or NULL to * create and add a default tab item. * @return * A pointer to the newly added tab item. * @details * This method is overridden in derived classes to provide * additional functionality and then this base class method is called. */ CXTPTabManagerItem* AddItem(int nItem, CXTPTabManagerItem* pItem = NULL); /** * @brief * The implementation should return TRUE if * the header has focus or FALSE otherwise. * @return * TRUE if the header has focus, otherwise FALSE. */ virtual BOOL HeaderHasFocus() const; protected: /** * @brief * Activates and tracks a specified tab item on mouse click. * @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. * @param pItem Pointer to the tab item to activate and track. */ void TrackClick(HWND hWnd, CPoint pt, CXTPTabManagerItem* pItem); /** * @brief * This method is called when the handle of a tab item is changed. * @param pItem Pointer to the tab item whose handle was changed. * @param hwndOld Previous handle of the tab item. * @param hwndNew New handle of the tab item. */ virtual void OnItemHandleChanged(CXTPTabManagerItem* pItem, HWND hwndOld, HWND hwndNew); protected: CXTPTabManagerItem* m_pSelected; /**< Tab currently selected (i.e. when the tab is clicked). */ CXTPTabManagerItem* m_pHighlighted; /**< Tab currently highlighted (i.e. When the mouse cursor is over the tab button). */ CXTPTabManagerItem* m_pPressed; /**< Pointer to the currently pressed tab. */ CXTPTabManagerNavigateButton* m_pHighlightedNavigateButton; /**< Pointer to highlighted navigate button. */ int m_nHeaderOffset; /**< Scroll offset, this is how much the tabs in the tab header have been scrolled using the left and right tab navigation buttons. See: GetHeaderOffset, SetHeaderOffset. */ BOOL m_bAllowReorder; /**< TRUE to allow tabs to be reordered. */ BOOL m_bActive; /**< TRUE if the MDITabClient tab group is active. This only applies to a TabWorkspace when grouping is enabled. */ XTPTabNavigateButtonFlags m_bCloseItemButton; /**< TRUE to show the close button for tabs. */ CRect m_rcHeaderRect; /**< Bounding rectangle of the tab header area. */ CRect m_rcControl; /**< Bounding rectangle of the tab manager control. This is the bounding rectangle for both the tab header and tab client. */ CRect m_rcClient; /** Bounding rectangle of the tab client area. */ CArray m_arrItems; /**< Collection of tabs for this tab manager. */ CXTPTabManagerNavigateButtons m_arrNavigateButtons; /**< Collection of tab navigation buttons for this tab manager. */ CRowIndexer* m_pRowIndexer; /**< Row indexer. */ int m_nScrollDelta; /**< Scroll header delta. */ CXTPMarkupContext* m_pMarkupContext; /**< Markup context of the tab manager. */ private: friend class CXTPTabManagerItem; friend class CXTPTabPaintManager; friend class CXTPTabManagerNavigateButton; friend class CXTPTabClientWnd; }; ////////////////////////////////////////////////////////////////////////// // CXTPTabManager AFX_INLINE int CXTPTabManager::GetItemCount() const { return (int)m_arrItems.GetSize(); } AFX_INLINE CXTPTabManagerItem* CXTPTabManager::GetItem(int nIndex) const { return nIndex >= 0 && nIndex < GetItemCount() ? m_arrItems[nIndex] : NULL; } AFX_INLINE int CXTPTabManager::GetNavigateButtonCount() const { return (int)m_arrNavigateButtons.GetSize(); } AFX_INLINE CXTPTabManagerNavigateButton* CXTPTabManager::GetNavigateButton(int nIndex) const { return nIndex >= 0 && nIndex < GetNavigateButtonCount() ? m_arrNavigateButtons[nIndex] : NULL; } AFX_INLINE CXTPTabManagerItem* CXTPTabManager::GetSelectedItem() const { return m_pSelected; } AFX_INLINE BOOL CXTPTabManager::IsHorizontalPosition() const { return (GetPosition() == xtpTabPositionBottom || GetPosition() == xtpTabPositionTop); } AFX_INLINE int CXTPTabManager::GetRectLength(CRect rc) const { if (IsHorizontalPosition()) return rc.Width(); return rc.Height(); } AFX_INLINE int CXTPTabManager::GetHeaderOffset() const { return m_nHeaderOffset; } AFX_INLINE void CXTPTabManager::OnNavigateButtonClick(UINT) { } AFX_INLINE void CXTPTabManager::OnNavigateButtonClick(CXTPTabManagerNavigateButton* pButton) { OnNavigateButtonClick(pButton->GetID()); } AFX_INLINE BOOL CXTPTabManager::IsAllowReorder() const { return m_bAllowReorder; } AFX_INLINE void CXTPTabManager::SetAllowReorder(BOOL bAllowReorder) { m_bAllowReorder = bAllowReorder; } AFX_INLINE void CXTPTabManager::SetPaintManager(CXTPTabPaintManager* /*pPaintManager*/) { } AFX_INLINE BOOL CXTPTabManager::IsActive() const { return m_bActive; } AFX_INLINE CRect CXTPTabManager::GetControlRect() const { return m_rcControl; } AFX_INLINE CRect CXTPTabManager::GetClientRect() const { return m_rcClient; } AFX_INLINE CRect CXTPTabManager::GetHeaderRect() const { return m_rcHeaderRect; } AFX_INLINE BOOL CXTPTabManager::IsMouseLocked() const { return FALSE; } AFX_INLINE int CXTPTabManager::GetRowCount() const { return m_pRowIndexer->m_nRowCount; } AFX_INLINE BOOL CXTPTabManager::HeaderHasFocus() const { return FALSE; } AFX_INLINE BOOL CXTPTabManagerItem::IsFocused() const { return IsSelected() && m_pTabManager->HeaderHasFocus(); } AFX_INLINE CXTPMarkupUIElement* CXTPTabManagerItem::GetMarkupUIElement() const { return m_pMarkupUIElement; } AFX_INLINE CXTPTabManager::ROW_ITEMS* CXTPTabManager::CRowIndexer::GetRowItems() const { return m_pRowItems; } AFX_INLINE CXTPTabManagerNavigateButtons* CXTPTabManager::GetNavigateButtons() { return &m_arrNavigateButtons; } AFX_INLINE void CXTPTabManager::OnItemHandleChanged(CXTPTabManagerItem*, HWND, HWND) { } AFX_INLINE BOOL CXTPTabManager::DrawParentBackground(CDC* /*pDC*/, CRect /*rc*/) { return FALSE; } AFX_INLINE void CXTPTabManager::ShowCloseItemButton(XTPTabNavigateButtonFlags bCloseItemButton) { m_bCloseItemButton = bCloseItemButton; } AFX_INLINE CXTPMarkupContext* CXTPTabManager::GetMarkupContext() const { return m_pMarkupContext; } AFX_INLINE void CXTPTabManager::OnSwitchItem(CXTPTabManagerItem* /*pItem1*/, CXTPTabManagerItem* /*pItem2*/) { } AFX_INLINE void CXTPTabManager::OnItemOrderChanged(CXTPTabManagerItem* /*pItem*/, int /*nOldIndex*/, int /*nNewIndex*/) { } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPTABMANAGER_H__) /** @endcond */