diff options
| author | Loic Guegan <manzerbredes@mailbox.org> | 2022-12-25 09:57:34 +0100 |
|---|---|---|
| committer | Loic Guegan <manzerbredes@mailbox.org> | 2022-12-25 09:57:34 +0100 |
| commit | 1293b59ed55423671dc204d3cb09822c9c599e55 (patch) | |
| tree | dc044f6de4aadd5e7ded4bf0447b8ab4dd33708e /src/MainWindow.cpp | |
| parent | d298c59206ccb8c3e511fad9884e1cb0bd98b793 (diff) | |
Improve tab management
Diffstat (limited to 'src/MainWindow.cpp')
| -rw-r--r-- | src/MainWindow.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index deb2b8b..53403ba 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -73,8 +73,19 @@ void MainWindow::OnCloseTabEvent(wxCommandEvent &event) { } void MainWindow::OnCloseTabLinkedTo(wxCommandEvent &event){ - TabInfos *infos=(TabInfos*)event.GetClientData(); - CloseTabLinkedTo(infos->id); + TabInfos *infosEvent=(TabInfos*)event.GetClientData(); + // Now close all tabs in the notebook related to the one in the event + int i=0; + while(i<notebook->GetPageCount()){ + wxWindow *page=notebook->GetPage(i); + TabInfos* infos=(TabInfos*)page->GetClientData(); + if(infos->is_linked && infos->linked_id==infosEvent->id){ + notebook->DeletePage(i); // Remove page + i=0; // Restart to page 0 since notebook updated (we just remove one page) + } + else + i++; + } } void MainWindow::OnMenuItemClick(wxCommandEvent &event) { @@ -104,7 +115,6 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) { } else if (id == 5) { OpenFile(); } else if (id == 6) { - CloseTabLinkedTo(1); NewEngine(); } } @@ -179,20 +189,6 @@ void MainWindow::OnClose(wxCloseEvent &e) { e.Skip(); } -void MainWindow::CloseTabLinkedTo(long id){ - int i=0; - while(i<notebook->GetPageCount()){ - wxWindow *page=notebook->GetPage(i); - TabInfos* infos=(TabInfos*)page->GetClientData(); - if(infos->is_linked && infos->linked_id==id){ - notebook->DeletePage(i); - i=0; // Restart to page 0 since notebook updated - } - else { - i++; - } - } -} void MainWindow::OpenFile() { wxFileDialog openFileDialog(this, _("Open file"), "", "", |
