OpenASIP 2.2
Loading...
Searching...
No Matches
UndoCmd.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file UndoCmd.cc
26 *
27 * Definition of UndoCmd class.
28 *
29 * @author Veli-Pekka Jääskeläinen (vjaaskel-no.spam-cs.tut.fi)
30 */
31
32#include <wx/docview.h>
33#include "UndoCmd.hh"
34#include "ProDe.hh"
35#include "ProDeConstants.hh"
36#include "MDFDocument.hh"
37
38
39using std::string;
40
41/**
42 * The Constructor.
43 */
45 EditorCommand(ProDeConstants::CMD_NAME_UNDO) {
46
47}
48
49
50/**
51 * The Destructor.
52 */
54
55
56/**
57 * Executes the command.
58 *
59 * @return Always false.
60 */
61bool
63 dynamic_cast<MDFDocument*>(view()->GetDocument())->getModel()->undo();
64 return false;
65}
66
67
68/**
69 * Returns id of this command.
70 *
71 * @return ID for this command to be used in menus and toolbars.
72 */
73int
77
78
79/**
80 * Creates and returns a new instance of this command.
81 *
82 * @return Newly created instance of this command.
83 */
86 return new UndoCmd();
87}
88
89
90
91/**
92 * Returns path to the command's icon file.
93 *
94 * @return Full path to the command's icon file.
95 */
96string
100
101
102/**
103 * Returns true when the command is executable, false when not.
104 *
105 * This command is executable when the model's undo stack is not empty.
106 *
107 * @return True, if the model's undo stack is not empty.
108 */
109bool
111
112 wxDocManager* manager = wxGetApp().docManager();
113
114 wxView* view = manager->GetCurrentView();
115 if (view == NULL) {
116 return false;
117 }
118
119 Model* model =
120 dynamic_cast<MDFDocument*>(view->GetDocument())->getModel();
121
122 if (model != NULL && model->canUndo()) {
123 return true;
124 }
125 return false;
126}
127
wxView * view() const
Definition Model.hh:50
bool canUndo()
Definition Model.cc:213
static const std::string CMD_ICON_UNDO
Icon location for the "Undo" command.
virtual UndoCmd * create() const
Definition UndoCmd.cc:85
virtual bool Do()
Definition UndoCmd.cc:62
virtual int id() const
Definition UndoCmd.cc:74
virtual std::string icon() const
Definition UndoCmd.cc:97
UndoCmd()
Definition UndoCmd.cc:44
virtual ~UndoCmd()
Definition UndoCmd.cc:53
virtual bool isEnabled()
Definition UndoCmd.cc:110