OpenASIP 2.2
Loading...
Searching...
No Matches
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
40BEGIN_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 */
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 */
79bool
81 assert(endianessChoise_->GetCount() > 1); // Assume
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 */
95void
96MachineDialog::onOK(wxCommandEvent& /*event*/) {
98 EndModal(wxID_OK);
99}
100
101
102/**
103 * Event handler for Cancel button press.
104 */
105void
106MachineDialog::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 */
119wxSizer*
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
#define assert(condition)
END_EVENT_TABLE() using namespace IDF
TTAMachine::Machine * machine
the architecture definition of the estimated processor
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
const string TRUE
Value used for true in attribute and element values.
EndianessChoice
Indexes for endianess choices.
@ LITTLEENDIAN
@ BIGENDIAN
void onOK(wxCommandEvent &event)
MachineDialog(wxWindow *parent, TTAMachine::Machine &machine)
TTAMachine::Machine & machine_
The machine to modify.
virtual bool TransferDataToWindow()
void onCancel(wxCommandEvent &event)
wxChoice * endianessChoise_
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
virtual ~MachineDialog()
void setLittleEndian(bool flag)
Definition Machine.hh:259
bool isLittleEndian() const
Definition Machine.hh:258