34 #include <wx/checklst.h>
35 #include <wx/statline.h>
36 #include <wx/valgen.h>
61 wxDialog(parent,
id, _T("Function Unit Port Port")),
62 port_(port), fu_(fu), depList_(NULL) {
79 createContents(
this,
true,
true);
81 depList_ =
dynamic_cast<wxCheckListBox*
>(
87 direction_ = port_.direction();
89 FindWindow(ID_NAME)->SetValidator(wxTextValidator(wxFILTER_ASCII, &name_));
91 wxTextValidator(wxFILTER_ASCII, &widthFormula_));
92 FindWindow(ID_DIRECTION)->SetValidator(wxGenericValidator(&direction_));
94 wxTextValidator(wxFILTER_ASCII, &description_));
97 for (
int i = 0; i < fu_.parameterCount(); i++) {
98 string parameter = fu_.parameter(i).name;
101 for (
int dep = 0; dep < port_.parameterDependencyCount(); dep++) {
102 if (port_.parameterDependency(dep) == parameter) {
116 TransferDataFromWindow();
118 name_ = name_.Trim(
true).Trim(
false);
119 widthFormula_ = widthFormula_.Trim(
true).Trim(
false);
120 description_ = description_.Trim(
true).Trim(
false);
122 if (name_.IsEmpty()) {
123 wxString message = _T(
"Name field must not be empty.");
129 if (widthFormula_.IsEmpty()) {
131 _T(
"Width formula field must not be empty.");
141 if (direction_ == 0) {
142 port_.setDirection(
IN);
143 }
else if (direction_ == 1) {
144 port_.setDirection(
OUT);
145 }
else if (direction_ == 2) {
146 port_.setDirection(
BIDIR);
151 for (
int i = 0; i < fu_.parameterCount(); i++) {
153 if (depList_->IsChecked(i)) {
154 port_.setParameterDependency(parameter);
156 port_.unsetParameterDependency(parameter);
169 wxWindow *parent,
bool call_fit,
bool set_sizer) {
170 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
172 wxBoxSizer *item1 =
new wxBoxSizer( wxVERTICAL );
174 wxFlexGridSizer *item2 =
new wxFlexGridSizer( 2, 0, 0 );
176 wxStaticText *item3 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
177 item2->Add( item3, 0, wxALIGN_RIGHT|wxALL, 5 );
179 wxTextCtrl *item4 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(300,-1), 0 );
180 item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
182 wxStaticText *item5 =
new wxStaticText( parent, ID_LABEL_WIDTH, wxT(
"Width formula:"), wxDefaultPosition, wxDefaultSize, 0 );
183 item2->Add( item5, 0, wxALIGN_RIGHT|wxALL, 5 );
185 wxTextCtrl *item6 =
new wxTextCtrl( parent, ID_WIDTH, wxT(
""), wxDefaultPosition, wxSize(200,-1), 0 );
186 item2->Add( item6, 0, wxGROW|wxALL, 5 );
188 wxStaticText *item7 =
new wxStaticText( parent, ID_LABEL_DESCRIPTION, wxT(
"Description:"), wxDefaultPosition, wxDefaultSize, 0 );
189 item2->Add( item7, 0, wxALIGN_RIGHT|wxALL, 5 );
191 wxTextCtrl *item8 =
new wxTextCtrl( parent, ID_DESCRIPTION, wxT(
""), wxDefaultPosition, wxSize(300,-1), 0 );
192 item2->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
194 item1->Add( item2, 0, wxGROW|wxALL, 5 );
196 wxGridSizer *item9 =
new wxGridSizer( 2, 0, 0 );
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 );
207 wxStaticBox *item12 =
new wxStaticBox( parent, -1, wxT(
"Parameter dependency:") );
208 wxStaticBoxSizer *item11 =
new wxStaticBoxSizer( item12, wxVERTICAL );
210 wxWindow *item13 =
new wxCheckListBox(parent, ID_PARAMETER_DEPS, wxDefaultPosition, wxSize(200, 150));
212 item11->Add( item13, 0, wxGROW|wxALL, 5 );
214 item9->Add( item11, 0, wxGROW|wxALL, 5 );
216 item1->Add( item9, 0, wxGROW|wxALL, 5 );
218 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
220 wxStaticLine *item14 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
221 item0->Add( item14, 0, wxGROW|wxALL, 5 );
223 wxBoxSizer *item15 =
new wxBoxSizer( wxHORIZONTAL );
225 wxButton *item16 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
226 item15->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
228 wxButton *item17 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
229 item15->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
231 item0->Add( item15, 0, wxALL, 5 );
235 parent->SetSizer( item0 );
237 item0->SetSizeHints( parent );