HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CH_UndoEventHandler.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: CH_UndoEventHandler.h (JIVE Library, C++)
7  *
8  * COMMENTS: Creates an undo marker to minimize sent events
9  */
10 
11 #ifndef __CH_UNDOEVENTHANDLER_H_INCLUDED__
12 #define __CH_UNDOEVENTHANDLER_H_INCLUDED__
13 
14 #include "CH_API.h"
15 #include <UT/UT_Undo.h>
16 #include <UT/UT_UndoManager.h>
17 
18 
19 /// Creates an event handler into the undo manager to minimize sent events. To
20 /// use this, create a CH_UndoEventHandler::Scope object on the stack to
21 /// encapsulate the undo actions that we want to batch events for. If the
22 /// actions span multiple function calls, use matching undoBegin()/undoEnd()
23 /// invocations.
25 {
26 public:
27 
28  class Scope
29  {
30  public:
32  {
33  myBlockLevel = CH_UndoEventHandler::start();
34  }
36  {
37  CH_UndoEventHandler::stop(myBlockLevel);
38  }
39  private:
40  int myBlockLevel;
41  };
42 
43  static int start()
44  {
46  return -1;
47 
49  return UTgetUndoManager()->blockLevel();
50  }
51  static void stop(int level)
52  {
53  if (level <= -1)
54  return;
56  }
57 
58  virtual void undo();
59  virtual void redo();
60 
61 private:
62  CH_UndoEventHandler(bool start_marker);
63  void swap();
64 
65 private:
66  bool myStartMarker;
67 
69 };
70 
71 #endif // __CH_UNDOEVENTHANDLER_H_INCLUDED__
virtual void redo()=0
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
Definition: UT_ArraySet.h:1561
UT_API UT_UndoManager * UTgetUndoManager()
GLint level
Definition: glcorearb.h:107
virtual void undo()=0
int blockLevel() const
UT_API int UTwillAcceptUndoAddition(UT_UndoManager *man=0)
UT_API void UTaddToUndoBlock(UT_Undo *, UT_UndoManager *man=0)
#define CH_API
Definition: CH_API.h:10
static void stop(int level)