OpenASIP 2.2
Loading...
Searching...
No Matches
QuitCmd.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 QuitCmd.cc
26 *
27 * Definition of QuitCmd class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30 */
31
32#include <wx/docmdi.h>
33
34#include "QuitCmd.hh"
35#include "ProDeConstants.hh"
36#include "ProDe.hh"
37#include "ProDeOptions.hh"
38#include "ConfirmDialog.hh"
39#include "CommandRegistry.hh"
40#include "WxConversion.hh"
41#include "MainFrame.hh"
42
43using std::string;
44
45/**
46 * The Constructor.
47 */
49 EditorCommand(ProDeConstants::CMD_NAME_QUIT) {
50
51}
52
53
54/**
55 * The Destructor.
56 */
58
59
60/**
61 * Executes the command.
62 *
63 * @return True, if the command was succesfully executed, false otherwise.
64 */
65bool
67
68 MainFrame* parent = wxGetApp().mainFrame();
69 ProDeOptions* options = wxGetApp().options();
70 if (options->isModified()) {
71 wxString question = _T("Options are modified. ");
72 if (options->hasFileName()) {
73 question.Append(_T("Do you want to save changes to '"));
74 question.Append(WxConversion::toWxString(
75 options->fileName()));
76 question.Append(_T("'?"));
77 } else {
78 question.Append(_T("Do you want to save changes?"));
79 }
80 ConfirmDialog confirm(parentWindow(), question);
81 int buttonPressed = confirm.ShowModal();
82 if (buttonPressed == wxID_YES) {
83 GUICommand* command = wxGetApp().commandRegistry()
85 if (!command->Do()) {
86 return false;
87 }
88 } else if (buttonPressed == wxID_CANCEL) {
89 return false;
90 }
91 // if 'No' button was pressed just exit the program
92 }
93
94 wxCommandEvent dummy(wxID_EXIT, 0);
95 parent->OnExit(dummy);
96 return false;
97}
98
99
100/**
101 * Returns id of this command.
102 *
103 * @return ID for this command to be used in menus and toolbars.
104 */
105int
106QuitCmd::id() const {
108}
109
110
111/**
112 * Creates and returns a new instance of this command.
113 *
114 * @return Newly created instance of this command.
115 */
116QuitCmd*
118 return new QuitCmd();
119}
120
121
122/**
123 * Returns path to the command's icon file.
124 *
125 * @return Full path to the command's icon file.
126 */
127string
131
132
133/**
134 * This command is always executable.
135 *
136 * @return Always true.
137 */
138bool
140 return true;
141}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
wxWindow * parentWindow() const
Definition GUICommand.cc:75
virtual bool Do()=0
void OnExit(wxCommandEvent &WXUNUSED(event))
Definition MainFrame.cc:771
static const std::string CMD_ICON_QUIT
Icon location for the "Quit" command.
virtual ~QuitCmd()
Definition QuitCmd.cc:57
virtual int id() const
Definition QuitCmd.cc:106
virtual QuitCmd * create() const
Definition QuitCmd.cc:117
virtual std::string icon() const
Definition QuitCmd.cc:128
QuitCmd()
Definition QuitCmd.cc:48
virtual bool Do()
Definition QuitCmd.cc:66
virtual bool isEnabled()
Definition QuitCmd.cc:139
static wxString toWxString(const std::string &source)