void CDFFDUseStruct::OnPrev() { // Does the same as OnOK but returns ID_DFFD_PREV to indicate // that the previous sibling should now be edited if (modified_) { if (!check_data()) return; save_data(); } // Save position so sibling node's dialog can be put in the same place pos_ = update_posn(this); CDialog::EndDialog(ID_DFFD_PREV); }
void CDFFDJump::OnNext() { // Does the same as OnOK but returns ID_DFFD_NEXT to indicate // that the next sibling should now be edited if (modified_) { if (!check_data()) return; save_data(); } // Save position so sibling node's dialog can be put in the same place pos_ = update_posn(this); CDialog::EndDialog(ID_DFFD_NEXT); }
void CDFFDJump::OnReplace() { // See if we have a subelement to replace (otherwise we just insert) CXmlTree::CElt curr_elt(pelt_->GetFirstChild()); if (!curr_elt.IsEmpty()) { ASSERT(valid_element_); CString sub_name = get_name(curr_elt); CString mess; if (curr_elt.GetFirstChild().IsEmpty()) { mess.Format("This will replace the contents of %s. " "The existing contents will be deleted.\n\n" "Are you sure you want to do this?", sub_name); } else { mess.Format("This will replace the contents of %s " "and all elements below it. " "The existing contents will be deleted.\n\n" "Are you sure you want to do this?", sub_name); } if (TaskMessageBox("Replacing Element", mess, MB_YESNO) != IDYES) return; pelt_->DeleteChild(curr_elt); // Remove the replaced node from the tree } // Work out where to put the dialog pos_ = update_posn(this); if (first_) orig_ = pos_; CPoint pt = get_posn(this, orig_); int dlg_ret; CXmlTree::CElt ee; switch (ctl_replace_.m_nMenuResult) { case ID_DFFD_INSERT_STRUCT: ee = pelt_->InsertNewChild("struct"); { CDFFDStruct dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetModified(); // Force validation as it is incomplete dlg.SetPosition(pt,orig_); dlg_ret = dlg.DoModal(); } break; case ID_DFFD_INSERT_USE_STRUCT: ee = pelt_->InsertNewChild("use_struct", NULL); { CDFFDUseStruct dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetModified(); // Force validation as it is incomplete dlg.SetPosition(pt,orig_); dlg_ret = dlg.DoModal(); } break; case ID_DFFD_INSERT_FOR: ee = pelt_->InsertNewChild("for"); { CDFFDFor dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetModified(); // Force validation as it is incomplete dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); } break; case ID_DFFD_INSERT_IF: ee = pelt_->InsertNewChild("if"); ee.SetAttr("test", "true"); { CDFFDIf dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetModified(); // Force validation as it is incomplete dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); } break; case ID_DFFD_INSERT_SWITCH: ee = pelt_->InsertNewChild("switch"); { CDFFDSwitch dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetModified(); // Force validation as it is incomplete dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); } break; case ID_DFFD_INSERT_DATA: ee = pelt_->InsertNewChild("data"); ee.SetAttr("type", "none"); { CDFFDData dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetModified(); // Force validation as it is incomplete dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); } break; default: ASSERT(0); } if (dlg_ret == IDCANCEL) { // Restore elts again (remove new element, add back old elt) pelt_->DeleteChild(ee); if (!curr_elt.IsEmpty()) { ASSERT(valid_element_); pelt_->InsertChild(curr_elt, NULL); } return; } modified_ = true; valid_element_ = true; UpdateData(TRUE); elt_name_ = get_name(ee); UpdateData(FALSE); }
void CDFFDJump::OnEdit() { CXmlTree::CElt ee(pelt_->GetFirstChild()); ASSERT(valid_element_ && !ee.IsEmpty()); // Work out where to put the dialog pos_ = update_posn(this); if (first_) orig_ = pos_; CPoint pt = get_posn(this, orig_); // Edit the subelement according to its type int dlg_ret; // Save value returned from dialog in case we need it CString elt_type = ee.GetName(); if (elt_type == "struct") { // Edit the struct element node CDFFDStruct dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); if (dlg_ret != IDCANCEL && dlg.IsModified()) modified_ = true; } else if (elt_type == "use_struct") { // Edit the struct element node CDFFDUseStruct dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); if (dlg_ret != IDCANCEL && dlg.IsModified()) modified_ = true; } else if (elt_type == "for") { // Edit the for element node CDFFDFor dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); if (dlg_ret != IDCANCEL && dlg.IsModified()) modified_ = true; } else if (elt_type == "if") { // Edit the if element node CDFFDIf dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); if (dlg_ret != IDCANCEL && dlg.IsModified()) modified_ = true; } else if (elt_type == "switch") { // Edit the switch element node CDFFDSwitch dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); if (dlg_ret != IDCANCEL && dlg.IsModified()) modified_ = true; } else if (elt_type == "data") { // Edit the data element node CDFFDData dlg(&ee, CHexEditDoc::DF_JUMP, this); dlg.SetPosition(pt, orig_); dlg_ret = dlg.DoModal(); if (dlg_ret != IDCANCEL && dlg.IsModified()) modified_ = true; } else ASSERT(0); UpdateData(TRUE); elt_name_ = get_name(ee); UpdateData(FALSE); }