OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
FUExternalPortDialog Class Reference

#include <FUExternalPortDialog.hh>

Inheritance diagram for FUExternalPortDialog:
Inheritance graph
Collaboration diagram for FUExternalPortDialog:
Collaboration graph

Public Member Functions

 FUExternalPortDialog (wxWindow *parent, wxWindowID id, HDB::FUExternalPort &implementation, const HDB::FUImplementation &fu)
 
virtual ~FUExternalPortDialog ()
 

Private Types

enum  {
  ID_LABEL_NAME = 10000, ID_NAME, ID_LABEL_WIDTH, ID_WIDTH,
  ID_LABEL_DESCRIPTION, ID_DESCRIPTION, ID_DIRECTION, ID_PARAMETER_DEPS,
  ID_LINE
}
 Enumerated IDs for dialog widgets. More...
 

Private Member Functions

void initialize ()
 
void onOK (wxCommandEvent &event)
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 Creates the dialog contents. More...
 

Private Attributes

HDB::FUExternalPortport_
 FU port implementation to modify. More...
 
const HDB::FUImplementationfu_
 Parent FU implementation of the port. More...
 
wxString name_
 
wxString widthFormula_
 
wxString description_
 
int direction_
 
wxCheckListBox * depList_
 

Detailed Description

Dialog for editing FU external ports.

Definition at line 48 of file FUExternalPortDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Enumerated IDs for dialog widgets.

Enumerator
ID_LABEL_NAME 
ID_NAME 
ID_LABEL_WIDTH 
ID_WIDTH 
ID_LABEL_DESCRIPTION 
ID_DESCRIPTION 
ID_DIRECTION 
ID_PARAMETER_DEPS 
ID_LINE 

Definition at line 62 of file FUExternalPortDialog.hh.

62  {
63  ID_LABEL_NAME = 10000,
64  ID_NAME,
66  ID_WIDTH,
71  ID_LINE
72  };

Constructor & Destructor Documentation

◆ FUExternalPortDialog()

FUExternalPortDialog::FUExternalPortDialog ( wxWindow *  parent,
wxWindowID  id,
HDB::FUExternalPort implementation,
const HDB::FUImplementation fu 
)

The Constructor.

Parameters
parentParent window of the dialog.
idWindow identifier for the dialog window.
portFU external port to modify.

Definition at line 58 of file FUExternalPortDialog.cc.

60  :
61  wxDialog(parent, id, _T("Function Unit Port Port")),
62  port_(port), fu_(fu), depList_(NULL) {
63 
64  initialize();
65 }

◆ ~FUExternalPortDialog()

FUExternalPortDialog::~FUExternalPortDialog ( )
virtual

The Destructor.

Definition at line 70 of file FUExternalPortDialog.cc.

70  {
71 }

Member Function Documentation

◆ createContents()

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

Creates the dialog contents.

Creates the dialog contents.

Definition at line 168 of file FUExternalPortDialog.cc.

169  {
170  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
171 
172  wxBoxSizer *item1 = new wxBoxSizer( wxVERTICAL );
173 
174  wxFlexGridSizer *item2 = new wxFlexGridSizer( 2, 0, 0 );
175 
176  wxStaticText *item3 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
177  item2->Add( item3, 0, wxALIGN_RIGHT|wxALL, 5 );
178 
179  wxTextCtrl *item4 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(300,-1), 0 );
180  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
181 
182  wxStaticText *item5 = new wxStaticText( parent, ID_LABEL_WIDTH, wxT("Width formula:"), wxDefaultPosition, wxDefaultSize, 0 );
183  item2->Add( item5, 0, wxALIGN_RIGHT|wxALL, 5 );
184 
185  wxTextCtrl *item6 = new wxTextCtrl( parent, ID_WIDTH, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
186  item2->Add( item6, 0, wxGROW|wxALL, 5 );
187 
188  wxStaticText *item7 = new wxStaticText( parent, ID_LABEL_DESCRIPTION, wxT("Description:"), wxDefaultPosition, wxDefaultSize, 0 );
189  item2->Add( item7, 0, wxALIGN_RIGHT|wxALL, 5 );
190 
191  wxTextCtrl *item8 = new wxTextCtrl( parent, ID_DESCRIPTION, wxT(""), wxDefaultPosition, wxSize(300,-1), 0 );
192  item2->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
193 
194  item1->Add( item2, 0, wxGROW|wxALL, 5 );
195 
196  wxGridSizer *item9 = new wxGridSizer( 2, 0, 0 );
197 
198  wxString strs10[] =
199  {
200  wxT("In"),
201  wxT("Out"),
202  wxT("Bidirectional")
203  };
204  wxRadioBox *item10 = new wxRadioBox( parent, ID_DIRECTION, wxT("Direction:"), wxDefaultPosition, wxDefaultSize, 3, strs10, 1, wxRA_SPECIFY_COLS );
205  item9->Add( item10, 0, wxGROW|wxALL, 5 );
206 
207  wxStaticBox *item12 = new wxStaticBox( parent, -1, wxT("Parameter dependency:") );
208  wxStaticBoxSizer *item11 = new wxStaticBoxSizer( item12, wxVERTICAL );
209 
210  wxWindow *item13 = new wxCheckListBox(parent, ID_PARAMETER_DEPS, wxDefaultPosition, wxSize(200, 150));
211  wxASSERT( item13 );
212  item11->Add( item13, 0, wxGROW|wxALL, 5 );
213 
214  item9->Add( item11, 0, wxGROW|wxALL, 5 );
215 
216  item1->Add( item9, 0, wxGROW|wxALL, 5 );
217 
218  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
219 
220  wxStaticLine *item14 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
221  item0->Add( item14, 0, wxGROW|wxALL, 5 );
222 
223  wxBoxSizer *item15 = new wxBoxSizer( wxHORIZONTAL );
224 
225  wxButton *item16 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
226  item15->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
227 
228  wxButton *item17 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
229  item15->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
230 
231  item0->Add( item15, 0, wxALL, 5 );
232 
233  if (set_sizer)
234  {
235  parent->SetSizer( item0 );
236  if (call_fit)
237  item0->SetSizeHints( parent );
238  }
239 
240  return item0;
241 }

◆ initialize()

void FUExternalPortDialog::initialize ( )
private

Creates and initializes the dialog widgets.

Definition at line 77 of file FUExternalPortDialog.cc.

77  {
78 
79  createContents(this, true, true);
80 
81  depList_ = dynamic_cast<wxCheckListBox*>(
83 
88 
89  FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
90  FindWindow(ID_WIDTH)->SetValidator(
91  wxTextValidator(wxFILTER_ASCII, &widthFormula_));
92  FindWindow(ID_DIRECTION)->SetValidator(wxGenericValidator(&direction_));
93  FindWindow(ID_DESCRIPTION)->SetValidator(
94  wxTextValidator(wxFILTER_ASCII, &description_));
95 
96  depList_->Clear();
97  for (int i = 0; i < fu_.parameterCount(); i++) {
98  string parameter = fu_.parameter(i).name;
99  depList_->Append( WxConversion::toWxString(parameter));
100 
101  for (int dep = 0; dep < port_.parameterDependencyCount(); dep++) {
102  if (port_.parameterDependency(dep) == parameter) {
103  depList_->Check(i);
104  }
105  }
106  }
107 }

References WxConversion::toWxString().

Here is the call graph for this function:

◆ onOK()

void FUExternalPortDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the dialog OK-button.

Definition at line 114 of file FUExternalPortDialog.cc.

114  {
115 
116  TransferDataFromWindow();
117 
118  name_ = name_.Trim(true).Trim(false);
119  widthFormula_ = widthFormula_.Trim(true).Trim(false);
120  description_ = description_.Trim(true).Trim(false);
121 
122  if (name_.IsEmpty()) {
123  wxString message = _T("Name field must not be empty.");
124  ErrorDialog dialog(this, message);
125  dialog.ShowModal();
126  return;
127  }
128 
129  if (widthFormula_.IsEmpty()) {
130  wxString message =
131  _T("Width formula field must not be empty.");
132  ErrorDialog dialog(this, message);
133  dialog.ShowModal();
134  return;
135  }
136 
140 
141  if (direction_ == 0) {
143  } else if (direction_ == 1) {
145  } else if (direction_ == 2) {
147  } else {
148  assert(false);
149  }
150 
151  for (int i = 0; i < fu_.parameterCount(); i++) {
152  string parameter = WxConversion::toString(depList_->GetString(i));
153  if (depList_->IsChecked(i)) {
154  port_.setParameterDependency(parameter);
155  } else {
156  port_.unsetParameterDependency(parameter);
157  }
158  }
159 
160  EndModal(wxID_OK);
161 
162 }

References assert, HDB::BIDIR, HDB::IN, HDB::OUT, and WxConversion::toString().

Here is the call graph for this function:

Member Data Documentation

◆ depList_

wxCheckListBox* FUExternalPortDialog::depList_
private

Definition at line 87 of file FUExternalPortDialog.hh.

◆ description_

wxString FUExternalPortDialog::description_
private

Definition at line 84 of file FUExternalPortDialog.hh.

◆ direction_

int FUExternalPortDialog::direction_
private

Definition at line 85 of file FUExternalPortDialog.hh.

◆ fu_

const HDB::FUImplementation& FUExternalPortDialog::fu_
private

Parent FU implementation of the port.

Definition at line 80 of file FUExternalPortDialog.hh.

◆ name_

wxString FUExternalPortDialog::name_
private

Definition at line 82 of file FUExternalPortDialog.hh.

◆ port_

HDB::FUExternalPort& FUExternalPortDialog::port_
private

FU port implementation to modify.

Definition at line 78 of file FUExternalPortDialog.hh.

◆ widthFormula_

wxString FUExternalPortDialog::widthFormula_
private

Definition at line 83 of file FUExternalPortDialog.hh.


The documentation for this class was generated from the following files:
HDB::ExternalPort::setDescription
void setDescription(const std::string &description)
Definition: ExternalPort.cc:139
FUExternalPortDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Creates the dialog contents.
Definition: FUExternalPortDialog.cc:168
WxConversion::toWxString
static wxString toWxString(const std::string &source)
FUExternalPortDialog::fu_
const HDB::FUImplementation & fu_
Parent FU implementation of the port.
Definition: FUExternalPortDialog.hh:80
FUExternalPortDialog::widthFormula_
wxString widthFormula_
Definition: FUExternalPortDialog.hh:83
FUExternalPortDialog::ID_LINE
@ ID_LINE
Definition: FUExternalPortDialog.hh:71
HDB::ExternalPort::setParameterDependency
bool setParameterDependency(const std::string &parameter)
Definition: ExternalPort.cc:162
FindWindow
Definition: FindWindow.hh:49
HDB::ExternalPort::unsetParameterDependency
bool unsetParameterDependency(const std::string &parameter)
Definition: ExternalPort.cc:178
assert
#define assert(condition)
Definition: Application.hh:86
HDB::FUImplementation::parameterCount
int parameterCount() const
Definition: FUImplementation.cc:443
FUExternalPortDialog::port_
HDB::FUExternalPort & port_
FU port implementation to modify.
Definition: FUExternalPortDialog.hh:78
ErrorDialog
Definition: ErrorDialog.hh:42
HDB::ExternalPort::setName
void setName(const std::string &name)
Definition: ExternalPort.cc:73
HDB::ExternalPort::parameterDependency
std::string parameterDependency(int index) const
Definition: ExternalPort.cc:203
HDB::BIDIR
@ BIDIR
Bidirectional port.
Definition: HDBTypes.hh:43
HDB::ExternalPort::setWidthFormula
void setWidthFormula(const std::string &widthFormula)
Definition: ExternalPort.cc:117
FUExternalPortDialog::depList_
wxCheckListBox * depList_
Definition: FUExternalPortDialog.hh:87
FUExternalPortDialog::initialize
void initialize()
Definition: FUExternalPortDialog.cc:77
FUExternalPortDialog::ID_LABEL_WIDTH
@ ID_LABEL_WIDTH
Definition: FUExternalPortDialog.hh:65
HDB::Parameter::name
std::string name
Name of the parameter.
Definition: HDBTypes.hh:47
FUExternalPortDialog::ID_DESCRIPTION
@ ID_DESCRIPTION
Definition: FUExternalPortDialog.hh:68
FUExternalPortDialog::ID_WIDTH
@ ID_WIDTH
Definition: FUExternalPortDialog.hh:66
FUExternalPortDialog::direction_
int direction_
Definition: FUExternalPortDialog.hh:85
HDB::FUImplementation::parameter
Parameter parameter(int index) const
Definition: FUImplementation.cc:457
FUExternalPortDialog::ID_PARAMETER_DEPS
@ ID_PARAMETER_DEPS
Definition: FUExternalPortDialog.hh:70
HDB::IN
@ IN
Input port.
Definition: HDBTypes.hh:41
FUExternalPortDialog::ID_LABEL_DESCRIPTION
@ ID_LABEL_DESCRIPTION
Definition: FUExternalPortDialog.hh:67
HDB::ExternalPort::setDirection
void setDirection(Direction direction)
Definition: ExternalPort.cc:95
FUExternalPortDialog::description_
wxString description_
Definition: FUExternalPortDialog.hh:84
FUExternalPortDialog::ID_NAME
@ ID_NAME
Definition: FUExternalPortDialog.hh:64
HDB::ExternalPort::description
std::string description() const
Definition: ExternalPort.cc:150
HDB::ExternalPort::name
std::string name() const
Definition: ExternalPort.cc:84
WxConversion::toString
static std::string toString(const wxString &source)
HDB::ExternalPort::direction
Direction direction() const
Definition: ExternalPort.cc:106
FUExternalPortDialog::ID_LABEL_NAME
@ ID_LABEL_NAME
Definition: FUExternalPortDialog.hh:63
HDB::ExternalPort::widthFormula
std::string widthFormula() const
Definition: ExternalPort.cc:128
HDB::OUT
@ OUT
Output port.
Definition: HDBTypes.hh:42
FUExternalPortDialog::ID_DIRECTION
@ ID_DIRECTION
Definition: FUExternalPortDialog.hh:69
HDB::ExternalPort::parameterDependencyCount
int parameterDependencyCount() const
Definition: ExternalPort.cc:189
FUExternalPortDialog::name_
wxString name_
Definition: FUExternalPortDialog.hh:82