27 #include <boost/format.hpp>
30 #include <wx/statline.h>
31 #include <wx/listctrl.h>
73 wxDialog(parent, -1, _T(""), wxDefaultPosition),
75 OTAFormatName_(_T("")) {
77 createContents(
this,
true,
true);
79 OTAFormatList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OTA_FORMAT_LIST));
80 operationList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OPERATION_LIST));
83 wxTextValidator(wxFILTER_ASCII, &OTAFormatName_));
107 format fmt = prodeTexts->
text(
145 wxListCtrl* OTAFormatList =
146 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OTA_FORMAT_LIST));
149 wxLIST_FORMAT_LEFT, 160);
152 wxListCtrl* OperationList =
153 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OPERATION_LIST));
156 wxLIST_FORMAT_LEFT, 100);
167 OTAFormatList_->DeleteAllItems();
169 machine_->operationTriggeredFormatNavigator();
170 for (
int i = 0; i < navigator.
count(); i++) {
171 OTAFormatList_->InsertItem(
174 updateOperationList();
175 return wxDialog::TransferDataToWindow();
186 operationList_->DeleteAllItems();
187 operationList_->Enable();
197 operationList_->InsertItem(
204 onOperationSelection(
dummy);
213 if (OTAFormatList_->GetSelectedItemCount() == 0) {
218 updateOperationList();
227 if (operationList_->GetSelectedItemCount() == 1) {
240 delete selectedOTAFormat();
241 TransferDataToWindow();
243 onOTAFormatSelection(
dummy);
255 item = OTAFormatList_->GetNextItem(
256 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
263 machine_->operationTriggeredFormatNavigator().item(item);
281 if (OTAFormatName_ ==
"riscv_r_type" ||
282 OTAFormatName_ ==
"riscv_i_type" ||
283 OTAFormatName_ ==
"riscv_s_type" ||
284 OTAFormatName_ ==
"riscv_b_type" ||
285 OTAFormatName_ ==
"riscv_u_type" ||
286 OTAFormatName_ ==
"riscv_j_type") {
300 if (!TransferDataFromWindow()) {
307 if (!validFormatName()) {
308 std::string message =
"Format name is illegal. Legal names are:\n" \
322 machine_->operationTriggeredFormatNavigator();
324 if (navigator.
hasItem(trimmedName)) {
335 message % trimmedName % a_tmplate.str() %
machine.str() %
342 OTAFormatName_ = _T(
"");
343 TransferDataToWindow();
353 if (!TransferDataFromWindow()) {
356 wxString trimmedName = OTAFormatName_.Trim(
false).Trim(
true);
358 machine_->operationTriggeredFormatNavigator();
359 if (trimmedName == _T(
"")) {
362 }
else if (nav.
count() > 5) {
376 if (selectedOTAFormat() == NULL) {
381 updateOperationList();
390 if (selectedOTAFormat() == NULL) {
393 selectedOTAFormat()->removeOperation(selectedOperation());
394 updateOperationList();
410 wxWindow *parent,
bool call_fit,
bool set_sizer) {
412 wxBoxSizer *item0 =
new wxBoxSizer( wxVERTICAL );
414 wxBoxSizer *item1 =
new wxBoxSizer( wxHORIZONTAL );
416 wxStaticBox *item3 =
new wxStaticBox( parent, -1, wxT(
"Instruction OTAFormats:") );
417 wxStaticBoxSizer *item2 =
new wxStaticBoxSizer( item3, wxVERTICAL );
418 OTAFormatSizer_ = item2;
420 wxListCtrl *item4 =
new wxListCtrl( parent, ID_OTA_FORMAT_LIST, wxDefaultPosition, wxSize(160,200), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
421 item2->Add( item4, 0, wxGROW|wxALL, 5 );
423 wxBoxSizer *item5 =
new wxBoxSizer( wxHORIZONTAL );
425 wxStaticText *item6 =
new wxStaticText( parent, ID_LABEL_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0 );
426 item5->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
428 wxTextCtrl *item7 =
new wxTextCtrl( parent, ID_NAME, wxT(
""), wxDefaultPosition, wxSize(120,-1), 0 );
429 item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
431 item2->Add( item5, 0, wxGROW|wxALL, 5 );
433 wxBoxSizer *item8 =
new wxBoxSizer( wxHORIZONTAL );
435 wxButton *item9 =
new wxButton( parent, ID_ADD_OTA_FORMAT, wxT(
"Add"), wxDefaultPosition, wxDefaultSize, 0 );
436 item8->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
438 wxButton *item10 =
new wxButton( parent, ID_DELETE_OTA_FORMAT, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
439 item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
441 item2->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
443 item1->Add( item2, 0, wxGROW|wxALL, 5 );
445 wxStaticBox *item12 =
new wxStaticBox( parent, -1, wxT(
"OTAFormat Operations:") );
446 wxStaticBoxSizer *item11 =
new wxStaticBoxSizer( item12, wxVERTICAL );
447 operationSizer_ = item11;
449 wxListCtrl *item13 =
new wxListCtrl( parent, ID_OPERATION_LIST, wxDefaultPosition, wxSize(250,245), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
450 item11->Add( item13, 0, wxGROW|wxALL, 5 );
452 wxBoxSizer *item14 =
new wxBoxSizer( wxHORIZONTAL );
454 wxButton *item15 =
new wxButton( parent, ID_ADD_OPERATION, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0 );
455 item14->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
457 wxButton *item17 =
new wxButton( parent, ID_DELETE_OPERATION, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0 );
458 item14->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
460 item11->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
462 item1->Add( item11, 0, wxGROW|wxALL, 5 );
464 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
466 wxStaticLine *item18 =
new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
467 item0->Add( item18, 0, wxGROW|wxALL, 5 );
469 wxGridSizer *item19 =
new wxGridSizer( 2, 0, 0 );
471 wxButton *item20 =
new wxButton( parent, ID_HELP, wxT(
"&Help"), wxDefaultPosition, wxDefaultSize, 0 );
472 item19->Add( item20, 0, wxALL, 5 );
474 wxBoxSizer *item21 =
new wxBoxSizer( wxHORIZONTAL );
476 wxButton *item22 =
new wxButton( parent, wxID_OK, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0 );
477 item21->Add( item22, 0, wxALIGN_CENTER|wxALL, 5 );
479 wxButton *item23 =
new wxButton( parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
480 item21->Add( item23, 0, wxALIGN_CENTER|wxALL, 5 );
482 item19->Add( item21, 0, wxALL, 5 );
484 item0->Add( item19, 0, wxGROW, 5 );
488 parent->SetSizer( item0 );
490 item0->SetSizeHints( parent );