/** * @file XTPTrackBlock.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(__XTPTRACKBLOCK_H__) # define __XTPTRACKBLOCK_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPTrackControlItem; /** * @brief * This class represents a track control block. Track blocks are a visual * representation of units of time in a track. They can have both a * minimum and maximum time period. */ class _XTP_EXT_CLASS CXTPTrackBlock : public CXTPCmdTarget { DECLARE_SERIAL(CXTPTrackBlock); public: /** * @brief * Constructs a CXTPTrackBlock object. */ CXTPTrackBlock(); public: /** * @brief * Draws the block. * @param pDC Pointer to the device context. * @param rc Bounds of the drawing area. * @param bSelected TRUE if the block is selected, FALSE otherwise. * @return * A value of 1 if the drawing was successful, otherwise a value of 0. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual int Draw(CDC* pDC, CRect rc, BOOL bSelected); /** * @brief * Determines if the item is a key. * @return * TRUE if the item is a key, otherwise FALSE. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual BOOL IsKey() const; /** * @brief * Determines if the block is resizable. * @return * TRUE if the block is resizable, otherwise FALSE. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual BOOL IsResizable() const; /** * @brief * Sets the position for the block on the track. * @param nPosition Position for the block on the track. */ void SetPosition(int nPosition); /** * @brief * Gets the position of the block on the track. * @return * The position of the block on the track. */ int GetPosition() const; /** * @brief * Sets the length for the block on the track. * @param nLength Length for the block on the track. */ void SetLength(int nLength); /** * @brief * Gets the length of the block on the track. * @return * The length of the block on the track. */ int GetLength() const; /** * @brief * Sets the color for the block. * @param clr COLORREF value specifying the color for the block. */ void SetColor(COLORREF clr); /** * @brief * Gets the bounding rectangle of the block. * @return * A CRect object containing the bounding rectangle of the block. */ CRect GetRect() const; /** * @brief * Gets the locked state of the block * (i.e. a locked block cannot be moved or resized). * @return * TRUE if the block is locked, otherwise FALSE. */ BOOL IsLocked() const; /** * @brief * Sets the locked state for the block * (i.e. a locked block cannot be moved or resized). * @param bLocked TRUE to lock the block; * the default value for this parameter is TRUE. */ void SetLocked(BOOL bLocked = TRUE); /** * @brief * Sets the height percentage for the block compared to its track. * @param dHeightPercent Double value denoting the height percentage. * @details * Blocks can be set to different heights and different vertical * alignments within a track. This is used as a visual aid to make * different blocks in the track visually different from each other. */ void SetHeightPercent(double dHeightPercent); /** * @brief * Gets the height percentage of the block compared to its track. * @return * A double value denoting the height percentage. */ double GetHeightPercent() const; void SetHeightFixed(int nHeightPercent); int GetHeightFixed() const; /** * @brief * Sets the vertical alignment for the block in its track. * @param nAlignment Double value denoting the vertical alignment. * @details * Vertical alignment is used for keys and blocks which do not share * the same height as their track. Vertical alignment aligns blocks * in relation to the center of the track. */ void SetVerticalAlignment(int nAlignment); /** * @brief * Gets the vertical alignment of the block in its track. * @return * A double value denoting the vertical alignment. * @details * Vertical alignment is used for keys and blocks which do not share * the same height as their track. Vertical alignment aligns blocks * in relation to the center of the track. */ int GetVerticalAlignment() const; /** * @brief * Gets the track control to which the block is associated with. * @return * A pointer to the CXTPTrackControl object to which the block * is associated with. * @details * Tracks are what hold blocks and keys. */ CXTPTrackControlItem* GetItem() const; /** * @brief * Gets the index of the block in its track. * @return * The index of the block in its track. */ int GetIndex() const; /** * @brief * Sets the selected state for the block. * @param bSelect TRUE to select the block, FALSE to unselect; * the default value for this parameter is TRUE. */ void Select(BOOL bSelect = TRUE); /** * @brief * Gets the selected state of the block. * @return * TRUE if the block is selected, otherwise FALSE. */ BOOL IsSelected() const; /** * @brief * Gets the caption of the block. * @return * The caption of the block. */ CString GetCaption() const; /** * @brief * Sets the caption for the block. * @param lpszCaption New caption for the block. */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Gets the tooltip text of the block. * @return * The tooltip text of the block. */ virtual CString GetTooltip() const; /** * @brief * Sets the tooltip text for the block. * @param lpszTooltip New tooltip text for the block. */ void SetTooltip(LPCTSTR lpszTooltip); /** * @brief * Sets the description text for the block. * @param lpszDescriptionText New description text for the block. */ void SetDescriptionText(LPCTSTR lpszDescriptionText); /** * @brief * Gets the description text of the block. * @return * The description text of the block. */ CString GetDescriptionText() const; /** * @brief * Sets the minimum length for the block. * @param nMinLength Minimum length for the block. */ void SetMinLength(int nMinLength); /** * @brief * Gets the minimum length of the block. * @return * The minimum length of the block. */ int GetMinLength() const; /** * @brief * Sets the maximum length for the block. * @param nMaxLength Maximum length for the block. */ void SetMaxLength(int nMaxLength); /** * @brief * Gets the maximum length of the block. * @return * The maximum length of the block. */ int GetMaxLength() const; public: /** * @brief * Call this member function to store/load the properties related * to the block. * @param pPX Source/destination CXTPPropExchange data object reference. * @details * This member function is used to store/load property data * to/from storage. */ void DoPropExchange(CXTPPropExchange* pPX); public: /** * @brief * Removes the block. */ void Remove(); public: CRect m_rcBlock; /**< Drawing bounding rectangle of block. */ CXTPTrackControlItem* m_pItem; /**< Pointer to the parent track of the block. */ int m_nPosition; /**< Position that resolve overlaps with items on same track. */ int m_nLength; /**< Length of the block. */ BOOL m_bLocked; /**< TRUE if the block is not movable/resizable. */ COLORREF m_clrBlock; /**< Color of the block. */ CString m_strCaption; /**< Caption text. */ double m_dHeightPercent; /**< Height percentage of the block compared to its track. */ int m_nHeightFixed; int m_nVerticalAlignment; /**< Vertical alignment of blocks with m_dHeightPercent < 1. */ protected: int m_nMRUPosition; /**< Last position that was set by the user. */ CString m_strToolTip; /**< Tooltip text. */ CString m_strDescription; /**< Description text. */ int m_nIndex; /**< Index of the block in its parent track. */ int m_nLastDragTime; /**< Last drag moment of user (used as priority for flexible draging). */ int m_nMinLength; /**< Minimum resize length. */ int m_nMaxLength; /**< Maximum resize length. */ BOOL m_bDragging; /**< Block is currently dragging. */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPTrackBlock); int OleGetPosition(); void OleSetPosition(int nPosition); int OleGetLength(); void OleSetLength(int nLength); BOOL OleGetLocked(); void OleSetLocked(BOOL bLocked); COLORREF OleGetColor(); void OleSetColor(OLE_COLOR clr); BSTR OleGetTooltip(); void OleSetTooltip(LPCTSTR lpszTooltip); BSTR OleGetDescriptionText(); void OleSetDescriptionText(LPCTSTR lpszDescription); double OleGetHeightPercent(); void OleSetHeightPercent(double dHeightPercent); int OleGetHeightFixed(); int OleGetVerticalAlignment(); void OleSetHeightFixed(int dHeightFixed); void OleSetVerticalAlignment(int nVerticalAlignment); int OleGetMinLength(); void OleSetMinLength(int nMinLength); int OleGetMaxLength(); void OleSetMaxLength(int nMaxLength); LPDISPATCH OleGetItem(); int OleGetIndex(); BOOL OleGetIsKey(); BSTR OleGetCaption(); void OleSetCaption(LPCTSTR lpszCaption); /** @endcond */ # endif private: friend class CXTPTrackControlItem; friend class CXTPTrackControl; }; /** * @brief * This class represents a track control key. Keys are used simply as * "notes" or reference points in the track. They can be added anywhere * in the track to make note of some event at a given moment in time. */ class _XTP_EXT_CLASS CXTPTrackKey : public CXTPTrackBlock { DECLARE_SERIAL(CXTPTrackKey); public: /** * @brief * Constructs a CXTPTrackKey object. */ CXTPTrackKey(); public: /** * @brief * Draws the key. * @param pDC Pointer to the device context. * @param rc Bounds of the drawing area. * @param bSelected TRUE if the block is selected, FALSE otherwise. * @return * A value of 1 if the drawing was successful, otherwise a value of 0. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual int Draw(CDC* pDC, CRect rc, BOOL bSelected); /** * @brief * Determines if the item is a key. * @return * TRUE if the item is a key, otherwise FALSE. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual BOOL IsKey() const; }; /** * @brief * This class represents a track control marker. Markers are used for block * alignment, blocks can be "snapped" to the left or right of these markers. */ class _XTP_EXT_CLASS CXTPTrackMarker : public CXTPCmdTarget { DECLARE_SERIAL(CXTPTrackMarker); public: /** * @brief * Constructs a CXTPTrackMarker object. */ CXTPTrackMarker(); public: /** * @brief * Sets the position of the marker. * @param nPosition Position of the marker on the time line. */ void SetPosition(int nPosition); /** * @brief * Gets the position of the marker. * @return * The position of the marker on the time line. */ int GetPosition() const; /** * @brief * Sets the caption for the marker. * @param lpszCaption New caption for the marker. */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Gets the caption of the marker. * @return * The caption of the marker. */ CString GetCaption() const; /** * @brief * Gets the bounding rectangle of the marker. * @return * A CRect object containing the bounding rectangle of the marker. */ CRect GetRect() const; /** * @brief * Removes the marker. */ void Remove(); /** * @brief * Gets the track control to which the marker is associated with. * @return * A pointer to the CXTPTrackControl object to which the marker * is associated with. */ CXTPTrackControl* GetControl() const; public: /** * @brief * Call this member function to store/load the properties related * to the marker. * @param pPX Source/destination CXTPPropExchange data object reference. * @details * This member function is used to store/load property data * to/from storage. */ void DoPropExchange(CXTPPropExchange* pPX); protected: CString m_strCaption; /**< Caption of the marker */ int m_nPosition; /**< Position of the marker. */ CRect m_rcMarker; /**< Drawing position of the marker. */ CXTPTrackControl* m_pControl; /**< Parent control. */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPTrackMarker); /** @endcond */ # endif private: friend class CXTPTrackPaintManager; friend class CXTPTrackMarkers; }; /** * @brief * This class abstracts the track control markers. Markers are used for block * alignment, blocks can be "snapped" to the left or right of these markers. */ class _XTP_EXT_CLASS CXTPTrackMarkers : public CXTPCmdTarget { protected: /** * @brief * Constructs a CXTPTrackMarkers object. * @param pControl Pointer to parent Track Control object */ CXTPTrackMarkers(CXTPTrackControl* pControl); /** * @brief * Destroys the CXTPTrackMarkers object, handles cleanup and deallocation. */ ~CXTPTrackMarkers(); public: /** * @brief * Creates and adds a marker to the marker collection. * @param nPosition Position of the marker. * @param lpszCaption Caption of the marker. * @return * A pointer to the newly created CXTPTrackMarker object. */ CXTPTrackMarker* Add(int nPosition, LPCTSTR lpszCaption); /** * @brief * Adds a marker to the marker collection. * @param pMarker Pointer to the marker to add. * @return * A pointer to the added CXTPTrackMarker object. */ CXTPTrackMarker* Add(CXTPTrackMarker* pMarker); /** * @brief * Retrieves the marker at a specified index in the marker collection. * @param nIndex Zero-based index of the marker to retrieve. * @return * A pointer to the CXTPTrackMarker at the specified index if successful, * NULL if the specified index is not valid in the current context. */ CXTPTrackMarker* GetAt(int nIndex) const; /** * @brief * Removes the marker at a specified index from the marker collection. * @param nIndex Zero-based index of the marker to remove. */ void RemoveAt(int nIndex); /** * @brief * Removes a specified marker from the marker collection. * @param pMarker Pointer to the marker to be removed. */ void Remove(CXTPTrackMarker* pMarker); /** * @brief * Removes all markers from the marker collection. */ void RemoveAll(); /** * @brief * Retrieves the index of a marker in the marker collection. * @param pMarker Pointer to the marker whose index must be retrieved. * @return * The zero-based index of the marker in the marker collection. */ int IndexOf(CXTPTrackMarker* pMarker); /** * @brief * Gets the number of markers in the marker collection. * @return * The number of markers in the marker collection. */ int GetCount() const; /** * @brief * Call this member function to determine the index of the marker, if any, * at a specified point. * @param pt Point to test. * @return * The zero-based index of the marker at the specified point, if any, * otherwise a value of -1. */ int HitTest(CPoint pt) const; public: /** * @brief * Call this member function to store/load the properties related * to the marker collection. * @param pPX Source/destination CXTPPropExchange data object reference. * @details * This member function is used to store/load property data * to/from storage. */ void DoPropExchange(CXTPPropExchange* pPX); protected: CXTPTrackControl* m_pControl; /**< Parent control. */ CArray m_arrMarkers; /**< Array of markers. */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPTrackMarkers); DECLARE_ENUM_VARIANT(CXTPTrackMarkers) LPDISPATCH OleAdd(int Position, LPCTSTR lpszCaption); LPDISPATCH OleGetItem(long nIndex); int OleGetItemCount(); /** @endcond */ # endif private: friend class CXTPTrackControl; }; /** * @brief * This class abstracts the selected blocks of the track control. This class * helps to perform a common task to the selected blocks (e.g. delete). */ class _XTP_EXT_CLASS CXTPTrackSelectedBlocks : public CXTPCmdTarget { public: /** * @brief * Constructs the CXTPTrackSelectedBlocks object. */ CXTPTrackSelectedBlocks(); /** * @brief * Gets the number of blocks in selected blocks. * @return * The number of blocks in selected blocks. */ int GetCount() const; /** * @brief * Adds a block to selected blocks. * @param pBlock Pointer to the block to add. */ void Add(CXTPTrackBlock* pBlock); /** * @brief * Determines if a block is selected. * @param pBlock Pointer to the block to check. * @return * TRUE if the block is selected, otherwise FALSE. */ BOOL IsSelected(const CXTPTrackBlock* pBlock) const; /** * @brief * Retrieves the block at a specified index in selected blocks. * @param nIndex Zero-based index of the block to retrieve. * @return * A pointer to the CXTPTrackBlock at the specified index. */ CXTPTrackBlock* GetAt(int nIndex) const; /** * @brief * Removes all blocks from selected blocks. */ void RemoveAll(); /** * @brief * Removes the block at a specified index from selected blocks. * @param nIndex Zero-based index of the block to remove. */ void RemoveAt(int nIndex); /** * @brief * Removes a specified block from selected blocks. * @param pBlock Pointer to the block to be removed. */ void Remove(CXTPTrackBlock* pBlock); protected: # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPTrackSelectedBlocks); DECLARE_ENUM_VARIANT(CXTPTrackSelectedBlocks) LPDISPATCH OleGetItem(long nIndex); int OleGetItemCount(); /** @endcond */ # endif protected: CArray m_arrBlocks; }; AFX_INLINE BOOL CXTPTrackBlock::IsKey() const { return FALSE; } AFX_INLINE void CXTPTrackBlock::SetColor(COLORREF clr) { m_clrBlock = clr; } AFX_INLINE CRect CXTPTrackBlock::GetRect() const { return m_rcBlock; } AFX_INLINE int CXTPTrackBlock::GetPosition() const { return m_nPosition; } AFX_INLINE int CXTPTrackBlock::GetLength() const { return m_nLength; } AFX_INLINE CString CXTPTrackBlock::GetTooltip() const { return m_strToolTip; } AFX_INLINE void CXTPTrackBlock::SetTooltip(LPCTSTR lpszTooltip) { m_strToolTip = lpszTooltip; } AFX_INLINE CString CXTPTrackBlock::GetCaption() const { return m_strCaption; } AFX_INLINE void CXTPTrackBlock::SetCaption(LPCTSTR lpszCaption) { m_strCaption = lpszCaption; } AFX_INLINE void CXTPTrackBlock::SetDescriptionText(LPCTSTR lpszDescriptionText) { m_strDescription = lpszDescriptionText; } AFX_INLINE CString CXTPTrackBlock::GetDescriptionText() const { return m_strDescription; } AFX_INLINE void CXTPTrackBlock::SetLocked(BOOL bLocked) { m_bLocked = bLocked; } AFX_INLINE void CXTPTrackBlock::SetHeightPercent(double dHeightPercent) { m_dHeightPercent = dHeightPercent; } AFX_INLINE double CXTPTrackBlock::GetHeightPercent() const { return m_dHeightPercent; } AFX_INLINE void CXTPTrackBlock::SetHeightFixed(int nHeightFixed) { m_nHeightFixed = nHeightFixed; } AFX_INLINE int CXTPTrackBlock::GetHeightFixed() const { return m_nHeightFixed; } AFX_INLINE void CXTPTrackBlock::SetVerticalAlignment(int nAlignment) { m_nVerticalAlignment = nAlignment; } AFX_INLINE int CXTPTrackBlock::GetVerticalAlignment() const { return m_nVerticalAlignment; } AFX_INLINE CXTPTrackControlItem* CXTPTrackBlock::GetItem() const { return m_pItem; } AFX_INLINE int CXTPTrackBlock::GetIndex() const { return m_nIndex; } AFX_INLINE BOOL CXTPTrackBlock::IsResizable() const { return !IsKey(); } AFX_INLINE void CXTPTrackBlock::SetMinLength(int nMinLength) { m_nMinLength = nMinLength; } AFX_INLINE int CXTPTrackBlock::GetMinLength() const { return m_nMinLength; } AFX_INLINE void CXTPTrackBlock::SetMaxLength(int nMaxLength) { m_nMaxLength = nMaxLength; } AFX_INLINE int CXTPTrackBlock::GetMaxLength() const { return m_nMaxLength; } AFX_INLINE BOOL CXTPTrackKey::IsKey() const { return TRUE; } AFX_INLINE int CXTPTrackMarker::GetPosition() const { return m_nPosition; } AFX_INLINE void CXTPTrackMarker::SetCaption(LPCTSTR lpszCaption) { m_strCaption = lpszCaption; } AFX_INLINE CString CXTPTrackMarker::GetCaption() const { return m_strCaption; } AFX_INLINE CRect CXTPTrackMarker::GetRect() const { return m_rcMarker; } AFX_INLINE CXTPTrackControl* CXTPTrackMarker::GetControl() const { return m_pControl; } typedef CArray CXTPTrackBlockArray; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPTRACKBLOCK_H__) /** @endcond */