mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Improve page management
This commit is contained in:
parent
2d9730e216
commit
418b2e7f60
2 changed files with 25 additions and 4 deletions
|
@ -33,7 +33,7 @@ MainWindow::MainWindow()
|
||||||
menu_game->Append(3, "New from FEN", "Create new game using FEN");
|
menu_game->Append(3, "New from FEN", "Create new game using FEN");
|
||||||
|
|
||||||
// Game base menu
|
// Game base menu
|
||||||
menu_db->Append(5, "New", "Create new database");
|
menu_db->Append(5, "Open", "Open a database");
|
||||||
|
|
||||||
// Engine menu
|
// Engine menu
|
||||||
menu_engine->Append(6, "New", "Create a new engine configuration");
|
menu_engine->Append(6, "New", "Create a new engine configuration");
|
||||||
|
@ -53,6 +53,16 @@ MainWindow::MainWindow()
|
||||||
|
|
||||||
// Add new game tab by default
|
// Add new game tab by default
|
||||||
NewGame(std::shared_ptr<Game>(new Game()));
|
NewGame(std::shared_ptr<Game>(new Game()));
|
||||||
|
|
||||||
|
// Temporary TO REMOVE JUST FOR TESTS:
|
||||||
|
//BaseTab *bt = new BaseTab((wxFrame *)notebook, "/home/loic/Downloads/PGN.pgn");
|
||||||
|
//this->AddPage(bt,bt);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::AddPage(wxWindow* window, TabInfos* infos){
|
||||||
|
window->SetClientData(infos);
|
||||||
|
notebook->AddPage(window, window->GetLabel());
|
||||||
|
notebook->SetSelection(notebook->GetPageIndex(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
|
void MainWindow::OnCloseTabEvent(wxCommandEvent &event) {
|
||||||
|
@ -86,6 +96,7 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
|
||||||
} else if (id == 5) {
|
} else if (id == 5) {
|
||||||
OpenFile();
|
OpenFile();
|
||||||
} else if (id == 6) {
|
} else if (id == 6) {
|
||||||
|
CloseTabLinkedTo(1);
|
||||||
NewEngine();
|
NewEngine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,6 +172,16 @@ void MainWindow::OnClose(wxCloseEvent &e) {
|
||||||
e.Skip();
|
e.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::CloseTabLinkedTo(long id){
|
||||||
|
for(int i=0;i<notebook->GetPageCount();i++){
|
||||||
|
wxWindow *page=notebook->GetPage(i);
|
||||||
|
TabInfos* infos=(TabInfos*)page->GetClientData();
|
||||||
|
if(infos->is_linked && infos->linked_id==id){
|
||||||
|
notebook->DeletePage(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::OpenFile() {
|
void MainWindow::OpenFile() {
|
||||||
wxFileDialog openFileDialog(this, _("Open file"), "", "",
|
wxFileDialog openFileDialog(this, _("Open file"), "", "",
|
||||||
"PGN files (*.pgn)|*.pgn",
|
"PGN files (*.pgn)|*.pgn",
|
||||||
|
@ -217,7 +238,6 @@ void MainWindow::OnRefreshTabTitle(wxCommandEvent &event) {
|
||||||
|
|
||||||
TabInfos* MainWindow::NewGame(std::shared_ptr<Game> game) {
|
TabInfos* MainWindow::NewGame(std::shared_ptr<Game> game) {
|
||||||
GameTab *gt = new GameTab((wxFrame *)notebook, game);
|
GameTab *gt = new GameTab((wxFrame *)notebook, game);
|
||||||
notebook->AddPage(gt, gt->GetLabel());
|
this->AddPage(gt,gt);
|
||||||
notebook->SetSelection(notebook->GetPageIndex(gt));
|
|
||||||
return(gt);
|
return(gt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,8 @@ class MainWindow : public MainFrame {
|
||||||
void OnCloseTabEvent(wxCommandEvent &event);
|
void OnCloseTabEvent(wxCommandEvent &event);
|
||||||
void OnRefreshEngineList(wxCommandEvent &event);
|
void OnRefreshEngineList(wxCommandEvent &event);
|
||||||
void OnMenuItemClick(wxCommandEvent &event);
|
void OnMenuItemClick(wxCommandEvent &event);
|
||||||
|
void AddPage(wxWindow* window, TabInfos* infos);
|
||||||
|
void CloseTabLinkedTo(long id);
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
void ApplyPreferences();
|
void ApplyPreferences();
|
||||||
|
|
Loading…
Add table
Reference in a new issue