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

#include <NewDocumentCmd.hh>

Inheritance diagram for NewDocumentCmd:
Inheritance graph
Collaboration diagram for NewDocumentCmd:
Collaboration graph

Public Member Functions

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

Constructor & Destructor Documentation

◆ NewDocumentCmd()

NewDocumentCmd::NewDocumentCmd ( )

The Constructor.

Definition at line 45 of file NewDocumentCmd.cc.

Referenced by create().

◆ ~NewDocumentCmd()

NewDocumentCmd::~NewDocumentCmd ( )
virtual

The Destructor.

Definition at line 54 of file NewDocumentCmd.cc.

54 {}

Member Function Documentation

◆ create()

NewDocumentCmd * NewDocumentCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 110 of file NewDocumentCmd.cc.

110  {
111  return new NewDocumentCmd();
112 }

References NewDocumentCmd().

Here is the call graph for this function:

◆ Do()

bool NewDocumentCmd::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 65 of file NewDocumentCmd.cc.

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

◆ icon()

string NewDocumentCmd::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 132 of file NewDocumentCmd.cc.

132  {
134 }

References ProDeConstants::CMD_ICON_NEW_DOC.

◆ id()

int NewDocumentCmd::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 99 of file NewDocumentCmd.cc.

99  {
101 }

References ProDeConstants::COMMAND_NEW_DOC.

◆ isEnabled()

bool NewDocumentCmd::isEnabled ( )
virtual

This command is always executable.

Returns
Always true.

Reimplemented from EditorCommand.

Definition at line 143 of file NewDocumentCmd.cc.

143  {
144  return true;
145 }

◆ shortName()

string NewDocumentCmd::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 121 of file NewDocumentCmd.cc.

121  {
123 }

References ProDeConstants::CMD_SNAME_NEW_DOC.


The documentation for this class was generated from the following files:
ProDeConstants::COMMAND_NEW_DOC
@ COMMAND_NEW_DOC
Definition: ProDeConstants.hh:407
ProDeConstants::CMD_SNAME_NEW_DOC
static const std::string CMD_SNAME_NEW_DOC
Command name for the "New Document" command.
Definition: ProDeConstants.hh:192
ProDeConstants::CMD_ICON_NEW_DOC
static const std::string CMD_ICON_NEW_DOC
Icon location for the "New Document" command.
Definition: ProDeConstants.hh:296
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
NewDocumentCmd::NewDocumentCmd
NewDocumentCmd()
Definition: NewDocumentCmd.cc:45
ProDeConstants::CMD_NAME_NEW_DOC
static const std::string CMD_NAME_NEW_DOC
Command name for the "New Document" command.
Definition: ProDeConstants.hh:74