mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-19 04:09:41 +00:00
Improve tab management
This commit is contained in:
parent
d298c59206
commit
1293b59ed5
6 changed files with 31 additions and 30 deletions
|
@ -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"), "", "",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue