OpenASIP  2.0
CloseDocumentCmd.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 CloseDocumentCmd.cc
26  *
27  * Definition of CloseDocumentCmd class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2004 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/docview.h>
34 
35 #include "CloseDocumentCmd.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_CLOSE_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  // close the active document
66  wxDocManager* docManager = wxGetApp().docManager();
67  wxDocument *doc = docManager->GetCurrentDocument();
68  if (!doc)
69  return false;
70  if (doc->Close()) {
71  doc->DeleteAllViews();
72  }
73  return false;
74 }
75 
76 
77 /**
78  * Returns id of this command.
79  *
80  * @return ID for this command to be used in menus and toolbars.
81  */
82 int
85 }
86 
87 
88 /**
89  * Creates and returns a new instance of this command.
90  *
91  * @return Newly created instance of this command.
92  */
95  return new CloseDocumentCmd();
96 }
97 
98 
99 /**
100  * Returns short version of the command name.
101  *
102  * @return Short name of the command to be used in the toolbar.
103  */
104 string
107 }
108 
109 /**
110  * Returns path to the command's icon file.
111  *
112  * @return Full path to the command's icon file.
113  */
114 string
117 }
118 
119 
120 /**
121  * Returns true when the command is executable, false when not.
122  *
123  * This command is executable when a document is open.
124  *
125  * @return True, if a document is open.
126  */
127 bool
129  wxDocManager* manager = wxGetApp().docManager();
130  if (manager->GetCurrentView() != NULL) {
131  return true;
132  }
133  return false;
134 }
135 
ProDe.hh
ProDeConstants::CMD_ICON_CLOSE_DOC
static const std::string CMD_ICON_CLOSE_DOC
Icon location for the "Close Document" command.
Definition: ProDeConstants.hh:290
CloseDocumentCmd::~CloseDocumentCmd
virtual ~CloseDocumentCmd()
Definition: CloseDocumentCmd.cc:53
CloseDocumentCmd::icon
virtual std::string icon() const
Definition: CloseDocumentCmd.cc:115
CloseDocumentCmd
Definition: CloseDocumentCmd.hh:41
CloseDocumentCmd.hh
CloseDocumentCmd::shortName
virtual std::string shortName() const
Definition: CloseDocumentCmd.cc:105
CloseDocumentCmd::isEnabled
virtual bool isEnabled()
Definition: CloseDocumentCmd.cc:128
CloseDocumentCmd::id
virtual int id() const
Definition: CloseDocumentCmd.cc:83
ProDeConstants::COMMAND_CLOSE_DOC
@ COMMAND_CLOSE_DOC
Definition: ProDeConstants.hh:409
ProDeConstants.hh
ProDeConstants::CMD_SNAME_CLOSE_DOC
static const std::string CMD_SNAME_CLOSE_DOC
Command name for the "Close Document" command.
Definition: ProDeConstants.hh:200
EditorCommand
Definition: EditorCommand.hh:46
ProDeConstants
Definition: ProDeConstants.hh:43
CloseDocumentCmd::Do
virtual bool Do()
Definition: CloseDocumentCmd.cc:64
CloseDocumentCmd::create
virtual CloseDocumentCmd * create() const
Definition: CloseDocumentCmd.cc:94
CloseDocumentCmd::CloseDocumentCmd
CloseDocumentCmd()
Definition: CloseDocumentCmd.cc:44