35 #include <wx/valtext.h>
36 #include <wx/valgen.h>
37 #include <boost/format.hpp>
68 BEGIN_EVENT_TABLE(
FUDialog, wxDialog)
112 wxDialog(parent, -1, _T(""), wxDefaultPosition),
113 functionUnit_(functionUnit),
116 operationListCtrl_(NULL),
117 addressSpaceChoice_(NULL) {
119 createContents(
this,
true,
true);
121 portListCtrl_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PORT_LIST));
123 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OPERATION_LIST));
124 addressSpaceChoice_ =
125 dynamic_cast<wxChoice*
>(
FindWindow(ID_ADDRESS_SPACE));
127 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
134 TransferDataToWindow();
200 wxListCtrl* portList =
201 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_PORT_LIST));
204 wxLIST_FORMAT_CENTER, 30);
207 wxLIST_FORMAT_LEFT, 110);
210 wxLIST_FORMAT_LEFT, 110);
213 wxListCtrl* operationList =
214 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OPERATION_LIST));
217 wxLIST_FORMAT_LEFT, 250);
232 updateOperationList();
233 updateAddressSpaceChoice();
235 return wxWindow::TransferDataToWindow();
249 if (!TransferDataFromWindow()) {
267 if (trimmedName != functionUnit_->name()) {
269 functionUnit_->machine()->functionUnitNavigator();
270 for (
int i = 0; i < navigator.
count(); i++) {
272 if (trimmedName == fu->
name()) {
283 message % trimmedName % a_fu.str() %
machine.str() % fu.str();
291 functionUnit_->setName(trimmedName);
305 functionUnit_->setAddressSpace(NULL);
309 functionUnit_->machine()->addressSpaceNavigator();
312 functionUnit_->setAddressSpace(as);
327 while (functionUnit_->hasPort(newName)) {
336 if (portDialog.ShowModal() == wxID_CANCEL) {
350 FUPort* selected = selectedPort();
351 if (selected == NULL) {
371 FUPort* port = functionUnit_->operationPort(name);
381 wxCommandEvent
dummy;
393 FUPort* port = selectedPort();
398 portDialog.ShowModal();
413 if (portListCtrl_->GetSelectedItemCount() != 1) {
437 while (functionUnit_->hasOperation(newName)) {
443 operation =
new HWOperation(newName, *functionUnit_);
446 if (dialog.ShowModal() == wxID_OK) {
449 functionUnit_->loadState(fu);
451 updateOperationList();
462 if (opsetDialog.ShowModal() != wxID_OK) {
468 if (operation == NULL) {
473 if (operationDialog.ShowModal() != wxID_OK) {
477 updateOperationList();
495 delete functionUnit_->operation(name);
496 updateOperationList();
510 if (selected == NULL) {
517 if (dialog.ShowModal() == wxID_OK) {
520 functionUnit_->loadState(fu);
522 updateOperationList();
532 if (!TransferDataFromWindow()) {
535 wxString trimmedName = name_.Trim(
false).Trim(
true);
536 if (trimmedName == _T(
"")) {
555 return functionUnit_->operation(name);
569 if (operationListCtrl_->GetSelectedItemCount() != 1) {
588 addressSpaceChoice_->Clear();
592 functionUnit_->machine()->addressSpaceNavigator();
595 for (
int i = 0; i < navigator.
count(); i++) {
598 addressSpaceChoice_->Append(name);
605 addressSpaceChoice_->SetStringSelection(name);
620 portListCtrl_->DeleteAllItems();
622 for (
int i = 0; i < functionUnit_->portCount(); i++) {
624 FUPort* port = functionUnit_->operationPort(i);
628 string name = port->
name();
632 portListCtrl_->InsertItem(i, _T(
""), 0);
634 portListCtrl_->InsertItem(i, _T(
"*"), 0);
642 onPortSelection(
dummy);
652 operationListCtrl_->DeleteAllItems();
656 std::set<std::string> operations;
657 for (
int i=0; i < functionUnit_->operationCount(); i++) {
658 operations.insert(functionUnit_->operation(i)->name());
661 std::set<std::string>::reverse_iterator iter = operations.rbegin();
662 for (; iter != operations.rend(); iter++) {
664 operationListCtrl_->InsertItem(0, name);
668 onOperationSelection(
dummy);
680 portListCtrl_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
681 wxLIST_STATE_SELECTED);
683 wxMenu* contextMenu =
new wxMenu();
686 format button = prodeTexts->
text(
690 button = prodeTexts->
text(
694 portListCtrl_->PopupMenu(contextMenu, event.GetPoint());
707 operationListCtrl_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
708 wxLIST_STATE_SELECTED);
710 wxMenu* contextMenu =
new wxMenu();
713 format button = prodeTexts->
text(
717 button = prodeTexts->
text(
721 operationListCtrl_->PopupMenu(contextMenu, event.GetPoint());
730 wxCommandEvent
dummy;
731 onEditOperation(
dummy);
749 wxFlexGridSizer *item0 =
new wxFlexGridSizer( 2, 0, 10 );
751 wxBoxSizer *item1 =
new wxBoxSizer( wxHORIZONTAL );
753 wxStaticText *item2 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
754 item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
756 wxTextCtrl *item3 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(150,-1), 0 );
757 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
759 item0->Add( item1, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
761 wxBoxSizer *item4 =
new wxBoxSizer( wxHORIZONTAL );
763 wxStaticText *item5 =
new wxStaticText( parent, ID_LABEL_AS, wxT(
"Address Space:"), wxDefaultPosition, wxDefaultSize, 0 );
764 item4->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
766 wxString *strs6 = (wxString*) NULL;
767 wxChoice *item6 =
new wxChoice( parent, ID_ADDRESS_SPACE, wxDefaultPosition, wxSize(150,-1), 0, strs6, 0 );
768 item4->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
770 item0->Add( item4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
772 wxStaticBox *item8 =
new wxStaticBox( parent, -1, wxT(
"Operations:") );
773 wxStaticBoxSizer *item7 =
new wxStaticBoxSizer( item8, wxVERTICAL );
774 operationsSizer_ = item7;
776 wxListCtrl *item9 =
new wxListCtrl( parent, ID_OPERATION_LIST, wxDefaultPosition, wxSize(160,200), wxLC_REPORT|wxSUNKEN_BORDER );
777 item7->Add( item9, 0, wxGROW|wxALL, 5 );
779 wxBoxSizer *item10 =
new wxBoxSizer( wxHORIZONTAL );
781 wxButton *item11 =
new wxButton( parent, ID_ADD_OPERATION, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
782 item10->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
784 wxButton *item12 =
new wxButton( parent, ID_EDIT_OPERATION, wxT(
"Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
785 item10->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
787 wxButton *item13 =
new wxButton( parent, ID_DELETE_OPERATION, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
788 item10->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
790 item7->Add( item10, 0, wxALIGN_CENTER, 5 );
792 wxButton *item14 =
new wxButton( parent, ID_ADD_OPERATION_FROM_OPSET, wxT(
" Add from Opset... "), wxDefaultPosition, wxDefaultSize, 0 );
793 item7->Add( item14, 0, wxALL, 5 );
795 item0->Add( item7, 0, wxGROW|wxALL, 5 );
797 wxStaticBox *item16 =
new wxStaticBox( parent, -1, wxT(
"Ports:") );
798 wxStaticBoxSizer *item15 =
new wxStaticBoxSizer( item16, wxVERTICAL );
799 portsSizer_ = item15;
801 wxListCtrl *item17 =
new wxListCtrl( parent, ID_PORT_LIST, wxDefaultPosition, wxSize(160,200), wxLC_REPORT|wxSUNKEN_BORDER );
802 item15->Add( item17, 0, wxGROW|wxALL, 5 );
804 wxBoxSizer *item18 =
new wxBoxSizer( wxHORIZONTAL );
806 wxButton *item19 =
new wxButton( parent, ID_ADD_PORT, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
807 item18->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
809 wxButton *item20 =
new wxButton( parent, ID_EDIT_PORT, wxT(
"Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
810 item18->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
812 wxButton *item21 =
new wxButton( parent, ID_DELETE_PORT, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
813 item18->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
815 item15->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
817 item0->Add( item15, 0, wxGROW|wxALL, 5 );
819 wxBoxSizer *item25 =
new wxBoxSizer( wxHORIZONTAL );
821 wxButton *item26 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
822 item25->Add( item26, 0, wxALIGN_CENTER|wxALL, 5 );
824 item0->Add( item25, 0, wxALL, 5 );
826 wxBoxSizer *item27 =
new wxBoxSizer( wxHORIZONTAL );
828 wxButton *item28 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
829 item27->Add( item28, 0, wxALIGN_CENTER|wxALL, 5 );
831 wxButton *item29 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
832 item27->Add( item29, 0, wxALIGN_CENTER|wxALL, 5 );
834 item0->Add( item27, 0, wxALL, 5 );
838 parent->SetSizer( item0 );
840 item0->SetSizeHints( parent );