/** * @file XTPTrackControlItem.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(__XTPTRACKCONTROLITEM_H__) # define __XTPTRACKCONTROLITEM_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPTrackControl; class CXTPTrackBlock; typedef CArray CXTPTrackBlockArray; /** * @brief * This class represents a container cell for a set of blocks and keys * and inherits basic functionality from the CXTPGridRecordItem class. * @see * CXTPGridRecordItem */ class _XTP_EXT_CLASS CXTPTrackControlItem : public CXTPGridRecordItem { /** @cond */ DECLARE_SERIAL(CXTPTrackControlItem) /** @endcond */ public: /** * @brief * Creates a CXTPTrackControlItem item. */ CXTPTrackControlItem(); /** * @brief * CXTPTrackControlItem default destructor. */ virtual ~CXTPTrackControlItem(); /** * @brief * Retrieves the text caption of the current item. * @param pColumn Pointer to the corresponding column of the current item. * @details * Overwrites parents' member function. * @return * The text caption of the current item. */ CString GetCaption(CXTPGridColumn* pColumn); using CXTPGridRecordItem::GetCaption; /** * @brief * Should be overridden by descendants for drawing itself. * @param pDrawArgs Pointer to an XTP_GRIDRECORDITEM_DRAWARGS * structure containing drawing arguments. * @details * This function simply prepares and calls the necessary drawing * functions from PaintManager to draw a grid item. As such, * you must provide your own implementation of PaintManager in * order to change the appearance of your grid item. * @return * Nonzero if successful, otherwise 0. * * Example: *
	 * // fill structure
	 * XTP_GRIDRECORDITEM_DRAWARGS drawArgs;
	 * drawArgs.pDC = pDC;
	 * drawArgs.pControl = m_pControl;
	 * drawArgs.pRow = this;
	 * // call function
	 * Draw(&drawArgs);
	 * 
* * @see * XTP_GRIDRECORDITEM_DRAWARGS */ virtual int Draw(XTP_GRIDRECORDITEM_DRAWARGS* pDrawArgs); /** * @brief * Determines which block, if any, is at a specified point. * @param ptPoint Point to be tested. * @return * A pointer to the CXTPTrackBlock object at the * specified point, if any, otherwise NULL. */ CXTPTrackBlock* HitTest(CPoint ptPoint); /** * @brief * Removes a block. * @param pBlock Pointer to the block to be removed. * @return * TRUE if the removal is successful, otherwise FALSE. */ BOOL Remove(CXTPTrackBlock* pBlock); /** * @brief * Removes a block. * @param nIndex Zero-based index of the block to be removed. * @return * TRUE if the removal is successful, otherwise FALSE. */ BOOL RemoveAt(int nIndex); /** * @brief * Removes all blocks. */ void RemoveAll(); /** * @brief * Adds a block to the track. * @param pBlock Pointer to track block to be added. * @return * A pointer to the newly added block. */ CXTPTrackBlock* Add(CXTPTrackBlock* pBlock); /** * @brief * Retrieves the track control associated with this item. * @return * A pointer to the track control associated with this item. */ CXTPTrackControl* GetTrackControl() const; /** * @brief * Retrieves a specified block. * @param nIndex Index of the block to retrieve. * @return * A pointer to a CXTPTrackBlock object. */ CXTPTrackBlock* GetBlock(int nIndex) const; /** * @brief * Calculates the number of blocks in the track control. * @return * The number of blocks in the track control. */ int GetBlockCount() const; /** * @brief * Gets the locked state of the track control. * @return * TRUE if the track control is locked, otherwise FALSE. * @details * If a track is locked, then it cannot be moved and none of its * blocks or keys can be moved. When locked, blocks and keys * from other tracks cannot be dragged into this track. */ BOOL IsLocked() const; /** * @brief * Sets the locked state of the track control. * @param bLocked TRUE to lock the track control, FALSE to unlock. * @details * If a track is locked, then it cannot be moved and none of its * blocks or keys can be moved. When locked, blocks and keys * from other tracks cannot be dragged into this track. */ void SetLocked(BOOL bLocked = TRUE); /** * @brief * Processes mouse left button down clicks. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing click arguments. * @return * TRUE if the implementation handles the mouse click event and no * further handling is required, otherwise FALSE. * @details * Usually this function is called by GridRow's OnLButtonDown function. * @see * XTP_GRIDRECORDITEM_CLICKARGS */ virtual BOOL OnLButtonDown(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs); // virtual BOOL OnRButtonDown(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs); /** * @brief * Processes mouse left button up clicks. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing click arguments. * @return * TRUE if the implementation handles the mouse click event and no * further handling is required, otherwise FALSE. * @details * Usually this function is called by GridRow's OnLButtonUp function. * @see * XTP_GRIDRECORDITEM_CLICKARGS */ virtual BOOL OnLButtonUp(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs); /** * @brief * Processes single mouse clicks. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing click arguments. * @details * Usually this function is called by GridRow's OnClick function. * @see * XTP_GRIDRECORDITEM_CLICKARGS */ virtual void OnClick(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs); /** * @brief * Processes double mouse clicks. * @param pClickArgs Pointer to an XTP_GRIDRECORDITEM_CLICKARGS * structure containing click arguments. * @details * Usually this function is called by GridRow's OnDblClick function. * @see * XTP_GRIDRECORDITEM_CLICKARGS */ virtual void OnDblClick(XTP_GRIDRECORDITEM_CLICKARGS* pClickArgs); /** * @brief * Processes the move mouse event. * @param point Specifies the x- and y- coordinates of the cursor. * @param nFlags Additional flags. * @param pControl Pointer to the Grid control. * @details * Usually this function is called by GridRow's OnMouseMove function. */ virtual void OnMouseMove(UINT nFlags, CPoint point, CXTPGridControl* pControl = NULL); /** * @brief * Call this member function to store/load a grid record item using * the specified data object. * @param pPX Source/destination CXTPPropExchange data object reference. */ virtual void DoPropExchange(CXTPPropExchange* pPX); /** * @brief * Call this member function to perform a hit test on the track control * at a specified point and fill a TOOLINFO structure * with the contextual display string. * @param point Point to test. * @param pTI Pointer to a TOOLINFO structure. * @return * An INT_PTR value pointing to the track control item where the * hit test was performed. */ INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI); /** * @brief * Call this method to recalculate the size of the track items * when the layout is changed. */ void RecalcLayout(); /** * @brief * Adjusts the block position when a block is resized/moved. * @param pBlock Pointer to the track block that is being resized/moved. * @param bResize TRUE if the block is being resized, * FALSE if the block is being moved. */ void AdjustBlockPosition(CXTPTrackBlock* pBlock, BOOL bResize = FALSE); /** * @brief * Redraws the track control. */ void RedrawControl(); protected: /** * @brief * Highlights the work area. * @param pDC Pointer to the device context. * @param rcItem Work area rectangle. */ virtual void HighlightWorkArea(CDC* pDC, CRect rcItem); # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() LPDISPATCH OleGetBlock(int nIndex); int OleGetBlockCount(); LPDISPATCH OleAddBlock(BOOL bKey, int nPosition, int nLength); void OleRemoveBlock(int nIndex); BOOL OleGetLocked(); void OleSetLocked(BOOL bLocked); DECLARE_OLETYPELIB_EX(CXTPTrackControlItem); /** @endcond */ # endif public: BOOL m_bLocked; /**< TRUE if the whole track is locked. */ protected: CXTPTrackBlockArray m_arrBlocks; /**< Blocks array. */ protected: struct DOCK_INFO; class CDockInfoArray; friend class CXTPTrackControl; }; AFX_INLINE CXTPTrackBlock* CXTPTrackControlItem::GetBlock(int nIndex) const { return m_arrBlocks[nIndex]; } AFX_INLINE int CXTPTrackControlItem::GetBlockCount() const { return (int)m_arrBlocks.GetSize(); } AFX_INLINE BOOL CXTPTrackControlItem::IsLocked() const { return m_bLocked; } AFX_INLINE void CXTPTrackControlItem::SetLocked(BOOL bLocked) { m_bLocked = bLocked; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPTRACKCONTROLITEM_H__) /** @endcond */