34 #include <wx/spinctrl.h>
35 #include <wx/listctrl.h>
36 #include <wx/statline.h>
37 #include <wx/valgen.h>
38 #include <boost/format.hpp>
109 wxDialog(parent, -1, _T(""), wxDefaultPosition),
115 createContents(
this,
true,
true);
116 addressSpaceChoice_ =
117 dynamic_cast<wxChoice*
>(
FindWindow(ID_ADDRESS_SPACE));
119 dynamic_cast<wxChoice*
>(
FindWindow(ID_RA_CHOICE));
121 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OPERATION_LIST));
123 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PORT_LIST));
137 wxTextValidator(wxFILTER_ASCII, &name_));
139 wxGenericValidator(&delaySlots_));
143 TransferDataToWindow();
165 string title = fmt.str();
220 wxListCtrl* operationList =
221 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OPERATION_LIST));
223 wxLIST_FORMAT_LEFT, 260);
228 wxLIST_FORMAT_CENTER, 30);
231 wxLIST_FORMAT_CENTER, 40);
234 wxLIST_FORMAT_LEFT, 110);
237 wxLIST_FORMAT_LEFT, 110);
249 delaySlots_ = gcu_->delaySlots();
250 guardLatency_ = gcu_->globalGuardLatency();
251 updateAddressSpaceChoice();
252 updateRAPortChoice();
254 updateOperationList();
258 dynamic_cast<wxSpinCtrl*
>(
259 FindWindow(ID_DELAY_SLOTS))->SetValue(delaySlots_);
261 return wxWindow::TransferDataToWindow();
274 addressSpaceChoice_->Clear();
279 gcu_->machine()->addressSpaceNavigator();
281 for (
int i = 0;i < navigator.
count(); i++) {
284 addressSpaceChoice_->Append(name);
287 if (gcu_->addressSpace() != NULL) {
292 addressSpaceChoice_->SetStringSelection(asName);
307 wxString selection = raPortChoice_->GetStringSelection();
309 raPortChoice_->Clear();
311 raPortChoice_->SetSelection(0);
313 for (
int i = 0; i < gcu_->specialRegisterPortCount(); i++) {
315 string portName = port->
name();
318 if (gcu_->hasReturnAddressPort() &&
319 port == gcu_->returnAddressPort()) {
321 raPortChoice_->SetStringSelection(
336 portList_->DeleteAllItems();
341 for (
int i = 0; i < gcu_->portCount(); i++) {
347 string name = port->
name();
351 portList_->InsertItem(index, _T(
""), 0);
353 portList_->InsertItem(index, _T(
"*"), 0);
358 if (gcu_->hasSpecialRegisterPort(port->
name())) {
359 portList_->SetItem(index, 1, _T(
"*"));
361 portList_->SetItem(index, 1, _T(
""));
370 onPortSelection(
dummy);
384 if (!TransferDataFromWindow()) {
403 if (trimmedName != gcu_->name()) {
405 gcu_->machine()->functionUnitNavigator();
406 for (
int i = 0; i < navigator.
count(); i++) {
408 if (trimmedName == fu->
name()) {
418 message % trimmedName % a_fu.str() %
machine.str() % gcu.str();
428 gcu_->setName(trimmedName);
429 gcu_->setDelaySlots(delaySlots_);
430 gcu_->setGlobalGuardLatency(guardLatency_);
445 gcu_->machine()->addressSpaceNavigator();
449 gcu_->setAddressSpace(addressSpace);
453 gcu_->setAddressSpace(NULL);
466 if (!TransferDataFromWindow()) {
469 wxString trimmedName = name_.Trim(
false).Trim(
true);
470 if (trimmedName == _T(
"")) {
490 while (gcu_->hasOperation(newName)) {
498 if (dialog.ShowModal() == wxID_OK) {
501 gcu_->loadState(gcu);
503 updateOperationList();
516 delete gcu_->operation(name);
517 updateOperationList();
530 if (selected == NULL) {
537 if (dialog.ShowModal() == wxID_OK) {
540 gcu_->loadState(gcu);
542 updateOperationList();
557 return gcu_->operation(name);
571 if (operationList_->GetSelectedItemCount() != 1) {
586 operationList_->DeleteAllItems();
587 for (
int i=0; i < gcu_->operationCount(); i++) {
589 operationList_->InsertItem(0, name);
592 onOperationSelection(
dummy);
605 operationList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
606 wxLIST_STATE_SELECTED);
608 wxMenu* contextMenu =
new wxMenu();
611 format button = prodeTexts->
text(
615 button = prodeTexts->
text(
619 operationList_->PopupMenu(contextMenu, event.GetPoint());
628 wxCommandEvent
dummy;
629 onEditOperation(
dummy);
644 while (gcu_->hasPort(newName)) {
653 if (portDialog.ShowModal() == wxID_CANCEL) {
671 while (gcu_->hasPort(newName)) {
681 if (portDialog.ShowModal() == wxID_CANCEL) {
686 updateRAPortChoice();
695 Port* selected = selectedPort();
696 if (selected == NULL) {
701 updateRAPortChoice();
729 if (selected == NULL) {
733 if (gcu_->hasSpecialRegisterPort(selected->
name())) {
735 gcu_->specialRegisterPort(selected->
name());
737 portDialog.ShowModal();
738 }
else if (gcu_->hasOperationPort(selected->
name())) {
739 FUPort* port = gcu_->operationPort(selected->
name());
741 portDialog.ShowModal();
744 updateRAPortChoice();
758 if (portList_->GetSelectedItemCount() != 1) {
776 portList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
777 wxLIST_STATE_SELECTED);
779 wxMenu* contextMenu =
new wxMenu();
782 format button = prodeTexts->
text(
786 button = prodeTexts->
text(
790 portList_->PopupMenu(contextMenu, event.GetPoint());
799 wxCommandEvent
dummy;
812 gcu_->unsetReturnAddressPort();
823 gcu_->setReturnAddressPort(*port);
824 updateRAPortChoice();
842 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
844 wxBoxSizer *item1 =
new wxBoxSizer( wxHORIZONTAL );
846 wxBoxSizer *item2 =
new wxBoxSizer( wxVERTICAL );
848 wxFlexGridSizer *item3 =
new wxFlexGridSizer( 2, 0, 0 );
850 wxStaticText *item4 =
new wxStaticText( parent, ID_TEXT_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
851 item3->Add( item4, 0, wxALL, 5 );
853 wxTextCtrl *item5 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(140,-1), 0 );
854 item3->Add( item5, 0, wxGROW|wxALL, 5 );
856 wxStaticText *item6 =
new wxStaticText( parent, ID_TEXT_DS, wxT(
"Delay slots:"), wxDefaultPosition, wxDefaultSize, 0 );
857 item3->Add( item6, 0, wxALL, 5 );
859 wxSpinCtrl *item7 =
new wxSpinCtrl( parent, ID_DELAY_SLOTS, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 10000, 1 );
860 item3->Add( item7, 0, wxGROW|wxALL, 5 );
869 wxStaticText *item10 =
new wxStaticText( parent, ID_TEXT_AS, wxT(
"Address Space:"), wxDefaultPosition, wxDefaultSize, 0 );
870 item3->Add( item10, 0, wxALL, 5 );
872 wxString *strs11 = (wxString*) NULL;
873 wxChoice *item11 =
new wxChoice( parent, ID_ADDRESS_SPACE, wxDefaultPosition, wxSize(100,-1), 0, strs11, 0 );
874 item3->Add( item11, 0, wxGROW|wxALL, 5 );
876 item2->Add( item3, 0, wxALL, 5 );
878 wxStaticBox *item13 =
new wxStaticBox( parent, -1, wxT(
"Operations:") );
879 wxStaticBoxSizer *item12 =
new wxStaticBoxSizer( item13, wxVERTICAL );
880 operationsSizer_ = item12;
882 wxListCtrl *item14 =
new wxListCtrl( parent, ID_OPERATION_LIST, wxDefaultPosition, wxSize(300,200), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
883 item12->Add( item14, 0, wxGROW|wxALL, 5 );
885 wxBoxSizer *item15 =
new wxBoxSizer( wxHORIZONTAL );
887 wxButton *item16 =
new wxButton( parent, ID_ADD_OPERATION, wxT(
"&Add..."), wxDefaultPosition, wxDefaultSize, 0 );
888 item15->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
890 wxButton *item17 =
new wxButton( parent, ID_EDIT_OPERATION, wxT(
"&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
891 item15->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
893 wxButton *item18 =
new wxButton( parent, ID_DELETE_OPERATION, wxT(
"&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
894 item15->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
896 item12->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
898 item2->Add( item12, 0, wxGROW|wxALL, 5 );
900 item1->Add( item2, 0, wxGROW|wxALL, 5 );
902 wxStaticBox *item20 =
new wxStaticBox( parent, -1, wxT(
"Ports:") );
903 wxStaticBoxSizer *item19 =
new wxStaticBoxSizer( item20, wxVERTICAL );
904 portListSizer_ = item19;
906 wxBoxSizer *item21 =
new wxBoxSizer( wxVERTICAL );
908 wxListCtrl *item22 =
new wxListCtrl( parent, ID_PORT_LIST, wxDefaultPosition, wxSize(300,180), wxLC_REPORT|wxSUNKEN_BORDER );
909 item21->Add( item22, 0, wxGROW|wxALL, 5 );
911 wxBoxSizer *item23 =
new wxBoxSizer( wxHORIZONTAL );
913 wxButton *item24 =
new wxButton( parent, ID_EDIT_PORT, wxT(
"Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
914 item23->Add( item24, 0, wxALIGN_CENTER|wxALL, 5 );
916 wxButton *item25 =
new wxButton( parent, ID_DELETE_PORT, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
917 item23->Add( item25, 0, wxALIGN_CENTER|wxALL, 5 );
919 item21->Add( item23, 0, 0, 5 );
921 wxBoxSizer *item26 =
new wxBoxSizer( wxHORIZONTAL );
923 wxButton *item27 =
new wxButton( parent, ID_ADD_FU_PORT, wxT(
"Add operation port..."), wxDefaultPosition, wxDefaultSize, 0 );
924 item26->Add( item27, 0, wxALIGN_CENTER|wxALL, 5 );
926 wxButton *item28 =
new wxButton( parent, ID_ADD_SR_PORT, wxT(
"Add special register port..."), wxDefaultPosition, wxDefaultSize, 0 );
927 item26->Add( item28, 0, wxALIGN_CENTER|wxALL, 5 );
929 item21->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
931 wxStaticLine *item29 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
932 item21->Add( item29, 0, wxGROW|wxALL, 5 );
934 wxFlexGridSizer *item30 =
new wxFlexGridSizer( 2, 0, 0 );
936 wxStaticText *item31 =
new wxStaticText( parent, ID_LABEL_RA_CHOICE, wxT(
"Return address port:"), wxDefaultPosition, wxDefaultSize, 0 );
937 item30->Add( item31, 0, wxALIGN_CENTER|wxALL, 5 );
943 wxChoice *item32 =
new wxChoice( parent, ID_RA_CHOICE, wxDefaultPosition, wxSize(120,-1), 1, strs32, 0 );
944 item30->Add( item32, 0, wxALIGN_CENTER|wxALL, 5 );
946 item21->Add( item30, 0, wxGROW|wxALL, 5 );
948 wxStaticLine *item35 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
949 item21->Add( item35, 0, wxGROW|wxALL, 5 );
951 item19->Add( item21, 0, wxGROW|wxALL, 5 );
953 item1->Add( item19, 0, wxGROW|wxALL, 5 );
955 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
957 wxStaticLine *item36 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
958 item0->Add( item36, 0, wxGROW|wxALL, 5 );
960 wxGridSizer *item37 =
new wxGridSizer( 2, 0, 0 );
962 wxButton *item38 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
963 item37->Add( item38, 0, wxALL, 5 );
965 wxBoxSizer *item39 =
new wxBoxSizer( wxHORIZONTAL );
967 wxButton *item40 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
968 item39->Add( item40, 0, wxALIGN_CENTER|wxALL, 5 );
970 wxButton *item41 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
971 item39->Add( item41, 0, wxALIGN_CENTER|wxALL, 5 );
973 item37->Add( item39, 0, wxALL, 5 );
975 item0->Add( item37, 0, wxGROW|wxLEFT|wxRIGHT, 5 );
979 parent->SetSizer( item0 );
981 item0->SetSizeHints( parent );