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

#include <ProDeBusOrderDialog.hh>

Inheritance diagram for ProDeBusOrderDialog:
Inheritance graph
Collaboration diagram for ProDeBusOrderDialog:
Collaboration graph

Public Member Functions

 ProDeBusOrderDialog (wxWindow *parent, TTAMachine::Machine &machine)
 
virtual ~ProDeBusOrderDialog ()
 

Private Types

enum  { ID_UP = 10000 , ID_DOWN , ID_LINE , ID_LIST }
 

Private Member Functions

void onUp (wxCommandEvent &event)
 
void onDown (wxCommandEvent &event)
 
void onBusSelectionChanged (wxListEvent &event)
 
void updateBusList ()
 
int selectedBus () const
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 

Private Attributes

TTAMachine::Machinemachine_
 Machine containing the buses to sort.
 
wxListCtrl * list_
 List widget for the buses.
 

Detailed Description

Dialog for modifying order of transport buses in a machine.

Definition at line 48 of file ProDeBusOrderDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_UP 
ID_DOWN 
ID_LINE 
ID_LIST 

Definition at line 61 of file ProDeBusOrderDialog.hh.

Constructor & Destructor Documentation

◆ ProDeBusOrderDialog()

ProDeBusOrderDialog::ProDeBusOrderDialog ( wxWindow *  parent,
TTAMachine::Machine machine 
)

The Constructor.

Parameters
parentParent window of the dialog.
machineMachine containing the buses to order.

Definition at line 53 of file ProDeBusOrderDialog.cc.

54 :
55 wxDialog(parent, -1, _T("Transport Bus Order"), wxDefaultPosition),
57
58 createContents(this, true, true);
59
60 list_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_LIST));
61 list_->InsertColumn(0, _T("index"), wxLIST_FORMAT_LEFT, 50);
62 list_->InsertColumn(1, _T("bus"), wxLIST_FORMAT_LEFT, 180);
63
64 // Disable conditional buttons.
65 FindWindow(ID_UP)->Disable();
66 FindWindow(ID_DOWN)->Disable();
67
69
70}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
TTAMachine::Machine & machine_
Machine containing the buses to sort.
wxListCtrl * list_
List widget for the buses.

◆ ~ProDeBusOrderDialog()

ProDeBusOrderDialog::~ProDeBusOrderDialog ( )
virtual

The Destructor.

Definition at line 75 of file ProDeBusOrderDialog.cc.

75 {
76}

Member Function Documentation

◆ createContents()

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

Creates the dialog widgets.

Definition at line 192 of file ProDeBusOrderDialog.cc.

193 {
194
195 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
196
197 wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
198
199 wxListCtrl *item2 = new wxListCtrl( parent, ID_LIST, wxDefaultPosition, wxSize(250,300), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
200 item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
201
202 wxBoxSizer *item3 = new wxBoxSizer( wxVERTICAL );
203
204 wxButton *item4 = new wxButton( parent, ID_UP, wxT("&Up"), wxDefaultPosition, wxDefaultSize, 0 );
205 item3->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
206
207 wxButton *item5 = new wxButton( parent, ID_DOWN, wxT("&Down"), wxDefaultPosition, wxDefaultSize, 0 );
208 item3->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
209
210 item1->Add( item3, 0, wxALL, 5 );
211
212 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
213
214 wxStaticLine *item6 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
215 item0->Add( item6, 0, wxGROW|wxALL, 5 );
216
217 wxBoxSizer *item7 = new wxBoxSizer( wxHORIZONTAL );
218
219 wxButton *item8 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
220 item7->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
221
222 wxButton *item9 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
223 item7->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
224
225 item0->Add( item7, 0, wxALL, 5 );
226
227 if (set_sizer)
228 {
229 parent->SetSizer( item0 );
230 if (call_fit)
231 item0->SetSizeHints( parent );
232 }
233
234 return item0;
235}

References ID_DOWN, ID_LINE, ID_LIST, and ID_UP.

◆ onBusSelectionChanged()

void ProDeBusOrderDialog::onBusSelectionChanged ( wxListEvent &  event)
private

Enables and disables Up/Down buttons according to bus selection.

Definition at line 149 of file ProDeBusOrderDialog.cc.

149 {
150
151 const TTAMachine::Machine::BusNavigator& navigator =
153
154 int selection = selectedBus();
155
156 if (selection < 0) {
157 FindWindow(ID_UP)->Disable();
158 FindWindow(ID_DOWN)->Disable();
159 return;
160 }
161
162 if (selection > 0) {
163 FindWindow(ID_UP)->Enable();
164 } else {
165 FindWindow(ID_UP)->Disable();
166 }
167
168 if (selection < (navigator.count() - 1)) {
169 FindWindow(ID_DOWN)->Enable();
170 } else {
171 FindWindow(ID_DOWN)->Disable();
172 }
173}
virtual BusNavigator busNavigator() const
Definition Machine.cc:356

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), ID_DOWN, ID_UP, machine_, and selectedBus().

Here is the call graph for this function:

◆ onDown()

void ProDeBusOrderDialog::onDown ( wxCommandEvent &  event)
private

Moves the selected bus one position down (increases the index by one).

Definition at line 124 of file ProDeBusOrderDialog.cc.

124 {
125
126 const TTAMachine::Machine::BusNavigator& navigator =
128
129 int position = selectedBus();
130 if (position >= (navigator.count() - 1)) {
131 return;
132 }
133
134 machine_.setBusPosition(*navigator.item(position), position + 1);
135
137
138 // Reselect the moved bus.
139 list_->SetItemState(
140 position + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
141
142 list_->EnsureVisible(position + 1);
143}
ComponentType * item(int index) const
void setBusPosition(const Bus &bus, int newPosition)
Definition Machine.cc:651

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), list_, machine_, selectedBus(), TTAMachine::Machine::setBusPosition(), and updateBusList().

Here is the call graph for this function:

◆ onUp()

void ProDeBusOrderDialog::onUp ( wxCommandEvent &  event)
private

Moves the selected bus one position up (decreases the index by one).

Definition at line 99 of file ProDeBusOrderDialog.cc.

99 {
100
101 const TTAMachine::Machine::BusNavigator& navigator =
103
104 int position = selectedBus();
105 if (position <= 0) {
106 return;
107 }
108 machine_.setBusPosition(*navigator.item(position), position - 1);
109
111
112 // Reselect the moved bus.
113 list_->SetItemState(
114 position - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
115
116 list_->EnsureVisible(position - 1);
117}

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), list_, machine_, selectedBus(), TTAMachine::Machine::setBusPosition(), and updateBusList().

Here is the call graph for this function:

◆ selectedBus()

int ProDeBusOrderDialog::selectedBus ( ) const
private

Returns index of the selected bus, or -1 if no bs is selected.

Returns
Index of bus selected in the bus list.

Definition at line 181 of file ProDeBusOrderDialog.cc.

181 {
182 int item = -1;
183 item = list_->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
184 return item;
185}

References list_.

Referenced by onBusSelectionChanged(), onDown(), and onUp().

◆ updateBusList()

void ProDeBusOrderDialog::updateBusList ( )
private

Updates the bus list order.

Definition at line 83 of file ProDeBusOrderDialog.cc.

83 {
84 list_->DeleteAllItems();
85 const TTAMachine::Machine::BusNavigator& navigator =
87
88 for (int i = 0; i < navigator.count(); i++) {
89 std::string busName = navigator.item(i)->name();
90 list_->InsertItem(i, WxConversion::toWxString(i));
91 list_->SetItem(i, 1, WxConversion::toWxString(busName));
92 }
93}
static wxString toWxString(const std::string &source)

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), list_, machine_, and WxConversion::toWxString().

Referenced by onDown(), and onUp().

Here is the call graph for this function:

Member Data Documentation

◆ list_

wxListCtrl* ProDeBusOrderDialog::list_
private

List widget for the buses.

Definition at line 71 of file ProDeBusOrderDialog.hh.

Referenced by onDown(), onUp(), selectedBus(), and updateBusList().

◆ machine_

TTAMachine::Machine& ProDeBusOrderDialog::machine_
private

Machine containing the buses to sort.

Definition at line 69 of file ProDeBusOrderDialog.hh.

Referenced by onBusSelectionChanged(), onDown(), onUp(), and updateBusList().


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