| library: libCore #include "TQCommand.h" |

| TQCommand(const TQCommand& com) | |
| TQCommand(TObject* obj, const char* redo = "0", const char* undo = "0") | |
| TQCommand(const char* cl = "0", void* object = 0, const char* redo = "0", const char* undo = "0") | |
| virtual | ~TQCommand() |
| void | TObject::AbstractMethod(const char* method) const |
| virtual void | Add(TObject* obj) |
| virtual void | Add(TObject* obj, Option_t* opt) |
| virtual void | TList::AddAfter(const TObject* after, TObject* obj) |
| virtual void | TList::AddAfter(TObjLink* after, TObject* obj) |
| virtual void | TCollection::AddAll(const TCollection* col) |
| virtual void | TList::AddAt(TObject* obj, Int_t idx) |
| virtual void | TList::AddBefore(const TObject* before, TObject* obj) |
| virtual void | TList::AddBefore(TObjLink* before, TObject* obj) |
| virtual void | TList::AddFirst(TObject* obj) |
| virtual void | TList::AddFirst(TObject* obj, Option_t* opt) |
| virtual void | TList::AddLast(TObject* obj) |
| virtual void | TList::AddLast(TObject* obj, Option_t* opt) |
| void | TCollection::AddVector(TObject* obj1) |
| virtual TObject* | TList::After(const TObject* obj) const |
| virtual void | TObject::AppendPad(Option_t* option = "") |
| Bool_t | TCollection::AssertClass(TClass* cl) const |
| virtual TObject* | TList::At(Int_t idx) const |
| virtual TObject* | TList::Before(const TObject* obj) const |
| virtual void | TCollection::Browse(TBrowser* b) |
| virtual Bool_t | CanCompress(TQCommand* c) const |
| virtual Bool_t | CanMerge(TQCommand* c) const |
| virtual Bool_t | CanRedo() const |
| virtual Bool_t | CanUndo() const |
| Int_t | TCollection::Capacity() const |
| virtual void | TQObject::ChangedBy(const char* method) |
| static TClass* | Class() |
| virtual const char* | TObject::ClassName() const |
| virtual void | TList::Clear(Option_t* option = "") |
| virtual TObject* | TObject::Clone(const char* newname = "") const |
| virtual Int_t | TCollection::Compare(const TObject* obj) const |
| virtual void | Compress(TQCommand* c) |
| Bool_t | TQObject::Connect(const char* signal, const char* receiver_class, void* receiver, const char* slot) |
| static Bool_t | TQObject::Connect(TQObject* sender, const char* signal, const char* receiver_class, void* receiver, const char* slot) |
| static Bool_t | TQObject::Connect(const char* sender_class, const char* signal, const char* receiver_class, void* receiver, const char* slot) |
| virtual void | TQObject::Connected(const char*) |
| Bool_t | TCollection::Contains(const char* name) const |
| Bool_t | TCollection::Contains(const TObject* obj) const |
| virtual void | TObject::Copy(TObject& object) const |
| virtual void | Delete(Option_t* option = "") |
| virtual void | TQObject::Destroyed() |
| Bool_t | TQObject::Disconnect(const char* signal = "0", void* receiver = 0, const char* slot = "0") |
| static Bool_t | TQObject::Disconnect(TQObject* sender, const char* signal = "0", void* receiver = 0, const char* slot = "0") |
| static Bool_t | TQObject::Disconnect(const char* class_name, const char* signal, void* receiver = 0, const char* slot = "0") |
| virtual void | TQObject::Disconnected(const char*) |
| virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
| virtual void | TCollection::Draw(Option_t* option = "") |
| virtual void | TObject::DrawClass() const |
| virtual TObject* | TObject::DrawClone(Option_t* option = "") const |
| virtual void | TCollection::Dump() const |
| void | TQObject::Emit(const char* signal) |
| void | TQObject::Emit(const char* signal, Long_t* paramArr) |
| void | TQObject::Emit(const char* signal, const char* params) |
| void | TQObject::Emit(const char* signal, Double_t param) |
| void | TQObject::Emit(const char* signal, Long_t param) |
| void | TQObject::Emit(const char* signal, Long64_t param) |
| void | TQObject::Emit(const char* signal, Bool_t param) |
| void | TQObject::Emit(const char* signal, Char_t param) |
| void | TQObject::Emit(const char* signal, UChar_t param) |
| void | TQObject::Emit(const char* signal, Short_t param) |
| void | TQObject::Emit(const char* signal, UShort_t param) |
| void | TQObject::Emit(const char* signal, Int_t param) |
| void | TQObject::Emit(const char* signal, UInt_t param) |
| void | TQObject::Emit(const char* signal, ULong_t param) |
| void | TQObject::Emit(const char* signal, ULong64_t param) |
| void | TQObject::Emit(const char* signal, Float_t param) |
| void | TQObject::EmitVA(const char* signal, Int_t nargs) |
| void | TQObject::EmitVA(const char* signal, Int_t nargs, va_list va) |
| static void | TCollection::EmptyGarbageCollection() |
| virtual void | TObject::Error(const char* method, const char* msgfmt) const |
| virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
| virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
| virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
| virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
| virtual TObject* | TList::FindObject(const char* name) const |
| virtual TObject* | TList::FindObject(const TObject* obj) const |
| virtual TObject* | TList::First() const |
| virtual TObjLink* | TList::FirstLink() const |
| static void | TCollection::GarbageCollect(TObject* obj) |
| static TQCommand* | GetCommand() |
| static TCollection* | TCollection::GetCurrentCollection() |
| virtual Option_t* | TObject::GetDrawOption() const |
| static Long_t | TObject::GetDtorOnly() |
| virtual Int_t | TCollection::GetEntries() const |
| virtual const char* | TObject::GetIconName() const |
| TList* | TQObject::GetListOfClassSignals() const |
| TList* | TQObject::GetListOfConnections() const |
| TList* | TQObject::GetListOfSignals() const |
| virtual const char* | GetName() const |
| Int_t | GetNRargs() const |
| Int_t | GetNUargs() const |
| void* | GetObject() const |
| virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
| virtual TObject** | TList::GetObjectRef(const TObject* obj) const |
| static Bool_t | TObject::GetObjectStat() |
| virtual Option_t* | TObject::GetOption() const |
| TQConnection* | GetRedo() const |
| Long_t* | GetRedoArgs() const |
| const char* | GetRedoName() const |
| virtual Int_t | TCollection::GetSize() const |
| Int_t | GetStatus() const |
| virtual const char* | GetTitle() const |
| TQConnection* | GetUndo() const |
| Long_t* | GetUndoArgs() const |
| const char* | GetUndoName() const |
| virtual UInt_t | TObject::GetUniqueID() const |
| virtual Int_t | TCollection::GrowBy(Int_t delta) const |
| virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
| virtual Bool_t | TQObject::HasConnection(const char* signal_name) const |
| virtual ULong_t | TCollection::Hash() const |
| virtual void | TQObject::HighPriority(const char* signal_name, const char* slot_name = "0") |
| virtual Int_t | TSeqCollection::IndexOf(const TObject* obj) const |
| virtual void | TObject::Info(const char* method, const char* msgfmt) const |
| virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
| virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
| virtual void | TObject::Inspect() const |
| void | TObject::InvertBit(UInt_t f) |
| virtual TClass* | IsA() const |
| Bool_t | TCollection::IsArgNull(const char* where, const TObject* obj) const |
| Bool_t | TList::IsAscending() |
| virtual Bool_t | TCollection::IsEmpty() const |
| virtual Bool_t | IsEqual(const TObject* obj) const |
| Bool_t | IsExecuting() const |
| virtual Bool_t | TCollection::IsFolder() const |
| Bool_t | IsMacro() const |
| Bool_t | TObject::IsOnHeap() const |
| Bool_t | TCollection::IsOwner() const |
| Bool_t | IsRedoing() const |
| virtual Bool_t | IsSetter() const |
| virtual Bool_t | TCollection::IsSortable() const |
| virtual Bool_t | TSeqCollection::IsSorted() const |
| Bool_t | IsUndoing() const |
| Bool_t | TObject::IsZombie() const |
| virtual TObject* | TList::Last() const |
| Int_t | TSeqCollection::LastIndex() const |
| virtual TObjLink* | TList::LastLink() const |
| static void | TQObject::LoadRQ_OBJECT() |
| virtual void | TQObject::LowPriority(const char* signal_name, const char* slot_name = "0") |
| virtual void | ls(Option_t* option = "") const |
| virtual TIterator* | TList::MakeIterator(Bool_t dir = kIterForward) const |
| virtual TIterator* | TCollection::MakeReverseIterator() const |
| void | TObject::MayNotUse(const char* method) const |
| virtual void | Merge(TQCommand* c) |
| virtual void | TQObject::Message(const char* msg) |
| virtual Bool_t | TObject::Notify() |
| virtual Int_t | TQObject::NumberOfConnections() const |
| virtual Int_t | TQObject::NumberOfSignals() const |
| static Int_t | TSeqCollection::ObjCompare(TObject* a, TObject* b) |
| static void | TObject::operator delete(void* ptr) |
| static void | TObject::operator delete(void* ptr, void* vp) |
| static void | TObject::operator delete[](void* ptr) |
| static void | TObject::operator delete[](void* ptr, void* vp) |
| void* | TObject::operator new(size_t sz) |
| void* | TObject::operator new(size_t sz, void* vp) |
| void* | TObject::operator new[](size_t sz) |
| void* | TObject::operator new[](size_t sz, void* vp) |
| TObject* | TCollection::operator()(const char* name) const |
| TObject& | TObject::operator=(const TObject& rhs) |
| virtual void | TCollection::Paint(Option_t* option = "") |
| virtual void | TObject::Pop() |
| virtual void | Print(Option_t* option = "") const |
| virtual void | Print(Option_t*, Option_t* option) const |
| static void | TSeqCollection::QSort(TObject** a, Int_t first, Int_t last) |
| static void | TSeqCollection::QSort(TObject** a, TObject** b, Int_t first, Int_t last) |
| virtual Int_t | TObject::Read(const char* name) |
| virtual void | TCollection::RecursiveRemove(TObject* obj) |
| virtual void | Redo(Option_t* option = "") |
| virtual TObject* | TList::Remove(TObject* obj) |
| virtual TObject* | TList::Remove(TObjLink* lnk) |
| virtual void | TSeqCollection::RemoveAfter(TObject* after) |
| void | TCollection::RemoveAll() |
| virtual void | TCollection::RemoveAll(TCollection* col) |
| virtual TObject* | TSeqCollection::RemoveAt(Int_t idx) |
| virtual void | TSeqCollection::RemoveBefore(TObject* before) |
| virtual void | TSeqCollection::RemoveFirst() |
| virtual void | TSeqCollection::RemoveLast() |
| void | TObject::ResetBit(UInt_t f) |
| virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") const |
| virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
| virtual void | SetArgs(Int_t nargs) |
| void | TObject::SetBit(UInt_t f) |
| void | TObject::SetBit(UInt_t f, Bool_t set) |
| void | TCollection::SetCurrentCollection() |
| virtual void | TObject::SetDrawOption(Option_t* option = "") |
| static void | TObject::SetDtorOnly(void* obj) |
| virtual void | SetName(const char* name) |
| static void | TObject::SetObjectStat(Bool_t stat) |
| virtual void | TCollection::SetOwner(Bool_t enable = kTRUE) |
| virtual void | SetRedoArgs(Int_t nargs) |
| virtual void | SetTitle(const char* title) |
| virtual void | SetUndoArgs(Int_t nargs) |
| virtual void | TObject::SetUniqueID(UInt_t uid) |
| virtual void | ShowMembers(TMemberInspector& insp, char* parent) |
| virtual void | TList::Sort(Bool_t order = kSortAscending) |
| static void | TCollection::StartGarbageCollection() |
| virtual void | Streamer(TBuffer& b) |
| void | StreamerNVirtual(TBuffer& b) |
| virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
| Bool_t | TObject::TestBit(UInt_t f) const |
| Int_t | TObject::TestBits(UInt_t f) const |
| virtual void | Undo(Option_t* option = "") |
| void | TSeqCollection::UnSort() |
| virtual void | TObject::UseCurrentStyle() |
| virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
| virtual Int_t | TCollection::Write(const char* name = "0", Int_t option = 0, Int_t bufsize = 0) |
| virtual Int_t | TCollection::Write(const char* name = "0", Int_t option = 0, Int_t bufsize = 0) const |
| virtual void | TSeqCollection::Changed() |
| static Int_t | TQObject::CheckConnectArgs(TQObject* sender, TClass* sender_class, const char* signal, TClass* receiver_class, const char* slot) |
| static Bool_t | TQObject::ConnectToClass(TQObject* sender, const char* signal, TClass* receiver_class, void* receiver, const char* slot) |
| static Bool_t | TQObject::ConnectToClass(const char* sender_class, const char* signal, TClass* receiver_class, void* receiver, const char* slot) |
| virtual void | TList::DeleteLink(TObjLink* lnk) |
| virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
| TObjLink** | TList::DoSort(TObjLink** head, Int_t n) |
| TObjLink* | TList::FindLink(const TObject* obj, Int_t& idx) const |
| virtual void* | TQObject::GetSender() |
| virtual const char* | TQObject::GetSenderClassName() const |
| virtual void | Init(const char* cl, void* object, const char* redo, const char* undo) |
| TObjLink* | TList::LinkAt(Int_t idx) const |
| Bool_t | TList::LnkCompare(TObjLink* l1, TObjLink* l2) |
| void | TObject::MakeZombie() |
| virtual TObjLink* | TList::NewLink(TObject* obj, TObjLink* prev = 0) |
| virtual TObjLink* | TList::NewOptLink(TObject* obj, Option_t* opt, TObjLink* prev = 0) |
| enum TCollection::[unnamed] { | kIsOwner | |
| kInitCapacity | ||
| kInitHashTableCapacity | ||
| }; | ||
| enum TObject::EStatusBits { | kCanDelete | |
| kMustCleanup | ||
| kObjInCanvas | ||
| kIsReferenced | ||
| kHasUUID | ||
| kCannotPick | ||
| kNoContextMenu | ||
| kInvalidObject | ||
| }; | ||
| enum TObject::[unnamed] { | kIsOnHeap | |
| kNotDeleted | ||
| kZombie | ||
| kBitMask | ||
| kSingleKey | ||
| kOverwrite | ||
| kWriteDelete | ||
| }; |
| TQConnection* | fRedo | do/redo action |
| TQConnection* | fUndo | undo action |
| Long_t* | fRedoArgs | redo values |
| Long_t* | fUndoArgs | undo values |
| Int_t | fNRargs | number of redo arguments |
| Int_t | fNUargs | number of undo arguments |
| Int_t | fState | -1 undoing on, 1 redoing on, 0 nothing in progress |
| Int_t | fStatus | fStatus++ after Redo(), fStatus-- after Undo() |
| Bool_t | fNewDelete | kTRUE if Redo/Undo methods are new/delete |
| TString | fName | command name. Default is "ClassName::RedoName(args)" |
| TString | fTitle | command description |
| void* | fObject | object to which undo/redo actions applied |
| TObjLink* | TList::fFirst | ! pointer to first entry in linked list |
| TObjLink* | TList::fLast | ! pointer to last entry in linked list |
| TObjLink* | TList::fCache | ! cache to speedup sequential calling of Before() and After() functions |
| Bool_t | TList::fAscending | ! sorting order (when calling Sort() or for TSortedList) |
| Bool_t | TSeqCollection::fSorted | true if collection has been sorted |
| TString | TCollection::fName | name of the collection |
| Int_t | TCollection::fSize | number of elements in collection |
| TList* | TQObject::fListOfSignals | ! list of signals from this object |
| TList* | TQObject::fListOfConnections | ! list of connections to this object |
The Command design pattern is based on the idea, that all editing
in an application is done by creating instances of command objects.
Command objects apply changes to the edited object and then are
stored on a command stack. Furthermore, each command knows how to
undo its changes to bring the edited object back to its previous
state. As long as the application only uses command objects to
change the state of the edited object, it is possible to undo
a sequence of commands by traversing the command stack downwards and
calling the "undo" method of each command in turn. It is also
possible to redo a sequence of commands by traversing the command
stack upwards and calling the "redo" method of each command.
Examples:
1. Create a new command
TQCommand *com = new TQCommand("TH1", hpx, "SetFillColor(Color_t)"
"SetFillColor(Color_t)");
1st parameter - the name of class
2nd parameter - object
3rd parameter - the name of do/redo method
4th parameter - the name of undo method
Since redo,undo methods are the same, undo name can be omitted, e.g.
TQCommand *com = new TQCommand("TH1", hpx, "SetFillColor(Color_t)");
For objects derived from TObject class name can be omitted, e.g.
TQCommand *com = new TQCommand(hpx, "SetFillColor(Color_t)");
2. Setting undo, redo parameters.
Color_t old_color = hpx->GetFillColor();
Color_t new_color = 4; // blue color
com->SetRedoArgs(1, new_color);
com->SetUndoArgs(1, old_color);
1st argument - the number of undo, redo parameters
the other arguments - undo, redo values
Since the number of undo,redo parameters is the same one can use
com->SetArgs(1, new_color, old_color);
3. Undo, redo method execution
com->Redo(); // execute redo method
com->Undo(); // execute undo method
4. Merged commands
It possible to group several commands together so an end user
can undo and redo them with one command.
TQCommand *update = new TQCommand(gPad, "Modified()");
com->Add(update);
5. Macro commands
"Merging" allows to create macro commands, e.g.
TQCommand *macro = new TQCommand("my macro");
macro->Add(com1);
macro->Add(com2);
...
During Redo operation commands composing macro command are executed
sequentially in direct order (first in first out). During Undo,
they are executed in reverse order (last in first out).
6. Undo manager.
TQUndoManager is recorder of undo and redo operations. This is
command history list which can be traversed backwards and upwards
performing undo and redo operations.
To register command TQUndoManager::Add(TObject*) method is used.
TQUndoManager *history = new TQUndoManager();
history->Add(com);
TQUndoManager::Add automatically invokes execution of command's
Redo method.
Use TQUndoManager::Undo to undo commands in history list.
Redo is Undo for undo action. Use TQUndoManager::Redo method for that
common protected method used in several constructors
Constructor.
Input parameters:
1. clname - class name.
2. obj - an object
3. redo - method or function to do/redo operation
4. undo - method or function to undo operation
Comments:
- if either clname or obj is NULL that means that redo/undo is function
- to specify default arguments for redo/undo method/function
'=' must precede to argument value.
Example:
TQCommand("TPad", gPad, "SetEditable(=kTRUE)", "SetEditable(=kFALSE)");
- undo method can be same as redo one. In that case undo parameter
can be omitted.
Example:
TQCommand("TPad", gPad, "SetFillStyle(Style_t)");
Constructor.
Input parameters:
1. obj - an object
2. redo - method or function to do/redo operation
3. undo - method or function to undo operation
Comments:
- to specify default arguments for redo/undo method/function
'=' must precede to argument value.
Example:
TQCommand(gPad, "SetEditable(=kTRUE)", "SetEditable(=kFALSE)");
- undo method can be same as redo one. In that case "undo"
can parameter be omitted.
Example:
TQCommand(gPad, "SetFillStyle(Style_t)");
Return a command which is doing redo/undo action. This static method allows to set undo parameters dynamically, i.e. during execution of Redo function. Example: For redo actions like TGTextEdit::DelChar() it is not possible to know ahead what character will be deleted. To set arguments for undo action ( e.g. TGTextEdit::InsChar(char)), one needs to call TQCommand::SetUndoArgs(1, character) from inside of TGTextEdit::DelChar() method, i.e. TQCommand::GetCommand()->SetUndoArgs(1, somechar);
If "opt" is not zero delete every merged command which option string is equal to "opt". If "opt" is zero - delete all merged commands.
Two commands can be merged if they can be composed into a single command (Macro command). To allow merging commands user might override this function.
Add command to the list of merged commands. This make it possible to group complex actions together so an end user can undo and redo them with one command. Execution of TQUndoManager::Undo(), TQUndoManager::Redo() methods only invokes the top level command as a whole. Merge method is analogous to logical join operation. Note: Merge method invokes redo action.
Add command to the list of merged commands. Option string can contain substrings: "compress" - try to compress input command "radd" - execute redo action of input command "uadd" - execute undo action of input command
By default, commands can be compressed if they are: - equal - setter commands More complicated commands might want to override this function.
Compress command. Compression is analogous to arithmetic "addition operation". Note: - The compressed command will be deleted. - Execution Compress method invokes Redo action with new redo arguments inheritied from compressed command. More complicated commands might want to override this function.
Equal comparison. The commands are equal if they are applied to the same object and have the same Redo/Undo actions More complicated commands might want to override this function.
Returns kTRUE is command if Redo is the same as Undo function and is the setter action. By default, all functions with names like "SetXXX" or "setXXX" considered as setters. Another type of setters are Move, Resize operations More complicated commands might want to override this function.
Set do/redo and undo parameters. The format is
SetArgs(number_of_params, redo_params, undo_params)
Example:
move_command->SetArgs(2, 100, 100, 200, 200);
2 params, (100,100) - do/redo position, (200,200) - undo position
Set redo parameters. The format is
SetRedoArgs(number_of_params, params)
Example:
move_command->SetRedoArgs(2, 100, 100);
Set undo parameters. The format is
SetUndoArgs(number_of_params, params)
Example:
move_command->SetUndoArgs(2, 200, 200);
Returns kTRUE if Redo action is possible, kFALSE if it's not. By default, only single sequential redo action is possible.
Returns kTRUE if Undo action is possible, kFALSE if it's not. By default, only single tial undo action is possible.
Unexecute all merged commands and the command. Merged commands are executed in reverse order.
Returns the command name. Default name is "ClassName::RedoName(args)" If list of merged commands is not empty the name is "ClassName::RedoName(args):cname1:cname2 ..."
Returns command description.
By default, "ClassName::RedoName(args)_ClassName::UndoName(args)"