OpenASIP  2.0
OpenDocumentCmd.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 OpenDocumentCmd.cc
26  *
27  * Definition of OpenDocumentCmd class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30  */
31 
32 #include <wx/docmdi.h>
33 #include <wx/msgdlg.h>
34 
35 #include "OpenDocumentCmd.hh"
36 #include "ProDeConstants.hh"
37 #include "ProDe.hh"
38 
39 using std::string;
40 
41 /**
42  * The Constructor.
43  */
45  EditorCommand(ProDeConstants::CMD_NAME_OPEN_DOC) {
46 
47 }
48 
49 
50 /**
51  * The Destructor.
52  */
54 
55 
56 /**
57  * Executes the command.
58  *
59  * @return Always false. Returning true here would cause problems with the
60  * wxCommandProcessor, and the command is never undoable so it's
61  * safe to return false even if the command was succesfully executed.
62  */
63 bool
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 }
90 
91 
92 /**
93  * Returns id of this command.
94  *
95  * @return ID for this command to be used in menus and toolbars.
96  */
97 int
100 }
101 
102 
103 /**
104  * Creates and returns a new instance of this command.
105  *
106  * @return Newly created instance of this command.
107  */
110  return new OpenDocumentCmd();
111 }
112 
113 
114 /**
115  * Returns short version of the command name.
116  *
117  * @return Short name of the command to be used in the toolbar.
118  */
119 string
122 }
123 
124 /**
125  * Returns path to the command's icon file.
126  *
127  * @return Full path to the command's icon file.
128  */
129 string
132 }
133 
134 
135 /**
136  * This command is always executable.
137  *
138  * @return Always true.
139  */
140 bool
142  return true;
143 }
ProDe.hh
OpenDocumentCmd::shortName
virtual std::string shortName() const
Definition: OpenDocumentCmd.cc:120
OpenDocumentCmd::Do
virtual bool Do()
Definition: OpenDocumentCmd.cc:64
OpenDocumentCmd::id
virtual int id() const
Definition: OpenDocumentCmd.cc:98
OpenDocumentCmd
Definition: OpenDocumentCmd.hh:41
ProDeConstants::COMMAND_OPEN_DOC
@ COMMAND_OPEN_DOC
Definition: ProDeConstants.hh:408
ProDeConstants::CMD_SNAME_OPEN_DOC
static const std::string CMD_SNAME_OPEN_DOC
Command name for the "Open Document" command.
Definition: ProDeConstants.hh:198
OpenDocumentCmd::icon
virtual std::string icon() const
Definition: OpenDocumentCmd.cc:130
OpenDocumentCmd::isEnabled
virtual bool isEnabled()
Definition: OpenDocumentCmd.cc:141
ProDeConstants.hh
OpenDocumentCmd::create
virtual OpenDocumentCmd * create() const
Definition: OpenDocumentCmd.cc:109
OpenDocumentCmd::OpenDocumentCmd
OpenDocumentCmd()
Definition: OpenDocumentCmd.cc:44
OpenDocumentCmd::~OpenDocumentCmd
virtual ~OpenDocumentCmd()
Definition: OpenDocumentCmd.cc:53
EditorCommand
Definition: EditorCommand.hh:46
ProDeConstants
Definition: ProDeConstants.hh:43
ProDeConstants::CMD_ICON_OPEN_DOC
static const std::string CMD_ICON_OPEN_DOC
Icon location for the "Open Document" command.
Definition: ProDeConstants.hh:288
OpenDocumentCmd.hh