HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_UndoBlock.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_UndoBlock.h ( Utility Library, C++)
7  *
8  * COMMENTS:
9  * This class is used by UT_UndoManager to organize groups
10  * of operations into a singe undoable block. It is basically
11  * a stack of UT_Undo's with an associated name (for the undo
12  * menu entry)
13  */
14 
15 #ifndef __UT_UndoBlock__
16 #define __UT_UndoBlock__
17 
18 #include "UT_API.h"
19 #include "UT_String.h"
20 #include "UT_Undo.h"
21 #include "UT_ValArray.h"
22 #include <SYS/SYS_Types.h>
23 
24 
25 class UT_API UT_UndoBlock : public UT_Undo
26 {
27 public:
28  explicit UT_UndoBlock(const char *name, UT_UndoBlock *next = NULL);
29  ~UT_UndoBlock();
30 
31  int isEmpty() const { return !myUndoHead; }
32  void addUndo(UT_Undo *);
33  void setNestedBlockName(int level, const char *name);
34  const char *getNestedBlockName(int level) const
35  {
36  if (level < myNestedNames.entries())
37  return myNestedNames(level);
38  return "";
39  }
40 
41  virtual void undo();
42  virtual void redo();
43  virtual int isUndoBlock() const { return 1; }
44 
45  // needToUndo/Redo return true if any of the UT_Undos in the block return
46  // true for the corresponding method
47  virtual bool needToUndo();
48  virtual bool needToRedo();
49 
50  /// Free all invalid undos/redos. Returns true if any pruning was done.
51  bool pruneInvalidUndos();
52 
53  virtual int64 getMemoryUsage();
54 
55  void clearContents();
56 
57  UT_UndoBlock *getNextBlock() { return myNextBlock; }
58  const UT_UndoBlock *getNextBlock() const { return myNextBlock; }
59  void setNextBlock(UT_UndoBlock *b) { myNextBlock = b; }
60 
61  // This is firefighting. The undo strategy we've employed is errorprone,
62  // and this method attempts to correct frequent programmer errors.
63  // Essentially, when a too-many-begins error occurs, this method is
64  // called, and it lops out any undos that don't belong in this block,
65  // returning them. The caller is responsible for taking ownership of
66  // these returned undos.
67  UT_UndoBlock *repairErrors();
68  void debugPrint(int indent = 1) const;
69 
70  // A suspend id of 0 means we're NOT suspended (the default)
71  exint getSuspendId() const { return mySuspendId; }
72  void setSuspendId(exint id) { mySuspendId = id; }
73 
74 private:
75  UT_Undo *myUndoHead;
76  UT_UndoBlock *myNextBlock;
77  UT_ValArray<char *> myNestedNames;
78  int64 myMemoryUsage;
79  exint mySuspendId;
80 };
81 
82 #endif
83 
void setSuspendId(exint id)
Definition: UT_UndoBlock.h:72
virtual bool needToRedo()
Definition: UT_Undo.h:45
virtual void redo()=0
GLint level
Definition: glcorearb.h:107
#define UT_API
Definition: UT_API.h:13
exint getSuspendId() const
Definition: UT_UndoBlock.h:71
GLuint id
Definition: glcorearb.h:654
long long int64
Definition: SYS_Types.h:107
virtual void undo()=0
int64 exint
Definition: SYS_Types.h:116
UT_UndoBlock * getNextBlock()
Definition: UT_UndoBlock.h:57
const UT_UndoBlock * getNextBlock() const
Definition: UT_UndoBlock.h:58
virtual int64 getMemoryUsage()
Definition: UT_Undo.h:57
GLuint const GLchar * name
Definition: glcorearb.h:785
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
int isEmpty() const
Definition: UT_UndoBlock.h:31
virtual int isUndoBlock() const
Definition: UT_UndoBlock.h:43
virtual bool needToUndo()
Definition: UT_Undo.h:44
const char * getNestedBlockName(int level) const
Definition: UT_UndoBlock.h:34
void setNextBlock(UT_UndoBlock *b)
Definition: UT_UndoBlock.h:59