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

#include <RFExternalPortDialog.hh>

Inheritance diagram for RFExternalPortDialog:
Inheritance graph
Collaboration diagram for RFExternalPortDialog:
Collaboration graph

Public Member Functions

 RFExternalPortDialog (wxWindow *parent, wxWindowID id, HDB::RFExternalPort &implementation, const HDB::RFImplementation &rf)
 
virtual ~RFExternalPortDialog ()
 

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::RFExternalPortport_
 RF port implementation to modify. More...
 
const HDB::RFImplementationrf_
 Parent RF implementation of the port. More...
 
wxString name_
 
wxString widthFormula_
 
wxString description_
 
int direction_
 
wxCheckListBox * depList_
 

Detailed Description

Dialog for editing RF external ports.

Definition at line 48 of file RFExternalPortDialog.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 RFExternalPortDialog.hh.

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

Constructor & Destructor Documentation

◆ RFExternalPortDialog()

RFExternalPortDialog::RFExternalPortDialog ( wxWindow *  parent,
wxWindowID  id,
HDB::RFExternalPort implementation,
const HDB::RFImplementation rf 
)

The Constructor.

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

Definition at line 61 of file RFExternalPortDialog.cc.

63  :
64  wxDialog(parent, id, _T("Register File Port")),
65  port_(port), rf_(rf), depList_(NULL) {
66 
67  initialize();
68 }

◆ ~RFExternalPortDialog()

RFExternalPortDialog::~RFExternalPortDialog ( )
virtual

The Destructor.

Definition at line 73 of file RFExternalPortDialog.cc.

73  {
74 }

Member Function Documentation

◆ createContents()

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

Creates the dialog contents.

Creates the dialog contents.

Definition at line 171 of file RFExternalPortDialog.cc.

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

◆ initialize()

void RFExternalPortDialog::initialize ( )
private

Creates and initializes the dialog widgets.

Definition at line 80 of file RFExternalPortDialog.cc.

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

References WxConversion::toWxString().

Here is the call graph for this function:

◆ onOK()

void RFExternalPortDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the dialog OK-button.

Definition at line 117 of file RFExternalPortDialog.cc.

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

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

Here is the call graph for this function:

Member Data Documentation

◆ depList_

wxCheckListBox* RFExternalPortDialog::depList_
private

Definition at line 87 of file RFExternalPortDialog.hh.

◆ description_

wxString RFExternalPortDialog::description_
private

Definition at line 84 of file RFExternalPortDialog.hh.

◆ direction_

int RFExternalPortDialog::direction_
private

Definition at line 85 of file RFExternalPortDialog.hh.

◆ name_

wxString RFExternalPortDialog::name_
private

Definition at line 82 of file RFExternalPortDialog.hh.

◆ port_

HDB::RFExternalPort& RFExternalPortDialog::port_
private

RF port implementation to modify.

Definition at line 78 of file RFExternalPortDialog.hh.

◆ rf_

const HDB::RFImplementation& RFExternalPortDialog::rf_
private

Parent RF implementation of the port.

Definition at line 80 of file RFExternalPortDialog.hh.

◆ widthFormula_

wxString RFExternalPortDialog::widthFormula_
private

Definition at line 83 of file RFExternalPortDialog.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
RFExternalPortDialog::description_
wxString description_
Definition: RFExternalPortDialog.hh:84
RFExternalPortDialog::ID_LABEL_WIDTH
@ ID_LABEL_WIDTH
Definition: RFExternalPortDialog.hh:65
WxConversion::toWxString
static wxString toWxString(const std::string &source)
RFExternalPortDialog::rf_
const HDB::RFImplementation & rf_
Parent RF implementation of the port.
Definition: RFExternalPortDialog.hh:80
HDB::ExternalPort::setParameterDependency
bool setParameterDependency(const std::string &parameter)
Definition: ExternalPort.cc:162
FindWindow
Definition: FindWindow.hh:49
HDB::RFImplementation::parameterCount
int parameterCount() const
Definition: RFImplementation.cc:352
RFExternalPortDialog::widthFormula_
wxString widthFormula_
Definition: RFExternalPortDialog.hh:83
RFExternalPortDialog::port_
HDB::RFExternalPort & port_
RF port implementation to modify.
Definition: RFExternalPortDialog.hh:78
RFExternalPortDialog::ID_NAME
@ ID_NAME
Definition: RFExternalPortDialog.hh:64
HDB::ExternalPort::unsetParameterDependency
bool unsetParameterDependency(const std::string &parameter)
Definition: ExternalPort.cc:178
RFExternalPortDialog::ID_DESCRIPTION
@ ID_DESCRIPTION
Definition: RFExternalPortDialog.hh:68
assert
#define assert(condition)
Definition: Application.hh:86
RFExternalPortDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Creates the dialog contents.
Definition: RFExternalPortDialog.cc:171
ErrorDialog
Definition: ErrorDialog.hh:42
HDB::ExternalPort::setName
void setName(const std::string &name)
Definition: ExternalPort.cc:73
RFExternalPortDialog::initialize
void initialize()
Definition: RFExternalPortDialog.cc:80
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
RFExternalPortDialog::depList_
wxCheckListBox * depList_
Definition: RFExternalPortDialog.hh:87
RFExternalPortDialog::name_
wxString name_
Definition: RFExternalPortDialog.hh:82
HDB::Parameter::name
std::string name
Name of the parameter.
Definition: HDBTypes.hh:47
RFExternalPortDialog::ID_LABEL_NAME
@ ID_LABEL_NAME
Definition: RFExternalPortDialog.hh:63
RFExternalPortDialog::ID_PARAMETER_DEPS
@ ID_PARAMETER_DEPS
Definition: RFExternalPortDialog.hh:70
HDB::IN
@ IN
Input port.
Definition: HDBTypes.hh:41
HDB::ExternalPort::setDirection
void setDirection(Direction direction)
Definition: ExternalPort.cc:95
HDB::RFImplementation::parameter
Parameter parameter(int index) const
Definition: RFImplementation.cc:366
RFExternalPortDialog::ID_LABEL_DESCRIPTION
@ ID_LABEL_DESCRIPTION
Definition: RFExternalPortDialog.hh:67
HDB::ExternalPort::description
std::string description() const
Definition: ExternalPort.cc:150
HDB::ExternalPort::name
std::string name() const
Definition: ExternalPort.cc:84
RFExternalPortDialog::ID_DIRECTION
@ ID_DIRECTION
Definition: RFExternalPortDialog.hh:69
RFExternalPortDialog::direction_
int direction_
Definition: RFExternalPortDialog.hh:85
WxConversion::toString
static std::string toString(const wxString &source)
RFExternalPortDialog::ID_WIDTH
@ ID_WIDTH
Definition: RFExternalPortDialog.hh:66
HDB::ExternalPort::direction
Direction direction() const
Definition: ExternalPort.cc:106
RFExternalPortDialog::ID_LINE
@ ID_LINE
Definition: RFExternalPortDialog.hh:71
HDB::ExternalPort::widthFormula
std::string widthFormula() const
Definition: ExternalPort.cc:128
HDB::OUT
@ OUT
Output port.
Definition: HDBTypes.hh:42
HDB::ExternalPort::parameterDependencyCount
int parameterDependencyCount() const
Definition: ExternalPort.cc:189