33 #include <wx/listctrl.h>
34 #include <wx/statline.h>
35 #include <wx/valgen.h>
44 #if wxCHECK_VERSION(3, 0, 0)
45 #define wxOPEN wxFD_OPEN
46 #define wxFILE_MUST_EXIST wxFD_FILE_MUST_EXIST
63 _T("
FU Cost Estimator");
65 _T("RF Cost Estimator");
67 _T("Decompressor Cost Estimator");
69 _T("IC & Decoder Cost Estimator");
80 wxWindow* parent, wxWindowID
id,
HDB::
HDBManager& hdb,
int pluginID) :
81 wxDialog(parent,
id, _T("Cost Function Plugin")),
82 hdb_(hdb), id_(pluginID) {
84 createContents(
this,
true,
true);
86 list_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_LIST));
87 typeChoice_ =
dynamic_cast<wxChoice*
>(
FindWindow(ID_TYPE));
89 list_->InsertColumn(0, _T(
"Type"), wxLIST_FORMAT_LEFT, 50);
90 list_->InsertColumn(1, _T(
"ID"), wxLIST_FORMAT_LEFT, 50);
91 list_->InsertColumn(2, _T(
"Name"), wxLIST_FORMAT_LEFT, 200);
92 list_->InsertColumn(3, _T(
"Data"), wxLIST_FORMAT_RIGHT, 200);
94 typeChoice_->Append(TYPE_COST_RF);
95 typeChoice_->Append(TYPE_COST_FU);
96 typeChoice_->Append(TYPE_COST_DECOMP);
97 typeChoice_->Append(TYPE_COST_ICDEC);
99 FindWindow(ID_NAME)->SetValidator(wxGenericValidator(&name_));
100 FindWindow(ID_PATH)->SetValidator(wxGenericValidator(&path_));
102 ID_DESCRIPTION)->SetValidator(wxGenericValidator(&description_));
111 typeChoice_->SetStringSelection(TYPE_COST_FU);
113 typeChoice_->SetStringSelection(TYPE_COST_RF);
115 typeChoice_->SetStringSelection(TYPE_COST_DECOMP);
117 typeChoice_->SetStringSelection(TYPE_COST_ICDEC);
137 list_->DeleteAllItems();
140 const std::set<RowID> pluginDataIDs = hdb_.costFunctionPluginDataIDs(id_);
141 std::set<RowID>::const_iterator iter = pluginDataIDs.begin();
142 for (; iter != pluginDataIDs.end(); iter++) {
145 list_->InsertItem(0, _T(
"FU"));
148 list_->InsertItem(0, _T(
"RF"));
151 list_->InsertItem(0, _T(
"Bus"));
155 list_->InsertItem(0, _T(
"Socket"));
159 list_->InsertItem(0, _T(
"-"));
160 list_->SetItem(0, 1, _T(
"-"));
166 list_->SetItemData(0, *iter);
169 return wxDialog::TransferDataToWindow();
181 int item = list_->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
187 return list_->GetItemData(item);
197 if (selectedData() == -1) {
212 this, _T(
"Choose a plugin file."), _T(
""), _T(
""),
213 _T(
"Plugin files (*.so)|*.so|All Files|*.*"),
214 wxOPEN | wxFILE_MUST_EXIST);
215 if (dialog.ShowModal() == wxID_OK) {
216 dynamic_cast<wxTextCtrl*
>(
217 FindWindow(ID_PATH))->SetValue(dialog.GetPath());
225 TransferDataFromWindow();
228 TransferDataFromWindow();
229 TransferDataToWindow();
238 TransferDataFromWindow();
239 int selected = selectedData();
243 TransferDataToWindow();
252 TransferDataFromWindow();
253 int selected = selectedData();
255 hdb_.removeCostEstimationData(selected);
256 TransferDataToWindow();
266 TransferDataFromWindow();
268 if (name_.IsEmpty()) {
269 wxString message(_T(
"Plugin name not set."));
278 if (typeChoice_->GetStringSelection() == TYPE_COST_RF) {
280 }
else if (typeChoice_->GetStringSelection() == TYPE_COST_DECOMP) {
282 }
else if (typeChoice_->GetStringSelection() == TYPE_COST_ICDEC) {
285 assert(typeChoice_->GetStringSelection() == TYPE_COST_FU);
292 hdb_.modifyCostFunctionPlugin(id_, modified);
303 wxWindow* parent,
bool call_fit,
bool set_sizer) {
305 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
307 wxFlexGridSizer *item1 =
new wxFlexGridSizer( 3, 0, 0 );
309 wxStaticText *item2 =
new wxStaticText( parent, ID_TEXT, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
310 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
312 wxTextCtrl *item3 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(300,-1), 0 );
313 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
315 item1->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
317 wxStaticText *item4 =
new wxStaticText( parent, ID_TEXT, wxT(
"Plugin file path:"), wxDefaultPosition, wxDefaultSize, 0 );
318 item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
320 wxTextCtrl *item5 =
new wxTextCtrl( parent, ID_PATH, wxT(
""), wxDefaultPosition, wxSize(80,-1), 0 );
321 item1->Add( item5, 0, wxGROW|wxALL, 5 );
323 wxButton *item6 =
new wxButton( parent, ID_BROWSE, wxT(
"Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
324 item1->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
326 wxStaticText *item7 =
new wxStaticText( parent, ID_TEXT, wxT(
"Plugin type:"), wxDefaultPosition, wxDefaultSize, 0 );
327 item1->Add( item7, 0, wxALIGN_RIGHT|wxALL, 5 );
329 wxString *strs8 = (wxString*) NULL;
330 wxChoice *item8 =
new wxChoice( parent, ID_TYPE, wxDefaultPosition, wxSize(100,-1), 0, strs8, 0 );
331 item1->Add( item8, 0, wxGROW|wxALL, 5 );
333 item1->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
335 wxStaticText *item9 =
new wxStaticText( parent, ID_TEXT, wxT(
"Description:"), wxDefaultPosition, wxDefaultSize, 0 );
336 item1->Add( item9, 0, wxALIGN_RIGHT|wxALL, 5 );
338 wxTextCtrl *item10 =
new wxTextCtrl( parent, ID_DESCRIPTION, wxT(
""), wxDefaultPosition, wxSize(200,60), wxTE_MULTILINE );
339 item1->Add( item10, 0, wxGROW|wxALL, 5 );
341 item0->Add( item1, 0, wxGROW|wxALL, 5 );
343 wxStaticBox *item12 =
new wxStaticBox( parent, -1, wxT(
"Plugin data:") );
344 wxStaticBoxSizer *item11 =
new wxStaticBoxSizer( item12, wxVERTICAL );
346 wxListCtrl *item13 =
new wxListCtrl( parent, ID_LIST, wxDefaultPosition, wxSize(500,300), wxLC_REPORT|wxSUNKEN_BORDER );
347 item11->Add( item13, 0, wxGROW|wxALL, 5 );
349 item0->Add( item11, 0, wxGROW|wxALL, 5 );
351 wxBoxSizer *item14 =
new wxBoxSizer( wxHORIZONTAL );
353 wxButton *item15 =
new wxButton( parent, ID_ADD, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
354 item14->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
356 wxButton *item16 =
new wxButton( parent, ID_MODIFY, wxT(
"Modify..."), wxDefaultPosition, wxDefaultSize, 0 );
357 item14->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
359 wxButton *item17 =
new wxButton( parent, ID_DELETE, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
360 item14->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
362 item0->Add( item14, 0, wxALIGN_CENTER, 5 );
364 wxStaticLine *item18 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
365 item0->Add( item18, 0, wxGROW|wxALL, 5 );
367 wxBoxSizer *item19 =
new wxBoxSizer( wxHORIZONTAL );
369 wxButton *item20 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
370 item19->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
372 wxButton *item21 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
373 item19->Add( item21, 0, wxALL, 5 );
375 item0->Add( item19, 0, 0, 5 );
379 parent->SetSizer( item0 );
381 item0->SetSizeHints( parent );