Go to the
documentation of this file.
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #pragma once
00017
00018 #include "maxheap.h"
00019 #include "baseinterface.h"
00020 #include "strclass.h"
00021
00022 #define RESTOBJ_DOES_REFERENCE_POINTER 1 // cmd ID for RestoreObj::Execute
00023 #define RESTOBJ_GOING_TO_DELETE_POINTER 2 // cmd ID for RestoreObj::Execute
00024 #define REFTARG_AUTO_DELETED 10 // cmd ID for HoldStore::Execute
00025
00026 #define HOLD_SYSTEM_EMPTY 1 // cmd ID for Hold::Execute - return 1 if hold system is definitely empty
00027 #define HOLD_POINTER_IS_MANAGER 2 // cmd ID for Hold::Execute - return 1 if arg1 is a pointer to the undo manager
00028 #define HOLD_SUPERLEVEL 3 // cmd ID for Hold::Execute - return Hold.superLevel
00029
00030 class HoldStore;
00035 class RestoreObj : public InterfaceServer {
00036 friend class HoldStore;
00037 friend class GenUndoObject;
00038 friend class CheckForFlush;
00039 RestoreObj *next,*prev;
00040 public:
00041 RestoreObj() { next = prev = NULL; }
00042 virtual ~RestoreObj() {};
00057 virtual void Restore(int isUndo)=0;
00061 virtual void Redo()=0;
00068 virtual int Size() { return sizeof(RestoreObj); }
00074 virtual void EndHold() { }
00080 virtual MSTR Description() { return MSTR(_M("---")); }
00088 virtual INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0)
00089 {
00090 UNUSED_PARAM(cmd);
00091 UNUSED_PARAM(arg1);
00092 UNUSED_PARAM(arg2);
00093 UNUSED_PARAM(arg3);
00094 return -1;
00095 }
00096 };
00097
00103 class Hold : public BaseInterfaceServer {
00104 HoldStore *holdStore, *holdList;
00105 int undoEnabled;
00106 int superLevel;
00107 int putCount;
00108 HoldStore *ResetStore();
00109 void Init();
00110 void AddOpToUndoMgr(MCHAR *name,int id);
00111 public:
00112 CoreExport Hold();
00113 CoreExport ~Hold();
00126 CoreExport void Put(RestoreObj *rob);
00142 CoreExport void Begin();
00145 CoreExport void Suspend();
00146 CoreExport int IsSuspended();
00149 CoreExport void Resume();
00164 CoreExport int Holding();
00169 CoreExport int Restoring(int& isUndo);
00172 CoreExport int Redoing();
00176 CoreExport int RestoreOrRedoing();
00177
00181 CoreExport void DisableUndo();
00185 CoreExport void EnableUndo();
00189 CoreExport BOOL IsUndoDisabled();
00190
00193 CoreExport int GetBeginDepth();
00194
00200 CoreExport void Restore();
00205 CoreExport void Release();
00206
00207
00212 CoreExport void End();
00220 CoreExport void Accept(int nameID);
00225 CoreExport void Accept(MCHAR *name);
00229 CoreExport void Cancel();
00230
00231
00232
00259 CoreExport void SuperBegin();
00268 CoreExport void SuperAccept(int nameID);
00275 CoreExport void SuperAccept(MCHAR *name);
00282 CoreExport void SuperCancel();
00285 CoreExport int GetSuperBeginDepth();
00286
00287
00288
00291 CoreExport int GetGlobalPutCount();
00292
00293 CoreExport INT_PTR Execute(int cmd, ULONG_PTR arg1=0, ULONG_PTR arg2=0, ULONG_PTR arg3=0);
00294
00303 CoreExport DWORD_PTR Size() const;
00304
00305 protected:
00306 friend HoldStore;
00307 unsigned flags;
00308 enum {
00309 kInRestore,
00310 kInUndo,
00311 kInRedo
00312 };
00313 };
00314
00315
00316
00317 extern CoreExport Hold theHold;
00318
00319 CoreExport void EnableUndoDebugPrintout(BOOL onoff);
00320
00321
00322
00323
00324 class HoldSuspend: public MaxHeapOperators {
00325 public:
00326 HoldSuspend(BOOL suspendNow = TRUE) : suspendCount(0) {
00327 if (suspendNow) {
00328 this->Suspend();
00329 }
00330 }
00331 ~HoldSuspend() {
00332 while(suspendCount > 0) {
00333 this->Resume();
00334 }
00335 }
00336 void Suspend() {
00337 if (suspendCount == 0)
00338 theHold.Suspend ();
00339 suspendCount++;
00340 }
00341 void Resume() {
00342 if (suspendCount == 1)
00343 theHold.Resume();
00344 if (suspendCount > 0)
00345 suspendCount--;
00346 }
00347
00348 private:
00349 int suspendCount;
00350
00351 };
00352
00353
00354