34 #include <wx/listctrl.h>
35 #include <wx/radiobox.h>
36 #include <wx/choice.h>
37 #include <wx/statline.h>
90 ID_DELETE_EXTERNAL_PORT,
94 ID_EXTERNAL_PORT_LIST,
97 ID_EXTERNAL_PORT_LIST,
100 ID_EXTERNAL_PORT_LIST,
127 wxDialog(parent,
id, _T("Register File Implementation")),
130 createContents(
this,
true,
true);
133 portList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PORT_LIST));
134 sourceList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_SOURCE_LIST));
135 externalPortList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(
136 ID_EXTERNAL_PORT_LIST));
137 parameterList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PARAMETER_LIST));
138 sizeChoice_ =
dynamic_cast<wxChoice*
>(
FindWindow(ID_SIZE_CHOICE));
139 widthChoice_ =
dynamic_cast<wxChoice*
>(
FindWindow(ID_WIDTH_CHOICE));
143 portList_->InsertColumn(0, _T(
"name"), wxLIST_FORMAT_LEFT, 200);
144 sourceList_->InsertColumn(0, _T(
"source file"), wxLIST_FORMAT_LEFT, 260);
147 sizeChoice_->SetSelection(sizeChoice_->Append(
149 widthChoice_->SetSelection(widthChoice_->Append(
153 externalPortList_->InsertColumn(0, _T(
"name"), wxLIST_FORMAT_LEFT, 260);
154 parameterList_->InsertColumn(0, _T(
"parameter"), wxLIST_FORMAT_LEFT, 180);
155 parameterList_->InsertColumn(1, _T(
"value"), wxLIST_FORMAT_LEFT, 80);
163 sacParam_ = implementation_.separateAddressCycleParameter();
167 wxTextValidator(wxFILTER_ASCII, &name_));
169 wxTextValidator(wxFILTER_ASCII, &clkPort_));
171 wxTextValidator(wxFILTER_ASCII, &rstPort_));
173 wxTextValidator(wxFILTER_ASCII, &gLockPort_));
175 wxTextValidator(wxFILTER_ASCII, &guardPort_));
177 wxRadioBox* rbox =
dynamic_cast<wxRadioBox*
>(
FindWindow(ID_SAC));
178 rbox->SetSelection(sacParam_ ? RBOX_TRUE : RBOX_FALSE);
185 FindWindow(ID_DELETE_EXTERNAL_PORT)->Disable();
202 portList_->DeleteAllItems();
203 for (
int i = 0; i < implementation_.portCount(); i++) {
205 implementation_.port(i).name());
206 portList_->InsertItem(i, portName);
210 sourceList_->DeleteAllItems();
211 for (
int i = 0; i < implementation_.implementationFileCount(); i++) {
213 implementation_.file(i).pathToFile());
214 sourceList_->InsertItem(i, fileName);
216 if (implementation_.implementationFileCount() != 0) {
217 sourceList_->SetColumnWidth(0, wxLIST_AUTOSIZE);
221 externalPortList_->DeleteAllItems();
222 for (
int i = 0; i < implementation_.externalPortCount(); i++) {
224 implementation_.externalPort(i).name());
225 externalPortList_->InsertItem(i, portName);
229 parameterList_->DeleteAllItems();
230 for (
int i = 0; i < implementation_.parameterCount(); i++) {
232 implementation_.parameter(i);
234 param.Append(_T(
": "));
236 parameterList_->InsertItem(i, param);
237 parameterList_->SetItem(
242 wxString oldWidthChoice = getWidthParameter();
243 wxString oldSizeChoice = getSizeParameter();
244 widthChoice_->Clear();
245 widthChoice_->Append(_T(
""));
246 sizeChoice_->Clear();
247 sizeChoice_->Append(_T(
""));
248 for (
int i = 0; i < implementation_.parameterCount(); i++) {
250 implementation_.parameter(i);
254 widthChoice_->SetSelection(widthChoice_->FindString(oldWidthChoice));
255 sizeChoice_->SetSelection(sizeChoice_->FindString(oldSizeChoice));
258 onPortSelection(
dummy);
259 onExternalPortSelection(
dummy);
260 onParameterSelection(
dummy);
265 assert((event.GetInt() == RBOX_FALSE) || (event.GetInt() == RBOX_TRUE));
266 sacParam_ = (
event.GetInt() == RBOX_FALSE) ?
false :
true;
278 "", implementation_);
282 if (dialog.ShowModal() != wxID_OK) {
283 implementation_.deletePort(port);
296 if (selectedPort() == NULL) {
319 implementation_.deletePort(port);
351 item = portList_->GetNextItem(item, wxLIST_NEXT_ALL,
352 wxLIST_STATE_SELECTED);
358 return &implementation_.port(item);
371 item = externalPortList_->GetNextItem(
372 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
378 return &implementation_.externalPort(item);
390 item = parameterList_->GetNextItem(
391 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
398 return implementation_.parameter(item);
424 if (selectedExternalPort() == NULL) {
425 FindWindow(ID_DELETE_EXTERNAL_PORT)->Disable();
428 FindWindow(ID_DELETE_EXTERNAL_PORT)->Enable();
442 "",
IN,
"",
"", implementation_);
446 if (dialog.ShowModal() != wxID_OK) {
447 implementation_.deleteExternalPort(port);
488 implementation_.deleteExternalPort(port);
502 std::string oldName = parameter.
name;
506 if (dialog.ShowModal() == wxID_OK) {
507 implementation_.removeParameter(oldName);
508 implementation_.addParameter(
512 for (
int i = 0; i < implementation_.externalPortCount(); i++) {
531 if (selectedParameter().name ==
"") {
554 wxString message = _T(
"");
556 if (dialog.ShowModal() != wxID_OK) {
567 implementation_.addParameter(
570 message = _T(
"RF implementation already contains ");
571 message.Append(_T(
"a parameter\nwith name '"));
573 message.Append(_T(
"'."));
597 std::string oldName = parameter.
name;
601 if (dialog.ShowModal() == wxID_OK) {
602 implementation_.removeParameter(oldName);
603 implementation_.addParameter(
607 for (
int i = 0; i < implementation_.externalPortCount(); i++) {
627 implementation_.removeParameter(parameter.
name);
630 for (
int i = 0; i < implementation_.externalPortCount(); i++) {
653 if (dialog.ShowModal() == wxID_OK) {
654 implementation_.addImplementationFile(file);
672 for (
int i = 0; i < implementation_.implementationFileCount(); i++) {
675 implementation_.removeImplementationFile(file);
689 if (implementation_.implementationFileCount() > 1) {
691 std::vector<std::string> pathToFileList;
692 int originalImplementationFileCount =
693 implementation_.implementationFileCount();
695 for (
int i = 0; i < originalImplementationFileCount; i++) {
698 implementation_.removeImplementationFile(file);
701 for (
unsigned int i = 1; i < pathToFileList.size(); i++) {
702 if (pathToFileList.at(i) == fileName) {
703 pathToFileList.erase(pathToFileList.begin() + i);
704 pathToFileList.insert(pathToFileList.begin() + i - 1,
710 for (
unsigned int i = 0; i < pathToFileList.size(); i++) {
713 implementation_.addImplementationFile(file);
716 pathToFileList.clear();
719 for (
int i = 0; i < implementation_.implementationFileCount(); i++) {
720 if (implementation_.file(i).pathToFile() == fileName) {
721 sourceList_->SetItemState(i, wxLIST_STATE_SELECTED,
722 wxLIST_STATE_SELECTED);
735 if (implementation_.implementationFileCount() > 1) {
737 std::vector<std::string> pathToFileList;
739 int originalImplementationFileCount =
740 implementation_.implementationFileCount();
742 for (
int i = 0; i < originalImplementationFileCount; i++) {
745 implementation_.removeImplementationFile(file);
748 for (
unsigned int i = 0; i < (pathToFileList.size() - 1); i++) {
749 if (pathToFileList.at(i) == fileName) {
750 pathToFileList.erase(pathToFileList.begin() + i);
751 pathToFileList.insert(pathToFileList.begin() + i + 1,
757 for (
unsigned int i = 0; i < pathToFileList.size(); i++) {
760 implementation_.addImplementationFile(file);
763 pathToFileList.clear();
766 for (
int i = 0; i < implementation_.implementationFileCount(); i++) {
767 if (implementation_.file(i).pathToFile() == fileName) {
768 sourceList_->SetItemState(i, wxLIST_STATE_SELECTED,
769 wxLIST_STATE_SELECTED);
801 return sizeChoice_->GetString(sizeChoice_->GetSelection());
813 return widthChoice_->GetString(widthChoice_->GetSelection());
826 TransferDataFromWindow();
828 name_ = name_.Trim(
true).Trim(
false);
829 clkPort_ = clkPort_.Trim(
true).Trim(
false);
830 rstPort_ = rstPort_.Trim(
true).Trim(
false);
831 gLockPort_ = gLockPort_.Trim(
true).Trim(
false);
832 guardPort_ = guardPort_.Trim(
true).Trim(
false);
834 if (name_.IsEmpty()) {
835 wxString message = _T(
"Name field must not be empty.");
846 implementation_.setSeparateAddressCycleParameter(sacParam_);
847 implementation_.setWidthParameter(
849 implementation_.setSizeParameter(
861 wxWindow *parent,
bool call_fit,
bool set_sizer) {
863 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
865 wxBoxSizer *item1 =
new wxBoxSizer( wxVERTICAL );
867 wxFlexGridSizer *item2 =
new wxFlexGridSizer( 2, 0, 0 );
869 wxStaticText *item3 =
new wxStaticText( parent, ID_LABEL_NAME,
870 wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
871 item2->Add( item3, 0, wxALIGN_RIGHT|wxALL, 5 );
873 wxTextCtrl *item4 =
new wxTextCtrl( parent, ID_NAME, wxT(
""),
874 wxDefaultPosition, wxSize(200,-1), 0 );
875 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
877 wxStaticText *item5 =
new wxStaticText( parent, ID_LABEL_CLK_PORT,
878 wxT(
"Clock port:"), wxDefaultPosition, wxDefaultSize, 0 );
879 item2->Add( item5, 0, wxALIGN_RIGHT|wxALL, 5 );
881 wxTextCtrl *item6 =
new wxTextCtrl( parent, ID_CLK_PORT, wxT(
""),
882 wxDefaultPosition, wxSize(80,-1), 0 );
883 item2->Add( item6, 0, wxGROW|wxALL, 5 );
885 wxStaticText *item7 =
new wxStaticText( parent, ID_LABEL_RESET_PORT,
886 wxT(
"Reset port:"), wxDefaultPosition, wxDefaultSize, 0 );
887 item2->Add( item7, 0, wxALIGN_RIGHT|wxALL, 5 );
889 wxTextCtrl *item8 =
new wxTextCtrl( parent, ID_RESET_PORT, wxT(
""),
890 wxDefaultPosition, wxSize(80,-1), 0 );
891 item2->Add( item8, 0, wxGROW|wxALL, 5 );
893 wxStaticText *item9 =
new wxStaticText( parent, ID_LABEL_GLOCK_PORT,
894 wxT(
"Global lock port:"), wxDefaultPosition, wxDefaultSize, 0 );
895 item2->Add( item9, 0, wxALIGN_RIGHT|wxALL, 5 );
897 wxTextCtrl *item10 =
new wxTextCtrl( parent, ID_GLOCK_PORT, wxT(
""),
898 wxDefaultPosition, wxSize(80,-1), 0 );
899 item2->Add( item10, 0, wxGROW|wxALL, 5 );
901 wxStaticText *item11 =
new wxStaticText( parent, ID_LABEL_GUARD_PORT,
902 wxT(
"Guard port:"), wxDefaultPosition, wxDefaultSize, 0 );
903 item2->Add( item11, 0, wxALIGN_RIGHT|wxALL, 5 );
905 wxTextCtrl *item12 =
new wxTextCtrl( parent, ID_GUARD_PORT, wxT(
""),
906 wxDefaultPosition, wxSize(80,-1), 0 );
907 item2->Add( item12, 0, wxGROW|wxALL, 5 );
909 wxStaticText *item13 =
new wxStaticText( parent, ID_LABEL_SIZE_PARAMETER,
910 wxT(
"Size parameter:"), wxDefaultPosition, wxDefaultSize, 0 );
911 item2->Add( item13, 0, wxALIGN_RIGHT|wxALL, 5 );
913 wxChoice *sizeChoice =
new wxChoice(parent, ID_SIZE_CHOICE,
914 wxDefaultPosition, wxSize(80,-1), 0, 0, wxCB_SORT);
915 item2->Add( sizeChoice, 0, wxGROW|wxALL, 5 );
917 wxStaticText *item15 =
new wxStaticText( parent, ID_LABEL_WIDTH_PARAMETER,
918 wxT(
"Width parameter:"), wxDefaultPosition, wxDefaultSize, 0 );
919 item2->Add( item15, 0, wxALIGN_RIGHT|wxALL, 5 );
921 wxChoice *widthChoice =
new wxChoice(parent, ID_WIDTH_CHOICE,
922 wxDefaultPosition, wxSize(80,-1), 0, 0, wxCB_SORT);
923 item2->Add(widthChoice, 0, wxGROW|wxALL, 5);
925 wxStaticText *saclabel =
new wxStaticText(parent, ID_LABEL_SAC,
926 wxT(
"Separate address cycle:"), wxDefaultPosition, wxDefaultSize, 0);
927 item2->Add(saclabel, 0, wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL,
930 wxString choises[2] =
931 { wxT(
"False"), wxT(
"True") };
932 wxRadioBox *sacradiobox =
new wxRadioBox(parent, ID_SAC, wxT(
""),
933 wxDefaultPosition, wxDefaultSize, 2, choises, 0, wxRA_SPECIFY_COLS);
934 item2->Add(sacradiobox, 0, wxGROW | wxALIGN_CENTER_VERTICAL | wxALL, 5);
936 item1->Add( item2, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 );
938 wxBoxSizer *item17 =
new wxBoxSizer( wxHORIZONTAL );
940 wxStaticBox *item19 =
new wxStaticBox( parent, -1, wxT(
"Ports:") );
941 wxStaticBoxSizer *item18 =
new wxStaticBoxSizer( item19, wxVERTICAL );
943 wxListCtrl *item20 =
new wxListCtrl( parent, ID_PORT_LIST,
944 wxDefaultPosition, wxSize(220,160), wxLC_REPORT|wxSUNKEN_BORDER );
945 item18->Add( item20, 0, wxGROW|wxALL, 5 );
947 wxBoxSizer *item21 =
new wxBoxSizer( wxHORIZONTAL );
949 wxButton *item22 =
new wxButton( parent, ID_ADD_PORT,
950 wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
951 item21->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
953 wxButton *item23 =
new wxButton( parent, ID_MODIFY_PORT,
954 wxT(
"Modify..."), wxDefaultPosition, wxDefaultSize, 0 );
955 item21->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
957 wxButton *item24 =
new wxButton( parent, ID_DELETE_PORT,
958 wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
959 item21->Add( item24, 0, wxALIGN_CENTER|wxALL, 5 );
961 item18->Add( item21, 0, wxALIGN_CENTER, 5 );
963 item17->Add( item18, 0, wxGROW|wxALL, 5 );
965 wxStaticBox *item26 =
new wxStaticBox( parent, -1, wxT(
"Source files:") );
966 wxStaticBoxSizer *item25 =
new wxStaticBoxSizer( item26, wxVERTICAL );
968 wxFlexGridSizer *item27_1 =
new wxFlexGridSizer( 2, 0, 0 );
970 wxListCtrl *item27 =
new wxListCtrl( parent, ID_SOURCE_LIST,
971 wxDefaultPosition, wxSize(300, 150), wxLC_REPORT|wxSUNKEN_BORDER );
972 item27_1->Add( item27, 0, wxGROW|wxALL, 5 );
974 wxBoxSizer *item27_2 =
new wxBoxSizer( wxVERTICAL );
976 wxButton *item60 =
new wxButton( parent, ID_MOVE_SOURCE_UP, wxT(
"▴"),
977 wxDefaultPosition, wxSize(20, 20), 0 );
978 item27_2->Add( item60, 0, wxALIGN_CENTER|wxALL, 5 );
980 wxButton *item61 =
new wxButton( parent, ID_MOVE_SOURCE_DOWN, wxT(
"▾"),
981 wxDefaultPosition, wxSize(20, 20), 0 );
982 item27_2->Add( item61, 0, wxALIGN_CENTER|wxALL, 5 );
984 item27_1->Add( item27_2, 0, wxALIGN_CENTER, 5 );
986 item25->Add( item27_1, 0, wxGROW|wxALL, 5 );
988 wxBoxSizer *item28 =
new wxBoxSizer( wxHORIZONTAL );
990 wxButton *item29 =
new wxButton( parent, ID_ADD_SOURCE, wxT(
"Add..."),
991 wxDefaultPosition, wxDefaultSize, 0 );
992 item28->Add( item29, 0, wxALL, 5 );
994 wxButton *item30 =
new wxButton( parent, ID_DELETE_SOURCE, wxT(
"Delete"),
995 wxDefaultPosition, wxDefaultSize, 0 );
996 item28->Add( item30, 0, wxALIGN_CENTER|wxALL, 5 );
998 item25->Add( item28, 0, 0, 5 );
1000 item17->Add( item25, 0, wxGROW|wxALL, 5 );
1002 item1->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
1005 wxBoxSizer *extPortAndParamSizer =
new wxBoxSizer( wxHORIZONTAL );
1007 wxStaticBox *extPortBox =
new wxStaticBox(parent, -1,
1008 wxT(
"External ports:"));
1009 wxStaticBoxSizer *extPortBoxSizer =
new wxStaticBoxSizer(extPortBox,
1011 wxListCtrl *item35 =
new wxListCtrl( parent, ID_EXTERNAL_PORT_LIST,
1012 wxDefaultPosition, wxSize(200,120), wxLC_REPORT|wxSUNKEN_BORDER );
1013 extPortBoxSizer->Add( item35, 0, wxGROW|wxALL, 5 );
1014 wxBoxSizer *extPortButtons =
new wxBoxSizer( wxHORIZONTAL );
1015 wxButton *addExtPort =
new wxButton( parent, ID_ADD_EXTERNAL_PORT,
1016 wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0);
1017 extPortButtons->Add( addExtPort, 0, wxALL, 5 );
1018 wxButton *editExtPort =
new wxButton( parent, ID_EDIT_EXTERNAL_PORT,
1019 wxT(
"Edit..."), wxDefaultPosition, wxDefaultSize, 0);
1020 extPortButtons->Add(editExtPort, 0, wxALIGN_CENTER|wxALL, 5);
1021 wxButton *deleteExtPort =
new wxButton( parent, ID_DELETE_EXTERNAL_PORT,
1022 wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0);
1023 extPortButtons->Add(deleteExtPort, 0, wxALIGN_CENTER|wxALL, 5);
1024 extPortBoxSizer->Add(extPortButtons, 0, wxALIGN_CENTER, 5);
1025 extPortAndParamSizer->Add(extPortBoxSizer, 0,
1029 wxStaticBox *paramBox =
new wxStaticBox(parent, -1, wxT(
"Parameters:"));
1030 wxStaticBoxSizer *paramBoxSizer =
new wxStaticBoxSizer(paramBox,
1033 wxListCtrl *item42 =
new wxListCtrl( parent, ID_PARAMETER_LIST,
1034 wxDefaultPosition, wxSize(300,120), wxLC_REPORT|wxSUNKEN_BORDER );
1035 paramBoxSizer->Add( item42, 0, wxGROW|wxALL, 5 );
1037 wxBoxSizer *item43 =
new wxBoxSizer( wxHORIZONTAL );
1039 wxButton *item44 =
new wxButton( parent, ID_ADD_PARAMETER, wxT(
"Add..."),
1040 wxDefaultPosition, wxDefaultSize, 0 );
1041 item43->Add( item44, 0, wxALIGN_CENTER|wxALL, 5 );
1043 wxButton *item45 =
new wxButton( parent, ID_EDIT_PARAMETER, wxT(
"Edit..."),
1044 wxDefaultPosition, wxDefaultSize, 0 );
1045 item43->Add( item45, 0, wxALIGN_CENTER|wxALL, 5 );
1047 wxButton *item46 =
new wxButton( parent, ID_DELETE_PARAMETER,
1048 wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
1049 item43->Add( item46, 0, wxALIGN_CENTER|wxALL, 5 );
1051 paramBoxSizer->Add( item43, 0,
1054 extPortAndParamSizer->Add( paramBoxSizer, 0,
1057 item1 ->Add(extPortAndParamSizer, 0,
1060 item0->Add( item1, 0, wxGROW|wxALL, 5 );
1062 wxStaticLine *item31 =
new wxStaticLine( parent, ID_LINE,
1063 wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
1064 item0->Add( item31, 0, wxGROW|wxALL, 5 );
1066 wxBoxSizer *item32 =
new wxBoxSizer( wxHORIZONTAL );
1068 wxButton *item33 =
new wxButton( parent, wxID_OK, wxT(
"&OK"),
1069 wxDefaultPosition, wxDefaultSize, 0 );
1070 item32->Add( item33, 0, wxALIGN_CENTER|wxALL, 5 );
1072 wxButton *item34 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"),
1073 wxDefaultPosition, wxDefaultSize, 0 );
1074 item32->Add( item34, 0, wxALIGN_CENTER|wxALL, 5 );
1076 item0->Add( item32, 0, wxALL, 5);
1080 parent->SetSizer( item0 );
1082 item0->SetSizeHints(parent);