OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SocketDialog Class Reference

#include <SocketDialog.hh>

Inheritance diagram for SocketDialog:
Inheritance graph
Collaboration diagram for SocketDialog:
Collaboration graph

Public Member Functions

 SocketDialog (wxWindow *parent, TTAMachine::Socket *socket)
 
virtual ~SocketDialog ()
 

Private Types

enum  {
  ID_NAME = 10000 , ID_ATTACHED_LIST , ID_DETACHED_LIST , ID_ATTACH ,
  ID_DETACH , ID_HELP , ID_DIRECTION , ID_LABEL_NAME ,
  ID_LINE
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
TTAMachine::Segmentsegment (wxListCtrl *listCtrl, int index)
 
void onOK (wxCommandEvent &)
 
void onHelp (wxCommandEvent &event)
 
void onName (wxCommandEvent &)
 
void onAttach (wxCommandEvent &)
 
void onDetach (wxCommandEvent &)
 
void onAttachedSelection (wxListEvent &)
 
void onDetachedSelection (wxListEvent &)
 
void onDirection (wxCommandEvent &)
 
void updateConnected ()
 
void updateDirection ()
 
virtual bool TransferDataToWindow ()
 
void setTexts ()
 

Private Attributes

TTAMachine::Socketsocket_
 Socket to modify.
 
wxString name_
 Name of the socket.
 
MachineTestertester_
 MachineTester which does sanity checks for the target machine.
 
wxRadioBox * directionBox_
 Radio box for direction.
 
wxListCtrl * connectedListCtrl_
 List control for connected (bus, segment) pairs.
 
wxListCtrl * segmentListCtrl_
 List control for all (bus, segment) pairs.
 
wxStaticBoxSizer * attachedSizer_
 Static boxsizer containing the list of attached buses.
 
wxStaticBoxSizer * detachedSizer_
 Static boxsizer containing the list of detached buses.
 

Detailed Description

Dialog for modifying socket attributes.

Definition at line 50 of file SocketDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_NAME 
ID_ATTACHED_LIST 
ID_DETACHED_LIST 
ID_ATTACH 
ID_DETACH 
ID_HELP 
ID_DIRECTION 
ID_LABEL_NAME 
ID_LINE 

Definition at line 88 of file SocketDialog.hh.

Constructor & Destructor Documentation

◆ SocketDialog()

SocketDialog::SocketDialog ( wxWindow *  parent,
TTAMachine::Socket socket 
)

The Constructor.

Parameters
parentParent window of the dialog.
socketSocket to be modified with the dialog.

Definition at line 90 of file SocketDialog.cc.

92 :
93 wxDialog(parent, -1, _T(""), wxDefaultPosition),
94 socket_(socket),
95 directionBox_(NULL),
97 segmentListCtrl_(NULL),
98 attachedSizer_(NULL),
99 detachedSizer_(NULL) {
100
101 createContents(this, true, true);
103
105
106 FindWindow(wxID_OK)->Disable();
107 FindWindow(ID_ATTACH)->Disable();
108 FindWindow(ID_DETACH)->Disable();
109
110 // Set widget pointers.
111 directionBox_ = dynamic_cast<wxRadioBox*>(FindWindow(ID_DIRECTION));
113 dynamic_cast<wxListCtrl*>(FindWindow(ID_ATTACHED_LIST));
115 dynamic_cast<wxListCtrl*>(FindWindow(ID_DETACHED_LIST));
116
117 // Set widget validators.
118 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
119
120 // sets labels for widgets
121 setTexts();
122
124}
wxString name_
Name of the socket.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
wxStaticBoxSizer * attachedSizer_
Static boxsizer containing the list of attached buses.
virtual bool TransferDataToWindow()
wxRadioBox * directionBox_
Radio box for direction.
TTAMachine::Socket * socket_
Socket to modify.
wxListCtrl * connectedListCtrl_
List control for connected (bus, segment) pairs.
MachineTester * tester_
MachineTester which does sanity checks for the target machine.
wxStaticBoxSizer * detachedSizer_
Static boxsizer containing the list of detached buses.
wxListCtrl * segmentListCtrl_
List control for all (bus, segment) pairs.
virtual Machine * machine() const
virtual TCEString name() const
static wxString toWxString(const std::string &source)

References WxConversion::toWxString().

Here is the call graph for this function:

◆ ~SocketDialog()

SocketDialog::~SocketDialog ( )
virtual

The Destructor.

Definition at line 130 of file SocketDialog.cc.

130 {
131 delete tester_;
132}

References tester_.

Member Function Documentation

◆ createContents()

wxSizer * SocketDialog::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the dialog window contents.

This method was initially generated with wxDesigner, code will be cleaned up later.

Returns
Main sizer of the created contents.
Parameters
parentThe dialog window.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.

Definition at line 567 of file SocketDialog.cc.

568 {
569
570 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
571
572 wxGridSizer *item1 = new wxGridSizer( 2, 0, 0 );
573
574 wxBoxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
575
576 wxStaticText *item3 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
577 item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
578
579 wxTextCtrl *item4 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(120,-1), 0 );
580 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
581
582 item1->Add( item2, 0, wxGROW|wxALL, 5 );
583
584 wxString strs5[] =
585 {
586 wxT("Input"),
587 wxT("Output")
588 };
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 );
591
592 item0->Add( item1, 0, wxGROW|wxALL, 5 );
593
594 wxBoxSizer *item6 = new wxBoxSizer( wxHORIZONTAL );
595
596 wxStaticBox *item8 = new wxStaticBox( parent, -1, wxT("Attached buses:") );
597 wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxVERTICAL );
598 attachedSizer_ = item7;
599
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 );
602
603 item6->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
604
605 wxBoxSizer *item10 = new wxBoxSizer( wxVERTICAL );
606
607 wxButton *item11 = new wxButton( parent, ID_ATTACH, wxT("&Attach"), wxDefaultPosition, wxDefaultSize, 0 );
608 item10->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
609
610 wxButton *item12 = new wxButton( parent, ID_DETACH, wxT("&Detach"), wxDefaultPosition, wxDefaultSize, 0 );
611 item10->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
612
613 item6->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
614
615 wxStaticBox *item14 = new wxStaticBox( parent, -1, wxT("Detached buses:") );
616 wxStaticBoxSizer *item13 = new wxStaticBoxSizer( item14, wxVERTICAL );
617 detachedSizer_ = item13;
618
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 );
621
622 item6->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
623
624 item0->Add( item6, 0, wxALIGN_CENTER, 5 );
625
626 wxStaticLine *item16 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
627 item0->Add( item16, 0, wxGROW|wxALL, 5 );
628
629 wxGridSizer *item17 = new wxGridSizer( 2, 0, 0 );
630
631 wxButton *item18 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
632 item17->Add( item18, 0, wxALL, 5 );
633
634 wxBoxSizer *item19 = new wxBoxSizer( wxHORIZONTAL );
635
636 wxButton *item20 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
637 item19->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
638
639 wxButton *item21 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
640 item19->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
641
642 item17->Add( item19, 0, wxALL, 5 );
643
644 item0->Add( item17, 0, wxGROW|wxALL, 5 );
645
646 if (set_sizer)
647 {
648 parent->SetSizer( item0 );
649 if (call_fit)
650 item0->SetSizeHints( parent );
651 }
652
653 return item0;
654}

References attachedSizer_, detachedSizer_, ID_ATTACH, ID_ATTACHED_LIST, ID_DETACH, ID_DETACHED_LIST, ID_DIRECTION, ID_HELP, ID_LABEL_NAME, ID_LINE, and ID_NAME.

◆ onAttach()

void SocketDialog::onAttach ( wxCommandEvent &  )
private

Attaches selected segments on the segment list to the socket.

Definition at line 364 of file SocketDialog.cc.

364 {
365
366 long item = -1;
367 item = segmentListCtrl_->GetNextItem(
368 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
369
370 // Socket state is saved, so it can be restored if the socket can't
371 // be connected to all selected segments.
372 ObjectState* savedState = socket_->saveState();
373 MachineTester tester(*socket_->machine());
374
375 // Try to connect socket to all selected segments.
376 while (item != -1) {
377
378 Segment* seg = segment(segmentListCtrl_, item);
379 assert(seg != NULL);
380
381 if (!tester.canConnect(*socket_, *seg)) {
382 // Socket couldn't be connected to all selected segments.
383 std::string error =
385 *socket_, *seg, tester);
386 wxString message = WxConversion::toWxString(error);
387 InformationDialog dialog(this, message);
388 dialog.ShowModal();
389 socket_->loadState(savedState);
390 break;
391 }
392 socket_->attachBus(*seg);
393 item = segmentListCtrl_->GetNextItem(
394 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
395 }
396 delete savedState;
397 savedState = NULL;
398
401
402 // Select the first item in the segment list (if possible) to improve
403 // the dialog usability.
404 if (segmentListCtrl_->GetItemCount() > 0) {
405 segmentListCtrl_->SetItemState(
406 0, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED,
407 wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
408 }
409
410 wxListEvent dummy;
412
413}
#define assert(condition)
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
static std::string socketSegmentConnectionError(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment, const MachineTester &tester)
void updateDirection()
TTAMachine::Segment * segment(wxListCtrl *listCtrl, int index)
void onDetachedSelection(wxListEvent &)
void updateConnected()
virtual void loadState(const ObjectState *state)
Definition Socket.cc:502
void attachBus(Segment &bus)
Definition Socket.cc:166
virtual ObjectState * saveState() const
Definition Socket.cc:465

References assert, TTAMachine::Socket::attachBus(), MachineTester::canConnect(), dummy, TTAMachine::Socket::loadState(), TTAMachine::Component::machine(), onDetachedSelection(), TTAMachine::Socket::saveState(), segment(), segmentListCtrl_, socket_, MachineTestReporter::socketSegmentConnectionError(), WxConversion::toWxString(), updateConnected(), and updateDirection().

Here is the call graph for this function:

◆ onAttachedSelection()

void SocketDialog::onAttachedSelection ( wxListEvent &  )
private

Disables and enables Detach button under the connected list.

If a (bus, segment) pair is selected, button is enabled. If no (bus, segment) pair is selected the button will be disabled.

Definition at line 530 of file SocketDialog.cc.

530 {
531 if (connectedListCtrl_->GetSelectedItemCount() < 1) {
532 FindWindow(ID_DETACH)->Disable();
533 return;
534 }
535 FindWindow(ID_DETACH)->Enable();
536}

References connectedListCtrl_, and ID_DETACH.

Referenced by onDetach().

◆ onDetach()

void SocketDialog::onDetach ( wxCommandEvent &  )
private

Detaches selected segments on the connection list from the socket.

Definition at line 419 of file SocketDialog.cc.

419 {
420
421 long item = -1;
422 item = connectedListCtrl_->GetNextItem(
423 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
424
425 // Detach socket from all selected segments.
426 while (item != -1) {
427 Segment* seg = segment(connectedListCtrl_, item);
428 assert(seg != NULL);
429 socket_->detachBus(*seg);
430 item = connectedListCtrl_->GetNextItem(
431 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
432 }
433
436 wxListEvent dummy;
438
439}
void onAttachedSelection(wxListEvent &)
void detachBus(Segment &bus)
Definition Socket.cc:213

References assert, connectedListCtrl_, TTAMachine::Socket::detachBus(), dummy, onAttachedSelection(), segment(), socket_, updateConnected(), and updateDirection().

Here is the call graph for this function:

◆ onDetachedSelection()

void SocketDialog::onDetachedSelection ( wxListEvent &  )
private

Disables and enables Attach button under the connected list.

If a (bus, segment) pair is selected, button is enabled. If no (bus, segment) pair is selected the button will be disabled.

Definition at line 546 of file SocketDialog.cc.

546 {
547 if (segmentListCtrl_->GetSelectedItemCount() < 1) {
548 FindWindow(ID_ATTACH)->Disable();
549 return;
550 }
551 FindWindow(ID_ATTACH)->Enable();
552}

References ID_ATTACH, and segmentListCtrl_.

Referenced by onAttach().

◆ onDirection()

void SocketDialog::onDirection ( wxCommandEvent &  )
private

Checks whether socket direction can be changed.

Due to the port connections to the sockets it might be impossible. If the socket is connected to the port already containing a connection to socket of this direction, changing the direction is not allowed.

Definition at line 315 of file SocketDialog.cc.

315 {
316
317 wxString direction = directionBox_->GetStringSelection();
318
319 if (direction.IsSameAs(ProDeConstants::SOCKET_DIRECTION_INPUT) &&
321
322 // It wasn't legal to change the direction to input,
323 // display an error message.
324 string message =
327
328 WarningDialog dialog(this, WxConversion::toWxString(message));
329 dialog.ShowModal();
330 directionBox_->SetStringSelection(
332
333 } else if(direction.IsSameAs(ProDeConstants::SOCKET_DIRECTION_OUTPUT) &&
335
336 // It wasn't legal to change the direction to output,
337 // display an error message.
338 string message =
341
342 WarningDialog dialog(this, WxConversion::toWxString(message));
343
344 dialog.ShowModal();
345 directionBox_->SetStringSelection(
347 }
348
349 direction = directionBox_->GetStringSelection();
350
351 if (direction.IsSameAs(ProDeConstants::SOCKET_DIRECTION_INPUT)) {
353 }
354 if (direction.IsSameAs(ProDeConstants::SOCKET_DIRECTION_OUTPUT)) {
356 }
357}
static std::string socketDirectionSettingError(const TTAMachine::Socket &socket, TTAMachine::Socket::Direction, const MachineTester &tester)
virtual bool canSetDirection(const TTAMachine::Socket &socket, TTAMachine::Socket::Direction direction)
static const wxString SOCKET_DIRECTION_INPUT
String for the socket direction: input.
static const wxString SOCKET_DIRECTION_OUTPUT
String for the socket direction output.
void setDirection(Direction direction)
Definition Socket.cc:130
@ OUTPUT
Data goes from port to bus.
Definition Socket.hh:60
@ INPUT
Data goes from bus to port.
Definition Socket.hh:59

References MachineTester::canSetDirection(), directionBox_, TTAMachine::Socket::INPUT, TTAMachine::Socket::OUTPUT, TTAMachine::Socket::setDirection(), socket_, ProDeConstants::SOCKET_DIRECTION_INPUT, ProDeConstants::SOCKET_DIRECTION_OUTPUT, MachineTestReporter::socketDirectionSettingError(), tester_, and WxConversion::toWxString().

Here is the call graph for this function:

◆ onHelp()

void SocketDialog::onHelp ( wxCommandEvent &  event)
private

◆ onName()

void SocketDialog::onName ( wxCommandEvent &  )
private

Enables and disables OK button based on input in the socket name.

Definition at line 293 of file SocketDialog.cc.

293 {
294 if (!TransferDataFromWindow()) {
295 assert(false);
296 }
297 wxString trimmedName = name_.Trim(false).Trim(true);
298 if (trimmedName == _T("")) {
299 FindWindow(wxID_OK)->Disable();
300 } else {
301 FindWindow(wxID_OK)->Enable();
302 }
303}

References assert, and name_.

◆ onOK()

void SocketDialog::onOK ( wxCommandEvent &  )
private

Validates input in the controls, and updates the Socket.

Definition at line 236 of file SocketDialog.cc.

236 {
237
238 if (!Validate()) {
239 return;
240 }
241 if (!TransferDataFromWindow()) {
242 return;
243 }
244
245 string trimmedName =
246 WxConversion::toString(name_.Trim(false).Trim(true));
247
248 // Check the name validity.
249 if (!MachineTester::isValidComponentName(trimmedName)) {
251 format message =
253 InformationDialog warning(
254 this, WxConversion::toWxString(message.str()));
255 warning.ShowModal();
256 return;
257 }
258
259 if (trimmedName != socket_->name()) {
260 Machine::SocketNavigator navigator =
262 for (int i = 0; i < navigator.count(); i++) {
263 Socket* socket = navigator.item(i);
264 if (trimmedName == socket->name()) {
265 ProDeTextGenerator* prodeTexts =
267 format message =
269 format a_soc =
271 format machine =
273 format soc =
275 message %
276 trimmedName % a_soc.str() % machine.str() % soc.str();
277 WarningDialog warning(
278 this, WxConversion::toWxString(message.str()));
279 warning.ShowModal();
280 return;
281 }
282 }
283 }
284 socket_->setName(trimmedName);
285 EndModal(wxID_OK);
286}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
static bool isValidComponentName(const std::string &name)
static ProDeTextGenerator * instance()
@ MSG_ERROR_SAME_NAME
Error: Same name exists.
@ MSG_ERROR_ILLEGAL_NAME
Error: Illegal component name.
@ COMP_MACHINE
Text for machine description.
@ COMP_SOCKET
Name for socket (w/o article).
@ COMP_A_SOCKET
Name for socket (w/ article).
ComponentType * item(int index) const
virtual SocketNavigator socketNavigator() const
Definition Machine.cc:368
virtual void setName(const std::string &name)
Definition Socket.cc:103
virtual boost::format text(int textId)
static std::string toString(const wxString &source)

References ProDeTextGenerator::COMP_A_SOCKET, ProDeTextGenerator::COMP_MACHINE, ProDeTextGenerator::COMP_SOCKET, TTAMachine::Machine::Navigator< ComponentType >::count(), ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), machine, ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, TTAMachine::Component::name(), name_, TTAMachine::Socket::setName(), socket_, TTAMachine::Machine::socketNavigator(), Texts::TextGenerator::text(), WxConversion::toString(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ segment()

Segment * SocketDialog::segment ( wxListCtrl *  listCtrl,
int  index 
)
private

Returns pointer to a segment with given index on a list.

Parameters
listCtrlList containing the segment.
indexList index of the segment.
Returns
Pointer to the segment.

Definition at line 449 of file SocketDialog.cc.

449 {
450
451 wxListItem busItem;
452 busItem.SetId(index);
453 busItem.SetColumn(0);
454 listCtrl->GetItem(busItem);
455 string busName = WxConversion::toString(busItem.GetText());
456
457 wxListItem segItem;
458 segItem.SetId(index);
459 segItem.SetColumn(1);
460 listCtrl->GetItem(segItem);
461 string segmentName = WxConversion::toString(segItem.GetText());
462
464 Segment* segment = navigator.item(busName)->segment(segmentName);
465 return segment;
466}
virtual BusNavigator busNavigator() const
Definition Machine.cc:356

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), segment(), socket_, and WxConversion::toString().

Referenced by onAttach(), onDetach(), segment(), and updateConnected().

Here is the call graph for this function:

◆ setTexts()

void SocketDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 139 of file SocketDialog.cc.

139 {
142
143 // Dialog title
144 format fmt = prodeTexts->text(ProDeTextGenerator::TXT_SOCKET_DIALOG_TITLE);
145 SetTitle(WxConversion::toWxString(fmt.str()));
146
147 // buttons
148 WidgetTools::setLabel(generator, FindWindow(wxID_OK),
150
151 WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
153
156
159
162
163 // widget labels
166
169
170 // box sizer label
173
176
177 // Create list columns.
178 wxListCtrl* attachedList =
179 dynamic_cast<wxListCtrl*>(FindWindow(ID_ATTACHED_LIST));
180 fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_BUS);
181 attachedList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
182 wxLIST_FORMAT_LEFT, 100);
184 attachedList->InsertColumn(1, WxConversion::toWxString(fmt.str()),
185 wxLIST_FORMAT_LEFT, 80);
186
187 wxListCtrl* detachedList =
188 dynamic_cast<wxListCtrl*>(FindWindow(ID_DETACHED_LIST));
189 fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_BUS);
190 detachedList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
191 wxLIST_FORMAT_LEFT, 100);
193 detachedList->InsertColumn(1, WxConversion::toWxString(fmt.str()),
194 wxLIST_FORMAT_LEFT, 80);
195
196 // Radio button labels
198 directionBox_->SetString(0, WxConversion::toWxString(fmt.str()));
200 directionBox_->SetString(1, WxConversion::toWxString(fmt.str()));
201}
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
@ TXT_BUTTON_DETACH
Label for detach button.
@ TXT_SOCKET_ATTACHED_BOX
Label for Attached buses box.
@ TXT_COLUMN_SEGMENT
Label for segment column.
@ TXT_LABEL_NAME
Label for component name widget.
@ TXT_SOCKET_DETACHED_BOX
Label for Detached buses box.
@ TXT_SOCKET_DIALOG_TITLE
Socket dialog title.
@ TXT_RADIO_DIRECTION_INPUT
Label for input radio button.
@ TXT_LABEL_DIRECTION
Label for direction widget.
@ TXT_COLUMN_BUS
Label for bus column in a list.
@ TXT_BUTTON_ATTACH
Label for attach button.
@ TXT_RADIO_DIRECTION_OUTPUT
Label for output radio button.
static void setWidgetLabel(wxWindow *widget, std::string text)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References attachedSizer_, detachedSizer_, directionBox_, ID_ATTACH, ID_ATTACHED_LIST, ID_DETACH, ID_DETACHED_LIST, ID_DIRECTION, ID_HELP, ID_LABEL_NAME, GUITextGenerator::instance(), ProDeTextGenerator::instance(), WidgetTools::setLabel(), WidgetTools::setWidgetLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_BUTTON_ATTACH, GUITextGenerator::TXT_BUTTON_CANCEL, ProDeTextGenerator::TXT_BUTTON_DETACH, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_COLUMN_BUS, ProDeTextGenerator::TXT_COLUMN_SEGMENT, ProDeTextGenerator::TXT_LABEL_DIRECTION, ProDeTextGenerator::TXT_LABEL_NAME, ProDeTextGenerator::TXT_RADIO_DIRECTION_INPUT, ProDeTextGenerator::TXT_RADIO_DIRECTION_OUTPUT, ProDeTextGenerator::TXT_SOCKET_ATTACHED_BOX, ProDeTextGenerator::TXT_SOCKET_DETACHED_BOX, and ProDeTextGenerator::TXT_SOCKET_DIALOG_TITLE.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool SocketDialog::TransferDataToWindow ( )
privatevirtual

Transfers data from the socket object to the dialog widgets.

Definition at line 208 of file SocketDialog.cc.

208 {
209 // Socket direction.
212 return wxDialog::TransferDataToWindow();
213}

References updateConnected(), and updateDirection().

Here is the call graph for this function:

◆ updateConnected()

void SocketDialog::updateConnected ( )
private

Updates connected list elements.

Definition at line 474 of file SocketDialog.cc.

474 {
475
476 connectedListCtrl_->DeleteAllItems();
477 segmentListCtrl_->DeleteAllItems();
478
479 // update connections list
480 for (int i = 0; i < socket_->segmentCount(); i++) {
481
483
484 wxString segmentName =
486 wxString busName =
488
489 connectedListCtrl_->InsertItem(i, busName);
490 connectedListCtrl_->SetItem(i, 1, segmentName);
491 }
492
493 // update list of segments available for connection
495 int segments = 0;
496 for (int i = 0; i < navigator.count(); i++) {
497 Bus* bus = navigator.item(i);
498 for (int j = 0; j < bus->segmentCount(); j++) {
499 Segment* segment = bus->segment(j);
501 wxString segmentName =
503 wxString busName =
505
506 segmentListCtrl_->InsertItem(segments, busName);
507 segmentListCtrl_->SetItem(segments, 1, segmentName);
508 segments++;
509 }
510 }
511 }
512
513 // Disable the direction control if the socket is not
514 // connected to a bus.
515 if (socket_->segmentCount() > 0) {
516 FindWindow(ID_DIRECTION)->Enable();
517 } else {
518 FindWindow(ID_DIRECTION)->Disable();
519 }
520}
virtual bool canConnect(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment)
virtual Segment * segment(int index) const
Definition Bus.cc:329
virtual int segmentCount() const
Definition Bus.cc:385
std::string name() const
Bus * parentBus() const
Segment * segment(int index) const
Definition Socket.cc:401
int segmentCount() const

References TTAMachine::Machine::busNavigator(), MachineTester::canConnect(), connectedListCtrl_, TTAMachine::Machine::Navigator< ComponentType >::count(), ID_DIRECTION, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Component::name(), TTAMachine::Segment::name(), TTAMachine::Segment::parentBus(), TTAMachine::Bus::segment(), TTAMachine::Socket::segment(), segment(), TTAMachine::Bus::segmentCount(), TTAMachine::Socket::segmentCount(), segmentListCtrl_, socket_, tester_, and WxConversion::toWxString().

Referenced by onAttach(), onDetach(), and TransferDataToWindow().

Here is the call graph for this function:

◆ updateDirection()

void SocketDialog::updateDirection ( )
private

Updates the direction choicer.

Definition at line 220 of file SocketDialog.cc.

220 {
221 if (socket_->direction() == Socket::INPUT) {
222 directionBox_->SetStringSelection(
224 } else if (socket_->direction() == Socket::OUTPUT) {
225 directionBox_->SetStringSelection(
227 }
228
229}
Direction direction() const

References TTAMachine::Socket::direction(), directionBox_, TTAMachine::Socket::INPUT, TTAMachine::Socket::OUTPUT, socket_, ProDeConstants::SOCKET_DIRECTION_INPUT, and ProDeConstants::SOCKET_DIRECTION_OUTPUT.

Referenced by onAttach(), onDetach(), and TransferDataToWindow().

Here is the call graph for this function:

Member Data Documentation

◆ attachedSizer_

wxStaticBoxSizer* SocketDialog::attachedSizer_
private

Static boxsizer containing the list of attached buses.

Definition at line 84 of file SocketDialog.hh.

Referenced by createContents(), and setTexts().

◆ connectedListCtrl_

wxListCtrl* SocketDialog::connectedListCtrl_
private

List control for connected (bus, segment) pairs.

Definition at line 80 of file SocketDialog.hh.

Referenced by onAttachedSelection(), onDetach(), and updateConnected().

◆ detachedSizer_

wxStaticBoxSizer* SocketDialog::detachedSizer_
private

Static boxsizer containing the list of detached buses.

Definition at line 86 of file SocketDialog.hh.

Referenced by createContents(), and setTexts().

◆ directionBox_

wxRadioBox* SocketDialog::directionBox_
private

Radio box for direction.

Definition at line 78 of file SocketDialog.hh.

Referenced by onDirection(), setTexts(), and updateDirection().

◆ name_

wxString SocketDialog::name_
private

Name of the socket.

Definition at line 74 of file SocketDialog.hh.

Referenced by onName(), and onOK().

◆ segmentListCtrl_

wxListCtrl* SocketDialog::segmentListCtrl_
private

List control for all (bus, segment) pairs.

Definition at line 82 of file SocketDialog.hh.

Referenced by onAttach(), onDetachedSelection(), and updateConnected().

◆ socket_

TTAMachine::Socket* SocketDialog::socket_
private

Socket to modify.

Definition at line 72 of file SocketDialog.hh.

Referenced by onAttach(), onDetach(), onDirection(), onOK(), segment(), updateConnected(), and updateDirection().

◆ tester_

MachineTester* SocketDialog::tester_
private

MachineTester which does sanity checks for the target machine.

Definition at line 76 of file SocketDialog.hh.

Referenced by onDirection(), updateConnected(), and ~SocketDialog().


The documentation for this class was generated from the following files: