00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TQCommand
00013 #define ROOT_TQCommand
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef ROOT_TList
00022 #include "TList.h"
00023 #endif
00024
00025 #ifndef ROOT_TQObject
00026 #include "TQObject.h"
00027 #endif
00028
00029 class TQCommand : public TList, public TQObject {
00030
00031 friend class TQUndoManager;
00032
00033 protected:
00034 TQConnection *fRedo;
00035 TQConnection *fUndo;
00036 Long_t *fRedoArgs;
00037 Long_t *fUndoArgs;
00038 Int_t fNRargs;
00039 Int_t fNUargs;
00040 Int_t fState;
00041 Int_t fStatus;
00042 Bool_t fNewDelete;
00043 TString fName;
00044 TString fTitle;
00045 void *fObject;
00046
00047 virtual void Init(const char *cl, void *object,
00048 const char *redo, const char *undo);
00049 virtual void PrintCollectionHeader(Option_t* option) const;
00050
00051 public:
00052 TQCommand(const char *cl = 0, void *object = 0,
00053 const char *redo = 0, const char *undo = 0);
00054 TQCommand(TObject *obj, const char *redo = 0, const char *undo = 0);
00055 TQCommand(const TQCommand &com);
00056 virtual ~TQCommand();
00057
00058 virtual void Redo(Option_t *option="");
00059 virtual void Undo(Option_t *option="");
00060 virtual void SetArgs(Int_t nargs, ...);
00061 virtual void SetUndoArgs(Int_t nargs, ...);
00062 virtual void SetRedoArgs(Int_t nargs, ...);
00063 virtual Bool_t CanMerge(TQCommand *c) const;
00064 virtual void Merge(TQCommand *c);
00065 virtual Bool_t CanCompress(TQCommand *c) const;
00066 virtual void Compress(TQCommand *c);
00067 virtual Bool_t IsEqual(const TObject* obj) const;
00068 virtual Bool_t IsSetter() const;
00069 virtual Bool_t CanRedo() const;
00070 virtual Bool_t CanUndo() const;
00071 const char *GetRedoName() const;
00072 const char *GetUndoName() const;
00073 TQConnection *GetRedo() const { return fRedo; }
00074 TQConnection *GetUndo() const { return fUndo; }
00075 Long_t *GetRedoArgs() const;
00076 Long_t *GetUndoArgs() const;
00077 Int_t GetNRargs() const;
00078 Int_t GetNUargs() const;
00079 void *GetObject() const;
00080 Int_t GetStatus() const;
00081 Bool_t IsMacro() const;
00082 Bool_t IsUndoing() const;
00083 Bool_t IsRedoing() const;
00084 Bool_t IsExecuting() const;
00085 virtual void SetName(const char *name);
00086 virtual void SetTitle(const char *title);
00087 virtual void ls(Option_t *option="") const;
00088 virtual void Add(TObject *obj, Option_t *opt);
00089 virtual void Add(TObject *obj) { Add(obj, 0); }
00090 virtual void Delete(Option_t *option="");
00091 virtual const char *GetName() const;
00092 virtual const char *GetTitle() const;
00093
00094 static TQCommand *GetCommand();
00095
00096 ClassDef(TQCommand,0)
00097 };
00098
00099
00100
00101 class TQUndoManager : public TQCommand {
00102
00103 protected:
00104 TObjLink *fCursor;
00105 TQCommand *fCurrent;
00106 UInt_t fLimit;
00107 TList *fLogBook;
00108 Bool_t fLogging;
00109
00110 virtual void PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const;
00111
00112 public:
00113 TQUndoManager();
00114 virtual ~TQUndoManager();
00115
00116 virtual void Add(TObject *obj, Option_t *opt);
00117 virtual void Add(TObject *obj) { Add(obj, 0); }
00118 virtual void Redo(Option_t *option="");
00119 virtual void Undo(Option_t *option="");
00120 virtual Bool_t CanRedo() const;
00121 virtual Bool_t CanUndo() const;
00122 virtual void SetLogging(Bool_t on = kTRUE);
00123 Bool_t IsLogging() const;
00124 TQCommand *GetCurrent() const;
00125 TQCommand *GetCursor() const;
00126 UInt_t GetLimit() const;
00127 virtual void SetLimit(UInt_t limit);
00128 virtual void CurrentChanged(TQCommand *c);
00129 virtual void ls(Option_t *option="") const;
00130
00131 ClassDef(TQUndoManager,0)
00132 };
00133
00134 #endif