Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/base:$Id$
2// Author: Valeriy Onuchin 04/27/2004
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
12#ifndef ROOT_TQCommand
13#define ROOT_TQCommand
16// //
17// TQCommand, TQUndoManager - support for multiple Undo/Redo operations //
18// //
21#include "TList.h"
23#include "TQObject.h"
25class TQConnection;
27class TQCommand : public TList, public TQObject {
29friend class TQUndoManager;
32 TQConnection *fRedo; // do/redo action
33 TQConnection *fUndo; // undo action
34 Long_t *fRedoArgs; // redo values
35 Long_t *fUndoArgs; // undo values
36 Int_t fNRargs; // number of redo arguments
37 Int_t fNUargs; // number of undo arguments
38 Int_t fState; // -1 undoing on, 1 redoing on, 0 nothing in progress
39 Int_t fStatus; // fStatus++ after Redo(), fStatus-- after Undo()
40 Bool_t fNewDelete; // kTRUE if Redo/Undo methods are new/delete
41 TString fName; // command name. Default is "ClassName::RedoName(args)"
42 TString fTitle; // command description
43 void *fObject; // object to which undo/redo actions applied
45 virtual void Init(const char *cl, void *object,
46 const char *redo, const char *undo);
47 void PrintCollectionHeader(Option_t* option) const override;
50 TQCommand &operator=(const TQCommand &); // Not yet implemented.
53 TQCommand(const char *cl = 0, void *object = 0,
54 const char *redo = 0, const char *undo = 0);
55 TQCommand(TObject *obj, const char *redo = 0, const char *undo = 0);
56 TQCommand(const TQCommand &com);
57 virtual ~TQCommand();
59 virtual void Redo(Option_t *option=""); //*SIGNAL*
60 virtual void Undo(Option_t *option=""); //*SIGNAL*
61 virtual void SetArgs(Int_t nargs, ...);
62 virtual void SetUndoArgs(Int_t nargs, ...);
63 virtual void SetRedoArgs(Int_t nargs, ...);
64 virtual Bool_t CanMerge(TQCommand *c) const;
65 virtual void Merge(TQCommand *c);
67 virtual Bool_t CanCompress(TQCommand *c) const;
68 virtual void Compress(TQCommand *c);
69 Bool_t IsEqual(const TObject* obj) const override;
70 virtual Bool_t IsSetter() const;
71 virtual Bool_t CanRedo() const;
72 virtual Bool_t CanUndo() const;
73 const char *GetRedoName() const;
74 const char *GetUndoName() const;
75 TQConnection *GetRedo() const { return fRedo; }
76 TQConnection *GetUndo() const { return fUndo; }
77 Long_t *GetRedoArgs() const;
78 Long_t *GetUndoArgs() const;
79 Int_t GetNRargs() const;
80 Int_t GetNUargs() const;
81 void *GetObject() const;
82 Int_t GetStatus() const;
83 Bool_t IsMacro() const;
84 Bool_t IsUndoing() const;
85 Bool_t IsRedoing() const;
86 Bool_t IsExecuting() const;
87 virtual void SetName(const char *name);
88 virtual void SetTitle(const char *title);
89 void ls(Option_t *option="") const override;
90 void Add(TObject *obj, Option_t *opt) override;
91 void Add(TObject *obj) override { Add(obj, 0); }
92 void Delete(Option_t *option="") override;
93 const char *GetName() const override;
94 const char *GetTitle() const override;
96 static TQCommand *GetCommand();
98 ClassDefOverride(TQCommand,0) // encapsulates the information for undo/redo a single action.
103class TQUndoManager : public TQCommand {
106 TObjLink *fCursor; // current position in history stack
107 TQCommand *fCurrent; // the latest executed command
108 UInt_t fLimit; // maximum number of commands can be located in stack
109 TList *fLogBook; // listing of all actions during execution
110 Bool_t fLogging; // kTRUE if logging is ON
112 void PrintCollectionEntry(TObject* entry, Option_t* option, Int_t recurse) const override;
116 virtual ~TQUndoManager();
118 void Add(TObject *obj, Option_t *opt) override;
119 void Add(TObject *obj) override { Add(obj, nullptr); }
120 void Redo(Option_t *option="") override;
121 void Undo(Option_t *option="") override;
122 Bool_t CanRedo() const override;
123 Bool_t CanUndo() const override;
124 virtual void SetLogging(Bool_t on = kTRUE);
125 Bool_t IsLogging() const;
126 TQCommand *GetCurrent() const;
127 TQCommand *GetCursor() const;
128 UInt_t GetLimit() const;
129 virtual void SetLimit(UInt_t limit);
130 virtual void CurrentChanged(TQCommand *c); //*SIGNAL*
131 void ls(Option_t *option="") const override;
133 ClassDefOverride(TQUndoManager,0) // recorder of operations for undo and redo
#define c(i)
Definition: RSha256.hxx:101
bool Bool_t
Definition: RtypesCore.h:63
int Int_t
Definition: RtypesCore.h:45
long Long_t
Definition: RtypesCore.h:54
unsigned int UInt_t
Definition: RtypesCore.h:46
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
char name[80]
Definition: TGX11.cxx:110
Collection abstract base class.
Definition: TCollection.h:65
A doubly linked list.
Definition: TList.h:38
Mother of all ROOT objects.
Definition: TObject.h:37
The Command design pattern is based on the idea, that all editing in an application is done by creati...
Definition: TQCommand.h:27
Bool_t IsRedoing() const
Redo action is in progress.
Definition: TQCommand.cxx:816
virtual void SetArgs(Int_t nargs,...)
Set do/redo and undo parameters.
Definition: TQCommand.cxx:465
TQConnection * GetRedo() const
Definition: TQCommand.h:75
virtual void Undo(Option_t *option="")
Un-execute all merged commands and the command.
Definition: TQCommand.cxx:626
virtual Bool_t CanCompress(TQCommand *c) const
By default, commands can be compressed if they are:
Definition: TQCommand.cxx:387
TString fName
Definition: TQCommand.h:41
virtual Bool_t CanMerge(TQCommand *c) const
Two commands can be merged if they can be composed into a single command (Macro command).
Definition: TQCommand.cxx:314
virtual void SetRedoArgs(Int_t nargs,...)
Set redo parameters.
Definition: TQCommand.cxx:508
Int_t GetNUargs() const
Returns a number of undo arguments.
Definition: TQCommand.cxx:776
Long_t * GetRedoArgs() const
Returns a pointer to array of redo arguments.
Definition: TQCommand.cxx:752
Int_t fState
Definition: TQCommand.h:38
void Delete(Option_t *option="") override
If "opt" is not zero delete every merged command which option string is equal to "opt".
Definition: TQCommand.cxx:285
Int_t fStatus
Definition: TQCommand.h:39
void Add(TObject *obj) override
Definition: TQCommand.h:91
virtual Bool_t CanRedo() const
Returns kTRUE if Redo action is possible, kFALSE if it's not.
Definition: TQCommand.cxx:571
virtual Bool_t CanUndo() const
Returns kTRUE if Undo action is possible, kFALSE if it's not.
Definition: TQCommand.cxx:580
Long_t * fUndoArgs
Definition: TQCommand.h:35
void Add(TObject *obj, Option_t *opt) override
Add command to the list of merged commands.
Definition: TQCommand.cxx:360
const char * GetUndoName() const
Returns the name of undo command.
Definition: TQCommand.cxx:744
virtual Bool_t IsSetter() const
Returns kTRUE is command if Redo is the same as Undo function and is the setter action.
Definition: TQCommand.cxx:440
const char * GetRedoName() const
Returns the name of redo command.
Definition: TQCommand.cxx:736
TQCommand & operator=(const TQCommand &)
Int_t fNRargs
Definition: TQCommand.h:36
virtual void Compress(TQCommand *c)
Compress command.
Definition: TQCommand.cxx:402
const char * GetName() const override
Returns the command name.
Definition: TQCommand.cxx:670
virtual void SetUndoArgs(Int_t nargs,...)
Set undo parameters.
Definition: TQCommand.cxx:542
virtual void SetName(const char *name)
Sets name of the command.
Definition: TQCommand.cxx:832
Int_t fNUargs
Definition: TQCommand.h:37
Bool_t IsUndoing() const
Undo action is in progress.
Definition: TQCommand.cxx:808
void * fObject
Definition: TQCommand.h:43
TQConnection * fRedo
Definition: TQCommand.h:32
virtual void Merge(TQCommand *c)
Add command to the list of merged commands.
Definition: TQCommand.cxx:329
void * GetObject() const
Returns an object for which undo redo actions are applied.
Definition: TQCommand.cxx:784
virtual ~TQCommand()
Definition: TQCommand.cxx:249
virtual void Init(const char *cl, void *object, const char *redo, const char *undo)
Common protected method used in several constructors.
Definition: TQCommand.cxx:120
Bool_t IsExecuting() const
Returns kTRUE if command execution is in progress.
Definition: TQCommand.cxx:824
TString fTitle
Definition: TQCommand.h:42
TQConnection * fUndo
Definition: TQCommand.h:33
void PrintCollectionHeader(Option_t *option) const override
Print collection header.
Definition: TQCommand.cxx:864
const char * GetTitle() const override
Returns command description.
Definition: TQCommand.cxx:713
Bool_t IsEqual(const TObject *obj) const override
Equal comparison.
Definition: TQCommand.cxx:418
Long_t * fRedoArgs
Definition: TQCommand.h:34
Int_t GetStatus() const
Returns a number of sequential undo or redo operations.
Definition: TQCommand.cxx:792
virtual void Redo(Option_t *option="")
Execute command and then merge commands.
Definition: TQCommand.cxx:588
TQConnection * GetUndo() const
Definition: TQCommand.h:76
Bool_t fNewDelete
Definition: TQCommand.h:40
Bool_t IsMacro() const
Returns kTRUE if neither redo nor undo action specified.
Definition: TQCommand.cxx:800
Long_t * GetUndoArgs() const
Returns a pointer to array of undo arguments.
Definition: TQCommand.cxx:760
static TQCommand * GetCommand()
Return a command which is doing redo/undo action.
Definition: TQCommand.cxx:276
Int_t GetNRargs() const
Returns a number of redo arguments.
Definition: TQCommand.cxx:768
virtual void SetTitle(const char *title)
Sets description of the command.
Definition: TQCommand.cxx:840
TQCommand(const char *cl=0, void *object=0, const char *redo=0, const char *undo=0)
Definition: TQCommand.cxx:168
void ls(Option_t *option="") const override
ls this command and merged commands
Definition: TQCommand.cxx:848
TQConnection class is an internal class, used in the object communication mechanism.
Definition: TQConnection.h:37
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
Definition: TQObject.h:48
Recorder of operations for undo and redo.
Definition: TQCommand.h:103
Bool_t fLogging
Definition: TQCommand.h:110
virtual ~TQUndoManager()
Definition: TQCommand.cxx:889
Bool_t CanUndo() const override
Returns kTRUE if undo action is possible.
Definition: TQCommand.cxx:1099
void ls(Option_t *option="") const override
Lists all commands in stack.
Definition: TQCommand.cxx:901
TList * fLogBook
Definition: TQCommand.h:109
void Add(TObject *obj) override
Definition: TQCommand.h:119
Definition: TQCommand.cxx:877
UInt_t GetLimit() const
Returns a maximum number of commands which could be located in stack.
Definition: TQCommand.cxx:1145
UInt_t fLimit
Definition: TQCommand.h:108
void Redo(Option_t *option="") override
Performs redo action. Move cursor position forward in history stack.
Definition: TQCommand.cxx:1053
Bool_t IsLogging() const
Returns kTRUE if logging is ON.
Definition: TQCommand.cxx:1113
TQCommand * GetCursor() const
Returns a command correspondent to the current cursor position in stack.
Definition: TQCommand.cxx:1129
TQCommand * GetCurrent() const
Returns the last executed command.
Definition: TQCommand.cxx:1121
void Add(TObject *obj, Option_t *opt) override
Add command to the stack of commands.
Definition: TQCommand.cxx:959
void PrintCollectionEntry(TObject *entry, Option_t *option, Int_t recurse) const override
Print collection entry.
Definition: TQCommand.cxx:921
Bool_t CanRedo() const override
Returns kTRUE if redo action is possible.
Definition: TQCommand.cxx:1085
void Undo(Option_t *option="") override
Performs undo action. Move cursor position backward in history stack.
Definition: TQCommand.cxx:1021
virtual void SetLogging(Bool_t on=kTRUE)
Start logging.
Definition: TQCommand.cxx:938
TObjLink * fCursor
Definition: TQCommand.h:106
virtual void CurrentChanged(TQCommand *c)
emit signal
Definition: TQCommand.cxx:1013
virtual void SetLimit(UInt_t limit)
Returns a maximum number of commands which could be located in stack.
Definition: TQCommand.cxx:1137
TQCommand * fCurrent
Definition: TQCommand.h:107
Basic string class.
Definition: TString.h:136