/** * @file XTPGridTip.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(__XTPGRIDTIP_H__) # define __XTPGRIDTIP_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * The CXTPGridTip class encapsulates the functionality of * a "tip control", a small pop-up window that displays a * single line of text describing the hidden text when hovering an * item on the grid area. * @details * CXTPGridTip provides the functionality to control the * the tip text, the size of the tip window itself, and the text * font of the tip. * * This class is used by the Grid control internally. * * @see * CXTPGridControl, CXTPGridRow::ShowToolTip */ class _XTP_EXT_CLASS CXTPGridTip : public CWnd { friend class CXTPGridRow; public: /** * @brief * Constructs a CXTPGridTip object. * @details * You construct a CXTPGridTip object in two steps. * First, call the CXTPGridTip constructor and then call Create. * This initializes the window and attaches it to the parent window. * * Example: *
* // Declare a local CXTPGridTip object. * CXTPGridTip wndTip; * * // Declare a dynamic CXTPGridTip object. * CXTPGridTip* pTipWnd = new CXTPGridTip; ** * @see * CWnd, Create, Activate, CXTPGridRow::ShowToolTip */ CXTPGridTip(); /** * @brief * Destroys a CXTPGridTip object, handles cleanup and deallocation. */ virtual ~CXTPGridTip(); /** * @brief * Creates a grid tip window. * @param pParentWnd Parent Grid control window. * @details * You construct a CXTPGridTip object in two steps. * First, call the CXTPGridTip constructor and then call Create. * This initializes the window and attaches it to the parent window. * @return * TRUE if the grid tip window was created successfully, otherwise FALSE. * @see * CXTPGridTip::CXTPGridTip, Activate */ virtual BOOL Create(CWnd* pParentWnd); public: /** * @brief * Determines if the tooltip text contains the new line character. * @return * TRUE if the tooltip text contains the new line character, otherwise FALSE. */ BOOL IsMultilineForce() const; /** * @brief * Gets the tooltip text. * @return * The tooltip text. * @see * SetTooltipText */ CString GetTooltipText() const; /** * @brief * Sets the tooltip text. * @param str New tooltip text. * @details * This method should be called before activating the tooltip window. * @see * GetTooltipText */ void SetTooltipText(LPCTSTR str); /** * @brief * Sets the font of the tooltip text. * @param pFont Pointer to the font to be set. */ void SetFont(CFont* pFont); /** * @brief * Sets the coordinates of the tooltip hover rectangle. * @param rc CRect object containing the tooltip hover rectangle in * parent window coordinates. * @details * This method should be called before activating the tooltip window. * @see * GetHoverRect */ void SetHoverRect(CRect rc); /** * @brief * Gets the coordinates of the tooltip hover rectangle. * @return * A CRect object containing the tooltip hover rectangle in * parent window coordinates. * @see * SetHoverRect */ CRect GetHoverRect() const; /** * @brief * Sets the tooltip rectangle. * * @param rc CRect object containing the tooltip rectangle. */ void SetTooltipRect(CRect rc); /** * @brief * Gets the tooltip rectangle. * @return * A CRect object containing the tooltip rectangle. */ CRect GetTooltipRect() const; /** * @brief * Call this function to activate/deactivate the tooltip control. * @param bActive TRUE to activate the tooltip control, FALSE to deactivate. * @param bMultiline TRUE if the tooltip is multiline, FALSE otherwise. * @details * When a tooltip control is active, tooltip information appears when * the cursor is on a tool that is registered with the control. * When a tooltip control is inactive, tooltip information does not appear when * the cursor is on a tool that is registered with the control. * @see * Create, CXTPGridTip::CXTPGridTip, SetTooltipText */ void Activate(BOOL bActive, BOOL bMultiline); protected: CRect m_rcHover; /**< Hover window coordinates. */ CRect m_rcTooltip; /**< Tooltip window coordinates. */ CWnd* m_pParentWnd; /**< Pointer to the parent grid window. */ CString m_strTooltipText; /**< Tooltip text to display. */ CXTPGridRecordItem* m_pItem; /**< Item which tooltip is visible. */ int m_nRowIndex; /**< Index of item's row. */ CXTPFont m_xtpFontToolTip; /**< Font for displaying tooltip text. */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fntToolTip, m_xtpFontToolTip, GetToolTipFontHandle); BOOL m_bMultiline; /**< Multiline tooltip flag. */ CXTPGridControl* m_pGridControl; /**< Parent Grid Control. */ protected: /** @cond */ //{{AFX_MSG(CXTPGridTip) afx_msg LRESULT OnNcHitTest(CPoint point); afx_msg BOOL OnEraseBkgnd(CDC*); afx_msg void OnPaint(); //}}AFX_MSG friend class CXTPGridControl; /** @endcond */ private: void RecalcTooltipRect(CRect& rc); BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); DECLARE_MESSAGE_MAP() }; AFX_INLINE CString CXTPGridTip::GetTooltipText() const { return m_strTooltipText; } AFX_INLINE void CXTPGridTip::SetTooltipText(LPCTSTR str) { m_strTooltipText = str; } AFX_INLINE void CXTPGridTip::SetHoverRect(CRect rc) { m_rcHover = rc; MoveWindow(rc); } AFX_INLINE void CXTPGridTip::SetTooltipRect(CRect rc) { m_rcTooltip = rc; MoveWindow(rc); } AFX_INLINE CRect CXTPGridTip::GetHoverRect() const { return m_rcHover; } AFX_INLINE CRect CXTPGridTip::GetTooltipRect() const { return m_rcTooltip; } AFX_INLINE BOOL CXTPGridTip::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); } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPGRIDTIP_H__) /** @endcond */