35 #include <wx/valgen.h>
36 #include <boost/format.hpp>
126 const std::
string& path) :
130 wxDefaultSize, wxRESIZE_BORDER),
131 operation_(op), name_(_T("")), module_(module), path_(path),
132 operationWasCreatedHere_(
false) {
134 createContents(
this,
true,
true);
136 affectedByList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_AFFECTED_BY));
137 affectsList_ =
dynamic_cast<wxListCtrl*
>(
FindWindow(ID_AFFECTS));
139 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_INPUT_OPERANDS));
141 dynamic_cast<wxListCtrl*
>(
FindWindow(ID_OUTPUT_OPERANDS));
143 dynamic_cast<wxComboBox*
>(
FindWindow(ID_OPERATION_AFFECTED_BY));
145 dynamic_cast<wxComboBox*
>(
FindWindow(ID_OPERATION_AFFECTS));
146 readMemoryCB_ =
dynamic_cast<wxCheckBox*
>(
FindWindow(ID_READS_MEMORY));
147 writeMemoryCB_ =
dynamic_cast<wxCheckBox*
>(
FindWindow(ID_WRITES_MEMORY));
148 canTrapCB_ =
dynamic_cast<wxCheckBox*
>(
FindWindow(ID_CAN_TRAP));
150 dynamic_cast<wxCheckBox*
>(
FindWindow(ID_HAS_SIDE_EFFECTS));
152 dynamic_cast<wxCheckBox*
>(
FindWindow(ID_CLOCKED));
154 editDescription_ =
dynamic_cast<wxTextCtrl*
>(
FindWindow(ID_EDIT_DESCRIPTION));
157 wxTextValidator(wxFILTER_ASCII, &name_));
160 wxGenericValidator(&readMemory_));
163 wxGenericValidator(&writeMemory_));
165 FindWindow(ID_CAN_TRAP)->SetValidator(wxGenericValidator(&canTrap_));
167 FindWindow(ID_HAS_SIDE_EFFECTS)->SetValidator(
168 wxGenericValidator(&hasSideEffects_));
171 wxGenericValidator(&clocked_));
176 if (operation_ != NULL) {
177 for (
int i = 1; i <= operation_->numberOfInputs(); i++) {
179 inputOperands_.push_back(op);
182 for (
int i = operation_->numberOfInputs() + 1;
183 i <= operation_->numberOfInputs() + operation_->numberOfOutputs(); i++) {
186 outputOperands_.push_back(op);
189 for (
int i = 0; i < operation_->affectsCount(); i++) {
190 affects_.push_back(operation_->affects(i));
193 for (
int i = 0; i < operation_->affectedByCount(); i++) {
194 affectedBy_.push_back(operation_->affectedBy(i));
198 operationWasCreatedHere_ =
true;
201 orig_ = operation_->saveState();
436 return wxWindow::TransferDataToWindow();
490 for (
unsigned int i = 0; i <
affectedBy_.size(); i++) {
495 for (
unsigned int i = 0; i <
affects_.size(); i++) {
506 for (
int j = 0; j < modules; j++) {
514 for (
int k = 0; k < operations; k++) {
640 format fmt = texts.
text(
659 for (
size_t i = 0; i < toBeDeleted.size(); i++) {
662 if (*it == toBeDeleted[i]) {
682 format fmt = texts.
text(
701 for (
size_t i = 0; i < toBeDeleted.size(); i++) {
702 vector<string>::iterator it =
affects_.begin();
704 if (*it == toBeDeleted[i]) {
725 if (dialog.ShowModal() == wxID_OK) {
783 if (dialog.ShowModal() == wxID_OK) {
883 string editor =
options->editor();
892 string cmd = editor +
" " + code;
898 size_t pos = code.find_last_of(
".");
913 string cmd = editor +
" " + code;
950 std::vector<Operand*>& ops,
956 ops[
id - 2] = ops[
id - 1];
959 item = list->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
961 item - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
962 list->SetItemState(item, 0, wxLIST_STATE_SELECTED);
975 std::vector<Operand*>& ops,
979 if (
static_cast<unsigned int>(
id) != ops.size()) {
981 ops[
id - 1] = ops[id];
984 item = list->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
986 item + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
987 list->SetItemState(item, 0, wxLIST_STATE_SELECTED);
999 vector<string> selected;
1002 item = listCtrl->GetNextItem(
1003 item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
1010 listCtrl->GetItem(info);
1026 TransferDataFromWindow();
1030 if (newOpDag && opName ==
"") {
1031 opName =
"__UnnamedNewOperation";
1067 if (*orig != *mod) {
1068 format fmt = texts.
text(
1071 int ans = dialog.ShowModal();
1072 if (ans == wxID_YES) {
1084 if (ans == wxID_YES) {
1087 }
else if (ans == wxID_NO) {
1088 EndModal(wxID_CANCEL);
1110 std::string description(
"");
1116 #if wxCHECK_VERSION(2, 6, 0)
1117 std::string stdTemp(wxTemp.mb_str());
1119 std::string stdTemp(wxTemp.c_str());
1122 stdTemp = stdTemp +
"\n";
1123 description += stdTemp;
1147 for (
unsigned int i = 0; i <
affectedBy_.size(); i++) {
1151 affectedBy->
addChild(affectedByChild);
1158 for (
unsigned int i = 0; i <
affects_.size(); i++) {
1220 for (
int j = 0; j < state->
childCount(); j++) {
1225 while (k < canSwap->childCount()) {
1230 bool deleted =
false;
1231 for (
size_t r = 0; r < deletedOperands.size(); r++) {
1232 if (deletedOperands[r] == idString) {
1243 for (
size_t r = 0; r < deletedOperands.size(); r++) {
1276 wxBoxSizer *item0 =
new wxBoxSizer(wxVERTICAL);
1278 wxGridSizer *item1 =
new wxGridSizer(2, 0, 0);
1280 wxBoxSizer *opHeaderSizer =
new wxBoxSizer(wxHORIZONTAL);
1282 wxBoxSizer *nameSizer =
new wxBoxSizer(wxHORIZONTAL);
1284 wxStaticText *item2 =
new wxStaticText(parent,
ID_TEXT_NAME, wxT(
"Name:"), wxDefaultPosition, wxDefaultSize, 0);
1285 nameSizer->Add(item2, 0, wxALL, 5);
1287 wxTextCtrl *item3 =
new wxTextCtrl(parent,
ID_NAME, wxT(
""), wxDefaultPosition, wxSize(200,-1), 0);
1288 nameSizer->Add(item3, 0, wxALL, 5);
1290 wxStaticBox *opProperties =
new wxStaticBox(parent, -1, wxT(
"Operation properties"));
1291 wxStaticBoxSizer *opPropertiesContainer =
new wxStaticBoxSizer(opProperties, wxVERTICAL);
1293 opPropertiesContainer->Add(nameSizer, 0, wxGROW, 5);
1294 opPropertiesContainer->Add(item1, 0, wxGROW, 5);
1296 wxStaticBox *opDescription =
new wxStaticBox(parent, -1, wxT(
"Operation description"));
1297 wxTextCtrl* editDescription =
new wxTextCtrl(parent,
ID_EDIT_DESCRIPTION, wxT(
""), wxDefaultPosition, wxSize(250,50), wxTE_MULTILINE);
1298 wxStaticBoxSizer *opDescriptionContainer =
new wxStaticBoxSizer(opDescription, wxHORIZONTAL);
1300 opDescriptionContainer->Add(editDescription, 0, wxALL|wxEXPAND, 5);
1302 opHeaderSizer->Add(opPropertiesContainer, 0, wxALL, 5);
1303 opHeaderSizer->Add(opDescriptionContainer, 0, wxALL|wxGROW, 5);
1305 wxCheckBox *item4 =
new wxCheckBox(parent,
ID_READS_MEMORY, wxT(
"Reads memory"), wxDefaultPosition, wxDefaultSize, 0);
1306 item1->Add(item4, 0, wxALL, 5);
1308 wxCheckBox *item5 =
new wxCheckBox(parent,
ID_WRITES_MEMORY, wxT(
"Writes memory"), wxDefaultPosition, wxDefaultSize, 0);
1309 item1->Add(item5, 0, wxALL, 5);
1311 wxCheckBox *item6 =
new wxCheckBox(parent,
ID_CAN_TRAP, wxT(
"Can trap"), wxDefaultPosition, wxDefaultSize, 0);
1312 item1->Add(item6, 0, wxALL, 5);
1314 wxCheckBox *item7 =
new wxCheckBox(parent,
ID_HAS_SIDE_EFFECTS, wxT(
"Has side effects"), wxDefaultPosition, wxDefaultSize, 0);
1315 item1->Add(item7, 0, wxALL, 5);
1317 wxCheckBox *clocked =
new wxCheckBox(parent,
ID_CLOCKED, wxT(
"Clocked"), wxDefaultPosition, wxDefaultSize, 0);
1318 item1->Add(clocked, 0, wxALL, 5);
1320 item0->Add(opHeaderSizer, 0, wxALIGN_CENTER|wxALL, 5);
1322 wxGridSizer *item8 =
new wxGridSizer(2, 0, 0);
1324 wxStaticBox *item10 =
new wxStaticBox(parent, -1, wxT(
"Affected by"));
1325 wxStaticBoxSizer *item9 =
new wxStaticBoxSizer(item10, wxVERTICAL);
1328 wxListCtrl *item11 =
new wxListCtrl(parent,
ID_AFFECTED_BY, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER);
1329 item9->Add(item11, 0, wxGROW|wxALL, 10);
1331 wxBoxSizer *item12 =
new wxBoxSizer(wxHORIZONTAL);
1337 wxComboBox *item13 =
new wxComboBox(parent,
ID_OPERATION_AFFECTED_BY, wxT(
""), wxDefaultPosition, wxSize(100,-1), 1, strs13, wxCB_SORT);
1338 item12->Add(item13, 0, wxALIGN_CENTER|wxALL, 5);
1340 wxButton *item14 =
new wxButton(parent,
ID_AFFECTED_ADD_BUTTON, wxT(
"Add"), wxDefaultPosition, wxDefaultSize, 0);
1341 item12->Add(item14, 0, wxALIGN_CENTER|wxALL, 5);
1344 item12->Add(item15, 0, wxALIGN_CENTER|wxALL, 5);
1346 item9->Add(item12, 0, wxGROW|wxALL, 5);
1348 item8->Add(item9, 0, wxGROW|wxALL, 5);
1351 wxStaticBox *item17 =
new wxStaticBox(parent, -1, wxT(
"Input operands"));
1352 wxStaticBoxSizer *item16 =
new wxStaticBoxSizer(item17, wxVERTICAL);
1355 wxBoxSizer *item18 =
new wxBoxSizer(wxHORIZONTAL);
1357 wxListCtrl *item19 =
new wxListCtrl(parent,
ID_INPUT_OPERANDS, wxDefaultPosition, wxSize(335,120), wxLC_REPORT|wxSUNKEN_BORDER);
1358 item18->Add(item19, 0, wxALIGN_CENTER|wxALL, 5);
1361 wxBoxSizer *item20 =
new wxBoxSizer(wxVERTICAL);
1365 item20->Add(item21, 0, wxALL, 5);
1368 item20->Add(item22, 0, wxALIGN_CENTER|wxALL, 5);
1370 item18->Add(item20, 0, wxALIGN_CENTER|wxALL, 5);
1372 item16->Add(item18, 0, wxGROW|wxALL, 5);
1374 wxBoxSizer *item23 =
new wxBoxSizer(wxHORIZONTAL);
1376 wxButton *item24 =
new wxButton(parent,
ID_INPUT_ADD_BUTTON, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0);
1377 item23->Add(item24, 0, wxALIGN_CENTER|wxALL, 5);
1379 wxButton *item25 =
new wxButton(parent,
ID_INPUT_MODIFY_BUTTON, wxT(
"Modify..."), wxDefaultPosition, wxDefaultSize, 0);
1380 item23->Add(item25, 0, wxALIGN_CENTER|wxALL, 5);
1382 wxButton *item26 =
new wxButton(parent,
ID_INPUT_DELETE_BUTTON, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0);
1383 item23->Add(item26, 0, wxALIGN_CENTER|wxALL, 5);
1385 item16->Add(item23, 0, wxALIGN_CENTER|wxALL, 5);
1387 item8->Add(item16, 0, wxGROW|wxALL, 5);
1389 wxStaticBox *item28 =
new wxStaticBox(parent, -1, wxT(
"Affects"));
1390 wxStaticBoxSizer *item27 =
new wxStaticBoxSizer(item28, wxVERTICAL);
1393 wxListCtrl *item29 =
new wxListCtrl(parent,
ID_AFFECTS, wxDefaultPosition, wxSize(160,120), wxLC_REPORT|wxSUNKEN_BORDER);
1394 item27->Add(item29, 0, wxGROW|wxALL, 10);
1396 wxBoxSizer *item30 =
new wxBoxSizer(wxHORIZONTAL);
1402 wxComboBox *item31 =
new wxComboBox(parent,
ID_OPERATION_AFFECTS, wxT(
""), wxDefaultPosition, wxSize(100,-1), 1, strs31, wxCB_SORT);
1403 item30->Add(item31, 0, wxALIGN_CENTER|wxALL, 5);
1405 wxButton *item32 =
new wxButton(parent,
ID_AFFECTS_ADD_BUTTON, wxT(
"Add"), wxDefaultPosition, wxDefaultSize, 0);
1406 item30->Add(item32, 0, wxALIGN_CENTER|wxALL, 5);
1408 wxButton *item33 =
new wxButton(parent,
ID_AFFECTS_DELETE_BUTTON, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0);
1409 item30->Add(item33, 0, wxALIGN_CENTER|wxALL, 5);
1411 item27->Add(item30, 0, wxGROW|wxALL, 5);
1413 item8->Add(item27, 0, wxGROW|wxALL, 5);
1415 wxStaticBox *item35 =
new wxStaticBox(parent, -1, wxT(
"Output operands"));
1416 wxStaticBoxSizer *item34 =
new wxStaticBoxSizer(item35, wxVERTICAL);
1419 wxBoxSizer *item36 =
new wxBoxSizer(wxHORIZONTAL);
1421 wxListCtrl *item37 =
new wxListCtrl(parent,
ID_OUTPUT_OPERANDS, wxDefaultPosition, wxSize(335,120), wxLC_REPORT|wxSUNKEN_BORDER);
1422 item36->Add(item37, 0, wxALIGN_CENTER|wxALL, 5);
1424 wxBoxSizer *item38 =
new wxBoxSizer(wxVERTICAL);
1427 item38->Add(item39, 0, wxALIGN_CENTER|wxALL, 5);
1430 item38->Add(item40, 0, wxALIGN_CENTER|wxALL, 5);
1432 item36->Add(item38, 0, wxALIGN_CENTER|wxALL, 5);
1434 item34->Add(item36, 0, wxGROW|wxALL, 5);
1436 wxBoxSizer *item41 =
new wxBoxSizer(wxHORIZONTAL);
1438 wxButton *item42 =
new wxButton(parent,
ID_OUTPUT_ADD_BUTTON, wxT(
"Add..."), wxDefaultPosition, wxDefaultSize, 0);
1439 item41->Add(item42, 0, wxALIGN_CENTER|wxALL, 5);
1441 wxButton *item43 =
new wxButton(parent,
ID_OUTPUT_MODIFY_BUTTON, wxT(
"Modify..."), wxDefaultPosition, wxDefaultSize, 0);
1442 item41->Add(item43, 0, wxALIGN_CENTER|wxALL, 5);
1444 wxButton *item44 =
new wxButton(parent,
ID_OUTPUT_DELETE_BUTTON, wxT(
"Delete"), wxDefaultPosition, wxDefaultSize, 0);
1445 item41->Add(item44, 0, wxALIGN_CENTER|wxALL, 5);
1447 item34->Add(item41, 0, wxALIGN_CENTER|wxALL, 5);
1449 item8->Add(item34, 0, wxALIGN_CENTER|wxALL, 5);
1451 wxBoxSizer *pageSizer =
new wxBoxSizer(wxHORIZONTAL);
1452 pageSizer->Add(item8, 0, wxALL, 5);
1454 item0->Add(pageSizer, 0, wxALIGN_CENTER|wxALL, 5);
1456 wxGridSizer *item45 =
new wxGridSizer(2, 0, 0);
1458 wxBoxSizer *item46 =
new wxBoxSizer(wxHORIZONTAL);
1460 wxStaticText *item47 = NULL;
1462 item47 =
new wxStaticText(parent,
ID_TEXT_OPEN, _T(
"Operation behavior module defined."), wxDefaultPosition, wxDefaultSize, 0);
1464 item47 =
new wxStaticText(parent,
ID_TEXT_OPEN, wxT(
"Operation behavior module not defined."), wxDefaultPosition, wxDefaultSize, 0);
1466 item46->Add(item47, 0, wxALIGN_CENTER|wxALL, 5);
1468 wxButton *item48 =
new wxButton(parent,
ID_OPEN_BUTTON, wxT(
"Open"), wxDefaultPosition, wxDefaultSize, 0);
1469 item46->Add(item48, 0, wxALIGN_CENTER|wxALL, 5);
1471 wxButton *OpenDAG =
new wxButton(parent,
ID_DAG_BUTTON, wxT(
"Open DAG"), wxDefaultPosition, wxDefaultSize, 0);
1472 item46->Add(OpenDAG, 0, wxALIGN_CENTER|wxALL, 5);
1474 item45->Add(item46, 0, wxALL, 5);
1476 wxBoxSizer *item49 =
new wxBoxSizer(wxHORIZONTAL);
1478 wxButton *item50 =
new wxButton(parent,
ID_OK_BUTTON, wxT(
"&OK"), wxDefaultPosition, wxDefaultSize, 0);
1479 item49->Add(item50, 0, wxALIGN_CENTER|wxALL, 5);
1481 wxButton *item51 =
new wxButton(parent, wxID_CANCEL, wxT(
"&Cancel"), wxDefaultPosition, wxDefaultSize, 0);
1482 item49->Add(item51, 0, wxALIGN_CENTER|wxALL, 5);
1484 item45->Add(item49, 0, wxALL, 5);
1486 item0->Add(item45, 0, wxGROW|wxALL, 5);
1490 parent->SetSizer(item0);
1492 item0->SetSizeHints(parent);
1511 static const char *xpm_data[] = {
1548 wxBitmap bitmap(xpm_data);
1554 static const char *xpm_data[] = {
1591 wxBitmap bitmap(xpm_data);
1594 return wxNullBitmap;