35 #include <wx/statline.h>
36 #include <wx/spinctrl.h>
37 #include <wx/valgen.h>
38 #include <boost/format.hpp>
79 wxDialog(parent, -1, _T(""), wxDefaultPosition),
84 inputSocketChoice_(NULL),
85 outputSocketChoice_(NULL) {
87 oldInput_ = port_->inputSocket();
88 oldOutput_ = port_->outputSocket();
90 createContents(
this,
true,
true);
92 inputSocketChoice_ =
dynamic_cast<wxChoice*
>(
FindWindow(ID_INPUT_SOCKET));
93 outputSocketChoice_ =
dynamic_cast<wxChoice*
>(
FindWindow(ID_OUTPUT_SOCKET));
94 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
95 FindWindow(ID_TRIGGERS)->SetValidator(wxGenericValidator(&triggers_));
96 FindWindow(ID_WIDTH)->SetValidator(wxGenericValidator(&width_));
103 TransferDataToWindow();
122 format fmt = prodeTexts->
text(
162 width_ = port_->width();
163 triggers_ = port_->isTriggering();
168 dynamic_cast<wxSpinCtrl*
>(
FindWindow(ID_WIDTH))->SetValue(width_);
169 dynamic_cast<wxCheckBox*
>(
FindWindow(ID_TRIGGERS))->SetValue(triggers_);
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) {
293 for (
int i = 0; i < fu->
portCount(); i++) {
306 message % trimmedName % a_port.str() %
machine.str() %
317 port_->setName(trimmedName);
318 port_->setTriggering(triggers_);
319 port_->setWidth(width_);
329 port_->detachAllSockets();
331 port_->parentUnit()->machine()->socketNavigator();
334 string inputSocketName =
337 port_->attachSocket(*(navigator.
item(inputSocketName)));
341 string outputSocketName =
344 port_->attachSocket(*(navigator.
item(outputSocketName)));
355 if (!TransferDataFromWindow()) {
358 wxString trimmedName = name_.Trim(
false).Trim(
true);
359 if (trimmedName == _T(
"")) {
378 wxWindow *parent,
bool call_fit,
bool set_sizer) {
380 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
382 wxFlexGridSizer *item1 =
new wxFlexGridSizer( 2, 0, 0 );
384 wxStaticText *item2 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
385 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
387 wxTextCtrl *item3 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(200,-1), 0 );
388 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
390 wxStaticText *item4 =
new wxStaticText( parent, ID_LABEL_WIDTH, wxT(
"Width:"), wxDefaultPosition, wxDefaultSize, 0 );
391 item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
393 wxSpinCtrl *item5 =
new wxSpinCtrl( parent, ID_WIDTH, wxT(
"1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
394 item1->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
396 wxStaticText *item6 =
new wxStaticText( parent, ID_LABEL_INPUT_SOCKET, wxT(
"Input Socket:"), wxDefaultPosition, wxDefaultSize, 0 );
397 item1->Add( item6, 0, wxALIGN_RIGHT|wxALL, 5 );
403 wxChoice *item7 =
new wxChoice( parent, ID_INPUT_SOCKET, wxDefaultPosition, wxSize(200,-1), 1, strs7, 0 );
404 item1->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
406 wxStaticText *item8 =
new wxStaticText( parent, ID_LABEL_OUTPUT_SOCKET, wxT(
"Output Socket:"), wxDefaultPosition, wxDefaultSize, 0 );
407 item1->Add( item8, 0, wxALIGN_RIGHT|wxALL, 5 );
413 wxChoice *item9 =
new wxChoice( parent, ID_OUTPUT_SOCKET, wxDefaultPosition, wxSize(200,-1), 1, strs9, 0 );
414 item1->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
416 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
418 wxBoxSizer *item10 =
new wxBoxSizer( wxHORIZONTAL );
420 wxCheckBox *item11 =
new wxCheckBox( parent, ID_TRIGGERS, wxT(
"Triggers"), wxDefaultPosition, wxDefaultSize, 0 );
421 item10->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
423 item0->Add( item10, 0, wxALL, 5 );
425 wxStaticLine *item12 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
426 item0->Add( item12, 0, wxGROW|wxALL, 5 );
428 wxBoxSizer *item13 =
new wxBoxSizer( wxHORIZONTAL );
430 wxButton *item14 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
431 item13->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
433 wxButton *item15 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
434 item13->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
436 wxButton *item16 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
437 item13->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
439 item0->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
443 parent->SetSizer( item0 );
445 item0->SetSizeHints( parent );