OpenASIP  2.0
VariableDialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2017 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 * Implementation of VariableDialog.
26 *
27 *@author Lasse Lehtonen 2017 (lasse.lehtonen-no.spam-tut.fi)
28 */
29 
30 #include "VariableDialog.hh"
31 
32 BEGIN_EVENT_TABLE(VariableDialog, wxDialog)
35 
36 VariableDialog::VariableDialog(wxListCtrl* list, std::string language)
37  : wxDialog(NULL, -1, "Add Variable for Operation Implementation",
38  wxDefaultPosition, wxSize(360, 140), wxRESIZE_BORDER),
39  varList_(list), language_(language) {
40 
41  wxButton* okButton = new wxButton(
42  this, wxID_OK, wxT("Ok"), wxDefaultPosition, wxSize(70, 30));
43 
44  wxButton* closeButton = new wxButton(
45  this, wxID_CANCEL, wxT("Cancel"), wxDefaultPosition, wxSize(70, 30));
46 
47  wxBoxSizer* hbox1 = new wxBoxSizer(wxHORIZONTAL);
48  hbox1->Add(okButton, 1);
49  hbox1->Add(closeButton, 1, wxLEFT, 5);
50 
51  nameCtrl_ = new wxTextCtrl(this, -1);
52  widthCtrl_ = new wxTextCtrl(this, -1);
53  if (language_ == "VHDL") {
54  wxString strs[] = {wxT("Logic"), wxT("Unsigned"), wxT("Signed")};
55  typeCtrl_ = new wxComboBox(this, -1, wxT(""), wxDefaultPosition,
56  wxDefaultSize, 3, strs, wxCB_READONLY);
57  } else {
58  wxString strs[] = {wxT("Unsigned"), wxT("Signed")};
59  typeCtrl_ = new wxComboBox(this, -1, wxT(""), wxDefaultPosition,
60  wxDefaultSize, 2, strs, wxCB_READONLY);
61  }
62  typeCtrl_->SetSelection(0);
63 
64  wxStaticText* title1 = new wxStaticText(this, -1, wxT("Name"));
65  wxStaticText* title2 = new wxStaticText(this, -1, wxT("Width"));
66  wxStaticText* title3 = new wxStaticText(this, -1, wxT("Type"));
67 
68  wxFlexGridSizer* flex1 = new wxFlexGridSizer(2, 3, 9, 25);
69  flex1->Add(title1);
70  flex1->Add(title2);
71  flex1->Add(title3);
72  flex1->Add(nameCtrl_);
73  flex1->Add(widthCtrl_);
74  flex1->Add(typeCtrl_);
75 
76  wxBoxSizer* vbox = new wxBoxSizer(wxVERTICAL);
77  vbox->Add(flex1, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxBOTTOM, 10);
78  vbox->Add(hbox1, 0, wxALIGN_CENTER | wxTOP | wxBOTTOM, 10);
79 
80  SetSizer(vbox);
81  Centre();
82  ShowModal();
83  Destroy();
84 }
85 
86 void
87 VariableDialog::onOK(wxCommandEvent&) {
88  int idx = varList_->GetItemCount();
89  varList_->InsertItem(idx, nameCtrl_->GetLineText(0));
90  varList_->SetItem(idx, 1, widthCtrl_->GetLineText(0));
91  varList_->SetItem(
92  idx, 2, typeCtrl_->GetString(typeCtrl_->GetSelection()));
93  varList_->SetItem(idx, 3, language_);
94  EndModal(wxID_OK);
95 }
VariableDialog::nameCtrl_
wxTextCtrl * nameCtrl_
Definition: VariableDialog.hh:42
VariableDialog.hh
VariableDialog::language_
std::string language_
Definition: VariableDialog.hh:46
VariableDialog
Definition: VariableDialog.hh:34
VariableDialog::onOK
void onOK(wxCommandEvent &)
Definition: VariableDialog.cc:87
VariableDialog::varList_
wxListCtrl * varList_
Definition: VariableDialog.hh:45
Operation
Definition: Operation.hh:59
VariableDialog::typeCtrl_
wxComboBox * typeCtrl_
Definition: VariableDialog.hh:44
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
VariableDialog::widthCtrl_
wxTextCtrl * widthCtrl_
Definition: VariableDialog.hh:43
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF