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

#include <ImmediateSlotDialog.hh>

Inheritance diagram for ImmediateSlotDialog:
Inheritance graph
Collaboration diagram for ImmediateSlotDialog:
Collaboration graph

Public Member Functions

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

Private Types

enum  {
  ID_SLOT_LIST = 10000 , ID_NAME , ID_LABEL_NAME , ID_LABE_NAME ,
  ID_ADD_SLOT , ID_DELETE_SLOT , ID_LINE , ID_HELP
}
 

Private Member Functions

virtual bool TransferDataToWindow ()
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
void updateSlotList ()
 
void onAddSlot (wxCommandEvent &event)
 
void onDeleteSlot (wxCommandEvent &event)
 
void onSlotName (wxCommandEvent &event)
 
void onSlotSelection (wxListEvent &event)
 
void setTexts ()
 

Private Attributes

TTAMachine::Machinemachine_
 Parent machine of the immediate slots.
 
wxListCtrl * slotList_
 Immediate slot list widget.
 
wxString slotName_
 Text in the slot name widget.
 

Detailed Description

Dialog for modifying immediate slots in a machine.

Definition at line 47 of file ImmediateSlotDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_SLOT_LIST 
ID_NAME 
ID_LABEL_NAME 
ID_LABE_NAME 
ID_ADD_SLOT 
ID_DELETE_SLOT 
ID_LINE 
ID_HELP 

Definition at line 69 of file ImmediateSlotDialog.hh.

Constructor & Destructor Documentation

◆ ImmediateSlotDialog()

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

The Constructor.

Parameters
parentParent window of the dialog.
machineParent Machine of the immediate slots.

Definition at line 67 of file ImmediateSlotDialog.cc.

69 :
70 wxDialog(parent, -1, _T(""), wxDefaultPosition),
72
73 createContents(this, true, true);
74
75 slotList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_SLOT_LIST));
76
77 FindWindow(ID_NAME)->SetValidator(
78 wxTextValidator(wxFILTER_ASCII, &slotName_));
79
80 // Disable conditional buttons.
81 FindWindow(ID_ADD_SLOT)->Disable();
82 FindWindow(ID_DELETE_SLOT)->Disable();
83
84 setTexts();
85}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
wxListCtrl * slotList_
Immediate slot list widget.
wxString slotName_
Text in the slot name widget.
TTAMachine::Machine * machine_
Parent machine of the immediate slots.

◆ ~ImmediateSlotDialog()

ImmediateSlotDialog::~ImmediateSlotDialog ( )
virtual

The Destructor.

Definition at line 91 of file ImmediateSlotDialog.cc.

91 {
92}

Member Function Documentation

◆ createContents()

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

Creates the dialog contents.

Parameters
parentParent dialog of the contents.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.
Returns
Top level sizer of the dialog contents.

Definition at line 276 of file ImmediateSlotDialog.cc.

277 {
278
279
280 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
281
282 wxListCtrl *item1 = new wxListCtrl( parent, ID_SLOT_LIST, wxDefaultPosition, wxSize(300,200), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
283 item0->Add( item1, 0, wxGROW|wxALL, 5 );
284
285 wxBoxSizer *item2 = new wxBoxSizer( wxVERTICAL );
286
287 wxBoxSizer *item3 = new wxBoxSizer( wxHORIZONTAL );
288
289 wxBoxSizer *item4 = new wxBoxSizer( wxHORIZONTAL );
290
291 wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
292 item4->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
293
294 wxTextCtrl *item6 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(120,-1), 0 );
295 item4->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
296
297 item3->Add( item4, 0, wxGROW|wxALL, 5 );
298
299 wxBoxSizer *item7 = new wxBoxSizer( wxHORIZONTAL );
300
301 wxButton *item8 = new wxButton( parent, ID_ADD_SLOT, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0 );
302 item7->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
303
304 wxButton *item9 = new wxButton( parent, ID_DELETE_SLOT, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
305 item7->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
306
307 item3->Add( item7, 0, wxALIGN_CENTER, 5 );
308
309 item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
310
311 item0->Add( item2, 0, wxGROW|wxALL, 5 );
312
313 wxStaticLine *item10 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
314 item0->Add( item10, 0, wxGROW|wxALL, 5 );
315
316 wxGridSizer *item11 = new wxGridSizer( 2, 0, 0 );
317
318 wxButton *item12 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
319 item11->Add( item12, 0, wxALL, 5 );
320
321 wxBoxSizer *item13 = new wxBoxSizer( wxHORIZONTAL );
322
323 wxButton *item14 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
324 item13->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
325
326 wxButton *item15 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
327 item13->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
328
329 item11->Add( item13, 0, 0, 5 );
330
331 item0->Add( item11, 0, wxGROW, 5 );
332
333 if (set_sizer)
334 {
335 parent->SetSizer( item0 );
336 if (call_fit)
337 item0->SetSizeHints( parent );
338 }
339
340 return item0;
341}

References ID_ADD_SLOT, ID_DELETE_SLOT, ID_HELP, ID_LABEL_NAME, ID_LINE, ID_NAME, and ID_SLOT_LIST.

◆ onAddSlot()

void ImmediateSlotDialog::onAddSlot ( wxCommandEvent &  event)
private

Adds a new slot to the machine when "Add" button is pressed.

Definition at line 193 of file ImmediateSlotDialog.cc.

193 {
194
195 if (!TransferDataFromWindow()) {
196 return;
197 }
198
199 string trimmedName =
200 WxConversion::toString(slotName_.Trim(false).Trim(true));
201
202 // Check name validity.
203 if (!MachineTester::isValidComponentName(trimmedName)) {
205 format message =
207 InformationDialog warning(
208 this, WxConversion::toWxString(message.str()));
209 warning.ShowModal();
210 return;
211 }
212
213 if (machine_->immediateSlotNavigator().hasItem(trimmedName)) {
215 format message =
217 message % trimmedName;
218 message % prodeTexts->text(ProDeTextGenerator::COMP_AN_IMM_SLOT).str();
219 message % prodeTexts->text(ProDeTextGenerator::COMP_MACHINE).str();
220 message % prodeTexts->text(ProDeTextGenerator::COMP_IMM_SLOT).str();
221 WarningDialog warning(this, WxConversion::toWxString(message.str()));
222 warning.ShowModal();
223 return;
224 }
225
226 // Buses share namespace with immediate slots. Check that a bus with the
227 // same name does not exist.
228 if (machine_->busNavigator().hasItem(trimmedName)) {
230 format message =
232 message % trimmedName;
233 message % prodeTexts->text(ProDeTextGenerator::COMP_A_BUS).str();
234 message % prodeTexts->text(ProDeTextGenerator::COMP_MACHINE).str();
235 message % prodeTexts->text(ProDeTextGenerator::COMP_IMM_SLOT).str();
236 WarningDialog warning(this, WxConversion::toWxString(message.str()));
237 warning.ShowModal();
238 return;
239 }
240
241 new ImmediateSlot(trimmedName, *machine_);
242 slotName_ = _T("");
244}
virtual bool TransferDataToWindow()
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_AN_IMM_SLOT
Name for imm. slot (w/ article).
@ COMP_A_BUS
Name for a bus component.
@ COMP_IMM_SLOT
Name for imm. slot (w/o article).
bool hasItem(const std::string &name) const
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition Machine.cc:462
virtual BusNavigator busNavigator() const
Definition Machine.cc:356
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)

References TTAMachine::Machine::busNavigator(), ProDeTextGenerator::COMP_A_BUS, ProDeTextGenerator::COMP_AN_IMM_SLOT, ProDeTextGenerator::COMP_IMM_SLOT, ProDeTextGenerator::COMP_MACHINE, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::immediateSlotNavigator(), ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), machine_, ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, slotName_, Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), and TransferDataToWindow().

Here is the call graph for this function:

◆ onDeleteSlot()

void ImmediateSlotDialog::onDeleteSlot ( wxCommandEvent &  event)
private

Deletes the selected immediate slot.

Definition at line 167 of file ImmediateSlotDialog.cc.

167 {
168
169 // Check which slot is selected.
170 long item = -1;
171 item = slotList_->GetNextItem(
172 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
173
174 if (item < 0) {
175 return;
176 }
177
178 ImmediateSlot* slot =
180
181 delete slot;
182
184 wxListEvent dummy;
186}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onSlotSelection(wxListEvent &event)
ComponentType * item(int index) const

References dummy, TTAMachine::Machine::immediateSlotNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, onSlotSelection(), slotList_, and TransferDataToWindow().

Here is the call graph for this function:

◆ onSlotName()

void ImmediateSlotDialog::onSlotName ( wxCommandEvent &  event)
private

Enables and disables the "Add" button when text is entered in the slot name widget.

Definition at line 252 of file ImmediateSlotDialog.cc.

252 {
253
254 if (!TransferDataFromWindow()) {
255 return;
256 }
257
258 wxString trimmedName = slotName_.Trim(false).Trim(true);
259 if (trimmedName == _T("")) {
260 FindWindow(ID_ADD_SLOT)->Disable();
261 } else {
262 FindWindow(ID_ADD_SLOT)->Enable();
263 }
264}

References ID_ADD_SLOT, and slotName_.

◆ onSlotSelection()

void ImmediateSlotDialog::onSlotSelection ( wxListEvent &  event)
private

Enables and disables the delete button according to slot list selection.

Definition at line 154 of file ImmediateSlotDialog.cc.

154 {
155 if (slotList_->GetSelectedItemCount() == 1) {
156 FindWindow(ID_DELETE_SLOT)->Enable();
157 } else {
158 FindWindow(ID_DELETE_SLOT)->Disable();
159 }
160}

References ID_DELETE_SLOT, and slotList_.

Referenced by onDeleteSlot().

◆ setTexts()

void ImmediateSlotDialog::setTexts ( )
private

Sets widget texts.

Definition at line 99 of file ImmediateSlotDialog.cc.

99 {
102
103 // Dialog title.
104 format fmt = prodeTexts->text(
106 SetTitle(WxConversion::toWxString(fmt.str()));
107
108 // Buttons
109 WidgetTools::setLabel(generator, FindWindow(wxID_OK),
111 WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
119
122
123 format fmtCol = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
124 slotList_->InsertColumn(0, WxConversion::toWxString(fmtCol.str()),
125 wxLIST_FORMAT_LEFT, 300);
126
127}
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_DELETE
Label for delete button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
@ TXT_BUTTON_ADD
Label for an add button.
static GUITextGenerator * instance()
@ TXT_LABEL_NAME
Label for component name widget.
@ TXT_IMMEDIATE_SLOT_DIALOG_TITLE
Immediate Slot dialog title.
@ TXT_COLUMN_NAME
Label for name column in a list.
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_ADD_SLOT, ID_DELETE_SLOT, ID_HELP, ID_NAME, GUITextGenerator::instance(), ProDeTextGenerator::instance(), WidgetTools::setLabel(), slotList_, Texts::TextGenerator::text(), WxConversion::toWxString(), GUITextGenerator::TXT_BUTTON_ADD, GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_DELETE, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_COLUMN_NAME, ProDeTextGenerator::TXT_IMMEDIATE_SLOT_DIALOG_TITLE, and ProDeTextGenerator::TXT_LABEL_NAME.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool ImmediateSlotDialog::TransferDataToWindow ( )
privatevirtual

Transfers data from the machine model to the dialog widgets.

Definition at line 134 of file ImmediateSlotDialog.cc.

134 {
135
136 // update slot list
137 slotList_->DeleteAllItems();
138 const Machine::ImmediateSlotNavigator navigator =
140
141 for (int i = 0; i < navigator.count(); i++) {
142 slotList_->InsertItem(
143 i, WxConversion::toWxString(navigator.item(i)->name()));
144 }
145
146 return wxDialog::TransferDataToWindow();
147}

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

Referenced by onAddSlot(), and onDeleteSlot().

Here is the call graph for this function:

◆ updateSlotList()

void ImmediateSlotDialog::updateSlotList ( )
private

Member Data Documentation

◆ machine_

TTAMachine::Machine* ImmediateSlotDialog::machine_
private

Parent machine of the immediate slots.

Definition at line 63 of file ImmediateSlotDialog.hh.

Referenced by onAddSlot(), onDeleteSlot(), and TransferDataToWindow().

◆ slotList_

wxListCtrl* ImmediateSlotDialog::slotList_
private

Immediate slot list widget.

Definition at line 65 of file ImmediateSlotDialog.hh.

Referenced by onDeleteSlot(), onSlotSelection(), setTexts(), and TransferDataToWindow().

◆ slotName_

wxString ImmediateSlotDialog::slotName_
private

Text in the slot name widget.

Definition at line 67 of file ImmediateSlotDialog.hh.

Referenced by onAddSlot(), and onSlotName().


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