mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-06 01:56:28 +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");
|
||||
|
||||
// Game base menu
|
||||
menu_db->Append(5, "New", "Create new database");
|
||||
menu_db->Append(5, "Open", "Open a database");
|
||||
|
||||
// Engine menu
|
||||
menu_engine->Append(6, "New", "Create a new engine configuration");
|
||||
|
@ -53,6 +53,16 @@ MainWindow::MainWindow()
|
|||
|
||||
// Add new game tab by default
|
||||
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) {
|
||||
|
@ -86,6 +96,7 @@ void MainWindow::OnMenuItemClick(wxCommandEvent &event) {
|
|||
} else if (id == 5) {
|
||||
OpenFile();
|
||||
} else if (id == 6) {
|
||||
CloseTabLinkedTo(1);
|
||||
NewEngine();
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +172,16 @@ void MainWindow::OnClose(wxCloseEvent &e) {
|
|||
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() {
|
||||
wxFileDialog openFileDialog(this, _("Open file"), "", "",
|
||||
"PGN files (*.pgn)|*.pgn",
|
||||
|
@ -217,7 +238,6 @@ void MainWindow::OnRefreshTabTitle(wxCommandEvent &event) {
|
|||
|
||||
TabInfos* MainWindow::NewGame(std::shared_ptr<Game> game) {
|
||||
GameTab *gt = new GameTab((wxFrame *)notebook, game);
|
||||
notebook->AddPage(gt, gt->GetLabel());
|
||||
notebook->SetSelection(notebook->GetPageIndex(gt));
|
||||
this->AddPage(gt,gt);
|
||||
return(gt);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ class MainWindow : public MainFrame {
|
|||
void OnCloseTabEvent(wxCommandEvent &event);
|
||||
void OnRefreshEngineList(wxCommandEvent &event);
|
||||
void OnMenuItemClick(wxCommandEvent &event);
|
||||
|
||||
void AddPage(wxWindow* window, TabInfos* infos);
|
||||
void CloseTabLinkedTo(long id);
|
||||
public:
|
||||
MainWindow();
|
||||
void ApplyPreferences();
|
||||
|
|
Loading…
Add table
Reference in a new issue