SUMO - Simulation of Urban MObility
GNEUndoList.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // FXUndoList is pretty dandy but some features are missing:
8 // - we cannot find out wether we have currently begun an undo-group and
9 // thus abort() is hard to use.
10 // - onUpd-methods do not disable undo/redo while in an undo-group
11 //
12 // GNEUndoList inherits from FXUndoList and patches some methods. these are
13 // prefixed with p_
14 /****************************************************************************/
15 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
16 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
17 /****************************************************************************/
18 //
19 // This file is part of SUMO.
20 // SUMO is free software: you can redistribute it and/or modify
21 // it under the terms of the GNU General Public License as published by
22 // the Free Software Foundation, either version 3 of the License, or
23 // (at your option) any later version.
24 //
25 /****************************************************************************/
26 #ifndef GNEUndoList_h
27 #define GNEUndoList_h
28 
29 
30 // ===========================================================================
31 // included modules
32 // ===========================================================================
33 #ifdef _MSC_VER
34 #include <windows_config.h>
35 #else
36 #include <config.h>
37 #endif
38 
39 #include <stack>
40 #include <fx.h>
41 
42 
43 // ===========================================================================
44 // class declarations
45 // ===========================================================================
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
55 class GNEUndoList : public FXUndoList {
57  FXDECLARE_ABSTRACT(GNEUndoList)
58 
59 public:
63 
69  void p_begin(const std::string& description);
70 
76  void p_end();
77 
79  void p_clear();
80 
82  void p_abort();
83 
85  void undo();
86 
88  void redo();
89 
91  void p_add(GNEChange_Attribute* cmd);
92 
96  long p_onUpdUndo(FXObject*, FXSelector, void*);
97 
99  long p_onUpdRedo(FXObject*, FXSelector, void*);
101 
103  bool hasCommandGroup() const;
104 
105 private:
107  class CommandGroup : public FXCommandGroup {
108  public:
110  CommandGroup(std::string description);
111 
113  const std::string& getDescription();
114 
116  FXString undoName() const;
117 
119  FXString redoName() const;
120 
121  private:
123  const std::string myDescription;
124  };
125 
126  // the stack of currently active command groups
127  std::stack<CommandGroup*> myCommandGroups;
128 
129  // the parent application for this undolist
131 };
132 
133 
134 #endif
135 
136 /****************************************************************************/
137 
The main window of the Netedit.
const std::string myDescription
description of command
Definition: GNEUndoList.h:123
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:82
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:96
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:75
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:89
FXString redoName() const
get redo name
std::stack< CommandGroup * > myCommandGroups
Definition: GNEUndoList.h:127
GNEApplicationWindow *const myParent
Definition: GNEUndoList.h:130
void p_abort()
reverts and discards ALL active command groups
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:107
const std::string & getDescription()
get description
long p_onUpdUndo(FXObject *, FXSelector, void *)