OpenASIP 2.2
Loading...
Searching...
No Matches
RFPortImplementationDialog.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 RFPortImplementationDialog.cc
26 *
27 * Implementation of RFPortImplementationDialog class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include <wx/statline.h>
34#include <wx/valgen.h>
37#include "WxConversion.hh"
38#include "ErrorDialog.hh"
39
40using namespace HDB;
41
42BEGIN_EVENT_TABLE(RFPortImplementationDialog, wxDialog)
45
46/**
47 * The Constructor.
48 *
49 * @param parent Parent window of the dialog.
50 * @param id Window identifier for the dialog window.
51 * @param port RF port implementation to modify.
52 */
54 wxWindow* parent, wxWindowID id, RFPortImplementation& port) :
55 wxDialog(parent, id, _T("Register File Port Implementation")),
56 port_(port) {
57
58 createContents(this, true, true);
59
60 name_ = WxConversion::toWxString(port_.name());
61 loadPort_ = WxConversion::toWxString(port_.loadPort());
62 opcodePort_ = WxConversion::toWxString(port_.opcodePort());
63 opcodePortWidth_ =
64 WxConversion::toWxString(port_.opcodePortWidthFormula());
65
66 direction_ = port_.direction();
67
68 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
69 FindWindow(ID_LOAD_PORT)->SetValidator(
70 wxTextValidator(wxFILTER_ASCII, &loadPort_));
71 FindWindow(ID_OPCODE_PORT)->SetValidator(
72 wxTextValidator(wxFILTER_ASCII, &opcodePort_));
73 FindWindow(ID_OPCODE_PORT_WIDTH)->SetValidator(
74 wxTextValidator(wxFILTER_ASCII, &opcodePortWidth_));
75 FindWindow(ID_DIRECTION)->SetValidator(wxGenericValidator(&direction_));
76
77 TransferDataToWindow();
78}
79
80/**
81 * The Destructor.
82 */
85
86/**
87 * Event handler for the dialog OK-button.
88 */
89void
91
92 TransferDataFromWindow();
93
94 name_ = name_.Trim(true).Trim(false);
95 loadPort_ = loadPort_.Trim(true).Trim(false);
96 opcodePort_ = opcodePort_.Trim(true).Trim(false);
97 opcodePortWidth_ = opcodePortWidth_.Trim(true).Trim(false);
98
99 if (name_.IsEmpty()) {
100 wxString message = _T("Name field must not be empty.");
101 ErrorDialog dialog(this, message);
102 dialog.ShowModal();
103 return;
104 }
105
110
111 if (direction_ == 0) {
113 } else if (direction_ == 1) {
115 } else if (direction_ == 2) {
117 } else {
118 assert(false);
119 }
120 EndModal(wxID_OK);
121
122}
123
124/**
125 * Creates the dialog contents.
126 */
127wxSizer*
129 wxWindow *parent, bool call_fit, bool set_sizer) {
130
131 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
132
133 wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
134
135 wxFlexGridSizer *item2 = new wxFlexGridSizer( 2, 0, 0 );
136
137 wxStaticText *item3 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
138 item2->Add( item3, 0, wxALL, 5 );
139
140 wxTextCtrl *item4 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
141 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
142
143 wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_LOAD_PORT, wxT("Load port:"), wxDefaultPosition, wxDefaultSize, 0 );
144 item2->Add( item5, 0, wxALL, 5 );
145
146 wxTextCtrl *item6 = new wxTextCtrl( parent, ID_LOAD_PORT, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
147 item2->Add( item6, 0, wxGROW|wxALL, 5 );
148
149 wxStaticText *item7 = new wxStaticText( parent, ID_LABEL_OPCODE_PORT, wxT("Opcode port:"), wxDefaultPosition, wxDefaultSize, 0 );
150 item2->Add( item7, 0, wxALL, 5 );
151
152 wxTextCtrl *item8 = new wxTextCtrl( parent, ID_OPCODE_PORT, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
153 item2->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
154
155 wxStaticText *item9 = new wxStaticText( parent, ID_LABEL_OPCODE_PORT_WIDTH, wxT("Opcode port width formula:"), wxDefaultPosition, wxDefaultSize, 0 );
156 item2->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
157
158 wxTextCtrl *item10 = new wxTextCtrl( parent, ID_OPCODE_PORT_WIDTH, wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
159 item2->Add( item10, 0, wxGROW|wxALL, 5 );
160
161 item1->Add( item2, 0, wxGROW|wxALL, 5 );
162
163 wxString strs11[] =
164 {
165 wxT("In"),
166 wxT("Out"),
167 wxT("Bidirectional")
168 };
169 wxRadioBox *item11 = new wxRadioBox( parent, ID_DIRECTION, wxT("Direction:"), wxDefaultPosition, wxDefaultSize, 3, strs11, 1, wxRA_SPECIFY_COLS );
170 item1->Add( item11, 0, wxGROW|wxALL, 5 );
171
172 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
173
174 wxStaticLine *item12 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
175 item0->Add( item12, 0, wxGROW|wxALL, 5 );
176
177 wxBoxSizer *item13 = new wxBoxSizer( wxHORIZONTAL );
178
179 wxButton *item14 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
180 item13->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
181
182 wxButton *item15 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
183 item13->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
184
185 item0->Add( item13, 0, wxALL, 5 );
186
187 if (set_sizer)
188 {
189 parent->SetSizer( item0 );
190 if (call_fit)
191 item0->SetSizeHints( parent );
192 }
193
194 return item0;
195}
#define assert(condition)
END_EVENT_TABLE() using namespace IDF
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
void setLoadPort(const std::string &name)
void setName(const std::string &name)
void setOpcodePortWidthFormula(const std::string &formula)
void setDirection(Direction direction)
void setOpcodePort(const std::string &name)
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Creates the dialog contents.
void onOK(wxCommandEvent &event)
HDB::RFPortImplementation & port_
FU port implementation to modify.
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)
@ OUT
Output port.
Definition HDBTypes.hh:42
@ BIDIR
Bidirectional port.
Definition HDBTypes.hh:43
@ IN
Input port.
Definition HDBTypes.hh:41