/** * @file XTPTabToolBar.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(__XTPTABTOOLBAR_H__) && defined(_XTP_INCLUDE_TABMANAGER) # define __XTPTABTOOLBAR_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPTabToolBar is a CXTPToolBar derived class. It represents a tabbable toolbar. */ class _XTP_EXT_CLASS CXTPTabToolBar : public CXTPToolBar , public CXTPTabManager { private: /** @cond */ DECLARE_XTP_COMMANDBAR(CXTPTabToolBar) /** @endcond */ public: /** * @brief * Constructs a CXTPTabToolBar object. */ CXTPTabToolBar(); /** * @brief * Destroys a CXTPTabToolBar object, handles cleanup and deallocation. */ virtual ~CXTPTabToolBar(); public: /** * @brief * Call this method to add a new tab to CXTPTabToolBar. * @param nItem Index to insert category to. * @param lpszItem Caption of new tab. * @param pItems Control items. * @param nCount Control items count. * @param bLoadIcons TRUE to load icons. * @return * CXTPTabManagerItem class of new tab. */ CXTPTabManagerItem* InsertCategory(int nItem, LPCTSTR lpszItem, UINT* pItems, int nCount, BOOL bLoadIcons = TRUE); /** * @brief * Call this method to add a new tab to CXTPTabToolBar. * @param nItem Index to insert category to. * @param lpszItem Caption of new tab. * @param bLoadIcons TRUE to load icons. * @param nIDResource Toolbar resource identifier. * @return * CXTPTabManagerItem class of new tab. */ CXTPTabManagerItem* InsertCategory(int nItem, LPCTSTR lpszItem, UINT nIDResource, BOOL bLoadIcons = TRUE); /** * @brief * Call this method to refresh controls on the selected tab. * @param pItem Selected item. */ void UpdateTabs(CXTPTabManagerItem* pItem = NULL); /** * @brief * Call this member to get a pointer to the tab paint manager. * The tab paint manager is used to customize the appearance of * CXTPTabManagerItem objects and the tab manager (e.g. tab colors, * styles, etc.). * @details * This member must be overridden in derived classes. * @return * Pointer to CXTPTabPaintManager that contains the visual elements * of the tabs. */ virtual CXTPTabPaintManager* GetPaintManager() const; /** * @brief * Call this method to set the minimum available width of the toolbar. * @param nMinWidth Minimum width of the toolbar. */ void SetMinimumWidth(int nMinWidth); protected: /** * @brief * This method is called to update the position of TabManager. */ void Reposition(); /** * @brief * This member is called when the icon of the tab needs to be drawn. * @param pDC Pointer to the destination device context. * @param pt Specifies the location of the image. * @param pItem CXTPTabManagerItem object to draw icon on. * @param bDraw TRUE if the icon needs to be drawn (e.g. the icon size changed), * FALSE if the icon does not need to be drawn or redrawn. * @param szIcon Size of the tab icon. * @details * This member is overridden by its descendants. * This member must be overridden in derived classes. * @return * TRUE if the icon was successfully drawn, FALSE if the icon was not drawn. */ BOOL DrawIcon(CDC* pDC, CPoint pt, CXTPTabManagerItem* pItem, BOOL bDraw, CSize& szIcon) const; /** * @brief * This member is called when the visual properties of the tabs are * changed (e.g. color, mouse-over, and on-click). * @details * This member must be overridden in derived classes. * @param lpRect The rectangular area of the window that is invalid. * @param bAnimate TRUE to animate changes in the bounding rectangle. */ void RedrawControl(LPCRECT lpRect, BOOL bAnimate); /** * @brief * Call this member to select a CXTPTabManagerItem tab. A selected tab * is the currently active tab. * @param pItem CXTPTabManagerItem tab to select. * @details * This member will will select the specified CXTPTabManagerItem. * SetCurSel will set the current CXTPTabManagerItem by its index * within the collection of items. * A tab is selected when it has focus or is clicked. * @see * CXTPTabManagerItem, GetCurSel, SetCurSel, GetSelectedItem */ void SetSelectedItem(CXTPTabManagerItem* pItem); /** * @brief * This method is called before an item click. * @param pItem Pointer to the item that is about to be clicked. * @return * TRUE if the process was canceled, otherwise FALSE. */ BOOL OnBeforeItemClick(CXTPTabManagerItem* pItem); /** * @brief * This method retrieves the borders of the toolbar. * @return * A CRect object containing the borders of the toolbar. */ CRect GetBorders(); /** * @brief * This method is called to draw the command bar in the given context. * @param pDC Pointer to a valid device context. * @param rcClipBox The rectangular area of the control that is invalid. */ void DrawCommandBar(CDC* pDC, CRect rcClipBox); /** * @brief * This method calculates the dimensions of a toolbar. * @param nLength Length of the bar. * @param dwMode Mode to dock. * @param nWidth Width of the bar. * @return * Size of the docked toolbar. */ CSize CalcDockingLayout(int nLength, DWORD dwMode, int nWidth); /** * @brief * This method calculates the dimensions of a toolbar. * @param nLength The requested dimension of the control bar, either * horizontal or vertical, depending on dwMode. * @param dwMode Mode to dock. * @return * Size of the docked toolbar. */ CSize CalcDynamicLayout(int nLength, DWORD dwMode); /** * @brief * Resets the controls to their original state. * @param bShowWarningMessage TRUE to show warning message. */ void Reset(BOOL bShowWarningMessage); /** * @brief * This method is called when a control is dropped to the command bar. * @param pDataObject Pointer to a CXTPControl object. * @param dropEffect DROPEFFECT enumerator. * @param ptDrop Point where the user dropped the control. * @param ptDrag Point where the user started dragging the control. */ void OnCustomizeDrop(CXTPControl* pDataObject, DROPEFFECT& dropEffect, CPoint ptDrop, CPoint ptDrag); protected: void BeforeCustomizeControlAdd(CXTPControl* pControl); protected: # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ LPDISPATCH OleInsertCategory(int nIndex, LPCTSTR lpszTitle); long OleGetItemCount(); LPDISPATCH OleGetItem(int nIndex); void OleRemoveCategory(int nIndex); LPDISPATCH OleGetTabPaintManager(); void OleUpdateTabs(); DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPTabToolBar); DECLARE_INTERFACE_MAP() DECLARE_ENUM_VARIANT(CXTPTabToolBar); DECLARE_CONNECTION_EX(CXTPTabToolBar) /** @endcond */ # endif protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPTabToolBar) //}}AFX_VIRTUAL //{{AFX_MSG(CXTPTabToolBar) afx_msg void OnMouseLeave(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; afx_msg void OnSysColorChange(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); //}}AFX_MSG /** @endcond */ protected: CXTPTabPaintManager* m_pTabPaintManager; /**< Tab PaintManager. */ CRect m_rcTabControl; /**< Bounding rectangle of Tabs. */ int m_nMinWidth; /**< Minimum available width of toolbar. */ }; AFX_INLINE CXTPTabPaintManager* CXTPTabToolBar::GetPaintManager() const { return m_pTabPaintManager; } AFX_INLINE void CXTPTabToolBar::SetMinimumWidth(int nMinWidth) { m_nMinWidth = nMinWidth; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTPTABTOOLBAR_H__) /** @endcond */