OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
AddressSpacesDialog Class Reference

#include <AddressSpacesDialog.hh>

Inheritance diagram for AddressSpacesDialog:
Inheritance graph
Collaboration diagram for AddressSpacesDialog:
Collaboration graph

Public Member Functions

 AddressSpacesDialog (wxWindow *parent, TTAMachine::Machine *machine)
 
 ~AddressSpacesDialog ()
 

Private Types

enum  {
  ID_ADD = 10000 , ID_EDIT , ID_HELP , ID_DELETE ,
  ID_LIST , ID_LINE
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
TTAMachine::AddressSpaceselectedAS ()
 
void updateASList ()
 
void onAdd (wxCommandEvent &event)
 
void onActivateAS (wxListEvent &event)
 
void onEdit (wxCommandEvent &event)
 
void onDelete (wxCommandEvent &event)
 
void onASSelection (wxListEvent &event)
 
void onASRightClick (wxListEvent &event)
 
void setTexts ()
 

Private Attributes

TTAMachine::Machinemachine_
 Machine containing the address spaces to list.
 
wxListCtrl * asList_
 List control for listing the address spaces.
 

Detailed Description

Dialog for listing and editing address spaces of the machine.

Definition at line 48 of file AddressSpacesDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_ADD 
ID_EDIT 
ID_HELP 
ID_DELETE 
ID_LIST 
ID_LINE 

Definition at line 71 of file AddressSpacesDialog.hh.

Constructor & Destructor Documentation

◆ AddressSpacesDialog()

AddressSpacesDialog::AddressSpacesDialog ( wxWindow *  parent,
TTAMachine::Machine machine 
)

The Constructor.

Parameters
parentParent window of the dialog.
machineMachine containing the address spaces.

Definition at line 81 of file AddressSpacesDialog.cc.

83 :
84 wxDialog(parent, -1, _T(""), wxDefaultPosition, wxSize(400,300)),
86
87 createContents(this, true, true);
88
89 asList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_LIST));
90
91 FindWindow(ID_EDIT)->Disable();
92 FindWindow(ID_DELETE)->Disable();
93
94 // set texts to widgets
95 setTexts();
96
98}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
wxListCtrl * asList_
List control for listing the address spaces.
TTAMachine::Machine * machine_
Machine containing the address spaces to list.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)

◆ ~AddressSpacesDialog()

AddressSpacesDialog::~AddressSpacesDialog ( )

The Destructor.

Definition at line 104 of file AddressSpacesDialog.cc.

104 {
105}

Member Function Documentation

◆ createContents()

wxSizer * AddressSpacesDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the dialog window contents.

This method was generated with wxDesigner, thus the ugly code and too long lines.

Returns
Main sizer of the created contents.
Parameters
parentThe dialog window.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.

Definition at line 352 of file AddressSpacesDialog.cc.

353{
354 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
355
356 wxListCtrl *item1 = new wxListCtrl( parent, ID_LIST, wxDefaultPosition, wxSize(400,200), wxLC_REPORT|wxLC_SINGLE_SEL );
357 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
358
359 wxGridSizer *item2 = new wxGridSizer( 3, 0, 0 );
360
361 wxButton *item3 = new wxButton( parent, ID_ADD, wxT("&Add..."), wxDefaultPosition, wxDefaultSize, 0 );
362 item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
363
364 wxButton *item4 = new wxButton( parent, ID_EDIT, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
365 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
366
367 wxButton *item5 = new wxButton( parent, ID_DELETE, wxT("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
368 item2->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
369
370 item0->Add( item2, 0, wxGROW, 5 );
371
372 wxStaticLine *item6 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
373 item0->Add( item6, 0, wxGROW|wxALL, 5 );
374
375 wxGridSizer *item7 = new wxGridSizer( 2, 0, 0 );
376
377 wxButton *item8 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
378 item7->Add( item8, 0, wxALL, 5 );
379
380 wxBoxSizer *item9 = new wxBoxSizer( wxHORIZONTAL );
381
382 wxButton *item10 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
383 item9->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
384
385 wxButton *item11 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
386 item9->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
387
388 item7->Add( item9, 0, wxALL, 5 );
389
390 item0->Add( item7, 0, wxGROW, 5 );
391
392 if (set_sizer)
393 {
394 parent->SetSizer( item0 );
395 if (call_fit)
396 item0->SetSizeHints( parent );
397 }
398
399 return item0;
400}

References ID_ADD, ID_DELETE, ID_EDIT, ID_HELP, ID_LINE, and ID_LIST.

◆ onActivateAS()

void AddressSpacesDialog::onActivateAS ( wxListEvent &  event)
private

Handles left mouse button double click on the address space list.

Opens the clicked address space in an AddressSpaceDialog.

Definition at line 233 of file AddressSpacesDialog.cc.

233 {
234 wxCommandEvent dummy;
235 onEdit(dummy);
236}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onEdit(wxCommandEvent &event)

References dummy, and onEdit().

Here is the call graph for this function:

◆ onAdd()

void AddressSpacesDialog::onAdd ( wxCommandEvent &  event)
private

Creates and shows an address space dialog with default values set for adding an address space.

Definition at line 194 of file AddressSpacesDialog.cc.

194 {
195
196 // Generate name for the new AS.
199 int i = 1;
202 while (navigator.hasItem(newName)) {
205 i++;
206 }
207
208 AddressSpace* newAS =
209 new AddressSpace(newName,
213 *machine_);
214
215 AddressSpaceDialog dialog(this, machine_, newAS);
216
217 if (dialog.ShowModal() == wxID_OK) {
218 updateASList();
219 } else {
220 // The dialog was cancelled.
221 delete newAS;
222 }
223}
static std::string toString(const T &source)
static const int DEFAULT_AS_MIN_ADDRESS
Default address space min address.
static const int DEFAULT_AS_MAU_WIDTH
Default address space width.
static const int DEFAULT_AS_MAX_ADDRESS
Default address space max address.
static const std::string COMP_NEW_NAME_PREFIX_AS
Prefix for new address space names.
bool hasItem(const std::string &name) const
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392

References TTAMachine::Machine::addressSpaceNavigator(), ProDeConstants::COMP_NEW_NAME_PREFIX_AS, ModelConstants::DEFAULT_AS_MAU_WIDTH, ModelConstants::DEFAULT_AS_MAX_ADDRESS, ModelConstants::DEFAULT_AS_MIN_ADDRESS, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), machine_, Conversion::toString(), and updateASList().

Here is the call graph for this function:

◆ onASRightClick()

void AddressSpacesDialog::onASRightClick ( wxListEvent &  event)
private

Opens a pop-up menu when right mouse button is pressed on the list.

Parameters
eventInformation about right mouse click event.

Definition at line 320 of file AddressSpacesDialog.cc.

320 {
321
322 asList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
323 wxLIST_STATE_SELECTED);
324
325 wxMenu* contextMenu = new wxMenu();
326
328 format button = prodeTexts->text(
330 contextMenu->Append(
331 ID_EDIT, WxConversion::toWxString(button.str()));
332 button = prodeTexts->text(
334 contextMenu->Append(
335 ID_DELETE, WxConversion::toWxString(button.str()));
336 asList_->PopupMenu(contextMenu, event.GetPoint());
337}
static ProDeTextGenerator * instance()
@ TXT_LABEL_BUTTON_EDIT
Label for &Edit... button.
@ TXT_LABEL_BUTTON_DELETE
Label for &Delete button.
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)

References asList_, ID_DELETE, ID_EDIT, ProDeTextGenerator::instance(), Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_LABEL_BUTTON_DELETE, and ProDeTextGenerator::TXT_LABEL_BUTTON_EDIT.

Here is the call graph for this function:

◆ onASSelection()

void AddressSpacesDialog::onASSelection ( wxListEvent &  event)
private

Disables and enables Edit and Delete buttons under the address space list.

If an address space is selected, buttons are enabled. If no address space is selected the buttons will be disabled.

Definition at line 280 of file AddressSpacesDialog.cc.

280 {
281 if (asList_->GetSelectedItemCount() != 1) {
282 FindWindow(ID_DELETE)->Disable();
283 FindWindow(ID_EDIT)->Disable();
284 return;
285 }
286 FindWindow(ID_DELETE)->Enable();
287 FindWindow(ID_EDIT)->Enable();
288}

References asList_, ID_DELETE, and ID_EDIT.

◆ onDelete()

void AddressSpacesDialog::onDelete ( wxCommandEvent &  event)
private

Handles the 'Delete' button event.

Deletes the selected address space.

Definition at line 267 of file AddressSpacesDialog.cc.

267 {
268 delete selectedAS();
269 updateASList();
270}
TTAMachine::AddressSpace * selectedAS()

References selectedAS(), and updateASList().

Here is the call graph for this function:

◆ onEdit()

void AddressSpacesDialog::onEdit ( wxCommandEvent &  event)
private

Handles the 'Edit' button event.

Opens an AddressSpaceDialog with the selected address space's attributes set.

Definition at line 246 of file AddressSpacesDialog.cc.

246 {
247
248 AddressSpace* selected = selectedAS();
249 if (selected == NULL) {
250 // No address space selected.
251 return;
252 }
253
254 AddressSpaceDialog dialog(this, machine_, selectedAS());
255
256 dialog.ShowModal();
257 updateASList();
258}

References machine_, selectedAS(), and updateASList().

Referenced by onActivateAS().

Here is the call graph for this function:

◆ selectedAS()

AddressSpace * AddressSpacesDialog::selectedAS ( )
private

Returns pointer to the AddressSpace, which is selected on the list.

Returns
The selected address space, or NULL if no address space is selected.

Definition at line 166 of file AddressSpacesDialog.cc.

166 {
167
168 long item = -1;
169 item = asList_->GetNextItem(
170 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
171
172 if (item == -1) {
173 return NULL;
174 }
175
176 string asName = WxConversion::toString(asList_->GetItemText(item));
179
180 if (!navigator.hasItem(asName)) {
181 return NULL;
182 }
183
184 return navigator.item(asName);
185
186}
ComponentType * item(int index) const
static std::string toString(const wxString &source)

References TTAMachine::Machine::addressSpaceNavigator(), asList_, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, and WxConversion::toString().

Referenced by onDelete(), and onEdit().

Here is the call graph for this function:

◆ setTexts()

void AddressSpacesDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 112 of file AddressSpacesDialog.cc.

112 {
115
116 // Dialog title
117 format fmt = prodeTexts->text(
119 SetTitle(WxConversion::toWxString(fmt.str()));
120
121 // buttons
122 WidgetTools::setLabel(generator, FindWindow(wxID_OK),
124
125 WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
127
130
133
136
139
140 // Create address space list column.
141 wxListCtrl* portList =
142 dynamic_cast<wxListCtrl*>(FindWindow(ID_LIST));
143 fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
144 portList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
145 wxLIST_FORMAT_LEFT, 100);
146 fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_MAU);
147 portList->InsertColumn(1, WxConversion::toWxString(fmt.str()),
148 wxLIST_FORMAT_LEFT, 40);
150 portList->InsertColumn(2, WxConversion::toWxString(fmt.str()),
151 wxLIST_FORMAT_LEFT, 90);
153 portList->InsertColumn(3, WxConversion::toWxString(fmt.str()),
154 wxLIST_FORMAT_LEFT, 90);
156 portList->InsertColumn(4, WxConversion::toWxString(fmt.str()),
157 wxLIST_FORMAT_LEFT, 80);
158}
@ TXT_BUTTON_EDIT_DIALOG
Label for edit button (with trailing ...).
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_DELETE
Label for delete button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
@ TXT_COLUMN_MAX_ADDRESS
Label for max-address column.
@ TXT_COLUMN_MIN_ADDRESS
Label for min-address column.
@ TXT_ADDRESS_SPACES_DIALOG_TITLE
Address spaces dialog title.
@ TXT_COLUMN_MAU
Label for MAU column in a list.
@ TXT_COLUMN_BIT_WIDTH
Label for bit width column in a list.
@ TXT_COLUMN_NAME
Label for name column in a list.
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_ADD, ID_DELETE, ID_EDIT, ID_HELP, ID_LIST, GUITextGenerator::instance(), ProDeTextGenerator::instance(), WidgetTools::setLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_ADDRESS_SPACES_DIALOG_TITLE, GUITextGenerator::TXT_BUTTON_ADD_DIALOG, GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_DELETE, GUITextGenerator::TXT_BUTTON_EDIT_DIALOG, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_COLUMN_BIT_WIDTH, ProDeTextGenerator::TXT_COLUMN_MAU, ProDeTextGenerator::TXT_COLUMN_MAX_ADDRESS, ProDeTextGenerator::TXT_COLUMN_MIN_ADDRESS, and ProDeTextGenerator::TXT_COLUMN_NAME.

Here is the call graph for this function:

◆ updateASList()

void AddressSpacesDialog::updateASList ( )
private

Updates the address space list.

Definition at line 295 of file AddressSpacesDialog.cc.

295 {
296
299
300 asList_->DeleteAllItems();
301
302 for (int i = 0; i < asNavigator.count(); i++) {
303 AddressSpace* as = asNavigator.item(i);
304 int bitWidth = MathTools::requiredBits(as->end());
305 asList_->InsertItem(i, WxConversion::toWxString(as->name()));
306 asList_->SetItem(i, 1, WxConversion::toWxString(as->width()));
307 asList_->SetItem(i, 2, WxConversion::toWxString(as->start()));
308 asList_->SetItem(i, 3, WxConversion::toWxString(as->end()));
309 asList_->SetItem(i, 4, WxConversion::toWxString(bitWidth));
310 }
311}
static int requiredBits(unsigned long int number)
virtual ULongWord end() const
virtual int width() const
virtual ULongWord start() const
virtual TCEString name() const

References TTAMachine::Machine::addressSpaceNavigator(), asList_, TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::AddressSpace::end(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, TTAMachine::Component::name(), MathTools::requiredBits(), TTAMachine::AddressSpace::start(), WxConversion::toWxString(), and TTAMachine::AddressSpace::width().

Referenced by onAdd(), onDelete(), and onEdit().

Here is the call graph for this function:

Member Data Documentation

◆ asList_

wxListCtrl* AddressSpacesDialog::asList_
private

List control for listing the address spaces.

Definition at line 68 of file AddressSpacesDialog.hh.

Referenced by onASRightClick(), onASSelection(), selectedAS(), and updateASList().

◆ machine_

TTAMachine::Machine* AddressSpacesDialog::machine_
private

Machine containing the address spaces to list.

Definition at line 66 of file AddressSpacesDialog.hh.

Referenced by onAdd(), onEdit(), selectedAS(), and updateASList().


The documentation for this class was generated from the following files: