OpenASIP 2.2
Loading...
Searching...
No Matches
ToggleUnitDetailsCmd.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 ToggleUnitDetailsCmd.cc
26 *
27 * Definition of ToggleUnitDetails class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include <wx/docview.h>
34
36#include "MDFView.hh"
37#include "MachineCanvas.hh"
38#include "ProDeConstants.hh"
39#include "ProDe.hh"
41#include "OptionValue.hh"
42
43using std::string;
44
45/**
46 * The Constructor.
47 */
49 EditorCommand(ProDeConstants::CMD_NAME_TOGGLE_UNIT_DETAILS) {
50
51}
52
53
54/**
55 * The Destructor.
56 */
59
60/**
61 * Executes the command.
62 *
63 * @return true, if the command was succesfully executed, false otherwise.
64 */
65bool
67 MDFView* mView = dynamic_cast<MDFView*>(view());
68 MachineCanvas* canvas = mView->canvas();
69 OptionValue& option = canvas->options().optionValue(
71 option.setBoolValue(!option.isFlagOn());
72 canvas->updateMachine();
73 return true;
74}
75
76
77/**
78 * Returns state of the check-item related to this command.
79 *
80 * @return true, if the command check item is checked.
81 */
82bool
84 MDFView* mView = dynamic_cast<MDFView*>(view());
85 if (mView == NULL) {
86 return false;
87 }
88 MachineCanvas* canvas = mView->canvas();
89 if (canvas == NULL) {
90 return false;
91 }
92 OptionValue& option = canvas->options().optionValue(
94 return option.isFlagOn();
95}
96
97
98
99/**
100 * Returns id of this command.
101 *
102 * @return ID for this command to be used in menus and toolbars.
103 */
104int
108
109
110/**
111 * Creates and returns a new instance of this command.
112 *
113 * @return Newly created instance of this command.
114 */
117 return new ToggleUnitDetailsCmd();
118}
119
120
121/**
122 * Returns short version of the command name.
123 *
124 * @return Short name of the command to be used in the toolbar.
125 */
126string
130
131
132/**
133 * Returns true when the command is executable, false when not.
134 *
135 * This command is executable when a document is open.
136 *
137 * @return True, if a document is open.
138 */
139bool
141 wxDocManager* manager = wxGetApp().docManager();
142 if (manager->GetCurrentView() != NULL) {
143 return true;
144 }
145 return false;
146}
wxView * view() const
MachineCanvas * canvas() const
Definition MDFView.cc:229
static const std::string SHOW_UNIT_INFO_STRING
Option name for the unit info string visibility flag.
MachineCanvasOptions & options()
virtual void setBoolValue(bool)
virtual bool isFlagOn() const
OptionValue & optionValue(const string &name, int index=0)
Definition Options.cc:115
static const std::string CMD_SNAME_TOGGLE_UNIT_DETAILS
Command name for the "Toggle Unit Details" command.
virtual std::string shortName() const
virtual bool isChecked() const
virtual ToggleUnitDetailsCmd * create() const