OpenASIP  2.0
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 
43 using 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  */
65 bool
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()
84  ->createCommand(ProDeConstants::COMMAND_SAVE_OPTIONS);
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  */
105 int
106 QuitCmd::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  */
116 QuitCmd*
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  */
127 string
128 QuitCmd::icon() const {
130 }
131 
132 
133 /**
134  * This command is always executable.
135  *
136  * @return Always true.
137  */
138 bool
140  return true;
141 }
ProDe.hh
ProDeOptions
Definition: ProDeOptions.hh:44
ProDeConstants::COMMAND_SAVE_OPTIONS
@ COMMAND_SAVE_OPTIONS
Definition: ProDeConstants.hh:464
WxConversion::toWxString
static wxString toWxString(const std::string &source)
QuitCmd::isEnabled
virtual bool isEnabled()
Definition: QuitCmd.cc:139
QuitCmd
Definition: QuitCmd.hh:41
CommandRegistry.hh
MainFrame
Definition: MainFrame.hh:50
ProDeConstants::COMMAND_QUIT
@ COMMAND_QUIT
Definition: ProDeConstants.hh:415
QuitCmd.hh
GUICommand::Do
virtual bool Do()=0
GUICommand
Definition: GUICommand.hh:43
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
ConfirmDialog.hh
QuitCmd::QuitCmd
QuitCmd()
Definition: QuitCmd.cc:48
QuitCmd::icon
virtual std::string icon() const
Definition: QuitCmd.cc:128
ConfirmDialog
Definition: ConfirmDialog.hh:41
ProDeConstants.hh
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
MainFrame.hh
ProDeOptions.hh
QuitCmd::create
virtual QuitCmd * create() const
Definition: QuitCmd.cc:117
ProDeConstants::CMD_ICON_QUIT
static const std::string CMD_ICON_QUIT
Icon location for the "Quit" command.
Definition: ProDeConstants.hh:298
QuitCmd::Do
virtual bool Do()
Definition: QuitCmd.cc:66
EditorCommand
Definition: EditorCommand.hh:46
WxConversion.hh
QuitCmd::~QuitCmd
virtual ~QuitCmd()
Definition: QuitCmd.cc:57
QuitCmd::id
virtual int id() const
Definition: QuitCmd.cc:106
ProDeConstants
Definition: ProDeConstants.hh:43
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
MainFrame::OnExit
void OnExit(wxCommandEvent &WXUNUSED(event))
Definition: MainFrame.cc:771