34 #include <wx/statline.h>
35 #include <boost/format.hpp>
74 wxDialog(parent, -1, _T(""), wxDefaultPosition),
77 inputSocketChoice_(NULL),
78 outputSocketChoice_(NULL) {
80 oldInput_ = port_->inputSocket();
81 oldOutput_ = port_->outputSocket();
82 createContents(
this,
true,
true);
88 TransferDataToWindow();
106 format fmt = prodeTexts->
text(
141 if (!TransferDataFromWindow()) {
160 if (port_->name() != trimmedName) {
161 Unit* rf = port_->parentUnit();
162 for (
int i = 0; i < rf->
portCount(); i++) {
175 message % trimmedName % a_port.str() % rf.str() % port.str();
184 port_->setName(trimmedName);
199 port_->detachAllSockets();
200 if (oldInput_ != NULL) {
201 port_->attachSocket(*oldInput_);
203 if (oldOutput_ != NULL) {
204 port_->attachSocket(*oldOutput_);
206 EndModal(wxID_CANCEL);
218 return wxWindow::TransferDataToWindow();
226 port_->detachAllSockets();
228 port_->parentUnit()->machine()->socketNavigator();
231 string inputSocketName =
234 port_->attachSocket(*(navigator.
item(inputSocketName)));
238 string outputSocketName =
241 port_->attachSocket(*(navigator.
item(outputSocketName)));
252 inputSocketChoice_->Clear();
254 outputSocketChoice_->Clear();
261 port_->parentUnit()->machine()->socketNavigator();
263 for (
int i = 0; i < navigator.
count(); i++) {
268 Socket* input = port_->inputSocket();
270 port_->detachSocket(*input);
272 bool legal = tester.
canConnect(*socket, *port_);
274 inputSocketChoice_->Append(socketName);
277 port_->attachSocket(*input);
281 Socket* output = port_->outputSocket();
282 if (output != NULL) {
283 port_->detachSocket(*output);
287 outputSocketChoice_->Append(socketName);
289 if (output != NULL) {
290 port_->attachSocket(*output);
296 if (port_->inputSocket() == NULL) {
299 wxString socketName =
301 inputSocketChoice_->SetStringSelection(socketName);
305 if (port_->outputSocket() == NULL) {
308 wxString socketName =
310 outputSocketChoice_->SetStringSelection(socketName);
319 if (!TransferDataFromWindow()) {
322 wxString trimmedName = name_.Trim(
false).Trim(
true);
323 if (trimmedName == _T(
"")) {
341 wxWindow *parent,
bool call_fit,
bool set_sizer) {
343 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
344 wxFlexGridSizer *item1 =
new wxFlexGridSizer( 2, 0, 0 );
347 wxStaticText *item2 =
348 new wxStaticText( parent, -1, wxT(
"Name:"),
349 wxDefaultPosition, wxDefaultSize, 0 );
350 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
352 new wxTextCtrl(parent, ID_NAME, wxT(
""), wxDefaultPosition,
354 wxTextValidator(wxFILTER_ASCII, &name_) );
355 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
358 wxStaticText *item4 =
359 new wxStaticText(parent, -1, wxT(
"Input Socket:"),
360 wxDefaultPosition, wxDefaultSize, 0);
361 item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
362 wxString *strs5 = (wxString*) NULL;
364 new wxChoice(parent, ID_INPUT_SOCKET, wxDefaultPosition,
365 wxSize(100,-1), 0, strs5, 0);
366 item1->Add( inputSocketChoice_, 0,
370 wxStaticText *item6 =
371 new wxStaticText(parent, -1, wxT(
"Output Socket:"),
372 wxDefaultPosition, wxDefaultSize, 0);
373 item1->Add( item6, 0, wxALIGN_RIGHT|wxALL, 5 );
374 wxString *strs7 = (wxString*) NULL;
375 outputSocketChoice_ =
376 new wxChoice(parent, ID_OUTPUT_SOCKET, wxDefaultPosition,
377 wxSize(100,-1), 0, strs7, 0);
378 item1->Add( outputSocketChoice_, 0,
380 item0->Add( item1, 0, wxGROW|wxALL, 5 );
381 wxStaticLine *item8 =
382 new wxStaticLine(parent, -1, wxDefaultPosition, wxSize(20,-1),
384 item0->Add( item8, 0, wxGROW|wxALL, 5 );
385 wxBoxSizer *item9 =
new wxBoxSizer( wxHORIZONTAL );
389 new wxButton(parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition,
391 item9->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
394 new wxButton(parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition,
396 item9->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
398 new wxButton(parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition,
400 item9->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
401 item0->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
404 parent->SetAutoLayout(
TRUE );
405 parent->SetSizer( item0 );
408 item0->Fit( parent );
409 item0->SetSizeHints( parent );