00001 /* 00002 * @(#)cmd/CommandHistory.h 3.00 10 June 1999 00003 * 00004 * Copyright (c) 2000 Pete Goodliffe (pete@cthree.org) 00005 * 00006 * This file is part of TSE3 - the Trax Sequencer Engine version 3.00. 00007 * 00008 * This library is modifiable/redistributable under the terms of the GNU 00009 * General Public License. 00010 * 00011 * You should have received a copy of the GNU General Public License along 00012 * with this program; see the file COPYING. If not, write to the Free Software 00013 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00014 * 00015 */ 00016 00017 #ifndef TSE3_CMD_COMMANDHISTORY_H 00018 #define TSE3_CMD_COMMANDHISTORY_H 00019 00020 #include "tse3/listen/cmd/CommandHistory.h" 00021 00022 #include "tse3/Notifier.h" 00023 #include "tse3/cmd/Command.h" 00024 00025 #include <list> 00026 #include <cstddef> 00027 00028 namespace TSE3 00029 { 00030 namespace Cmd 00031 { 00053 class CommandHistory : public TSE3::Notifier<CommandHistoryListener> 00054 { 00055 public: 00056 00063 CommandHistory(int limit = defaultLimit); 00064 00075 void add(Command *command); 00076 00085 bool undos() const; 00086 00090 void undo(); 00091 00103 Command *undoCommand(size_t pos); 00104 00113 bool redos() const; 00114 00118 void redo(); 00119 00131 Command *redoCommand(size_t pos); 00132 00143 int limit() const; 00144 00152 void setLimit(int limit); 00153 00160 void clear() 00161 { 00162 clearUndos(); 00163 clearRedos(); 00164 } 00165 00172 void clearUndos(); 00173 00180 void clearRedos(); 00181 00185 static const int defaultLimit = 20; 00186 00187 private: 00188 00189 int _limit; 00190 std::list<Command*> undolist; 00191 std::list<Command*> redolist; 00192 }; 00193 } 00194 } 00195 00196 #endif