1 /*$ 2 Copyright (C) 2013-2020 Azel. 3 4 This file is part of AzPainter. 5 6 AzPainter is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 AzPainter is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 $*/ 19 20 #ifndef MLIB_UNDO_H 21 #define MLIB_UNDO_H 22 23 #include "mListDef.h" 24 25 typedef struct _mUndo mUndo; 26 27 struct _mUndo 28 { 29 mList list; 30 mListItem *current; 31 int maxnum; 32 33 mListItem *(*create)(mUndo *); 34 mBool (*setreverse)(mUndo *,mListItem *,mListItem *,int); 35 mBool (*run)(mUndo *,mListItem *,int); 36 }; 37 38 enum MUNDO_RUNERR 39 { 40 MUNDO_RUNERR_OK, 41 MUNDO_RUNERR_NO_DATA, 42 MUNDO_RUNERR_CREATE, 43 MUNDO_RUNERR_RUN 44 }; 45 46 enum MUNDO_TYPE 47 { 48 MUNDO_TYPE_UNDO, 49 MUNDO_TYPE_REDO 50 }; 51 52 53 #ifdef __cplusplus 54 extern "C" { 55 #endif 56 57 void mUndoFree(mUndo *p); 58 mUndo *mUndoNew(int size); 59 60 mBool mUndoIsHave(mUndo *p,mBool redo); 61 62 void mUndoDeleteAll(mUndo *p); 63 void mUndoDelete_onlyUndo(mUndo *p); 64 void mUndoDelete_onlyRedo(mUndo *p); 65 66 void mUndoAdd(mUndo *p,mListItem *item); 67 68 int mUndoRunUndo(mUndo *p); 69 int mUndoRunRedo(mUndo *p); 70 71 #ifdef __cplusplus 72 } 73 #endif 74 75 #endif 76