OpenASIP
2.2
Loading...
Searching...
No Matches
src
procgen
ProDe
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
39
using
std::string;
40
41
/**
42
* The Constructor.
43
*/
44
UndoCmd::UndoCmd
():
45
EditorCommand
(
ProDeConstants
::CMD_NAME_UNDO) {
46
47
}
48
49
50
/**
51
* The Destructor.
52
*/
53
UndoCmd::~UndoCmd
() {}
54
55
56
/**
57
* Executes the command.
58
*
59
* @return Always false.
60
*/
61
bool
62
UndoCmd::Do
() {
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
*/
73
int
74
UndoCmd::id
()
const
{
75
return
ProDeConstants::COMMAND_UNDO
;
76
}
77
78
79
/**
80
* Creates and returns a new instance of this command.
81
*
82
* @return Newly created instance of this command.
83
*/
84
UndoCmd
*
85
UndoCmd::create
()
const
{
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
*/
96
string
97
UndoCmd::icon
()
const
{
98
return
ProDeConstants::CMD_ICON_UNDO
;
99
}
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
*/
109
bool
110
UndoCmd::isEnabled
() {
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
MDFDocument.hh
ProDeConstants.hh
ProDe.hh
UndoCmd.hh
EditorCommand
Definition
EditorCommand.hh:46
EditorCommand::view
wxView * view() const
Definition
EditorCommand.cc:76
MDFDocument
Definition
MDFDocument.hh:51
Model
Definition
Model.hh:50
Model::canUndo
bool canUndo()
Definition
Model.cc:213
ProDeConstants
Definition
ProDeConstants.hh:43
ProDeConstants::COMMAND_UNDO
@ COMMAND_UNDO
Definition
ProDeConstants.hh:433
ProDeConstants::CMD_ICON_UNDO
static const std::string CMD_ICON_UNDO
Icon location for the "Undo" command.
Definition
ProDeConstants.hh:306
UndoCmd
Definition
UndoCmd.hh:41
UndoCmd::create
virtual UndoCmd * create() const
Definition
UndoCmd.cc:85
UndoCmd::Do
virtual bool Do()
Definition
UndoCmd.cc:62
UndoCmd::id
virtual int id() const
Definition
UndoCmd.cc:74
UndoCmd::icon
virtual std::string icon() const
Definition
UndoCmd.cc:97
UndoCmd::UndoCmd
UndoCmd()
Definition
UndoCmd.cc:44
UndoCmd::~UndoCmd
virtual ~UndoCmd()
Definition
UndoCmd.cc:53
UndoCmd::isEnabled
virtual bool isEnabled()
Definition
UndoCmd.cc:110
Generated by
1.9.8