32 #include <wx/valgen.h>
33 #include <boost/format.hpp>
56 BEGIN_EVENT_TABLE(
IUDialog, wxDialog)
84 wxDialog(parent, -1, _T(""), wxDefaultPosition),
85 immediateUnit_(immediateUnit),
94 createContents(
this,
true,
true);
96 portList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PORT_LIST));
97 templateList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_TEMPLATE_LIST));
98 extensionBox_ =
dynamic_cast<wxRadioBox*
>(
FindWindow(ID_EXTENSION));
100 FindWindow(ID_SIZE)->SetValidator(wxGenericValidator(&size_));
101 FindWindow(ID_WIDTH)->SetValidator(wxGenericValidator(&width_));
102 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
112 TransferDataToWindow();
181 wxListCtrl* portList =
182 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PORT_LIST));
185 wxLIST_FORMAT_LEFT, 240);
186 wxListCtrl* templateList =
187 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_TEMPLATE_LIST));
190 wxLIST_FORMAT_LEFT, 240);
204 width_ = immediateUnit_->width();
205 size_ = immediateUnit_->numberOfRegisters();
206 cycles_ = immediateUnit_->latency();
211 extensionBox_->SetStringSelection(zero);
212 }
else if (immediateUnit_->extensionMode() ==
Machine::SIGN) {
214 extensionBox_->SetStringSelection(sign);
220 updateTemplateList();
224 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_WIDTH))->SetValue(width_);
225 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_SIZE))->SetValue(size_);
227 return wxWindow::TransferDataToWindow();
241 if (!TransferDataFromWindow()) {
259 if (trimmedName != immediateUnit_->name()) {
262 immediateUnit_->machine()->immediateUnitNavigator();
263 for (
int i = 0; i < navigator.
count(); i++) {
265 if (trimmedName == iu->
name()) {
270 format an_iu = prodeTexts->
text(
276 message % trimmedName % an_iu.str() %
machine.str() % iu.str();
286 immediateUnit_->setName(trimmedName);
287 immediateUnit_->setNumberOfRegisters(size_);
288 immediateUnit_->setWidth(width_);
290 wxString extension = extensionBox_->GetStringSelection();
311 if (!TransferDataFromWindow()) {
314 wxString trimmedName = name_.Trim(
false).Trim(
true);
315 if (trimmedName == _T(
"")) {
331 item = portList_->GetNextItem(
332 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
341 return immediateUnit_->port(portName);
357 while (immediateUnit_->hasPort(newName)) {
365 if (portDialog.ShowModal() == wxID_OK) {
378 Port* selected = selectedPort();
390 wxCommandEvent
dummy;
403 Port* port = selectedPort();
410 if (portDialog.ShowModal() == wxID_OK) {
425 if (portList_->GetSelectedItemCount() != 1) {
443 portList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
444 wxLIST_STATE_SELECTED);
446 wxMenu* contextMenu =
new wxMenu();
447 contextMenu->Append(ID_EDIT_PORT, _T(
"&Edit..."));
448 contextMenu->Append(ID_DELETE_PORT, _T(
"&Delete"));
449 portList_->PopupMenu(contextMenu, event.GetPoint());
460 portList_->DeleteAllItems();
461 for (
int i=0; i < immediateUnit_->portCount(); i++) {
466 portList_->InsertItem(i, portName);
477 templateList_->DeleteAllItems();
479 immediateUnit_->machine()->instructionTemplateNavigator();
481 for (
int i = 0; i < navigator.
count(); i++) {
482 if (navigator.
item(i)->isOneOfDestinations(*immediateUnit_)) {
486 templateList_->InsertItem(0, name);
505 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
507 wxFlexGridSizer *item1 =
new wxFlexGridSizer( 2, 0, 0 );
509 wxFlexGridSizer *item2 =
new wxFlexGridSizer( 4, 0, 0 );
511 wxStaticText *item3 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
512 item2->Add( item3, 0, wxALIGN_RIGHT|wxALL, 5 );
514 wxTextCtrl *item4 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(120,-1), 0 );
515 item2->Add( item4, 0, wxGROW|wxALL, 5 );
517 wxStaticText *item5 =
new wxStaticText( parent, ID_LABEL_SIZE, wxT(
"Size:"), wxDefaultPosition, wxDefaultSize, 0 );
518 item2->Add( item5, 0, wxALIGN_RIGHT|wxALL, 5 );
520 wxSpinCtrl *item6 =
new wxSpinCtrl( parent, ID_SIZE, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
521 item2->Add( item6, 0, wxGROW|wxALL, 5 );
523 wxStaticText *item7 =
new wxStaticText( parent, ID_LABEL_WIDTH, wxT(
"Width:"), wxDefaultPosition, wxDefaultSize, 0 );
524 item2->Add( item7, 0, wxALIGN_RIGHT|wxALL, 5 );
526 wxSpinCtrl *item8 =
new wxSpinCtrl( parent, ID_WIDTH, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
527 item2->Add( item8, 0, wxGROW|wxALL, 5 );
529 item1->Add( item2, 0, 0, 5 );
536 wxRadioBox *item11 =
new wxRadioBox( parent, ID_EXTENSION, wxT(
"Extension"), wxDefaultPosition, wxDefaultSize, 2, strs11, 1, wxRA_SPECIFY_COLS );
537 item1->Add( item11, 0, wxGROW|wxALL, 5 );
539 wxStaticBox *item13 =
new wxStaticBox( parent, -1, wxT(
"Templates:") );
540 wxStaticBoxSizer *item12 =
new wxStaticBoxSizer( item13, wxVERTICAL );
541 templateListSizer_ = item12;
543 wxListCtrl *item14 =
new wxListCtrl( parent, ID_TEMPLATE_LIST, wxDefaultPosition, wxSize(200,200), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
544 item12->Add( item14, 0, wxGROW|wxALL, 5 );
546 item1->Add( item12, 0, wxGROW|wxALL, 5 );
548 wxStaticBox *item16 =
new wxStaticBox( parent, -1, wxT(
"Ports:") );
549 wxStaticBoxSizer *item15 =
new wxStaticBoxSizer( item16, wxVERTICAL );
550 portListSizer_ = item15;
552 wxListCtrl *item17 =
new wxListCtrl( parent, ID_PORT_LIST, wxDefaultPosition, wxSize(240,150), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
553 item15->Add( item17, 0, wxGROW|wxALL, 5 );
555 wxBoxSizer *item18 =
new wxBoxSizer( wxHORIZONTAL );
557 wxButton *item19 =
new wxButton( parent, ID_ADD_PORT, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
558 item18->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
560 wxButton *item20 =
new wxButton( parent, ID_EDIT_PORT, wxT(
"Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
561 item18->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
563 wxButton *item21 =
new wxButton( parent, ID_DELETE_PORT, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
564 item18->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
566 item15->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
568 item1->Add( item15, 0, wxGROW|wxALL, 5 );
570 item0->Add( item1, 0, wxALL, 5 );
572 wxStaticLine *item22 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
573 item0->Add( item22, 0, wxGROW|wxALL, 5 );
575 wxGridSizer *item23 =
new wxGridSizer( 2, 0, 0 );
577 wxButton *item24 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
578 item23->Add( item24, 0, wxALL, 5 );
580 wxBoxSizer *item25 =
new wxBoxSizer( wxHORIZONTAL );
582 wxButton *item26 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
583 item25->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
585 wxButton *item27 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
586 item25->Add( item27, 0, wxALIGN_CENTER|wxALL, 5 );
588 item23->Add( item25, 0, wxALL, 5 );
590 item0->Add( item23, 0, wxGROW, 5 );
594 parent->SetSizer( item0 );
596 item0->SetSizeHints( parent );