OpenASIP 2.2
Loading...
Searching...
No Matches
ResultDialog.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 ResultDialog.cc
26 *
27 * Definition of ResultDialog 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 "ResultDialog.hh"
36#include "OSEdTextGenerator.hh"
37#include "GUITextGenerator.hh"
38#include "WxConversion.hh"
39#include "WidgetTools.hh"
40#include "DialogPosition.hh"
41#include "ErrorDialog.hh"
42#include "CommandThread.hh"
43#include "FileSystem.hh"
44#include "OSEd.hh"
45#include "OSEdOptions.hh"
46
47using boost::format;
48using std::string;
49using std::vector;
50
51BEGIN_EVENT_TABLE(ResultDialog, wxDialog)
52 EVT_BUTTON(ID_BUTTON_OPEN, ResultDialog::onOpen)
54
55/**
56 * Constructor.
57 *
58 * @param parent Parent window.
59 */
61 wxWindow* parent,
62 std::vector<std::string> output,
63 const std::string& title,
64 const std::string& module) :
65 wxDialog(parent, -1, _T(""),
66 DialogPosition::getPosition(DialogPosition::DIALOG_RESULT),
67 wxDefaultSize, wxRESIZE_BORDER),
68 output_(output), module_(module) {
69
70 createContents(this, true, true);
71 result_ = dynamic_cast<wxTextCtrl*>(FindWindow(ID_RESULT));
72 result_->SetEditable(false);
73
74 FindWindow(wxID_OK)->SetFocus();
75 SetTitle(WxConversion::toWxString(title));
76 if (module_ == "") {
77 FindWindow(ID_BUTTON_OPEN)->Disable();
78 }
79 setTexts();
80}
81
82/**
83 * Destructor.
84 */
86 int x, y;
87 GetPosition(&x, &y);
88 wxPoint point(x, y);
90}
91
92/**
93 * Set texts to widgets.
94 */
95void
108
109/**
110 * Transfer data to window.
111 *
112 * @return True if transfer is successful.
113 */
114bool
116 for (size_t i = 0; i < output_.size(); i++) {
118 }
119 return wxWindow::TransferDataToWindow();
120}
121
122/**
123 * Handles the event when Open button is pushed.
124 */
125void
126ResultDialog::onOpen(wxCommandEvent&) {
127
129 OSEdOptions* options = wxGetApp().options();
130 string editor = options->editor();
131 if (editor == "") {
133 ErrorDialog error(this, WxConversion::toWxString(fmt.str()));
134 error.ShowModal();
135 } else {
136 if (FileSystem::fileExists(editor)) {
137 string cmd = editor + " " + module_;
138 CommandThread* thread = new CommandThread(cmd);
139 thread->Create();
140 thread->Run();
141 } else {
142 format fmt = texts.text(OSEdTextGenerator::TXT_ERROR_OPEN);
143 fmt % editor;
144 ErrorDialog dialog(this, WxConversion::toWxString(fmt.str()));
145 dialog.ShowModal();
146 }
147 }
148}
149
150/**
151 * Creates the contents of the dialog.
152 *
153 * NOTE! This function was generated by wxDesigner.
154 *
155 * @param parent Parent window.
156 * @param call_fit If true fits the contents inside the dialog.
157 * @param set_sizer If true, sets the main sizer as contents of dialog.
158 * @return The created sizer.
159 */
160wxSizer*
162 wxWindow *parent,
163 bool call_fit,
164 bool set_sizer) {
165
166 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
167
168 wxTextCtrl *item1 = new wxTextCtrl( parent, ID_RESULT, wxT(""), wxDefaultPosition, wxSize(400,100), wxTE_MULTILINE );
169 item0->Add( item1, 1, wxGROW|wxALL, 5 );
170
171 wxBoxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
172
173 wxButton *item3 = new wxButton( parent, ID_BUTTON_OPEN, wxT("Open"), wxDefaultPosition, wxDefaultSize, 0 );
174 item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
175
176 wxButton *item4 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
177 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
178
179 item0->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
180
181 if (set_sizer)
182 {
183 parent->SetSizer( item0 );
184 if (call_fit)
185 item0->SetSizeHints( parent );
186 }
187
188 return item0;
189}
END_EVENT_TABLE() using namespace IDF
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
static void setPosition(Dialogs dialog, wxPoint point)
@ DIALOG_RESULT
Result dialog.
static bool fileExists(const std::string fileName)
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
static OSEdTextGenerator & instance()
@ TXT_ERROR_OPEN
Error when opening fails.
@ TXT_ERROR_NO_EDITOR
Error when no editor is given.
@ TXT_BUTTON_OPEN
Open button label.
virtual ~ResultDialog()
virtual bool TransferDataToWindow()
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
std::string module_
Module which was compiled or empty string, if all modules were compiled.
void onOpen(wxCommandEvent &event)
wxTextCtrl * result_
Result window pointer.
std::vector< std::string > output_
Output of compilation.
virtual boost::format text(int textId)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
static wxString toWxString(const std::string &source)