/** * @file XTPTabControl.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(__XTPTABCONTROL_H__) # define __XTPTABCONTROL_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPTabPaintManager; class CXTPImageManager; class CXTPToolTipContext; /** * @brief * CXTPTabControl is used to draw an enhanced tab control with * Office 2003, Visual Studio, or Win XP tabs. * @see * Create, CXTPTabManager::SetColor, CXTPTabManager::SetAppearance */ class _XTP_EXT_CLASS CXTPTabControl : public CWnd , public CXTPTabManager { private: class CTabControlDropTarget; public: /** * @brief * Constructs a CXTPTabControl object. */ CXTPTabControl(); /** * @brief * Destroys a CXTPTabControl object, handles cleanup and deallocation. */ virtual ~CXTPTabControl(); public: /** * @brief * Inserts a tab at a specified index. * @param nItem Index of the new tab. * @param lpszItem Caption of the new tab. * @param hwndChild Handle of the object to be displayed in the tab * (e.g. a dialog page). * @param nImage Identifier of the image resource to display in * the tab if icons are displayed. * @param pAddItem Pointer to the item to insert, or NULL to * create and add a default item. * @return * A pointer to the newly inserted CXTPTabManagerItem object. */ CXTPTabManagerItem* InsertItem(int nItem, LPCTSTR lpszItem, HWND hwndChild = NULL, int nImage = -1, CXTPTabManagerItem* pAddItem = NULL); /** * @brief * Creates the tab control. * @param dwStyle Style of the tab control. * @param rect Reference to the size of the tab control. * @param pParentWnd Pointer to the parent of the tab control. * @param nID Identifier of the tab control. * @return * TRUE if successful, otherwise FALSE. * @see * CXTPTabControl::CXTPTabControl, GetPaintManager, CXTPTabManager::SetPosition, * CXTPTabManager::SetLayout, GetImageManager */ BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID); 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; /** * @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 * Recalculates the layout of the tab manager and then repositions itself. * @details * This method must be overridden in derived classes. */ virtual void Reposition(); /** * @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); /** * @brief * Selects a specified tab. * @param pItem Pointer to the tab to be selected. */ virtual void SetSelectedItem(CXTPTabManagerItem* pItem); /** * @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 */ void OnItemClick(CXTPTabManagerItem* pItem); /** * @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; /** * @brief * Sets the icons of the tabs. * @param pImageList Pointer to an image list containing the icons of the tabs. * @details * It is recommended to use both the GetImageManager and * CXTPImageManager::SetIcons methods to add icons. */ void SetImageList(CImageList* pImageList); /** * @brief * Gets the image manager containing the icons of the tabs. * @return * A pointer to the image manager containing the icons of the tabs. * * Example: *
m_wmdTabControl.GetImageManager()->SetIcons(IDR_MAINFRAME);*/ CXTPImageManager* GetImageManager() const; /** * @brief * Sets the image manager to contain the icons of the tabs. * @param pImageManager Pointer to the image manager to be set. */ void SetImageManager(CXTPImageManager* pImageManager); /** * @brief * Gets the tooltip context. * @return * A pointer to the tooltip context. */ CXTPToolTipContext* GetToolTipContext() const; /** * @brief * Sets the behaviour for tooltips. * @param behaviour Tooltips behaviour to be set. * See the Remarks section for available flags. * @details * The behaviour parameter can be one of the following: * xtpTabToolTipNever: Never show tooltips for tabs. * xtpTabToolTipAlways: Always show tooltips for tabs. * xtpTabToolTipShrinkedOnly: Only show tooltips if the tab was shrinked * (see xtpTabLayoutSizeToFit layout). */ void EnableToolTips(XTPTabToolTipBehaviour behaviour = xtpTabToolTipAlways); /** * @brief * This method will either calculate the window rectangle of a tab control * when provided with a display rectangle or vice versa. * @param bLarger Indicates which operation to perform. * If the value of this parameter is TRUE, then lpRect specifies * a display rectangle and receives the corresponding window rectangle. * If the value of this parameter is FALSE, then lpRect specifies * a window rectangle and receives the corresponding display rectangle. * @param lpRect Pointer to a RECT structure that contains the given rectangle * and receives the calculated rectangle. */ void AdjustRect(BOOL bLarger, LPRECT lpRect) const; public: /** * @brief * Locks/unlocks redrawing controls. * @param bLockRedraw TRUE to lock redrawing controls, * FALSE to unlock redrawing controls. * @details * The bLockRedraw parameter should be set to TRUE when you want * to add many items, but do not want CXTPTabControl::Reposition * to be called each time an item is added. */ void SetLockRedraw(BOOL bLockRedraw); /** * @brief * Sets the focused item. * @param pItem Pointer to the item to set. * @see * SetSelectedItem */ virtual void SetFocusedItem(CXTPTabManagerItem* pItem); protected: /** * @brief * This method is called when a tab navigation button is clicked. * @param pButton Pointer to the tab navigation button that was clicked. * @details * 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 */ void OnNavigateButtonClick(CXTPTabManagerNavigateButton* pButton); using CXTPTabManager::OnNavigateButtonClick; /** * @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: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPTabControl) virtual void PreSubclassWindow(); BOOL DrawParentBackground(CDC* pDC, CRect rc); virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPTabControl) afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnSysColorChange(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnMouseLeave(); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg UINT OnGetDlgCode(); afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM lParam); afx_msg void OnDestroy(); //}}AFX_MSG /** @endcond */ protected: /** @cond */ BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); /** @endcond */ private: HWND m_hwndClient; CXTPTabPaintManager* m_pPaintManager; CXTPImageManager* m_pImageManager; CTabControlDropTarget* m_pDropTarget; CXTPToolTipContext* m_pToolTipContext; int m_nLockRedraw; friend class CTabControlDropTarget; }; ////////////////////////////////////////////////////////////////////////// AFX_INLINE CXTPTabPaintManager* CXTPTabControl::GetPaintManager() const { return m_pPaintManager; } AFX_INLINE CXTPImageManager* CXTPTabControl::GetImageManager() const { return m_pImageManager; } AFX_INLINE BOOL CXTPTabControl::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 CXTPToolTipContext* CXTPTabControl::GetToolTipContext() const { return m_pToolTipContext; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPTABCONTROL_H__) /** @endcond */