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-2018 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // FXUndoList is pretty dandy but some features are missing:
16 // - we cannot find out wether we have currently begun an undo-group and
17 // thus abort() is hard to use.
18 // - onUpd-methods do not disable undo/redo while in an undo-group
19 //
20 // GNEUndoList inherits from FXUndoList and patches some methods. these are
21 // prefixed with p_
22 /****************************************************************************/
23 #ifndef GNEUndoList_h
24 #define GNEUndoList_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #include <config.h>
31 
32 #include <fx.h>
33 #include <stack>
34 
35 
36 // ===========================================================================
37 // class declarations
38 // ===========================================================================
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
48 class GNEUndoList : public FXUndoList {
50  FXDECLARE_ABSTRACT(GNEUndoList)
51 
52 public:
56 
62  void p_begin(const std::string& description);
63 
69  void p_end();
70 
72  void p_clear();
73 
75  void p_abort();
76 
79 
81  void undo();
82 
84  void redo();
85 
87  void p_add(GNEChange_Attribute* cmd);
88 
90  int currentCommandGroupSize() const;
91 
95  long p_onUpdUndo(FXObject*, FXSelector, void*);
96 
98  long p_onUpdRedo(FXObject*, FXSelector, void*);
100 
102  bool hasCommandGroup() const;
103 
104 private:
106  class CommandGroup : public FXCommandGroup {
107  public:
109  CommandGroup(std::string description);
110 
112  const std::string& getDescription();
113 
115  FXString undoName() const;
116 
118  FXString redoName() const;
119 
120  private:
122  const std::string myDescription;
123  };
124 
125  // the stack of currently active command groups
126  std::stack<CommandGroup*> myCommandGroups;
127 
128  // the parent application for this undolist
130 };
131 
132 
133 #endif
134 
135 /****************************************************************************/
136 
The main window of the Netedit.
const std::string myDescription
description of command
Definition: GNEUndoList.h:122
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:73
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:87
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:66
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:80
FXString redoName() const
get redo name
std::stack< CommandGroup * > myCommandGroups
Definition: GNEUndoList.h:126
GNEApplicationWindow *const myParent
Definition: GNEUndoList.h:129
int currentCommandGroupSize() const
get size of current CommandGroup
void p_abort()
reverts and discards ALL active command groups
Definition: GNEUndoList.cpp:94
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:106
const std::string & getDescription()
get description
long p_onUpdUndo(FXObject *, FXSelector, void *)