OpenASIP  2.0
OSEdUserManualCmd.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 OSEdUserManualCmd.cc
26  *
27  * Definition of OSEdUserManualCmd class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <boost/format.hpp>
34 
35 #include "OSEdUserManualCmd.hh"
36 #include "OSEdConstants.hh"
37 #include "Environment.hh"
38 #include "FileSystem.hh"
39 #include "HelpBrowser.hh"
40 #include "OSEdTextGenerator.hh"
41 #include "WxConversion.hh"
42 
43 using std::string;
44 using boost::format;
45 
46 /**
47  * Constructor.
48  */
50  GUICommand(OSEdConstants::CMD_NAME_USER_MANUAL, NULL) {
51 }
52 
53 /**
54  * Destructor.
55  */
57 }
58 
59 /**
60  * Returns the id of the command.
61  *
62  * @return The id of the command.
63  */
64 int
67 }
68 
69 /**
70  * Creates new command.
71  *
72  * @return New command.
73  */
76  return new OSEdUserManualCmd();
77 }
78 
79 /**
80  * Executes the command.
81  *
82  * @return True if execution is successful.
83  */
84 bool
86 
87  string manualFile = userManual();
88 
91 
92  HelpBrowser* browser = new HelpBrowser(
93  WxConversion::toWxString(fmt.str()),
94  WxConversion::toWxString(manualFile), wxDefaultPosition,
95  wxSize(800, 600));
96 
97  browser->Show(true);
98  return true;
99 }
100 
101 /**
102  * Returns true if command is enabled.
103  *
104  * Command is enabled when user manual exists.
105  *
106  * @return True if command is enabled.
107  */
108 bool
110  string manualFile = userManual();
111  return FileSystem::fileExists(manualFile);
112 }
113 
114 /**
115  * Returns the icon path.
116  *
117  * @return Empty string (icons not used).
118  */
119 string
121  return "";
122 }
123 
124 /**
125  * Returns the user manual location.
126  *
127  * @return User manual location.
128  */
129 std::string
131  return Environment::manDirPath("OSALGUI") +
132  FileSystem::DIRECTORY_SEPARATOR + "OSALGUI" +
134 }
OSEdUserManualCmd::isEnabled
virtual bool isEnabled()
Definition: OSEdUserManualCmd.cc:109
FileSystem.hh
WxConversion::toWxString
static wxString toWxString(const std::string &source)
Environment::manDirPath
static std::string manDirPath(const std::string &prog)
Definition: Environment.cc:250
OSEdConstants::USER_MANUAL_NAME
static const std::string USER_MANUAL_NAME
Name of the user manual.
Definition: OSEdConstants.hh:80
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
OSEdUserManualCmd::create
virtual GUICommand * create() const
Definition: OSEdUserManualCmd.cc:75
OSEdConstants.hh
HelpBrowser
Definition: HelpBrowser.hh:42
GUICommand
Definition: GUICommand.hh:43
OSEdConstants
Definition: OSEdConstants.hh:45
OSEdTextGenerator::TXT_USER_MANUAL_TITLE
@ TXT_USER_MANUAL_TITLE
User manual dialog title.
Definition: OSEdTextGenerator.hh:116
OSEdUserManualCmd::Do
virtual bool Do()
Definition: OSEdUserManualCmd.cc:85
Environment.hh
OSEdUserManualCmd::OSEdUserManualCmd
OSEdUserManualCmd()
Definition: OSEdUserManualCmd.cc:49
OSEdUserManualCmd::~OSEdUserManualCmd
virtual ~OSEdUserManualCmd()
Definition: OSEdUserManualCmd.cc:56
OSEdConstants::CMD_USER_MANUAL
@ CMD_USER_MANUAL
User manual command id.
Definition: OSEdConstants.hh:103
OSEdUserManualCmd::id
virtual int id() const
Definition: OSEdUserManualCmd.cc:65
HelpBrowser.hh
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
OSEdUserManualCmd.hh
OSEdUserManualCmd::userManual
std::string userManual() const
Definition: OSEdUserManualCmd.cc:130
FileSystem::fileExists
static bool fileExists(const std::string fileName)
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
WxConversion.hh
OSEdTextGenerator.hh
OSEdUserManualCmd::icon
virtual std::string icon() const
Definition: OSEdUserManualCmd.cc:120