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

#include <OpenDocumentCmd.hh>

Inheritance diagram for OpenDocumentCmd:
Inheritance graph
Collaboration diagram for OpenDocumentCmd:
Collaboration graph

Public Member Functions

 OpenDocumentCmd ()
 
virtual ~OpenDocumentCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual OpenDocumentCmdcreate () 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 OpenDocumentCmd.hh.

Constructor & Destructor Documentation

◆ OpenDocumentCmd()

OpenDocumentCmd::OpenDocumentCmd ( )

The Constructor.

Definition at line 44 of file OpenDocumentCmd.cc.

Referenced by create().

◆ ~OpenDocumentCmd()

OpenDocumentCmd::~OpenDocumentCmd ( )
virtual

The Destructor.

Definition at line 53 of file OpenDocumentCmd.cc.

53 {}

Member Function Documentation

◆ create()

OpenDocumentCmd * OpenDocumentCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 109 of file OpenDocumentCmd.cc.

109  {
110  return new OpenDocumentCmd();
111 }

References OpenDocumentCmd().

Here is the call graph for this function:

◆ Do()

bool OpenDocumentCmd::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 OpenDocumentCmd.cc.

64  {
65 
66  wxDocManager* docManager = wxGetApp().docManager();
67 
68  // Disable multiple tabs if we're not using wxWidgets 2.8 or above
69  if (wxCHECK_VERSION(2, 8, 0)) {
70  docManager->CreateDocument(_T(""), 0);
71  return false;
72  }
73  else {
74  // close the active document if there is any
75  wxDocument *doc = docManager->GetCurrentDocument();
76  if (doc) {
77  if (doc->Close()) {
78  doc->DeleteAllViews();
79  }
80  else { // cancel was pressed -> cancel the command
81  return false;
82  }
83  }
84  }
85 
86  // Open the document
87  docManager->CreateDocument(_T(""), 0);
88  return false;
89 }

◆ icon()

string OpenDocumentCmd::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 130 of file OpenDocumentCmd.cc.

130  {
132 }

References ProDeConstants::CMD_ICON_OPEN_DOC.

◆ id()

int OpenDocumentCmd::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 98 of file OpenDocumentCmd.cc.

98  {
100 }

References ProDeConstants::COMMAND_OPEN_DOC.

◆ isEnabled()

bool OpenDocumentCmd::isEnabled ( )
virtual

This command is always executable.

Returns
Always true.

Reimplemented from EditorCommand.

Definition at line 141 of file OpenDocumentCmd.cc.

141  {
142  return true;
143 }

◆ shortName()

string OpenDocumentCmd::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 120 of file OpenDocumentCmd.cc.

120  {
122 }

References ProDeConstants::CMD_SNAME_OPEN_DOC.


The documentation for this class was generated from the following files:
ProDeConstants::COMMAND_OPEN_DOC
@ COMMAND_OPEN_DOC
Definition: ProDeConstants.hh:408
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
ProDeConstants::CMD_SNAME_OPEN_DOC
static const std::string CMD_SNAME_OPEN_DOC
Command name for the "Open Document" command.
Definition: ProDeConstants.hh:198
ProDeConstants::CMD_NAME_OPEN_DOC
static const std::string CMD_NAME_OPEN_DOC
Command name for the "Open Document" command.
Definition: ProDeConstants.hh:76
OpenDocumentCmd::OpenDocumentCmd
OpenDocumentCmd()
Definition: OpenDocumentCmd.cc:44
ProDeConstants::CMD_ICON_OPEN_DOC
static const std::string CMD_ICON_OPEN_DOC
Icon location for the "Open Document" command.
Definition: ProDeConstants.hh:288