From 1293b59ed55423671dc204d3cb09822c9c599e55 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 25 Dec 2022 09:57:34 +0100 Subject: Improve tab management --- src/MainWindow.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src/MainWindow.cpp') 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(iGetPageCount()){ + 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(iGetPageCount()){ - 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"), "", "", -- cgit v1.2.3