/** * @file XTPTrackUndoManager.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(__XTPTRACKUNDOMANAGER_H__) # define __XTPTRACKUNDOMANAGER_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" const int XTP_ID_TRACKUNDO_GROUP = -1; /**< The undo group command. */ const int XTP_ID_TRACKUNDO_SETMARKERPOSITION = 1000; /**< The undo set marker position command. */ const int XTP_ID_TRACKUNDO_ADDMARKER = 1001; /**< The undo add marker command. */ const int XTP_ID_TRACKUNDO_DELETEMARKER = 1002; /**< The undo delete marker command. */ const int XTP_ID_TRACKUNDO_ADDBLOCK = 1003; /**< The undo add block command. */ const int XTP_ID_TRACKUNDO_DELETEBLOCK = 1004; /**< The undo delete block command. */ const int XTP_ID_TRACKUNDO_SETBLOCKPOSITION = 1005; /**< The undo set block position command. */ /** * @brief * This class abstracts the undo command. */ class _XTP_EXT_CLASS CXTPTrackUndoCommand { protected: /** * @brief * Constructor, creates a CXTPTrackUndoCommand object. * @param nID The command ID. */ CXTPTrackUndoCommand(int nID); /** * @brief * CXTPTrackUndoCommand destructor, * handles cleanup and deallocation. */ virtual ~CXTPTrackUndoCommand(); public: /** * @brief * Call this function to get the command ID associated with this object. * @return * The command ID associated with this object. */ int GetID() const; protected: /** * @brief * Call this function to do the undo operation. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual void Undo(); protected: const int m_nID; /**< The command ID. */ friend class CXTPTrackUndoManager; friend class CXTPTrackUndoGroupCommand; }; /** * @brief * This class abstracts the undo commands in a group. */ class _XTP_EXT_CLASS CXTPTrackUndoGroupCommand : public CXTPTrackUndoCommand { protected: /** * @brief * Constructor, creates a CXTPTrackUndoCommand object. * @param pManager Pointer to the track undo manager. */ CXTPTrackUndoGroupCommand(CXTPTrackUndoManager* pManager); /** * @brief * CXTPTrackUndoGroupCommand destructor, * handles cleanup and deallocation. */ virtual ~CXTPTrackUndoGroupCommand(); public: /** * @brief * Call this function to do the undo operation. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual void Undo(); /** * @brief * Call this function to get the number of command objects in this group. * @return * The number of command objects in this group. */ int GetCount() const; /** * @brief * Call this function to add a command to the command group. * @param pCommand Pointer to the undo command object. */ void Add(CXTPTrackUndoCommand* pCommand); protected: CArray m_arrUndoCommands; /**< The command collection. */ CXTPTrackUndoManager* m_pManager; /**< The undo manager. */ friend class CXTPTrackUndoManager; }; /** * @brief * This class abstracts the undo delete marker command. * This is a kind of CXTPTrackUndoCommand. */ class _XTP_EXT_CLASS CXTPTrackUndoDeleteMarkerCommand : public CXTPTrackUndoCommand { public: /** * @brief * Constructor, creates a CXTPTrackUndoDeleteMarkerCommand object. * @param pMarker Pointer to the track marker object. */ CXTPTrackUndoDeleteMarkerCommand(CXTPTrackMarker* pMarker); /** * @brief * CXTPTrackUndoDeleteMarkerCommand destructor, * handles cleanup and deallocation. */ virtual ~CXTPTrackUndoDeleteMarkerCommand(); protected: /** * @brief * Call this function to do the undo operation. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual void Undo(); protected: CXTPTrackMarker* m_pMarker; /**< The track marker object. */ }; /** * @brief * This class abstracts the undo add marker command. * This is a kind of CXTPTrackUndoCommand. */ class _XTP_EXT_CLASS CXTPTrackUndoAddMarkerCommand : public CXTPTrackUndoCommand { public: /** * @brief * Constructor, creates a CXTPTrackUndoDeleteMarkerCommand object. * @param pMarker Pointer to the track marker object. */ CXTPTrackUndoAddMarkerCommand(CXTPTrackMarker* pMarker); /** * @brief * CXTPTrackUndoAddMarkerCommand destructor, * handles cleanup and deallocation. */ virtual ~CXTPTrackUndoAddMarkerCommand(); protected: /** * @brief * Call this function to do the undo operation. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual void Undo(); protected: CXTPTrackMarker* m_pMarker; /**< The track marker object. */ }; /** * @brief * This class abstracts the undo set marker position command. * This is a kind of CXTPTrackUndoCommand. */ class _XTP_EXT_CLASS CXTPTrackUndoSetMarkerPositionCommand : public CXTPTrackUndoCommand { public: /** * @brief * Constructor, creates a CXTPTrackUndoSetMarkerPositionCommand object. * @param pMarker Pointer to the track marker object. * @param nOldPosition Old position of the marker. */ CXTPTrackUndoSetMarkerPositionCommand(CXTPTrackMarker* pMarker, int nOldPosition); /** * @brief * CXTPTrackUndoSetMarkerPositionCommand destructor, * handles cleanup and deallocation. */ virtual ~CXTPTrackUndoSetMarkerPositionCommand(); protected: /** * @brief * Call this function to do the undo operation. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual void Undo(); protected: CXTPTrackMarker* m_pMarker; /**< The track marker object. */ int m_nOldPosition; /**< Old position of the marker. */ }; /** * @brief * This class abstracts the undo delete block command. * This is a kind of CXTPTrackUndoCommand. */ class _XTP_EXT_CLASS CXTPTrackUndoDeleteBlockCommand : public CXTPTrackUndoCommand { public: /** * @brief * Constructor, creates a CXTPTrackUndoDeleteBlockCommand object. * @param pBlock Pointer to the track block object. */ CXTPTrackUndoDeleteBlockCommand(CXTPTrackBlock* pBlock); /** * @brief * CXTPTrackUndoDeleteBlockCommand destructor, * handles cleanup and deallocation. */ virtual ~CXTPTrackUndoDeleteBlockCommand(); protected: /** * @brief * Call this function to do the undo operation. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual void Undo(); protected: CXTPTrackBlock* m_pBlock; /**< The track block object. */ CXTPTrackControlItem* m_pOldItem; /**< The old track control item. */ }; /** * @brief * This class abstracts the undo add block command. * This is a kind of CXTPTrackUndoCommand. */ class _XTP_EXT_CLASS CXTPTrackUndoAddBlockCommand : public CXTPTrackUndoCommand { public: /** * @brief * Constructor, creates a CXTPTrackUndoAddBlockCommand object. * @param pBlock Pointer to the track block object. */ CXTPTrackUndoAddBlockCommand(CXTPTrackBlock* pBlock); /** * @brief * CXTPTrackUndoAddBlockCommand destructor, * handles cleanup and deallocation. */ virtual ~CXTPTrackUndoAddBlockCommand(); protected: /** * @brief * Call this function to do the undo operation. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual void Undo(); protected: CXTPTrackBlock* m_pBlock; /**< Pointer to the track block object. */ }; /** * @brief * This class abstracts the undo set block position command. * This is a kind of CXTPTrackUndoCommand. */ class _XTP_EXT_CLASS CXTPTrackUndoSetBlockPositionCommand : public CXTPTrackUndoCommand { public: /** * @brief * Constructor, creates a CXTPTrackUndoSetBlockPositionCommand object. * @param pBlock Pointer to the track block object. * @param nOldPosition Old position of the block. * @param nOldLength Old length of the block. */ CXTPTrackUndoSetBlockPositionCommand(CXTPTrackBlock* pBlock, int nOldPosition, int nOldLength); /** * @brief * CXTPTrackUndoSetBlockPositionCommand destructor, * handles cleanup and deallocation. */ virtual ~CXTPTrackUndoSetBlockPositionCommand(); protected: /** * @brief * Call this function to do the undo operation. * @details * This is a virtual function so derived classes can provide their * specific implementations. */ virtual void Undo(); protected: CXTPTrackBlock* m_pBlock; /**< Pointer to the track block object. */ int m_nOldPosition; /**< Old position of the block. */ int m_nOldLength; /**< Old length of the block. */ }; /** * @brief * This class abstracts an undo manager. It manages all the undo * operations of the track control. This is a kind of CXTPCmdTarget. */ class _XTP_EXT_CLASS CXTPTrackUndoManager : public CXTPCmdTarget { public: /** * @brief * Constructor, creates a CXTPTrackUndoManager object. */ CXTPTrackUndoManager(); /** * @brief * CXTPTrackUndoManager destructor, * handles cleanup and deallocation. */ ~CXTPTrackUndoManager(); public: /** * @brief * Call this function to do the undo operation. */ void Undo(); /** * @brief * Call this function to do the redo operation. */ void Redo(); /** * @brief * Determines if the undo operation is possible in the current context. * @return * TRUE if the undo operation is possible, otherwise FALSE. */ BOOL CanUndo() const; /** * @brief * Determines if the redo operation is possible in the current context. * @return * TRUE if the redo operation is possible, otherwise FALSE. */ BOOL CanRedo() const; public: /** * @brief * Call this function to clear the list of undo and redo operations. */ void Clear(); /** * @brief * Adds an undo command to the collection of undo commands. * @param pCommand Pointer to the track undo command object. */ void AddUndoCommand(CXTPTrackUndoCommand* pCommand); /** * @brief * Call this function to start an undo group command. */ void StartGroup(); /** * @brief * Call this function to end an undo group command. */ void EndGroup(); protected: CArray m_arrUndoCommands; /**< The undo commands array. */ CArray m_arrRedoCommands; /**< The redo command array. */ int m_nUndoContext; /**< The undo context. */ CXTPTrackUndoGroupCommand* m_pUndoGroup; /**< The undo group command. */ # ifdef _XTP_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPTrackUndoManager); /** @endcond */ # endif }; AFX_INLINE int CXTPTrackUndoCommand::GetID() const { return m_nID; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPTRACKUNDOMANAGER_H__) /** @endcond */