|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>: Undo and Redo<64><6F>ȫ<EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><DEB8><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ĵ<DEB8>Redo/Undo
|
|
|
|
|
|
//
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д: 2006-12-07
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(UNDOMANAGER_H)
|
|
|
|
|
|
#define UNDOMANAGER_H
|
|
|
|
|
|
|
|
|
|
|
|
#if _MSC_VER >= 1000
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
#endif // _MSC_VER >= 1000
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
|
#pragma warning(disable:4786)
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <deque>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include "UMString.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace NAction
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Action <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct ActionDetail
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string uuid;
|
|
|
|
|
|
std::string classType;
|
|
|
|
|
|
std::string createAt;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class CAction;
|
|
|
|
|
|
class CActionManager
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
enum StackKind
|
|
|
|
|
|
{
|
|
|
|
|
|
UNDO,
|
|
|
|
|
|
REDO
|
|
|
|
|
|
};
|
|
|
|
|
|
public:
|
|
|
|
|
|
CActionManager(void *actionTarget);
|
|
|
|
|
|
virtual ~CActionManager();
|
|
|
|
|
|
void RemoveLastAction();
|
|
|
|
|
|
void ClearTarget();
|
|
|
|
|
|
long GetStackCapacity() const;
|
|
|
|
|
|
void SetStackCapacity(long capacity);
|
|
|
|
|
|
void SetLastAction(CAction *itsLastAction);
|
|
|
|
|
|
const UMString & GetActionName(StackKind kind, long pos) const;
|
|
|
|
|
|
long GetStackSize(StackKind kind) const;
|
|
|
|
|
|
virtual int Undo(long nActions = 1);
|
|
|
|
|
|
virtual bool CanUndo(long nActions = 1) const;
|
|
|
|
|
|
virtual int Redo(long nActions = 1);
|
|
|
|
|
|
virtual bool CanRedo(long nActions = 1) const;
|
|
|
|
|
|
void * GetTarget() const;
|
|
|
|
|
|
void TargetCleaned();
|
|
|
|
|
|
|
|
|
|
|
|
void SavePostion();
|
|
|
|
|
|
bool IsModified();
|
|
|
|
|
|
|
|
|
|
|
|
// we use a deque so that we can pop off both ends
|
|
|
|
|
|
// (e.g., off the bottom during overflow) and so we
|
|
|
|
|
|
// can access all actions, say when building an undo
|
|
|
|
|
|
// menu, rather than just the top; also note that we
|
|
|
|
|
|
// push onto the back (like you would with a vector)
|
|
|
|
|
|
typedef std::deque<CAction *> ActionStack;
|
|
|
|
|
|
|
|
|
|
|
|
const ActionStack& GetUndoStack() const;
|
|
|
|
|
|
|
|
|
|
|
|
const ActionStack& GetRedoStack() const;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* <EFBFBD>г<EFBFBD> * Action <EFBFBD>嵥
|
|
|
|
|
|
*
|
|
|
|
|
|
* \return
|
|
|
|
|
|
*/
|
|
|
|
|
|
std::vector<ActionDetail> ListActionDetails() const;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* <EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD> action<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ uuid Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD>ԭͼ<EFBFBD><EFBFBD>
|
|
|
|
|
|
*
|
|
|
|
|
|
* \param uuid
|
|
|
|
|
|
*/
|
|
|
|
|
|
void RestoreToTargetAction(const std::string& targetUUID);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
virtual void DeleteActions(ActionStack &aStack, long nActions);
|
|
|
|
|
|
//virtual void NotifyTarget(UINT operation, long nActions);
|
|
|
|
|
|
void * actionTarget;
|
|
|
|
|
|
ActionStack undoStack, redoStack;
|
|
|
|
|
|
long cleanMarker;
|
|
|
|
|
|
long capacity;
|
|
|
|
|
|
CAction* m_pSavedAction;
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
/**
|
|
|
|
|
|
* <EFBFBD>ж<EFBFBD>ָ<EFBFBD><EFBFBD> uuid <EFBFBD><EFBFBD> Action <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD> undo ջ<EFBFBD><EFBFBD>
|
|
|
|
|
|
*
|
|
|
|
|
|
* \param uuid
|
|
|
|
|
|
* \return
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool InUndoStack(const std::string& uuid) const;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* <EFBFBD>ж<EFBFBD>ָ<EFBFBD><EFBFBD> uuid <EFBFBD><EFBFBD> Action <EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD> redo ջ<EFBFBD><EFBFBD>
|
|
|
|
|
|
*
|
|
|
|
|
|
* \param uuid
|
|
|
|
|
|
* \return
|
|
|
|
|
|
*/
|
|
|
|
|
|
bool InRedoStack(const std::string& uuid) const;
|
|
|
|
|
|
};
|
|
|
|
|
|
} //end namespace
|
|
|
|
|
|
#endif
|