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

#include <TemplateSlotDialog.hh>

Inheritance diagram for TemplateSlotDialog:
Inheritance graph
Collaboration diagram for TemplateSlotDialog:
Collaboration graph

Public Member Functions

 TemplateSlotDialog (wxWindow *parent, TTAMachine::InstructionTemplate *it, TTAMachine::TemplateSlot *slot=NULL)
 
virtual ~TemplateSlotDialog ()
 

Private Types

enum  {
  ID_LABEL_SLOT = 10000 , ID_SLOT , ID_LABEL_WIDTH , ID_WIDTH ,
  ID_LABEL_DESTINATION , ID_DESTINATION , ID_LINE , ID_HELP
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
virtual bool TransferDataToWindow ()
 
void onOK (wxCommandEvent &event)
 
void setTexts ()
 

Private Attributes

TTAMachine::TemplateSlotslot_
 Instruction template slot to edit.
 
TTAMachine::InstructionTemplateit_
 Parent instruction template of the slot.
 
wxChoice * slotChoice_
 Choice control for the slot.
 
wxChoice * destinationChoice_
 Choice control fot the destination IU.
 
wxSpinCtrl * widthCtrl_
 Spin control for the width.
 
int width_
 Bit width of the slot.
 
TTAMachine::ImmediateUnitdestination_
 Destination immediate unit.
 

Detailed Description

Dialog for editing telplate slot properties.

Definition at line 49 of file TemplateSlotDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_LABEL_SLOT 
ID_SLOT 
ID_LABEL_WIDTH 
ID_WIDTH 
ID_LABEL_DESTINATION 
ID_DESTINATION 
ID_LINE 
ID_HELP 

Definition at line 80 of file TemplateSlotDialog.hh.

Constructor & Destructor Documentation

◆ TemplateSlotDialog()

TemplateSlotDialog::TemplateSlotDialog ( wxWindow *  parent,
TTAMachine::InstructionTemplate it,
TTAMachine::TemplateSlot slot = NULL 
)

The Constructor.

Parameters
parentParent window of the dialog.
tempInstructionTemplate to edit.
slotSlot to edit, NULL if a new slot is being added.

Definition at line 69 of file TemplateSlotDialog.cc.

72 :
73 wxDialog(parent, -1, _T(""), wxDefaultPosition),
74 slot_(slot),
75 it_(it),
77 destination_(NULL) {
78
79 createContents(this, true, true);
80
81 slotChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_SLOT));
82 destinationChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_DESTINATION));
83 widthCtrl_ = dynamic_cast<wxSpinCtrl*>(FindWindow(ID_WIDTH));
84
85 widthCtrl_->SetValidator(wxGenericValidator(&width_));
86
87 // Read slot attributes.
88 if (slot_ != NULL) {
92 for (int i = 0; i < navigator.count(); i++) {
94 slot_->slot(), *navigator.item(i))) {
95 destination_ = navigator.item(i);
96 }
97 }
98 }
99
100 // set widget texts
101 setTexts();
102}
static const int DEFAULT_WIDTH
Default bit width.
virtual Machine * machine() const
virtual bool destinationUsesSlot(const std::string &slotName, const ImmediateUnit &dstUnit) const
ComponentType * item(int index) const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416
std::string slot() const
TTAMachine::ImmediateUnit * destination_
Destination immediate unit.
wxChoice * destinationChoice_
Choice control fot the destination IU.
TTAMachine::TemplateSlot * slot_
Instruction template slot to edit.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
wxSpinCtrl * widthCtrl_
Spin control for the width.
int width_
Bit width of the slot.
wxChoice * slotChoice_
Choice control for the slot.
TTAMachine::InstructionTemplate * it_
Parent instruction template of the slot.

References TTAMachine::Machine::Navigator< ComponentType >::count(), and TTAMachine::Machine::Navigator< ComponentType >::item().

Here is the call graph for this function:

◆ ~TemplateSlotDialog()

TemplateSlotDialog::~TemplateSlotDialog ( )
virtual

The Destructor.

Definition at line 108 of file TemplateSlotDialog.cc.

108 {
109}

Member Function Documentation

◆ createContents()

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

Creates the dialog window contents.

This method was generated with wxDesigner.

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 264 of file TemplateSlotDialog.cc.

265 {
266
267 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
268
269 wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
270
271 wxStaticText *item2 = new wxStaticText( parent, ID_LABEL_SLOT, wxT("Slot:"), wxDefaultPosition, wxDefaultSize, 0 );
272 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
273
274 wxString *strs3 = (wxString*) NULL;
275 wxChoice *item3 = new wxChoice( parent, ID_SLOT, wxDefaultPosition, wxSize(150,-1), 0, strs3, 0 );
276 item1->Add( item3, 0, wxGROW|wxALL, 5 );
277
278 wxStaticText *item4 = new wxStaticText( parent, ID_LABEL_DESTINATION, wxT("Destination:"), wxDefaultPosition, wxDefaultSize, 0 );
279 item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
280
281 wxString *strs5 = (wxString*) NULL;
282 wxChoice *item5 = new wxChoice( parent, ID_DESTINATION, wxDefaultPosition, wxSize(100,-1), 0, strs5, 0 );
283 item1->Add( item5, 0, wxGROW|wxALL, 5 );
284
285 wxStaticText *item6 = new wxStaticText( parent, ID_LABEL_WIDTH, wxT("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
286 item1->Add( item6, 0, wxALIGN_RIGHT|wxALL, 5 );
287
288 wxSpinCtrl *item7 = new wxSpinCtrl( parent, ID_WIDTH, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
289 item1->Add( item7, 0, wxALL, 5 );
290
291 item0->Add( item1, 0, wxGROW|wxALL, 5 );
292
293 wxStaticLine *item8 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
294 item0->Add( item8, 0, wxGROW|wxALL, 5 );
295
296 wxFlexGridSizer *item9 = new wxFlexGridSizer( 2, 0, 0 );
297
298 wxButton *item10 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
299 item9->Add( item10, 0, wxALL, 5 );
300
301 wxBoxSizer *item11 = new wxBoxSizer( wxHORIZONTAL );
302
303 wxButton *item12 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
304 item11->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
305
306 wxButton *item13 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
307 item11->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
308
309 item9->Add( item11, 0, 0, 5 );
310
311 item0->Add( item9, 0, wxGROW|wxALL, 5 );
312
313 if (set_sizer)
314 {
315 parent->SetSizer( item0 );
316 if (call_fit)
317 item0->SetSizeHints( parent );
318 }
319
320 return item0;
321}

References ID_DESTINATION, ID_HELP, ID_LABEL_DESTINATION, ID_LABEL_SLOT, ID_LABEL_WIDTH, ID_LINE, ID_SLOT, and ID_WIDTH.

◆ onOK()

void TemplateSlotDialog::onOK ( wxCommandEvent &  event)
private

Creates a new tempalte slot based on the dialog widget values.

Definition at line 220 of file TemplateSlotDialog.cc.

220 {
221
222 string slotName = WxConversion::toString(slotChoice_->GetStringSelection());
223
224 // Commit edit as new slot. Delete old slot.
225 if (slot_ != NULL) {
226 it_->removeSlot(slotName);
227 }
228 TransferDataFromWindow();
229
230 const Machine::BusNavigator busNavigator = it_->machine()->busNavigator();
231 const Machine::ImmediateSlotNavigator immsNavigator =
233
235 WxConversion::toString(destinationChoice_->GetStringSelection()));
236
237 if (busNavigator.hasItem(slotName)) {
238 Bus* slot = it_->machine()->busNavigator().item(slotName);
239 // create the new slot
240 it_->addSlot(slot->name(), width_, *destination_);
241 } else if (immsNavigator.hasItem(slotName)) {
242 ImmediateSlot* slot = immsNavigator.item(slotName);
243 // create the new slot
244 it_->addSlot(slot->name(), width_, *destination_);
245 } else {
246 assert(false);
247 }
248
249 EndModal(wxID_OK);
250}
#define assert(condition)
virtual TCEString name() const
virtual void addSlot(const std::string &slotName, int width, ImmediateUnit &dstUnit)
virtual void removeSlot(const std::string &slotName)
bool hasItem(const std::string &name) const
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition Machine.cc:462
virtual BusNavigator busNavigator() const
Definition Machine.cc:356
static std::string toString(const wxString &source)

References TTAMachine::InstructionTemplate::addSlot(), assert, TTAMachine::Machine::busNavigator(), destination_, destinationChoice_, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::immediateSlotNavigator(), TTAMachine::Machine::immediateUnitNavigator(), it_, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Component::name(), TTAMachine::InstructionTemplate::removeSlot(), slot_, slotChoice_, WxConversion::toString(), and width_.

Here is the call graph for this function:

◆ setTexts()

void TemplateSlotDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 116 of file TemplateSlotDialog.cc.

116 {
119
120 // Dialog title
121 format fmt = prodeTexts->text(
123 SetTitle(WxConversion::toWxString(fmt.str()));
124
125 // buttons
126 WidgetTools::setLabel(generator, FindWindow(wxID_OK),
128
129 WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
131
134
135
136 // widget labels
139
142
145}
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
static ProDeTextGenerator * instance()
@ TXT_LABEL_WIDTH
Label for bit width widget.
@ TXT_LABEL_DESTINATION
Label for destination widget.
@ TXT_TEMPLATE_SLOT_DIALOG_TITLE
Template Slot dialog title.
@ TXT_LABEL_SLOT
Label for slot widget.
virtual boost::format text(int textId)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
static wxString toWxString(const std::string &source)

References ID_HELP, ID_LABEL_DESTINATION, ID_LABEL_SLOT, ID_LABEL_WIDTH, GUITextGenerator::instance(), ProDeTextGenerator::instance(), WidgetTools::setLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_LABEL_DESTINATION, ProDeTextGenerator::TXT_LABEL_SLOT, ProDeTextGenerator::TXT_LABEL_WIDTH, and ProDeTextGenerator::TXT_TEMPLATE_SLOT_DIALOG_TITLE.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool TemplateSlotDialog::TransferDataToWindow ( )
privatevirtual

Transfers data from the InstructionTemplate object to the dialog widgets.

Returns
true, if the transfer was succesful, false otherwise.

Definition at line 154 of file TemplateSlotDialog.cc.

154 {
155
156 // Set slot choicer.
157 slotChoice_->Clear();
158
159 if (slot_ == NULL) {
160 // A new slot is being added, set all available busses to the
161 // slot choice.
163 for (int i = 0; i < navigator.count(); i++) {
164 if (!(it_->usesSlot(navigator.item(i)->name()))) {
165 wxString name =
166 WxConversion::toWxString(navigator.item(i)->name());
167 slotChoice_->Append(name);
168 }
169 }
170 // Add immediate slots.
171 Machine::ImmediateSlotNavigator immSlotNavigator =
173 for (int i = 0; i < immSlotNavigator.count(); i++) {
174 if (!(it_->usesSlot(immSlotNavigator.item(i)->name()))) {
175 wxString name =
176 WxConversion::toWxString(immSlotNavigator.item(i)->name());
177 slotChoice_->Append(name);
178 }
179 }
180 } else {
181 // An old slot is being modified, set the slot and disable the control.
183 slotChoice_->Disable();
184 }
185
186 // Set destination choicer.
187 destinationChoice_->Clear();
190 for (int i = 0; i < navigator.count(); i++) {
191 wxString name =
192 WxConversion::toWxString(navigator.item(i)->name());
193 destinationChoice_->Append(name);
194 }
195 // Set selections for editing slot
196 if(slot_ != NULL) {
197 wxString name = WxConversion::toWxString(slot_->destination()->name());
198 assert(!name.empty());
199 destinationChoice_->SetSelection(destinationChoice_->FindString(name));
200 widthCtrl_->SetValue(slot_->width());
201 }
202
203
204 // Set choicer selections.
205 slotChoice_->SetSelection(0);
206 if (destination_ == NULL) {
207 destinationChoice_->SetSelection(0);
208 } else {
209 wxString name = WxConversion::toWxString(destination_->name());
210 destinationChoice_->SetStringSelection(name);
211 }
212 return wxDialog::TransferDataToWindow();
213}
virtual bool usesSlot(const std::string &slotName) const
ImmediateUnit * destination() const

References assert, TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::TemplateSlot::destination(), destination_, destinationChoice_, TTAMachine::Machine::immediateSlotNavigator(), TTAMachine::Machine::immediateUnitNavigator(), it_, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Component::name(), TTAMachine::TemplateSlot::slot(), slot_, slotChoice_, WxConversion::toWxString(), TTAMachine::InstructionTemplate::usesSlot(), TTAMachine::TemplateSlot::width(), and widthCtrl_.

Here is the call graph for this function:

Member Data Documentation

◆ destination_

TTAMachine::ImmediateUnit* TemplateSlotDialog::destination_
private

Destination immediate unit.

Definition at line 77 of file TemplateSlotDialog.hh.

Referenced by onOK(), and TransferDataToWindow().

◆ destinationChoice_

wxChoice* TemplateSlotDialog::destinationChoice_
private

Choice control fot the destination IU.

Definition at line 71 of file TemplateSlotDialog.hh.

Referenced by onOK(), and TransferDataToWindow().

◆ it_

TTAMachine::InstructionTemplate* TemplateSlotDialog::it_
private

Parent instruction template of the slot.

Definition at line 67 of file TemplateSlotDialog.hh.

Referenced by onOK(), and TransferDataToWindow().

◆ slot_

TTAMachine::TemplateSlot* TemplateSlotDialog::slot_
private

Instruction template slot to edit.

Definition at line 65 of file TemplateSlotDialog.hh.

Referenced by onOK(), and TransferDataToWindow().

◆ slotChoice_

wxChoice* TemplateSlotDialog::slotChoice_
private

Choice control for the slot.

Definition at line 69 of file TemplateSlotDialog.hh.

Referenced by onOK(), and TransferDataToWindow().

◆ width_

int TemplateSlotDialog::width_
private

Bit width of the slot.

Definition at line 75 of file TemplateSlotDialog.hh.

Referenced by onOK().

◆ widthCtrl_

wxSpinCtrl* TemplateSlotDialog::widthCtrl_
private

Spin control for the width.

Definition at line 73 of file TemplateSlotDialog.hh.

Referenced by TransferDataToWindow().


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