34 #include <boost/format.hpp>
84 wxDialog(parent, -1, _T(""), wxDefaultPosition),
86 oppositeName_(_T("")),
87 oppositeNameCtrl_(NULL),
88 inputBusChoice_(NULL),
89 outputBusChoice_(NULL),
90 bidirectionalBox_(NULL) {
96 dynamic_cast<MDFView*
>(wxGetApp().docManager()->GetCurrentView());
101 createContents(
this,
true,
true);
104 wxTextCtrl* nameCtrl =
dynamic_cast<wxTextCtrl*
>(
FindWindow(ID_NAME));
106 nameCtrl->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
109 dynamic_cast<wxTextCtrl*
>(
FindWindow(ID_OPPOSITE_BRIDGE));
110 assert(oppositeNameCtrl_ != 0);
111 oppositeNameCtrl_->SetValidator(wxTextValidator(wxFILTER_ASCII,
114 inputBusChoice_ =
dynamic_cast<wxChoice*
>(
FindWindow(ID_INPUT_BUS));
115 assert(inputBusChoice_ != NULL);
116 outputBusChoice_ =
dynamic_cast<wxChoice*
>(
FindWindow(ID_OUTPUT_BUS));
117 assert(outputBusChoice_ != NULL);
120 dynamic_cast<wxCheckBox*
>(
FindWindow(ID_BIDIRECTIONAL));
121 assert(bidirectionalBox_ != NULL);
129 machine_ = bridge->machine();
133 if (opposite != NULL) {
134 bidirectional_ =
true;
136 assert(opposite->sourceBus() == bridge->destinationBus());
137 assert(opposite->destinationBus() == bridge->sourceBus());
140 bidirectional_ =
false;
147 TransferDataToWindow();
205 bidirectionalBox_->SetValue(bidirectional_);
206 if (bidirectional_) {
207 oppositeNameCtrl_->Enable();
209 oppositeNameCtrl_->Disable();
214 bool transferResult = wxWindow::TransferDataToWindow();
217 wxCommandEvent
dummy;
220 return transferResult;
235 inputBusChoice_->Clear();
236 for (
int i = 0;i < navigator.
count(); i++) {
238 for (
int j = 0;j < navigator.
count(); j++) {
240 inputBusChoice_->Append(busName);
245 inputBusChoice_->SetStringSelection(inputBus_);
248 outputBusChoice_->Clear();
249 for (
int i = 0;i < navigator.
count(); i++) {
252 outputBusChoice_->Append(busName);
255 outputBusChoice_->SetStringSelection(outputBus_);
269 if (!TransferDataFromWindow()) {
274 string trimmedOppName =
292 if (bidirectional_ && trimmedName == trimmedOppName) {
304 if (bidirectional_ && navigator.
hasItem(trimmedOppName)) {
311 message % trimmedOppName % component;
317 if (navigator.
hasItem(trimmedName)) {
329 message % trimmedName % acomponent %
machine % component;
341 new Bridge(trimmedName, *source, *destination);
343 if (bidirectional_ && tester.
canBridge(*destination, *source)) {
344 new Bridge(trimmedOppName, *destination, *source);
347 dynamic_cast<MDFView*
>(wxGetApp().docManager()->GetCurrentView());
356 dynamic_cast<MDFView*
>(wxGetApp().docManager()->GetCurrentView());
358 EndModal(wxID_CANCEL);
368 wxTextCtrl* nameCtrl =
dynamic_cast<wxTextCtrl*
>(
FindWindow(ID_NAME));
369 wxTextCtrl* oppNameCtrl =
370 dynamic_cast<wxTextCtrl*
>(
FindWindow(ID_OPPOSITE_BRIDGE));
372 wxString name = nameCtrl->GetValue();
373 wxString trimmedName = name.Trim(
false).Trim(
true);
374 wxString oppositeName = oppNameCtrl->GetValue();
375 wxString trimmedOppositeName = oppositeName.Trim(
false).Trim(
true);
377 if (trimmedName == _T(
"") ||
378 (bidirectional_ && trimmedOppositeName == _T(
""))) {
395 wxString outputBus = outputBusChoice_->GetStringSelection();
396 outputBus_ = outputBus;
417 Bus* source = navigator.
item(inputBus);
418 Bus* destination = navigator.
item(outputBus);
420 if (!tester.
canBridge(*source, *destination)) {
422 for (
int i=0; i < navigator.
count(); i++) {
424 outputBus = navigator.
item(i)->name();
445 if (bidirectionalBox_->IsChecked()) {
446 oppositeNameCtrl_->Enable();
447 bidirectional_ =
true;
449 oppositeNameCtrl_->Disable();
450 bidirectional_ =
false;
452 wxCommandEvent
dummy;
471 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
473 wxBoxSizer *item1 =
new wxBoxSizer( wxHORIZONTAL );
475 wxFlexGridSizer *item2 =
new wxFlexGridSizer( 2, 0, 0 );
477 wxStaticText *item3 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
478 item2->Add( item3, 0, wxALL, 5 );
480 wxTextCtrl *item4 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(120,-1), 0 );
481 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
483 wxStaticText *item5 =
new wxStaticText( parent, ID_LABEL_INPUT_BUS, wxT(
"Input Bus:"), wxDefaultPosition, wxDefaultSize, 0 );
484 item2->Add( item5, 0, wxALL, 5 );
486 wxString *strs6 = (wxString*) NULL;
487 wxChoice *item6 =
new wxChoice( parent, ID_INPUT_BUS, wxDefaultPosition, wxSize(100,-1), 0, strs6, 0 );
488 item2->Add( item6, 0, wxGROW|wxALL, 5 );
490 wxStaticText *item7 =
new wxStaticText( parent, ID_LABEL_OUTPUT_BUS, wxT(
"Output Bus:"), wxDefaultPosition, wxDefaultSize, 0 );
491 item2->Add( item7, 0, wxALL, 5 );
493 wxString *strs8 = (wxString*) NULL;
494 wxChoice *item8 =
new wxChoice( parent, ID_OUTPUT_BUS, wxDefaultPosition, wxSize(100,-1), 0, strs8, 0 );
495 item2->Add( item8, 0, wxGROW|wxALL, 5 );
497 item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
499 wxBoxSizer *item9 =
new wxBoxSizer( wxVERTICAL );
501 wxCheckBox *item10 =
new wxCheckBox( parent, ID_BIDIRECTIONAL, wxT(
"Bidirectional"), wxDefaultPosition, wxDefaultSize, 0 );
502 item9->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
504 item9->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
506 wxStaticText *item11 =
new wxStaticText( parent, ID_LABEL_OPPOSITE_NAME, wxT(
"Opposite Bridge Name:"), wxDefaultPosition, wxDefaultSize, 0 );
507 item9->Add( item11, 0, wxGROW, 15 );
509 wxTextCtrl *item12 =
new wxTextCtrl( parent, ID_OPPOSITE_BRIDGE, wxT(
""), wxDefaultPosition, wxSize(80,-1), 0 );
510 item9->Add( item12, 0, wxGROW|wxALL, 5 );
512 item1->Add( item9, 0, wxGROW|wxALL, 5 );
514 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
516 wxStaticLine *item13 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
517 item0->Add( item13, 0, wxGROW|wxALL, 5 );
519 wxGridSizer *item14 =
new wxGridSizer( 2, 0, 0 );
521 wxButton *item15 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
522 item14->Add( item15, 0, wxALL, 5 );
524 wxBoxSizer *item16 =
new wxBoxSizer( wxHORIZONTAL );
526 wxButton *item17 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
527 item16->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
529 wxButton *item18 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
530 item16->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
532 item14->Add( item16, 0, wxALL, 5 );
534 item0->Add( item14, 0, wxALIGN_CENTER, 5 );
538 parent->SetSizer( item0 );
540 item0->SetSizeHints( parent );