36 #include <wx/statline.h>
37 #include <wx/spinctrl.h>
38 #include <wx/valgen.h>
39 #include <boost/format.hpp>
81 wxDialog(parent, -1, _T(""), wxDefaultPosition),
85 inputSocketChoice_(NULL),
86 outputSocketChoice_(NULL) {
88 oldInput_ = port_->inputSocket();
89 oldOutput_ = port_->outputSocket();
91 createContents(
this,
true,
true);
94 dynamic_cast<wxChoice*
>(
FindWindow(ID_INPUT_SOCKET));
96 dynamic_cast<wxChoice*
>(
FindWindow(ID_OUTPUT_SOCKET));
98 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
99 FindWindow(ID_WIDTH)->SetValidator(wxGenericValidator(&width_));
106 TransferDataToWindow();
125 format fmt = prodeTexts->
text(
164 width_ = port_->width();
169 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_WIDTH))->SetValue(width_);
171 return wxWindow::TransferDataToWindow();
181 inputSocketChoice_->Clear();
183 outputSocketChoice_->Clear();
190 port_->parentUnit()->machine()->socketNavigator();
192 for (
int i = 0; i < navigator.
count(); i++) {
197 Socket* input = port_->inputSocket();
199 port_->detachSocket(*input);
201 bool legal = tester.
canConnect(*socket, *port_);
203 inputSocketChoice_->Append(socketName);
206 port_->attachSocket(*input);
210 Socket* output = port_->outputSocket();
211 if (output != NULL) {
212 port_->detachSocket(*output);
216 outputSocketChoice_->Append(socketName);
218 if (output != NULL) {
219 port_->attachSocket(*output);
225 if (port_->inputSocket() == NULL) {
228 wxString socketName =
230 inputSocketChoice_->SetStringSelection(socketName);
234 if (port_->outputSocket() == NULL) {
237 wxString socketName =
239 outputSocketChoice_->SetStringSelection(socketName);
250 port_->detachAllSockets();
251 if (oldInput_ != NULL) {
252 port_->attachSocket(*oldInput_);
254 if (oldOutput_ != NULL) {
255 port_->attachSocket(*oldOutput_);
257 EndModal(wxID_CANCEL);
271 if (!TransferDataFromWindow()) {
291 if (port_->name() != trimmedName) {
298 for (
int i = 0; i < gcu->
portCount(); i++) {
311 message % trimmedName % a_port.str() %
machine.str() %
322 port_->setName(trimmedName);
323 port_->setWidth(width_);
333 port_->detachAllSockets();
335 port_->parentUnit()->machine()->socketNavigator();
338 string inputSocketName =
341 port_->attachSocket(*(navigator.
item(inputSocketName)));
345 string outputSocketName =
348 port_->attachSocket(*(navigator.
item(outputSocketName)));
359 if (!TransferDataFromWindow()) {
362 wxString trimmedName = name_.Trim(
false).Trim(
true);
363 if (trimmedName == _T(
"")) {
382 wxWindow *parent,
bool call_fit,
bool set_sizer) {
384 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
386 wxFlexGridSizer *item1 =
new wxFlexGridSizer( 2, 0, 0 );
388 wxStaticText *item2 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
389 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
391 wxTextCtrl *item3 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(200,-1), 0 );
392 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
394 wxStaticText *item4 =
new wxStaticText( parent, ID_LABEL_WIDTH, wxT(
"Width:"), wxDefaultPosition, wxDefaultSize, 0 );
395 item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
397 wxSpinCtrl *item5 =
new wxSpinCtrl( parent, ID_WIDTH, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
398 item1->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
400 wxStaticText *item6 =
new wxStaticText( parent, ID_LABEL_INPUT_SOCKET, wxT(
"Input Socket:"), wxDefaultPosition, wxDefaultSize, 0 );
401 item1->Add( item6, 0, wxALIGN_RIGHT|wxALL, 5 );
407 wxChoice *item7 =
new wxChoice( parent, ID_INPUT_SOCKET, wxDefaultPosition, wxSize(200,-1), 1, strs7, 0 );
408 item1->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
410 wxStaticText *item8 =
new wxStaticText( parent, ID_LABEL_OUTPUT_SOCKET, wxT(
"Output Socket:"), wxDefaultPosition, wxDefaultSize, 0 );
411 item1->Add( item8, 0, wxALIGN_RIGHT|wxALL, 5 );
417 wxChoice *item9 =
new wxChoice( parent, ID_OUTPUT_SOCKET, wxDefaultPosition, wxSize(200,-1), 1, strs9, 0 );
418 item1->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
420 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
422 wxStaticLine *item10 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
423 item0->Add( item10, 0, wxGROW|wxALL, 5 );
425 wxBoxSizer *item11 =
new wxBoxSizer( wxHORIZONTAL );
427 wxButton *item12 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
428 item11->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
430 wxButton *item13 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
431 item11->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
433 wxButton *item14 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
434 item11->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
436 item0->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
440 parent->SetSizer( item0 );
442 item0->SetSizeHints( parent );