| 547 | } |
| 548 | |
| 549 | void LabelDialog::OnInsert(wxCommandEvent &event) |
| 550 | { |
| 551 | int cnt = mData.size(); |
| 552 | int row = 0; |
| 553 | int index = 0; |
| 554 | |
| 555 | // Make sure the edit control isn't active before inserting any rows |
| 556 | if (mGrid->IsCellEditControlShown()) { |
| 557 | mGrid->HideCellEditControl(); |
| 558 | } |
| 559 | |
| 560 | // Attempt to guess which track the label should reside on |
| 561 | if (cnt > 0) { |
| 562 | row = mGrid->GetGridCursorRow(); |
| 563 | if (row > 0 && row >= cnt) { |
| 564 | index = make_iterator_range( mTrackNames ) |
| 565 | .index( mGrid->GetCellValue(row - 1, Col_Track) ); |
| 566 | } |
| 567 | else { |
| 568 | index = make_iterator_range( mTrackNames ) |
| 569 | .index( mGrid->GetCellValue(row, Col_Track) ); |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | // Insert NEW label before or after the current row |
| 574 | if (event.GetId() == ID_INSERTA && row < cnt) { |
| 575 | row++; |
| 576 | } |
| 577 | mData.insert(mData.begin() + row, RowData(index, wxT(""), SelectedRegion())); |
| 578 | |
| 579 | // Repopulate the grid |
| 580 | TransferDataToWindow(); |
| 581 | |
| 582 | // Reposition cursor to NEW row/col and put user into edit mode to |
| 583 | // set the label name |
| 584 | mGrid->SetGridCursor(row, Col_Label); |
| 585 | mGrid->EnableCellEditControl(true); |
| 586 | mGrid->ShowCellEditControl(); |
| 587 | } |
| 588 | |
| 589 | void LabelDialog::OnRemove(wxCommandEvent & WXUNUSED(event)) |
| 590 | { |
nothing calls this directly
no test coverage detected