SUMO - Simulation of Urban MObility
GNEUndoList.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // FXUndoList is pretty dandy but some features are missing:
18 // - we cannot find out wether we have currently begun an undo-group and
19 // thus abort() is hard to use.
20 // - onUpd-methods do not disable undo/redo while in an undo-group
21 //
22 // GNEUndoList inherits from FXUndoList and patches some methods. these are
23 // prefixed with p_
24 /****************************************************************************/
25 #ifndef GNEUndoList_h
26 #define GNEUndoList_h
27 
28 
29 // ===========================================================================
30 // included modules
31 // ===========================================================================
32 #ifdef _MSC_VER
33 #include <windows_config.h>
34 #else
35 #include <config.h>
36 #endif
37 
38 #include <stack>
39 #include <fx.h>
40 
41 
42 // ===========================================================================
43 // class declarations
44 // ===========================================================================
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
54 class GNEUndoList : public FXUndoList {
56  FXDECLARE_ABSTRACT(GNEUndoList)
57 
58 public:
62 
68  void p_begin(const std::string& description);
69 
75  void p_end();
76 
78  void p_clear();
79 
81  void p_abort();
82 
85 
87  void undo();
88 
90  void redo();
91 
93  void p_add(GNEChange_Attribute* cmd);
94 
96  int currentCommandGroupSize() const;
97 
101  long p_onUpdUndo(FXObject*, FXSelector, void*);
102 
104  long p_onUpdRedo(FXObject*, FXSelector, void*);
106 
108  bool hasCommandGroup() const;
109 
110 private:
112  class CommandGroup : public FXCommandGroup {
113  public:
115  CommandGroup(std::string description);
116 
118  const std::string& getDescription();
119 
121  FXString undoName() const;
122 
124  FXString redoName() const;
125 
126  private:
128  const std::string myDescription;
129  };
130 
131  // the stack of currently active command groups
132  std::stack<CommandGroup*> myCommandGroups;
133 
134  // the parent application for this undolist
136 };
137 
138 
139 #endif
140 
141 /****************************************************************************/
142 
The main window of the Netedit.
const std::string myDescription
description of command
Definition: GNEUndoList.h:128
void p_begin(const std::string &description)
Begin undo command sub-group. This begins a new group of commands that are treated as a single comman...
Definition: GNEUndoList.cpp:84
void redo()
redo the last command group
void undo()
undo the last command group
void p_clear()
clears the undo list (implies abort)
Definition: GNEUndoList.cpp:98
void p_add(GNEChange_Attribute *cmd)
special method, avoid empty changes, always execute
the function-object for an editing operation (abstract base)
GNEUndoList(GNEApplicationWindow *parent)
FOX declaration.
Definition: GNEUndoList.cpp:77
bool hasCommandGroup() const
Check if undoList has command group.
void p_end()
End undo command sub-group. If the sub-group is still empty, it will be deleted; otherwise, the sub-group will be added as a new command into parent group. A matching begin() must have been called previously.
Definition: GNEUndoList.cpp:91
FXString redoName() const
get redo name
std::stack< CommandGroup * > myCommandGroups
Definition: GNEUndoList.h:132
GNEApplicationWindow *const myParent
Definition: GNEUndoList.h:135
int currentCommandGroupSize() const
get size of current CommandGroup
void p_abort()
reverts and discards ALL active command groups
void p_abortLastCommandGroup()
reverts last command group
long p_onUpdRedo(FXObject *, FXSelector, void *)
event after Redo
CommandGroup(std::string description)
Constructor.
FXString undoName() const
get undo Name
class CommandGroup
Definition: GNEUndoList.h:112
const std::string & getDescription()
get description
long p_onUpdUndo(FXObject *, FXSelector, void *)