OpenASIP  2.0
Public Member Functions | List of all members
QuitCmd Class Reference

#include <QuitCmd.hh>

Inheritance diagram for QuitCmd:
Inheritance graph
Collaboration diagram for QuitCmd:
Collaboration graph

Public Member Functions

 QuitCmd ()
 
virtual ~QuitCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual QuitCmdcreate () const
 
virtual std::string icon () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from EditorCommand
 EditorCommand (std::string name, wxWindow *parent=NULL)
 
virtual ~EditorCommand ()
 
void setView (wxView *view)
 
wxView * view () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
virtual std::string shortName () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

EditorCommand for quiting the editor.

Definition at line 41 of file QuitCmd.hh.

Constructor & Destructor Documentation

◆ QuitCmd()

QuitCmd::QuitCmd ( )

The Constructor.

Definition at line 48 of file QuitCmd.cc.

48  :
50 
51 }

Referenced by create().

◆ ~QuitCmd()

QuitCmd::~QuitCmd ( )
virtual

The Destructor.

Definition at line 57 of file QuitCmd.cc.

57 {}

Member Function Documentation

◆ create()

QuitCmd * QuitCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 117 of file QuitCmd.cc.

117  {
118  return new QuitCmd();
119 }

References QuitCmd().

Here is the call graph for this function:

◆ Do()

bool QuitCmd::Do ( )
virtual

Executes the command.

Returns
True, if the command was succesfully executed, false otherwise.

Implements GUICommand.

Definition at line 66 of file QuitCmd.cc.

66  {
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 }

References ProDeConstants::COMMAND_SAVE_OPTIONS, GUICommand::Do(), dummy, MainFrame::OnExit(), options, GUICommand::parentWindow(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ icon()

string QuitCmd::icon ( ) const
virtual

Returns path to the command's icon file.

Returns
Full path to the command's icon file.

Reimplemented from EditorCommand.

Definition at line 128 of file QuitCmd.cc.

128  {
130 }

References ProDeConstants::CMD_ICON_QUIT.

◆ id()

int QuitCmd::id ( ) const
virtual

Returns id of this command.

Returns
ID for this command to be used in menus and toolbars.

Implements GUICommand.

Definition at line 106 of file QuitCmd.cc.

106  {
108 }

References ProDeConstants::COMMAND_QUIT.

◆ isEnabled()

bool QuitCmd::isEnabled ( )
virtual

This command is always executable.

Returns
Always true.

Reimplemented from EditorCommand.

Definition at line 139 of file QuitCmd.cc.

139  {
140  return true;
141 }

The documentation for this class was generated from the following files:
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)
MainFrame
Definition: MainFrame.hh:50
ProDeConstants::COMMAND_QUIT
@ COMMAND_QUIT
Definition: ProDeConstants.hh:415
GUICommand::Do
virtual bool Do()=0
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
GUICommand
Definition: GUICommand.hh:43
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
QuitCmd::QuitCmd
QuitCmd()
Definition: QuitCmd.cc:48
ProDeConstants::CMD_NAME_QUIT
static const std::string CMD_NAME_QUIT
Command name for the "Quit" command.
Definition: ProDeConstants.hh:90
ConfirmDialog
Definition: ConfirmDialog.hh:41
options
static MachInfoCmdLineOptions options
Definition: MachInfo.cc:46
ProDeConstants::CMD_ICON_QUIT
static const std::string CMD_ICON_QUIT
Icon location for the "Quit" command.
Definition: ProDeConstants.hh:298
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
MainFrame::OnExit
void OnExit(wxCommandEvent &WXUNUSED(event))
Definition: MainFrame.cc:771