OpenASIP  2.0
MachineDialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2015 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 MachineDialog.cc
26  *
27  * Implementation of MachineDialog class.
28  *
29  * Created on: 6.2.2015
30  * @author: Henry Linjamäki (henry.linjamaki-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #include <wx/statline.h>
35 
36 #include "MachineDialog.hh"
37 
38 #include "Machine.hh"
39 
40 BEGIN_EVENT_TABLE(MachineDialog, wxDialog)
44 
45 /// Indexes for endianess choices
47 
48 /**
49  * The Constructor.
50  *
51  * @param parent Parent window of the dialog.
52  * @param machine The machine to modify.
53  */
55  wxDialog(parent, -1, _T(""), wxDefaultPosition),
56  machine_(machine) {
57 
58  createContents(this, true, true);
59  SetTitle(wxT("Architecture Features"));
60  endianessChoise_->Append(wxT("Big-endian"));
61  endianessChoise_->Append(wxT("Little-endian"));
63 }
64 
65 
66 /**
67  * The Destructor.
68  */
70 
71 }
72 
73 
74 /**
75  * Transfers data from the port object to the dialog widgets.
76  *
77  * @return False, if an error occured in the transfer.
78  */
79 bool
81  assert(endianessChoise_->GetCount() > 1); // Assume
82  if (machine_.isLittleEndian()) {
83  endianessChoise_->SetSelection(LITTLEENDIAN);
84  } else {
85  endianessChoise_->SetSelection(BIGENDIAN);
86  }
87 
88  return wxWindow::TransferDataToWindow();
89 }
90 
91 
92 /**
93  * Event handler for Ok button press.
94  */
95 void
96 MachineDialog::onOK(wxCommandEvent& /*event*/) {
98  EndModal(wxID_OK);
99 }
100 
101 
102 /**
103  * Event handler for Cancel button press.
104  */
105 void
106 MachineDialog::onCancel(wxCommandEvent& /*event*/) {
107  EndModal(wxID_CANCEL);
108 }
109 
110 
111 /**
112  * Creates contents of the dialog window.
113  *
114  * @param parent Parent dialog of the contents.
115  * @param call_fit If true, fits sizer in dialog window.
116  * @param set_sizer If true, sets sizer as dialog's sizer.
117  * @return Top level sizer of the contents.
118  */
119 wxSizer*
121  wxWindow *parent, bool call_fit, bool set_sizer) {
122 
123  wxBoxSizer *root = new wxBoxSizer(wxVERTICAL);
124  wxFlexGridSizer *machSettings = new wxFlexGridSizer(2, 0, 0);
125 
126  // Global Endianess Setting //
127  // Label
128  wxStaticText *endianessLabel = new wxStaticText(parent, -1,
129  wxT("Endianess:"), wxDefaultPosition, wxDefaultSize, 0 );
130  machSettings->Add(endianessLabel,
131  0, wxALIGN_RIGHT|wxALL, 5);
132  // Choice
133  endianessChoise_ = new wxChoice(parent, ID_ENDIANESS_CHOICE,
134  wxDefaultPosition, wxDefaultSize);
135  machSettings->Add(endianessChoise_,
136  0, wxALL, 5);
137 
138  root->Add(machSettings, 0, wxALIGN_CENTER|wxALL, 5);
139 
140  // Buttons //
141  wxStaticLine *horizLine = new wxStaticLine(parent, wxID_ANY,
142  wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL);
143  root->Add(horizLine, 0, wxGROW|wxALL, 5);
144  wxBoxSizer *buttonBox = new wxBoxSizer(wxHORIZONTAL);
145  // Ok button
146  wxButton *okButton =
147  new wxButton(parent, wxID_OK, wxT("&OK"), wxDefaultPosition,
148  wxDefaultSize, 0);
149  buttonBox->Add(okButton, 0, wxALIGN_CENTER|wxALL, 5);
150  // Cancel Button
151  wxButton *cancelButton =
152  new wxButton(parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition,
153  wxDefaultSize, 0);
154  buttonBox->Add(cancelButton, 0, wxALIGN_CENTER|wxALL, 5);
155  root->Add(buttonBox, 0, wxALIGN_CENTER|wxALL, 5);
156 
157  if (set_sizer) {
158  parent->SetAutoLayout(TRUE);
159  parent->SetSizer(root);
160  if (call_fit)
161  {
162  root->Fit(parent);
163  root->SetSizeHints(parent);
164  }
165  }
166  return root;
167 }
168 
169 
MachineDialog
Definition: MachineDialog.hh:48
EndianessChoice
EndianessChoice
Indexes for endianess choices.
Definition: MachineDialog.cc:46
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
MachineDialog::machine_
TTAMachine::Machine & machine_
The machine to modify.
Definition: MachineDialog.hh:60
MachineDialog::ID_ENDIANESS_CHOICE
@ ID_ENDIANESS_CHOICE
Definition: MachineDialog.hh:64
BIGENDIAN
@ BIGENDIAN
Definition: MachineDialog.cc:46
TTAMachine::Machine::isLittleEndian
bool isLittleEndian() const
Definition: Machine.hh:258
MachineDialog::~MachineDialog
virtual ~MachineDialog()
Definition: MachineDialog.cc:69
assert
#define assert(condition)
Definition: Application.hh:86
MachineDialog::TransferDataToWindow
virtual bool TransferDataToWindow()
Definition: MachineDialog.cc:80
Machine.hh
TRUE
const string TRUE
Value used for true in attribute and element values.
Definition: GUIOptionsSerializer.cc:65
MachineDialog.hh
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
MachineDialog::onCancel
void onCancel(wxCommandEvent &event)
Definition: MachineDialog.cc:106
TTAMachine::Machine::setLittleEndian
void setLittleEndian(bool flag)
Definition: Machine.hh:259
MachineDialog::endianessChoise_
wxChoice * endianessChoise_
Definition: MachineDialog.hh:61
LITTLEENDIAN
@ LITTLEENDIAN
Definition: MachineDialog.cc:46
MachineDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: MachineDialog.cc:120
MachineDialog::onOK
void onOK(wxCommandEvent &event)
Definition: MachineDialog.cc:96
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
TTAMachine::Machine
Definition: Machine.hh:73
MachineDialog::MachineDialog
MachineDialog(wxWindow *parent, TTAMachine::Machine &machine)
Definition: MachineDialog.cc:54