OpenCPN Partial API docs
Loading...
Searching...
No Matches
undo.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2012 Jesper Weissglas *
3 * Copyright (C) 2012 by David S. Register *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
25#ifndef UNDO_H
26#define UNDO_H
27
28#include <wx/string.h>
29
30#include <vector>
31#include <deque>
32
33#include "chcanv.h"
34
35enum UndoType {
36 Undo_CreateWaypoint,
37 Undo_DeleteWaypoint,
38 Undo_AppendWaypoint,
39 Undo_MoveWaypoint
40};
41
42enum UndoBeforePointerType { Undo_IsOrphanded, Undo_NeedsCopy, Undo_HasParent };
43
44typedef void* UndoItemPointer;
45
47public:
49 wxString Description();
50
51 UndoType type;
52 std::vector<UndoItemPointer> before;
53 std::vector<UndoBeforePointerType> beforeType;
54 std::vector<UndoItemPointer> after;
55 std::vector<UndoItemPointer> selectable;
56};
57
58class Undo {
59public:
60 Undo(ChartCanvas* parent);
61 ~Undo();
62 bool AnythingToUndo();
63 bool AnythingToRedo();
64 void InvalidateRedo();
65 void InvalidateUndo();
66 void Invalidate();
67 bool InUndoableAction() { return isInsideUndoableAction; }
68 UndoAction* GetNextUndoableAction();
69 UndoAction* GetNextRedoableAction();
70 bool UndoLastAction();
71 bool RedoNextAction();
72 bool BeforeUndoableAction(UndoType type, UndoItemPointer before,
73 UndoBeforePointerType beforeType,
74 UndoItemPointer selectable);
75 bool AfterUndoableAction(UndoItemPointer after);
76 bool CancelUndoableAction(bool noDataDelete = false);
77 ChartCanvas* GetParent() { return m_parent; }
78
79private:
80 ChartCanvas* m_parent;
81 bool isInsideUndoableAction;
82 UndoAction* candidate;
83 unsigned int stackpointer;
84 unsigned int depthSetting;
85 std::deque<UndoAction*> undoStack;
86};
87
88#endif
Generic Chart canvas base.
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:157
Definition undo.h:58