33 #include <boost/format.hpp>
93 wxDialog(parent, -1, _T(""), wxDefaultPosition),
96 connectedListCtrl_(NULL),
97 segmentListCtrl_(NULL),
99 detachedSizer_(NULL) {
101 createContents(
this,
true,
true);
111 directionBox_ =
dynamic_cast<wxRadioBox*
>(
FindWindow(ID_DIRECTION));
113 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_ATTACHED_LIST));
115 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_DETACHED_LIST));
118 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
123 TransferDataToWindow();
178 wxListCtrl* attachedList =
179 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_ATTACHED_LIST));
182 wxLIST_FORMAT_LEFT, 100);
185 wxLIST_FORMAT_LEFT, 80);
187 wxListCtrl* detachedList =
188 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_DETACHED_LIST));
191 wxLIST_FORMAT_LEFT, 100);
194 wxLIST_FORMAT_LEFT, 80);
212 return wxDialog::TransferDataToWindow();
222 directionBox_->SetStringSelection(
225 directionBox_->SetStringSelection(
241 if (!TransferDataFromWindow()) {
259 if (trimmedName != socket_->name()) {
261 socket_->machine()->socketNavigator();
262 for (
int i = 0; i < navigator.
count(); i++) {
264 if (trimmedName == socket->
name()) {
276 trimmedName % a_soc.str() %
machine.str() % soc.str();
284 socket_->setName(trimmedName);
294 if (!TransferDataFromWindow()) {
297 wxString trimmedName = name_.Trim(
false).Trim(
true);
298 if (trimmedName == _T(
"")) {
317 wxString direction = directionBox_->GetStringSelection();
330 directionBox_->SetStringSelection(
345 directionBox_->SetStringSelection(
349 direction = directionBox_->GetStringSelection();
367 item = segmentListCtrl_->GetNextItem(
368 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
378 Segment* seg = segment(segmentListCtrl_, item);
385 *socket_, *seg, tester);
389 socket_->loadState(savedState);
392 socket_->attachBus(*seg);
393 item = segmentListCtrl_->GetNextItem(
394 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
404 if (segmentListCtrl_->GetItemCount() > 0) {
405 segmentListCtrl_->SetItemState(
406 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
407 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
411 onDetachedSelection(
dummy);
422 item = connectedListCtrl_->GetNextItem(
423 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
427 Segment* seg = segment(connectedListCtrl_, item);
429 socket_->detachBus(*seg);
430 item = connectedListCtrl_->GetNextItem(
431 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
437 onAttachedSelection(
dummy);
452 busItem.SetId(index);
453 busItem.SetColumn(0);
454 listCtrl->GetItem(busItem);
458 segItem.SetId(index);
459 segItem.SetColumn(1);
460 listCtrl->GetItem(segItem);
464 Segment* segment = navigator.
item(busName)->segment(segmentName);
476 connectedListCtrl_->DeleteAllItems();
477 segmentListCtrl_->DeleteAllItems();
480 for (
int i = 0; i < socket_->segmentCount(); i++) {
482 Segment* segment = socket_->segment(i);
484 wxString segmentName =
489 connectedListCtrl_->InsertItem(i, busName);
490 connectedListCtrl_->SetItem(i, 1, segmentName);
496 for (
int i = 0; i < navigator.
count(); i++) {
500 if (tester_->canConnect(*socket_, *segment)) {
501 wxString segmentName =
506 segmentListCtrl_->InsertItem(segments, busName);
507 segmentListCtrl_->SetItem(segments, 1, segmentName);
515 if (socket_->segmentCount() > 0) {
531 if (connectedListCtrl_->GetSelectedItemCount() < 1) {
547 if (segmentListCtrl_->GetSelectedItemCount() < 1) {
568 wxWindow *parent,
bool call_fit,
bool set_sizer) {
570 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
572 wxGridSizer *item1 =
new wxGridSizer( 2, 0, 0 );
574 wxBoxSizer *item2 =
new wxBoxSizer( wxHORIZONTAL );
576 wxStaticText *item3 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
577 item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
579 wxTextCtrl *item4 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(120,-1), 0 );
580 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
582 item1->Add( item2, 0, wxGROW|wxALL, 5 );
589 wxRadioBox *item5 =
new wxRadioBox( parent, ID_DIRECTION, wxT(
"Direction:"), wxDefaultPosition, wxDefaultSize, 2, strs5, 1, wxRA_SPECIFY_COLS );
590 item1->Add( item5, 0, wxGROW|wxALL, 5 );
592 item0->Add( item1, 0, wxGROW|wxALL, 5 );
594 wxBoxSizer *item6 =
new wxBoxSizer( wxHORIZONTAL );
596 wxStaticBox *item8 =
new wxStaticBox( parent, -1, wxT(
"Attached buses:") );
597 wxStaticBoxSizer *item7 =
new wxStaticBoxSizer( item8, wxVERTICAL );
598 attachedSizer_ = item7;
600 wxListCtrl *item9 =
new wxListCtrl( parent, ID_ATTACHED_LIST, wxDefaultPosition, wxSize(200,120), wxLC_REPORT|wxSUNKEN_BORDER );
601 item7->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
603 item6->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
605 wxBoxSizer *item10 =
new wxBoxSizer( wxVERTICAL );
607 wxButton *item11 =
new wxButton( parent, ID_ATTACH, wxT(
"&Attach"), wxDefaultPosition, wxDefaultSize, 0 );
608 item10->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
610 wxButton *item12 =
new wxButton( parent, ID_DETACH, wxT(
"&Detach"), wxDefaultPosition, wxDefaultSize, 0 );
611 item10->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
613 item6->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
615 wxStaticBox *item14 =
new wxStaticBox( parent, -1, wxT(
"Detached buses:") );
616 wxStaticBoxSizer *item13 =
new wxStaticBoxSizer( item14, wxVERTICAL );
617 detachedSizer_ = item13;
619 wxListCtrl *item15 =
new wxListCtrl( parent, ID_DETACHED_LIST, wxDefaultPosition, wxSize(200,120), wxLC_REPORT|wxSUNKEN_BORDER );
620 item13->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
622 item6->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
624 item0->Add( item6, 0, wxALIGN_CENTER, 5 );
626 wxStaticLine *item16 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
627 item0->Add( item16, 0, wxGROW|wxALL, 5 );
629 wxGridSizer *item17 =
new wxGridSizer( 2, 0, 0 );
631 wxButton *item18 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
632 item17->Add( item18, 0, wxALL, 5 );
634 wxBoxSizer *item19 =
new wxBoxSizer( wxHORIZONTAL );
636 wxButton *item20 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
637 item19->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
639 wxButton *item21 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
640 item19->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
642 item17->Add( item19, 0, wxALL, 5 );
644 item0->Add( item17, 0, wxGROW|wxALL, 5 );
648 parent->SetSizer( item0 );
650 item0->SetSizeHints( parent );