33 #include <wx/valgen.h>
34 #include <boost/format.hpp>
57 BEGIN_EVENT_TABLE(
RFDialog, wxDialog)
85 wxDialog(parent, -1, _T(""), wxDefaultPosition),
86 registerFile_(registerFile),
97 createContents(
this,
true,
true);
103 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
105 portListCtrl_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PORT_LIST));
106 typeChoice_ =
dynamic_cast<wxChoice*
>(
FindWindow(ID_TYPE));
109 FindWindow(ID_WIDTH)->SetValidator(wxGenericValidator(&width_));
110 FindWindow(ID_SIZE)->SetValidator(wxGenericValidator(&size_));
112 wxGenericValidator(&guardLatency_));
115 wxGenericValidator(&zeroRegister_));
120 TransferDataToWindow();
197 wxListCtrl* portList =
198 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PORT_LIST));
201 wxLIST_FORMAT_LEFT, 200);
214 return wxWindow::TransferDataToWindow();
228 size_ = registerFile_->numberOfRegisters();
229 width_ = registerFile_->width();
230 maxReads_ = registerFile_->maxReads();
231 maxWrites_ = registerFile_->maxWrites();
232 guardLatency_ = registerFile_->guardLatency();
233 zeroRegister_ = registerFile_->zeroRegister();
235 switch (registerFile_->type()) {
237 typeChoice_->SetSelection(0);
240 typeChoice_->SetSelection(1);
243 typeChoice_->SetSelection(2);
253 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_SIZE))->SetValue(size_);
254 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_WIDTH))->SetValue(width_);
255 dynamic_cast<wxStaticText*
>(
FindWindow(ID_MAX_READS))->SetLabel(
257 dynamic_cast<wxStaticText*
>(
FindWindow(ID_MAX_WRITES))->SetLabel(
259 dynamic_cast<wxSpinCtrl*
>(
260 FindWindow(ID_GUARD_LATENCY))->SetValue(guardLatency_);
261 dynamic_cast<wxCheckBox*
>(
262 FindWindow(ID_ZERO_REGISTER))->SetValue(zeroRegister_);
270 portListCtrl_->DeleteAllItems();
271 for (
int i=0; i < registerFile_->portCount(); i++) {
276 portListCtrl_->InsertItem(i, name);
290 if (!TransferDataFromWindow()) {
308 if (registerFile_->name() != trimmedName) {
311 registerFile_->machine()->registerFileNavigator();
313 for (
int i = 0; i < navigator.
count(); i++) {
315 if (trimmedName == rf->
name()) {
326 message % trimmedName % a_rf.str() %
machine.str() % rf.str();
336 registerFile_->setName(trimmedName);
337 registerFile_->setWidth(width_);
338 registerFile_->setNumberOfRegisters(size_);
339 registerFile_->setGuardLatency(guardLatency_);
340 registerFile_->setZeroRegister(zeroRegister_);
349 switch (typeChoice_->GetSelection()) {
374 if (!TransferDataFromWindow()) {
377 wxString trimmedName = name_.Trim(
false).Trim(
true);
378 if (trimmedName == _T(
"")) {
394 item = portListCtrl_->GetNextItem(
395 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
404 return registerFile_->port(portName);
418 while (registerFile_->hasPort(newName)) {
426 if (portDialog.ShowModal() == wxID_OK) {
442 Port* selected = selectedPort();
456 wxCommandEvent
dummy;
469 Port* port = selectedPort();
476 if (portDialog.ShowModal() == wxID_OK) {
489 if (portListCtrl_->GetSelectedItemCount() != 1) {
507 portListCtrl_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
508 wxLIST_STATE_SELECTED);
510 wxMenu* contextMenu =
new wxMenu();
513 format button = prodeTexts->
text(
517 button = prodeTexts->
text(
521 portListCtrl_->PopupMenu(contextMenu, event.GetPoint());
538 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
540 wxFlexGridSizer *item1 =
new wxFlexGridSizer( 2, 0, 0 );
542 wxStaticText *item2 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
543 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
545 wxTextCtrl *item3 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(200,-1), 0 );
546 item1->Add( item3, 0, wxGROW|wxALL, 5 );
548 wxStaticText *item4 =
new wxStaticText( parent, ID_LABEL_TYPE, wxT(
"Type:"), wxDefaultPosition, wxDefaultSize, 0 );
549 item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
551 wxString *strs5 = (wxString*) NULL;
552 wxChoice *item5 =
new wxChoice( parent, ID_TYPE, wxDefaultPosition, wxSize(100,-1), 0, strs5, 0 );
553 item1->Add( item5, 0, wxGROW|wxALL, 5 );
555 wxStaticText *item6 =
new wxStaticText( parent, ID_LABEL_SIZE, wxT(
"Size:"), wxDefaultPosition, wxDefaultSize, 0 );
556 item1->Add( item6, 0, wxALIGN_RIGHT|wxALL, 5 );
558 wxSpinCtrl *item7 =
new wxSpinCtrl( parent, ID_SIZE, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
559 item1->Add( item7, 0, wxGROW|wxALL, 5 );
561 wxStaticText *item8 =
new wxStaticText( parent, ID_LABEL_WIDTH, wxT(
"Width:"), wxDefaultPosition, wxDefaultSize, 0 );
562 item1->Add( item8, 0, wxALIGN_RIGHT|wxALL, 5 );
564 wxSpinCtrl *item9 =
new wxSpinCtrl( parent, ID_WIDTH, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
565 item1->Add( item9, 0, wxGROW|wxALL, 5 );
567 wxStaticText *item10 =
new wxStaticText( parent, ID_LABEL_MAX_READS, wxT(
"Max-Reads:"), wxDefaultPosition, wxDefaultSize, 0 );
568 item1->Add( item10, 0, wxALIGN_RIGHT|wxALL, 5 );
570 wxStaticText *item11 =
new wxStaticText( parent, ID_MAX_READS, wxT(
"0"), wxDefaultPosition, wxSize(100,-1), 0);
571 item1->Add( item11, 0, wxGROW|wxALL, 5 );
573 wxStaticText *item12 =
new wxStaticText( parent, ID_LABEL_MAX_WRITES, wxT(
"Max-Writes:"), wxDefaultPosition, wxDefaultSize, 0 );
574 item1->Add( item12, 0, wxALIGN_RIGHT|wxALL, 5 );
576 wxStaticText *item13 =
new wxStaticText( parent, ID_MAX_WRITES, wxT(
"0"), wxDefaultPosition, wxSize(100,-1), 0);
577 item1->Add( item13, 0, wxGROW|wxALL, 5 );
579 wxStaticText *item14 =
new wxStaticText( parent, ID_LABEL_GUARD_LATENCY, wxT(
"Guard Latency:"), wxDefaultPosition, wxDefaultSize, 0 );
580 item1->Add( item14, 0, wxALIGN_RIGHT|wxALL, 5 );
582 wxSpinCtrl *item15 =
new wxSpinCtrl( parent, ID_GUARD_LATENCY, wxT(
"0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 1, 0 );
583 item1->Add( item15, 0, wxGROW|wxALL, 5 );
585 item0->Add( item1, 0, wxGROW|wxALL, 5 );
587 wxStaticBox *item17 =
new wxStaticBox( parent, -1, wxT(
"Ports:") );
588 wxStaticBoxSizer *item16 =
new wxStaticBoxSizer( item17, wxVERTICAL );
589 portsSizer_ = item16;
591 wxListCtrl *item18 =
new wxListCtrl( parent, ID_PORT_LIST, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER );
592 item16->Add( item18, 0, wxGROW|wxALL, 5 );
594 wxBoxSizer *item19 =
new wxBoxSizer( wxHORIZONTAL );
596 wxButton *item20 =
new wxButton( parent, ID_ADD_PORT, wxT(
"&Add.."), wxDefaultPosition, wxDefaultSize, 0 );
597 item19->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
599 wxButton *item21 =
new wxButton( parent, ID_EDIT_PORT, wxT(
"&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
600 item19->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
602 wxButton *item22 =
new wxButton( parent, ID_DELETE_PORT, wxT(
"&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
603 item19->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
605 item16->Add( item19, 0, wxALIGN_CENTER|wxLEFT|wxRIGHT, 5 );
607 item0->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
609 wxBoxSizer *item23 =
new wxBoxSizer( wxHORIZONTAL );
611 wxButton *item24 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
612 item23->Add( item24, 0, wxALIGN_CENTER|wxALL, 5 );
614 wxButton *item25 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
615 item23->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
617 wxButton *item26 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
618 item23->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
620 item0->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
622 wxCheckBox *item27 =
new wxCheckBox( parent, ID_ZERO_REGISTER, wxT(
"Zero register"), wxDefaultPosition, wxDefaultSize, 0);
623 item1->Add( item27, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
627 parent->SetSizer( item0 );
629 item0->SetSizeHints( parent );