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

#include <SaveDocumentCmd.hh>

Inheritance diagram for SaveDocumentCmd:
Inheritance graph
Collaboration diagram for SaveDocumentCmd:
Collaboration graph

Public Member Functions

 SaveDocumentCmd ()
 
virtual ~SaveDocumentCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual SaveDocumentCmdcreate () const
 
virtual std::string shortName () 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
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

EditorCommand for opening documents.

Definition at line 41 of file SaveDocumentCmd.hh.

Constructor & Destructor Documentation

◆ SaveDocumentCmd()

SaveDocumentCmd::SaveDocumentCmd ( )

The Constructor.

Definition at line 44 of file SaveDocumentCmd.cc.

Referenced by create().

◆ ~SaveDocumentCmd()

SaveDocumentCmd::~SaveDocumentCmd ( )
virtual

The Destructor.

Definition at line 53 of file SaveDocumentCmd.cc.

53 {}

Member Function Documentation

◆ create()

SaveDocumentCmd * SaveDocumentCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 102 of file SaveDocumentCmd.cc.

102  {
103  return new SaveDocumentCmd();
104 }

References SaveDocumentCmd().

Here is the call graph for this function:

◆ Do()

bool SaveDocumentCmd::Do ( )
virtual

Executes the command.

Returns
Always false. Returning true here would cause problems with the wxCommandProcessor, and the command is never undoable so it's safe to return false even if the command was succesfully executed.

Implements GUICommand.

Definition at line 64 of file SaveDocumentCmd.cc.

64  {
65  wxDocument* doc = wxGetApp().docManager()->GetCurrentDocument();
66  assert(doc != NULL);
67 
68  // warning: Dirty trick to avoid file dialog on saving a document
69  // already assigned into a specific file name. wxID_SAVE handler
70  // always opens file dialog. Checking that file name does not
71  // contain a . should verify that the document has not been
72  // saved before.
73  wxString currentDocFilename = doc->GetFilename();
74  if (doc->GetFilename().Find('.') == -1) {
75  wxCommandEvent dummy(wxID_SAVE, 0);
76  wxGetApp().docManager()->OnFileSave(dummy);
77  } else {
78  doc->OnSaveDocument(currentDocFilename);
79  }
80 
81  return false;
82 }

References assert, and dummy.

◆ icon()

string SaveDocumentCmd::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 124 of file SaveDocumentCmd.cc.

124  {
126 }

References ProDeConstants::CMD_ICON_SAVE_DOC.

◆ id()

int SaveDocumentCmd::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 91 of file SaveDocumentCmd.cc.

91  {
93 }

References ProDeConstants::COMMAND_SAVE_DOC.

◆ isEnabled()

bool SaveDocumentCmd::isEnabled ( )
virtual

Returns true when the command is executable, false when not.

This command is executable when a document is open.

Returns
True, if a document is open.

Reimplemented from EditorCommand.

Definition at line 137 of file SaveDocumentCmd.cc.

137  {
138  wxDocument* doc = wxGetApp().docManager()->GetCurrentDocument();
139  if (doc != NULL && doc->IsModified()) {
140  return true;
141  }
142  return false;
143 }

◆ shortName()

string SaveDocumentCmd::shortName ( ) const
virtual

Returns short version of the command name.

Returns
Short name of the command to be used in the toolbar.

Reimplemented from GUICommand.

Definition at line 113 of file SaveDocumentCmd.cc.

113  {
115 }

References ProDeConstants::CMD_SNAME_SAVE_DOC.


The documentation for this class was generated from the following files:
ProDeConstants::CMD_NAME_SAVE_DOC
static const std::string CMD_NAME_SAVE_DOC
Command name for the "Save Document" command.
Definition: ProDeConstants.hh:80
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
ProDeConstants::CMD_ICON_SAVE_DOC
static const std::string CMD_ICON_SAVE_DOC
Icon location for the "Save Document" command.
Definition: ProDeConstants.hh:292
assert
#define assert(condition)
Definition: Application.hh:86
ProDeConstants::COMMAND_SAVE_DOC
@ COMMAND_SAVE_DOC
Definition: ProDeConstants.hh:410
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
ProDeConstants::CMD_SNAME_SAVE_DOC
static const std::string CMD_SNAME_SAVE_DOC
Command name for the "Save Document" command.
Definition: ProDeConstants.hh:194
SaveDocumentCmd::SaveDocumentCmd
SaveDocumentCmd()
Definition: SaveDocumentCmd.cc:44